xref: /freebsd/sys/dev/isp/isp_ioctl.h (revision 2df76c160ba5c04ece8efeff418362c9a1adc9f5)
15d571944SMatt Jacob /* $FreeBSD$ */
2098ca2bdSWarner Losh /*-
3e5265237SMatt Jacob  * Copyright (c) 1997-2006 by Matthew Jacob
4e5265237SMatt Jacob  * All rights reserved.
55d571944SMatt Jacob  *
65d571944SMatt Jacob  * Redistribution and use in source and binary forms, with or without
75d571944SMatt Jacob  * modification, are permitted provided that the following conditions
85d571944SMatt Jacob  * are met:
95d571944SMatt Jacob  * 1. Redistributions of source code must retain the above copyright
10e5265237SMatt Jacob  *    notice immediately at the beginning of the file, without modification,
11e5265237SMatt Jacob  *    this list of conditions, and the following disclaimer.
12e5265237SMatt Jacob  * 2. The name of the author may not be used to endorse or promote products
13e5265237SMatt Jacob  *    derived from this software without specific prior written permission.
145d571944SMatt Jacob  *
15e5265237SMatt Jacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16e5265237SMatt Jacob  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17e5265237SMatt Jacob  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18e5265237SMatt Jacob  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
19e5265237SMatt Jacob  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20e5265237SMatt Jacob  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21e5265237SMatt Jacob  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22e5265237SMatt Jacob  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23e5265237SMatt Jacob  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24e5265237SMatt Jacob  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25e5265237SMatt Jacob  * SUCH DAMAGE.
265d571944SMatt Jacob  */
27e48b2487SMatt 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.
572df76c16SMatt Jacob  *
582df76c16SMatt Jacob  * Channel selector stored in bits 8..32 as input to driver.
595d571944SMatt Jacob  */
60f553351eSMatt Jacob #define ISP_SETROLE     _IOWR(ISP_IOC, 4, int)
61f553351eSMatt Jacob 
62f553351eSMatt Jacob #define ISP_ROLE_NONE           0x0
634e8a2b48SMatt Jacob #define ISP_ROLE_TARGET         0x1
644e8a2b48SMatt Jacob #define ISP_ROLE_INITIATOR      0x2
65f553351eSMatt Jacob #define ISP_ROLE_BOTH           (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR)
665d571944SMatt Jacob 
675d571944SMatt Jacob /*
68f553351eSMatt Jacob  * Get the current adapter role
692df76c16SMatt Jacob  * Channel selector passed in first argument.
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 {
1132df76c16SMatt Jacob 	uint32_t	loopid;		/* 0..255,2047 */
1142df76c16SMatt Jacob 	uint32_t
1152df76c16SMatt Jacob 			chan 	: 6,
1164e8a2b48SMatt Jacob 			role 	: 2,
1174e8a2b48SMatt Jacob 			portid	: 24;	/* 24 bit Port ID */
1181dae40ebSMatt Jacob 	uint64_t	node_wwn;
1191dae40ebSMatt Jacob 	uint64_t	port_wwn;
120f553351eSMatt Jacob };
121f553351eSMatt Jacob #define	ISP_FC_GETDINFO	_IOWR(ISP_IOC, 9, struct isp_fc_device)
122f553351eSMatt Jacob 
123f553351eSMatt Jacob /*
124b8941882SMatt Jacob  * Get F/W crash dump
125b8941882SMatt Jacob  */
126d134aa0bSMatt Jacob #define	ISP_GET_FW_CRASH_DUMP	_IO(ISP_IOC, 10)
127b8941882SMatt Jacob #define	ISP_FORCE_CRASH_DUMP	_IO(ISP_IOC, 11)
12881ac5536SMatt Jacob 
12981ac5536SMatt Jacob /*
13081ac5536SMatt Jacob  * Get information about this Host Adapter, including current connection
13181ac5536SMatt Jacob  * topology and capabilities.
13281ac5536SMatt Jacob  */
13381ac5536SMatt Jacob struct isp_hba_device {
1341dae40ebSMatt Jacob 	uint32_t
13581ac5536SMatt Jacob 					: 8,
13681ac5536SMatt Jacob 		fc_speed		: 4,	/* Gbps */
1372df76c16SMatt Jacob 					: 1,
13881ac5536SMatt Jacob 		fc_topology		: 3,
1392df76c16SMatt Jacob 		fc_channel		: 8,
1402df76c16SMatt Jacob 		fc_loopid		: 16;
1411dae40ebSMatt Jacob 	uint8_t		fc_fw_major;
1421dae40ebSMatt Jacob 	uint8_t		fc_fw_minor;
1431dae40ebSMatt Jacob 	uint8_t		fc_fw_micro;
1442df76c16SMatt Jacob 	uint8_t		fc_nchannels;	/* number of supported channels */
1452df76c16SMatt Jacob 	uint16_t	fc_nports;	/* number of supported ports */
1461dae40ebSMatt Jacob 	uint64_t	nvram_node_wwn;
1471dae40ebSMatt Jacob 	uint64_t	nvram_port_wwn;
1481dae40ebSMatt Jacob 	uint64_t	active_node_wwn;
1491dae40ebSMatt Jacob 	uint64_t	active_port_wwn;
15081ac5536SMatt Jacob };
15181ac5536SMatt Jacob 
15281ac5536SMatt Jacob #define	ISP_TOPO_UNKNOWN	0	/* connection topology unknown */
15381ac5536SMatt Jacob #define	ISP_TOPO_FCAL		1	/* private or PL_DA */
15481ac5536SMatt Jacob #define	ISP_TOPO_LPORT		2	/* public loop */
15581ac5536SMatt Jacob #define	ISP_TOPO_NPORT		3	/* N-port */
15681ac5536SMatt Jacob #define	ISP_TOPO_FPORT		4	/* F-port */
15781ac5536SMatt Jacob 
1582df76c16SMatt Jacob /* don't use 12 any more */
1592df76c16SMatt Jacob #define	ISP_FC_GETHINFO	_IOWR(ISP_IOC, 13, struct isp_hba_device)
1608e62a8acSMatt Jacob 
1618e62a8acSMatt Jacob /*
1628e62a8acSMatt Jacob  * Various Reset Goodies
1638e62a8acSMatt Jacob  */
1648e62a8acSMatt Jacob struct isp_fc_tsk_mgmt {
1652df76c16SMatt Jacob 	uint32_t	loopid;		/* 0..255/2048 */
1662df76c16SMatt Jacob 	uint16_t	lun;
1672df76c16SMatt Jacob 	uint16_t	chan;
1688e62a8acSMatt Jacob 	enum {
169f0f536d1SMatt Jacob 		IPT_CLEAR_ACA,
170f0f536d1SMatt Jacob 		IPT_TARGET_RESET,
171f0f536d1SMatt Jacob 		IPT_LUN_RESET,
172f0f536d1SMatt Jacob 		IPT_CLEAR_TASK_SET,
173f0f536d1SMatt Jacob 		IPT_ABORT_TASK_SET
1748e62a8acSMatt Jacob 	} action;
1758e62a8acSMatt Jacob };
1762df76c16SMatt Jacob /* don't use 97 any more */
1772df76c16SMatt Jacob #define	ISP_TSK_MGMT		_IOWR(ISP_IOC, 98, struct isp_fc_tsk_mgmt)
1782df76c16SMatt Jacob 
1792df76c16SMatt Jacob /*
1802df76c16SMatt Jacob  * Just gimme a list of WWPNs that are logged into us.
1812df76c16SMatt Jacob  */
1822df76c16SMatt Jacob typedef struct {
1832df76c16SMatt Jacob 	uint16_t count;
1842df76c16SMatt Jacob 	uint16_t channel;
1852df76c16SMatt Jacob 	struct wwnpair {
1862df76c16SMatt Jacob 		uint64_t wwnn;
1872df76c16SMatt Jacob 		uint64_t wwpn;
1882df76c16SMatt Jacob 	} wwns[1];
1892df76c16SMatt Jacob } isp_dlist_t;
1902df76c16SMatt Jacob #define	ISP_FC_GETDLIST _IO(ISP_IOC, 14)
191