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>
54 #define MPT2SAS_MINOR (MPT_MINOR + 1)
57 #define MPT3SAS_MINOR (MPT_MINOR + 2)
59 #define MPT2SAS_DEV_NAME "mpt2ctl"
60 #define MPT3SAS_DEV_NAME "mpt3ctl"
61 #define MPT3_MAGIC_NUMBER 'L'
62 #define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
67 #define MPT3IOCINFO _IOWR(MPT3_MAGIC_NUMBER, 17, \
68 struct mpt3_ioctl_iocinfo)
69 #define MPT3COMMAND _IOWR(MPT3_MAGIC_NUMBER, 20, \
70 struct mpt3_ioctl_command)
72 #define MPT3COMMAND32 _IOWR(MPT3_MAGIC_NUMBER, 20, \
73 struct mpt3_ioctl_command32)
75 #define MPT3EVENTQUERY _IOWR(MPT3_MAGIC_NUMBER, 21, \
76 struct mpt3_ioctl_eventquery)
77 #define MPT3EVENTENABLE _IOWR(MPT3_MAGIC_NUMBER, 22, \
78 struct mpt3_ioctl_eventenable)
79 #define MPT3EVENTREPORT _IOWR(MPT3_MAGIC_NUMBER, 23, \
80 struct mpt3_ioctl_eventreport)
81 #define MPT3HARDRESET _IOWR(MPT3_MAGIC_NUMBER, 24, \
82 struct mpt3_ioctl_diag_reset)
83 #define MPT3BTDHMAPPING _IOWR(MPT3_MAGIC_NUMBER, 31, \
84 struct mpt3_ioctl_btdh_mapping)
86 /* diag buffer support */
87 #define MPT3DIAGREGISTER _IOWR(MPT3_MAGIC_NUMBER, 26, \
88 struct mpt3_diag_register)
89 #define MPT3DIAGRELEASE _IOWR(MPT3_MAGIC_NUMBER, 27, \
90 struct mpt3_diag_release)
91 #define MPT3DIAGUNREGISTER _IOWR(MPT3_MAGIC_NUMBER, 28, \
92 struct mpt3_diag_unregister)
93 #define MPT3DIAGQUERY _IOWR(MPT3_MAGIC_NUMBER, 29, \
94 struct mpt3_diag_query)
95 #define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \
96 struct mpt3_diag_read_buffer)
99 * struct mpt3_ioctl_header - main header structure
100 * @ioc_number - IOC unit number
101 * @port_number - IOC port number
102 * @max_data_size - maximum number bytes to transfer on read
104 struct mpt3_ioctl_header {
106 uint32_t port_number;
107 uint32_t max_data_size;
111 * struct mpt3_ioctl_diag_reset - diagnostic reset
112 * @hdr - generic header
114 struct mpt3_ioctl_diag_reset {
115 struct mpt3_ioctl_header hdr;
120 * struct mpt3_ioctl_pci_info - pci device info
121 * @device - pci device id
122 * @function - pci function id
124 * @segment_id - pci segment id
126 struct mpt3_ioctl_pci_info {
139 #define MPT2_IOCTL_INTERFACE_SCSI (0x00)
140 #define MPT2_IOCTL_INTERFACE_FC (0x01)
141 #define MPT2_IOCTL_INTERFACE_FC_IP (0x02)
142 #define MPT2_IOCTL_INTERFACE_SAS (0x03)
143 #define MPT2_IOCTL_INTERFACE_SAS2 (0x04)
144 #define MPT2_IOCTL_INTERFACE_SAS2_SSS6200 (0x05)
145 #define MPT3_IOCTL_INTERFACE_SAS3 (0x06)
146 #define MPT2_IOCTL_VERSION_LENGTH (32)
149 * struct mpt3_ioctl_iocinfo - generic controller info
150 * @hdr - generic header
151 * @adapter_type - type of adapter (spi, fc, sas)
152 * @port_number - port number
154 * @hw_rev - hardware revision
155 * @sub_system_device - PCI subsystem Device ID
156 * @sub_system_vendor - PCI subsystem Vendor ID
158 * @firmware_version - firmware version
159 * @bios_version - BIOS version
160 * @driver_version - driver version - 32 ASCII characters
162 * @scsi_id - scsi id of adapter 0
164 * @pci_information - pci info (2nd revision)
166 struct mpt3_ioctl_iocinfo {
167 struct mpt3_ioctl_header hdr;
168 uint32_t adapter_type;
169 uint32_t port_number;
172 uint32_t subsystem_device;
173 uint32_t subsystem_vendor;
175 uint32_t firmware_version;
176 uint32_t bios_version;
177 uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
181 struct mpt3_ioctl_pci_info pci_information;
185 /* number of event log entries */
186 #define MPT3SAS_CTL_EVENT_LOG_SIZE (50)
189 * struct mpt3_ioctl_eventquery - query event count and type
190 * @hdr - generic header
191 * @event_entries - number of events returned by get_event_report
193 * @event_types - type of events currently being captured
195 struct mpt3_ioctl_eventquery {
196 struct mpt3_ioctl_header hdr;
197 uint16_t event_entries;
199 uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
203 * struct mpt3_ioctl_eventenable - enable/disable event capturing
204 * @hdr - generic header
205 * @event_types - toggle off/on type of events to be captured
207 struct mpt3_ioctl_eventenable {
208 struct mpt3_ioctl_header hdr;
209 uint32_t event_types[4];
212 #define MPT3_EVENT_DATA_SIZE (192)
214 * struct MPT3_IOCTL_EVENTS -
215 * @event - the event that was reported
216 * @context - unique value for each event assigned by driver
217 * @data - event data returned in fw reply message
219 struct MPT3_IOCTL_EVENTS {
222 uint8_t data[MPT3_EVENT_DATA_SIZE];
226 * struct mpt3_ioctl_eventreport - returing event log
227 * @hdr - generic header
228 * @event_data - (see struct MPT3_IOCTL_EVENTS)
230 struct mpt3_ioctl_eventreport {
231 struct mpt3_ioctl_header hdr;
232 struct MPT3_IOCTL_EVENTS event_data[1];
236 * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl
237 * @hdr - generic header
238 * @timeout - command timeout in seconds. (if zero then use driver default
240 * @reply_frame_buf_ptr - reply location
241 * @data_in_buf_ptr - destination for read
242 * @data_out_buf_ptr - data source for write
243 * @sense_data_ptr - sense data location
244 * @max_reply_bytes - maximum number of reply bytes to be sent to app.
245 * @data_in_size - number bytes for data transfer in (read)
246 * @data_out_size - number bytes for data transfer out (write)
247 * @max_sense_bytes - maximum number of bytes for auto sense buffers
248 * @data_sge_offset - offset in words from the start of the request message to
252 struct mpt3_ioctl_command {
253 struct mpt3_ioctl_header hdr;
255 void __user *reply_frame_buf_ptr;
256 void __user *data_in_buf_ptr;
257 void __user *data_out_buf_ptr;
258 void __user *sense_data_ptr;
259 uint32_t max_reply_bytes;
260 uint32_t data_in_size;
261 uint32_t data_out_size;
262 uint32_t max_sense_bytes;
263 uint32_t data_sge_offset;
268 struct mpt3_ioctl_command32 {
269 struct mpt3_ioctl_header hdr;
271 uint32_t reply_frame_buf_ptr;
272 uint32_t data_in_buf_ptr;
273 uint32_t data_out_buf_ptr;
274 uint32_t sense_data_ptr;
275 uint32_t max_reply_bytes;
276 uint32_t data_in_size;
277 uint32_t data_out_size;
278 uint32_t max_sense_bytes;
279 uint32_t data_sge_offset;
285 * struct mpt3_ioctl_btdh_mapping - mapping info
286 * @hdr - generic header
287 * @id - target device identification number
288 * @bus - SCSI bus number that the target device exists on
289 * @handle - device handle for the target device
292 * To obtain a bus/id the application sets
293 * handle to valid handle, and bus/id to 0xFFFF.
295 * To obtain the device handle the application sets
296 * bus/id valid value, and the handle to 0xFFFF.
298 struct mpt3_ioctl_btdh_mapping {
299 struct mpt3_ioctl_header hdr;
308 /* application flags for mpt3_diag_register, mpt3_diag_query */
309 #define MPT3_APP_FLAGS_APP_OWNED (0x0001)
310 #define MPT3_APP_FLAGS_BUFFER_VALID (0x0002)
311 #define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
313 /* flags for mpt3_diag_read_buffer */
314 #define MPT3_FLAGS_REREGISTER (0x0001)
316 #define MPT3_PRODUCT_SPECIFIC_DWORDS 23
319 * struct mpt3_diag_register - application register with driver
320 * @hdr - generic header
322 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
323 * @application_flags - misc flags
324 * @diagnostic_flags - specifies flags affecting command processing
325 * @product_specific - product specific information
326 * @requested_buffer_size - buffers size in bytes
327 * @unique_id - tag specified by application that is used to signal ownership
330 * This will allow the driver to setup any required buffers that will be
331 * needed by firmware to communicate with the driver.
333 struct mpt3_diag_register {
334 struct mpt3_ioctl_header hdr;
337 uint16_t application_flags;
338 uint32_t diagnostic_flags;
339 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
340 uint32_t requested_buffer_size;
345 * struct mpt3_diag_unregister - application unregister with driver
346 * @hdr - generic header
347 * @unique_id - tag uniquely identifies the buffer to be unregistered
349 * This will allow the driver to cleanup any memory allocated for diag
350 * messages and to free up any resources.
352 struct mpt3_diag_unregister {
353 struct mpt3_ioctl_header hdr;
358 * struct mpt3_diag_query - query relevant info associated with diag buffers
359 * @hdr - generic header
361 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
362 * @application_flags - misc flags
363 * @diagnostic_flags - specifies flags affecting command processing
364 * @product_specific - product specific information
365 * @total_buffer_size - diag buffer size in bytes
366 * @driver_added_buffer_size - size of extra space appended to end of buffer
367 * @unique_id - unique id associated with this buffer.
369 * The application will send only buffer_type and unique_id. Driver will
370 * inspect unique_id first, if valid, fill in all the info. If unique_id is
371 * 0x00, the driver will return info specified by Buffer Type.
373 struct mpt3_diag_query {
374 struct mpt3_ioctl_header hdr;
377 uint16_t application_flags;
378 uint32_t diagnostic_flags;
379 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
380 uint32_t total_buffer_size;
381 uint32_t driver_added_buffer_size;
386 * struct mpt3_diag_release - request to send Diag Release Message to firmware
387 * @hdr - generic header
388 * @unique_id - tag uniquely identifies the buffer to be released
390 * This allows ownership of the specified buffer to returned to the driver,
391 * allowing an application to read the buffer without fear that firmware is
392 * overwritting information in the buffer.
394 struct mpt3_diag_release {
395 struct mpt3_ioctl_header hdr;
400 * struct mpt3_diag_read_buffer - request for copy of the diag buffer
401 * @hdr - generic header
404 * @flags - misc flags
405 * @starting_offset - starting offset within drivers buffer where to start
406 * reading data at into the specified application buffer
407 * @bytes_to_read - number of bytes to copy from the drivers buffer into the
408 * application buffer starting at starting_offset.
409 * @unique_id - unique id associated with this buffer.
410 * @diagnostic_data - data payload
412 struct mpt3_diag_read_buffer {
413 struct mpt3_ioctl_header hdr;
417 uint32_t starting_offset;
418 uint32_t bytes_to_read;
420 uint32_t diagnostic_data[1];
423 #endif /* MPT3SAS_CTL_H_INCLUDED */