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-2013 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com)
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
21 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
22 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
23 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
24 * solely responsible for determining the appropriateness of using and
25 * distributing the Program and assumes all risks associated with its
26 * exercise of rights under this Agreement, including but not limited to
27 * the risks and costs of program errors, damage to or loss of data,
28 * programs or equipment, and unavailability or interruption of operations.
30 * DISCLAIMER OF LIABILITY
31 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
32 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
34 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
35 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
36 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
37 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
39 * You should have received a copy of the GNU General Public License
40 * along with this program; if not, write to the Free Software
41 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
45 #ifndef MPT3SAS_CTL_H_INCLUDED
46 #define MPT3SAS_CTL_H_INCLUDED
49 #include <linux/miscdevice.h>
54 #define MPT3SAS_MINOR (MPT_MINOR + 2)
56 #define MPT3SAS_DEV_NAME "mpt3ctl"
57 #define MPT3_MAGIC_NUMBER 'L'
58 #define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
63 #define MPT3IOCINFO _IOWR(MPT3_MAGIC_NUMBER, 17, \
64 struct mpt3_ioctl_iocinfo)
65 #define MPT3COMMAND _IOWR(MPT3_MAGIC_NUMBER, 20, \
66 struct mpt3_ioctl_command)
68 #define MPT3COMMAND32 _IOWR(MPT3_MAGIC_NUMBER, 20, \
69 struct mpt3_ioctl_command32)
71 #define MPT3EVENTQUERY _IOWR(MPT3_MAGIC_NUMBER, 21, \
72 struct mpt3_ioctl_eventquery)
73 #define MPT3EVENTENABLE _IOWR(MPT3_MAGIC_NUMBER, 22, \
74 struct mpt3_ioctl_eventenable)
75 #define MPT3EVENTREPORT _IOWR(MPT3_MAGIC_NUMBER, 23, \
76 struct mpt3_ioctl_eventreport)
77 #define MPT3HARDRESET _IOWR(MPT3_MAGIC_NUMBER, 24, \
78 struct mpt3_ioctl_diag_reset)
79 #define MPT3BTDHMAPPING _IOWR(MPT3_MAGIC_NUMBER, 31, \
80 struct mpt3_ioctl_btdh_mapping)
82 /* diag buffer support */
83 #define MPT3DIAGREGISTER _IOWR(MPT3_MAGIC_NUMBER, 26, \
84 struct mpt3_diag_register)
85 #define MPT3DIAGRELEASE _IOWR(MPT3_MAGIC_NUMBER, 27, \
86 struct mpt3_diag_release)
87 #define MPT3DIAGUNREGISTER _IOWR(MPT3_MAGIC_NUMBER, 28, \
88 struct mpt3_diag_unregister)
89 #define MPT3DIAGQUERY _IOWR(MPT3_MAGIC_NUMBER, 29, \
90 struct mpt3_diag_query)
91 #define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \
92 struct mpt3_diag_read_buffer)
95 * struct mpt3_ioctl_header - main header structure
96 * @ioc_number - IOC unit number
97 * @port_number - IOC port number
98 * @max_data_size - maximum number bytes to transfer on read
100 struct mpt3_ioctl_header
{
102 uint32_t port_number
;
103 uint32_t max_data_size
;
107 * struct mpt3_ioctl_diag_reset - diagnostic reset
108 * @hdr - generic header
110 struct mpt3_ioctl_diag_reset
{
111 struct mpt3_ioctl_header hdr
;
116 * struct mpt3_ioctl_pci_info - pci device info
117 * @device - pci device id
118 * @function - pci function id
120 * @segment_id - pci segment id
122 struct mpt3_ioctl_pci_info
{
135 #define MPT2_IOCTL_INTERFACE_SCSI (0x00)
136 #define MPT2_IOCTL_INTERFACE_FC (0x01)
137 #define MPT2_IOCTL_INTERFACE_FC_IP (0x02)
138 #define MPT2_IOCTL_INTERFACE_SAS (0x03)
139 #define MPT2_IOCTL_INTERFACE_SAS2 (0x04)
140 #define MPT3_IOCTL_INTERFACE_SAS3 (0x06)
141 #define MPT2_IOCTL_VERSION_LENGTH (32)
144 * struct mpt3_ioctl_iocinfo - generic controller info
145 * @hdr - generic header
146 * @adapter_type - type of adapter (spi, fc, sas)
147 * @port_number - port number
149 * @hw_rev - hardware revision
150 * @sub_system_device - PCI subsystem Device ID
151 * @sub_system_vendor - PCI subsystem Vendor ID
153 * @firmware_version - firmware version
154 * @bios_version - BIOS version
155 * @driver_version - driver version - 32 ASCII characters
157 * @scsi_id - scsi id of adapter 0
159 * @pci_information - pci info (2nd revision)
161 struct mpt3_ioctl_iocinfo
{
162 struct mpt3_ioctl_header hdr
;
163 uint32_t adapter_type
;
164 uint32_t port_number
;
167 uint32_t subsystem_device
;
168 uint32_t subsystem_vendor
;
170 uint32_t firmware_version
;
171 uint32_t bios_version
;
172 uint8_t driver_version
[MPT2_IOCTL_VERSION_LENGTH
];
176 struct mpt3_ioctl_pci_info pci_information
;
180 /* number of event log entries */
181 #define MPT3SAS_CTL_EVENT_LOG_SIZE (50)
184 * struct mpt3_ioctl_eventquery - query event count and type
185 * @hdr - generic header
186 * @event_entries - number of events returned by get_event_report
188 * @event_types - type of events currently being captured
190 struct mpt3_ioctl_eventquery
{
191 struct mpt3_ioctl_header hdr
;
192 uint16_t event_entries
;
194 uint32_t event_types
[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS
];
198 * struct mpt3_ioctl_eventenable - enable/disable event capturing
199 * @hdr - generic header
200 * @event_types - toggle off/on type of events to be captured
202 struct mpt3_ioctl_eventenable
{
203 struct mpt3_ioctl_header hdr
;
204 uint32_t event_types
[4];
207 #define MPT3_EVENT_DATA_SIZE (192)
209 * struct MPT3_IOCTL_EVENTS -
210 * @event - the event that was reported
211 * @context - unique value for each event assigned by driver
212 * @data - event data returned in fw reply message
214 struct MPT3_IOCTL_EVENTS
{
217 uint8_t data
[MPT3_EVENT_DATA_SIZE
];
221 * struct mpt3_ioctl_eventreport - returing event log
222 * @hdr - generic header
223 * @event_data - (see struct MPT3_IOCTL_EVENTS)
225 struct mpt3_ioctl_eventreport
{
226 struct mpt3_ioctl_header hdr
;
227 struct MPT3_IOCTL_EVENTS event_data
[1];
231 * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl
232 * @hdr - generic header
233 * @timeout - command timeout in seconds. (if zero then use driver default
235 * @reply_frame_buf_ptr - reply location
236 * @data_in_buf_ptr - destination for read
237 * @data_out_buf_ptr - data source for write
238 * @sense_data_ptr - sense data location
239 * @max_reply_bytes - maximum number of reply bytes to be sent to app.
240 * @data_in_size - number bytes for data transfer in (read)
241 * @data_out_size - number bytes for data transfer out (write)
242 * @max_sense_bytes - maximum number of bytes for auto sense buffers
243 * @data_sge_offset - offset in words from the start of the request message to
247 struct mpt3_ioctl_command
{
248 struct mpt3_ioctl_header hdr
;
250 void __user
*reply_frame_buf_ptr
;
251 void __user
*data_in_buf_ptr
;
252 void __user
*data_out_buf_ptr
;
253 void __user
*sense_data_ptr
;
254 uint32_t max_reply_bytes
;
255 uint32_t data_in_size
;
256 uint32_t data_out_size
;
257 uint32_t max_sense_bytes
;
258 uint32_t data_sge_offset
;
263 struct mpt3_ioctl_command32
{
264 struct mpt3_ioctl_header hdr
;
266 uint32_t reply_frame_buf_ptr
;
267 uint32_t data_in_buf_ptr
;
268 uint32_t data_out_buf_ptr
;
269 uint32_t sense_data_ptr
;
270 uint32_t max_reply_bytes
;
271 uint32_t data_in_size
;
272 uint32_t data_out_size
;
273 uint32_t max_sense_bytes
;
274 uint32_t data_sge_offset
;
280 * struct mpt3_ioctl_btdh_mapping - mapping info
281 * @hdr - generic header
282 * @id - target device identification number
283 * @bus - SCSI bus number that the target device exists on
284 * @handle - device handle for the target device
287 * To obtain a bus/id the application sets
288 * handle to valid handle, and bus/id to 0xFFFF.
290 * To obtain the device handle the application sets
291 * bus/id valid value, and the handle to 0xFFFF.
293 struct mpt3_ioctl_btdh_mapping
{
294 struct mpt3_ioctl_header hdr
;
303 /* application flags for mpt3_diag_register, mpt3_diag_query */
304 #define MPT3_APP_FLAGS_APP_OWNED (0x0001)
305 #define MPT3_APP_FLAGS_BUFFER_VALID (0x0002)
306 #define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
308 /* flags for mpt3_diag_read_buffer */
309 #define MPT3_FLAGS_REREGISTER (0x0001)
311 #define MPT3_PRODUCT_SPECIFIC_DWORDS 23
314 * struct mpt3_diag_register - application register with driver
315 * @hdr - generic header
317 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
318 * @application_flags - misc flags
319 * @diagnostic_flags - specifies flags affecting command processing
320 * @product_specific - product specific information
321 * @requested_buffer_size - buffers size in bytes
322 * @unique_id - tag specified by application that is used to signal ownership
325 * This will allow the driver to setup any required buffers that will be
326 * needed by firmware to communicate with the driver.
328 struct mpt3_diag_register
{
329 struct mpt3_ioctl_header hdr
;
332 uint16_t application_flags
;
333 uint32_t diagnostic_flags
;
334 uint32_t product_specific
[MPT3_PRODUCT_SPECIFIC_DWORDS
];
335 uint32_t requested_buffer_size
;
340 * struct mpt3_diag_unregister - application unregister with driver
341 * @hdr - generic header
342 * @unique_id - tag uniquely identifies the buffer to be unregistered
344 * This will allow the driver to cleanup any memory allocated for diag
345 * messages and to free up any resources.
347 struct mpt3_diag_unregister
{
348 struct mpt3_ioctl_header hdr
;
353 * struct mpt3_diag_query - query relevant info associated with diag buffers
354 * @hdr - generic header
356 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
357 * @application_flags - misc flags
358 * @diagnostic_flags - specifies flags affecting command processing
359 * @product_specific - product specific information
360 * @total_buffer_size - diag buffer size in bytes
361 * @driver_added_buffer_size - size of extra space appended to end of buffer
362 * @unique_id - unique id associated with this buffer.
364 * The application will send only buffer_type and unique_id. Driver will
365 * inspect unique_id first, if valid, fill in all the info. If unique_id is
366 * 0x00, the driver will return info specified by Buffer Type.
368 struct mpt3_diag_query
{
369 struct mpt3_ioctl_header hdr
;
372 uint16_t application_flags
;
373 uint32_t diagnostic_flags
;
374 uint32_t product_specific
[MPT3_PRODUCT_SPECIFIC_DWORDS
];
375 uint32_t total_buffer_size
;
376 uint32_t driver_added_buffer_size
;
381 * struct mpt3_diag_release - request to send Diag Release Message to firmware
382 * @hdr - generic header
383 * @unique_id - tag uniquely identifies the buffer to be released
385 * This allows ownership of the specified buffer to returned to the driver,
386 * allowing an application to read the buffer without fear that firmware is
387 * overwritting information in the buffer.
389 struct mpt3_diag_release
{
390 struct mpt3_ioctl_header hdr
;
395 * struct mpt3_diag_read_buffer - request for copy of the diag buffer
396 * @hdr - generic header
399 * @flags - misc flags
400 * @starting_offset - starting offset within drivers buffer where to start
401 * reading data at into the specified application buffer
402 * @bytes_to_read - number of bytes to copy from the drivers buffer into the
403 * application buffer starting at starting_offset.
404 * @unique_id - unique id associated with this buffer.
405 * @diagnostic_data - data payload
407 struct mpt3_diag_read_buffer
{
408 struct mpt3_ioctl_header hdr
;
412 uint32_t starting_offset
;
413 uint32_t bytes_to_read
;
415 uint32_t diagnostic_data
[1];
418 #endif /* MPT3SAS_CTL_H_INCLUDED */