brintos

brintos / linux-shallow public Read only

0
0
Text · 13.6 KiB · d564cc9 Raw
468 lines · c
1/*2 *  linux/drivers/message/fusion/mptioctl.h3 *      Fusion MPT misc device (ioctl) driver.4 *      For use with PCI chip/adapter(s):5 *          LSIFC9xx/LSI409xx Fibre Channel6 *      running LSI Fusion MPT (Message Passing Technology) firmware.7 *8 *  Copyright (c) 1999-2008 LSI Corporation9 *  (mailto:DL-MPTFusionLinux@lsi.com)10 *11 */12/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/13/*14    This program is free software; you can redistribute it and/or modify15    it under the terms of the GNU General Public License as published by16    the Free Software Foundation; version 2 of the License.17 18    This program is distributed in the hope that it will be useful,19    but WITHOUT ANY WARRANTY; without even the implied warranty of20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the21    GNU General Public License for more details.22 23    NO WARRANTY24    THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR25    CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT26    LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,27    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is28    solely responsible for determining the appropriateness of using and29    distributing the Program and assumes all risks associated with its30    exercise of rights under this Agreement, including but not limited to31    the risks and costs of program errors, damage to or loss of data,32    programs or equipment, and unavailability or interruption of operations.33 34    DISCLAIMER OF LIABILITY35    NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY36    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL37    DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND38    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR39    TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE40    USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED41    HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES42 43    You should have received a copy of the GNU General Public License44    along with this program; if not, write to the Free Software45    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA46*/47 48#ifndef MPTCTL_H_INCLUDED49#define MPTCTL_H_INCLUDED50/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/51 52 53 54/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/55/*56 *57 */58#define MPT_MISCDEV_BASENAME            "mptctl"59#define MPT_MISCDEV_PATHNAME            "/dev/" MPT_MISCDEV_BASENAME60 61#define MPT_PRODUCT_LENGTH              1262 63/*64 *  Generic MPT Control IOCTLs and structures65 */66#define MPT_MAGIC_NUMBER	'm'67 68#define MPTRWPERF		_IOWR(MPT_MAGIC_NUMBER,0,struct mpt_raw_r_w)69 70#define MPTFWDOWNLOAD		_IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer)71#define MPTCOMMAND		_IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command)72 73#if defined(__KERNEL__) && defined(CONFIG_COMPAT)74#define MPTFWDOWNLOAD32		_IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer32)75#define MPTCOMMAND32		_IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command32)76#endif77 78#define MPTIOCINFO		_IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo)79#define MPTIOCINFO1		_IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev0)80#define MPTIOCINFO2		_IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev1)81#define MPTTARGETINFO		_IOWR(MPT_MAGIC_NUMBER,18,struct mpt_ioctl_targetinfo)82#define MPTTEST			_IOWR(MPT_MAGIC_NUMBER,19,struct mpt_ioctl_test)83#define MPTEVENTQUERY		_IOWR(MPT_MAGIC_NUMBER,21,struct mpt_ioctl_eventquery)84#define MPTEVENTENABLE		_IOWR(MPT_MAGIC_NUMBER,22,struct mpt_ioctl_eventenable)85#define MPTEVENTREPORT		_IOWR(MPT_MAGIC_NUMBER,23,struct mpt_ioctl_eventreport)86#define MPTHARDRESET		_IOWR(MPT_MAGIC_NUMBER,24,struct mpt_ioctl_diag_reset)87#define MPTFWREPLACE		_IOWR(MPT_MAGIC_NUMBER,25,struct mpt_ioctl_replace_fw)88 89/*90 * SPARC PLATFORM REMARKS:91 * IOCTL data structures that contain pointers92 * will have different sizes in the driver and applications93 * (as the app. will not use 8-byte pointers).94 * Apps should use MPTFWDOWNLOAD and MPTCOMMAND.95 * The driver will convert data from96 * mpt_fw_xfer32 (mpt_ioctl_command32) to mpt_fw_xfer (mpt_ioctl_command)97 * internally.98 *99 * If data structures change size, must handle as in IOCGETINFO.100 */101struct mpt_fw_xfer {102	unsigned int	 iocnum;	/* IOC unit number */103	unsigned int	 fwlen;104	void		__user *bufp;	/* Pointer to firmware buffer */105};106 107#if defined(__KERNEL__) && defined(CONFIG_COMPAT)108struct mpt_fw_xfer32 {109	unsigned int iocnum;110	unsigned int fwlen;111	u32 bufp;112};113#endif	/*}*/114 115/*116 *  IOCTL header structure.117 *  iocnum - must be defined.118 *  port - must be defined for all IOCTL commands other than MPTIOCINFO119 *  maxDataSize - ignored on MPTCOMMAND commands120 *		- ignored on MPTFWREPLACE commands121 *		- on query commands, reports the maximum number of bytes to be returned122 *		  to the host driver (count includes the header).123 *		  That is, set to sizeof(struct mpt_ioctl_iocinfo) for fixed sized commands.124 *		  Set to sizeof(struct mpt_ioctl_targetinfo) + datasize for variable125 *			sized commands. (MPTTARGETINFO, MPTEVENTREPORT)126 */127typedef struct _mpt_ioctl_header {128	unsigned int	 iocnum;	/* IOC unit number */129	unsigned int	 port;		/* IOC port number */130	int		 maxDataSize;	/* Maximum Num. bytes to transfer on read */131} mpt_ioctl_header;132 133/*134 * Issue a diagnostic reset135 */136struct mpt_ioctl_diag_reset {137	mpt_ioctl_header hdr;138};139 140 141/*142 *  PCI bus/device/function information structure.143 */144struct mpt_ioctl_pci_info {145	union {146		struct {147			unsigned int  deviceNumber   :  5;148			unsigned int  functionNumber :  3;149			unsigned int  busNumber      : 24;150		} bits;151		unsigned int  asUlong;152	} u;153};154 155struct mpt_ioctl_pci_info2 {156	union {157		struct {158			unsigned int  deviceNumber   :  5;159			unsigned int  functionNumber :  3;160			unsigned int  busNumber      : 24;161		} bits;162		unsigned int  asUlong;163	} u;164  int segmentID;165};166 167/*168 *  Adapter Information Page169 *  Read only.170 *  Data starts at offset 0xC171 */172#define MPT_IOCTL_INTERFACE_SCSI	(0x00)173#define MPT_IOCTL_INTERFACE_FC		(0x01)174#define MPT_IOCTL_INTERFACE_FC_IP	(0x02)175#define MPT_IOCTL_INTERFACE_SAS		(0x03)176#define MPT_IOCTL_VERSION_LENGTH	(32)177 178struct mpt_ioctl_iocinfo {179	mpt_ioctl_header hdr;180	int		 adapterType;	/* SCSI or FCP */181	int		 port;		/* port number */182	int		 pciId;		/* PCI Id. */183	int		 hwRev;		/* hardware revision */184	int		 subSystemDevice;	/* PCI subsystem Device ID */185	int		 subSystemVendor;	/* PCI subsystem Vendor ID */186	int		 numDevices;		/* number of devices */187	int		 FWVersion;		/* FW Version (integer) */188	int		 BIOSVersion;		/* BIOS Version (integer) */189	char		 driverVersion[MPT_IOCTL_VERSION_LENGTH];	/* Driver Version (string) */190	char		 busChangeEvent;191	char		 hostId;192	char		 rsvd[2];193	struct mpt_ioctl_pci_info2  pciInfo; /* Added Rev 2 */194};195 196struct mpt_ioctl_iocinfo_rev1 {197	mpt_ioctl_header hdr;198	int		 adapterType;	/* SCSI or FCP */199	int		 port;		/* port number */200	int		 pciId;		/* PCI Id. */201	int		 hwRev;		/* hardware revision */202	int		 subSystemDevice;	/* PCI subsystem Device ID */203	int		 subSystemVendor;	/* PCI subsystem Vendor ID */204	int		 numDevices;		/* number of devices */205	int		 FWVersion;		/* FW Version (integer) */206	int		 BIOSVersion;		/* BIOS Version (integer) */207	char		 driverVersion[MPT_IOCTL_VERSION_LENGTH];	/* Driver Version (string) */208	char		 busChangeEvent;209	char		 hostId;210	char		 rsvd[2];211	struct mpt_ioctl_pci_info  pciInfo; /* Added Rev 1 */212};213 214/* Original structure, must always accept these215 * IOCTLs. 4 byte pads can occur based on arch with216 * above structure. Wish to re-align, but cannot.217 */218struct mpt_ioctl_iocinfo_rev0 {219	mpt_ioctl_header hdr;220	int		 adapterType;	/* SCSI or FCP */221	int		 port;		/* port number */222	int		 pciId;		/* PCI Id. */223	int		 hwRev;		/* hardware revision */224	int		 subSystemDevice;	/* PCI subsystem Device ID */225	int		 subSystemVendor;	/* PCI subsystem Vendor ID */226	int		 numDevices;		/* number of devices */227	int		 FWVersion;		/* FW Version (integer) */228	int		 BIOSVersion;		/* BIOS Version (integer) */229	char		 driverVersion[MPT_IOCTL_VERSION_LENGTH];	/* Driver Version (string) */230	char		 busChangeEvent;231	char		 hostId;232	char		 rsvd[2];233};234 235/*236 * Device Information Page237 * Report the number of, and ids of, all targets238 * on this IOC.  The ids array is a packed structure239 * of the known targetInfo.240 * bits 31-24: reserved241 *      23-16: LUN242 *      15- 8: Bus Number243 *       7- 0: Target ID244 */245struct mpt_ioctl_targetinfo {246	mpt_ioctl_header hdr;247	int		 numDevices;	/* Num targets on this ioc */248	int		 targetInfo[1];249};250 251 252/*253 * Event reporting IOCTL's.  These IOCTL's will254 * use the following defines:255 */256struct mpt_ioctl_eventquery {257	mpt_ioctl_header hdr;258	unsigned short	 eventEntries;259	unsigned short	 reserved;260	unsigned int	 eventTypes;261};262 263struct mpt_ioctl_eventenable {264	mpt_ioctl_header hdr;265	unsigned int	 eventTypes;266};267 268#ifndef __KERNEL__269typedef struct {270	uint	event;271	uint	eventContext;272	uint	data[2];273} MPT_IOCTL_EVENTS;274#endif275 276struct mpt_ioctl_eventreport {277	mpt_ioctl_header	hdr;278	MPT_IOCTL_EVENTS	eventData[1];279};280 281#define MPT_MAX_NAME	32282struct mpt_ioctl_test {283	mpt_ioctl_header hdr;284	u8		 name[MPT_MAX_NAME];285	int		 chip_type;286	u8		 product [MPT_PRODUCT_LENGTH];287};288 289/* Replace the FW image cached in host driver memory290 * newImageSize - image size in bytes291 * newImage - first byte of the new image292 */293typedef struct mpt_ioctl_replace_fw {294	mpt_ioctl_header hdr;295	int		 newImageSize;296	u8		 newImage[1];297} mpt_ioctl_replace_fw_t;298 299/* General MPT Pass through data strucutre300 *301 * iocnum302 * timeout - in seconds, command timeout. If 0, set by driver to303 *		default value.304 * replyFrameBufPtr - reply location305 * dataInBufPtr - destination for read306 * dataOutBufPtr - data source for write307 * senseDataPtr - sense data location308 * maxReplyBytes - maximum number of reply bytes to be sent to app.309 * dataInSize - num bytes for data transfer in (read)310 * dataOutSize - num bytes for data transfer out (write)311 * dataSgeOffset - offset in words from the start of the request message312 *		to the first SGL313 * MF[1];314 *315 * Remark:  Some config pages have bi-directional transfer,316 * both a read and a write. The basic structure allows for317 * a bidirectional set up. Normal messages will have one or318 * both of these buffers NULL.319 */320struct mpt_ioctl_command {321	mpt_ioctl_header hdr;322	int		timeout;	/* optional (seconds) */323	char		__user *replyFrameBufPtr;324	char		__user *dataInBufPtr;325	char		__user *dataOutBufPtr;326	char		__user *senseDataPtr;327	int		maxReplyBytes;328	int		dataInSize;329	int		dataOutSize;330	int		maxSenseBytes;331	int		dataSgeOffset;332	char		MF[1];333};334 335/*336 * SPARC PLATFORM: See earlier remark.337 */338#if defined(__KERNEL__) && defined(CONFIG_COMPAT)339struct mpt_ioctl_command32 {340	mpt_ioctl_header hdr;341	int	timeout;342	u32	replyFrameBufPtr;343	u32	dataInBufPtr;344	u32	dataOutBufPtr;345	u32	senseDataPtr;346	int	maxReplyBytes;347	int	dataInSize;348	int	dataOutSize;349	int	maxSenseBytes;350	int	dataSgeOffset;351	char	MF[1];352};353#endif	/*}*/354 355 356/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/357 358#define CPQFCTS_IOC_MAGIC 'Z'359#define HP_IOC_MAGIC 'Z'360#define HP_GETHOSTINFO		_IOR(HP_IOC_MAGIC, 20, hp_host_info_t)361#define HP_GETHOSTINFO1		_IOR(HP_IOC_MAGIC, 20, hp_host_info_rev0_t)362#define HP_GETTARGETINFO	_IOR(HP_IOC_MAGIC, 21, hp_target_info_t)363 364typedef struct _hp_header {365	unsigned int iocnum;366	unsigned int host;367	unsigned int channel;368	unsigned int id;369	unsigned int lun;370} hp_header_t;371 372/*373 *  Header:374 *  iocnum 	required (input)375 *  host 	ignored376 *  channe	ignored377 *  id		ignored378 *  lun		ignored379 */380typedef struct _hp_host_info {381	hp_header_t	 hdr;382	u16		 vendor;383	u16		 device;384	u16		 subsystem_vendor;385	u16		 subsystem_id;386	u8		 devfn;387	u8		 bus;388	ushort		 host_no;		/* SCSI Host number, if scsi driver not loaded*/389	u8		 fw_version[16];	/* string */390	u8		 serial_number[24];	/* string */391	u32		 ioc_status;392	u32		 bus_phys_width;393	u32		 base_io_addr;394	u32		 rsvd;395	unsigned int	 hard_resets;		/* driver initiated resets */396	unsigned int	 soft_resets;		/* ioc, external resets */397	unsigned int	 timeouts;		/* num timeouts */398} hp_host_info_t;399 400/* replace ulongs with uints, need to preserve backwards401 * compatibility.402 */403typedef struct _hp_host_info_rev0 {404	hp_header_t	 hdr;405	u16		 vendor;406	u16		 device;407	u16		 subsystem_vendor;408	u16		 subsystem_id;409	u8		 devfn;410	u8		 bus;411	ushort		 host_no;		/* SCSI Host number, if scsi driver not loaded*/412	u8		 fw_version[16];	/* string */413	u8		 serial_number[24];	/* string */414	u32		 ioc_status;415	u32		 bus_phys_width;416	u32		 base_io_addr;417	u32		 rsvd;418	unsigned long	 hard_resets;		/* driver initiated resets */419	unsigned long	 soft_resets;		/* ioc, external resets */420	unsigned long	 timeouts;		/* num timeouts */421} hp_host_info_rev0_t;422 423/*424 *  Header:425 *  iocnum 	required (input)426 *  host 	required427 *  channel	required	(bus number)428 *  id		required429 *  lun		ignored430 *431 *  All error values between 0 and 0xFFFF in size.432 */433typedef struct _hp_target_info {434	hp_header_t	 hdr;435	u32 parity_errors;436	u32 phase_errors;437	u32 select_timeouts;438	u32 message_rejects;439	u32 negotiated_speed;440	u8  negotiated_width;441	u8  rsvd[7];				/* 8 byte alignment */442} hp_target_info_t;443 444#define HP_STATUS_OTHER		1445#define HP_STATUS_OK		2446#define HP_STATUS_FAILED	3447 448#define HP_BUS_WIDTH_UNK	1449#define HP_BUS_WIDTH_8		2450#define HP_BUS_WIDTH_16		3451#define HP_BUS_WIDTH_32		4452 453#define HP_DEV_SPEED_ASYNC	2454#define HP_DEV_SPEED_FAST	3455#define HP_DEV_SPEED_ULTRA	4456#define HP_DEV_SPEED_ULTRA2	5457#define HP_DEV_SPEED_ULTRA160	6458#define HP_DEV_SPEED_SCSI1	7459#define HP_DEV_SPEED_ULTRA320	8460 461/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/462 463 464/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/465 466#endif467 468