xref: /freebsd/sys/dev/isp/isp_ioctl.h (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
1098ca2bdSWarner Losh /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
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  */
28e48b2487SMatt Jacob 
295d571944SMatt Jacob /*
305d571944SMatt Jacob  * ioctl definitions for Qlogic FC/SCSI HBA driver
315d571944SMatt Jacob  */
325d571944SMatt Jacob #define	ISP_IOC		(021)	/* 'Ctrl-Q' */
335d571944SMatt Jacob 
345d571944SMatt Jacob /*
355d571944SMatt Jacob  * This ioctl sets/retrieves the debugging level for this hba instance.
365d571944SMatt Jacob  * Note that this is not a simple integer level- see ispvar.h for definitions.
375d571944SMatt Jacob  *
385d571944SMatt Jacob  * The arguments is a pointer to an integer with the new debugging level.
395d571944SMatt Jacob  * The old value is written into this argument.
405d571944SMatt Jacob  */
415d571944SMatt Jacob 
42f553351eSMatt Jacob #define	ISP_SDBLEV	_IOWR(ISP_IOC, 1, int)
435d571944SMatt Jacob 
445d571944SMatt Jacob /*
455d571944SMatt Jacob  * This ioctl resets the HBA. Use with caution.
465d571944SMatt Jacob  */
47f553351eSMatt Jacob #define	ISP_RESETHBA	_IO(ISP_IOC, 2)
485d571944SMatt Jacob 
495d571944SMatt Jacob /*
509cd7268eSMatt Jacob  * This ioctl performs a fibre channel rescan.
515d571944SMatt Jacob  */
52f553351eSMatt Jacob #define	ISP_RESCAN	_IO(ISP_IOC, 3)
535d571944SMatt Jacob 
545d571944SMatt Jacob /*
55f553351eSMatt Jacob  * This ioctl performs a reset and then will set the adapter to the
56f553351eSMatt Jacob  * role that was passed in (the old role will be returned). It almost
57f553351eSMatt Jacob  * goes w/o saying: use with caution.
582df76c16SMatt Jacob  *
592df76c16SMatt Jacob  * Channel selector stored in bits 8..32 as input to driver.
605d571944SMatt Jacob  */
61f553351eSMatt Jacob #define ISP_SETROLE     _IOWR(ISP_IOC, 4, int)
62f553351eSMatt Jacob 
63f553351eSMatt Jacob #define ISP_ROLE_NONE           0x0
644e8a2b48SMatt Jacob #define ISP_ROLE_TARGET         0x1
654e8a2b48SMatt Jacob #define ISP_ROLE_INITIATOR      0x2
66f553351eSMatt Jacob #define ISP_ROLE_BOTH           (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR)
675d571944SMatt Jacob 
685d571944SMatt Jacob /*
69f553351eSMatt Jacob  * Get the current adapter role
702df76c16SMatt Jacob  * Channel selector passed in first argument.
715d571944SMatt Jacob  */
721484f178SMatt Jacob #define ISP_GETROLE     _IOR(ISP_IOC, 5, int)
732903b272SMatt Jacob 
742903b272SMatt Jacob /*
752903b272SMatt Jacob  * Get/Clear Stats
762903b272SMatt Jacob  */
772903b272SMatt Jacob #define	ISP_STATS_VERSION	0
782903b272SMatt Jacob typedef struct {
791dae40ebSMatt Jacob 	uint8_t		isp_stat_version;
801dae40ebSMatt Jacob 	uint8_t		isp_type;		/* (ro) reflects chip type */
811dae40ebSMatt Jacob 	uint8_t		isp_revision;		/* (ro) reflects chip version */
821dae40ebSMatt Jacob 	uint8_t		unused1;
831dae40ebSMatt Jacob 	uint32_t	unused2;
842903b272SMatt Jacob 	/*
852903b272SMatt Jacob 	 * Statistics Counters
862903b272SMatt Jacob 	 */
872903b272SMatt Jacob #define	ISP_NSTATS	16
882903b272SMatt Jacob #define	ISP_INTCNT	0
892903b272SMatt Jacob #define	ISP_INTBOGUS	1
902903b272SMatt Jacob #define	ISP_INTMBOXC	2
912903b272SMatt Jacob #define	ISP_INGOASYNC	3
922903b272SMatt Jacob #define	ISP_RSLTCCMPLT	4
932903b272SMatt Jacob #define	ISP_FPHCCMCPLT	5
942903b272SMatt Jacob #define	ISP_RSCCHIWAT	6
952903b272SMatt Jacob #define	ISP_FPCCHIWAT	7
961dae40ebSMatt Jacob 	uint64_t	isp_stats[ISP_NSTATS];
972903b272SMatt Jacob } isp_stats_t;
982903b272SMatt Jacob 
992903b272SMatt Jacob #define	ISP_GET_STATS	_IOR(ISP_IOC, 6, isp_stats_t)
1002903b272SMatt Jacob #define	ISP_CLR_STATS	_IO(ISP_IOC, 7)
101b8941882SMatt Jacob 
102b8941882SMatt Jacob /*
103f553351eSMatt Jacob  * Initiate a LIP
104f553351eSMatt Jacob  */
105f553351eSMatt Jacob #define	ISP_FC_LIP	_IO(ISP_IOC, 8)
106f553351eSMatt Jacob 
107f553351eSMatt Jacob /*
108f553351eSMatt Jacob  * Return the Port Database structure for the named device, or ENODEV if none.
109f553351eSMatt Jacob  * Caller fills in virtual loopid (0..255), aka 'target'. The driver returns
110f553351eSMatt Jacob  * ENODEV (if nothing valid there) or the actual loopid (for local loop devices
111f553351eSMatt Jacob  * only), 24 bit Port ID and Node and Port WWNs.
112f553351eSMatt Jacob  */
113f553351eSMatt Jacob struct isp_fc_device {
1142df76c16SMatt Jacob 	uint32_t	loopid;		/* 0..255,2047 */
1152df76c16SMatt Jacob 	uint32_t
1162df76c16SMatt Jacob 			chan 	: 6,
1174e8a2b48SMatt Jacob 			role 	: 2,
1184e8a2b48SMatt Jacob 			portid	: 24;	/* 24 bit Port ID */
1191dae40ebSMatt Jacob 	uint64_t	node_wwn;
1201dae40ebSMatt Jacob 	uint64_t	port_wwn;
121f553351eSMatt Jacob };
122f553351eSMatt Jacob #define	ISP_FC_GETDINFO	_IOWR(ISP_IOC, 9, struct isp_fc_device)
123f553351eSMatt Jacob 
124f553351eSMatt Jacob /*
125b8941882SMatt Jacob  * Get F/W crash dump
126b8941882SMatt Jacob  */
127d134aa0bSMatt Jacob #define	ISP_GET_FW_CRASH_DUMP	_IO(ISP_IOC, 10)
128b8941882SMatt Jacob #define	ISP_FORCE_CRASH_DUMP	_IO(ISP_IOC, 11)
12981ac5536SMatt Jacob 
13081ac5536SMatt Jacob /*
13181ac5536SMatt Jacob  * Get information about this Host Adapter, including current connection
13281ac5536SMatt Jacob  * topology and capabilities.
13381ac5536SMatt Jacob  */
13481ac5536SMatt Jacob struct isp_hba_device {
1351dae40ebSMatt Jacob 	uint32_t
13681ac5536SMatt Jacob 					: 8,
13781ac5536SMatt Jacob 		fc_speed		: 4,	/* Gbps */
1382df76c16SMatt Jacob 					: 1,
13981ac5536SMatt Jacob 		fc_topology		: 3,
1402df76c16SMatt Jacob 		fc_channel		: 8,
1412df76c16SMatt Jacob 		fc_loopid		: 16;
1421dae40ebSMatt Jacob 	uint8_t		fc_fw_major;
1431dae40ebSMatt Jacob 	uint8_t		fc_fw_minor;
1441dae40ebSMatt Jacob 	uint8_t		fc_fw_micro;
1452df76c16SMatt Jacob 	uint8_t		fc_nchannels;	/* number of supported channels */
1462df76c16SMatt Jacob 	uint16_t	fc_nports;	/* number of supported ports */
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 
1592df76c16SMatt Jacob /* don't use 12 any more */
1602df76c16SMatt Jacob #define	ISP_FC_GETHINFO	_IOWR(ISP_IOC, 13, struct isp_hba_device)
1618e62a8acSMatt Jacob 
1628e62a8acSMatt Jacob /*
1638e62a8acSMatt Jacob  * Various Reset Goodies
1648e62a8acSMatt Jacob  */
1658e62a8acSMatt Jacob struct isp_fc_tsk_mgmt {
1662df76c16SMatt Jacob 	uint32_t	loopid;		/* 0..255/2048 */
1672df76c16SMatt Jacob 	uint16_t	lun;
1682df76c16SMatt Jacob 	uint16_t	chan;
1698e62a8acSMatt Jacob 	enum {
170f0f536d1SMatt Jacob 		IPT_CLEAR_ACA,
171f0f536d1SMatt Jacob 		IPT_TARGET_RESET,
172f0f536d1SMatt Jacob 		IPT_LUN_RESET,
173f0f536d1SMatt Jacob 		IPT_CLEAR_TASK_SET,
174f0f536d1SMatt Jacob 		IPT_ABORT_TASK_SET
1758e62a8acSMatt Jacob 	} action;
1768e62a8acSMatt Jacob };
1772df76c16SMatt Jacob /* don't use 97 any more */
1782df76c16SMatt Jacob #define	ISP_TSK_MGMT		_IOWR(ISP_IOC, 98, struct isp_fc_tsk_mgmt)
1792df76c16SMatt Jacob 
1802df76c16SMatt Jacob /*
1812df76c16SMatt Jacob  * Just gimme a list of WWPNs that are logged into us.
1822df76c16SMatt Jacob  */
1832df76c16SMatt Jacob typedef struct {
1842df76c16SMatt Jacob 	uint16_t count;
1852df76c16SMatt Jacob 	uint16_t channel;
1862df76c16SMatt Jacob 	struct wwnpair {
1872df76c16SMatt Jacob 		uint64_t wwnn;
1882df76c16SMatt Jacob 		uint64_t wwpn;
1892df76c16SMatt Jacob 	} wwns[1];
1902df76c16SMatt Jacob } isp_dlist_t;
1912df76c16SMatt Jacob #define	ISP_FC_GETDLIST _IO(ISP_IOC, 14)
192