xref: /titanic_41/usr/src/uts/common/xen/io/xnf.h (revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_XNF_H
28 #define	_SYS_XNF_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define	NET_TX_RING_SIZE  __RING_SIZE((netif_tx_sring_t *)0, PAGESIZE)
35 #define	NET_RX_RING_SIZE  __RING_SIZE((netif_rx_sring_t *)0, PAGESIZE)
36 
37 #define	XNF_MAXPKT	1500		/* MTU size */
38 #define	XNF_FRAMESIZE	1514		/* frame size including MAC header */
39 
40 #define	XNF_MAX_RXDESCS	256
41 
42 #define	MCAST_HASHBITS		256
43 
44 extern int	xnf_diagnose;	/* Available for use any time. */
45 
46 /* Flags to set in the global xnf_diagnose */
47 #define	XNF_DIAG_RX		0x01
48 #define	XNF_DIAG_TX		0x02
49 #define	XNF_DIAG_STATS		0x04
50 #define	XNF_DIAG_RX_BUFS	0x08
51 
52 /* DEBUG flags */
53 #define	XNF_DEBUG_DDI		0x01
54 #define	XNF_DEBUG_TRACE		0x02
55 #define	XNF_DEBUG_SEND		0x04
56 #define	XNF_DEBUG_INT		0x08
57 
58 #define	XNF_DESC_ALIGN		8
59 
60 
61 /* Info pertaining to each xmit/receive buffer */
62 struct xnf_buffer_desc {
63 	frtn_t			free_rtn;	/* desballoc() structure */
64 	struct xnf		*xnfp;
65 	ddi_dma_handle_t	dma_handle;
66 	caddr_t			buf;		/* DMA-able data buffer */
67 	paddr_t			buf_phys;
68 	struct xnf_buffer_desc	*next;	/* For linking into free list */
69 	ddi_acc_handle_t	acc_handle;
70 	grant_ref_t		grant_ref;	/* grant table reference */
71 	uint16_t		id;		/* buffer id */
72 };
73 
74 /* Various information about each transmit packet */
75 struct tx_pktinfo {
76 	mblk_t			*mp;	/* mblk associated with packet */
77 	ddi_dma_handle_t	dma_handle;
78 	struct xnf_buffer_desc	*bdesc; /* pointer to buffer descriptor */
79 	grant_ref_t		grant_ref;	/* grant table reference */
80 	uint16_t		id;	/* tx pkt id/free list next pointer */
81 };
82 
83 /* Per network-interface-controller driver private structure */
84 typedef struct xnf {
85 	/* most interesting stuff first to assist debugging */
86 	dev_info_t		*xnf_devinfo;	/* System per-device info. */
87 	mac_handle_t		xnf_mh;		/* Nemo per-device info. */
88 	int			xnf_rx_bufs_outstanding;
89 	int			xnf_tx_descs_free;
90 	int			xnf_rx_descs_free; /* count of free rx bufs */
91 	int			xnf_n_tx;	/* No. xmit descriptors */
92 	int			xnf_n_rx;	/* No. recv descriptors */
93 	int			xnf_n_rx_bufs;	/* No. recv DMA buffers */
94 	int			xnf_tx_start_thresh_regval;
95 	unsigned char		xnf_mac_addr[ETHERADDRL];
96 	int			xnf_max_rx_bufs;
97 	int			xnf_rx_buffer_count;
98 	int			xnf_tx_buffer_count;
99 
100 	boolean_t		xnf_connected;
101 	boolean_t		xnf_running;
102 
103 	boolean_t		xnf_cksum_offload;
104 
105 	uint64_t		xnf_stat_interrupts;
106 	uint64_t		xnf_stat_unclaimed_interrupts;
107 	uint64_t		xnf_stat_norxbuf;
108 	uint64_t		xnf_stat_drop;
109 	uint64_t		xnf_stat_errrx;
110 
111 	uint64_t		xnf_stat_tx_attempt;
112 	uint64_t		xnf_stat_tx_pullup;
113 	uint64_t		xnf_stat_tx_pagebndry;
114 	uint64_t		xnf_stat_tx_defer;
115 	uint64_t		xnf_stat_rx_no_ringbuf;
116 	uint64_t		xnf_stat_mac_rcv_error;
117 	uint64_t		xnf_stat_runt;
118 
119 	uint64_t		xnf_stat_ipackets;
120 	uint64_t		xnf_stat_opackets;
121 	uint64_t		xnf_stat_rbytes;
122 	uint64_t		xnf_stat_obytes;
123 
124 	uint64_t		xnf_stat_tx_cksum_deferred;
125 	uint64_t		xnf_stat_rx_cksum_no_need;
126 	uint64_t		xnf_stat_hvcopy_enabled; /* on/off */
127 	uint64_t		xnf_stat_hvcopy_packet_processed;
128 
129 	kstat_t			*xnf_kstat_aux;
130 
131 	struct xnf_buffer_desc	*xnf_free_list;
132 	struct xnf_buffer_desc	*xnf_tx_free_list;
133 	int			xnf_tx_pkt_id_list;
134 				/* free list of avail pkt ids */
135 	struct tx_pktinfo	xnf_tx_pkt_info[NET_TX_RING_SIZE];
136 	struct xnf_buffer_desc	*xnf_rxpkt_bufptr[XNF_MAX_RXDESCS];
137 
138 	ddi_iblock_cookie_t	xnf_icookie;
139 	kmutex_t		xnf_tx_buf_mutex;
140 	kmutex_t		xnf_rx_buf_mutex;
141 	kmutex_t		xnf_txlock;
142 	kmutex_t		xnf_intrlock;
143 	boolean_t		xnf_tx_pages_readonly;
144 	boolean_t		xnf_need_sched;
145 
146 	netif_tx_front_ring_t	xnf_tx_ring;	/* tx interface struct ptr */
147 	ddi_dma_handle_t	xnf_tx_ring_dma_handle;
148 	ddi_acc_handle_t	xnf_tx_ring_dma_acchandle;
149 	paddr_t			xnf_tx_ring_phys_addr;
150 	grant_ref_t		xnf_tx_ring_ref;
151 
152 	netif_rx_front_ring_t	xnf_rx_ring;	/* rx interface struct ptr */
153 	ddi_dma_handle_t	xnf_rx_ring_dma_handle;
154 	ddi_acc_handle_t	xnf_rx_ring_dma_acchandle;
155 	paddr_t			xnf_rx_ring_phys_addr;
156 	grant_ref_t		xnf_rx_ring_ref;
157 
158 	uint16_t		xnf_evtchn;	/* channel to back end ctlr */
159 	grant_ref_t		xnf_gref_tx_head;	/* tx grant free list */
160 	grant_ref_t		xnf_gref_rx_head;	/* rx grant free list */
161 	kcondvar_t		xnf_cv;
162 
163 	boolean_t		xnf_rx_hvcopy;	/* do we do HV copy? */
164 } xnf_t;
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif	/* _SYS_XNF_H */
171