2 * Management Module Support for MPT (Message Passing Technology) based
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: MPT-FusionLinux.pdl@avagotech.com)
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.
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.
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.
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
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,
46 #ifndef MPT3SAS_CTL_H_INCLUDED
47 #define MPT3SAS_CTL_H_INCLUDED
50 #include <linux/miscdevice.h>
53 #include "mpt3sas_base.h"
56 #define MPT2SAS_MINOR (MPT_MINOR + 1)
59 #define MPT3SAS_MINOR (MPT_MINOR + 2)
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 */
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)
74 #define MPT3COMMAND32 _IOWR(MPT3_MAGIC_NUMBER, 20, \
75 struct mpt3_ioctl_command32)
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)
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)
102 /* Trace Buffer default UniqueId */
103 #define MPT2DIAGBUFFUNIQUEID (0x07075900)
104 #define MPT3DIAGBUFFUNIQUEID (0x4252434D)
107 #define MPT3_DIAG_UID_NOT_FOUND (0xFF)
111 * struct mpt3_ioctl_header - main header structure
112 * @ioc_number - IOC unit number
113 * @port_number - IOC port number
114 * @max_data_size - maximum number bytes to transfer on read
116 struct mpt3_ioctl_header {
118 uint32_t port_number;
119 uint32_t max_data_size;
123 * struct mpt3_ioctl_diag_reset - diagnostic reset
124 * @hdr - generic header
126 struct mpt3_ioctl_diag_reset {
127 struct mpt3_ioctl_header hdr;
132 * struct mpt3_ioctl_pci_info - pci device info
133 * @device - pci device id
134 * @function - pci function id
136 * @segment_id - pci segment id
138 struct mpt3_ioctl_pci_info {
151 #define MPT2_IOCTL_INTERFACE_SCSI (0x00)
152 #define MPT2_IOCTL_INTERFACE_FC (0x01)
153 #define MPT2_IOCTL_INTERFACE_FC_IP (0x02)
154 #define MPT2_IOCTL_INTERFACE_SAS (0x03)
155 #define MPT2_IOCTL_INTERFACE_SAS2 (0x04)
156 #define MPT2_IOCTL_INTERFACE_SAS2_SSS6200 (0x05)
157 #define MPT3_IOCTL_INTERFACE_SAS3 (0x06)
158 #define MPT3_IOCTL_INTERFACE_SAS35 (0x07)
159 #define MPT2_IOCTL_VERSION_LENGTH (32)
162 * struct mpt3_ioctl_iocinfo - generic controller info
163 * @hdr - generic header
164 * @adapter_type - type of adapter (spi, fc, sas)
165 * @port_number - port number
167 * @hw_rev - hardware revision
168 * @sub_system_device - PCI subsystem Device ID
169 * @sub_system_vendor - PCI subsystem Vendor ID
171 * @firmware_version - firmware version
172 * @bios_version - BIOS version
173 * @driver_version - driver version - 32 ASCII characters
175 * @scsi_id - scsi id of adapter 0
177 * @pci_information - pci info (2nd revision)
179 struct mpt3_ioctl_iocinfo {
180 struct mpt3_ioctl_header hdr;
181 uint32_t adapter_type;
182 uint32_t port_number;
185 uint32_t subsystem_device;
186 uint32_t subsystem_vendor;
188 uint32_t firmware_version;
189 uint32_t bios_version;
190 uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
194 struct mpt3_ioctl_pci_info pci_information;
198 /* number of event log entries */
199 #define MPT3SAS_CTL_EVENT_LOG_SIZE (200)
202 * struct mpt3_ioctl_eventquery - query event count and type
203 * @hdr - generic header
204 * @event_entries - number of events returned by get_event_report
206 * @event_types - type of events currently being captured
208 struct mpt3_ioctl_eventquery {
209 struct mpt3_ioctl_header hdr;
210 uint16_t event_entries;
212 uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
216 * struct mpt3_ioctl_eventenable - enable/disable event capturing
217 * @hdr - generic header
218 * @event_types - toggle off/on type of events to be captured
220 struct mpt3_ioctl_eventenable {
221 struct mpt3_ioctl_header hdr;
222 uint32_t event_types[4];
225 #define MPT3_EVENT_DATA_SIZE (192)
227 * struct MPT3_IOCTL_EVENTS -
228 * @event - the event that was reported
229 * @context - unique value for each event assigned by driver
230 * @data - event data returned in fw reply message
232 struct MPT3_IOCTL_EVENTS {
235 uint8_t data[MPT3_EVENT_DATA_SIZE];
239 * struct mpt3_ioctl_eventreport - returing event log
240 * @hdr - generic header
241 * @event_data - (see struct MPT3_IOCTL_EVENTS)
243 struct mpt3_ioctl_eventreport {
244 struct mpt3_ioctl_header hdr;
245 struct MPT3_IOCTL_EVENTS event_data[1];
249 * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl
250 * @hdr - generic header
251 * @timeout - command timeout in seconds. (if zero then use driver default
253 * @reply_frame_buf_ptr - reply location
254 * @data_in_buf_ptr - destination for read
255 * @data_out_buf_ptr - data source for write
256 * @sense_data_ptr - sense data location
257 * @max_reply_bytes - maximum number of reply bytes to be sent to app.
258 * @data_in_size - number bytes for data transfer in (read)
259 * @data_out_size - number bytes for data transfer out (write)
260 * @max_sense_bytes - maximum number of bytes for auto sense buffers
261 * @data_sge_offset - offset in words from the start of the request message to
265 struct mpt3_ioctl_command {
266 struct mpt3_ioctl_header hdr;
268 void __user *reply_frame_buf_ptr;
269 void __user *data_in_buf_ptr;
270 void __user *data_out_buf_ptr;
271 void __user *sense_data_ptr;
272 uint32_t max_reply_bytes;
273 uint32_t data_in_size;
274 uint32_t data_out_size;
275 uint32_t max_sense_bytes;
276 uint32_t data_sge_offset;
281 struct mpt3_ioctl_command32 {
282 struct mpt3_ioctl_header hdr;
284 uint32_t reply_frame_buf_ptr;
285 uint32_t data_in_buf_ptr;
286 uint32_t data_out_buf_ptr;
287 uint32_t sense_data_ptr;
288 uint32_t max_reply_bytes;
289 uint32_t data_in_size;
290 uint32_t data_out_size;
291 uint32_t max_sense_bytes;
292 uint32_t data_sge_offset;
298 * struct mpt3_ioctl_btdh_mapping - mapping info
299 * @hdr - generic header
300 * @id - target device identification number
301 * @bus - SCSI bus number that the target device exists on
302 * @handle - device handle for the target device
305 * To obtain a bus/id the application sets
306 * handle to valid handle, and bus/id to 0xFFFF.
308 * To obtain the device handle the application sets
309 * bus/id valid value, and the handle to 0xFFFF.
311 struct mpt3_ioctl_btdh_mapping {
312 struct mpt3_ioctl_header hdr;
321 /* application flags for mpt3_diag_register, mpt3_diag_query */
322 #define MPT3_APP_FLAGS_APP_OWNED (0x0001)
323 #define MPT3_APP_FLAGS_BUFFER_VALID (0x0002)
324 #define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
325 #define MPT3_APP_FLAGS_DYNAMIC_BUFFER_ALLOC (0x0008)
327 /* flags for mpt3_diag_read_buffer */
328 #define MPT3_FLAGS_REREGISTER (0x0001)
330 #define MPT3_PRODUCT_SPECIFIC_DWORDS 23
333 * struct mpt3_diag_register - application register with driver
334 * @hdr - generic header
336 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
337 * @application_flags - misc flags
338 * @diagnostic_flags - specifies flags affecting command processing
339 * @product_specific - product specific information
340 * @requested_buffer_size - buffers size in bytes
341 * @unique_id - tag specified by application that is used to signal ownership
344 * This will allow the driver to setup any required buffers that will be
345 * needed by firmware to communicate with the driver.
347 struct mpt3_diag_register {
348 struct mpt3_ioctl_header hdr;
351 uint16_t application_flags;
352 uint32_t diagnostic_flags;
353 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
354 uint32_t requested_buffer_size;
359 * struct mpt3_diag_unregister - application unregister with driver
360 * @hdr - generic header
361 * @unique_id - tag uniquely identifies the buffer to be unregistered
363 * This will allow the driver to cleanup any memory allocated for diag
364 * messages and to free up any resources.
366 struct mpt3_diag_unregister {
367 struct mpt3_ioctl_header hdr;
372 * struct mpt3_diag_query - query relevant info associated with diag buffers
373 * @hdr - generic header
375 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
376 * @application_flags - misc flags
377 * @diagnostic_flags - specifies flags affecting command processing
378 * @product_specific - product specific information
379 * @total_buffer_size - diag buffer size in bytes
380 * @driver_added_buffer_size - size of extra space appended to end of buffer
381 * @unique_id - unique id associated with this buffer.
383 * The application will send only buffer_type and unique_id. Driver will
384 * inspect unique_id first, if valid, fill in all the info. If unique_id is
385 * 0x00, the driver will return info specified by Buffer Type.
387 struct mpt3_diag_query {
388 struct mpt3_ioctl_header hdr;
391 uint16_t application_flags;
392 uint32_t diagnostic_flags;
393 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
394 uint32_t total_buffer_size;
395 uint32_t driver_added_buffer_size;
400 * struct mpt3_diag_release - request to send Diag Release Message to firmware
401 * @hdr - generic header
402 * @unique_id - tag uniquely identifies the buffer to be released
404 * This allows ownership of the specified buffer to returned to the driver,
405 * allowing an application to read the buffer without fear that firmware is
406 * overwriting information in the buffer.
408 struct mpt3_diag_release {
409 struct mpt3_ioctl_header hdr;
414 * struct mpt3_diag_read_buffer - request for copy of the diag buffer
415 * @hdr - generic header
418 * @flags - misc flags
419 * @starting_offset - starting offset within drivers buffer where to start
420 * reading data at into the specified application buffer
421 * @bytes_to_read - number of bytes to copy from the drivers buffer into the
422 * application buffer starting at starting_offset.
423 * @unique_id - unique id associated with this buffer.
424 * @diagnostic_data - data payload
426 struct mpt3_diag_read_buffer {
427 struct mpt3_ioctl_header hdr;
431 uint32_t starting_offset;
432 uint32_t bytes_to_read;
434 uint32_t diagnostic_data[1];
438 * struct mpt3_addnl_diag_query - diagnostic buffer release reason
439 * @hdr - generic header
440 * @unique_id - unique id associated with this buffer.
441 * @rel_query - release query.
444 struct mpt3_addnl_diag_query {
445 struct mpt3_ioctl_header hdr;
447 struct htb_rel_query rel_query;
448 uint32_t reserved2[2];
451 #endif /* MPT3SAS_CTL_H_INCLUDED */