xref: /freebsd/sys/dev/isp/isp_ioctl.h (revision 8e62a8ac99b80a912b05e2482839532b9be38fbd)
15d571944SMatt Jacob /* $FreeBSD$ */
2098ca2bdSWarner Losh /*-
35d571944SMatt Jacob  * Copyright (c) 2001 by Matthew Jacob
45d571944SMatt Jacob  *
55d571944SMatt Jacob  * Redistribution and use in source and binary forms, with or without
65d571944SMatt Jacob  * modification, are permitted provided that the following conditions
75d571944SMatt Jacob  * are met:
85d571944SMatt Jacob  *
95d571944SMatt Jacob  * 1. Redistributions of source code must retain the above copyright
105d571944SMatt Jacob  *    notice, this list of conditions and the following disclaimer.
115d571944SMatt Jacob  * 2. Redistributions in binary form must reproduce the above copyright
125d571944SMatt Jacob  *    notice, this list of conditions and the following disclaimer in the
135d571944SMatt Jacob  *    documentation and/or other materials provided with the distribution.
145d571944SMatt Jacob  *
155d571944SMatt Jacob  * Alternatively, this software may be distributed under the terms of the
165d571944SMatt Jacob  * the GNU Public License ("GPL", Library, Version 2).
175d571944SMatt Jacob  *
185d571944SMatt Jacob  *
195d571944SMatt Jacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
205d571944SMatt Jacob  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
215d571944SMatt Jacob  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
225d571944SMatt Jacob  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
235d571944SMatt Jacob  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
245d571944SMatt Jacob  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
255d571944SMatt Jacob  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
265d571944SMatt Jacob  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
275d571944SMatt Jacob  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
285d571944SMatt Jacob  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
295d571944SMatt Jacob  *
305d571944SMatt Jacob  * Matthew Jacob <mjacob@feral.com)
315d571944SMatt Jacob  *
325d571944SMatt Jacob  */
335d571944SMatt Jacob /*
345d571944SMatt Jacob  * ioctl definitions for Qlogic FC/SCSI HBA driver
355d571944SMatt Jacob  */
365d571944SMatt Jacob #define	ISP_IOC		(021)	/* 'Ctrl-Q' */
375d571944SMatt Jacob 
385d571944SMatt Jacob /*
395d571944SMatt Jacob  * This ioctl sets/retrieves the debugging level for this hba instance.
405d571944SMatt Jacob  * Note that this is not a simple integer level- see ispvar.h for definitions.
415d571944SMatt Jacob  *
425d571944SMatt Jacob  * The arguments is a pointer to an integer with the new debugging level.
435d571944SMatt Jacob  * The old value is written into this argument.
445d571944SMatt Jacob  */
455d571944SMatt Jacob 
46f553351eSMatt Jacob #define	ISP_SDBLEV	_IOWR(ISP_IOC, 1, int)
475d571944SMatt Jacob 
485d571944SMatt Jacob /*
495d571944SMatt Jacob  * This ioctl resets the HBA. Use with caution.
505d571944SMatt Jacob  */
51f553351eSMatt Jacob #define	ISP_RESETHBA	_IO(ISP_IOC, 2)
525d571944SMatt Jacob 
535d571944SMatt Jacob /*
545d571944SMatt Jacob  * This ioctl performs a fibre chanel rescan.
555d571944SMatt Jacob  */
56f553351eSMatt Jacob #define	ISP_RESCAN	_IO(ISP_IOC, 3)
575d571944SMatt Jacob 
585d571944SMatt Jacob /*
59f553351eSMatt Jacob  * This ioctl performs a reset and then will set the adapter to the
60f553351eSMatt Jacob  * role that was passed in (the old role will be returned). It almost
61f553351eSMatt Jacob  * goes w/o saying: use with caution.
625d571944SMatt Jacob  */
63f553351eSMatt Jacob #define ISP_SETROLE     _IOWR(ISP_IOC, 4, int)
64f553351eSMatt Jacob 
65f553351eSMatt Jacob #define ISP_ROLE_NONE           0x0
664e8a2b48SMatt Jacob #define ISP_ROLE_TARGET         0x1
674e8a2b48SMatt Jacob #define ISP_ROLE_INITIATOR      0x2
68f553351eSMatt Jacob #define ISP_ROLE_BOTH           (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR)
69f553351eSMatt Jacob #ifndef ISP_DEFAULT_ROLES
70f553351eSMatt Jacob #define ISP_DEFAULT_ROLES       ISP_ROLE_BOTH
71f553351eSMatt Jacob #endif
725d571944SMatt Jacob 
735d571944SMatt Jacob /*
74f553351eSMatt Jacob  * Get the current adapter role
755d571944SMatt Jacob  */
761484f178SMatt Jacob #define ISP_GETROLE     _IOR(ISP_IOC, 5, int)
772903b272SMatt Jacob 
782903b272SMatt Jacob /*
792903b272SMatt Jacob  * Get/Clear Stats
802903b272SMatt Jacob  */
812903b272SMatt Jacob #define	ISP_STATS_VERSION	0
822903b272SMatt Jacob typedef struct {
8375c1e828SMatt Jacob 	u_int8_t	isp_stat_version;
8475c1e828SMatt Jacob 	u_int8_t	isp_type;		/* (ro) reflects chip type */
8575c1e828SMatt Jacob 	u_int8_t	isp_revision;		/* (ro) reflects chip version */
8675c1e828SMatt Jacob 	u_int8_t	unused1;
8775c1e828SMatt Jacob 	u_int32_t	unused2;
882903b272SMatt Jacob 	/*
892903b272SMatt Jacob 	 * Statistics Counters
902903b272SMatt Jacob 	 */
912903b272SMatt Jacob #define	ISP_NSTATS	16
922903b272SMatt Jacob #define	ISP_INTCNT	0
932903b272SMatt Jacob #define	ISP_INTBOGUS	1
942903b272SMatt Jacob #define	ISP_INTMBOXC	2
952903b272SMatt Jacob #define	ISP_INGOASYNC	3
962903b272SMatt Jacob #define	ISP_RSLTCCMPLT	4
972903b272SMatt Jacob #define	ISP_FPHCCMCPLT	5
982903b272SMatt Jacob #define	ISP_RSCCHIWAT	6
992903b272SMatt Jacob #define	ISP_FPCCHIWAT	7
10075c1e828SMatt Jacob 	u_int64_t	isp_stats[ISP_NSTATS];
1012903b272SMatt Jacob } isp_stats_t;
1022903b272SMatt Jacob 
1032903b272SMatt Jacob #define	ISP_GET_STATS	_IOR(ISP_IOC, 6, isp_stats_t)
1042903b272SMatt Jacob #define	ISP_CLR_STATS	_IO(ISP_IOC, 7)
105b8941882SMatt Jacob 
106b8941882SMatt Jacob /*
107f553351eSMatt Jacob  * Initiate a LIP
108f553351eSMatt Jacob  */
109f553351eSMatt Jacob #define	ISP_FC_LIP	_IO(ISP_IOC, 8)
110f553351eSMatt Jacob 
111f553351eSMatt Jacob /*
112f553351eSMatt Jacob  * Return the Port Database structure for the named device, or ENODEV if none.
113f553351eSMatt Jacob  * Caller fills in virtual loopid (0..255), aka 'target'. The driver returns
114f553351eSMatt Jacob  * ENODEV (if nothing valid there) or the actual loopid (for local loop devices
115f553351eSMatt Jacob  * only), 24 bit Port ID and Node and Port WWNs.
116f553351eSMatt Jacob  */
117f553351eSMatt Jacob struct isp_fc_device {
118f553351eSMatt Jacob 	u_int32_t	loopid;		/* 0..255 */
1194e8a2b48SMatt Jacob 	u_int32_t		: 6,
1204e8a2b48SMatt Jacob 			role 	: 2,
1214e8a2b48SMatt Jacob 			portid	: 24;	/* 24 bit Port ID */
122f553351eSMatt Jacob 	u_int64_t	node_wwn;
123f553351eSMatt Jacob 	u_int64_t	port_wwn;
124f553351eSMatt Jacob };
125f553351eSMatt Jacob #define	ISP_FC_GETDINFO	_IOWR(ISP_IOC, 9, struct isp_fc_device)
126f553351eSMatt Jacob 
127f553351eSMatt Jacob /*
128b8941882SMatt Jacob  * Get F/W crash dump
129b8941882SMatt Jacob  */
130d134aa0bSMatt Jacob #define	ISP_GET_FW_CRASH_DUMP	_IO(ISP_IOC, 10)
131b8941882SMatt Jacob #define	ISP_FORCE_CRASH_DUMP	_IO(ISP_IOC, 11)
13281ac5536SMatt Jacob 
13381ac5536SMatt Jacob /*
13481ac5536SMatt Jacob  * Get information about this Host Adapter, including current connection
13581ac5536SMatt Jacob  * topology and capabilities.
13681ac5536SMatt Jacob  */
13781ac5536SMatt Jacob struct isp_hba_device {
13881ac5536SMatt Jacob 	u_int32_t
13981ac5536SMatt Jacob 					: 8,
14081ac5536SMatt Jacob 					: 4,
14181ac5536SMatt Jacob 		fc_speed		: 4,	/* Gbps */
14281ac5536SMatt Jacob 					: 2,
14381ac5536SMatt Jacob 		fc_class2		: 1,
14481ac5536SMatt Jacob 		fc_ip_supported		: 1,
14581ac5536SMatt Jacob 		fc_scsi_supported	: 1,
14681ac5536SMatt Jacob 		fc_topology		: 3,
14781ac5536SMatt Jacob 		fc_loopid		: 8;
148a556b68eSMatt Jacob 	u_int8_t	fc_fw_major;
149a556b68eSMatt Jacob 	u_int8_t	fc_fw_minor;
150a556b68eSMatt Jacob 	u_int8_t	fc_fw_micro;
151a556b68eSMatt Jacob 	u_int8_t	reserved;
15281ac5536SMatt Jacob 	u_int64_t	nvram_node_wwn;
15381ac5536SMatt Jacob 	u_int64_t	nvram_port_wwn;
15481ac5536SMatt Jacob 	u_int64_t	active_node_wwn;
15581ac5536SMatt Jacob 	u_int64_t	active_port_wwn;
15681ac5536SMatt Jacob };
15781ac5536SMatt Jacob 
15881ac5536SMatt Jacob #define	ISP_TOPO_UNKNOWN	0	/* connection topology unknown */
15981ac5536SMatt Jacob #define	ISP_TOPO_FCAL		1	/* private or PL_DA */
16081ac5536SMatt Jacob #define	ISP_TOPO_LPORT		2	/* public loop */
16181ac5536SMatt Jacob #define	ISP_TOPO_NPORT		3	/* N-port */
16281ac5536SMatt Jacob #define	ISP_TOPO_FPORT		4	/* F-port */
16381ac5536SMatt Jacob 
16481ac5536SMatt Jacob #define	ISP_FC_GETHINFO	_IOR(ISP_IOC, 12, struct isp_hba_device)
165f00939f9SMatt Jacob /*
166f00939f9SMatt Jacob  * Set some internal parameters. This doesn't take effect until
167f00939f9SMatt Jacob  * the chip is reset.
168f00939f9SMatt Jacob  *
169f00939f9SMatt Jacob  * Each parameter is generalized to be a name string with an integer value.
170f00939f9SMatt Jacob  *
171f00939f9SMatt Jacob  * Known parameters are:
172f00939f9SMatt Jacob  *
173f00939f9SMatt Jacob  *	Name				Value Range
174f00939f9SMatt Jacob  *
175f00939f9SMatt Jacob  *	"framelength"			512,1024,2048
176f00939f9SMatt Jacob  *	"exec_throttle"			16..255
177f00939f9SMatt Jacob  *	"fullduplex"			0,1
178f00939f9SMatt Jacob  *	"loopid"			0..125
179f00939f9SMatt Jacob  */
180f00939f9SMatt Jacob 
181f00939f9SMatt Jacob struct isp_fc_param {
182f00939f9SMatt Jacob 	char		param_name[16];	/* null terminated */
183f00939f9SMatt Jacob 	u_int32_t	parameter;
184f00939f9SMatt Jacob };
185f00939f9SMatt Jacob 
186f00939f9SMatt Jacob #define	ISP_GET_FC_PARAM	_IOWR(ISP_IOC, 98, struct isp_fc_param)
187f00939f9SMatt Jacob #define	ISP_SET_FC_PARAM	_IOWR(ISP_IOC, 99, struct isp_fc_param)
1888e62a8acSMatt Jacob 
1898e62a8acSMatt Jacob /*
1908e62a8acSMatt Jacob  * Various Reset Goodies
1918e62a8acSMatt Jacob  */
1928e62a8acSMatt Jacob struct isp_fc_tsk_mgmt {
1938e62a8acSMatt Jacob 	u_int32_t	loopid;		/* 0..255 */
1948e62a8acSMatt Jacob 	u_int32_t	lun;
1958e62a8acSMatt Jacob 	enum {
1968e62a8acSMatt Jacob 	    CLEAR_ACA, TARGET_RESET, LUN_RESET, CLEAR_TASK_SET, ABORT_TASK_SET
1978e62a8acSMatt Jacob 	} action;
1988e62a8acSMatt Jacob };
1998e62a8acSMatt Jacob #define	ISP_TSK_MGMT		_IOWR(ISP_IOC, 97, struct isp_fc_tsk_mgmt)
200