xref: /titanic_52/usr/src/uts/common/sys/fibre-channel/ulp/fcip.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1*fcf3ce44SJohn Forte /*
2*fcf3ce44SJohn Forte  * CDDL HEADER START
3*fcf3ce44SJohn Forte  *
4*fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5*fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6*fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7*fcf3ce44SJohn Forte  *
8*fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10*fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11*fcf3ce44SJohn Forte  * and limitations under the License.
12*fcf3ce44SJohn Forte  *
13*fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14*fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16*fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17*fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18*fcf3ce44SJohn Forte  *
19*fcf3ce44SJohn Forte  * CDDL HEADER END
20*fcf3ce44SJohn Forte  */
21*fcf3ce44SJohn Forte /*
22*fcf3ce44SJohn Forte  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*fcf3ce44SJohn Forte  * Use is subject to license terms.
24*fcf3ce44SJohn Forte  */
25*fcf3ce44SJohn Forte 
26*fcf3ce44SJohn Forte #ifndef	_SYS_FIBRE_CHANNEL_ULP_FCIP_H
27*fcf3ce44SJohn Forte #define	_SYS_FIBRE_CHANNEL_ULP_FCIP_H
28*fcf3ce44SJohn Forte 
29*fcf3ce44SJohn Forte 
30*fcf3ce44SJohn Forte 
31*fcf3ce44SJohn Forte /*
32*fcf3ce44SJohn Forte  * Header file for FCIP: IP/ARP ULP over FibreChannel
33*fcf3ce44SJohn Forte  */
34*fcf3ce44SJohn Forte 
35*fcf3ce44SJohn Forte #include <sys/kstat.h>
36*fcf3ce44SJohn Forte #include <sys/socket.h>
37*fcf3ce44SJohn Forte #include <netinet/arp.h>
38*fcf3ce44SJohn Forte 
39*fcf3ce44SJohn Forte #ifdef	__cplusplus
40*fcf3ce44SJohn Forte extern "C" {
41*fcf3ce44SJohn Forte #endif
42*fcf3ce44SJohn Forte 
43*fcf3ce44SJohn Forte /*
44*fcf3ce44SJohn Forte  * Definitions for module_info.
45*fcf3ce44SJohn Forte  */
46*fcf3ce44SJohn Forte #define		FCIPIDNUM	(77)		/* module ID number */
47*fcf3ce44SJohn Forte #define		FCIPNAME	"fcip"		/* module name */
48*fcf3ce44SJohn Forte #define		FCIPMINPSZ	(0)		/* min packet size */
49*fcf3ce44SJohn Forte #define		FCIPMAXPSZ	1514		/* max packet size */
50*fcf3ce44SJohn Forte #define		FCIPHIWAT	(32 * 1024)	/* hi-water mark */
51*fcf3ce44SJohn Forte #define		FCIPLOWAT	(1)		/* lo-water mark */
52*fcf3ce44SJohn Forte #define		FCIPMTU		65280		/* Max permissible MTU */
53*fcf3ce44SJohn Forte #define		FCIPMIN		(ETHERMIN + sizeof (llc_snap_hdr_t) + \
54*fcf3ce44SJohn Forte 				sizeof (fcph_network_hdr_t))
55*fcf3ce44SJohn Forte 
56*fcf3ce44SJohn Forte /*
57*fcf3ce44SJohn Forte  * Per-Stream instance state information.
58*fcf3ce44SJohn Forte  *
59*fcf3ce44SJohn Forte  * Each instance is dynamically allocated at open() and free'd
60*fcf3ce44SJohn Forte  * at close().  Each per-Stream instance points to at most one
61*fcf3ce44SJohn Forte  * per-device structure using the sl_fcip field.  All instances
62*fcf3ce44SJohn Forte  * are threaded together into one list of active instances
63*fcf3ce44SJohn Forte  * ordered on minor device number.
64*fcf3ce44SJohn Forte  */
65*fcf3ce44SJohn Forte 
66*fcf3ce44SJohn Forte #define	NMCHASH			64	/* no. of multicast hash buckets */
67*fcf3ce44SJohn Forte #define	INIT_BUCKET_SIZE	16	/* Initial hash bucket size */
68*fcf3ce44SJohn Forte 
69*fcf3ce44SJohn Forte struct	fcipstr {
70*fcf3ce44SJohn Forte 	struct fcipstr	*sl_nextp;	/* next in list */
71*fcf3ce44SJohn Forte 	queue_t		*sl_rq;		/* pointer to our rq */
72*fcf3ce44SJohn Forte 	struct fcip 	*sl_fcip;	/* attached device */
73*fcf3ce44SJohn Forte 	t_uscalar_t	sl_state;	/* current DL state */
74*fcf3ce44SJohn Forte 	t_uscalar_t	sl_sap;		/* bound sap */
75*fcf3ce44SJohn Forte 	uint32_t	sl_flags;	/* misc. flags */
76*fcf3ce44SJohn Forte 	uint32_t	sl_minor;	/* minor device number */
77*fcf3ce44SJohn Forte 	la_wwn_t	*sl_mctab[NMCHASH]; /* multicast addr table */
78*fcf3ce44SJohn Forte 	uint_t		sl_mccount[NMCHASH]; /* # valid addr in mctab[i] */
79*fcf3ce44SJohn Forte 	uint_t		sl_mcsize[NMCHASH]; /* size of mctab[i] */
80*fcf3ce44SJohn Forte 	ushort_t	sl_ladrf[4];	/* Multicast filter bits */
81*fcf3ce44SJohn Forte 	ushort_t	sl_ladrf_refcnt[64]; /* ref. count for filter bits */
82*fcf3ce44SJohn Forte 	kmutex_t	sl_lock;	/* protect this structure */
83*fcf3ce44SJohn Forte };
84*fcf3ce44SJohn Forte 
85*fcf3ce44SJohn Forte /* per-stream flags */
86*fcf3ce44SJohn Forte #define	FCIP_SLFAST	0x01	/* "M_DATA fastpath" mode */
87*fcf3ce44SJohn Forte #define	FCIP_SLRAW	0x02	/* M_DATA plain raw mode */
88*fcf3ce44SJohn Forte #define	FCIP_SLALLPHYS	0x04	/* "promiscuous mode" */
89*fcf3ce44SJohn Forte #define	FCIP_SLALLMULTI	0x08	/* enable all multicast addresses */
90*fcf3ce44SJohn Forte #define	FCIP_SLALLSAP	0x10	/* enable all ether type values */
91*fcf3ce44SJohn Forte 
92*fcf3ce44SJohn Forte /*
93*fcf3ce44SJohn Forte  * Maximum # of multicast addresses per Stream.
94*fcf3ce44SJohn Forte  */
95*fcf3ce44SJohn Forte #define	FCIPMAXMC	64
96*fcf3ce44SJohn Forte #define	FCIPMCALLOC	(FCIPMAXMC * sizeof (la_wwn_t))
97*fcf3ce44SJohn Forte 
98*fcf3ce44SJohn Forte /*
99*fcf3ce44SJohn Forte  * Full DLSAP address length (in struct dladdr format).
100*fcf3ce44SJohn Forte  */
101*fcf3ce44SJohn Forte #define	FCIPADDRL	(sizeof (ushort_t) + sizeof (struct ether_addr))
102*fcf3ce44SJohn Forte 
103*fcf3ce44SJohn Forte 
104*fcf3ce44SJohn Forte typedef struct fcip_port_info {
105*fcf3ce44SJohn Forte 	struct fcip_port_info	*fcipp_next;	/* next port in list */
106*fcf3ce44SJohn Forte 	opaque_t		*fcipp_handle;
107*fcf3ce44SJohn Forte 	struct modlinkage	fcipp_linkage;
108*fcf3ce44SJohn Forte 	dev_info_t		*fcipp_dip;
109*fcf3ce44SJohn Forte 	uint32_t		fcipp_topology;
110*fcf3ce44SJohn Forte 	uint32_t		fcipp_pstate;
111*fcf3ce44SJohn Forte 	la_wwn_t		fcipp_pwwn;
112*fcf3ce44SJohn Forte 	la_wwn_t		fcipp_nwwn;
113*fcf3ce44SJohn Forte 	uchar_t			fcipp_naa;	/* This port's NAA */
114*fcf3ce44SJohn Forte 	int			fcipp_fca_pkt_size;
115*fcf3ce44SJohn Forte 	ddi_dma_attr_t		fcipp_cmd_dma_attr;
116*fcf3ce44SJohn Forte 	ddi_dma_attr_t		fcipp_resp_dma_attr;
117*fcf3ce44SJohn Forte 	ddi_device_acc_attr_t	fcipp_fca_acc_attr;
118*fcf3ce44SJohn Forte 	fc_portid_t		fcipp_sid;	/* this port's S_ID */
119*fcf3ce44SJohn Forte 	struct fcip		*fcipp_fcip;	/* this port's fcip struct */
120*fcf3ce44SJohn Forte } fcip_port_info_t;
121*fcf3ce44SJohn Forte 
122*fcf3ce44SJohn Forte #define	FCIP_SUCCESS		(0)
123*fcf3ce44SJohn Forte #define	FCIP_FAILURE		(1)
124*fcf3ce44SJohn Forte #define	FCIP_FARP_TIMEOUT	10	/* seconds */
125*fcf3ce44SJohn Forte #define	FCIP_WAIT_CMDS		5	/* 5 retries at 1 sec between retries */
126*fcf3ce44SJohn Forte 
127*fcf3ce44SJohn Forte /*
128*fcf3ce44SJohn Forte  * Num ports supported for soft_state_init
129*fcf3ce44SJohn Forte  */
130*fcf3ce44SJohn Forte #define	FCIP_NUM_INSTANCES	5
131*fcf3ce44SJohn Forte 
132*fcf3ce44SJohn Forte #define	FCIP_UB_NBUFS		60
133*fcf3ce44SJohn Forte #define	FCIP_UB_SIZE		65535
134*fcf3ce44SJohn Forte #define	FCIP_UB_DECREMENT	4
135*fcf3ce44SJohn Forte #define	FCIP_UB_MINBUFS		8
136*fcf3ce44SJohn Forte #define	FCIP_INIT_DELAY		10000000	/* 10 seconds */
137*fcf3ce44SJohn Forte #define	FCIP_PKT_TTL		120		/* 120 secs */
138*fcf3ce44SJohn Forte #define	FCIP_TIMEOUT_INTERVAL	10		/* 10 seconds */
139*fcf3ce44SJohn Forte #define	FCIP_OFFLINE_TIMEOUT	60		/* 60 seconds */
140*fcf3ce44SJohn Forte #define	FCIP_MAX_PORTS		127		/* for private loop/pt_pt */
141*fcf3ce44SJohn Forte #define	FCIP_RTE_TIMEOUT	60		/* 60 seconds */
142*fcf3ce44SJohn Forte 
143*fcf3ce44SJohn Forte #define	ETHERSTRL		((2 * ETHERADDRL) + 1)
144*fcf3ce44SJohn Forte /*
145*fcf3ce44SJohn Forte  * Hash lists
146*fcf3ce44SJohn Forte  */
147*fcf3ce44SJohn Forte #define	FCIP_RT_HASH_ELEMS	32
148*fcf3ce44SJohn Forte #define	FCIP_DEST_HASH_ELEMS	16
149*fcf3ce44SJohn Forte 
150*fcf3ce44SJohn Forte 
151*fcf3ce44SJohn Forte #define	FCIP_RT_HASH(x)		((x[2] + x[3] + x[4] + x[5] + x[6] + x[7]) \
152*fcf3ce44SJohn Forte 				& (FCIP_RT_HASH_ELEMS - 1))
153*fcf3ce44SJohn Forte 
154*fcf3ce44SJohn Forte #define	FCIP_DEST_HASH(x)	((x[2] + x[3] + x[4] + x[5] + x[6] + x[7]) \
155*fcf3ce44SJohn Forte 				& (FCIP_DEST_HASH_ELEMS - 1))
156*fcf3ce44SJohn Forte 
157*fcf3ce44SJohn Forte #define	FCIP_HDR_SIZE		8
158*fcf3ce44SJohn Forte #define	FCIP_RT_INVALID		(-1)
159*fcf3ce44SJohn Forte #define	FCIP_RT_RETIRED		(-2)
160*fcf3ce44SJohn Forte #define	FCIP_RT_SUSPENDED	(-3)
161*fcf3ce44SJohn Forte #define	FCIP_RT_LOGIN_PROGRESS	(-4)
162*fcf3ce44SJohn Forte 
163*fcf3ce44SJohn Forte #define	FCIP_RTE_UNAVAIL(state)	(((state) == FCIP_RT_INVALID) || \
164*fcf3ce44SJohn Forte 					((state) == FCIP_RT_RETIRED) || \
165*fcf3ce44SJohn Forte 					((state) == FCIP_RT_SUSPENDED)) ? 1 : 0
166*fcf3ce44SJohn Forte 
167*fcf3ce44SJohn Forte /*
168*fcf3ce44SJohn Forte  * Taskq related
169*fcf3ce44SJohn Forte  */
170*fcf3ce44SJohn Forte #define	FCIP_NUM_THREADS	4
171*fcf3ce44SJohn Forte #define	FCIP_MIN_TASKS		12
172*fcf3ce44SJohn Forte #define	FCIP_MAX_TASKS		32
173*fcf3ce44SJohn Forte 
174*fcf3ce44SJohn Forte 
175*fcf3ce44SJohn Forte /*
176*fcf3ce44SJohn Forte  * Per-Device instance state information.
177*fcf3ce44SJohn Forte  *
178*fcf3ce44SJohn Forte  * Each instance is dynamically allocated on first attach.
179*fcf3ce44SJohn Forte  */
180*fcf3ce44SJohn Forte struct fcip {
181*fcf3ce44SJohn Forte 	dev_info_t		*fcip_dip;	/* parent's dev_info */
182*fcf3ce44SJohn Forte 	int			fcip_instance;	/* parent's instance */
183*fcf3ce44SJohn Forte 	struct fcip		*fcip_sibling;	/* The other FCA port */
184*fcf3ce44SJohn Forte 	uint32_t		fcip_flags;	/* misc. flags */
185*fcf3ce44SJohn Forte 	uint32_t		fcip_port_state; /* Link State */
186*fcf3ce44SJohn Forte 	fcip_port_info_t	*fcip_port_info; /* info about port */
187*fcf3ce44SJohn Forte 	struct fcip		*fcip_next;
188*fcf3ce44SJohn Forte 
189*fcf3ce44SJohn Forte 	kcondvar_t		fcip_farp_cv;	/* For perport serialization */
190*fcf3ce44SJohn Forte 	int			fcip_farp_rsp_flag; /* FARP response flag */
191*fcf3ce44SJohn Forte 	kmutex_t		fcip_mutex;	/* protect this structure */
192*fcf3ce44SJohn Forte 	kmutex_t		fcip_ub_mutex;	/* protect the unsol bufs */
193*fcf3ce44SJohn Forte 
194*fcf3ce44SJohn Forte 	uint32_t		fcip_ub_nbufs;	/* no. of Unsol. Buffers */
195*fcf3ce44SJohn Forte 	uint32_t		fcip_ub_upstream; /* no ubufs in use */
196*fcf3ce44SJohn Forte 	kcondvar_t		fcip_ub_cv;
197*fcf3ce44SJohn Forte 	timeout_id_t		fcip_timeout_id; /* for timeout routine */
198*fcf3ce44SJohn Forte 	uint32_t		fcip_timeout_ticks;
199*fcf3ce44SJohn Forte 	uint32_t		fcip_mark_offline;
200*fcf3ce44SJohn Forte 
201*fcf3ce44SJohn Forte 	uint64_t		*fcip_ub_tokens; /* unsol buf tokens */
202*fcf3ce44SJohn Forte 	kmutex_t		fcip_dest_mutex; /* dest table lock */
203*fcf3ce44SJohn Forte 	struct fcip_dest	*fcip_dest[FCIP_DEST_HASH_ELEMS];
204*fcf3ce44SJohn Forte 					/* hash table of remote dest. ports */
205*fcf3ce44SJohn Forte 	kmutex_t		fcip_rt_mutex;	/* routing table lock */
206*fcf3ce44SJohn Forte 	struct fcip_routing_table *fcip_rtable[FCIP_RT_HASH_ELEMS];
207*fcf3ce44SJohn Forte 					/* hash table of WWN to D_ID maps */
208*fcf3ce44SJohn Forte 
209*fcf3ce44SJohn Forte 	int			fcip_intr_flag;	/* init. flag for fcipintr() */
210*fcf3ce44SJohn Forte 	uint32_t		fcip_addrflags;	/* type of MAC address */
211*fcf3ce44SJohn Forte 	struct ether_addr	fcip_factmacaddr; /* local mac address */
212*fcf3ce44SJohn Forte 	struct ether_addr	fcip_macaddr;	/* MAC addr */
213*fcf3ce44SJohn Forte 	la_wwn_t		fcip_ouraddr;	/* individual address */
214*fcf3ce44SJohn Forte 	uchar_t			fcip_ouripaddr[16]; /* Our IP address */
215*fcf3ce44SJohn Forte 	struct kmem_cache	*fcip_xmit_cache; /* cache of xmit pkts */
216*fcf3ce44SJohn Forte 	uint32_t		fcip_wantw;	/* out of xmit resources */
217*fcf3ce44SJohn Forte 	queue_t			*fcip_ipq;	/* ip read queue */
218*fcf3ce44SJohn Forte 	taskq_t			*fcip_tq;	/* Taskq pointer */
219*fcf3ce44SJohn Forte 	int			fcip_sendup_thr_initted; /* sendup tq thread */
220*fcf3ce44SJohn Forte 	kmutex_t		fcip_sendup_mutex; /* for upstream data */
221*fcf3ce44SJohn Forte 	kcondvar_t		fcip_sendup_cv;	/* for upstream unsol data */
222*fcf3ce44SJohn Forte 	struct fcip_sendup_elem	*fcip_sendup_head; /* head of mblk elems */
223*fcf3ce44SJohn Forte 	struct fcip_sendup_elem	*fcip_sendup_tail; /* tail of elem list */
224*fcf3ce44SJohn Forte 	struct kmem_cache	*fcip_sendup_cache; /* for sendup elems */
225*fcf3ce44SJohn Forte 	uint32_t		fcip_sendup_cnt; /* Num msgs queued */
226*fcf3ce44SJohn Forte 	uint32_t		fcip_broadcast_did; /* broadcast D_ID */
227*fcf3ce44SJohn Forte 
228*fcf3ce44SJohn Forte 	kstat_t			*fcip_intrstats; /* interrupt statistics */
229*fcf3ce44SJohn Forte 	kstat_t			*fcip_kstatp;	/* kstat pointer */
230*fcf3ce44SJohn Forte 
231*fcf3ce44SJohn Forte 	callb_cpr_t		fcip_cpr_info;	/* for the sendup thread */
232*fcf3ce44SJohn Forte 
233*fcf3ce44SJohn Forte 	ulong_t			fcip_ipackets;  /* # packets received */
234*fcf3ce44SJohn Forte 	ulong_t			fcip_ierrors;	/* # total input errors */
235*fcf3ce44SJohn Forte 	ulong_t			fcip_opackets;  /* # packets sent */
236*fcf3ce44SJohn Forte 	ulong_t			fcip_oerrors;	/* # total output errors */
237*fcf3ce44SJohn Forte 	ulong_t			fcip_collisions;  /* # collisions */
238*fcf3ce44SJohn Forte 	ulong_t			fcip_defer;	/* # defers */
239*fcf3ce44SJohn Forte 	ulong_t			fcip_fram;	/* # receive framing errors */
240*fcf3ce44SJohn Forte 	ulong_t			fcip_crc;	/* # receive crc errors */
241*fcf3ce44SJohn Forte 	ulong_t			fcip_oflo;	/* # receiver overflows */
242*fcf3ce44SJohn Forte 	ulong_t			fcip_uflo;	/* # transmit underflows */
243*fcf3ce44SJohn Forte 	ulong_t			fcip_missed;	/* # receive missed */
244*fcf3ce44SJohn Forte 	ulong_t			fcip_tlcol;	/* # xmit late collisions */
245*fcf3ce44SJohn Forte 	ulong_t			fcip_trtry;	/* # transmit retry failures */
246*fcf3ce44SJohn Forte 	ulong_t			fcip_tnocar;	/* # loss of carrier errors */
247*fcf3ce44SJohn Forte 	ulong_t			fcip_inits;	/* # driver inits */
248*fcf3ce44SJohn Forte 	ulong_t			fcip_notbufs;	/* # out of pkts for xmit */
249*fcf3ce44SJohn Forte 	ulong_t			fcip_norbufs;	/* # out of buffers for rcv */
250*fcf3ce44SJohn Forte 	ulong_t			fcip_nocanput;  /* # input canputret.false */
251*fcf3ce44SJohn Forte 	ulong_t			fcip_allocbfail;  /* # allocb failed */
252*fcf3ce44SJohn Forte 	int 			fcip_tx_lbolt;  /* time of last tx interrupt */
253*fcf3ce44SJohn Forte 	int 			fcip_rx_lbolt; 	/* time of last rx interrupt */
254*fcf3ce44SJohn Forte 
255*fcf3ce44SJohn Forte 	/*
256*fcf3ce44SJohn Forte 	 * MIB II variables
257*fcf3ce44SJohn Forte 	 */
258*fcf3ce44SJohn Forte 	ulong_t			fcip_rcvbytes; /* # bytes received */
259*fcf3ce44SJohn Forte 	ulong_t			fcip_xmtbytes; /* # bytes transmitted */
260*fcf3ce44SJohn Forte 	ulong_t			fcip_multircv; /* # multicast pkts received */
261*fcf3ce44SJohn Forte 	ulong_t			fcip_multixmt; /* # multicast pkts for xmit */
262*fcf3ce44SJohn Forte 	ulong_t			fcip_brdcstrcv; /* # broadcast pkts received */
263*fcf3ce44SJohn Forte 	ulong_t			fcip_brdcstxmt; /* # broadcast pkts for xmit */
264*fcf3ce44SJohn Forte 	ulong_t			fcip_norcvbuf; /* # rcv pkts discarded */
265*fcf3ce44SJohn Forte 	ulong_t			fcip_noxmtbuf; /* # xmit pkts discarded */
266*fcf3ce44SJohn Forte 
267*fcf3ce44SJohn Forte 	ulong_t			fcip_num_ipkts_pending;
268*fcf3ce44SJohn Forte 						/* #ipkts pending call back */
269*fcf3ce44SJohn Forte };
270*fcf3ce44SJohn Forte 
271*fcf3ce44SJohn Forte #define	FCIP_FACTADDR_PRESENT		0x01
272*fcf3ce44SJohn Forte #define	FCIP_FACTADDR_USE		0x02
273*fcf3ce44SJohn Forte 
274*fcf3ce44SJohn Forte /* flags */
275*fcf3ce44SJohn Forte #define	FCIP_RUNNING			0x01
276*fcf3ce44SJohn Forte #define	FCIP_INITED			0x02
277*fcf3ce44SJohn Forte #define	FCIP_PROMISC			0x04
278*fcf3ce44SJohn Forte #define	FCIP_SUSPENDED			0x08
279*fcf3ce44SJohn Forte #define	FCIP_NOTIMEOUTS			0x10
280*fcf3ce44SJohn Forte #define	FCIP_DETACHING			0x20
281*fcf3ce44SJohn Forte #define	FCIP_DETACHED			0x40
282*fcf3ce44SJohn Forte #define	FCIP_ATTACHING			0x80
283*fcf3ce44SJohn Forte #define	FCIP_LINK_DOWN			0x100
284*fcf3ce44SJohn Forte #define	FCIP_IN_SC_CB			0x200
285*fcf3ce44SJohn Forte #define	FCIP_IN_DATA_CB			0x400
286*fcf3ce44SJohn Forte #define	FCIP_IN_ELS_CB			0x800
287*fcf3ce44SJohn Forte #define	FCIP_IN_TIMEOUT			0x1000
288*fcf3ce44SJohn Forte #define	FCIP_POWER_DOWN			0x2000
289*fcf3ce44SJohn Forte #define	FCIP_RTE_REMOVING		0x4000
290*fcf3ce44SJohn Forte #define	FCIP_REG_INPROGRESS		0x8000
291*fcf3ce44SJohn Forte /* macro for checking any callback */
292*fcf3ce44SJohn Forte #define	FCIP_IN_CALLBACK		(FCIP_IN_SC_CB | FCIP_IN_DATA_CB | \
293*fcf3ce44SJohn Forte 					FCIP_IN_ELS_CB)
294*fcf3ce44SJohn Forte /* macro for checking if a port is busy */
295*fcf3ce44SJohn Forte #define	FCIP_PORT_BUSY			(FCIP_ATTACHING | \
296*fcf3ce44SJohn Forte 					FCIP_REG_INPROGRESS | FCIP_DETACHING)
297*fcf3ce44SJohn Forte 
298*fcf3ce44SJohn Forte 
299*fcf3ce44SJohn Forte /*
300*fcf3ce44SJohn Forte  * FCIP routing table maintains the FC Layer and the ARP layer
301*fcf3ce44SJohn Forte  * mapping for a destination port.
302*fcf3ce44SJohn Forte  */
303*fcf3ce44SJohn Forte struct fcip_routing_table {
304*fcf3ce44SJohn Forte 	struct fcip_routing_table *fcipr_next;	/* next elem */
305*fcf3ce44SJohn Forte 	la_wwn_t	fcipr_pwwn;	/* Destination Port's Port WWN */
306*fcf3ce44SJohn Forte 	la_wwn_t	fcipr_nwwn;	/* Destination Port's Node WWN */
307*fcf3ce44SJohn Forte 	fc_portid_t	fcipr_d_id;	/* Destination Port's D_ID */
308*fcf3ce44SJohn Forte 	void		*fcipr_pd;	/* pointer to port device struct */
309*fcf3ce44SJohn Forte 	uchar_t		fcipr_ipaddr[16]; /* Port's IP address */
310*fcf3ce44SJohn Forte 	int		fcipr_state;	/* login state etc */
311*fcf3ce44SJohn Forte 	clock_t		fcipr_invalid_timeout;	/* wait after marked inval */
312*fcf3ce44SJohn Forte 	opaque_t	fcipr_fca_dev;	/* FCA device pointer */
313*fcf3ce44SJohn Forte };
314*fcf3ce44SJohn Forte 
315*fcf3ce44SJohn Forte #define	FCIP_COMPARE_NWWN		0x001
316*fcf3ce44SJohn Forte #define	FCIP_COMPARE_PWWN		0x010
317*fcf3ce44SJohn Forte #define	FCIP_COMPARE_BROADCAST		0x100
318*fcf3ce44SJohn Forte 
319*fcf3ce44SJohn Forte #define	IS_BROADCAST_ADDR(wwn)	(((wwn)->raw_wwn[2] == 0xff) && \
320*fcf3ce44SJohn Forte 				((wwn)->raw_wwn[3] == 0xff) && \
321*fcf3ce44SJohn Forte 				((wwn)->w.wwn_lo == 0xffffffff))
322*fcf3ce44SJohn Forte 
323*fcf3ce44SJohn Forte /*
324*fcf3ce44SJohn Forte  * Define a fcip_pkt structure. We can stuff information about
325*fcf3ce44SJohn Forte  * the message block and queue for which the packet was built. We can
326*fcf3ce44SJohn Forte  * then free up the message once the transport layer has confirmed
327*fcf3ce44SJohn Forte  * that the packet has been successfully transported.
328*fcf3ce44SJohn Forte  */
329*fcf3ce44SJohn Forte typedef struct fcip_pkt {
330*fcf3ce44SJohn Forte 	mblk_t			*fcip_pkt_mp;	/* message blk pointer */
331*fcf3ce44SJohn Forte 	queue_t			*fcip_pkt_wq;	/* queue pointer if needed */
332*fcf3ce44SJohn Forte 	uint32_t		fcip_pkt_ttl;	/* time to live */
333*fcf3ce44SJohn Forte 	uint32_t		fcip_pkt_retries; /* retries if needed */
334*fcf3ce44SJohn Forte 	fc_packet_t		*fcip_pkt_fcpktp; /* the actual fc packet */
335*fcf3ce44SJohn Forte 	struct fcip_dest	*fcip_pkt_dest;	/* destination of pkt */
336*fcf3ce44SJohn Forte 	struct fcip		*fcip_pkt_fptr;	/* fcip structure */
337*fcf3ce44SJohn Forte 	struct fcip_pkt		*fcip_pkt_next;	/* next pkt */
338*fcf3ce44SJohn Forte 	struct fcip_pkt		*fcip_pkt_prev;	/* prev pkt */
339*fcf3ce44SJohn Forte 	uint32_t		fcip_pkt_state;	/* pkt state */
340*fcf3ce44SJohn Forte 	uint32_t		fcip_pkt_reason;	/* pkt reason */
341*fcf3ce44SJohn Forte 	uint32_t		fcip_pkt_flags;	/* pkt flags */
342*fcf3ce44SJohn Forte 	uint32_t		fcip_pkt_dma_flags; /* DMA flags */
343*fcf3ce44SJohn Forte 	fc_packet_t		fcip_pkt_fcpkt;	/* the actual fc packet */
344*fcf3ce44SJohn Forte 	struct fcip_routing_table *fcip_pkt_frp;	/* routing table */
345*fcf3ce44SJohn Forte } fcip_pkt_t;
346*fcf3ce44SJohn Forte 
347*fcf3ce44SJohn Forte /* fcipp_dma_flags */
348*fcf3ce44SJohn Forte #define	FCIP_CMD_DMA_MEM	0x01
349*fcf3ce44SJohn Forte #define	FCIP_CMD_DMA_BOUND	0x02
350*fcf3ce44SJohn Forte #define	FCIP_RESP_DMA_MEM	0x04
351*fcf3ce44SJohn Forte #define	FCIP_RESP_DMA_BOUND	0x08
352*fcf3ce44SJohn Forte 
353*fcf3ce44SJohn Forte /* fcipp_flags */
354*fcf3ce44SJohn Forte #define	FCIP_PKT_INTERNAL	0x01
355*fcf3ce44SJohn Forte #define	FCIP_PKT_IN_TIMEOUT	0x02
356*fcf3ce44SJohn Forte #define	FCIP_PKT_RETURNED	0x04
357*fcf3ce44SJohn Forte #define	FCIP_PKT_IN_LIST	0x08
358*fcf3ce44SJohn Forte #define	FCIP_PKT_IN_ABORT	0x10
359*fcf3ce44SJohn Forte 
360*fcf3ce44SJohn Forte #define	FCIP_PKT_TO_FC_PKT(fcip_pkt)	&(fcip_pkt)->fcip_pkt_fcpkt
361*fcf3ce44SJohn Forte /*
362*fcf3ce44SJohn Forte  * For each remote port we have a active session with (logged in and
363*fcf3ce44SJohn Forte  * having active exchanges) setup a Destination Port structure. Maintain
364*fcf3ce44SJohn Forte  * a Hash list of destination structures in the fcip structure. Before
365*fcf3ce44SJohn Forte  * starting a new session with the destination port, lookup the hash
366*fcf3ce44SJohn Forte  * table to see if we are already having active exchanges with a remote
367*fcf3ce44SJohn Forte  * port and if yes bump the reference count and continue use the same
368*fcf3ce44SJohn Forte  * destination port. Hash on Port WWNs.
369*fcf3ce44SJohn Forte  */
370*fcf3ce44SJohn Forte struct fcip_dest {
371*fcf3ce44SJohn Forte 	struct fcip_dest	*fcipd_next;	/* next element of hashtable */
372*fcf3ce44SJohn Forte 	fcip_pkt_t		*fcipd_head;	/* packet head for this port */
373*fcf3ce44SJohn Forte 	kmutex_t		fcipd_mutex;	/* packet list mutex */
374*fcf3ce44SJohn Forte 	uint32_t		fcipd_refcnt;	/* no.of active sessions */
375*fcf3ce44SJohn Forte 	struct fcip_routing_table *fcipd_rtable;
376*fcf3ce44SJohn Forte 
377*fcf3ce44SJohn Forte #define	fcipd_nwwn	fcipd_rtable->fcipr_nwwn
378*fcf3ce44SJohn Forte #define	fcipd_pwwn	fcipd_rtable->fcipr_pwwn
379*fcf3ce44SJohn Forte #define	fcipd_did	fcipd_rtable->fcipr_d_id
380*fcf3ce44SJohn Forte #define	fcipd_pd	fcipd_rtable->fcipr_pd
381*fcf3ce44SJohn Forte #define	fcipd_state	fcipd_rtable->fcipr_state
382*fcf3ce44SJohn Forte #define	fcipd_fca_dev	fcipd_rtable->fcipr_fca_dev;
383*fcf3ce44SJohn Forte 
384*fcf3ce44SJohn Forte 	uint32_t		fcipd_retries;	/* retries if needed ?? */
385*fcf3ce44SJohn Forte 	uint32_t		fcipd_flags;	/* flags ?? */
386*fcf3ce44SJohn Forte 	ulong_t			fcipd_ncmds;	/* no. of transport cmds */
387*fcf3ce44SJohn Forte };
388*fcf3ce44SJohn Forte 
389*fcf3ce44SJohn Forte 
390*fcf3ce44SJohn Forte #define	FCIP_PORT_OFFLINE	0
391*fcf3ce44SJohn Forte #define	FCIP_PORT_ONLINE	1
392*fcf3ce44SJohn Forte #define	FCIP_PORT_NOTLOGGED	2
393*fcf3ce44SJohn Forte 
394*fcf3ce44SJohn Forte #define	FCIP_INVALID_WWN	-1
395*fcf3ce44SJohn Forte 
396*fcf3ce44SJohn Forte #define	SLFAST			0x01	/* MDATA fastpath mode */
397*fcf3ce44SJohn Forte #define	SLRAW			0x02	/* M_DATA plain raw mode */
398*fcf3ce44SJohn Forte #define	SLALLPHYS		0x04	/* promiscuous mode */
399*fcf3ce44SJohn Forte #define	SLALLMULTI		0x05	/* enable all multicast addr */
400*fcf3ce44SJohn Forte #define	SLALLSAP		0x10	/* enable all ethertype values */
401*fcf3ce44SJohn Forte 
402*fcf3ce44SJohn Forte 
403*fcf3ce44SJohn Forte 
404*fcf3ce44SJohn Forte /*
405*fcf3ce44SJohn Forte  * Private DLPI full dlsap address format.
406*fcf3ce44SJohn Forte  */
407*fcf3ce44SJohn Forte struct	fcipdladdr {
408*fcf3ce44SJohn Forte 	struct	ether_addr	dl_phys;
409*fcf3ce44SJohn Forte 	uint16_t		dl_sap;
410*fcf3ce44SJohn Forte };
411*fcf3ce44SJohn Forte 
412*fcf3ce44SJohn Forte 
413*fcf3ce44SJohn Forte typedef struct llc_snap_hdr {
414*fcf3ce44SJohn Forte 	uchar_t		dsap;
415*fcf3ce44SJohn Forte 	uchar_t		ssap;
416*fcf3ce44SJohn Forte 	uchar_t		ctrl;
417*fcf3ce44SJohn Forte 	uchar_t		oui[3];
418*fcf3ce44SJohn Forte 	ushort_t	pid;
419*fcf3ce44SJohn Forte } llc_snap_hdr_t;
420*fcf3ce44SJohn Forte 
421*fcf3ce44SJohn Forte /*
422*fcf3ce44SJohn Forte  * "Export" a few of the error counters via the kstats mechanism.
423*fcf3ce44SJohn Forte  */
424*fcf3ce44SJohn Forte struct	fcipstat {
425*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_ipackets;
426*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_ierrors;
427*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_opackets;
428*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_oerrors;
429*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_collisions;
430*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_defer;
431*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_fram;
432*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_crc;
433*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_oflo;
434*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_uflo;
435*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_missed;
436*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_tlcol;
437*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_trtry;
438*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_tnocar;
439*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_inits;
440*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_notmds;
441*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_notbufs;
442*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_norbufs;
443*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_nocanput;
444*fcf3ce44SJohn Forte 	struct	kstat_named	fcips_allocbfail;
445*fcf3ce44SJohn Forte 
446*fcf3ce44SJohn Forte 	/*
447*fcf3ce44SJohn Forte 	 * required by kstat for MIB II objects(RFC 1213)
448*fcf3ce44SJohn Forte 	 */
449*fcf3ce44SJohn Forte 	struct  kstat_named	fcips_rcvbytes;	/* # octets received */
450*fcf3ce44SJohn Forte 						/* MIB - ifInOctets */
451*fcf3ce44SJohn Forte 	struct  kstat_named	fcips_xmtbytes; /* # octets xmitted */
452*fcf3ce44SJohn Forte 						/* MIB - ifOutOctets */
453*fcf3ce44SJohn Forte 	struct  kstat_named	fcips_multircv;	/* # multicast packets */
454*fcf3ce44SJohn Forte 						/* delivered to upper layer */
455*fcf3ce44SJohn Forte 						/* MIB - ifInNUcastPkts */
456*fcf3ce44SJohn Forte 	struct  kstat_named	fcips_multixmt;	/* # multicast packets */
457*fcf3ce44SJohn Forte 						/* requested to be sent */
458*fcf3ce44SJohn Forte 						/* MIB - ifOutNUcastPkts */
459*fcf3ce44SJohn Forte 	struct  kstat_named	fcips_brdcstrcv; /* # broadcast packets */
460*fcf3ce44SJohn Forte 						/* delivered to upper layer */
461*fcf3ce44SJohn Forte 						/* MIB - ifInNUcastPkts */
462*fcf3ce44SJohn Forte 	struct  kstat_named	fcips_brdcstxmt; /* # broadcast packets */
463*fcf3ce44SJohn Forte 						/* requested to be sent */
464*fcf3ce44SJohn Forte 						/* MIB - ifOutNUcastPkts */
465*fcf3ce44SJohn Forte 	struct  kstat_named	fcips_norcvbuf;	/* # rcv packets discarded */
466*fcf3ce44SJohn Forte 						/* MIB - ifInDiscards */
467*fcf3ce44SJohn Forte 	struct  kstat_named	fcips_noxmtbuf;	/* # xmt packets discarded */
468*fcf3ce44SJohn Forte 						/* MIB - ifOutDiscards */
469*fcf3ce44SJohn Forte };
470*fcf3ce44SJohn Forte 
471*fcf3ce44SJohn Forte 
472*fcf3ce44SJohn Forte #define	FC_OFF		0x00
473*fcf3ce44SJohn Forte #define	DA_OFF		0x01
474*fcf3ce44SJohn Forte #define	SA_OFF		0x07
475*fcf3ce44SJohn Forte #define	DLSAP_OFF	0x0D
476*fcf3ce44SJohn Forte #define	SLSAP_OFF	0x0E
477*fcf3ce44SJohn Forte #define	ORG_OFF		0x0F
478*fcf3ce44SJohn Forte #define	TYPE_OFF	0x13
479*fcf3ce44SJohn Forte 
480*fcf3ce44SJohn Forte #define	FCIP_IPV4_LEN	0x04;
481*fcf3ce44SJohn Forte 
482*fcf3ce44SJohn Forte #define	FCIP_CP_IN(s, d, handle, len)	(ddi_rep_get8((handle), \
483*fcf3ce44SJohn Forte 					(uint8_t *)(d), (uint8_t *)(s), \
484*fcf3ce44SJohn Forte 					(len), DDI_DEV_AUTOINCR))
485*fcf3ce44SJohn Forte 
486*fcf3ce44SJohn Forte #define	FCIP_CP_OUT(s, d, handle, len)	(ddi_rep_put8((handle), \
487*fcf3ce44SJohn Forte 					(uint8_t *)(s), (uint8_t *)(d), \
488*fcf3ce44SJohn Forte 					(len), DDI_DEV_AUTOINCR))
489*fcf3ce44SJohn Forte 
490*fcf3ce44SJohn Forte #define	LA_ELS_FARP_REQ			0x54
491*fcf3ce44SJohn Forte #define	LA_ELS_FARP_REPLY		0x55
492*fcf3ce44SJohn Forte 
493*fcf3ce44SJohn Forte /* Match address code points */
494*fcf3ce44SJohn Forte #define	FARP_MATCH_RSVD			0x00
495*fcf3ce44SJohn Forte #define	FARP_MATCH_WW_PN		0x01
496*fcf3ce44SJohn Forte #define	FARP_MATCH_WW_NN		0x02
497*fcf3ce44SJohn Forte #define	FARP_MATCH_WW_PN_NN		0x03
498*fcf3ce44SJohn Forte #define	FARP_MATCH_IPv4			0x04
499*fcf3ce44SJohn Forte #define	FARP_MATCH_WW_PN_IPv4		0x05
500*fcf3ce44SJohn Forte #define	FARP_MATCH_WW_NN_IPv4		0x06
501*fcf3ce44SJohn Forte #define	FARP_MATCH_WW_PN_NN_IPv4	0x07
502*fcf3ce44SJohn Forte 
503*fcf3ce44SJohn Forte /* Responder flags */
504*fcf3ce44SJohn Forte #define	FARP_INIT_P_LOGI		0x0
505*fcf3ce44SJohn Forte #define	FARP_INIT_REPLY			0x1
506*fcf3ce44SJohn Forte 
507*fcf3ce44SJohn Forte 
508*fcf3ce44SJohn Forte /*
509*fcf3ce44SJohn Forte  * Structure for FARP ELS request and Response
510*fcf3ce44SJohn Forte  */
511*fcf3ce44SJohn Forte typedef struct la_els_farp {
512*fcf3ce44SJohn Forte 	ls_code_t	ls_code;  /* FARP ELS code - 0x54/0x55 */
513*fcf3ce44SJohn Forte 	uchar_t		match_addr; /* match addr. code points */
514*fcf3ce44SJohn Forte 	fc_portid_t	req_id; /* Requester Port_ID */
515*fcf3ce44SJohn Forte 	uchar_t		resp_flags; /* Responder flags */
516*fcf3ce44SJohn Forte 	fc_portid_t	dest_id; /* Responder Port_ID */
517*fcf3ce44SJohn Forte 	la_wwn_t	req_pwwn; /* Port WWN of Requester */
518*fcf3ce44SJohn Forte 	la_wwn_t	req_nwwn; /* Node WWN of Requester */
519*fcf3ce44SJohn Forte 	la_wwn_t	resp_pwwn; /* Port WWN of Responder */
520*fcf3ce44SJohn Forte 	la_wwn_t	resp_nwwn; /* Node WWN of Responder */
521*fcf3ce44SJohn Forte 	uchar_t		req_ip[16]; /* IP address or Requester */
522*fcf3ce44SJohn Forte 	uchar_t		resp_ip[16]; /* IP address or Responder */
523*fcf3ce44SJohn Forte } la_els_farp_t;
524*fcf3ce44SJohn Forte 
525*fcf3ce44SJohn Forte /*
526*fcf3ce44SJohn Forte  * Linked list of farp responses
527*fcf3ce44SJohn Forte  */
528*fcf3ce44SJohn Forte struct farp_resp_list {
529*fcf3ce44SJohn Forte 	struct farp_resp_list *farpl_next;
530*fcf3ce44SJohn Forte 	struct farp_resp_list *farpl_prev;
531*fcf3ce44SJohn Forte 	la_els_farp_t *farpl_resp;
532*fcf3ce44SJohn Forte };
533*fcf3ce44SJohn Forte 
534*fcf3ce44SJohn Forte /*
535*fcf3ce44SJohn Forte  * FCPH Optional network Header
536*fcf3ce44SJohn Forte  */
537*fcf3ce44SJohn Forte typedef struct network_header {
538*fcf3ce44SJohn Forte 	la_wwn_t	net_dest_addr;
539*fcf3ce44SJohn Forte 	la_wwn_t	net_src_addr;
540*fcf3ce44SJohn Forte } fcph_network_hdr_t;
541*fcf3ce44SJohn Forte 
542*fcf3ce44SJohn Forte /*
543*fcf3ce44SJohn Forte  * InArp request structure
544*fcf3ce44SJohn Forte  */
545*fcf3ce44SJohn Forte typedef struct fcip_inarp {
546*fcf3ce44SJohn Forte 	fcph_network_hdr_t	fcip_inarp_nh;
547*fcf3ce44SJohn Forte 	llc_snap_hdr_t		fcip_inarp_snap;
548*fcf3ce44SJohn Forte 	struct ether_arp	fcip_inarp_data;
549*fcf3ce44SJohn Forte } fcip_inarp_t;
550*fcf3ce44SJohn Forte 
551*fcf3ce44SJohn Forte /*
552*fcf3ce44SJohn Forte  * InArp Response list
553*fcf3ce44SJohn Forte  */
554*fcf3ce44SJohn Forte struct inarp_resp_list {
555*fcf3ce44SJohn Forte 	struct inarp_resp_list *inarpl_next;
556*fcf3ce44SJohn Forte 	struct inarp_resp_list *inarpl_prev;
557*fcf3ce44SJohn Forte 	fcip_inarp_t *inarpl_resp;
558*fcf3ce44SJohn Forte };
559*fcf3ce44SJohn Forte 
560*fcf3ce44SJohn Forte /*
561*fcf3ce44SJohn Forte  * Structure to define args for esballoc frtn function
562*fcf3ce44SJohn Forte  */
563*fcf3ce44SJohn Forte struct fcip_esballoc_arg {
564*fcf3ce44SJohn Forte 	fc_unsol_buf_t	*buf;
565*fcf3ce44SJohn Forte 	opaque_t	phandle;
566*fcf3ce44SJohn Forte 	frtn_t		*frtnp;
567*fcf3ce44SJohn Forte };
568*fcf3ce44SJohn Forte 
569*fcf3ce44SJohn Forte struct fcip_sendup_elem {
570*fcf3ce44SJohn Forte 	struct fcip_sendup_elem *fcipsu_next;
571*fcf3ce44SJohn Forte 	mblk_t			*fcipsu_mp;
572*fcf3ce44SJohn Forte 	struct fcipstr		*(*fcipsu_func)();
573*fcf3ce44SJohn Forte };
574*fcf3ce44SJohn Forte 
575*fcf3ce44SJohn Forte 
576*fcf3ce44SJohn Forte /*
577*fcf3ce44SJohn Forte  * Having TNF probe points can be lethal during reconfiguration boot. Enable
578*fcf3ce44SJohn Forte  * TNF using a compile time define.
579*fcf3ce44SJohn Forte  */
580*fcf3ce44SJohn Forte 
581*fcf3ce44SJohn Forte #ifdef __lint
582*fcf3ce44SJohn Forte #define	FCIP_TNF_ENABLED
583*fcf3ce44SJohn Forte #else
584*fcf3ce44SJohn Forte #undef	FCIP_TNF_ENABLED
585*fcf3ce44SJohn Forte #endif
586*fcf3ce44SJohn Forte 
587*fcf3ce44SJohn Forte #ifdef	FCIP_TNF_ENABLED
588*fcf3ce44SJohn Forte 
589*fcf3ce44SJohn Forte extern int tnf_mod_load(void);
590*fcf3ce44SJohn Forte extern int tnf_mod_unload(struct modlinkage *e);
591*fcf3ce44SJohn Forte 
592*fcf3ce44SJohn Forte #define	FCIP_TNF_LOAD()			(void) tnf_mod_load()
593*fcf3ce44SJohn Forte #define	FCIP_TNF_UNLOAD(x)		(void) tnf_mod_unload(x)
594*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_0(x)		TNF_PROBE_0 x
595*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_1(x)		TNF_PROBE_1 x
596*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_2(x)		TNF_PROBE_2 x
597*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_3(x)		TNF_PROBE_3 x
598*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_4(x)		TNF_PROBE_4 x
599*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_5(x)		TNF_PROBE_5 x
600*fcf3ce44SJohn Forte 
601*fcf3ce44SJohn Forte #else
602*fcf3ce44SJohn Forte 
603*fcf3ce44SJohn Forte #define	FCIP_TNF_LOAD()
604*fcf3ce44SJohn Forte #define	FCIP_TNF_UNLOAD(x)
605*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_0(x)
606*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_1(x)
607*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_2(x)
608*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_3(x)
609*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_4(x)
610*fcf3ce44SJohn Forte #define	FCIP_TNF_PROBE_5(x)
611*fcf3ce44SJohn Forte 
612*fcf3ce44SJohn Forte #endif	/* FCIP_TNF_ENABLED */
613*fcf3ce44SJohn Forte 
614*fcf3ce44SJohn Forte /*
615*fcf3ce44SJohn Forte  * Macros to help with complex TNF output
616*fcf3ce44SJohn Forte  */
617*fcf3ce44SJohn Forte 
618*fcf3ce44SJohn Forte #ifdef FCIP_TNF_ENABLED
619*fcf3ce44SJohn Forte 
620*fcf3ce44SJohn Forte #define	FCIP_TNF_BYTE_ARRAY(name, keys, detail, mesg, barray_name, \
621*fcf3ce44SJohn Forte barray, len) \
622*fcf3ce44SJohn Forte { \
623*fcf3ce44SJohn Forte 	TNF_PROBE_1(name, keys, detail, tnf_string, msg, mesg); \
624*fcf3ce44SJohn Forte 	{ \
625*fcf3ce44SJohn Forte 		int i = 0; \
626*fcf3ce44SJohn Forte 		char str[65] = ""; \
627*fcf3ce44SJohn Forte 		char *strp = str; \
628*fcf3ce44SJohn Forte 		while (i < 32 && i < len) { \
629*fcf3ce44SJohn Forte 			(void) sprintf(strp, "%02x", \
630*fcf3ce44SJohn Forte 				((char *)(barray))[i++] & 0xff); \
631*fcf3ce44SJohn Forte 			strp += 2; \
632*fcf3ce44SJohn Forte 		} \
633*fcf3ce44SJohn Forte 		TNF_PROBE_1(name, keys, "", \
634*fcf3ce44SJohn Forte 			tnf_string, barray_name, str); \
635*fcf3ce44SJohn Forte 	} \
636*fcf3ce44SJohn Forte }
637*fcf3ce44SJohn Forte 
638*fcf3ce44SJohn Forte #else
639*fcf3ce44SJohn Forte 
640*fcf3ce44SJohn Forte #define	FCIP_TNF_BYTE_ARRAY(name, keys, detail, mesg, barray_name, barray, len)
641*fcf3ce44SJohn Forte 
642*fcf3ce44SJohn Forte #endif	/* FCIP_TNF_ENABLED */
643*fcf3ce44SJohn Forte 
644*fcf3ce44SJohn Forte /*
645*fcf3ce44SJohn Forte  * FC4 type setttings for Name Server registration.
646*fcf3ce44SJohn Forte  */
647*fcf3ce44SJohn Forte #define	FC4_TYPE_WORD_POS(x)	((uchar_t)(x) >> 5)
648*fcf3ce44SJohn Forte #define	FC4_TYPE_BIT_POS(x)	((uchar_t)(x) & 0x1F)
649*fcf3ce44SJohn Forte 
650*fcf3ce44SJohn Forte #ifdef	__cplusplus
651*fcf3ce44SJohn Forte }
652*fcf3ce44SJohn Forte #endif
653*fcf3ce44SJohn Forte 
654*fcf3ce44SJohn Forte #endif /* !_SYS_FIBRE_CHANNEL_ULP_FCIP_H */
655