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