1 /*	$NetBSD: if_nfevar.h,v 1.10 2010/11/03 14:03:40 jakllsch Exp $	*/
2 /*	$OpenBSD: if_nfevar.h,v 1.13 2007/12/05 08:30:33 jsg Exp $	*/
3 
4 /*-
5  * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org>
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #define NFE_IFQ_MAXLEN	64
21 
22 struct nfe_tx_data {
23 	bus_dmamap_t	map;
24 	bus_dmamap_t	active;
25 	struct mbuf	*m;
26 };
27 
28 struct nfe_tx_ring {
29 	bus_dmamap_t		map;
30 	bus_dma_segment_t	seg;
31 	bus_addr_t		physaddr;
32 	struct nfe_desc32	*desc32;
33 	struct nfe_desc64	*desc64;
34 	struct nfe_tx_data	data[NFE_TX_RING_COUNT];
35 	int			queued;
36 	int			cur;
37 	int			next;
38 };
39 
40 struct nfe_jbuf {
41 	void			*buf;
42 	bus_addr_t		physaddr;
43 	SLIST_ENTRY(nfe_jbuf)	jnext;
44 };
45 
46 struct nfe_rx_data {
47 	bus_dmamap_t	map;
48 	struct mbuf	*m;
49 };
50 
51 struct nfe_rx_ring {
52 	bus_dmamap_t		map;
53 	bus_dma_segment_t	seg;
54 	bus_dmamap_t		jmap;
55 	bus_dma_segment_t	jseg;
56 	bus_addr_t		physaddr;
57 	struct nfe_desc32	*desc32;
58 	struct nfe_desc64	*desc64;
59 	void			*jpool;
60 	struct nfe_rx_data	data[NFE_RX_RING_COUNT];
61 	struct nfe_jbuf		jbuf[NFE_JPOOL_COUNT];
62 	int			jbufmap[NFE_RX_RING_COUNT];
63 	SLIST_HEAD(, nfe_jbuf)	jfreelist;
64 	int			bufsz;
65 	int			cur;
66 	int			next;
67 	kmutex_t		mtx;
68 };
69 
70 struct nfe_softc {
71 	device_t		sc_dev;
72 	struct ethercom		sc_ethercom;
73 	uint8_t			sc_enaddr[ETHER_ADDR_LEN];
74 	pci_chipset_tag_t	sc_pc;
75 	bus_space_handle_t	sc_memh;
76 	bus_space_tag_t		sc_memt;
77 	bus_size_t		sc_mems;
78 	void			*sc_ih;
79 	bus_dma_tag_t		sc_dmat;
80 	struct mii_data		sc_mii;
81 	struct callout		sc_tick_ch;
82 
83 	int			sc_if_flags;
84 	u_int			sc_flags;
85 #define NFE_JUMBO_SUP		0x01
86 #define NFE_40BIT_ADDR		0x02
87 #define NFE_HW_CSUM		0x04
88 #define NFE_HW_VLAN		0x08
89 #define NFE_USE_JUMBO		0x10
90 #define NFE_CORRECT_MACADDR	0x20
91 #define NFE_PWR_MGMT		0x40
92 
93 	uint32_t		rxtxctl;
94 	uint8_t			mii_phyaddr;
95 
96 	struct nfe_tx_ring	txq;
97 	struct nfe_rx_ring	rxq;
98 };
99