xref: /freebsd/sys/dev/qlxge/qls_def.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1718cf2ccSPedro F. Giffuni /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
4711bcba0SDavid C Somayajulu  * Copyright (c) 2013-2014 Qlogic Corporation
5711bcba0SDavid C Somayajulu  * All rights reserved.
6711bcba0SDavid C Somayajulu  *
7711bcba0SDavid C Somayajulu  *  Redistribution and use in source and binary forms, with or without
8711bcba0SDavid C Somayajulu  *  modification, are permitted provided that the following conditions
9711bcba0SDavid C Somayajulu  *  are met:
10711bcba0SDavid C Somayajulu  *
11711bcba0SDavid C Somayajulu  *  1. Redistributions of source code must retain the above copyright
12711bcba0SDavid C Somayajulu  *     notice, this list of conditions and the following disclaimer.
13711bcba0SDavid C Somayajulu  *  2. Redistributions in binary form must reproduce the above copyright
14711bcba0SDavid C Somayajulu  *     notice, this list of conditions and the following disclaimer in the
15711bcba0SDavid C Somayajulu  *     documentation and/or other materials provided with the distribution.
16711bcba0SDavid C Somayajulu  *
17711bcba0SDavid C Somayajulu  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18711bcba0SDavid C Somayajulu  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19711bcba0SDavid C Somayajulu  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20711bcba0SDavid C Somayajulu  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21711bcba0SDavid C Somayajulu  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22711bcba0SDavid C Somayajulu  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23711bcba0SDavid C Somayajulu  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24711bcba0SDavid C Somayajulu  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25711bcba0SDavid C Somayajulu  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26711bcba0SDavid C Somayajulu  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27711bcba0SDavid C Somayajulu  *  POSSIBILITY OF SUCH DAMAGE.
28711bcba0SDavid C Somayajulu  */
29711bcba0SDavid C Somayajulu 
30711bcba0SDavid C Somayajulu /*
31711bcba0SDavid C Somayajulu  * File: qls_def.h
32711bcba0SDavid C Somayajulu  * Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656.
33711bcba0SDavid C Somayajulu  */
34711bcba0SDavid C Somayajulu 
35711bcba0SDavid C Somayajulu #ifndef _QLS_DEF_H_
36711bcba0SDavid C Somayajulu #define _QLS_DEF_H_
37711bcba0SDavid C Somayajulu 
38711bcba0SDavid C Somayajulu /*
39711bcba0SDavid C Somayajulu  * structure encapsulating a DMA buffer
40711bcba0SDavid C Somayajulu  */
41711bcba0SDavid C Somayajulu struct qla_dma {
42711bcba0SDavid C Somayajulu         bus_size_t              alignment;
43711bcba0SDavid C Somayajulu         uint32_t                size;
44711bcba0SDavid C Somayajulu         void                    *dma_b;
45711bcba0SDavid C Somayajulu         bus_addr_t              dma_addr;
46711bcba0SDavid C Somayajulu         bus_dmamap_t            dma_map;
47711bcba0SDavid C Somayajulu         bus_dma_tag_t           dma_tag;
48711bcba0SDavid C Somayajulu };
49711bcba0SDavid C Somayajulu typedef struct qla_dma qla_dma_t;
50711bcba0SDavid C Somayajulu 
51711bcba0SDavid C Somayajulu /*
52711bcba0SDavid C Somayajulu  * structure encapsulating interrupt vectors
53711bcba0SDavid C Somayajulu  */
54711bcba0SDavid C Somayajulu struct qla_ivec {
55711bcba0SDavid C Somayajulu 	uint32_t		cq_idx;
56711bcba0SDavid C Somayajulu 	void			*ha;
57711bcba0SDavid C Somayajulu 	struct resource		*irq;
58711bcba0SDavid C Somayajulu 	void			*handle;
59711bcba0SDavid C Somayajulu 	int			irq_rid;
60711bcba0SDavid C Somayajulu };
61711bcba0SDavid C Somayajulu typedef struct qla_ivec qla_ivec_t;
62711bcba0SDavid C Somayajulu 
63711bcba0SDavid C Somayajulu /*
64711bcba0SDavid C Somayajulu  * Transmit Related Definitions
65711bcba0SDavid C Somayajulu  */
66711bcba0SDavid C Somayajulu 
67711bcba0SDavid C Somayajulu #define MAX_TX_RINGS		1
68711bcba0SDavid C Somayajulu #define NUM_TX_DESCRIPTORS	1024
69711bcba0SDavid C Somayajulu 
70711bcba0SDavid C Somayajulu #define QLA_MAX_SEGMENTS	64	/* maximum # of segs in a sg list */
71711bcba0SDavid C Somayajulu #define QLA_OAL_BLK_SIZE	(sizeof (q81_txb_desc_t) * QLA_MAX_SEGMENTS)
72711bcba0SDavid C Somayajulu 
73711bcba0SDavid C Somayajulu #define QLA_TX_OALB_TOTAL_SIZE	(NUM_TX_DESCRIPTORS * QLA_OAL_BLK_SIZE)
74711bcba0SDavid C Somayajulu 
75711bcba0SDavid C Somayajulu #define QLA_TX_PRIVATE_BSIZE	((QLA_TX_OALB_TOTAL_SIZE + \
76711bcba0SDavid C Somayajulu 					PAGE_SIZE + \
77711bcba0SDavid C Somayajulu 					(PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1))
78711bcba0SDavid C Somayajulu 
79711bcba0SDavid C Somayajulu #define QLA_MAX_MTU		9000
80711bcba0SDavid C Somayajulu #define QLA_STD_FRAME_SIZE	1514
81711bcba0SDavid C Somayajulu #define QLA_MAX_TSO_FRAME_SIZE	((64 * 1024 - 1) + 22)
82711bcba0SDavid C Somayajulu 
83711bcba0SDavid C Somayajulu #define QL_FRAME_HDR_SIZE	(ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN +\
84711bcba0SDavid C Somayajulu                 sizeof (struct ip6_hdr) + sizeof (struct tcphdr) + 16)
85711bcba0SDavid C Somayajulu 
86711bcba0SDavid C Somayajulu struct qla_tx_buf {
87711bcba0SDavid C Somayajulu 	struct mbuf	*m_head;
88711bcba0SDavid C Somayajulu 	bus_dmamap_t	map;
89711bcba0SDavid C Somayajulu 
90711bcba0SDavid C Somayajulu 	/* The number of entries in the OAL is determined by QLA_MAX_SEGMENTS */
91711bcba0SDavid C Somayajulu 	bus_addr_t      oal_paddr;
92711bcba0SDavid C Somayajulu 	void		*oal_vaddr;
93711bcba0SDavid C Somayajulu };
94711bcba0SDavid C Somayajulu typedef struct qla_tx_buf qla_tx_buf_t;
95711bcba0SDavid C Somayajulu 
96711bcba0SDavid C Somayajulu struct qla_tx_ring {
97711bcba0SDavid C Somayajulu 	volatile struct {
98711bcba0SDavid C Somayajulu 		uint32_t	wq_dma:1,
99711bcba0SDavid C Somayajulu 				privb_dma:1;
100711bcba0SDavid C Somayajulu 	} flags;
101711bcba0SDavid C Somayajulu 
102711bcba0SDavid C Somayajulu 	qla_dma_t		privb_dma;
103711bcba0SDavid C Somayajulu 	qla_dma_t		wq_dma;
104711bcba0SDavid C Somayajulu 
105711bcba0SDavid C Somayajulu 	qla_tx_buf_t		tx_buf[NUM_TX_DESCRIPTORS];
106711bcba0SDavid C Somayajulu 	uint64_t		count;
107711bcba0SDavid C Somayajulu 
108711bcba0SDavid C Somayajulu 	struct resource         *wq_db_addr;
109711bcba0SDavid C Somayajulu 	uint32_t		wq_db_offset;
110711bcba0SDavid C Somayajulu 
111711bcba0SDavid C Somayajulu 	q81_tx_cmd_t		*wq_vaddr;
112711bcba0SDavid C Somayajulu 	bus_addr_t		wq_paddr;
113711bcba0SDavid C Somayajulu 
114711bcba0SDavid C Somayajulu 	void			*wq_icb_vaddr;
115711bcba0SDavid C Somayajulu 	bus_addr_t		wq_icb_paddr;
116711bcba0SDavid C Somayajulu 
117711bcba0SDavid C Somayajulu 	uint32_t		*txr_cons_vaddr;
118711bcba0SDavid C Somayajulu 	bus_addr_t		txr_cons_paddr;
119711bcba0SDavid C Somayajulu 
120711bcba0SDavid C Somayajulu 	volatile uint32_t	txr_free; /* # of free entries in tx ring */
121711bcba0SDavid C Somayajulu 	volatile uint32_t	txr_next; /* # next available tx ring entry */
122711bcba0SDavid C Somayajulu 	volatile uint32_t	txr_done;
123711bcba0SDavid C Somayajulu 
124711bcba0SDavid C Somayajulu 	uint64_t		tx_frames;
125711bcba0SDavid C Somayajulu 	uint64_t		tx_tso_frames;
126711bcba0SDavid C Somayajulu 	uint64_t		tx_vlan_frames;
127711bcba0SDavid C Somayajulu };
128711bcba0SDavid C Somayajulu typedef struct qla_tx_ring qla_tx_ring_t;
129711bcba0SDavid C Somayajulu 
130711bcba0SDavid C Somayajulu /*
131711bcba0SDavid C Somayajulu  * Receive Related Definitions
132711bcba0SDavid C Somayajulu  */
133711bcba0SDavid C Somayajulu 
134711bcba0SDavid C Somayajulu #define MAX_RX_RINGS		MAX_TX_RINGS
135711bcba0SDavid C Somayajulu 
136711bcba0SDavid C Somayajulu #define NUM_RX_DESCRIPTORS	1024
137711bcba0SDavid C Somayajulu #define NUM_CQ_ENTRIES		NUM_RX_DESCRIPTORS
138711bcba0SDavid C Somayajulu 
139711bcba0SDavid C Somayajulu #define QLA_LGB_SIZE		(12 * 1024)
140711bcba0SDavid C Somayajulu #define QLA_NUM_LGB_ENTRIES	32
141711bcba0SDavid C Somayajulu 
142711bcba0SDavid C Somayajulu #define QLA_LBQ_SIZE		(QLA_NUM_LGB_ENTRIES * sizeof(q81_bq_addr_e_t))
143711bcba0SDavid C Somayajulu 
144711bcba0SDavid C Somayajulu #define QLA_LGBQ_AND_TABLE_SIZE	\
145711bcba0SDavid C Somayajulu 	((QLA_LBQ_SIZE + PAGE_SIZE + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1))
146711bcba0SDavid C Somayajulu 
147711bcba0SDavid C Somayajulu /* Please note that Small Buffer size is determined by max mtu size */
148711bcba0SDavid C Somayajulu #define QLA_NUM_SMB_ENTRIES	NUM_RX_DESCRIPTORS
149711bcba0SDavid C Somayajulu 
150711bcba0SDavid C Somayajulu #define QLA_SBQ_SIZE		(QLA_NUM_SMB_ENTRIES * sizeof(q81_bq_addr_e_t))
151711bcba0SDavid C Somayajulu 
152711bcba0SDavid C Somayajulu #define QLA_SMBQ_AND_TABLE_SIZE	\
153711bcba0SDavid C Somayajulu 	((QLA_SBQ_SIZE + PAGE_SIZE + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1))
154711bcba0SDavid C Somayajulu 
155711bcba0SDavid C Somayajulu struct qla_rx_buf {
156711bcba0SDavid C Somayajulu 	struct mbuf	*m_head;
157711bcba0SDavid C Somayajulu 	bus_dmamap_t	map;
158711bcba0SDavid C Somayajulu 	bus_addr_t      paddr;
159711bcba0SDavid C Somayajulu 	void		*next;
160711bcba0SDavid C Somayajulu };
161711bcba0SDavid C Somayajulu typedef struct qla_rx_buf qla_rx_buf_t;
162711bcba0SDavid C Somayajulu 
163711bcba0SDavid C Somayajulu struct qla_rx_ring {
164711bcba0SDavid C Somayajulu 	volatile struct {
165711bcba0SDavid C Somayajulu 		uint32_t	cq_dma:1,
166711bcba0SDavid C Somayajulu 				lbq_dma:1,
167711bcba0SDavid C Somayajulu 				sbq_dma:1,
168711bcba0SDavid C Somayajulu 				lb_dma:1;
169711bcba0SDavid C Somayajulu 	} flags;
170711bcba0SDavid C Somayajulu 
171711bcba0SDavid C Somayajulu 	qla_dma_t		cq_dma;
172711bcba0SDavid C Somayajulu 	qla_dma_t		lbq_dma;
173711bcba0SDavid C Somayajulu 	qla_dma_t		sbq_dma;
174711bcba0SDavid C Somayajulu 	qla_dma_t		lb_dma;
175711bcba0SDavid C Somayajulu 
176711bcba0SDavid C Somayajulu 	struct lro_ctrl		lro;
177711bcba0SDavid C Somayajulu 
178711bcba0SDavid C Somayajulu 	qla_rx_buf_t		rx_buf[NUM_RX_DESCRIPTORS];
179711bcba0SDavid C Somayajulu 	qla_rx_buf_t		*rxb_free;
180711bcba0SDavid C Somayajulu 	uint32_t		rx_free;
181711bcba0SDavid C Somayajulu 	uint32_t		rx_next;
182711bcba0SDavid C Somayajulu 
183711bcba0SDavid C Somayajulu 	uint32_t		cq_db_offset;
184711bcba0SDavid C Somayajulu 
185711bcba0SDavid C Somayajulu 	void			*cq_icb_vaddr;
186711bcba0SDavid C Somayajulu 	bus_addr_t		cq_icb_paddr;
187711bcba0SDavid C Somayajulu 
188711bcba0SDavid C Somayajulu 	uint32_t		*cqi_vaddr;
189711bcba0SDavid C Somayajulu 	bus_addr_t		cqi_paddr;
190711bcba0SDavid C Somayajulu 
191711bcba0SDavid C Somayajulu 	void			*cq_base_vaddr;
192711bcba0SDavid C Somayajulu 	bus_addr_t		cq_base_paddr;
193711bcba0SDavid C Somayajulu 	uint32_t		cq_next; /* next cq entry to process */
194711bcba0SDavid C Somayajulu 
195711bcba0SDavid C Somayajulu 	void			*lbq_addr_tbl_vaddr;
196711bcba0SDavid C Somayajulu 	bus_addr_t		lbq_addr_tbl_paddr;
197711bcba0SDavid C Somayajulu 
198711bcba0SDavid C Somayajulu 	void			*lbq_vaddr;
199711bcba0SDavid C Somayajulu 	bus_addr_t		lbq_paddr;
200711bcba0SDavid C Somayajulu 	uint32_t		lbq_next; /* next entry in LBQ to process */
201711bcba0SDavid C Somayajulu 	uint32_t		lbq_free;/* # of entries in LBQ to arm */
202711bcba0SDavid C Somayajulu 	uint32_t		lbq_in; /* next entry in LBQ to arm */
203711bcba0SDavid C Somayajulu 
204711bcba0SDavid C Somayajulu 	void			*lb_vaddr;
205711bcba0SDavid C Somayajulu 	bus_addr_t		lb_paddr;
206711bcba0SDavid C Somayajulu 
207711bcba0SDavid C Somayajulu 	void			*sbq_addr_tbl_vaddr;
208711bcba0SDavid C Somayajulu 	bus_addr_t		sbq_addr_tbl_paddr;
209711bcba0SDavid C Somayajulu 
210711bcba0SDavid C Somayajulu 	void			*sbq_vaddr;
211711bcba0SDavid C Somayajulu 	bus_addr_t		sbq_paddr;
212711bcba0SDavid C Somayajulu 	uint32_t		sbq_next; /* next entry in SBQ to process */
213711bcba0SDavid C Somayajulu 	uint32_t		sbq_free;/* # of entries in SBQ to arm */
214711bcba0SDavid C Somayajulu 	uint32_t		sbq_in; /* next entry in SBQ to arm */
215711bcba0SDavid C Somayajulu 
216711bcba0SDavid C Somayajulu 	uint64_t		rx_int;
217711bcba0SDavid C Somayajulu 	uint64_t		rss_int;
218711bcba0SDavid C Somayajulu };
219711bcba0SDavid C Somayajulu typedef struct qla_rx_ring qla_rx_ring_t;
220711bcba0SDavid C Somayajulu 
221711bcba0SDavid C Somayajulu #define QLA_WATCHDOG_CALLOUT_TICKS	1
222711bcba0SDavid C Somayajulu 
223711bcba0SDavid C Somayajulu /*
224711bcba0SDavid C Somayajulu  * Multicast Definitions
225711bcba0SDavid C Somayajulu  */
226711bcba0SDavid C Somayajulu typedef struct _qla_mcast {
227711bcba0SDavid C Somayajulu 	uint16_t	rsrvd;
228711bcba0SDavid C Somayajulu 	uint8_t		addr[6];
229711bcba0SDavid C Somayajulu } __packed qla_mcast_t;
230711bcba0SDavid C Somayajulu 
231711bcba0SDavid C Somayajulu /*
232711bcba0SDavid C Somayajulu  * Misc. definitions
233711bcba0SDavid C Somayajulu  */
234711bcba0SDavid C Somayajulu #define QLA_PAGE_SIZE		4096
235711bcba0SDavid C Somayajulu 
236711bcba0SDavid C Somayajulu /*
237453130d9SPedro F. Giffuni  * Adapter structure contains the hardware independent information of the
238711bcba0SDavid C Somayajulu  * pci function.
239711bcba0SDavid C Somayajulu  */
240711bcba0SDavid C Somayajulu struct qla_host {
241711bcba0SDavid C Somayajulu         volatile struct {
242711bcba0SDavid C Somayajulu                 volatile uint32_t
243711bcba0SDavid C Somayajulu 			mpi_dma			:1,
244711bcba0SDavid C Somayajulu 			rss_dma			:1,
245711bcba0SDavid C Somayajulu 			intr_enable		:1,
246711bcba0SDavid C Somayajulu 			qla_callout_init	:1,
247711bcba0SDavid C Somayajulu 			qla_watchdog_active	:1,
248711bcba0SDavid C Somayajulu 			qla_watchdog_exit	:1,
249711bcba0SDavid C Somayajulu 			qla_watchdog_pause	:1,
250711bcba0SDavid C Somayajulu 			lro_init		:1,
251711bcba0SDavid C Somayajulu 			parent_tag		:1,
252711bcba0SDavid C Somayajulu 			lock_init		:1;
253711bcba0SDavid C Somayajulu         } flags;
254711bcba0SDavid C Somayajulu 
255711bcba0SDavid C Somayajulu 	volatile uint32_t	hw_init;
256711bcba0SDavid C Somayajulu 
257711bcba0SDavid C Somayajulu 	volatile uint32_t	qla_watchdog_exited;
258711bcba0SDavid C Somayajulu 	volatile uint32_t	qla_watchdog_paused;
259711bcba0SDavid C Somayajulu 	volatile uint32_t	qla_initiate_recovery;
260711bcba0SDavid C Somayajulu 
261711bcba0SDavid C Somayajulu 	device_t		pci_dev;
262711bcba0SDavid C Somayajulu 
263711bcba0SDavid C Somayajulu 	uint8_t			pci_func;
264711bcba0SDavid C Somayajulu 	uint16_t		watchdog_ticks;
265711bcba0SDavid C Somayajulu 	uint8_t			resvd;
266711bcba0SDavid C Somayajulu 
267711bcba0SDavid C Somayajulu         /* ioctl related */
268711bcba0SDavid C Somayajulu         struct cdev             *ioctl_dev;
269711bcba0SDavid C Somayajulu 
270711bcba0SDavid C Somayajulu 	/* register mapping */
271711bcba0SDavid C Somayajulu 	struct resource		*pci_reg;
272711bcba0SDavid C Somayajulu 	int			reg_rid;
273711bcba0SDavid C Somayajulu 
274711bcba0SDavid C Somayajulu 	struct resource		*pci_reg1;
275711bcba0SDavid C Somayajulu 	int			reg_rid1;
276711bcba0SDavid C Somayajulu 
277711bcba0SDavid C Somayajulu 	int			msix_count;
278711bcba0SDavid C Somayajulu 	qla_ivec_t              irq_vec[MAX_RX_RINGS];
279711bcba0SDavid C Somayajulu 
280711bcba0SDavid C Somayajulu 	/* parent dma tag */
281711bcba0SDavid C Somayajulu 	bus_dma_tag_t           parent_tag;
282711bcba0SDavid C Somayajulu 
283711bcba0SDavid C Somayajulu 	/* interface to o.s */
28464c618edSJustin Hibbits 	if_t ifp;
285711bcba0SDavid C Somayajulu 
286711bcba0SDavid C Somayajulu 	struct ifmedia		media;
287711bcba0SDavid C Somayajulu 	uint16_t		max_frame_size;
288711bcba0SDavid C Somayajulu 	uint16_t		rsrvd0;
289711bcba0SDavid C Somayajulu 	uint32_t		msize;
290711bcba0SDavid C Somayajulu 	int			if_flags;
291711bcba0SDavid C Somayajulu 
292711bcba0SDavid C Somayajulu 	/* hardware access lock */
293711bcba0SDavid C Somayajulu 	struct mtx		hw_lock;
294711bcba0SDavid C Somayajulu 	volatile uint32_t	hw_lock_held;
295711bcba0SDavid C Somayajulu 
296711bcba0SDavid C Somayajulu 	uint32_t		vm_pgsize;
297711bcba0SDavid C Somayajulu 	/* transmit related */
298711bcba0SDavid C Somayajulu 	uint32_t		num_tx_rings;
299711bcba0SDavid C Somayajulu 	qla_tx_ring_t		tx_ring[MAX_TX_RINGS];
300711bcba0SDavid C Somayajulu 
301711bcba0SDavid C Somayajulu 	bus_dma_tag_t		tx_tag;
302711bcba0SDavid C Somayajulu 	struct task		tx_task;
303711bcba0SDavid C Somayajulu 	struct taskqueue	*tx_tq;
304711bcba0SDavid C Somayajulu 	struct callout		tx_callout;
305711bcba0SDavid C Somayajulu 	struct mtx		tx_lock;
306711bcba0SDavid C Somayajulu 
307711bcba0SDavid C Somayajulu 	/* receive related */
308711bcba0SDavid C Somayajulu 	uint32_t		num_rx_rings;
309711bcba0SDavid C Somayajulu 	qla_rx_ring_t		rx_ring[MAX_RX_RINGS];
310711bcba0SDavid C Somayajulu 	bus_dma_tag_t		rx_tag;
311711bcba0SDavid C Somayajulu 
312711bcba0SDavid C Somayajulu 	/* stats */
313711bcba0SDavid C Somayajulu 	uint32_t		err_m_getcl;
314711bcba0SDavid C Somayajulu 	uint32_t		err_m_getjcl;
315711bcba0SDavid C Somayajulu 	uint32_t		err_tx_dmamap_create;
316711bcba0SDavid C Somayajulu 	uint32_t		err_tx_dmamap_load;
317711bcba0SDavid C Somayajulu 	uint32_t		err_tx_defrag;
318711bcba0SDavid C Somayajulu 
319711bcba0SDavid C Somayajulu 	/* mac address related */
320711bcba0SDavid C Somayajulu 	uint8_t			mac_rcv_mode;
321711bcba0SDavid C Somayajulu 	uint8_t			mac_addr[ETHER_ADDR_LEN];
322711bcba0SDavid C Somayajulu 	uint32_t		nmcast;
323711bcba0SDavid C Somayajulu 	qla_mcast_t		mcast[Q8_MAX_NUM_MULTICAST_ADDRS];
324711bcba0SDavid C Somayajulu 
325711bcba0SDavid C Somayajulu 	/* Link Related */
326711bcba0SDavid C Somayajulu         uint8_t			link_up;
327711bcba0SDavid C Somayajulu 	uint32_t		link_status;
328711bcba0SDavid C Somayajulu 	uint32_t		link_down_info;
329711bcba0SDavid C Somayajulu 	uint32_t		link_hw_info;
330711bcba0SDavid C Somayajulu 	uint32_t		link_dcbx_counters;
331711bcba0SDavid C Somayajulu 	uint32_t		link_change_counters;
332711bcba0SDavid C Somayajulu 
333711bcba0SDavid C Somayajulu 	/* Flash Related */
334711bcba0SDavid C Somayajulu 	q81_flash_t		flash;
335711bcba0SDavid C Somayajulu 
336711bcba0SDavid C Somayajulu 	/* debug stuff */
337711bcba0SDavid C Somayajulu 	volatile const char 	*qla_lock;
338711bcba0SDavid C Somayajulu 	volatile const char	*qla_unlock;
339711bcba0SDavid C Somayajulu 
340711bcba0SDavid C Somayajulu 	/* Error Recovery Related */
341711bcba0SDavid C Somayajulu 	uint32_t		err_inject;
342711bcba0SDavid C Somayajulu 	struct task		err_task;
343711bcba0SDavid C Somayajulu 	struct taskqueue	*err_tq;
344711bcba0SDavid C Somayajulu 
345711bcba0SDavid C Somayajulu 	/* Chip related */
346711bcba0SDavid C Somayajulu 	uint32_t		rev_id;
347711bcba0SDavid C Somayajulu 
348711bcba0SDavid C Somayajulu 	/* mailbox completions */
349711bcba0SDavid C Somayajulu 	uint32_t		aen[Q81_NUM_AEN_REGISTERS];
350711bcba0SDavid C Somayajulu 	uint32_t		mbox[Q81_NUM_MBX_REGISTERS];
351711bcba0SDavid C Somayajulu 	volatile uint32_t       mbx_done;
352711bcba0SDavid C Somayajulu 
353711bcba0SDavid C Somayajulu 	/* mpi dump related */
354711bcba0SDavid C Somayajulu 	qla_dma_t		mpi_dma;
355711bcba0SDavid C Somayajulu 	qla_dma_t		rss_dma;
356711bcba0SDavid C Somayajulu 
357711bcba0SDavid C Somayajulu };
358711bcba0SDavid C Somayajulu typedef struct qla_host qla_host_t;
359711bcba0SDavid C Somayajulu 
360711bcba0SDavid C Somayajulu /* note that align has to be a power of 2 */
361dd00a8cdSRyan Libby #define QL_ALIGN(size, align) (((size) + ((align) - 1)) & (~((align) - 1)))
362711bcba0SDavid C Somayajulu #define QL_MIN(x, y) ((x < y) ? x : y)
363711bcba0SDavid C Somayajulu 
364711bcba0SDavid C Somayajulu #define QL_RUNNING(ifp) \
36564c618edSJustin Hibbits 		((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) == \
366711bcba0SDavid C Somayajulu 			IFF_DRV_RUNNING)
367711bcba0SDavid C Somayajulu 
368711bcba0SDavid C Somayajulu /* Return 0, if identical, else 1 */
369711bcba0SDavid C Somayajulu 
370711bcba0SDavid C Somayajulu #define QL_MAC_CMP(mac1, mac2)    \
371711bcba0SDavid C Somayajulu 	((((*(uint32_t *) mac1) == (*(uint32_t *) mac2) && \
372711bcba0SDavid C Somayajulu 	(*(uint16_t *)(mac1 + 4)) == (*(uint16_t *)(mac2 + 4)))) ? 0 : 1)
373711bcba0SDavid C Somayajulu 
374711bcba0SDavid C Somayajulu #endif /* #ifndef _QLS_DEF_H_ */
375