xref: /dflybsd-src/sys/dev/netif/bnx/if_bnxvar.h (revision 2eaa7169b800150eff65706a41f3cb005b2bf0c6)
16c8d8eccSSepherosa Ziehau /*
26c8d8eccSSepherosa Ziehau  * Copyright (c) 2001 Wind River Systems
36c8d8eccSSepherosa Ziehau  * Copyright (c) 1997, 1998, 1999, 2001
46c8d8eccSSepherosa Ziehau  *	Bill Paul <wpaul@windriver.com>.  All rights reserved.
56c8d8eccSSepherosa Ziehau  *
66c8d8eccSSepherosa Ziehau  * Redistribution and use in source and binary forms, with or without
76c8d8eccSSepherosa Ziehau  * modification, are permitted provided that the following conditions
86c8d8eccSSepherosa Ziehau  * are met:
96c8d8eccSSepherosa Ziehau  * 1. Redistributions of source code must retain the above copyright
106c8d8eccSSepherosa Ziehau  *    notice, this list of conditions and the following disclaimer.
116c8d8eccSSepherosa Ziehau  * 2. Redistributions in binary form must reproduce the above copyright
126c8d8eccSSepherosa Ziehau  *    notice, this list of conditions and the following disclaimer in the
136c8d8eccSSepherosa Ziehau  *    documentation and/or other materials provided with the distribution.
146c8d8eccSSepherosa Ziehau  * 3. All advertising materials mentioning features or use of this software
156c8d8eccSSepherosa Ziehau  *    must display the following acknowledgement:
166c8d8eccSSepherosa Ziehau  *	This product includes software developed by Bill Paul.
176c8d8eccSSepherosa Ziehau  * 4. Neither the name of the author nor the names of any co-contributors
186c8d8eccSSepherosa Ziehau  *    may be used to endorse or promote products derived from this software
196c8d8eccSSepherosa Ziehau  *    without specific prior written permission.
206c8d8eccSSepherosa Ziehau  *
216c8d8eccSSepherosa Ziehau  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
226c8d8eccSSepherosa Ziehau  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
236c8d8eccSSepherosa Ziehau  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
246c8d8eccSSepherosa Ziehau  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
256c8d8eccSSepherosa Ziehau  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
266c8d8eccSSepherosa Ziehau  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
276c8d8eccSSepherosa Ziehau  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
286c8d8eccSSepherosa Ziehau  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
296c8d8eccSSepherosa Ziehau  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
306c8d8eccSSepherosa Ziehau  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
316c8d8eccSSepherosa Ziehau  * THE POSSIBILITY OF SUCH DAMAGE.
326c8d8eccSSepherosa Ziehau  *
336c8d8eccSSepherosa Ziehau  * $FreeBSD: src/sys/dev/bge/if_bgereg.h,v 1.1.2.16 2004/09/23 20:11:18 ps Exp $
346c8d8eccSSepherosa Ziehau  */
356c8d8eccSSepherosa Ziehau 
366c8d8eccSSepherosa Ziehau #ifndef _IF_BNXVAR_H_
376c8d8eccSSepherosa Ziehau #define _IF_BNXVAR_H_
386c8d8eccSSepherosa Ziehau 
396c8d8eccSSepherosa Ziehau /*
406c8d8eccSSepherosa Ziehau  * Tigon general information block. This resides in host memory
416c8d8eccSSepherosa Ziehau  * and contains the status counters, ring control blocks and
426c8d8eccSSepherosa Ziehau  * producer pointers.
436c8d8eccSSepherosa Ziehau  */
446c8d8eccSSepherosa Ziehau 
456c8d8eccSSepherosa Ziehau struct bnx_gib {
466c8d8eccSSepherosa Ziehau 	struct bge_stats	bnx_stats;
476c8d8eccSSepherosa Ziehau 	struct bge_rcb		bnx_tx_rcb[16];
486c8d8eccSSepherosa Ziehau 	struct bge_rcb		bnx_std_rx_rcb;
496c8d8eccSSepherosa Ziehau 	struct bge_rcb		bnx_jumbo_rx_rcb;
506c8d8eccSSepherosa Ziehau 	struct bge_rcb		bnx_mini_rx_rcb;
516c8d8eccSSepherosa Ziehau 	struct bge_rcb		bnx_return_rcb;
526c8d8eccSSepherosa Ziehau };
536c8d8eccSSepherosa Ziehau 
546c8d8eccSSepherosa Ziehau #define BNX_MIN_FRAMELEN	60
556c8d8eccSSepherosa Ziehau #define BNX_MAX_FRAMELEN	1536
566c8d8eccSSepherosa Ziehau #define BNX_JUMBO_FRAMELEN	9018
576c8d8eccSSepherosa Ziehau #define BNX_JUMBO_MTU		(BNX_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
586c8d8eccSSepherosa Ziehau 
596c8d8eccSSepherosa Ziehau #define BNX_TIMEOUT		5000
606c8d8eccSSepherosa Ziehau #define BNX_FIRMWARE_TIMEOUT	100000
616c8d8eccSSepherosa Ziehau #define BNX_TXCONS_UNSET	0xFFFF	/* impossible value */
626c8d8eccSSepherosa Ziehau 
636c8d8eccSSepherosa Ziehau /*
646c8d8eccSSepherosa Ziehau  * Other utility macros.
656c8d8eccSSepherosa Ziehau  */
666c8d8eccSSepherosa Ziehau #define BNX_INC(x, y)		(x) = ((x) + 1) % (y)
676c8d8eccSSepherosa Ziehau 
686c8d8eccSSepherosa Ziehau /*
699f5082d5SSepherosa Ziehau  * BAR0 MAC register access macros. The Tigon always uses memory mapped
709f5082d5SSepherosa Ziehau  * register accesses and all registers must be accessed with 32 bit
719f5082d5SSepherosa Ziehau  * operations.
726c8d8eccSSepherosa Ziehau  */
736c8d8eccSSepherosa Ziehau 
746c8d8eccSSepherosa Ziehau #define CSR_WRITE_4(sc, reg, val)	\
756c8d8eccSSepherosa Ziehau 	bus_space_write_4(sc->bnx_btag, sc->bnx_bhandle, reg, val)
766c8d8eccSSepherosa Ziehau 
776c8d8eccSSepherosa Ziehau #define CSR_READ_4(sc, reg)		\
786c8d8eccSSepherosa Ziehau 	bus_space_read_4(sc->bnx_btag, sc->bnx_bhandle, reg)
796c8d8eccSSepherosa Ziehau 
806c8d8eccSSepherosa Ziehau #define BNX_SETBIT(sc, reg, x)	\
816c8d8eccSSepherosa Ziehau 	CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) | x))
826c8d8eccSSepherosa Ziehau 
836c8d8eccSSepherosa Ziehau #define BNX_CLRBIT(sc, reg, x)	\
846c8d8eccSSepherosa Ziehau 	CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) & ~x))
856c8d8eccSSepherosa Ziehau 
869f5082d5SSepherosa Ziehau /* BAR2 APE register access macros. */
879f5082d5SSepherosa Ziehau #define	APE_WRITE_4(sc, reg, val)	\
889f5082d5SSepherosa Ziehau 	bus_write_4(sc->bnx_res2, reg, val)
899f5082d5SSepherosa Ziehau 
909f5082d5SSepherosa Ziehau #define	APE_READ_4(sc, reg)		\
919f5082d5SSepherosa Ziehau 	bus_read_4(sc->bnx_res2, reg)
929f5082d5SSepherosa Ziehau 
939f5082d5SSepherosa Ziehau #define	APE_SETBIT(sc, reg, x)	\
949f5082d5SSepherosa Ziehau 	APE_WRITE_4(sc, reg, (APE_READ_4(sc, reg) | (x)))
959f5082d5SSepherosa Ziehau #define	APE_CLRBIT(sc, reg, x)	\
969f5082d5SSepherosa Ziehau 	APE_WRITE_4(sc, reg, (APE_READ_4(sc, reg) & ~(x)))
979f5082d5SSepherosa Ziehau 
986c8d8eccSSepherosa Ziehau #define BNX_MEMWIN_READ(sc, x, val)				\
996c8d8eccSSepherosa Ziehau do {								\
1006c8d8eccSSepherosa Ziehau 	pci_write_config(sc->bnx_dev, BGE_PCI_MEMWIN_BASEADDR,	\
1016c8d8eccSSepherosa Ziehau 	    (0xFFFF0000 & x), 4);				\
1026c8d8eccSSepherosa Ziehau 	val = CSR_READ_4(sc, BGE_MEMWIN_START + (x & 0xFFFF));	\
1036c8d8eccSSepherosa Ziehau } while(0)
1046c8d8eccSSepherosa Ziehau 
1056c8d8eccSSepherosa Ziehau #define BNX_MEMWIN_WRITE(sc, x, val)				\
1066c8d8eccSSepherosa Ziehau do {								\
1076c8d8eccSSepherosa Ziehau 	pci_write_config(sc->bnx_dev, BGE_PCI_MEMWIN_BASEADDR,	\
1086c8d8eccSSepherosa Ziehau 	    (0xFFFF0000 & x), 4);				\
1096c8d8eccSSepherosa Ziehau 	CSR_WRITE_4(sc, BGE_MEMWIN_START + (x & 0xFFFF), val);	\
1106c8d8eccSSepherosa Ziehau } while(0)
1116c8d8eccSSepherosa Ziehau 
1126c8d8eccSSepherosa Ziehau #define RCB_WRITE_4(sc, rcb, offset, val)			\
1136c8d8eccSSepherosa Ziehau 	bus_space_write_4(sc->bnx_btag, sc->bnx_bhandle,	\
1146c8d8eccSSepherosa Ziehau 			  rcb + offsetof(struct bge_rcb, offset), val)
1156c8d8eccSSepherosa Ziehau 
1166c8d8eccSSepherosa Ziehau /*
1176c8d8eccSSepherosa Ziehau  * Memory management stuff. Note: the SSLOTS, MSLOTS and JSLOTS
1186c8d8eccSSepherosa Ziehau  * values are tuneable. They control the actual amount of buffers
1196c8d8eccSSepherosa Ziehau  * allocated for the standard, mini and jumbo receive rings.
1206c8d8eccSSepherosa Ziehau  */
1216c8d8eccSSepherosa Ziehau 
1226c8d8eccSSepherosa Ziehau #define BNX_SSLOTS	256
1236c8d8eccSSepherosa Ziehau #define BNX_MSLOTS	256
1246c8d8eccSSepherosa Ziehau #define BNX_JSLOTS	384
1256c8d8eccSSepherosa Ziehau 
1266c8d8eccSSepherosa Ziehau #define BNX_JRAWLEN (BNX_JUMBO_FRAMELEN + ETHER_ALIGN)
1276c8d8eccSSepherosa Ziehau #define BNX_JLEN (BNX_JRAWLEN + \
1286c8d8eccSSepherosa Ziehau 	(sizeof(uint64_t) - BNX_JRAWLEN % sizeof(uint64_t)))
1296c8d8eccSSepherosa Ziehau #define BNX_JPAGESZ PAGE_SIZE
1306c8d8eccSSepherosa Ziehau #define BNX_RESID (BNX_JPAGESZ - (BNX_JLEN * BNX_JSLOTS) % BNX_JPAGESZ)
1316c8d8eccSSepherosa Ziehau #define BNX_JMEM ((BNX_JLEN * BNX_JSLOTS) + BNX_RESID)
1326c8d8eccSSepherosa Ziehau 
1336c8d8eccSSepherosa Ziehau struct bnx_softc;
134695a8586SSepherosa Ziehau struct bnx_tx_ring;
1356c8d8eccSSepherosa Ziehau 
1366c8d8eccSSepherosa Ziehau struct bnx_jslot {
1376c8d8eccSSepherosa Ziehau 	struct bnx_softc	*bnx_sc;
1386c8d8eccSSepherosa Ziehau 	void			*bnx_buf;
1396c8d8eccSSepherosa Ziehau 	bus_addr_t		bnx_paddr;
1406c8d8eccSSepherosa Ziehau 	int			bnx_inuse;
1416c8d8eccSSepherosa Ziehau 	int			bnx_slot;
1426c8d8eccSSepherosa Ziehau 	SLIST_ENTRY(bnx_jslot)	jslot_link;
1436c8d8eccSSepherosa Ziehau };
1446c8d8eccSSepherosa Ziehau 
1456c8d8eccSSepherosa Ziehau /*
1466c8d8eccSSepherosa Ziehau  * Ring structures. Most of these reside in host memory and we tell
1476c8d8eccSSepherosa Ziehau  * the NIC where they are via the ring control blocks. The exceptions
1486c8d8eccSSepherosa Ziehau  * are the tx and command rings, which live in NIC memory and which
1496c8d8eccSSepherosa Ziehau  * we access via the shared memory window.
1506c8d8eccSSepherosa Ziehau  */
1516c8d8eccSSepherosa Ziehau struct bnx_ring_data {
1526c8d8eccSSepherosa Ziehau 	struct bge_rx_bd	*bnx_rx_jumbo_ring;
1536c8d8eccSSepherosa Ziehau 	bus_addr_t		bnx_rx_jumbo_ring_paddr;
1546c8d8eccSSepherosa Ziehau 	void			*bnx_jumbo_buf;
1556c8d8eccSSepherosa Ziehau 	struct bnx_gib		bnx_info;
1566c8d8eccSSepherosa Ziehau };
1576c8d8eccSSepherosa Ziehau 
158beedf5beSSepherosa Ziehau struct bnx_rx_buf {
159beedf5beSSepherosa Ziehau 	bus_dmamap_t		bnx_rx_dmamap;
160beedf5beSSepherosa Ziehau 	struct mbuf		*bnx_rx_mbuf;
161beedf5beSSepherosa Ziehau 	bus_addr_t		bnx_rx_paddr;
162695a8586SSepherosa Ziehau 	int			bnx_rx_len;
163841cdf08SSepherosa Ziehau 	int			bnx_rx_refilled;
164841cdf08SSepherosa Ziehau } __cachealign;
1656c8d8eccSSepherosa Ziehau 
166beedf5beSSepherosa Ziehau struct bnx_rx_std_ring {
167329f9016SSepherosa Ziehau 	struct lwkt_serialize	bnx_rx_std_serialize;
168beedf5beSSepherosa Ziehau 	struct bnx_softc	*bnx_sc;
169beedf5beSSepherosa Ziehau 
170695a8586SSepherosa Ziehau 	uint16_t		bnx_rx_std_stop;
171beedf5beSSepherosa Ziehau 	uint16_t		bnx_rx_std;	/* current prod ring head */
172beedf5beSSepherosa Ziehau 	struct bge_rx_bd	*bnx_rx_std_ring;
173beedf5beSSepherosa Ziehau 
174841cdf08SSepherosa Ziehau 	int			bnx_rx_std_refill __cachealign;
175625c3ba3SSepherosa Ziehau 	int			bnx_rx_std_used;
176841cdf08SSepherosa Ziehau 	u_int			bnx_rx_std_running;
177c450d4d8SSepherosa Ziehau 	struct thread		*bnx_rx_std_ithread;
178841cdf08SSepherosa Ziehau 
179beedf5beSSepherosa Ziehau 	struct bnx_rx_buf	bnx_rx_std_buf[BGE_STD_RX_RING_CNT];
180beedf5beSSepherosa Ziehau 
181841cdf08SSepherosa Ziehau 	bus_dma_tag_t		bnx_rx_mtag;	/* RX mbuf DMA tag */
182841cdf08SSepherosa Ziehau 
183beedf5beSSepherosa Ziehau 	bus_dma_tag_t		bnx_rx_std_ring_tag;
184beedf5beSSepherosa Ziehau 	bus_dmamap_t		bnx_rx_std_ring_map;
185beedf5beSSepherosa Ziehau 	bus_addr_t		bnx_rx_std_ring_paddr;
186beedf5beSSepherosa Ziehau } __cachealign;
187beedf5beSSepherosa Ziehau 
188beedf5beSSepherosa Ziehau struct bnx_rx_ret_ring {
189329f9016SSepherosa Ziehau 	struct lwkt_serialize	bnx_rx_ret_serialize;
190ac2936fdSSepherosa Ziehau 	int			bnx_rx_mbx;
1914fa38985SSepherosa Ziehau 	uint32_t		bnx_saved_status_tag;
1924fa38985SSepherosa Ziehau 	volatile uint32_t	*bnx_hw_status_tag;
193695a8586SSepherosa Ziehau 	int			bnx_msix_mbx;
194beedf5beSSepherosa Ziehau 	struct bnx_softc	*bnx_sc;
195beedf5beSSepherosa Ziehau 	struct bnx_rx_std_ring	*bnx_std;
196695a8586SSepherosa Ziehau 	struct bnx_tx_ring	*bnx_txr;
197beedf5beSSepherosa Ziehau 
198beedf5beSSepherosa Ziehau 	/* Shadow of bnx_rx_std_ring's bnx_rx_mtag */
199beedf5beSSepherosa Ziehau 	bus_dma_tag_t		bnx_rx_mtag;
200beedf5beSSepherosa Ziehau 
2013a16b7b8SSepherosa Ziehau 	volatile uint16_t	*bnx_rx_considx;
202beedf5beSSepherosa Ziehau 	uint16_t		bnx_rx_saved_considx;
203841cdf08SSepherosa Ziehau 	uint16_t		bnx_rx_cnt;
204841cdf08SSepherosa Ziehau 	uint16_t		bnx_rx_cntmax;
205841cdf08SSepherosa Ziehau 	uint16_t		bnx_rx_mask;
206beedf5beSSepherosa Ziehau 	struct bge_rx_bd	*bnx_rx_ret_ring;
207beedf5beSSepherosa Ziehau 	bus_dmamap_t		bnx_rx_tmpmap;
208beedf5beSSepherosa Ziehau 
209beedf5beSSepherosa Ziehau 	bus_dma_tag_t		bnx_rx_ret_ring_tag;
210beedf5beSSepherosa Ziehau 	bus_dmamap_t		bnx_rx_ret_ring_map;
211beedf5beSSepherosa Ziehau 	bus_addr_t		bnx_rx_ret_ring_paddr;
212625c3ba3SSepherosa Ziehau 
213625c3ba3SSepherosa Ziehau 	u_long			bnx_rx_pkt;
214625c3ba3SSepherosa Ziehau 	u_long			bnx_rx_force_sched;
215beedf5beSSepherosa Ziehau } __cachealign;
216beedf5beSSepherosa Ziehau 
2176c8d8eccSSepherosa Ziehau /*
2186c8d8eccSSepherosa Ziehau  * Mbuf pointers. We need these to keep track of the virtual addresses
2196c8d8eccSSepherosa Ziehau  * of our mbuf chains since we can only convert from physical to virtual,
2206c8d8eccSSepherosa Ziehau  * not the other way around.
2216c8d8eccSSepherosa Ziehau  */
2226c8d8eccSSepherosa Ziehau struct bnx_chain_data {
2236c8d8eccSSepherosa Ziehau 	bus_dma_tag_t		bnx_parent_tag;
2246c8d8eccSSepherosa Ziehau 	bus_dma_tag_t		bnx_rx_jumbo_ring_tag;
2256c8d8eccSSepherosa Ziehau 	bus_dma_tag_t		bnx_jumbo_tag;
2266c8d8eccSSepherosa Ziehau 	bus_dmamap_t		bnx_rx_jumbo_ring_map;
2276c8d8eccSSepherosa Ziehau 	bus_dmamap_t		bnx_jumbo_map;
228beedf5beSSepherosa Ziehau 	struct bnx_rx_buf	bnx_rx_jumbo_chain[BGE_JUMBO_RX_RING_CNT];
2296c8d8eccSSepherosa Ziehau 	/* Stick the jumbo mem management stuff here too. */
2306c8d8eccSSepherosa Ziehau 	struct bnx_jslot	bnx_jslots[BNX_JSLOTS];
2316c8d8eccSSepherosa Ziehau };
2326c8d8eccSSepherosa Ziehau 
233fa4b1067SSepherosa Ziehau struct bnx_tx_buf {
234fa4b1067SSepherosa Ziehau 	bus_dmamap_t		bnx_tx_dmamap;
235fa4b1067SSepherosa Ziehau 	struct mbuf		*bnx_tx_mbuf;
236fa4b1067SSepherosa Ziehau };
237fa4b1067SSepherosa Ziehau 
23833a04907SSepherosa Ziehau struct bnx_tx_ring {
239329f9016SSepherosa Ziehau 	struct lwkt_serialize	bnx_tx_serialize;
240695a8586SSepherosa Ziehau 	volatile uint32_t	*bnx_hw_status_tag;
2414fa38985SSepherosa Ziehau 	uint32_t		bnx_saved_status_tag;
24233a04907SSepherosa Ziehau 	struct bnx_softc	*bnx_sc;
2433397dea6SSepherosa Ziehau 	struct ifaltq_subque	*bnx_ifsq;
2443a16b7b8SSepherosa Ziehau 	volatile uint16_t	*bnx_tx_considx;
24579a64343SSepherosa Ziehau 	uint16_t		bnx_tx_flags;
24679a64343SSepherosa Ziehau #define BNX_TX_FLAG_SHORTDMA		0x0001
247aad4de2bSSepherosa Ziehau #define BNX_TX_FLAG_FORCE_DEFRAG	0x0002
24833a04907SSepherosa Ziehau 	uint16_t		bnx_tx_saved_considx;
249fa639b88SSepherosa Ziehau 	int			bnx_tx_cnt;
25033a04907SSepherosa Ziehau 	uint32_t		bnx_tx_prodidx;
25133a04907SSepherosa Ziehau 	int			bnx_tx_wreg;
2528bd43d5dSSepherosa Ziehau 	int			bnx_tx_mbx;
2533397dea6SSepherosa Ziehau 	struct ifsubq_watchdog	bnx_tx_watchdog;
25433a04907SSepherosa Ziehau 
25533a04907SSepherosa Ziehau 	struct bge_tx_bd	*bnx_tx_ring;
25633a04907SSepherosa Ziehau 
25733a04907SSepherosa Ziehau 	bus_dma_tag_t		bnx_tx_mtag;	/* TX mbuf DMA tag */
258fa4b1067SSepherosa Ziehau 	struct bnx_tx_buf	bnx_tx_buf[BGE_TX_RING_CNT];
25933a04907SSepherosa Ziehau 
26033a04907SSepherosa Ziehau 	bus_dma_tag_t		bnx_tx_ring_tag;
26133a04907SSepherosa Ziehau 	bus_dmamap_t		bnx_tx_ring_map;
26233a04907SSepherosa Ziehau 	bus_addr_t		bnx_tx_ring_paddr;
263f33ac8a4SSepherosa Ziehau 	int			bnx_tx_cpuid;
264695a8586SSepherosa Ziehau 
265695a8586SSepherosa Ziehau 	u_long			bnx_tx_pkt;
26633a04907SSepherosa Ziehau } __cachealign;
26733a04907SSepherosa Ziehau 
268f33ac8a4SSepherosa Ziehau struct bnx_intr_data {
269f33ac8a4SSepherosa Ziehau 	struct bnx_softc	*bnx_sc;
270f33ac8a4SSepherosa Ziehau 	struct bnx_rx_ret_ring	*bnx_ret;
271f33ac8a4SSepherosa Ziehau 	struct bnx_tx_ring	*bnx_txr;
272f33ac8a4SSepherosa Ziehau 
273f33ac8a4SSepherosa Ziehau 	int			bnx_intr_cpuid;
274f33ac8a4SSepherosa Ziehau 	struct lwkt_serialize	*bnx_intr_serialize;
275f33ac8a4SSepherosa Ziehau 	struct callout		bnx_intr_timer;
276f33ac8a4SSepherosa Ziehau 	void			(*bnx_intr_check)(void *);
277f33ac8a4SSepherosa Ziehau 	uint16_t		bnx_rx_check_considx;
278f33ac8a4SSepherosa Ziehau 	uint16_t		bnx_tx_check_considx;
279f33ac8a4SSepherosa Ziehau 	boolean_t		bnx_intr_maylose;
280f33ac8a4SSepherosa Ziehau 
281f33ac8a4SSepherosa Ziehau 	void			*bnx_intr_arg;
282f33ac8a4SSepherosa Ziehau 	driver_intr_t		*bnx_intr_func;
283f33ac8a4SSepherosa Ziehau 	void			*bnx_intr_hand;
284f33ac8a4SSepherosa Ziehau 	struct resource		*bnx_intr_res;
285f33ac8a4SSepherosa Ziehau 	int			bnx_intr_rid;
28697ba8fc5SSepherosa Ziehau 	int			bnx_intr_mbx;
2874fa38985SSepherosa Ziehau 	const uint32_t		*bnx_saved_status_tag;
288f33ac8a4SSepherosa Ziehau 
289f33ac8a4SSepherosa Ziehau 	const char		*bnx_intr_desc;
290f33ac8a4SSepherosa Ziehau 	char			bnx_intr_desc0[64];
2910a806e3aSSepherosa Ziehau 
2920a806e3aSSepherosa Ziehau 	bus_dma_tag_t		bnx_status_tag;
2930a806e3aSSepherosa Ziehau 	bus_dmamap_t		bnx_status_map;
2940a806e3aSSepherosa Ziehau 	struct bge_status_block	*bnx_status_block;
2950a806e3aSSepherosa Ziehau 	bus_addr_t		bnx_status_block_paddr;
296f33ac8a4SSepherosa Ziehau } __cachealign;
297f33ac8a4SSepherosa Ziehau 
298695a8586SSepherosa Ziehau #define BNX_RX_RING_MAX		4
299695a8586SSepherosa Ziehau #define BNX_TX_RING_MAX		4
300f33ac8a4SSepherosa Ziehau #define BNX_INTR_MAX		5
301f33ac8a4SSepherosa Ziehau 
30202596bedSSepherosa Ziehau #define BNX_RDRTABLE_SIZE	(BGE_RSS_INDIR_TBLENT_CNT * \
30302596bedSSepherosa Ziehau 				 BGE_RSS_INDIR_TBL_CNT)
30402596bedSSepherosa Ziehau 
3056c8d8eccSSepherosa Ziehau struct bnx_softc {
3066c8d8eccSSepherosa Ziehau 	struct arpcom		arpcom;		/* interface info */
3076c8d8eccSSepherosa Ziehau 	device_t		bnx_dev;
3086c8d8eccSSepherosa Ziehau 	device_t		bnx_miibus;
3096c8d8eccSSepherosa Ziehau 	bus_space_handle_t	bnx_bhandle;
3106c8d8eccSSepherosa Ziehau 	bus_space_tag_t		bnx_btag;
3119f5082d5SSepherosa Ziehau 	struct resource		*bnx_res;	/* MAC mapped I/O */
3129f5082d5SSepherosa Ziehau 	struct resource		*bnx_res2;	/* APE mapped I/O */
3136c8d8eccSSepherosa Ziehau 	struct ifmedia		bnx_ifmedia;	/* TBI media info */
3146c8d8eccSSepherosa Ziehau 	int			bnx_pciecap;
3156c8d8eccSSepherosa Ziehau 	uint32_t		bnx_flags;	/* BNX_FLAG_ */
3166c8d8eccSSepherosa Ziehau #define BNX_FLAG_TBI		0x00000001
3176c8d8eccSSepherosa Ziehau #define BNX_FLAG_JUMBO		0x00000002
3184aa71e73SSepherosa Ziehau #define BNX_FLAG_APE		0x00000004
3196c8d8eccSSepherosa Ziehau #define BNX_FLAG_5717_PLUS	0x00000008
3206c8d8eccSSepherosa Ziehau #define BNX_FLAG_MII_SERDES	0x00000010
3216c8d8eccSSepherosa Ziehau #define BNX_FLAG_CPMU		0x00000020
322f368d0d9SSepherosa Ziehau #define BNX_FLAG_57765_PLUS	0x00000040
323f368d0d9SSepherosa Ziehau #define BNX_FLAG_57765_FAMILY	0x00000080
324df9ccc98SSepherosa Ziehau #define BNX_FLAG_STATUSTAG_BUG	0x00000100
32566deb1c1SSepherosa Ziehau #define BNX_FLAG_TSO		0x00000200
3266c8d8eccSSepherosa Ziehau #define BNX_FLAG_NO_EEPROM	0x10000000
3274fa38985SSepherosa Ziehau #define BNX_FLAG_RXTX_BUNDLE	0x20000000
328695a8586SSepherosa Ziehau #define BNX_FLAG_STATUS_HASTAG	0x80000000
3296c8d8eccSSepherosa Ziehau 
3309f5082d5SSepherosa Ziehau 	uint32_t		bnx_mfw_flags;	/* Management F/W flags */
3319f5082d5SSepherosa Ziehau #define	BNX_MFW_ON_RXCPU	0x00000001
3329f5082d5SSepherosa Ziehau #define	BNX_MFW_ON_APE		0x00000002
3339f5082d5SSepherosa Ziehau #define	BNX_MFW_TYPE_NCSI	0x00000004
3349f5082d5SSepherosa Ziehau #define	BNX_MFW_TYPE_DASH	0x00000008
3359f5082d5SSepherosa Ziehau 	int			bnx_phy_ape_lock;
3369f5082d5SSepherosa Ziehau 	int			bnx_func_addr;
3379f5082d5SSepherosa Ziehau 
3386c8d8eccSSepherosa Ziehau 	uint32_t		bnx_chipid;
3396c8d8eccSSepherosa Ziehau 	uint32_t		bnx_asicrev;
3406c8d8eccSSepherosa Ziehau 	uint32_t		bnx_chiprev;
3416c8d8eccSSepherosa Ziehau 	struct bnx_ring_data	bnx_ldata;	/* rings */
3426c8d8eccSSepherosa Ziehau 	struct bnx_chain_data	bnx_cdata;	/* mbufs */
343beedf5beSSepherosa Ziehau 
344f33ac8a4SSepherosa Ziehau 	struct lwkt_serialize	bnx_main_serialize;
345695a8586SSepherosa Ziehau 	volatile uint32_t	*bnx_hw_status;
346695a8586SSepherosa Ziehau 	volatile uint32_t	*bnx_hw_status_tag;
347695a8586SSepherosa Ziehau 	uint32_t		bnx_saved_status_tag;
348695a8586SSepherosa Ziehau 	int			bnx_link_evt;
349695a8586SSepherosa Ziehau 	u_long			bnx_errors;
350695a8586SSepherosa Ziehau 	u_long			bnx_norxbds;
351695a8586SSepherosa Ziehau 
352329f9016SSepherosa Ziehau 	int			bnx_serialize_cnt;
353329f9016SSepherosa Ziehau 	struct lwkt_serialize	**bnx_serialize;
354f33ac8a4SSepherosa Ziehau 
35533a04907SSepherosa Ziehau 	int			bnx_tx_ringcnt;
35633a04907SSepherosa Ziehau 	struct bnx_tx_ring	*bnx_tx_ring;
357beedf5beSSepherosa Ziehau 	int			bnx_rx_retcnt;
358beedf5beSSepherosa Ziehau 	struct bnx_rx_ret_ring	*bnx_rx_ret_ring;
359beedf5beSSepherosa Ziehau 	struct bnx_rx_std_ring	bnx_rx_std_ring;
360beedf5beSSepherosa Ziehau 
3616c8d8eccSSepherosa Ziehau 	uint16_t		bnx_jumbo;	/* current jumo ring head */
3626c8d8eccSSepherosa Ziehau 	SLIST_HEAD(__bnx_jfreehead, bnx_jslot)	bnx_jfree_listhead;
3636c8d8eccSSepherosa Ziehau 	struct lwkt_serialize	bnx_jslot_serializer;
3646c8d8eccSSepherosa Ziehau 	uint32_t		bnx_rx_coal_ticks;
3656c8d8eccSSepherosa Ziehau 	uint32_t		bnx_tx_coal_ticks;
3666c8d8eccSSepherosa Ziehau 	uint32_t		bnx_rx_coal_bds;
367a86cc105SSepherosa Ziehau 	uint32_t		bnx_rx_coal_bds_poll;
3686c8d8eccSSepherosa Ziehau 	uint32_t		bnx_tx_coal_bds;
36927357d84SSepherosa Ziehau 	uint32_t		bnx_tx_coal_bds_poll;
3706c8d8eccSSepherosa Ziehau 	uint32_t		bnx_rx_coal_bds_int;
3716c8d8eccSSepherosa Ziehau 	uint32_t		bnx_tx_coal_bds_int;
3726c8d8eccSSepherosa Ziehau 	uint32_t		bnx_mi_mode;
3736c8d8eccSSepherosa Ziehau 	int			bnx_if_flags;
3746c8d8eccSSepherosa Ziehau 	int			bnx_link;
375*2eaa7169SSepherosa Ziehau 	uint32_t		bnx_rdma_wa;
3767dbaa833SSepherosa Ziehau 	int			bnx_tick_cpuid;
3777dbaa833SSepherosa Ziehau 	struct callout		bnx_tick_timer;
3784fa38985SSepherosa Ziehau 
37902596bedSSepherosa Ziehau 	struct if_ringmap	*bnx_tx_rmap;
38002596bedSSepherosa Ziehau 	struct if_ringmap	*bnx_rx_rmap;
3816c8d8eccSSepherosa Ziehau 
382695a8586SSepherosa Ziehau 	int			bnx_msix_mem_rid;
383695a8586SSepherosa Ziehau 	struct resource		*bnx_msix_mem_res;
384f33ac8a4SSepherosa Ziehau 	int			bnx_intr_type;
385f33ac8a4SSepherosa Ziehau 	int			bnx_intr_cnt;
386f33ac8a4SSepherosa Ziehau 	struct bnx_intr_data	bnx_intr_data[BNX_INTR_MAX];
387df9ccc98SSepherosa Ziehau 
38802596bedSSepherosa Ziehau 	int			bnx_rdr_table[BNX_RDRTABLE_SIZE];
38902596bedSSepherosa Ziehau 
3906c8d8eccSSepherosa Ziehau 	int			bnx_phyno;
3916c8d8eccSSepherosa Ziehau 	uint32_t		bnx_coal_chg;
3926c8d8eccSSepherosa Ziehau #define BNX_RX_COAL_TICKS_CHG		0x01
3936c8d8eccSSepherosa Ziehau #define BNX_TX_COAL_TICKS_CHG		0x02
3946c8d8eccSSepherosa Ziehau #define BNX_RX_COAL_BDS_CHG		0x04
3956c8d8eccSSepherosa Ziehau #define BNX_TX_COAL_BDS_CHG		0x08
3966c8d8eccSSepherosa Ziehau #define BNX_RX_COAL_BDS_INT_CHG		0x40
3976c8d8eccSSepherosa Ziehau #define BNX_TX_COAL_BDS_INT_CHG		0x80
3986c8d8eccSSepherosa Ziehau 
3996c8d8eccSSepherosa Ziehau 	void			(*bnx_link_upd)(struct bnx_softc *, uint32_t);
4006c8d8eccSSepherosa Ziehau 	uint32_t		bnx_link_chg;
40166deb1c1SSepherosa Ziehau 
402695a8586SSepherosa Ziehau 	int			bnx_rss_debug;
40366deb1c1SSepherosa Ziehau #define BNX_TSO_NSTATS		45
40466deb1c1SSepherosa Ziehau 	u_long			bnx_tsosegs[BNX_TSO_NSTATS];
4056c8d8eccSSepherosa Ziehau };
4066c8d8eccSSepherosa Ziehau 
40766deb1c1SSepherosa Ziehau #define BNX_NSEG_NEW		40
408adea0b8cSSepherosa Ziehau #define BNX_NSEG_SPARE		33	/* enough for 64K TSO segment */
409adea0b8cSSepherosa Ziehau #define BNX_NSEG_RSVD		4
4106c8d8eccSSepherosa Ziehau 
4116c8d8eccSSepherosa Ziehau /* RX coalesce ticks, unit: us */
4126c8d8eccSSepherosa Ziehau #define BNX_RX_COAL_TICKS_MIN	0
4136c8d8eccSSepherosa Ziehau #define BNX_RX_COAL_TICKS_DEF	160
4146c8d8eccSSepherosa Ziehau #define BNX_RX_COAL_TICKS_MAX	1023
4156c8d8eccSSepherosa Ziehau 
4166c8d8eccSSepherosa Ziehau /* TX coalesce ticks, unit: us */
4176c8d8eccSSepherosa Ziehau #define BNX_TX_COAL_TICKS_MIN	0
4186c8d8eccSSepherosa Ziehau #define BNX_TX_COAL_TICKS_DEF	1023
4196c8d8eccSSepherosa Ziehau #define BNX_TX_COAL_TICKS_MAX	1023
4206c8d8eccSSepherosa Ziehau 
4216c8d8eccSSepherosa Ziehau /* RX coalesce BDs */
4228a382fe7SSepherosa Ziehau #define BNX_RX_COAL_BDS_MIN	0
423306e5498SSepherosa Ziehau #define BNX_RX_COAL_BDS_DEF	0
424306e5498SSepherosa Ziehau #define BNX_RX_COAL_BDS_INT_DEF	80
4256c8d8eccSSepherosa Ziehau #define BNX_RX_COAL_BDS_MAX	255
4266c8d8eccSSepherosa Ziehau 
4276c8d8eccSSepherosa Ziehau /* TX coalesce BDs */
4288a382fe7SSepherosa Ziehau #define BNX_TX_COAL_BDS_MIN	0
42927357d84SSepherosa Ziehau #define BNX_TX_COAL_BDS_DEF	128
43027357d84SSepherosa Ziehau #define BNX_TX_COAL_BDS_POLL_DEF 64
431c9b7f592SSepherosa Ziehau #define BNX_TX_COAL_BDS_INT_DEF	64
4326c8d8eccSSepherosa Ziehau #define BNX_TX_COAL_BDS_MAX	255
4336c8d8eccSSepherosa Ziehau 
4340bb53200SSepherosa Ziehau /* Number of segments sent before writing to TX related registers */
4350bb53200SSepherosa Ziehau #define BNX_TX_WREG_NSEGS	8
4360bb53200SSepherosa Ziehau 
437e0f74fc8SSepherosa Ziehau /* Return ring descriptor count */
438e0f74fc8SSepherosa Ziehau #define BNX_RETURN_RING_CNT	512
439e0f74fc8SSepherosa Ziehau 
4401c9d03f6SSepherosa Ziehau #define BNX_TX_RING_MAX		4
4411c9d03f6SSepherosa Ziehau 
442695a8586SSepherosa Ziehau #define BNX_RSS_ENABLED(sc)	((sc)->bnx_rx_retcnt > 1)
443695a8586SSepherosa Ziehau 
4446c8d8eccSSepherosa Ziehau #endif	/* !_IF_BNXVAR_H_ */
445