smartmontools  SVN Rev 4048
Utility to control and monitor storage systems with "S.M.A.R.T."
dev_areca.h
Go to the documentation of this file.
1 /*
2  * dev_areca.h
3  *
4  * Home page of code is: http://smartmontools.sourceforge.net
5  *
6  * Copyright (C) 2012 Hank Wu <hank@areca.com.tw>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * You should have received a copy of the GNU General Public License
14  * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17 
18 #ifndef DEV_ARECA_H
19 #define DEV_ARECA_H
20 
21 #define DEV_ARECA_H_CVSID "$Id: dev_areca.h 3854 2013-09-12 05:36:20Z chrfranke $"
22 
23 /////////////////////////////////////////////////////////////////////////////
24 /// Areca RAID support
25 
26 /* GENERIC ARECA IO CONTROL CODE*/
28 {
35 };
36 
37 #define ARECA_SIG_STR "ARCMSR"
38 
39 #if defined(_WIN32) || defined(__CYGWIN__)
40 #define ARCMSR_IOCTL_READ_RQBUFFER 0x90002004
41 #define ARCMSR_IOCTL_WRITE_WQBUFFER 0x90002008
42 #define ARCMSR_IOCTL_CLEAR_RQBUFFER 0x9000200C
43 #define ARCMSR_IOCTL_CLEAR_WQBUFFER 0x90002010
44 #define ARCMSR_IOCTL_RETURN_CODE_3F 0x90002018
45 #elif defined(__linux__)
46 /*DeviceType*/
47 #define ARECA_SATA_RAID 0x90000000
48 /*FunctionCode*/
49 #define FUNCTION_READ_RQBUFFER 0x0801
50 #define FUNCTION_WRITE_WQBUFFER 0x0802
51 #define FUNCTION_CLEAR_RQBUFFER 0x0803
52 #define FUNCTION_CLEAR_WQBUFFER 0x0804
53 #define FUNCTION_RETURN_CODE_3F 0x0806
54 
55 /* ARECA IO CONTROL CODE*/
56 #define ARCMSR_IOCTL_READ_RQBUFFER (ARECA_SATA_RAID | FUNCTION_READ_RQBUFFER)
57 #define ARCMSR_IOCTL_WRITE_WQBUFFER (ARECA_SATA_RAID | FUNCTION_WRITE_WQBUFFER)
58 #define ARCMSR_IOCTL_CLEAR_RQBUFFER (ARECA_SATA_RAID | FUNCTION_CLEAR_RQBUFFER)
59 #define ARCMSR_IOCTL_CLEAR_WQBUFFER (ARECA_SATA_RAID | FUNCTION_CLEAR_WQBUFFER)
60 #define ARCMSR_IOCTL_RETURN_CODE_3F (ARECA_SATA_RAID | FUNCTION_RETURN_CODE_3F)
61 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
62 #include <sys/ioctl.h> // _IOWR
63 
64 /*FunctionCode*/
65 #define FUNCTION_READ_RQBUFFER 0x0801
66 #define FUNCTION_WRITE_WQBUFFER 0x0802
67 #define FUNCTION_CLEAR_RQBUFFER 0x0803
68 #define FUNCTION_CLEAR_WQBUFFER 0x0804
69 #define FUNCTION_RETURN_CODE_3F 0x0806
70 
71 /* ARECA IO CONTROL CODE*/
72 #define ARCMSR_IOCTL_READ_RQBUFFER _IOWR('F', FUNCTION_READ_RQBUFFER, sSRB_BUFFER)
73 #define ARCMSR_IOCTL_WRITE_WQBUFFER _IOWR('F', FUNCTION_WRITE_WQBUFFER, sSRB_BUFFER)
74 #define ARCMSR_IOCTL_CLEAR_RQBUFFER _IOWR('F', FUNCTION_CLEAR_RQBUFFER, sSRB_BUFFER)
75 #define ARCMSR_IOCTL_CLEAR_WQBUFFER _IOWR('F', FUNCTION_CLEAR_WQBUFFER, sSRB_BUFFER)
76 #define ARCMSR_IOCTL_RETURN_CODE_3F _IOWR('F', FUNCTION_RETURN_CODE_3F, sSRB_BUFFER)
77 #endif
78 
79 
80 // The SRB_IO_CONTROL & SRB_BUFFER structures are used to communicate(to/from) to areca driver
81 typedef struct _ARCMSR_IO_HDR
82 {
83  unsigned int HeaderLength;
84  unsigned char Signature[8];
85  unsigned int Timeout;
86  unsigned int ControlCode;
87  unsigned int ReturnCode;
88  unsigned int Length;
90 
91 typedef struct _SRB_BUFFER
92 {
94  unsigned char ioctldatabuffer[1032]; // the buffer to put the command data to/from firmware
95 } sSRB_BUFFER;
96 
98 virtual public smart_device
99 {
100 public:
101  generic_areca_device(smart_interface * intf, const char * dev_name, int disknum, int encnum = 1);
102  ~generic_areca_device() throw();
103 
104  /////////////////////////////////////////////////////////////////////
105  // OS-dependent functions
106  virtual bool arcmsr_lock() = 0;
107  virtual bool arcmsr_unlock() = 0;
108  virtual int arcmsr_do_scsi_io(struct scsi_cmnd_io * iop) = 0;
109 
110  /////////////////////////////////////////////////////////////////////
111  // OS-independent functions
112  virtual int arcmsr_command_handler(unsigned long arcmsr_cmd, unsigned char *data, int data_len);
113  virtual int arcmsr_ui_handler(unsigned char *areca_packet, int areca_packet_len, unsigned char *result);
114  virtual bool arcmsr_probe();
115  virtual int arcmsr_get_dev_type();
116  virtual int arcmsr_get_controller_type();
117  virtual bool arcmsr_scsi_pass_through(scsi_cmnd_io * iop);
118  virtual bool arcmsr_ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out);
119 
120 protected:
122  {
123  }
124 
125  void set_disknum(int disknum)
126  {m_disknum = disknum;}
127 
128  void set_encnum(int encnum)
129  {m_encnum = encnum;}
130 
132  {return m_disknum;}
133 
135  {return m_encnum;}
136 
137 private:
138  int m_disknum; ///< Disk number.
139  int m_encnum; ///< Enclosure number.
140  };
141 
142 // SATA(ATA) device behind Areca RAID Controller
144 : public ata_device,
145  public generic_areca_device
146 {
147 public:
148  areca_ata_device(smart_interface * intf, const char * dev_name, int disknum, int encnum = 1);
149  ~areca_ata_device() throw();
150  bool arcmsr_lock() { return true; }
151  bool arcmsr_unlock() { return true; }
152  int arcmsr_do_scsi_io(struct scsi_cmnd_io * /* iop */)
153  {
154  return -1;
155  }
156 protected:
158  {
159  }
160  virtual bool ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out);
161 };
162 
163 // SAS(SCSI) device behind Areca RAID Controller
165 : public scsi_device,
166  public generic_areca_device
167 {
168 public:
169  areca_scsi_device(smart_interface * intf, const char * dev_name, int disknum, int encnum = 1);
170  ~areca_scsi_device() throw();
171  bool arcmsr_lock() { return true; }
172  bool arcmsr_unlock() { return true; }
173  int arcmsr_do_scsi_io(struct scsi_cmnd_io * /* iop */)
174  {
175  return -1;
176  }
177 protected:
179  {
180  }
181  virtual bool scsi_pass_through(scsi_cmnd_io * iop);
182 };
183 
184 #endif
virtual int arcmsr_ui_handler(unsigned char *areca_packet, int areca_packet_len, unsigned char *result)
Definition: dev_areca.cpp:278
virtual bool arcmsr_scsi_pass_through(scsi_cmnd_io *iop)
Definition: dev_areca.cpp:537
void set_disknum(int disknum)
Definition: dev_areca.h:125
virtual int arcmsr_command_handler(unsigned long arcmsr_cmd, unsigned char *data, int data_len)
Definition: dev_areca.cpp:115
unsigned int HeaderLength
Definition: dev_areca.h:83
bool arcmsr_lock()
Definition: dev_areca.h:150
unsigned char ioctldatabuffer[1032]
Definition: dev_areca.h:94
virtual int arcmsr_get_dev_type()
Definition: dev_areca.cpp:350
virtual bool arcmsr_lock()=0
virtual bool arcmsr_unlock()=0
unsigned char Signature[8]
Definition: dev_areca.h:84
ptr_t data
Definition: megaraid.h:94
virtual bool scsi_pass_through(scsi_cmnd_io *iop)
SCSI pass through.
Definition: dev_areca.cpp:696
bool arcmsr_lock()
Definition: dev_areca.h:171
The platform interface abstraction.
virtual int arcmsr_do_scsi_io(struct scsi_cmnd_io *iop)=0
struct _SRB_BUFFER sSRB_BUFFER
_GENERIC_ARCMSR_CMDS
Areca RAID support.
Definition: dev_areca.h:27
int m_encnum
Enclosure number.
Definition: dev_areca.h:139
virtual bool ata_pass_through(const ata_cmd_in &in, ata_cmd_out &out)
ATA pass through.
Definition: dev_areca.cpp:668
void set_encnum(int encnum)
Definition: dev_areca.h:128
unsigned int ControlCode
Definition: dev_areca.h:86
SCSI device access.
virtual bool arcmsr_probe()
Definition: dev_areca.cpp:264
bool arcmsr_unlock()
Definition: dev_areca.h:172
Base class for all devices.
Definition: dev_interface.h:38
ATA device access.
bool arcmsr_unlock()
Definition: dev_areca.h:151
sARCMSR_IO_HDR srbioctl
Definition: dev_areca.h:93
unsigned int Length
Definition: dev_areca.h:88
int m_disknum
Disk number.
Definition: dev_areca.h:138
int arcmsr_do_scsi_io(struct scsi_cmnd_io *)
Definition: dev_areca.h:173
ATA pass through input parameters.
unsigned int ReturnCode
Definition: dev_areca.h:87
unsigned int Timeout
Definition: dev_areca.h:85
int arcmsr_do_scsi_io(struct scsi_cmnd_io *)
Definition: dev_areca.h:152
virtual int arcmsr_get_controller_type()
Definition: dev_areca.cpp:334
virtual bool arcmsr_ata_pass_through(const ata_cmd_in &in, ata_cmd_out &out)
Definition: dev_areca.cpp:385
struct _ARCMSR_IO_HDR sARCMSR_IO_HDR
ATA pass through output parameters.