xref: /freebsd/sys/dev/nfe/if_nfevar.h (revision ec22a3a259193685afaea1667a39266264c65fd3)
1257c5577SDavid E. O'Brien /*	$OpenBSD: if_nfevar.h,v 1.11 2006/02/19 13:57:02 damien Exp $	*/
2257c5577SDavid E. O'Brien 
3257c5577SDavid E. O'Brien /*-
4257c5577SDavid E. O'Brien  * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org>
5257c5577SDavid E. O'Brien  *
6257c5577SDavid E. O'Brien  * Permission to use, copy, modify, and distribute this software for any
7257c5577SDavid E. O'Brien  * purpose with or without fee is hereby granted, provided that the above
8257c5577SDavid E. O'Brien  * copyright notice and this permission notice appear in all copies.
9257c5577SDavid E. O'Brien  *
10257c5577SDavid E. O'Brien  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11257c5577SDavid E. O'Brien  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12257c5577SDavid E. O'Brien  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13257c5577SDavid E. O'Brien  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14257c5577SDavid E. O'Brien  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15257c5577SDavid E. O'Brien  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16257c5577SDavid E. O'Brien  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17bfc788c2SDavid E. O'Brien  *
18bfc788c2SDavid E. O'Brien  * $FreeBSD$
19257c5577SDavid E. O'Brien  */
20257c5577SDavid E. O'Brien 
21257c5577SDavid E. O'Brien struct nfe_tx_data {
22bfc788c2SDavid E. O'Brien 	bus_dmamap_t	tx_data_map;
23257c5577SDavid E. O'Brien 	struct mbuf	*m;
24257c5577SDavid E. O'Brien };
25257c5577SDavid E. O'Brien 
26257c5577SDavid E. O'Brien struct nfe_tx_ring {
27aab5582fSPyun YongHyeon 	bus_dma_tag_t		tx_desc_tag;
28bfc788c2SDavid E. O'Brien 	bus_dmamap_t		tx_desc_map;
29257c5577SDavid E. O'Brien 	bus_addr_t		physaddr;
30257c5577SDavid E. O'Brien 	struct nfe_desc32	*desc32;
31257c5577SDavid E. O'Brien 	struct nfe_desc64	*desc64;
32aab5582fSPyun YongHyeon 	bus_dma_tag_t		tx_data_tag;
33257c5577SDavid E. O'Brien 	struct nfe_tx_data	data[NFE_TX_RING_COUNT];
34257c5577SDavid E. O'Brien 	int			queued;
35257c5577SDavid E. O'Brien 	int			cur;
36257c5577SDavid E. O'Brien 	int			next;
37257c5577SDavid E. O'Brien };
38257c5577SDavid E. O'Brien 
39257c5577SDavid E. O'Brien struct nfe_rx_data {
40bfc788c2SDavid E. O'Brien 	bus_dmamap_t	rx_data_map;
41aab5582fSPyun YongHyeon 	bus_addr_t	paddr;
42257c5577SDavid E. O'Brien 	struct mbuf	*m;
43257c5577SDavid E. O'Brien };
44257c5577SDavid E. O'Brien 
45257c5577SDavid E. O'Brien struct nfe_rx_ring {
46bfc788c2SDavid E. O'Brien 	bus_dma_tag_t		rx_desc_tag;
47aab5582fSPyun YongHyeon 	bus_dmamap_t		rx_desc_map;
48257c5577SDavid E. O'Brien 	bus_addr_t		physaddr;
49257c5577SDavid E. O'Brien 	struct nfe_desc32	*desc32;
50257c5577SDavid E. O'Brien 	struct nfe_desc64	*desc64;
51aab5582fSPyun YongHyeon 	bus_dma_tag_t		rx_data_tag;
52aab5582fSPyun YongHyeon 	bus_dmamap_t		rx_spare_map;
53257c5577SDavid E. O'Brien 	struct nfe_rx_data	data[NFE_RX_RING_COUNT];
54257c5577SDavid E. O'Brien 	int			cur;
55257c5577SDavid E. O'Brien 	int			next;
56257c5577SDavid E. O'Brien };
57257c5577SDavid E. O'Brien 
58aab5582fSPyun YongHyeon struct nfe_jrx_ring {
59aab5582fSPyun YongHyeon 	bus_dma_tag_t		jrx_desc_tag;
60aab5582fSPyun YongHyeon 	bus_dmamap_t		jrx_desc_map;
61aab5582fSPyun YongHyeon 	bus_dma_tag_t		jrx_jumbo_tag;
62aab5582fSPyun YongHyeon 	bus_dmamap_t		jrx_jumbo_map;
63aab5582fSPyun YongHyeon 	bus_addr_t		jphysaddr;
64aab5582fSPyun YongHyeon 	struct nfe_desc32	*jdesc32;
65aab5582fSPyun YongHyeon 	struct nfe_desc64	*jdesc64;
66aab5582fSPyun YongHyeon 	bus_dma_tag_t		jrx_data_tag;
67aab5582fSPyun YongHyeon 	bus_dmamap_t		jrx_spare_map;
68aab5582fSPyun YongHyeon 	struct nfe_rx_data	jdata[NFE_JUMBO_RX_RING_COUNT];
69aab5582fSPyun YongHyeon 	int			jcur;
70aab5582fSPyun YongHyeon 	int			jnext;
71aab5582fSPyun YongHyeon };
72aab5582fSPyun YongHyeon 
7317d022beSPyun YongHyeon struct nfe_hw_stats {
7417d022beSPyun YongHyeon 	uint64_t		rx_octets;
7517d022beSPyun YongHyeon 	uint32_t		rx_frame_errors;
7617d022beSPyun YongHyeon 	uint32_t		rx_extra_bytes;
7717d022beSPyun YongHyeon 	uint32_t		rx_late_cols;
7817d022beSPyun YongHyeon 	uint32_t		rx_runts;
7917d022beSPyun YongHyeon 	uint32_t		rx_jumbos;
8017d022beSPyun YongHyeon 	uint32_t		rx_fifo_overuns;
8117d022beSPyun YongHyeon 	uint32_t		rx_crc_errors;
8217d022beSPyun YongHyeon 	uint32_t		rx_fae;
8317d022beSPyun YongHyeon 	uint32_t		rx_len_errors;
8417d022beSPyun YongHyeon 	uint32_t		rx_unicast;
8517d022beSPyun YongHyeon 	uint32_t		rx_multicast;
8617d022beSPyun YongHyeon 	uint32_t		rx_broadcast;
8717d022beSPyun YongHyeon 	uint32_t		rx_pause;
8817d022beSPyun YongHyeon 	uint32_t		rx_drops;
8917d022beSPyun YongHyeon 	uint64_t		tx_octets;
9017d022beSPyun YongHyeon 	uint32_t		tx_zero_rexmits;
9117d022beSPyun YongHyeon 	uint32_t		tx_one_rexmits;
9217d022beSPyun YongHyeon 	uint32_t		tx_multi_rexmits;
9317d022beSPyun YongHyeon 	uint32_t		tx_late_cols;
9417d022beSPyun YongHyeon 	uint32_t		tx_fifo_underuns;
9517d022beSPyun YongHyeon 	uint32_t		tx_carrier_losts;
9617d022beSPyun YongHyeon 	uint32_t		tx_excess_deferals;
9717d022beSPyun YongHyeon 	uint32_t		tx_retry_errors;
9817d022beSPyun YongHyeon 	uint32_t		tx_deferals;
9917d022beSPyun YongHyeon 	uint32_t		tx_frames;
10017d022beSPyun YongHyeon 	uint32_t		tx_pause;
10117d022beSPyun YongHyeon 	uint32_t		tx_unicast;
10217d022beSPyun YongHyeon 	uint32_t		tx_multicast;
10317d022beSPyun YongHyeon 	uint32_t		tx_broadcast;
10417d022beSPyun YongHyeon };
10517d022beSPyun YongHyeon 
106257c5577SDavid E. O'Brien struct nfe_softc {
107*ec22a3a2SJustin Hibbits 	if_t			nfe_ifp;
108bfc788c2SDavid E. O'Brien 	device_t		nfe_dev;
109aab5582fSPyun YongHyeon 	uint16_t		nfe_devid;
110aab5582fSPyun YongHyeon 	uint16_t		nfe_revid;
111bfc788c2SDavid E. O'Brien 	device_t		nfe_miibus;
112bfc788c2SDavid E. O'Brien 	struct mtx		nfe_mtx;
113aab5582fSPyun YongHyeon 	struct resource		*nfe_res[1];
114aab5582fSPyun YongHyeon 	struct resource		*nfe_msix_res;
115aab5582fSPyun YongHyeon 	struct resource		*nfe_msix_pba_res;
116aab5582fSPyun YongHyeon 	struct resource		*nfe_irq[NFE_MSI_MESSAGES];
117aab5582fSPyun YongHyeon 	void			*nfe_intrhand[NFE_MSI_MESSAGES];
118bfc788c2SDavid E. O'Brien 	struct callout		nfe_stat_ch;
119aab5582fSPyun YongHyeon 	int			nfe_watchdog_timer;
120257c5577SDavid E. O'Brien 
121bfc788c2SDavid E. O'Brien 	bus_dma_tag_t		nfe_parent_tag;
122bfc788c2SDavid E. O'Brien 
123bfc788c2SDavid E. O'Brien 	int			nfe_if_flags;
124aab5582fSPyun YongHyeon 	uint32_t		nfe_flags;
125aab5582fSPyun YongHyeon #define	NFE_JUMBO_SUP		0x0001
126aab5582fSPyun YongHyeon #define	NFE_40BIT_ADDR		0x0002
127aab5582fSPyun YongHyeon #define	NFE_HW_CSUM		0x0004
128aab5582fSPyun YongHyeon #define	NFE_HW_VLAN		0x0008
129aab5582fSPyun YongHyeon #define	NFE_PWR_MGMT		0x0010
130aab5582fSPyun YongHyeon #define	NFE_CORRECT_MACADDR	0x0020
131aab5582fSPyun YongHyeon #define	NFE_TX_FLOW_CTRL	0x0040
13217d022beSPyun YongHyeon #define	NFE_MIB_V1		0x0080
13317d022beSPyun YongHyeon #define	NFE_MIB_V2		0x0100
13417d022beSPyun YongHyeon #define	NFE_MIB_V3		0x0200
1358b590ad2SPyun YongHyeon 	int			nfe_jumbo_disable;
136aab5582fSPyun YongHyeon 	uint32_t		rxtxctl;
137aab5582fSPyun YongHyeon 	uint8_t			mii_phyaddr;
138aab5582fSPyun YongHyeon 	uint8_t			eaddr[ETHER_ADDR_LEN];
13917d022beSPyun YongHyeon 	struct nfe_hw_stats	nfe_stats;
140aab5582fSPyun YongHyeon 	struct taskqueue	*nfe_tq;
141aab5582fSPyun YongHyeon 	struct task		nfe_int_task;
142bfc788c2SDavid E. O'Brien 	int			nfe_link;
143aab5582fSPyun YongHyeon 	int			nfe_suspended;
144aab5582fSPyun YongHyeon 	int			nfe_framesize;
145aab5582fSPyun YongHyeon 	int			nfe_process_limit;
146aab5582fSPyun YongHyeon 	int			nfe_force_tx;
147aab5582fSPyun YongHyeon 	uint32_t		nfe_irq_status;
148aab5582fSPyun YongHyeon 	uint32_t		nfe_irq_mask;
149aab5582fSPyun YongHyeon 	uint32_t		nfe_intrs;
150aab5582fSPyun YongHyeon 	uint32_t		nfe_nointrs;
151aab5582fSPyun YongHyeon 	uint32_t		nfe_msi;
152aab5582fSPyun YongHyeon 	uint32_t		nfe_msix;
153257c5577SDavid E. O'Brien 
154257c5577SDavid E. O'Brien 	struct nfe_tx_ring	txq;
155257c5577SDavid E. O'Brien 	struct nfe_rx_ring	rxq;
156aab5582fSPyun YongHyeon 	struct nfe_jrx_ring	jrxq;
157bfc788c2SDavid E. O'Brien };
158bfc788c2SDavid E. O'Brien 
159bfc788c2SDavid E. O'Brien struct nfe_type {
160aab5582fSPyun YongHyeon 	uint16_t	vid_id;
161aab5582fSPyun YongHyeon 	uint16_t	dev_id;
162bfc788c2SDavid E. O'Brien 	char		*name;
163257c5577SDavid E. O'Brien };
164