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