blob: 0f7aa4ddade0acc93af96bde74eb6f0174cd03a5 [file] [log] [blame]
Sreekanth Reddyf92363d2012-11-30 07:44:21 +05301/*
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
Sreekanth Reddya4ffce02014-09-12 15:35:29 +05306 * Copyright (C) 2012-2014 LSI Corporation
Sreekanth Reddya03bd152015-01-12 11:39:02 +05307 * Copyright (C) 2013-2014 Avago Technologies
8 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
Sreekanth Reddyf92363d2012-11-30 07:44:21 +05309 *
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
Sreekanth Reddy78f97c82015-11-11 17:30:20 +053053#ifndef MPT2SAS_MINOR
54#define MPT2SAS_MINOR (MPT_MINOR + 1)
55#endif
Sreekanth Reddyf92363d2012-11-30 07:44:21 +053056#ifndef MPT3SAS_MINOR
57#define MPT3SAS_MINOR (MPT_MINOR + 2)
58#endif
Sreekanth Reddy78f97c82015-11-11 17:30:20 +053059#define MPT2SAS_DEV_NAME "mpt2ctl"
Sreekanth Reddyf92363d2012-11-30 07:44:21 +053060#define MPT3SAS_DEV_NAME "mpt3ctl"
61#define MPT3_MAGIC_NUMBER 'L'
62#define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
63
64/**
65 * IOCTL opcodes
66 */
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)
71#ifdef CONFIG_COMPAT
72#define MPT3COMMAND32 _IOWR(MPT3_MAGIC_NUMBER, 20, \
73 struct mpt3_ioctl_command32)
74#endif
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)
85
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)
97
Sreekanth Reddy08e73782019-09-13 09:04:42 -040098/* Trace Buffer default UniqueId */
99#define MPT2DIAGBUFFUNIQUEID (0x07075900)
100#define MPT3DIAGBUFFUNIQUEID (0x4252434D)
101
102/* UID not found */
103#define MPT3_DIAG_UID_NOT_FOUND (0xFF)
104
105
Sreekanth Reddyf92363d2012-11-30 07:44:21 +0530106/**
107 * struct mpt3_ioctl_header - main header structure
108 * @ioc_number - IOC unit number
109 * @port_number - IOC port number
110 * @max_data_size - maximum number bytes to transfer on read
111 */
112struct mpt3_ioctl_header {
113 uint32_t ioc_number;
114 uint32_t port_number;
115 uint32_t max_data_size;
116};
117
118/**
119 * struct mpt3_ioctl_diag_reset - diagnostic reset
120 * @hdr - generic header
121 */
122struct mpt3_ioctl_diag_reset {
123 struct mpt3_ioctl_header hdr;
124};
125
126
127/**
128 * struct mpt3_ioctl_pci_info - pci device info
129 * @device - pci device id
130 * @function - pci function id
131 * @bus - pci bus id
132 * @segment_id - pci segment id
133 */
134struct mpt3_ioctl_pci_info {
135 union {
136 struct {
137 uint32_t device:5;
138 uint32_t function:3;
139 uint32_t bus:24;
140 } bits;
141 uint32_t word;
142 } u;
143 uint32_t segment_id;
144};
145
146
147#define MPT2_IOCTL_INTERFACE_SCSI (0x00)
148#define MPT2_IOCTL_INTERFACE_FC (0x01)
149#define MPT2_IOCTL_INTERFACE_FC_IP (0x02)
150#define MPT2_IOCTL_INTERFACE_SAS (0x03)
151#define MPT2_IOCTL_INTERFACE_SAS2 (0x04)
Sreekanth Reddy7786ab62015-11-11 17:30:28 +0530152#define MPT2_IOCTL_INTERFACE_SAS2_SSS6200 (0x05)
Sreekanth Reddyf92363d2012-11-30 07:44:21 +0530153#define MPT3_IOCTL_INTERFACE_SAS3 (0x06)
Suganath Prabu Subramani998f26a2016-10-26 13:34:37 +0530154#define MPT3_IOCTL_INTERFACE_SAS35 (0x07)
Sreekanth Reddyf92363d2012-11-30 07:44:21 +0530155#define MPT2_IOCTL_VERSION_LENGTH (32)
156
157/**
158 * struct mpt3_ioctl_iocinfo - generic controller info
159 * @hdr - generic header
160 * @adapter_type - type of adapter (spi, fc, sas)
161 * @port_number - port number
162 * @pci_id - PCI Id
163 * @hw_rev - hardware revision
164 * @sub_system_device - PCI subsystem Device ID
165 * @sub_system_vendor - PCI subsystem Vendor ID
166 * @rsvd0 - reserved
167 * @firmware_version - firmware version
168 * @bios_version - BIOS version
169 * @driver_version - driver version - 32 ASCII characters
170 * @rsvd1 - reserved
171 * @scsi_id - scsi id of adapter 0
172 * @rsvd2 - reserved
173 * @pci_information - pci info (2nd revision)
174 */
175struct mpt3_ioctl_iocinfo {
176 struct mpt3_ioctl_header hdr;
177 uint32_t adapter_type;
178 uint32_t port_number;
179 uint32_t pci_id;
180 uint32_t hw_rev;
181 uint32_t subsystem_device;
182 uint32_t subsystem_vendor;
183 uint32_t rsvd0;
184 uint32_t firmware_version;
185 uint32_t bios_version;
186 uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
187 uint8_t rsvd1;
188 uint8_t scsi_id;
189 uint16_t rsvd2;
190 struct mpt3_ioctl_pci_info pci_information;
191};
192
193
194/* number of event log entries */
Chaitra P B1537d1b2018-04-24 05:28:36 -0400195#define MPT3SAS_CTL_EVENT_LOG_SIZE (200)
Sreekanth Reddyf92363d2012-11-30 07:44:21 +0530196
197/**
198 * struct mpt3_ioctl_eventquery - query event count and type
199 * @hdr - generic header
200 * @event_entries - number of events returned by get_event_report
201 * @rsvd - reserved
202 * @event_types - type of events currently being captured
203 */
204struct mpt3_ioctl_eventquery {
205 struct mpt3_ioctl_header hdr;
206 uint16_t event_entries;
207 uint16_t rsvd;
208 uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
209};
210
211/**
212 * struct mpt3_ioctl_eventenable - enable/disable event capturing
213 * @hdr - generic header
214 * @event_types - toggle off/on type of events to be captured
215 */
216struct mpt3_ioctl_eventenable {
217 struct mpt3_ioctl_header hdr;
218 uint32_t event_types[4];
219};
220
221#define MPT3_EVENT_DATA_SIZE (192)
222/**
223 * struct MPT3_IOCTL_EVENTS -
224 * @event - the event that was reported
225 * @context - unique value for each event assigned by driver
226 * @data - event data returned in fw reply message
227 */
228struct MPT3_IOCTL_EVENTS {
229 uint32_t event;
230 uint32_t context;
231 uint8_t data[MPT3_EVENT_DATA_SIZE];
232};
233
234/**
235 * struct mpt3_ioctl_eventreport - returing event log
236 * @hdr - generic header
237 * @event_data - (see struct MPT3_IOCTL_EVENTS)
238 */
239struct mpt3_ioctl_eventreport {
240 struct mpt3_ioctl_header hdr;
241 struct MPT3_IOCTL_EVENTS event_data[1];
242};
243
244/**
245 * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl
246 * @hdr - generic header
247 * @timeout - command timeout in seconds. (if zero then use driver default
248 * value).
249 * @reply_frame_buf_ptr - reply location
250 * @data_in_buf_ptr - destination for read
251 * @data_out_buf_ptr - data source for write
252 * @sense_data_ptr - sense data location
253 * @max_reply_bytes - maximum number of reply bytes to be sent to app.
254 * @data_in_size - number bytes for data transfer in (read)
255 * @data_out_size - number bytes for data transfer out (write)
256 * @max_sense_bytes - maximum number of bytes for auto sense buffers
257 * @data_sge_offset - offset in words from the start of the request message to
258 * the first SGL
259 * @mf[1];
260 */
261struct mpt3_ioctl_command {
262 struct mpt3_ioctl_header hdr;
263 uint32_t timeout;
264 void __user *reply_frame_buf_ptr;
265 void __user *data_in_buf_ptr;
266 void __user *data_out_buf_ptr;
267 void __user *sense_data_ptr;
268 uint32_t max_reply_bytes;
269 uint32_t data_in_size;
270 uint32_t data_out_size;
271 uint32_t max_sense_bytes;
272 uint32_t data_sge_offset;
273 uint8_t mf[1];
274};
275
276#ifdef CONFIG_COMPAT
277struct mpt3_ioctl_command32 {
278 struct mpt3_ioctl_header hdr;
279 uint32_t timeout;
280 uint32_t reply_frame_buf_ptr;
281 uint32_t data_in_buf_ptr;
282 uint32_t data_out_buf_ptr;
283 uint32_t sense_data_ptr;
284 uint32_t max_reply_bytes;
285 uint32_t data_in_size;
286 uint32_t data_out_size;
287 uint32_t max_sense_bytes;
288 uint32_t data_sge_offset;
289 uint8_t mf[1];
290};
291#endif
292
293/**
294 * struct mpt3_ioctl_btdh_mapping - mapping info
295 * @hdr - generic header
296 * @id - target device identification number
297 * @bus - SCSI bus number that the target device exists on
298 * @handle - device handle for the target device
299 * @rsvd - reserved
300 *
301 * To obtain a bus/id the application sets
302 * handle to valid handle, and bus/id to 0xFFFF.
303 *
304 * To obtain the device handle the application sets
305 * bus/id valid value, and the handle to 0xFFFF.
306 */
307struct mpt3_ioctl_btdh_mapping {
308 struct mpt3_ioctl_header hdr;
309 uint32_t id;
310 uint32_t bus;
311 uint16_t handle;
312 uint16_t rsvd;
313};
314
315
316
317/* application flags for mpt3_diag_register, mpt3_diag_query */
318#define MPT3_APP_FLAGS_APP_OWNED (0x0001)
319#define MPT3_APP_FLAGS_BUFFER_VALID (0x0002)
320#define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
Sreekanth Reddya066f4c2019-09-13 09:04:44 -0400321#define MPT3_APP_FLAGS_DYNAMIC_BUFFER_ALLOC (0x0008)
Sreekanth Reddyf92363d2012-11-30 07:44:21 +0530322
323/* flags for mpt3_diag_read_buffer */
324#define MPT3_FLAGS_REREGISTER (0x0001)
325
326#define MPT3_PRODUCT_SPECIFIC_DWORDS 23
327
328/**
329 * struct mpt3_diag_register - application register with driver
330 * @hdr - generic header
331 * @reserved -
332 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
333 * @application_flags - misc flags
334 * @diagnostic_flags - specifies flags affecting command processing
335 * @product_specific - product specific information
336 * @requested_buffer_size - buffers size in bytes
337 * @unique_id - tag specified by application that is used to signal ownership
338 * of the buffer.
339 *
340 * This will allow the driver to setup any required buffers that will be
341 * needed by firmware to communicate with the driver.
342 */
343struct mpt3_diag_register {
344 struct mpt3_ioctl_header hdr;
345 uint8_t reserved;
346 uint8_t buffer_type;
347 uint16_t application_flags;
348 uint32_t diagnostic_flags;
349 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
350 uint32_t requested_buffer_size;
351 uint32_t unique_id;
352};
353
354/**
355 * struct mpt3_diag_unregister - application unregister with driver
356 * @hdr - generic header
357 * @unique_id - tag uniquely identifies the buffer to be unregistered
358 *
359 * This will allow the driver to cleanup any memory allocated for diag
360 * messages and to free up any resources.
361 */
362struct mpt3_diag_unregister {
363 struct mpt3_ioctl_header hdr;
364 uint32_t unique_id;
365};
366
367/**
368 * struct mpt3_diag_query - query relevant info associated with diag buffers
369 * @hdr - generic header
370 * @reserved -
371 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
372 * @application_flags - misc flags
373 * @diagnostic_flags - specifies flags affecting command processing
374 * @product_specific - product specific information
375 * @total_buffer_size - diag buffer size in bytes
376 * @driver_added_buffer_size - size of extra space appended to end of buffer
377 * @unique_id - unique id associated with this buffer.
378 *
379 * The application will send only buffer_type and unique_id. Driver will
380 * inspect unique_id first, if valid, fill in all the info. If unique_id is
381 * 0x00, the driver will return info specified by Buffer Type.
382 */
383struct mpt3_diag_query {
384 struct mpt3_ioctl_header hdr;
385 uint8_t reserved;
386 uint8_t buffer_type;
387 uint16_t application_flags;
388 uint32_t diagnostic_flags;
389 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
390 uint32_t total_buffer_size;
391 uint32_t driver_added_buffer_size;
392 uint32_t unique_id;
393};
394
395/**
396 * struct mpt3_diag_release - request to send Diag Release Message to firmware
397 * @hdr - generic header
398 * @unique_id - tag uniquely identifies the buffer to be released
399 *
400 * This allows ownership of the specified buffer to returned to the driver,
401 * allowing an application to read the buffer without fear that firmware is
Masahiro Yamada9a284e52017-02-27 14:29:48 -0800402 * overwriting information in the buffer.
Sreekanth Reddyf92363d2012-11-30 07:44:21 +0530403 */
404struct mpt3_diag_release {
405 struct mpt3_ioctl_header hdr;
406 uint32_t unique_id;
407};
408
409/**
410 * struct mpt3_diag_read_buffer - request for copy of the diag buffer
411 * @hdr - generic header
412 * @status -
413 * @reserved -
414 * @flags - misc flags
415 * @starting_offset - starting offset within drivers buffer where to start
416 * reading data at into the specified application buffer
417 * @bytes_to_read - number of bytes to copy from the drivers buffer into the
418 * application buffer starting at starting_offset.
419 * @unique_id - unique id associated with this buffer.
420 * @diagnostic_data - data payload
421 */
422struct mpt3_diag_read_buffer {
423 struct mpt3_ioctl_header hdr;
424 uint8_t status;
425 uint8_t reserved;
426 uint16_t flags;
427 uint32_t starting_offset;
428 uint32_t bytes_to_read;
429 uint32_t unique_id;
430 uint32_t diagnostic_data[1];
431};
432
433#endif /* MPT3SAS_CTL_H_INCLUDED */