Debian Codegraph @

drivers/scsi/mpt3sas/mpt3sas_ctl.h

raw
1 /*
2 * Management Module Support for MPT (Message Passing Technology) based
3 * controllers
4 *
5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.h
6 * Copyright (C) 2012-2014 LSI Corporation
7 * Copyright (C) 2013-2014 Avago Technologies
8 * (mailto: [email protected])
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * NO WARRANTY
21 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
22 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
23 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
24 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
25 * solely responsible for determining the appropriateness of using and
26 * distributing the Program and assumes all risks associated with its
27 * exercise of rights under this Agreement, including but not limited to
28 * the risks and costs of program errors, damage to or loss of data,
29 * programs or equipment, and unavailability or interruption of operations.
30
31 * DISCLAIMER OF LIABILITY
32 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
33 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
38 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
39
40 * You should have received a copy of the GNU General Public License
41 * along with this program; if not, write to the Free Software
42 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
43 * USA.
44 */
45
46 #ifndef MPT3SAS_CTL_H_INCLUDED
47 #define MPT3SAS_CTL_H_INCLUDED
48
49 #ifdef __KERNEL__
50 #include <linux/miscdevice.h>
51 #endif
52
53 #include "mpt3sas_base.h"
54
55 #ifndef MPT2SAS_MINOR
56 #define MPT2SAS_MINOR (MPT_MINOR + 1)
57 #endif
58 #ifndef MPT3SAS_MINOR
59 #define MPT3SAS_MINOR (MPT_MINOR + 2)
60 #endif
61 #define MPT2SAS_DEV_NAME "mpt2ctl"
62 #define MPT3SAS_DEV_NAME "mpt3ctl"
63 #define MPT3_MAGIC_NUMBER 'L'
64 #define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
65
66 /**
67 * IOCTL opcodes
68 */
69 #define MPT3IOCINFO _IOWR(MPT3_MAGIC_NUMBER, 17, \
70 struct mpt3_ioctl_iocinfo)
71 #define MPT3COMMAND _IOWR(MPT3_MAGIC_NUMBER, 20, \
72 struct mpt3_ioctl_command)
73 #ifdef CONFIG_COMPAT
74 #define MPT3COMMAND32 _IOWR(MPT3_MAGIC_NUMBER, 20, \
75 struct mpt3_ioctl_command32)
76 #endif
77 #define MPT3EVENTQUERY _IOWR(MPT3_MAGIC_NUMBER, 21, \
78 struct mpt3_ioctl_eventquery)
79 #define MPT3EVENTENABLE _IOWR(MPT3_MAGIC_NUMBER, 22, \
80 struct mpt3_ioctl_eventenable)
81 #define MPT3EVENTREPORT _IOWR(MPT3_MAGIC_NUMBER, 23, \
82 struct mpt3_ioctl_eventreport)
83 #define MPT3HARDRESET _IOWR(MPT3_MAGIC_NUMBER, 24, \
84 struct mpt3_ioctl_diag_reset)
85 #define MPT3BTDHMAPPING _IOWR(MPT3_MAGIC_NUMBER, 31, \
86 struct mpt3_ioctl_btdh_mapping)
87
88 /* diag buffer support */
89 #define MPT3DIAGREGISTER _IOWR(MPT3_MAGIC_NUMBER, 26, \
90 struct mpt3_diag_register)
91 #define MPT3DIAGRELEASE _IOWR(MPT3_MAGIC_NUMBER, 27, \
92 struct mpt3_diag_release)
93 #define MPT3DIAGUNREGISTER _IOWR(MPT3_MAGIC_NUMBER, 28, \
94 struct mpt3_diag_unregister)
95 #define MPT3DIAGQUERY _IOWR(MPT3_MAGIC_NUMBER, 29, \
96 struct mpt3_diag_query)
97 #define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \
98 struct mpt3_diag_read_buffer)
99 #define MPT3ADDNLDIAGQUERY _IOWR(MPT3_MAGIC_NUMBER, 32, \
100 struct mpt3_addnl_diag_query)
101 #define MPT3ENABLEDIAGSBRRELOAD _IOWR(MPT3_MAGIC_NUMBER, 33, \
102 struct mpt3_enable_diag_sbr_reload)
103
104 /* Trace Buffer default UniqueId */
105 #define MPT2DIAGBUFFUNIQUEID (0x07075900)
106 #define MPT3DIAGBUFFUNIQUEID (0x4252434D)
107
108 /* UID not found */
109 #define MPT3_DIAG_UID_NOT_FOUND (0xFF)
110
111
112 /**
113 * struct mpt3_ioctl_header - main header structure
114 * @ioc_number - IOC unit number
115 * @port_number - IOC port number
116 * @max_data_size - maximum number bytes to transfer on read
117 */
118 struct mpt3_ioctl_header {
119 uint32_t ioc_number;
120 uint32_t port_number;
121 uint32_t max_data_size;
122 };
123
124 /**
125 * struct mpt3_ioctl_diag_reset - diagnostic reset
126 * @hdr - generic header
127 */
128 struct mpt3_ioctl_diag_reset {
129 struct mpt3_ioctl_header hdr;
130 };
131
132
133 /**
134 * struct mpt3_ioctl_pci_info - pci device info
135 * @device - pci device id
136 * @function - pci function id
137 * @bus - pci bus id
138 * @segment_id - pci segment id
139 */
140 struct mpt3_ioctl_pci_info {
141 union {
142 struct {
143 uint32_t device:5;
144 uint32_t function:3;
145 uint32_t bus:24;
146 } bits;
147 uint32_t word;
148 } u;
149 uint32_t segment_id;
150 };
151
152
153 #define MPT2_IOCTL_INTERFACE_SCSI (0x00)
154 #define MPT2_IOCTL_INTERFACE_FC (0x01)
155 #define MPT2_IOCTL_INTERFACE_FC_IP (0x02)
156 #define MPT2_IOCTL_INTERFACE_SAS (0x03)
157 #define MPT2_IOCTL_INTERFACE_SAS2 (0x04)
158 #define MPT2_IOCTL_INTERFACE_SAS2_SSS6200 (0x05)
159 #define MPT3_IOCTL_INTERFACE_SAS3 (0x06)
160 #define MPT3_IOCTL_INTERFACE_SAS35 (0x07)
161 #define MPT2_IOCTL_VERSION_LENGTH (32)
162
163 /* Bits set for mpt3_ioctl_iocinfo.driver_cap */
164 #define MPT3_IOCTL_IOCINFO_DRIVER_CAP_MCTP_PASSTHRU 0x1
165
166 /**
167 * struct mpt3_ioctl_iocinfo - generic controller info
168 * @hdr - generic header
169 * @adapter_type - type of adapter (spi, fc, sas)
170 * @port_number - port number
171 * @pci_id - PCI Id
172 * @hw_rev - hardware revision
173 * @sub_system_device - PCI subsystem Device ID
174 * @sub_system_vendor - PCI subsystem Vendor ID
175 * @rsvd0 - reserved
176 * @firmware_version - firmware version
177 * @bios_version - BIOS version
178 * @driver_version - driver version - 32 ASCII characters
179 * @rsvd1 - reserved
180 * @scsi_id - scsi id of adapter 0
181 * @driver_capability - driver capabilities
182 * @rsvd2 - reserved
183 * @pci_information - pci info (2nd revision)
184 */
185 struct mpt3_ioctl_iocinfo {
186 struct mpt3_ioctl_header hdr;
187 uint32_t adapter_type;
188 uint32_t port_number;
189 uint32_t pci_id;
190 uint32_t hw_rev;
191 uint32_t subsystem_device;
192 uint32_t subsystem_vendor;
193 uint32_t rsvd0;
194 uint32_t firmware_version;
195 uint32_t bios_version;
196 uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
197 uint8_t rsvd1;
198 uint8_t scsi_id;
199 uint8_t driver_capability;
200 uint8_t rsvd2;
201 struct mpt3_ioctl_pci_info pci_information;
202 };
203
204
205 /* number of event log entries */
206 #define MPT3SAS_CTL_EVENT_LOG_SIZE (200)
207
208 /**
209 * struct mpt3_ioctl_eventquery - query event count and type
210 * @hdr - generic header
211 * @event_entries - number of events returned by get_event_report
212 * @rsvd - reserved
213 * @event_types - type of events currently being captured
214 */
215 struct mpt3_ioctl_eventquery {
216 struct mpt3_ioctl_header hdr;
217 uint16_t event_entries;
218 uint16_t rsvd;
219 uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
220 };
221
222 /**
223 * struct mpt3_ioctl_eventenable - enable/disable event capturing
224 * @hdr - generic header
225 * @event_types - toggle off/on type of events to be captured
226 */
227 struct mpt3_ioctl_eventenable {
228 struct mpt3_ioctl_header hdr;
229 uint32_t event_types[4];
230 };
231
232 #define MPT3_EVENT_DATA_SIZE (192)
233 /**
234 * struct MPT3_IOCTL_EVENTS -
235 * @event - the event that was reported
236 * @context - unique value for each event assigned by driver
237 * @data - event data returned in fw reply message
238 */
239 struct MPT3_IOCTL_EVENTS {
240 uint32_t event;
241 uint32_t context;
242 uint8_t data[MPT3_EVENT_DATA_SIZE];
243 };
244
245 /**
246 * struct mpt3_ioctl_eventreport - returing event log
247 * @hdr - generic header
248 * @event_data - (see struct MPT3_IOCTL_EVENTS)
249 */
250 struct mpt3_ioctl_eventreport {
251 struct mpt3_ioctl_header hdr;
252 struct MPT3_IOCTL_EVENTS event_data[1];
253 };
254
255 /**
256 * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl
257 * @hdr - generic header
258 * @timeout - command timeout in seconds. (if zero then use driver default
259 * value).
260 * @reply_frame_buf_ptr - reply location
261 * @data_in_buf_ptr - destination for read
262 * @data_out_buf_ptr - data source for write
263 * @sense_data_ptr - sense data location
264 * @max_reply_bytes - maximum number of reply bytes to be sent to app.
265 * @data_in_size - number bytes for data transfer in (read)
266 * @data_out_size - number bytes for data transfer out (write)
267 * @max_sense_bytes - maximum number of bytes for auto sense buffers
268 * @data_sge_offset - offset in words from the start of the request message to
269 * the first SGL
270 * @mf[1];
271 */
272 struct mpt3_ioctl_command {
273 struct mpt3_ioctl_header hdr;
274 uint32_t timeout;
275 void __user *reply_frame_buf_ptr;
276 void __user *data_in_buf_ptr;
277 void __user *data_out_buf_ptr;
278 void __user *sense_data_ptr;
279 uint32_t max_reply_bytes;
280 uint32_t data_in_size;
281 uint32_t data_out_size;
282 uint32_t max_sense_bytes;
283 uint32_t data_sge_offset;
284 uint8_t mf[1];
285 };
286
287 #ifdef CONFIG_COMPAT
288 struct mpt3_ioctl_command32 {
289 struct mpt3_ioctl_header hdr;
290 uint32_t timeout;
291 uint32_t reply_frame_buf_ptr;
292 uint32_t data_in_buf_ptr;
293 uint32_t data_out_buf_ptr;
294 uint32_t sense_data_ptr;
295 uint32_t max_reply_bytes;
296 uint32_t data_in_size;
297 uint32_t data_out_size;
298 uint32_t max_sense_bytes;
299 uint32_t data_sge_offset;
300 uint8_t mf[1];
301 };
302 #endif
303
304 /**
305 * struct mpt3_ioctl_btdh_mapping - mapping info
306 * @hdr - generic header
307 * @id - target device identification number
308 * @bus - SCSI bus number that the target device exists on
309 * @handle - device handle for the target device
310 * @rsvd - reserved
311 *
312 * To obtain a bus/id the application sets
313 * handle to valid handle, and bus/id to 0xFFFF.
314 *
315 * To obtain the device handle the application sets
316 * bus/id valid value, and the handle to 0xFFFF.
317 */
318 struct mpt3_ioctl_btdh_mapping {
319 struct mpt3_ioctl_header hdr;
320 uint32_t id;
321 uint32_t bus;
322 uint16_t handle;
323 uint16_t rsvd;
324 };
325
326
327
328 /* application flags for mpt3_diag_register, mpt3_diag_query */
329 #define MPT3_APP_FLAGS_APP_OWNED (0x0001)
330 #define MPT3_APP_FLAGS_BUFFER_VALID (0x0002)
331 #define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
332 #define MPT3_APP_FLAGS_DYNAMIC_BUFFER_ALLOC (0x0008)
333
334 /* flags for mpt3_diag_read_buffer */
335 #define MPT3_FLAGS_REREGISTER (0x0001)
336
337 #define MPT3_PRODUCT_SPECIFIC_DWORDS 23
338
339 /**
340 * struct mpt3_diag_register - application register with driver
341 * @hdr - generic header
342 * @reserved -
343 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
344 * @application_flags - misc flags
345 * @diagnostic_flags - specifies flags affecting command processing
346 * @product_specific - product specific information
347 * @requested_buffer_size - buffers size in bytes
348 * @unique_id - tag specified by application that is used to signal ownership
349 * of the buffer.
350 *
351 * This will allow the driver to setup any required buffers that will be
352 * needed by firmware to communicate with the driver.
353 */
354 struct mpt3_diag_register {
355 struct mpt3_ioctl_header hdr;
356 uint8_t reserved;
357 uint8_t buffer_type;
358 uint16_t application_flags;
359 uint32_t diagnostic_flags;
360 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
361 uint32_t requested_buffer_size;
362 uint32_t unique_id;
363 };
364
365 /**
366 * struct mpt3_diag_unregister - application unregister with driver
367 * @hdr - generic header
368 * @unique_id - tag uniquely identifies the buffer to be unregistered
369 *
370 * This will allow the driver to cleanup any memory allocated for diag
371 * messages and to free up any resources.
372 */
373 struct mpt3_diag_unregister {
374 struct mpt3_ioctl_header hdr;
375 uint32_t unique_id;
376 };
377
378 /**
379 * struct mpt3_diag_query - query relevant info associated with diag buffers
380 * @hdr - generic header
381 * @reserved -
382 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
383 * @application_flags - misc flags
384 * @diagnostic_flags - specifies flags affecting command processing
385 * @product_specific - product specific information
386 * @total_buffer_size - diag buffer size in bytes
387 * @driver_added_buffer_size - size of extra space appended to end of buffer
388 * @unique_id - unique id associated with this buffer.
389 *
390 * The application will send only buffer_type and unique_id. Driver will
391 * inspect unique_id first, if valid, fill in all the info. If unique_id is
392 * 0x00, the driver will return info specified by Buffer Type.
393 */
394 struct mpt3_diag_query {
395 struct mpt3_ioctl_header hdr;
396 uint8_t reserved;
397 uint8_t buffer_type;
398 uint16_t application_flags;
399 uint32_t diagnostic_flags;
400 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
401 uint32_t total_buffer_size;
402 uint32_t driver_added_buffer_size;
403 uint32_t unique_id;
404 };
405
406 /**
407 * struct mpt3_diag_release - request to send Diag Release Message to firmware
408 * @hdr - generic header
409 * @unique_id - tag uniquely identifies the buffer to be released
410 *
411 * This allows ownership of the specified buffer to returned to the driver,
412 * allowing an application to read the buffer without fear that firmware is
413 * overwriting information in the buffer.
414 */
415 struct mpt3_diag_release {
416 struct mpt3_ioctl_header hdr;
417 uint32_t unique_id;
418 };
419
420 /**
421 * struct mpt3_diag_read_buffer - request for copy of the diag buffer
422 * @hdr - generic header
423 * @status -
424 * @reserved -
425 * @flags - misc flags
426 * @starting_offset - starting offset within drivers buffer where to start
427 * reading data at into the specified application buffer
428 * @bytes_to_read - number of bytes to copy from the drivers buffer into the
429 * application buffer starting at starting_offset.
430 * @unique_id - unique id associated with this buffer.
431 * @diagnostic_data - data payload
432 */
433 struct mpt3_diag_read_buffer {
434 struct mpt3_ioctl_header hdr;
435 uint8_t status;
436 uint8_t reserved;
437 uint16_t flags;
438 uint32_t starting_offset;
439 uint32_t bytes_to_read;
440 uint32_t unique_id;
441 uint32_t diagnostic_data[1];
442 };
443
444 /**
445 * struct mpt3_addnl_diag_query - diagnostic buffer release reason
446 * @hdr - generic header
447 * @unique_id - unique id associated with this buffer.
448 * @rel_query - release query.
449 * @reserved2
450 */
451 struct mpt3_addnl_diag_query {
452 struct mpt3_ioctl_header hdr;
453 uint32_t unique_id;
454 struct htb_rel_query rel_query;
455 uint32_t reserved2[2];
456 };
457
458 /**
459 * struct mpt3_enable_diag_sbr_reload - enable sbr reload
460 * @hdr - generic header
461 */
462 struct mpt3_enable_diag_sbr_reload {
463 struct mpt3_ioctl_header hdr;
464 };
465
466 /**
467 * struct mpt3_passthru_command - generic mpt firmware passthru command
468 * @dev_index - device index
469 * @timeout - command timeout in seconds. (if zero then use driver default
470 * value).
471 * @reply_frame_buf_ptr - MPI reply location
472 * @data_in_buf_ptr - destination for read
473 * @data_out_buf_ptr - data source for write
474 * @max_reply_bytes - maximum number of reply bytes to be sent to app.
475 * @data_in_size - number bytes for data transfer in (read)
476 * @data_out_size - number bytes for data transfer out (write)
477 * @mpi_request - request frame
478 */
479 struct mpt3_passthru_command {
480 u8 dev_index;
481 uint32_t timeout;
482 void *reply_frame_buf_ptr;
483 void *data_in_buf_ptr;
484 void *data_out_buf_ptr;
485 uint32_t max_reply_bytes;
486 uint32_t data_in_size;
487 uint32_t data_out_size;
488 Mpi26MctpPassthroughRequest_t *mpi_request;
489 };
490
491 /*
492 * mpt3sas_get_device_count - Retrieve the count of MCTP passthrough
493 * capable devices managed by the driver.
494 *
495 * Returns number of devices that support MCTP passthrough.
496 */
497 int mpt3sas_get_device_count(void);
498
499 /*
500 * mpt3sas_send_passthru_cmd - Send an MPI MCTP passthrough command to
501 * firmware
502 * @command: The MPI MCTP passthrough command to send to firmware
503 *
504 * Returns 0 on success, anything else is error .
505 */
506 int mpt3sas_send_mctp_passthru_req(struct mpt3_passthru_command *command);
507
508 #endif /* MPT3SAS_CTL_H_INCLUDED */