xref: /freebsd/sys/dev/isp/isp_ioctl.h (revision f0f536d1aec2e5e9e81de1bf696c6d306e5c92fe)
15d571944SMatt Jacob /* $FreeBSD$ */
2098ca2bdSWarner Losh /*-
3e5265237SMatt Jacob  *
4e5265237SMatt Jacob  * Copyright (c) 1997-2006 by Matthew Jacob
5e5265237SMatt Jacob  * All rights reserved.
65d571944SMatt Jacob  *
75d571944SMatt Jacob  * Redistribution and use in source and binary forms, with or without
85d571944SMatt Jacob  * modification, are permitted provided that the following conditions
95d571944SMatt Jacob  * are met:
105d571944SMatt Jacob  * 1. Redistributions of source code must retain the above copyright
11e5265237SMatt Jacob  *    notice immediately at the beginning of the file, without modification,
12e5265237SMatt Jacob  *    this list of conditions, and the following disclaimer.
13e5265237SMatt Jacob  * 2. The name of the author may not be used to endorse or promote products
14e5265237SMatt Jacob  *    derived from this software without specific prior written permission.
155d571944SMatt Jacob  *
16e5265237SMatt Jacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17e5265237SMatt Jacob  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18e5265237SMatt Jacob  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19e5265237SMatt Jacob  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20e5265237SMatt Jacob  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21e5265237SMatt Jacob  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22e5265237SMatt Jacob  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23e5265237SMatt Jacob  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24e5265237SMatt Jacob  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25e5265237SMatt Jacob  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26e5265237SMatt Jacob  * SUCH DAMAGE.
275d571944SMatt Jacob  */
285d571944SMatt Jacob /*
295d571944SMatt Jacob  * ioctl definitions for Qlogic FC/SCSI HBA driver
305d571944SMatt Jacob  */
315d571944SMatt Jacob #define	ISP_IOC		(021)	/* 'Ctrl-Q' */
325d571944SMatt Jacob 
335d571944SMatt Jacob /*
345d571944SMatt Jacob  * This ioctl sets/retrieves the debugging level for this hba instance.
355d571944SMatt Jacob  * Note that this is not a simple integer level- see ispvar.h for definitions.
365d571944SMatt Jacob  *
375d571944SMatt Jacob  * The arguments is a pointer to an integer with the new debugging level.
385d571944SMatt Jacob  * The old value is written into this argument.
395d571944SMatt Jacob  */
405d571944SMatt Jacob 
41f553351eSMatt Jacob #define	ISP_SDBLEV	_IOWR(ISP_IOC, 1, int)
425d571944SMatt Jacob 
435d571944SMatt Jacob /*
445d571944SMatt Jacob  * This ioctl resets the HBA. Use with caution.
455d571944SMatt Jacob  */
46f553351eSMatt Jacob #define	ISP_RESETHBA	_IO(ISP_IOC, 2)
475d571944SMatt Jacob 
485d571944SMatt Jacob /*
499cd7268eSMatt Jacob  * This ioctl performs a fibre channel rescan.
505d571944SMatt Jacob  */
51f553351eSMatt Jacob #define	ISP_RESCAN	_IO(ISP_IOC, 3)
525d571944SMatt Jacob 
535d571944SMatt Jacob /*
54f553351eSMatt Jacob  * This ioctl performs a reset and then will set the adapter to the
55f553351eSMatt Jacob  * role that was passed in (the old role will be returned). It almost
56f553351eSMatt Jacob  * goes w/o saying: use with caution.
575d571944SMatt Jacob  */
58f553351eSMatt Jacob #define ISP_SETROLE     _IOWR(ISP_IOC, 4, int)
59f553351eSMatt Jacob 
60f553351eSMatt Jacob #define ISP_ROLE_NONE           0x0
614e8a2b48SMatt Jacob #define ISP_ROLE_TARGET         0x1
624e8a2b48SMatt Jacob #define ISP_ROLE_INITIATOR      0x2
63f553351eSMatt Jacob #define ISP_ROLE_BOTH           (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR)
64f553351eSMatt Jacob #ifndef ISP_DEFAULT_ROLES
65f553351eSMatt Jacob #define ISP_DEFAULT_ROLES       ISP_ROLE_BOTH
66f553351eSMatt Jacob #endif
675d571944SMatt Jacob 
685d571944SMatt Jacob /*
69f553351eSMatt Jacob  * Get the current adapter role
705d571944SMatt Jacob  */
711484f178SMatt Jacob #define ISP_GETROLE     _IOR(ISP_IOC, 5, int)
722903b272SMatt Jacob 
732903b272SMatt Jacob /*
742903b272SMatt Jacob  * Get/Clear Stats
752903b272SMatt Jacob  */
762903b272SMatt Jacob #define	ISP_STATS_VERSION	0
772903b272SMatt Jacob typedef struct {
781dae40ebSMatt Jacob 	uint8_t		isp_stat_version;
791dae40ebSMatt Jacob 	uint8_t		isp_type;		/* (ro) reflects chip type */
801dae40ebSMatt Jacob 	uint8_t		isp_revision;		/* (ro) reflects chip version */
811dae40ebSMatt Jacob 	uint8_t		unused1;
821dae40ebSMatt Jacob 	uint32_t	unused2;
832903b272SMatt Jacob 	/*
842903b272SMatt Jacob 	 * Statistics Counters
852903b272SMatt Jacob 	 */
862903b272SMatt Jacob #define	ISP_NSTATS	16
872903b272SMatt Jacob #define	ISP_INTCNT	0
882903b272SMatt Jacob #define	ISP_INTBOGUS	1
892903b272SMatt Jacob #define	ISP_INTMBOXC	2
902903b272SMatt Jacob #define	ISP_INGOASYNC	3
912903b272SMatt Jacob #define	ISP_RSLTCCMPLT	4
922903b272SMatt Jacob #define	ISP_FPHCCMCPLT	5
932903b272SMatt Jacob #define	ISP_RSCCHIWAT	6
942903b272SMatt Jacob #define	ISP_FPCCHIWAT	7
951dae40ebSMatt Jacob 	uint64_t	isp_stats[ISP_NSTATS];
962903b272SMatt Jacob } isp_stats_t;
972903b272SMatt Jacob 
982903b272SMatt Jacob #define	ISP_GET_STATS	_IOR(ISP_IOC, 6, isp_stats_t)
992903b272SMatt Jacob #define	ISP_CLR_STATS	_IO(ISP_IOC, 7)
100b8941882SMatt Jacob 
101b8941882SMatt Jacob /*
102f553351eSMatt Jacob  * Initiate a LIP
103f553351eSMatt Jacob  */
104f553351eSMatt Jacob #define	ISP_FC_LIP	_IO(ISP_IOC, 8)
105f553351eSMatt Jacob 
106f553351eSMatt Jacob /*
107f553351eSMatt Jacob  * Return the Port Database structure for the named device, or ENODEV if none.
108f553351eSMatt Jacob  * Caller fills in virtual loopid (0..255), aka 'target'. The driver returns
109f553351eSMatt Jacob  * ENODEV (if nothing valid there) or the actual loopid (for local loop devices
110f553351eSMatt Jacob  * only), 24 bit Port ID and Node and Port WWNs.
111f553351eSMatt Jacob  */
112f553351eSMatt Jacob struct isp_fc_device {
1131dae40ebSMatt Jacob 	uint32_t	loopid;		/* 0..255 */
1141dae40ebSMatt Jacob 	uint32_t		: 6,
1154e8a2b48SMatt Jacob 			role 	: 2,
1164e8a2b48SMatt Jacob 			portid	: 24;	/* 24 bit Port ID */
1171dae40ebSMatt Jacob 	uint64_t	node_wwn;
1181dae40ebSMatt Jacob 	uint64_t	port_wwn;
119f553351eSMatt Jacob };
120f553351eSMatt Jacob #define	ISP_FC_GETDINFO	_IOWR(ISP_IOC, 9, struct isp_fc_device)
121f553351eSMatt Jacob 
122f553351eSMatt Jacob /*
123b8941882SMatt Jacob  * Get F/W crash dump
124b8941882SMatt Jacob  */
125d134aa0bSMatt Jacob #define	ISP_GET_FW_CRASH_DUMP	_IO(ISP_IOC, 10)
126b8941882SMatt Jacob #define	ISP_FORCE_CRASH_DUMP	_IO(ISP_IOC, 11)
12781ac5536SMatt Jacob 
12881ac5536SMatt Jacob /*
12981ac5536SMatt Jacob  * Get information about this Host Adapter, including current connection
13081ac5536SMatt Jacob  * topology and capabilities.
13181ac5536SMatt Jacob  */
13281ac5536SMatt Jacob struct isp_hba_device {
1331dae40ebSMatt Jacob 	uint32_t
13481ac5536SMatt Jacob 					: 8,
13581ac5536SMatt Jacob 					: 4,
13681ac5536SMatt Jacob 		fc_speed		: 4,	/* Gbps */
13781ac5536SMatt Jacob 					: 2,
13881ac5536SMatt Jacob 		fc_class2		: 1,
13981ac5536SMatt Jacob 		fc_ip_supported		: 1,
14081ac5536SMatt Jacob 		fc_scsi_supported	: 1,
14181ac5536SMatt Jacob 		fc_topology		: 3,
14281ac5536SMatt Jacob 		fc_loopid		: 8;
1431dae40ebSMatt Jacob 	uint8_t		fc_fw_major;
1441dae40ebSMatt Jacob 	uint8_t		fc_fw_minor;
1451dae40ebSMatt Jacob 	uint8_t		fc_fw_micro;
1461dae40ebSMatt Jacob 	uint8_t		reserved;
1471dae40ebSMatt Jacob 	uint64_t	nvram_node_wwn;
1481dae40ebSMatt Jacob 	uint64_t	nvram_port_wwn;
1491dae40ebSMatt Jacob 	uint64_t	active_node_wwn;
1501dae40ebSMatt Jacob 	uint64_t	active_port_wwn;
15181ac5536SMatt Jacob };
15281ac5536SMatt Jacob 
15381ac5536SMatt Jacob #define	ISP_TOPO_UNKNOWN	0	/* connection topology unknown */
15481ac5536SMatt Jacob #define	ISP_TOPO_FCAL		1	/* private or PL_DA */
15581ac5536SMatt Jacob #define	ISP_TOPO_LPORT		2	/* public loop */
15681ac5536SMatt Jacob #define	ISP_TOPO_NPORT		3	/* N-port */
15781ac5536SMatt Jacob #define	ISP_TOPO_FPORT		4	/* F-port */
15881ac5536SMatt Jacob 
15981ac5536SMatt Jacob #define	ISP_FC_GETHINFO	_IOR(ISP_IOC, 12, struct isp_hba_device)
160f00939f9SMatt Jacob /*
161f00939f9SMatt Jacob  * Set some internal parameters. This doesn't take effect until
162f00939f9SMatt Jacob  * the chip is reset.
163f00939f9SMatt Jacob  *
164f00939f9SMatt Jacob  * Each parameter is generalized to be a name string with an integer value.
165f00939f9SMatt Jacob  *
166f00939f9SMatt Jacob  * Known parameters are:
167f00939f9SMatt Jacob  *
168f00939f9SMatt Jacob  *	Name				Value Range
169f00939f9SMatt Jacob  *
170f00939f9SMatt Jacob  *	"framelength"			512,1024,2048
171f00939f9SMatt Jacob  *	"exec_throttle"			16..255
172f00939f9SMatt Jacob  *	"fullduplex"			0,1
173f00939f9SMatt Jacob  *	"loopid"			0..125
174f00939f9SMatt Jacob  */
175f00939f9SMatt Jacob 
176f00939f9SMatt Jacob struct isp_fc_param {
177f00939f9SMatt Jacob 	char		param_name[16];	/* null terminated */
1781dae40ebSMatt Jacob 	uint32_t	parameter;
179f00939f9SMatt Jacob };
180f00939f9SMatt Jacob 
181f00939f9SMatt Jacob #define	ISP_GET_FC_PARAM	_IOWR(ISP_IOC, 98, struct isp_fc_param)
182f00939f9SMatt Jacob #define	ISP_SET_FC_PARAM	_IOWR(ISP_IOC, 99, struct isp_fc_param)
1838e62a8acSMatt Jacob 
1848e62a8acSMatt Jacob /*
1858e62a8acSMatt Jacob  * Various Reset Goodies
1868e62a8acSMatt Jacob  */
1878e62a8acSMatt Jacob struct isp_fc_tsk_mgmt {
1881dae40ebSMatt Jacob 	uint32_t	loopid;		/* 0..255 */
1891dae40ebSMatt Jacob 	uint32_t	lun;
1908e62a8acSMatt Jacob 	enum {
191f0f536d1SMatt Jacob 		IPT_CLEAR_ACA,
192f0f536d1SMatt Jacob 		IPT_TARGET_RESET,
193f0f536d1SMatt Jacob 		IPT_LUN_RESET,
194f0f536d1SMatt Jacob 		IPT_CLEAR_TASK_SET,
195f0f536d1SMatt Jacob 		IPT_ABORT_TASK_SET
1968e62a8acSMatt Jacob 	} action;
1978e62a8acSMatt Jacob };
1988e62a8acSMatt Jacob #define	ISP_TSK_MGMT		_IOWR(ISP_IOC, 97, struct isp_fc_tsk_mgmt)
199