1fcf3ce4John Forte/*
2fcf3ce4John Forte * CDDL HEADER START
3fcf3ce4John Forte *
4fcf3ce4John Forte * The contents of this file are subject to the terms of the
5fcf3ce4John Forte * Common Development and Distribution License (the "License").
6fcf3ce4John Forte * You may not use this file except in compliance with the License.
7fcf3ce4John Forte *
88f23e9fHans Rosenfeld * You can obtain a copy of the license at
98f23e9fHans Rosenfeld * http://www.opensource.org/licenses/cddl1.txt.
10fcf3ce4John Forte * See the License for the specific language governing permissions
11fcf3ce4John Forte * and limitations under the License.
12fcf3ce4John Forte *
13fcf3ce4John Forte * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce4John Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce4John Forte * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce4John Forte * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce4John Forte * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce4John Forte *
19fcf3ce4John Forte * CDDL HEADER END
20fcf3ce4John Forte */
21fcf3ce4John Forte
22fcf3ce4John Forte/*
238f23e9fHans Rosenfeld * Copyright (c) 2004-2012 Emulex. All rights reserved.
248252773Sukumar Swaminathan * Use is subject to license terms.
25a317005Paul Winder * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
26a317005Paul Winder * Copyright 2020 RackTop Systems, Inc.
27fcf3ce4John Forte */
28fcf3ce4John Forte
29fcf3ce4John Forte#ifndef _EMLXS_FC_H
30fcf3ce4John Forte#define	_EMLXS_FC_H
31fcf3ce4John Forte
32fcf3ce4John Forte#ifdef	__cplusplus
33fcf3ce4John Forteextern "C" {
34fcf3ce4John Forte#endif
35fcf3ce4John Forte
36291a2b4Sukumar Swaminathantypedef struct emlxs_buf
37291a2b4Sukumar Swaminathan{
38291a2b4Sukumar Swaminathan	fc_packet_t		*pkt;		/* scsi_pkt reference */
39291a2b4Sukumar Swaminathan	struct emlxs_port	*port;		/* pointer to port */
40291a2b4Sukumar Swaminathan	void			*bmp;		/* Save the buffer pointer */
41291a2b4Sukumar Swaminathan						/* list for later use. */
42291a2b4Sukumar Swaminathan	struct emlxs_buf	*fc_fwd;	/* Use it by chip_Q */
43291a2b4Sukumar Swaminathan	struct emlxs_buf	*fc_bkwd;	/* Use it by chip_Q */
44291a2b4Sukumar Swaminathan	struct emlxs_buf	*next;		/* Use it when the iodone */
45a9800beGarrett D'Amore	struct emlxs_node 	*node;
468252773Sukumar Swaminathan	void			*channel;	/* Save channel and used by */
47291a2b4Sukumar Swaminathan						/* abort */
488252773Sukumar Swaminathan	struct emlxs_buf	*fpkt;		/* Flush pkt pointer */
49a9800beGarrett D'Amore	struct XRIobj		*xrip;		/* Exchange resource */
50291a2b4Sukumar Swaminathan	IOCBQ			iocbq;
51291a2b4Sukumar Swaminathan	kmutex_t		mtx;
52291a2b4Sukumar Swaminathan	uint32_t		pkt_flags;
53291a2b4Sukumar Swaminathan	uint32_t		iotag;		/* iotag for this cmd */
54291a2b4Sukumar Swaminathan	uint32_t		ticks;		/* save the timeout ticks */
55291a2b4Sukumar Swaminathan						/* for the fc_packet_t */
56291a2b4Sukumar Swaminathan	uint32_t		abort_attempts;
57a9800beGarrett D'Amore	uint32_t		lun;
58a9800beGarrett D'Amore#define	EMLXS_LUN_NONE		0xFFFFFFFF
59a9800beGarrett D'Amore
60291a2b4Sukumar Swaminathan	uint32_t		class;		/* Save class and used by */
61291a2b4Sukumar Swaminathan						/* abort */
62291a2b4Sukumar Swaminathan	uint32_t		ucmd;		/* Unsolicted command that */
63291a2b4Sukumar Swaminathan						/* this packet is responding */
64291a2b4Sukumar Swaminathan						/* to, if any */
65291a2b4Sukumar Swaminathan	int32_t			flush_count;	/* Valid only in flush pkts */
66291a2b4Sukumar Swaminathan	uint32_t		did;
67fcf3ce4John Forte
68fcf3ce4John Forte#ifdef SFCT_SUPPORT
69291a2b4Sukumar Swaminathan	kmutex_t		fct_mtx;
70291a2b4Sukumar Swaminathan	fc_packet_t		*fct_pkt;
71291a2b4Sukumar Swaminathan	fct_cmd_t		*fct_cmd;
72fcf3ce4John Forte
73291a2b4Sukumar Swaminathan	uint8_t			fct_type;
74fcf3ce4John Forte
75fcf3ce4John Forte#define	EMLXS_FCT_ELS_CMD		0x01	/* Unsolicted */
76fcf3ce4John Forte#define	EMLXS_FCT_ELS_REQ		0x02	/* Solicited */
77fcf3ce4John Forte#define	EMLXS_FCT_ELS_RSP		0x04
78fcf3ce4John Forte#define	EMLXS_FCT_CT_REQ		0x08	/* Solicited */
79fcf3ce4John Forte#define	EMLXS_FCT_FCP_CMD		0x10	/* Unsolicted */
80fcf3ce4John Forte#define	EMLXS_FCT_FCP_DATA		0x20
81fcf3ce4John Forte#define	EMLXS_FCT_FCP_STATUS		0x40
82fcf3ce4John Forte
83fcf3ce4John Forte
84291a2b4Sukumar Swaminathan	uint8_t			fct_flags;
85fcf3ce4John Forte
86fcf3ce4John Forte#define	EMLXS_FCT_SEND_STATUS		0x01
878252773Sukumar Swaminathan#define	EMLXS_FCT_ABORT_INP		0x02
888252773Sukumar Swaminathan#define	EMLXS_FCT_IO_INP		0x04
89a9800beGarrett D'Amore#define	EMLXS_FCT_PLOGI_RECEIVED	0x10
90a9800beGarrett D'Amore#define	EMLXS_FCT_REGISTERED		0x20
91291a2b4Sukumar Swaminathan
92291a2b4Sukumar Swaminathan	uint16_t		fct_state;
93291a2b4Sukumar Swaminathan
94291a2b4Sukumar Swaminathan#define	EMLXS_FCT_FCP_CMD_RECEIVED	1
95291a2b4Sukumar Swaminathan#define	EMLXS_FCT_ELS_CMD_RECEIVED	2
96291a2b4Sukumar Swaminathan#define	EMLXS_FCT_CMD_POSTED		3
97291a2b4Sukumar Swaminathan#define	EMLXS_FCT_CMD_WAITQ		4
988252773Sukumar Swaminathan#define	EMLXS_FCT_SEND_CMD_RSP		5
998252773Sukumar Swaminathan#define	EMLXS_FCT_SEND_ELS_RSP		6
1008252773Sukumar Swaminathan#define	EMLXS_FCT_SEND_ELS_REQ		7
1018252773Sukumar Swaminathan#define	EMLXS_FCT_SEND_CT_REQ		8
1028252773Sukumar Swaminathan#define	EMLXS_FCT_RSP_PENDING		9
1038252773Sukumar Swaminathan#define	EMLXS_FCT_REQ_PENDING		10
1048252773Sukumar Swaminathan#define	EMLXS_FCT_REG_PENDING		11
1058252773Sukumar Swaminathan#define	EMLXS_FCT_REG_COMPLETE		12
1068252773Sukumar Swaminathan#define	EMLXS_FCT_OWNED			13
1078252773Sukumar Swaminathan#define	EMLXS_FCT_SEND_FCP_DATA		14
1088252773Sukumar Swaminathan#define	EMLXS_FCT_SEND_FCP_STATUS	15
1098252773Sukumar Swaminathan#define	EMLXS_FCT_DATA_PENDING		16
1108252773Sukumar Swaminathan#define	EMLXS_FCT_STATUS_PENDING	17
1118252773Sukumar Swaminathan#define	EMLXS_FCT_PKT_COMPLETE		18
1128252773Sukumar Swaminathan#define	EMLXS_FCT_PKT_FCPRSP_COMPLETE	19
1138252773Sukumar Swaminathan#define	EMLXS_FCT_PKT_ELSRSP_COMPLETE	20
1148252773Sukumar Swaminathan#define	EMLXS_FCT_PKT_ELSCMD_COMPLETE	21
1158252773Sukumar Swaminathan#define	EMLXS_FCT_PKT_CTCMD_COMPLETE	22
1168252773Sukumar Swaminathan#define	EMLXS_FCT_REQ_COMPLETE		23
1178252773Sukumar Swaminathan#define	EMLXS_FCT_CLOSE_PENDING		24
1188252773Sukumar Swaminathan#define	EMLXS_FCT_ABORT_PENDING		25
1198252773Sukumar Swaminathan#define	EMLXS_FCT_ABORT_DONE		26
1208252773Sukumar Swaminathan#define	EMLXS_FCT_IO_DONE		27
1218252773Sukumar Swaminathan
1228252773Sukumar Swaminathan#define	EMLXS_FCT_IOCB_ISSUED		256 /* For tracing only */
1238252773Sukumar Swaminathan#define	EMLXS_FCT_IOCB_COMPLETE		257 /* For tracing only */
124291a2b4Sukumar Swaminathan
125291a2b4Sukumar Swaminathan	stmf_data_buf_t		*fct_buf;
126291a2b4Sukumar Swaminathan
127291a2b4Sukumar Swaminathan#endif /* SFCT_SUPPORT */
128291a2b4Sukumar Swaminathan
129291a2b4Sukumar Swaminathan#ifdef SAN_DIAG_SUPPORT
130291a2b4Sukumar Swaminathan	hrtime_t		sd_start_time;
1318f23e9fHans Rosenfeld#endif /* SAN_DIAG_SUPPORT */
1328f23e9fHans Rosenfeld
133291a2b4Sukumar Swaminathan} emlxs_buf_t;
134fcf3ce4John Forte
135fcf3ce4John Forte
136fcf3ce4John Forte
137291a2b4Sukumar Swaminathan#ifdef FCT_IO_TRACE
1388252773Sukumar Swaminathan#define	EMLXS_FCT_STATE_CHG(_fct_cmd, _cmd_sbp, _state)	\
1398252773Sukumar Swaminathan	(_cmd_sbp)->fct_state = _state;			\
1408252773Sukumar Swaminathan	emlxs_fct_io_trace((_cmd_sbp)->port, _fct_cmd, _state)
141291a2b4Sukumar Swaminathan#else
142291a2b4Sukumar Swaminathan/* define to set fct_state */
1438252773Sukumar Swaminathan#define	EMLXS_FCT_STATE_CHG(_fct_cmd, _cmd_sbp, _state)	\
1448252773Sukumar Swaminathan	(_cmd_sbp)->fct_state = _state
145291a2b4Sukumar Swaminathan#endif /* FCT_IO_TRACE */
146fcf3ce4John Forte
147fcf3ce4John Forte
148fcf3ce4John Forte/* pkt_flags */
149fcf3ce4John Forte#define	PACKET_IN_COMPLETION	0x00000001
150fcf3ce4John Forte#define	PACKET_IN_TXQ		0x00000002
151fcf3ce4John Forte#define	PACKET_IN_CHIPQ		0x00000004
152fcf3ce4John Forte#define	PACKET_IN_DONEQ		0x00000008
153fcf3ce4John Forte
154fcf3ce4John Forte#define	PACKET_FCP_RESET	0x00000030
155fcf3ce4John Forte#define	PACKET_FCP_TGT_RESET	0x00000010
156fcf3ce4John Forte#define	PACKET_FCP_LUN_RESET	0x00000020
157fcf3ce4John Forte#define	PACKET_POLLED		0x00000040
158fcf3ce4John Forte
159fcf3ce4John Forte#ifdef EMLXS_I386
160fcf3ce4John Forte#define	PACKET_FCP_SWAPPED	0x00000100
161fcf3ce4John Forte#define	PACKET_ELS_SWAPPED	0x00000200
162fcf3ce4John Forte#define	PACKET_CT_SWAPPED	0x00000400
163fcf3ce4John Forte#define	PACKET_CSP_SWAPPED	0x00000800
164fcf3ce4John Forte#endif	/* EMLXS_I386 */
165fcf3ce4John Forte
166fcf3ce4John Forte#define	PACKET_STALE		0x00001000
167fcf3ce4John Forte
168fcf3ce4John Forte#define	PACKET_IN_TIMEOUT	0x00010000
169fcf3ce4John Forte#define	PACKET_IN_FLUSH		0x00020000
170fcf3ce4John Forte#define	PACKET_IN_ABORT		0x00040000
171e2ca286Sukumar Swaminathan#define	PACKET_XRI_CLOSED	0x00080000 /* An XRI abort/close was issued */
172fcf3ce4John Forte
173fcf3ce4John Forte#define	PACKET_CHIP_COMP	0x00100000
174fcf3ce4John Forte#define	PACKET_COMPLETED	0x00200000
1758252773Sukumar Swaminathan#define	PACKET_ULP_OWNED	0x00400000
176fcf3ce4John Forte
177fcf3ce4John Forte#define	PACKET_STATE_VALID	0x01000000
178fcf3ce4John Forte#define	PACKET_FCP_RSP_VALID	0x02000000
179fcf3ce4John Forte#define	PACKET_ELS_RSP_VALID	0x04000000
180fcf3ce4John Forte#define	PACKET_CT_RSP_VALID	0x08000000
181fcf3ce4John Forte
182fcf3ce4John Forte#define	PACKET_DELAY_REQUIRED	0x10000000
183fcf3ce4John Forte#define	PACKET_ALLOCATED	0x40000000
184fcf3ce4John Forte#define	PACKET_VALID		0x80000000
185fcf3ce4John Forte
186fcf3ce4John Forte
187fcf3ce4John Forte#define	STALE_PACKET		((emlxs_buf_t *)0xFFFFFFFF)
188fcf3ce4John Forte
189fcf3ce4John Forte
190fcf3ce4John Forte/*
191fcf3ce4John Forte * From fc_error.h pkt_reason (except for state = NPORT_RJT, FABRIC_RJT,
192fcf3ce4John Forte * NPORT_BSY, FABRIC_BSY, LS_RJT, BA_RJT, FS_RJT)
193fcf3ce4John Forte *
194fcf3ce4John Forte * FCA unique error codes can begin after FC_REASON_FCA_UNIQUE.
195fcf3ce4John Forte * Each FCA defines its own set with values greater >= 0x7F
196fcf3ce4John Forte */
197fcf3ce4John Forte#define	FC_REASON_FCA_DEFINED   0x100
198fcf3ce4John Forte
199fcf3ce4John Forte
200fcf3ce4John Forte/*
201fcf3ce4John Forte * Device VPD save area
202fcf3ce4John Forte */
203fcf3ce4John Forte
204291a2b4Sukumar Swaminathantypedef struct emlxs_vpd
205291a2b4Sukumar Swaminathan{
206291a2b4Sukumar Swaminathan	uint32_t	biuRev;
207291a2b4Sukumar Swaminathan	uint32_t	smRev;
208291a2b4Sukumar Swaminathan	uint32_t	smFwRev;
209291a2b4Sukumar Swaminathan	uint32_t	endecRev;
210291a2b4Sukumar Swaminathan	uint16_t	rBit;
211291a2b4Sukumar Swaminathan	uint8_t		fcphHigh;
212291a2b4Sukumar Swaminathan	uint8_t		fcphLow;
213291a2b4Sukumar Swaminathan	uint8_t		feaLevelHigh;
214291a2b4Sukumar Swaminathan	uint8_t		feaLevelLow;
215291a2b4Sukumar Swaminathan
216291a2b4Sukumar Swaminathan	uint32_t	postKernRev;
217291a2b4Sukumar Swaminathan	char		postKernName[32];
218291a2b4Sukumar Swaminathan
219291a2b4Sukumar Swaminathan	uint32_t	opFwRev;
220291a2b4Sukumar Swaminathan	char		opFwName[32];
221291a2b4Sukumar Swaminathan	char		opFwLabel[32];
222291a2b4Sukumar Swaminathan
223291a2b4Sukumar Swaminathan	uint32_t	sli1FwRev;
224291a2b4Sukumar Swaminathan	char		sli1FwName[32];
225291a2b4Sukumar Swaminathan	char		sli1FwLabel[32];
226291a2b4Sukumar Swaminathan
227291a2b4Sukumar Swaminathan	uint32_t	sli2FwRev;
228291a2b4Sukumar Swaminathan	char		sli2FwName[32];
229291a2b4Sukumar Swaminathan	char		sli2FwLabel[32];
230291a2b4Sukumar Swaminathan
231291a2b4Sukumar Swaminathan	uint32_t	sli3FwRev;
232291a2b4Sukumar Swaminathan	char		sli3FwName[32];
233291a2b4Sukumar Swaminathan	char		sli3FwLabel[32];
234291a2b4Sukumar Swaminathan
235291a2b4Sukumar Swaminathan	uint32_t	sli4FwRev;
236291a2b4Sukumar Swaminathan	char		sli4FwName[32];
237291a2b4Sukumar Swaminathan	char		sli4FwLabel[32];
238291a2b4Sukumar Swaminathan
239291a2b4Sukumar Swaminathan	char		fw_version[32];
240291a2b4Sukumar Swaminathan	char		fw_label[32];
241291a2b4Sukumar Swaminathan
242291a2b4Sukumar Swaminathan	char		fcode_version[32];
243291a2b4Sukumar Swaminathan	char		boot_version[32];
244291a2b4Sukumar Swaminathan
245291a2b4Sukumar Swaminathan	char		serial_num[32];
246291a2b4Sukumar Swaminathan	char		part_num[32];
247291a2b4Sukumar Swaminathan	char		port_num[20];
248291a2b4Sukumar Swaminathan	char		eng_change[32];
249291a2b4Sukumar Swaminathan	char		manufacturer[80];
250291a2b4Sukumar Swaminathan	char		model[80];
251291a2b4Sukumar Swaminathan	char		model_desc[256];
252291a2b4Sukumar Swaminathan	char		prog_types[256];
2538f23e9fHans Rosenfeld	char		id[256];
254291a2b4Sukumar Swaminathan
255291a2b4Sukumar Swaminathan	uint32_t	port_index;
256a9800beGarrett D'Amore	uint16_t	link_speed;
257fcf3ce4John Forte} emlxs_vpd_t;
258fcf3ce4John Forte
259fcf3ce4John Forte
260291a2b4Sukumar Swaminathantypedef struct emlxs_queue
261291a2b4Sukumar Swaminathan{
262a9800beGarrett D'Amore	void		*q_first;	/* queue first element */
263a9800beGarrett D'Amore	void		*q_last;	/* queue last element */
264291a2b4Sukumar Swaminathan	uint16_t	q_cnt;	/* current length of queue */
265291a2b4Sukumar Swaminathan	uint16_t	q_max;	/* max length queue can get */
266fcf3ce4John Forte} emlxs_queue_t;
267fcf3ce4John Fortetypedef emlxs_queue_t Q;
268fcf3ce4John Forte
269fcf3ce4John Forte
270fcf3ce4John Forte
271fcf3ce4John Forte/*
272fcf3ce4John Forte * This structure is used when allocating a buffer pool.
273fcf3ce4John Forte * Note: this should be identical to gasket buf_info (fldl.h).
274fcf3ce4John Forte */
275291a2b4Sukumar Swaminathantypedef struct emlxs_buf_info
276291a2b4Sukumar Swaminathan{
277291a2b4Sukumar Swaminathan	int32_t		size;	/* Specifies the number of bytes to allocate. */
278291a2b4Sukumar Swaminathan	int32_t		align;	/* The desired address boundary. */
279fcf3ce4John Forte
280291a2b4Sukumar Swaminathan	int32_t		flags;
281fcf3ce4John Forte
282fcf3ce4John Forte#define	FC_MBUF_DMA		0x01	/* blocks are for DMA */
283fcf3ce4John Forte#define	FC_MBUF_PHYSONLY	0x02	/* For malloc - map a given virtual */
284291a2b4Sukumar Swaminathan					/* address to physical address (skip */
285291a2b4Sukumar Swaminathan					/* the malloc). */
286291a2b4Sukumar Swaminathan					/* For free - just unmap the given */
287fcf3ce4John Forte					/* physical address (skip the free). */
288fcf3ce4John Forte#define	FC_MBUF_IOCTL		0x04	/* called from dfc_ioctl */
289fcf3ce4John Forte#define	FC_MBUF_UNLOCK		0x08	/* called with driver unlocked */
290291a2b4Sukumar Swaminathan#define	FC_MBUF_SNGLSG		0x10	/* allocate a single contiguous */
291291a2b4Sukumar Swaminathan					/* physical memory */
292fcf3ce4John Forte
293291a2b4Sukumar Swaminathan	uint64_t	phys;		/* specifies physical buffer pointer */
294291a2b4Sukumar Swaminathan	void		*virt;		/* specifies virtual buffer pointer */
295291a2b4Sukumar Swaminathan	void		*data_handle;
296291a2b4Sukumar Swaminathan	void		*dma_handle;
297fcf3ce4John Forte} emlxs_buf_info_t;
298fcf3ce4John Fortetypedef emlxs_buf_info_t MBUF_INFO;
299fcf3ce4John Forte
300fcf3ce4John Forte
301fcf3ce4John Forte#define	EMLXS_MAX_HBQ   	16	/* Max HBQs handled by firmware */
302fcf3ce4John Forte#define	EMLXS_ELS_HBQ_ID	0
303fcf3ce4John Forte#define	EMLXS_IP_HBQ_ID		1
304fcf3ce4John Forte#define	EMLXS_CT_HBQ_ID		2
305fcf3ce4John Forte#define	EMLXS_FCT_HBQ_ID	3
306fcf3ce4John Forte
307fcf3ce4John Forte#ifdef SFCT_SUPPORT
308fcf3ce4John Forte#define	EMLXS_NUM_HBQ		4	/* Number of HBQs supported by driver */
309fcf3ce4John Forte#else
310fcf3ce4John Forte#define	EMLXS_NUM_HBQ		3	/* Number of HBQs supported by driver */
311291a2b4Sukumar Swaminathan#endif /* SFCT_SUPPORT */
312fcf3ce4John Forte
313fcf3ce4John Forte
3148252773Sukumar Swaminathan/*
3158252773Sukumar Swaminathan * An IO Channel is a object that comprises a xmit/cmpl
3168252773Sukumar Swaminathan * path for IOs.
3178252773Sukumar Swaminathan * For SLI3, an IO path maps to a ring (cmd/rsp)
3188252773Sukumar Swaminathan * For SLI4, an IO path map to a queue pair (WQ/CQ)
3198252773Sukumar Swaminathan */
3208252773Sukumar Swaminathantypedef struct emlxs_channel
3218252773Sukumar Swaminathan{
3228252773Sukumar Swaminathan	struct emlxs_hba *hba;			/* ptr to hba for channel */
3238252773Sukumar Swaminathan	void		*iopath;		/* ptr to SLI3/4 io path */
3248252773Sukumar Swaminathan
3258252773Sukumar Swaminathan	kmutex_t	rsp_lock;
3268252773Sukumar Swaminathan	IOCBQ		*rsp_head;	/* deferred completion head */
3278252773Sukumar Swaminathan	IOCBQ		*rsp_tail;	/* deferred completion tail */
3288252773Sukumar Swaminathan	emlxs_thread_t  intr_thread;
3298252773Sukumar Swaminathan
3308252773Sukumar Swaminathan
3318252773Sukumar Swaminathan	uint16_t	channelno;
3328252773Sukumar Swaminathan	uint16_t	chan_flag;
3338252773Sukumar Swaminathan
3348252773Sukumar Swaminathan#define	EMLXS_NEEDS_TRIGGER 1
3358252773Sukumar Swaminathan
3368252773Sukumar Swaminathan	/* Protected by EMLXS_TX_CHANNEL_LOCK */
3378252773Sukumar Swaminathan	emlxs_queue_t	nodeq;			/* Node service queue */
3388252773Sukumar Swaminathan
3398252773Sukumar Swaminathan	kmutex_t	channel_cmd_lock;
3408252773Sukumar Swaminathan	uint32_t	timeout;
3418252773Sukumar Swaminathan
3428252773Sukumar Swaminathan	/* Channel command counters */
3438252773Sukumar Swaminathan	uint32_t	ulpSendCmd;
3448252773Sukumar Swaminathan	uint32_t	ulpCmplCmd;
3458252773Sukumar Swaminathan	uint32_t	hbaSendCmd;
3468252773Sukumar Swaminathan	uint32_t	hbaCmplCmd;
3478252773Sukumar Swaminathan	uint32_t	hbaSendCmd_sbp;
3488252773Sukumar Swaminathan	uint32_t	hbaCmplCmd_sbp;
3498252773Sukumar Swaminathan
3508252773Sukumar Swaminathan} emlxs_channel_t;
3518252773Sukumar Swaminathantypedef emlxs_channel_t CHANNEL;
3528252773Sukumar Swaminathan
3538252773Sukumar Swaminathan/*
3548252773Sukumar Swaminathan * Should be able to handle max number of io paths for a
3558252773Sukumar Swaminathan * SLI4 HBA (EMLXS_MAX_WQS) or for a SLI3 HBA (MAX_RINGS)
3568252773Sukumar Swaminathan */
3578252773Sukumar Swaminathan#define	MAX_CHANNEL EMLXS_MSI_MAX_INTRS
358fcf3ce4John Forte
359fcf3ce4John Forte
360fcf3ce4John Forte/* Structure used to access adapter rings */
361291a2b4Sukumar Swaminathantypedef struct emlxs_ring
362291a2b4Sukumar Swaminathan{
363291a2b4Sukumar Swaminathan	void		*fc_cmdringaddr;	/* virtual offset for cmd */
364291a2b4Sukumar Swaminathan						/* rings */
365291a2b4Sukumar Swaminathan	void		*fc_rspringaddr;	/* virtual offset for rsp */
366291a2b4Sukumar Swaminathan						/* rings */
367291a2b4Sukumar Swaminathan
368a9800beGarrett D'Amore	void		*fc_mpon;		/* index ptr for match */
369291a2b4Sukumar Swaminathan						/* structure */
370a9800beGarrett D'Amore	void		*fc_mpoff;		/* index ptr for match */
371291a2b4Sukumar Swaminathan						/* structure */
3728252773Sukumar Swaminathan	struct emlxs_hba *hba;			/* ptr to hba for ring */
373291a2b4Sukumar Swaminathan
374291a2b4Sukumar Swaminathan	uint8_t		fc_numCiocb;		/* number of command iocb's */
375291a2b4Sukumar Swaminathan						/* per ring */
376291a2b4Sukumar Swaminathan	uint8_t		fc_numRiocb;		/* number of response iocb's */
377291a2b4Sukumar Swaminathan						/* per ring */
378291a2b4Sukumar Swaminathan	uint8_t		fc_rspidx;		/* current index in response */
379291a2b4Sukumar Swaminathan						/* ring */
380291a2b4Sukumar Swaminathan	uint8_t		fc_cmdidx;		/* current index in command */
381291a2b4Sukumar Swaminathan						/* ring */
382291a2b4Sukumar Swaminathan	uint8_t		fc_port_rspidx;
383291a2b4Sukumar Swaminathan	uint8_t		fc_port_cmdidx;
384291a2b4Sukumar Swaminathan	uint8_t		ringno;
385291a2b4Sukumar Swaminathan
386291a2b4Sukumar Swaminathan	uint16_t	fc_missbufcnt;		/* buf cnt we need to repost */
3878252773Sukumar Swaminathan	CHANNEL		*channelp;
388291a2b4Sukumar Swaminathan
389fcf3ce4John Forte
390fcf3ce4John Forte} emlxs_ring_t;
391fcf3ce4John Fortetypedef emlxs_ring_t RING;
392fcf3ce4John Forte
393fcf3ce4John Forte
394291a2b4Sukumar Swaminathan#ifdef SAN_DIAG_SUPPORT
395291a2b4Sukumar Swaminathan/*
396291a2b4Sukumar Swaminathan * Although right now it's just 1 field, SAN Diag anticipates that this
397291a2b4Sukumar Swaminathan * structure will grow in the future.
398291a2b4Sukumar Swaminathan */
399291a2b4Sukumar Swaminathantypedef struct sd_timestat_level0 {
400291a2b4Sukumar Swaminathan	int		count;
401291a2b4Sukumar Swaminathan} sd_timestat_level0_t;
402291a2b4Sukumar Swaminathan#endif
403291a2b4Sukumar Swaminathan
404291a2b4Sukumar Swaminathantypedef struct emlxs_node
405291a2b4Sukumar Swaminathan{
406291a2b4Sukumar Swaminathan	struct emlxs_node	*nlp_list_next;
407291a2b4Sukumar Swaminathan	struct emlxs_node	*nlp_list_prev;
408fcf3ce4John Forte
409291a2b4Sukumar Swaminathan	NAME_TYPE		nlp_portname;	/* port name */
410291a2b4Sukumar Swaminathan	NAME_TYPE		nlp_nodename;	/* node name */
411fcf3ce4John Forte
412291a2b4Sukumar Swaminathan	uint32_t		nlp_DID;	/* fibre channel D_ID */
413fcf3ce4John Forte
414291a2b4Sukumar Swaminathan	uint16_t		nlp_Rpi;	/* login id returned by */
415291a2b4Sukumar Swaminathan						/* REG_LOGIN */
416291a2b4Sukumar Swaminathan	uint16_t		nlp_Xri;	/* login id returned by */
417291a2b4Sukumar Swaminathan						/* REG_LOGIN */
418fcf3ce4John Forte
419291a2b4Sukumar Swaminathan	uint8_t			nlp_fcp_info;	/* Remote class info */
420fcf3ce4John Forte
421fcf3ce4John Forte	/* nlp_fcp_info */
422fcf3ce4John Forte#define	NLP_FCP_TGT_DEVICE	0x10	/* FCP TGT device */
423fcf3ce4John Forte#define	NLP_FCP_INI_DEVICE	0x20	/* FCP Initiator device */
424fcf3ce4John Forte#define	NLP_FCP_2_DEVICE	0x40	/* FCP-2 TGT device */
425291a2b4Sukumar Swaminathan#define	NLP_EMLX_VPORT		0x80    /* Virtual port */
426fcf3ce4John Forte
4278f23e9fHans Rosenfeld	uint8_t			dfc_state;
4288f23e9fHans Rosenfeld#define	EMLXS_SET_DFC_STATE(_n, _state)	if (_n && _n->nlp_active)\
4298f23e9fHans Rosenfeld		{(_n)->dfc_state = (_state); }
4308f23e9fHans Rosenfeld
4318252773Sukumar Swaminathan	uint32_t		nlp_force_rscn;
432291a2b4Sukumar Swaminathan	uint32_t		nlp_tag;	/* Tag used by port_offline */
433291a2b4Sukumar Swaminathan	uint32_t		flag;
434fcf3ce4John Forte
435291a2b4Sukumar Swaminathan#define	NODE_POOL_ALLOCATED 	0x00000001
436fcf3ce4John Forte
437291a2b4Sukumar Swaminathan	SERV_PARM		sparm;
438fcf3ce4John Forte
4398252773Sukumar Swaminathan	/* Protected by EMLXS_TX_CHANNEL_LOCK */
440291a2b4Sukumar Swaminathan	uint32_t		nlp_active;	/* Node active flag */
441291a2b4Sukumar Swaminathan	uint32_t		nlp_base;
4428252773Sukumar Swaminathan	uint32_t		nlp_flag[MAX_CHANNEL];	/* Node level channel */
443291a2b4Sukumar Swaminathan							/* flags */
444fcf3ce4John Forte
445fcf3ce4John Forte	/* nlp_flag */
446291a2b4Sukumar Swaminathan#define	NLP_CLOSED		0x1
447291a2b4Sukumar Swaminathan#define	NLP_OFFLINE		0x2
448291a2b4Sukumar Swaminathan#define	NLP_RPI_XRI		0x4
449291a2b4Sukumar Swaminathan
4508252773Sukumar Swaminathan	uint32_t		nlp_tics[MAX_CHANNEL];	/* gate timeout */
4518252773Sukumar Swaminathan	emlxs_queue_t		nlp_tx[MAX_CHANNEL];	/* Transmit Q head */
4528252773Sukumar Swaminathan	emlxs_queue_t		nlp_ptx[MAX_CHANNEL];	/* Priority transmit */
453291a2b4Sukumar Swaminathan							/* Queue head */
4548252773Sukumar Swaminathan	void			*nlp_next[MAX_CHANNEL];	/* Service Request */
455291a2b4Sukumar Swaminathan							/* Queue pointer used */
456291a2b4Sukumar Swaminathan							/* when node needs */
457291a2b4Sukumar Swaminathan							/* servicing */
458fcf3ce4John Forte#ifdef DHCHAP_SUPPORT
459291a2b4Sukumar Swaminathan	emlxs_node_dhc_t	node_dhc;
460fcf3ce4John Forte#endif	/* DHCHAP_SUPPORT */
461fcf3ce4John Forte
462291a2b4Sukumar Swaminathan#ifdef SAN_DIAG_SUPPORT
463291a2b4Sukumar Swaminathan	sd_timestat_level0_t	sd_dev_bucket[SD_IO_LATENCY_MAX_BUCKETS];
464291a2b4Sukumar Swaminathan#endif
4658252773Sukumar Swaminathan
466a9800beGarrett D'Amore	struct RPIobj		*rpip;	/* SLI4 only */
467a9800beGarrett D'Amore#define	EMLXS_NODE_TO_RPI(_p, _n)	\
468a9800beGarrett D'Amore	((_n)?((_n->rpip)?_n->rpip:emlxs_rpi_find(_p, _n->nlp_Rpi)):NULL)
4698252773Sukumar Swaminathan
4708f23e9fHans Rosenfeld#ifdef NODE_THROTTLE_SUPPORT
4718f23e9fHans Rosenfeld	uint32_t io_throttle;
4728f23e9fHans Rosenfeld	uint32_t io_active;
4738f23e9fHans Rosenfeld#endif /* NODE_THROTTLE_SUPPORT */
4748f23e9fHans Rosenfeld
475fcf3ce4John Forte} emlxs_node_t;
476fcf3ce4John Fortetypedef emlxs_node_t NODELIST;
477fcf3ce4John Forte
478fcf3ce4John Forte
479fcf3ce4John Forte
480fcf3ce4John Forte#define	NADDR_LEN	6	/* MAC network address length */
481291a2b4Sukumar Swaminathantypedef struct emlxs_fcip_nethdr
482291a2b4Sukumar Swaminathan{
483291a2b4Sukumar Swaminathan	NAME_TYPE	fc_destname;	/* destination port name */
484291a2b4Sukumar Swaminathan	NAME_TYPE	fc_srcname;	/* source port name */
485fcf3ce4John Forte} emlxs_fcip_nethdr_t;
486fcf3ce4John Fortetypedef emlxs_fcip_nethdr_t NETHDR;
487fcf3ce4John Forte
488fcf3ce4John Forte
489fcf3ce4John Forte#define	MEM_NLP		0	/* memory segment to hold node list entries */
490fcf3ce4John Forte#define	MEM_IOCB	1	/* memory segment to hold iocb commands */
491291a2b4Sukumar Swaminathan#define	MEM_MBOX	2	/* memory segment to hold mailbox cmds  */
492291a2b4Sukumar Swaminathan#define	MEM_BPL		3	/* and to hold buffer ptr lists - SLI2   */
493291a2b4Sukumar Swaminathan#define	MEM_BUF		4	/* memory segment to hold buffer data   */
494291a2b4Sukumar Swaminathan#define	MEM_ELSBUF	4	/* memory segment to hold buffer data   */
495fcf3ce4John Forte#define	MEM_IPBUF	5	/* memory segment to hold IP buffer data */
496fcf3ce4John Forte#define	MEM_CTBUF	6	/* memory segment to hold CT buffer data */
497fcf3ce4John Forte#define	MEM_FCTBUF	7	/* memory segment to hold FCT buffer data */
498a317005Paul Winder#define MEM_SGL1K	8	/* memory segment to hold 1K SGL entries */
499a317005Paul Winder#define MEM_SGL2K	9	/* memory segment to hold 2K SGL entries */
500a317005Paul Winder#define MEM_SGL4K	10	/* memory segment to hold 4K SGL entries */
501fcf3ce4John Forte
502fcf3ce4John Forte#ifdef SFCT_SUPPORT
503a317005Paul Winder#define	FC_MAX_SEG	11
504a317005Paul Winder#define	MEM_FCTSEG	13 /* must be greater than FC_MAX_SEG */
505fcf3ce4John Forte#else
506a317005Paul Winder#define	FC_MAX_SEG	10
507291a2b4Sukumar Swaminathan#endif /* SFCT_SUPPORT */
508fcf3ce4John Forte
509fcf3ce4John Forte
510fcf3ce4John Forte/* A BPL entry is 12 bytes. Subtract 2 for command and response buffers */
5118f23e9fHans Rosenfeld#define	BPL_TO_SGLLEN(_bpl)	((_bpl/12)-2)
5128f23e9fHans Rosenfeld#define	MEM_BPL_SIZE		36 /* Default size */
513fcf3ce4John Forte
5148252773Sukumar Swaminathan/* A SGL entry is 16 bytes. Subtract 2 for command and response buffers */
5158f23e9fHans Rosenfeld#define	SGL_TO_SGLLEN(_sgl)	((_sgl/16)-2)
5168f23e9fHans Rosenfeld#define	MEM_SGL_SIZE		4096 /* Default size */
517fcf3ce4John Forte
518fcf3ce4John Forte#define	MEM_BUF_SIZE		1024
519fcf3ce4John Forte#define	MEM_BUF_COUNT		64
520fcf3ce4John Forte
521291a2b4Sukumar Swaminathan#define	MEM_ELSBUF_SIZE   	MEM_BUF_SIZE
522291a2b4Sukumar Swaminathan#define	MEM_ELSBUF_COUNT  	hba->max_nodes
523291a2b4Sukumar Swaminathan#define	MEM_IPBUF_SIZE  	65535
524fcf3ce4John Forte#define	MEM_IPBUF_COUNT		60
525fcf3ce4John Forte#define	MEM_CTBUF_SIZE		MAX_CT_PAYLOAD	/* (1024*320) */
526fcf3ce4John Forte#define	MEM_CTBUF_COUNT		8
527291a2b4Sukumar Swaminathan#define	MEM_FCTBUF_SIZE  	65535
528fcf3ce4John Forte#define	MEM_FCTBUF_COUNT	128
529fcf3ce4John Forte
530291a2b4Sukumar Swaminathantypedef struct emlxs_memseg
531291a2b4Sukumar Swaminathan{
532a9800beGarrett D'Amore	void			*fc_memget_ptr;
533a9800beGarrett D'Amore	void			*fc_memget_end;
534a9800beGarrett D'Amore	void			*fc_memput_ptr;
535a9800beGarrett D'Amore	void			*fc_memput_end;
536291a2b4Sukumar Swaminathan
537291a2b4Sukumar Swaminathan	uint32_t		fc_total_memsize;
538291a2b4Sukumar Swaminathan	uint32_t		fc_memsize;		/* size of mem blks */
539291a2b4Sukumar Swaminathan	uint32_t		fc_numblks;		/* no of mem blks */
540291a2b4Sukumar Swaminathan	uint32_t		fc_memget_cnt;		/* no of mem get blks */
541291a2b4Sukumar Swaminathan	uint32_t		fc_memput_cnt;		/* no of mem put blks */
5428252773Sukumar Swaminathan	uint32_t		fc_memflag;  /* emlxs_buf_info_t FLAGS */
5438f23e9fHans Rosenfeld#define	FC_MEMSEG_PUT_ENABLED	0x20000000
5448f23e9fHans Rosenfeld#define	FC_MEMSEG_GET_ENABLED	0x40000000
5458f23e9fHans Rosenfeld#define	FC_MEMSEG_DYNAMIC	0x80000000
5468f23e9fHans Rosenfeld
5478252773Sukumar Swaminathan	uint32_t		fc_memalign;
5488252773Sukumar Swaminathan	uint32_t		fc_memtag;
5498252773Sukumar Swaminathan	char			fc_label[32];
5508252773Sukumar Swaminathan
5518f23e9fHans Rosenfeld	uint32_t		fc_hi_water;
5528f23e9fHans Rosenfeld	uint32_t		fc_lo_water;
5538f23e9fHans Rosenfeld	uint32_t		fc_step;  /* Dyn increment.  Zero = static */
5548f23e9fHans Rosenfeld	uint32_t		fc_low;   /* Lowest free count (dyn only) */
5558f23e9fHans Rosenfeld	uint32_t		fc_last;  /* Last fc_numblks (dyn only) */
5568f23e9fHans Rosenfeld
557fcf3ce4John Forte} emlxs_memseg_t;
558fcf3ce4John Fortetypedef emlxs_memseg_t MEMSEG;
559fcf3ce4John Forte
560fcf3ce4John Forte
561fcf3ce4John Forte/* Board stat counters */
562291a2b4Sukumar Swaminathantypedef struct emlxs_stats
563291a2b4Sukumar Swaminathan{
564291a2b4Sukumar Swaminathan	uint32_t	LinkUp;
565291a2b4Sukumar Swaminathan	uint32_t	LinkDown;
566291a2b4Sukumar Swaminathan	uint32_t	LinkEvent;
567291a2b4Sukumar Swaminathan	uint32_t	LinkMultiEvent;
568291a2b4Sukumar Swaminathan
569291a2b4Sukumar Swaminathan	uint32_t	MboxIssued;
570291a2b4Sukumar Swaminathan	uint32_t	MboxCompleted;	/* MboxError + MbxGood */
571291a2b4Sukumar Swaminathan	uint32_t	MboxGood;
572291a2b4Sukumar Swaminathan	uint32_t	MboxError;
573291a2b4Sukumar Swaminathan	uint32_t	MboxBusy;
574291a2b4Sukumar Swaminathan	uint32_t	MboxInvalid;
575291a2b4Sukumar Swaminathan
5768252773Sukumar Swaminathan	uint32_t	IocbIssued[MAX_CHANNEL];
5778252773Sukumar Swaminathan	uint32_t	IocbReceived[MAX_CHANNEL];
5788252773Sukumar Swaminathan	uint32_t	IocbTxPut[MAX_CHANNEL];
5798252773Sukumar Swaminathan	uint32_t	IocbTxGet[MAX_CHANNEL];
5808252773Sukumar Swaminathan	uint32_t	IocbRingFull[MAX_CHANNEL];
581291a2b4Sukumar Swaminathan	uint32_t	IocbThrottled;
582291a2b4Sukumar Swaminathan
583291a2b4Sukumar Swaminathan	uint32_t	IntrEvent[8];
584291a2b4Sukumar Swaminathan
585291a2b4Sukumar Swaminathan	uint32_t	FcpIssued;
586291a2b4Sukumar Swaminathan	uint32_t	FcpCompleted;	/* FcpGood + FcpError */
587291a2b4Sukumar Swaminathan	uint32_t	FcpGood;
588291a2b4Sukumar Swaminathan	uint32_t	FcpError;
589291a2b4Sukumar Swaminathan
590291a2b4Sukumar Swaminathan	uint32_t	FcpEvent;	/* FcpStray + FcpCompleted */
591291a2b4Sukumar Swaminathan	uint32_t	FcpStray;
592fcf3ce4John Forte#ifdef SFCT_SUPPORT
593291a2b4Sukumar Swaminathan	uint32_t	FctRingEvent;
594291a2b4Sukumar Swaminathan	uint32_t	FctRingError;
595291a2b4Sukumar Swaminathan	uint32_t	FctRingDropped;
596291a2b4Sukumar Swaminathan#endif /* SFCT_SUPPORT */
597291a2b4Sukumar Swaminathan
598291a2b4Sukumar Swaminathan	uint32_t	ElsEvent;	/* ElsStray + ElsCmplt (cmd + rsp) */
599291a2b4Sukumar Swaminathan	uint32_t	ElsStray;
600291a2b4Sukumar Swaminathan
601291a2b4Sukumar Swaminathan	uint32_t	ElsCmdIssued;
602291a2b4Sukumar Swaminathan	uint32_t	ElsCmdCompleted;	/* ElsCmdGood + ElsCmdError */
603291a2b4Sukumar Swaminathan	uint32_t	ElsCmdGood;
604291a2b4Sukumar Swaminathan	uint32_t	ElsCmdError;
605291a2b4Sukumar Swaminathan
606291a2b4Sukumar Swaminathan	uint32_t	ElsRspIssued;
607291a2b4Sukumar Swaminathan	uint32_t	ElsRspCompleted;
608291a2b4Sukumar Swaminathan
609291a2b4Sukumar Swaminathan	uint32_t	ElsRcvEvent;	/* ElsRcvErr + ElsRcvDrop + ElsCmdRcv */
610291a2b4Sukumar Swaminathan	uint32_t	ElsRcvError;
611291a2b4Sukumar Swaminathan	uint32_t	ElsRcvDropped;
612291a2b4Sukumar Swaminathan	uint32_t	ElsCmdReceived;	/* ElsRscnRcv + ElsPlogiRcv + ... */