177365Smjacob/* $FreeBSD$ */
2139749Simp/*-
3154704Smjacob * Copyright (c) 1997-2006 by Matthew Jacob
4154704Smjacob * All rights reserved.
5154704Smjacob *
677365Smjacob * Redistribution and use in source and binary forms, with or without
777365Smjacob * modification, are permitted provided that the following conditions
877365Smjacob * are met:
977365Smjacob * 1. Redistributions of source code must retain the above copyright
10154704Smjacob *    notice immediately at the beginning of the file, without modification,
11154704Smjacob *    this list of conditions, and the following disclaimer.
12154704Smjacob * 2. The name of the author may not be used to endorse or promote products
13154704Smjacob *    derived from this software without specific prior written permission.
1477365Smjacob *
15154704Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16154704Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17154704Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18154704Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
19154704Smjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20154704Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21154704Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22154704Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23154704Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24154704Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25154704Smjacob * SUCH DAMAGE.
2677365Smjacob */
27167403Smjacob
2877365Smjacob/*
2977365Smjacob * ioctl definitions for Qlogic FC/SCSI HBA driver
3077365Smjacob */
3177365Smjacob#define	ISP_IOC		(021)	/* 'Ctrl-Q' */
3277365Smjacob
3377365Smjacob/*
3477365Smjacob * This ioctl sets/retrieves the debugging level for this hba instance.
3577365Smjacob * Note that this is not a simple integer level- see ispvar.h for definitions.
3677365Smjacob *
3777365Smjacob * The arguments is a pointer to an integer with the new debugging level.
3877365Smjacob * The old value is written into this argument.
3977365Smjacob */
4077365Smjacob
4191036Smjacob#define	ISP_SDBLEV	_IOWR(ISP_IOC, 1, int)
4277365Smjacob
4377365Smjacob/*
4477365Smjacob * This ioctl resets the HBA. Use with caution.
4577365Smjacob */
4691036Smjacob#define	ISP_RESETHBA	_IO(ISP_IOC, 2)
4777365Smjacob
4877365Smjacob/*
49157943Smjacob * This ioctl performs a fibre channel rescan.
5077365Smjacob */
5191036Smjacob#define	ISP_RESCAN	_IO(ISP_IOC, 3)
5277365Smjacob
5377365Smjacob/*
5491036Smjacob * This ioctl performs a reset and then will set the adapter to the
5591036Smjacob * role that was passed in (the old role will be returned). It almost
5691036Smjacob * goes w/o saying: use with caution.
57196008Smjacob *
58196008Smjacob * Channel selector stored in bits 8..32 as input to driver.
5977365Smjacob */
6091036Smjacob#define ISP_SETROLE     _IOWR(ISP_IOC, 4, int)
6177365Smjacob
6291036Smjacob#define ISP_ROLE_NONE           0x0
63125547Smjacob#define ISP_ROLE_TARGET         0x1
64125547Smjacob#define ISP_ROLE_INITIATOR      0x2
6591036Smjacob#define ISP_ROLE_BOTH           (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR)
6691036Smjacob
6777365Smjacob/*
6891036Smjacob * Get the current adapter role
69196008Smjacob * Channel selector passed in first argument.
7077365Smjacob */
71122638Smjacob#define ISP_GETROLE     _IOR(ISP_IOC, 5, int)
7277365Smjacob
7388855Smjacob/*
7488855Smjacob * Get/Clear Stats
7588855Smjacob */
7688855Smjacob#define	ISP_STATS_VERSION	0
7788855Smjacobtypedef struct {
78155704Smjacob	uint8_t		isp_stat_version;
79155704Smjacob	uint8_t		isp_type;		/* (ro) reflects chip type */
80155704Smjacob	uint8_t		isp_revision;		/* (ro) reflects chip version */
81155704Smjacob	uint8_t		unused1;
82155704Smjacob	uint32_t	unused2;
8388855Smjacob	/*
8488855Smjacob	 * Statistics Counters
8588855Smjacob	 */
8688855Smjacob#define	ISP_NSTATS	16
8788855Smjacob#define	ISP_INTCNT	0
8888855Smjacob#define	ISP_INTBOGUS	1
8988855Smjacob#define	ISP_INTMBOXC	2
9088855Smjacob#define	ISP_INGOASYNC	3
9188855Smjacob#define	ISP_RSLTCCMPLT	4
9288855Smjacob#define	ISP_FPHCCMCPLT	5
9388855Smjacob#define	ISP_RSCCHIWAT	6
9488855Smjacob#define	ISP_FPCCHIWAT	7
95155704Smjacob	uint64_t	isp_stats[ISP_NSTATS];
9688855Smjacob} isp_stats_t;
9788855Smjacob
9888855Smjacob#define	ISP_GET_STATS	_IOR(ISP_IOC, 6, isp_stats_t)
9988855Smjacob#define	ISP_CLR_STATS	_IO(ISP_IOC, 7)
10090754Smjacob
10190754Smjacob/*
10291036Smjacob * Initiate a LIP
10391036Smjacob */
10491036Smjacob#define	ISP_FC_LIP	_IO(ISP_IOC, 8)
10591036Smjacob
10691036Smjacob/*
10791036Smjacob * Return the Port Database structure for the named device, or ENODEV if none.
10891036Smjacob * Caller fills in virtual loopid (0..255), aka 'target'. The driver returns
10991036Smjacob * ENODEV (if nothing valid there) or the actual loopid (for local loop devices
11091036Smjacob * only), 24 bit Port ID and Node and Port WWNs.
11191036Smjacob */
11291036Smjacobstruct isp_fc_device {
113196008Smjacob	uint32_t	loopid;		/* 0..255,2047 */
114196008Smjacob	uint32_t
115196008Smjacob			chan 	: 6,
116125547Smjacob			role 	: 2,
117125547Smjacob			portid	: 24;	/* 24 bit Port ID */
118155704Smjacob	uint64_t	node_wwn;
119155704Smjacob	uint64_t	port_wwn;
12091036Smjacob};
12191036Smjacob#define	ISP_FC_GETDINFO	_IOWR(ISP_IOC, 9, struct isp_fc_device)
12291036Smjacob
12391036Smjacob/*
12490754Smjacob * Get F/W crash dump
12590754Smjacob */
12690813Smjacob#define	ISP_GET_FW_CRASH_DUMP	_IO(ISP_IOC, 10)
12790754Smjacob#define	ISP_FORCE_CRASH_DUMP	_IO(ISP_IOC, 11)
12898286Smjacob
12998286Smjacob/*
13098286Smjacob * Get information about this Host Adapter, including current connection
13198286Smjacob * topology and capabilities.
13298286Smjacob */
13398286Smjacobstruct isp_hba_device {
134155704Smjacob	uint32_t
13598286Smjacob					: 8,
13698286Smjacob		fc_speed		: 4,	/* Gbps */
137196008Smjacob					: 1,
13898286Smjacob		fc_topology		: 3,
139196008Smjacob		fc_channel		: 8,
140196008Smjacob		fc_loopid		: 16;
141155704Smjacob	uint8_t		fc_fw_major;
142155704Smjacob	uint8_t		fc_fw_minor;
143155704Smjacob	uint8_t		fc_fw_micro;
144196008Smjacob	uint8_t		fc_nchannels;	/* number of supported channels */
145196008Smjacob	uint16_t	fc_nports;	/* number of supported ports */
146155704Smjacob	uint64_t	nvram_node_wwn;
147155704Smjacob	uint64_t	nvram_port_wwn;
148155704Smjacob	uint64_t	active_node_wwn;
149155704Smjacob	uint64_t	active_port_wwn;
15098286Smjacob};
15198286Smjacob
15298286Smjacob#define	ISP_TOPO_UNKNOWN	0	/* connection topology unknown */
15398286Smjacob#define	ISP_TOPO_FCAL		1	/* private or PL_DA */
15498286Smjacob#define	ISP_TOPO_LPORT		2	/* public loop */
15598286Smjacob#define	ISP_TOPO_NPORT		3	/* N-port */
15698286Smjacob#define	ISP_TOPO_FPORT		4	/* F-port */
15798286Smjacob
158196008Smjacob/* don't use 12 any more */
159196008Smjacob#define	ISP_FC_GETHINFO	_IOWR(ISP_IOC, 13, struct isp_hba_device)
16099597Smjacob
161151834Smjacob/*
162151834Smjacob * Various Reset Goodies
163151834Smjacob */
164151834Smjacobstruct isp_fc_tsk_mgmt {
165196008Smjacob	uint32_t	loopid;		/* 0..255/2048 */
166196008Smjacob	uint16_t	lun;
167196008Smjacob	uint16_t	chan;
168151834Smjacob	enum {
169160976Smjacob		IPT_CLEAR_ACA,
170160976Smjacob		IPT_TARGET_RESET,
171160976Smjacob		IPT_LUN_RESET,
172160976Smjacob		IPT_CLEAR_TASK_SET,
173160976Smjacob		IPT_ABORT_TASK_SET
174151834Smjacob	} action;
175151834Smjacob};
176196008Smjacob/* don't use 97 any more */
177196008Smjacob#define	ISP_TSK_MGMT		_IOWR(ISP_IOC, 98, struct isp_fc_tsk_mgmt)
178196008Smjacob
179196008Smjacob/*
180196008Smjacob * Just gimme a list of WWPNs that are logged into us.
181196008Smjacob */
182196008Smjacobtypedef struct {
183196008Smjacob	uint16_t count;
184196008Smjacob	uint16_t channel;
185196008Smjacob	struct wwnpair {
186196008Smjacob		uint64_t wwnn;
187196008Smjacob		uint64_t wwpn;
188196008Smjacob	} wwns[1];
189196008Smjacob} isp_dlist_t;
190196008Smjacob#define	ISP_FC_GETDLIST _IO(ISP_IOC, 14)
191