xref: /freebsd/sys/dev/isp/isp_ioctl.h (revision f4b37ed0f8b307b1f3f0f630ca725d68f1dff30d)
1 /* $FreeBSD$ */
2 /*-
3  * Copyright (c) 1997-2006 by Matthew Jacob
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice immediately at the beginning of the file, without modification,
11  *    this list of conditions, and the following disclaimer.
12  * 2. The name of the author may not be used to endorse or promote products
13  *    derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
19  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 /*
29  * ioctl definitions for Qlogic FC/SCSI HBA driver
30  */
31 #define	ISP_IOC		(021)	/* 'Ctrl-Q' */
32 
33 /*
34  * This ioctl sets/retrieves the debugging level for this hba instance.
35  * Note that this is not a simple integer level- see ispvar.h for definitions.
36  *
37  * The arguments is a pointer to an integer with the new debugging level.
38  * The old value is written into this argument.
39  */
40 
41 #define	ISP_SDBLEV	_IOWR(ISP_IOC, 1, int)
42 
43 /*
44  * This ioctl resets the HBA. Use with caution.
45  */
46 #define	ISP_RESETHBA	_IO(ISP_IOC, 2)
47 
48 /*
49  * This ioctl performs a fibre channel rescan.
50  */
51 #define	ISP_RESCAN	_IO(ISP_IOC, 3)
52 
53 /*
54  * This ioctl performs a reset and then will set the adapter to the
55  * role that was passed in (the old role will be returned). It almost
56  * goes w/o saying: use with caution.
57  *
58  * Channel selector stored in bits 8..32 as input to driver.
59  */
60 #define ISP_SETROLE     _IOWR(ISP_IOC, 4, int)
61 
62 #define ISP_ROLE_NONE           0x0
63 #define ISP_ROLE_TARGET         0x1
64 #define ISP_ROLE_INITIATOR      0x2
65 #define ISP_ROLE_BOTH           (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR)
66 
67 /*
68  * Get the current adapter role
69  * Channel selector passed in first argument.
70  */
71 #define ISP_GETROLE     _IOR(ISP_IOC, 5, int)
72 
73 /*
74  * Get/Clear Stats
75  */
76 #define	ISP_STATS_VERSION	0
77 typedef struct {
78 	uint8_t		isp_stat_version;
79 	uint8_t		isp_type;		/* (ro) reflects chip type */
80 	uint8_t		isp_revision;		/* (ro) reflects chip version */
81 	uint8_t		unused1;
82 	uint32_t	unused2;
83 	/*
84 	 * Statistics Counters
85 	 */
86 #define	ISP_NSTATS	16
87 #define	ISP_INTCNT	0
88 #define	ISP_INTBOGUS	1
89 #define	ISP_INTMBOXC	2
90 #define	ISP_INGOASYNC	3
91 #define	ISP_RSLTCCMPLT	4
92 #define	ISP_FPHCCMCPLT	5
93 #define	ISP_RSCCHIWAT	6
94 #define	ISP_FPCCHIWAT	7
95 	uint64_t	isp_stats[ISP_NSTATS];
96 } isp_stats_t;
97 
98 #define	ISP_GET_STATS	_IOR(ISP_IOC, 6, isp_stats_t)
99 #define	ISP_CLR_STATS	_IO(ISP_IOC, 7)
100 
101 /*
102  * Initiate a LIP
103  */
104 #define	ISP_FC_LIP	_IO(ISP_IOC, 8)
105 
106 /*
107  * Return the Port Database structure for the named device, or ENODEV if none.
108  * Caller fills in virtual loopid (0..255), aka 'target'. The driver returns
109  * ENODEV (if nothing valid there) or the actual loopid (for local loop devices
110  * only), 24 bit Port ID and Node and Port WWNs.
111  */
112 struct isp_fc_device {
113 	uint32_t	loopid;		/* 0..255,2047 */
114 	uint32_t
115 			chan 	: 6,
116 			role 	: 2,
117 			portid	: 24;	/* 24 bit Port ID */
118 	uint64_t	node_wwn;
119 	uint64_t	port_wwn;
120 };
121 #define	ISP_FC_GETDINFO	_IOWR(ISP_IOC, 9, struct isp_fc_device)
122 
123 /*
124  * Get F/W crash dump
125  */
126 #define	ISP_GET_FW_CRASH_DUMP	_IO(ISP_IOC, 10)
127 #define	ISP_FORCE_CRASH_DUMP	_IO(ISP_IOC, 11)
128 
129 /*
130  * Get information about this Host Adapter, including current connection
131  * topology and capabilities.
132  */
133 struct isp_hba_device {
134 	uint32_t
135 					: 8,
136 		fc_speed		: 4,	/* Gbps */
137 					: 1,
138 		fc_topology		: 3,
139 		fc_channel		: 8,
140 		fc_loopid		: 16;
141 	uint8_t		fc_fw_major;
142 	uint8_t		fc_fw_minor;
143 	uint8_t		fc_fw_micro;
144 	uint8_t		fc_nchannels;	/* number of supported channels */
145 	uint16_t	fc_nports;	/* number of supported ports */
146 	uint64_t	nvram_node_wwn;
147 	uint64_t	nvram_port_wwn;
148 	uint64_t	active_node_wwn;
149 	uint64_t	active_port_wwn;
150 };
151 
152 #define	ISP_TOPO_UNKNOWN	0	/* connection topology unknown */
153 #define	ISP_TOPO_FCAL		1	/* private or PL_DA */
154 #define	ISP_TOPO_LPORT		2	/* public loop */
155 #define	ISP_TOPO_NPORT		3	/* N-port */
156 #define	ISP_TOPO_FPORT		4	/* F-port */
157 
158 /* don't use 12 any more */
159 #define	ISP_FC_GETHINFO	_IOWR(ISP_IOC, 13, struct isp_hba_device)
160 
161 /*
162  * Various Reset Goodies
163  */
164 struct isp_fc_tsk_mgmt {
165 	uint32_t	loopid;		/* 0..255/2048 */
166 	uint16_t	lun;
167 	uint16_t	chan;
168 	enum {
169 		IPT_CLEAR_ACA,
170 		IPT_TARGET_RESET,
171 		IPT_LUN_RESET,
172 		IPT_CLEAR_TASK_SET,
173 		IPT_ABORT_TASK_SET
174 	} action;
175 };
176 /* don't use 97 any more */
177 #define	ISP_TSK_MGMT		_IOWR(ISP_IOC, 98, struct isp_fc_tsk_mgmt)
178 
179 /*
180  * Just gimme a list of WWPNs that are logged into us.
181  */
182 typedef struct {
183 	uint16_t count;
184 	uint16_t channel;
185 	struct wwnpair {
186 		uint64_t wwnn;
187 		uint64_t wwpn;
188 	} wwns[1];
189 } isp_dlist_t;
190 #define	ISP_FC_GETDLIST _IO(ISP_IOC, 14)
191