1635374e7eb110e80d9918b8611198edd56a32975Eric Moore/*
2635374e7eb110e80d9918b8611198edd56a32975Eric Moore * Management Module Support for MPT (Message Passing Technology) based
3635374e7eb110e80d9918b8611198edd56a32975Eric Moore * controllers
4635374e7eb110e80d9918b8611198edd56a32975Eric Moore *
5635374e7eb110e80d9918b8611198edd56a32975Eric Moore * This code is based on drivers/scsi/mpt2sas/mpt2_ctl.h
631b7f2e25d4b30d9b8701a6820c8e521cf409c29Kashyap, Desai * Copyright (C) 2007-2010  LSI Corporation
7635374e7eb110e80d9918b8611198edd56a32975Eric Moore *  (mailto:DL-MPTFusionLinux@lsi.com)
8635374e7eb110e80d9918b8611198edd56a32975Eric Moore *
9635374e7eb110e80d9918b8611198edd56a32975Eric Moore * This program is free software; you can redistribute it and/or
10635374e7eb110e80d9918b8611198edd56a32975Eric Moore * modify it under the terms of the GNU General Public License
11635374e7eb110e80d9918b8611198edd56a32975Eric Moore * as published by the Free Software Foundation; either version 2
12635374e7eb110e80d9918b8611198edd56a32975Eric Moore * of the License, or (at your option) any later version.
13635374e7eb110e80d9918b8611198edd56a32975Eric Moore *
14635374e7eb110e80d9918b8611198edd56a32975Eric Moore * This program is distributed in the hope that it will be useful,
15635374e7eb110e80d9918b8611198edd56a32975Eric Moore * but WITHOUT ANY WARRANTY; without even the implied warranty of
16635374e7eb110e80d9918b8611198edd56a32975Eric Moore * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17635374e7eb110e80d9918b8611198edd56a32975Eric Moore * GNU General Public License for more details.
18635374e7eb110e80d9918b8611198edd56a32975Eric Moore *
19635374e7eb110e80d9918b8611198edd56a32975Eric Moore * NO WARRANTY
20635374e7eb110e80d9918b8611198edd56a32975Eric Moore * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
21635374e7eb110e80d9918b8611198edd56a32975Eric Moore * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
22635374e7eb110e80d9918b8611198edd56a32975Eric Moore * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
23635374e7eb110e80d9918b8611198edd56a32975Eric Moore * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
24635374e7eb110e80d9918b8611198edd56a32975Eric Moore * solely responsible for determining the appropriateness of using and
25635374e7eb110e80d9918b8611198edd56a32975Eric Moore * distributing the Program and assumes all risks associated with its
26635374e7eb110e80d9918b8611198edd56a32975Eric Moore * exercise of rights under this Agreement, including but not limited to
27635374e7eb110e80d9918b8611198edd56a32975Eric Moore * the risks and costs of program errors, damage to or loss of data,
28635374e7eb110e80d9918b8611198edd56a32975Eric Moore * programs or equipment, and unavailability or interruption of operations.
29635374e7eb110e80d9918b8611198edd56a32975Eric Moore
30635374e7eb110e80d9918b8611198edd56a32975Eric Moore * DISCLAIMER OF LIABILITY
31635374e7eb110e80d9918b8611198edd56a32975Eric Moore * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
32635374e7eb110e80d9918b8611198edd56a32975Eric Moore * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33635374e7eb110e80d9918b8611198edd56a32975Eric Moore * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
34635374e7eb110e80d9918b8611198edd56a32975Eric Moore * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
35635374e7eb110e80d9918b8611198edd56a32975Eric Moore * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
36635374e7eb110e80d9918b8611198edd56a32975Eric Moore * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
37635374e7eb110e80d9918b8611198edd56a32975Eric Moore * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
38635374e7eb110e80d9918b8611198edd56a32975Eric Moore
39635374e7eb110e80d9918b8611198edd56a32975Eric Moore * You should have received a copy of the GNU General Public License
40635374e7eb110e80d9918b8611198edd56a32975Eric Moore * along with this program; if not, write to the Free Software
41635374e7eb110e80d9918b8611198edd56a32975Eric Moore * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
42635374e7eb110e80d9918b8611198edd56a32975Eric Moore * USA.
43635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
44635374e7eb110e80d9918b8611198edd56a32975Eric Moore
45635374e7eb110e80d9918b8611198edd56a32975Eric Moore#ifndef MPT2SAS_CTL_H_INCLUDED
46635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2SAS_CTL_H_INCLUDED
47635374e7eb110e80d9918b8611198edd56a32975Eric Moore
48635374e7eb110e80d9918b8611198edd56a32975Eric Moore#ifdef __KERNEL__
49635374e7eb110e80d9918b8611198edd56a32975Eric Moore#include <linux/miscdevice.h>
50635374e7eb110e80d9918b8611198edd56a32975Eric Moore#endif
51635374e7eb110e80d9918b8611198edd56a32975Eric Moore
52635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2SAS_DEV_NAME	"mpt2ctl"
53fd01825c70006638dee16f48c810c20c54f6cd15Eric Moore#define MPT2_MAGIC_NUMBER	'L'
54635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
55635374e7eb110e80d9918b8611198edd56a32975Eric Moore
56635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
57635374e7eb110e80d9918b8611198edd56a32975Eric Moore * IOCTL opcodes
58635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
59635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2IOCINFO	_IOWR(MPT2_MAGIC_NUMBER, 17, \
60635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_ioctl_iocinfo)
61635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2COMMAND	_IOWR(MPT2_MAGIC_NUMBER, 20, \
62635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_ioctl_command)
63635374e7eb110e80d9918b8611198edd56a32975Eric Moore#ifdef CONFIG_COMPAT
64635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2COMMAND32	_IOWR(MPT2_MAGIC_NUMBER, 20, \
65635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_ioctl_command32)
66635374e7eb110e80d9918b8611198edd56a32975Eric Moore#endif
67635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2EVENTQUERY	_IOWR(MPT2_MAGIC_NUMBER, 21, \
68635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_ioctl_eventquery)
69635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2EVENTENABLE	_IOWR(MPT2_MAGIC_NUMBER, 22, \
70635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_ioctl_eventenable)
71635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2EVENTREPORT	_IOWR(MPT2_MAGIC_NUMBER, 23, \
72635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_ioctl_eventreport)
73635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2HARDRESET	_IOWR(MPT2_MAGIC_NUMBER, 24, \
74635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_ioctl_diag_reset)
75635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2BTDHMAPPING	_IOWR(MPT2_MAGIC_NUMBER, 31, \
76635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_ioctl_btdh_mapping)
77635374e7eb110e80d9918b8611198edd56a32975Eric Moore
78635374e7eb110e80d9918b8611198edd56a32975Eric Moore/* diag buffer support */
79635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2DIAGREGISTER _IOWR(MPT2_MAGIC_NUMBER, 26, \
80635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_diag_register)
81635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2DIAGRELEASE	_IOWR(MPT2_MAGIC_NUMBER, 27, \
82635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_diag_release)
83635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2DIAGUNREGISTER _IOWR(MPT2_MAGIC_NUMBER, 28, \
84635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_diag_unregister)
85635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2DIAGQUERY	_IOWR(MPT2_MAGIC_NUMBER, 29, \
86635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_diag_query)
87635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2DIAGREADBUFFER _IOWR(MPT2_MAGIC_NUMBER, 30, \
88635374e7eb110e80d9918b8611198edd56a32975Eric Moore    struct mpt2_diag_read_buffer)
89635374e7eb110e80d9918b8611198edd56a32975Eric Moore
90635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
91635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_ioctl_header - main header structure
92635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @ioc_number -  IOC unit number
93635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @port_number - IOC port number
94635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @max_data_size - maximum number bytes to transfer on read
95635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
96635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_ioctl_header {
97635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t ioc_number;
98635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t port_number;
99635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t max_data_size;
100635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
101635374e7eb110e80d9918b8611198edd56a32975Eric Moore
102635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
103635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_ioctl_diag_reset - diagnostic reset
104635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
105635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
106635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_ioctl_diag_reset {
107635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
108635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
109635374e7eb110e80d9918b8611198edd56a32975Eric Moore
110635374e7eb110e80d9918b8611198edd56a32975Eric Moore
111635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
112635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_ioctl_pci_info - pci device info
113635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @device - pci device id
114635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @function - pci function id
115635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @bus - pci bus id
116635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @segment_id - pci segment id
117635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
118635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_ioctl_pci_info {
119635374e7eb110e80d9918b8611198edd56a32975Eric Moore	union {
120635374e7eb110e80d9918b8611198edd56a32975Eric Moore		struct {
121635374e7eb110e80d9918b8611198edd56a32975Eric Moore			uint32_t device:5;
122635374e7eb110e80d9918b8611198edd56a32975Eric Moore			uint32_t function:3;
123635374e7eb110e80d9918b8611198edd56a32975Eric Moore			uint32_t bus:24;
124635374e7eb110e80d9918b8611198edd56a32975Eric Moore		} bits;
125635374e7eb110e80d9918b8611198edd56a32975Eric Moore		uint32_t  word;
126635374e7eb110e80d9918b8611198edd56a32975Eric Moore	} u;
127635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t segment_id;
128635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
129635374e7eb110e80d9918b8611198edd56a32975Eric Moore
130635374e7eb110e80d9918b8611198edd56a32975Eric Moore
131635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_IOCTL_INTERFACE_SCSI	(0x00)
132635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_IOCTL_INTERFACE_FC		(0x01)
133635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_IOCTL_INTERFACE_FC_IP	(0x02)
134635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_IOCTL_INTERFACE_SAS	(0x03)
135635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_IOCTL_INTERFACE_SAS2	(0x04)
1360bdccdb0a090ad8dc5f851cad5e843244c410ee8Kashyap, Desai#define MPT2_IOCTL_INTERFACE_SAS2_SSS6200	(0x05)
137635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_IOCTL_VERSION_LENGTH	(32)
138635374e7eb110e80d9918b8611198edd56a32975Eric Moore
139635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
140635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_ioctl_iocinfo - generic controller info
141635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
142635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @adapter_type - type of adapter (spi, fc, sas)
143635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @port_number - port number
144635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @pci_id - PCI Id
145635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hw_rev - hardware revision
146635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @sub_system_device - PCI subsystem Device ID
147635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @sub_system_vendor - PCI subsystem Vendor ID
148635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @rsvd0 - reserved
149635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @firmware_version - firmware version
150635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @bios_version - BIOS version
151635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @driver_version - driver version - 32 ASCII characters
152635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @rsvd1 - reserved
153635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @scsi_id - scsi id of adapter 0
154635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @rsvd2 - reserved
155635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @pci_information - pci info (2nd revision)
156635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
157635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_ioctl_iocinfo {
158635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
159635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t adapter_type;
160635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t port_number;
161635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t pci_id;
162635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t hw_rev;
163635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t subsystem_device;
164635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t subsystem_vendor;
165635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t rsvd0;
166635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t firmware_version;
167635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t bios_version;
168635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
169635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t rsvd1;
170635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t scsi_id;
171635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint16_t rsvd2;
172635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_pci_info pci_information;
173635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
174635374e7eb110e80d9918b8611198edd56a32975Eric Moore
175635374e7eb110e80d9918b8611198edd56a32975Eric Moore
176635374e7eb110e80d9918b8611198edd56a32975Eric Moore/* number of event log entries */
177635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2SAS_CTL_EVENT_LOG_SIZE (50)
178635374e7eb110e80d9918b8611198edd56a32975Eric Moore
179635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
180635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_ioctl_eventquery - query event count and type
181635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
182635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @event_entries - number of events returned by get_event_report
183635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @rsvd - reserved
184635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @event_types - type of events currently being captured
185635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
186635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_ioctl_eventquery {
187635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
188635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint16_t event_entries;
189635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint16_t rsvd;
190635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
191635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
192635374e7eb110e80d9918b8611198edd56a32975Eric Moore
193635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
194635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_ioctl_eventenable - enable/disable event capturing
195635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
196635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @event_types - toggle off/on type of events to be captured
197635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
198635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_ioctl_eventenable {
199635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
200635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t event_types[4];
201635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
202635374e7eb110e80d9918b8611198edd56a32975Eric Moore
203635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_EVENT_DATA_SIZE (192)
204635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
205635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct MPT2_IOCTL_EVENTS -
206635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @event - the event that was reported
207635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @context - unique value for each event assigned by driver
208635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @data - event data returned in fw reply message
209635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
210635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct MPT2_IOCTL_EVENTS {
211635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t event;
212635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t context;
213635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t data[MPT2_EVENT_DATA_SIZE];
214635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
215635374e7eb110e80d9918b8611198edd56a32975Eric Moore
216635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
217635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_ioctl_eventreport - returing event log
218635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
219635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @event_data - (see struct MPT2_IOCTL_EVENTS)
220635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
221635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_ioctl_eventreport {
222635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
223635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct MPT2_IOCTL_EVENTS event_data[1];
224635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
225635374e7eb110e80d9918b8611198edd56a32975Eric Moore
226635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
227635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_ioctl_command - generic mpt firmware passthru ioclt
228635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
229635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @timeout - command timeout in seconds. (if zero then use driver default
230635374e7eb110e80d9918b8611198edd56a32975Eric Moore *  value).
231635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @reply_frame_buf_ptr - reply location
232635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @data_in_buf_ptr - destination for read
233635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @data_out_buf_ptr - data source for write
234635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @sense_data_ptr - sense data location
235635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @max_reply_bytes - maximum number of reply bytes to be sent to app.
236635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @data_in_size - number bytes for data transfer in (read)
237635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @data_out_size - number bytes for data transfer out (write)
238635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @max_sense_bytes - maximum number of bytes for auto sense buffers
239635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @data_sge_offset - offset in words from the start of the request message to
240635374e7eb110e80d9918b8611198edd56a32975Eric Moore * the first SGL
241635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @mf[1];
242635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
243635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_ioctl_command {
244635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
245635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t timeout;
246635374e7eb110e80d9918b8611198edd56a32975Eric Moore	void __user *reply_frame_buf_ptr;
247635374e7eb110e80d9918b8611198edd56a32975Eric Moore	void __user *data_in_buf_ptr;
248635374e7eb110e80d9918b8611198edd56a32975Eric Moore	void __user *data_out_buf_ptr;
249635374e7eb110e80d9918b8611198edd56a32975Eric Moore	void __user *sense_data_ptr;
250635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t max_reply_bytes;
251635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t data_in_size;
252635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t data_out_size;
253635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t max_sense_bytes;
254635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t data_sge_offset;
255635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t mf[1];
256635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
257635374e7eb110e80d9918b8611198edd56a32975Eric Moore
258635374e7eb110e80d9918b8611198edd56a32975Eric Moore#ifdef CONFIG_COMPAT
259635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_ioctl_command32 {
260635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
261635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t timeout;
262635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t reply_frame_buf_ptr;
263635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t data_in_buf_ptr;
264635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t data_out_buf_ptr;
265635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t sense_data_ptr;
266635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t max_reply_bytes;
267635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t data_in_size;
268635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t data_out_size;
269635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t max_sense_bytes;
270635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t data_sge_offset;
271635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t mf[1];
272635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
273635374e7eb110e80d9918b8611198edd56a32975Eric Moore#endif
274635374e7eb110e80d9918b8611198edd56a32975Eric Moore
275635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
276635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_ioctl_btdh_mapping - mapping info
277635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
278635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @id - target device identification number
279635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @bus - SCSI bus number that the target device exists on
280635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @handle - device handle for the target device
281635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @rsvd - reserved
282635374e7eb110e80d9918b8611198edd56a32975Eric Moore *
283635374e7eb110e80d9918b8611198edd56a32975Eric Moore * To obtain a bus/id the application sets
284635374e7eb110e80d9918b8611198edd56a32975Eric Moore * handle to valid handle, and bus/id to 0xFFFF.
285635374e7eb110e80d9918b8611198edd56a32975Eric Moore *
286635374e7eb110e80d9918b8611198edd56a32975Eric Moore * To obtain the device handle the application sets
287635374e7eb110e80d9918b8611198edd56a32975Eric Moore * bus/id valid value, and the handle to 0xFFFF.
288635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
289635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_ioctl_btdh_mapping {
290635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
291635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t id;
292635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t bus;
293635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint16_t handle;
294635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint16_t rsvd;
295635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
296635374e7eb110e80d9918b8611198edd56a32975Eric Moore
297635374e7eb110e80d9918b8611198edd56a32975Eric Moore
298635374e7eb110e80d9918b8611198edd56a32975Eric Moore/* status bits for ioc->diag_buffer_status */
29999bb214b1b652c475bb3d79cede47ecb76b758faEric Moore#define MPT2_DIAG_BUFFER_IS_REGISTERED	(0x01)
30099bb214b1b652c475bb3d79cede47ecb76b758faEric Moore#define MPT2_DIAG_BUFFER_IS_RELEASED	(0x02)
30199bb214b1b652c475bb3d79cede47ecb76b758faEric Moore#define MPT2_DIAG_BUFFER_IS_DIAG_RESET	(0x04)
302635374e7eb110e80d9918b8611198edd56a32975Eric Moore
303635374e7eb110e80d9918b8611198edd56a32975Eric Moore/* application flags for mpt2_diag_register, mpt2_diag_query */
304635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_APP_FLAGS_APP_OWNED	(0x0001)
305635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_APP_FLAGS_BUFFER_VALID	(0x0002)
306635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_APP_FLAGS_FW_BUFFER_ACCESS	(0x0004)
307635374e7eb110e80d9918b8611198edd56a32975Eric Moore
308635374e7eb110e80d9918b8611198edd56a32975Eric Moore/* flags for mpt2_diag_read_buffer */
309635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_FLAGS_REREGISTER		(0x0001)
310635374e7eb110e80d9918b8611198edd56a32975Eric Moore
311635374e7eb110e80d9918b8611198edd56a32975Eric Moore#define MPT2_PRODUCT_SPECIFIC_DWORDS 		23
312635374e7eb110e80d9918b8611198edd56a32975Eric Moore
313635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
314635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_diag_register - application register with driver
315635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
316635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @reserved -
3171b01fe3aa58b114b2dc296676023451c6434561eKashyap, Desai * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
318635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @application_flags - misc flags
319635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @diagnostic_flags - specifies flags affecting command processing
320635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @product_specific - product specific information
321635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @requested_buffer_size - buffers size in bytes
322635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @unique_id - tag specified by application that is used to signal ownership
323635374e7eb110e80d9918b8611198edd56a32975Eric Moore *  of the buffer.
324635374e7eb110e80d9918b8611198edd56a32975Eric Moore *
325635374e7eb110e80d9918b8611198edd56a32975Eric Moore * This will allow the driver to setup any required buffers that will be
326635374e7eb110e80d9918b8611198edd56a32975Eric Moore * needed by firmware to communicate with the driver.
327635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
328635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_diag_register {
329635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
330635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t reserved;
331635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t buffer_type;
332635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint16_t application_flags;
333635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t diagnostic_flags;
334635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t product_specific[MPT2_PRODUCT_SPECIFIC_DWORDS];
335635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t requested_buffer_size;
336635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t unique_id;
337635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
338635374e7eb110e80d9918b8611198edd56a32975Eric Moore
339635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
340635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_diag_unregister - application unregister with driver
341635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
342635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @unique_id - tag uniquely identifies the buffer to be unregistered
343635374e7eb110e80d9918b8611198edd56a32975Eric Moore *
344635374e7eb110e80d9918b8611198edd56a32975Eric Moore * This will allow the driver to cleanup any memory allocated for diag
345635374e7eb110e80d9918b8611198edd56a32975Eric Moore * messages and to free up any resources.
346635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
347635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_diag_unregister {
348635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
349635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t unique_id;
350635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
351635374e7eb110e80d9918b8611198edd56a32975Eric Moore
352635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
353635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_diag_query - query relevant info associated with diag buffers
354635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
355635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @reserved -
3561b01fe3aa58b114b2dc296676023451c6434561eKashyap, Desai * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
357635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @application_flags - misc flags
358635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @diagnostic_flags - specifies flags affecting command processing
359635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @product_specific - product specific information
360635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @total_buffer_size - diag buffer size in bytes
361635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @driver_added_buffer_size - size of extra space appended to end of buffer
362635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @unique_id - unique id associated with this buffer.
363635374e7eb110e80d9918b8611198edd56a32975Eric Moore *
364635374e7eb110e80d9918b8611198edd56a32975Eric Moore * The application will send only buffer_type and unique_id.  Driver will
365635374e7eb110e80d9918b8611198edd56a32975Eric Moore * inspect unique_id first, if valid, fill in all the info.  If unique_id is
366635374e7eb110e80d9918b8611198edd56a32975Eric Moore * 0x00, the driver will return info specified by Buffer Type.
367635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
368635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_diag_query {
369635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
370635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t reserved;
371635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t buffer_type;
372635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint16_t application_flags;
373635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t diagnostic_flags;
374635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t product_specific[MPT2_PRODUCT_SPECIFIC_DWORDS];
375635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t total_buffer_size;
376635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t driver_added_buffer_size;
377635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t unique_id;
378635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
379635374e7eb110e80d9918b8611198edd56a32975Eric Moore
380635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
381635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_diag_release -  request to send Diag Release Message to firmware
382635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
383635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @unique_id - tag uniquely identifies the buffer to be released
384635374e7eb110e80d9918b8611198edd56a32975Eric Moore *
385635374e7eb110e80d9918b8611198edd56a32975Eric Moore * This allows ownership of the specified buffer to returned to the driver,
386635374e7eb110e80d9918b8611198edd56a32975Eric Moore * allowing an application to read the buffer without fear that firmware is
387635374e7eb110e80d9918b8611198edd56a32975Eric Moore * overwritting information in the buffer.
388635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
389635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_diag_release {
390635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
391635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t unique_id;
392635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
393635374e7eb110e80d9918b8611198edd56a32975Eric Moore
394635374e7eb110e80d9918b8611198edd56a32975Eric Moore/**
395635374e7eb110e80d9918b8611198edd56a32975Eric Moore * struct mpt2_diag_read_buffer - request for copy of the diag buffer
396635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @hdr - generic header
397635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @status -
398635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @reserved -
399635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @flags - misc flags
400635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @starting_offset - starting offset within drivers buffer where to start
401635374e7eb110e80d9918b8611198edd56a32975Eric Moore *  reading data at into the specified application buffer
402635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @bytes_to_read - number of bytes to copy from the drivers buffer into the
403635374e7eb110e80d9918b8611198edd56a32975Eric Moore *  application buffer starting at starting_offset.
404635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @unique_id - unique id associated with this buffer.
405635374e7eb110e80d9918b8611198edd56a32975Eric Moore * @diagnostic_data - data payload
406635374e7eb110e80d9918b8611198edd56a32975Eric Moore */
407635374e7eb110e80d9918b8611198edd56a32975Eric Moorestruct mpt2_diag_read_buffer {
408635374e7eb110e80d9918b8611198edd56a32975Eric Moore	struct mpt2_ioctl_header hdr;
409635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t status;
410635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint8_t reserved;
411635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint16_t flags;
412635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t starting_offset;
413635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t bytes_to_read;
414635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t unique_id;
415635374e7eb110e80d9918b8611198edd56a32975Eric Moore	uint32_t diagnostic_data[1];
416635374e7eb110e80d9918b8611198edd56a32975Eric Moore};
417635374e7eb110e80d9918b8611198edd56a32975Eric Moore
418635374e7eb110e80d9918b8611198edd56a32975Eric Moore#endif /* MPT2SAS_CTL_H_INCLUDED */
419