if_ixgb.h revision 1.8
10SN/A/**************************************************************************
20SN/A
30SN/ACopyright (c) 2001-2005, Intel Corporation
40SN/AAll rights reserved.
50SN/A
62362SN/ARedistribution and use in source and binary forms, with or without
70SN/Amodification, are permitted provided that the following conditions are met:
82362SN/A
90SN/A 1. Redistributions of source code must retain the above copyright notice,
100SN/A    this list of conditions and the following disclaimer.
110SN/A
120SN/A 2. Redistributions in binary form must reproduce the above copyright
130SN/A    notice, this list of conditions and the following disclaimer in the
140SN/A    documentation and/or other materials provided with the distribution.
150SN/A
160SN/A 3. Neither the name of the Intel Corporation nor the names of its
170SN/A    contributors may be used to endorse or promote products derived from
180SN/A    this software without specific prior written permission.
190SN/A
202362SN/ATHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
212362SN/AAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
222362SN/AIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
230SN/AARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
240SN/ALIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
250SN/ACONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
260SN/ASUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
270SN/AINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
280SN/ACONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
290SN/AARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
300SN/APOSSIBILITY OF SUCH DAMAGE.
310SN/A
320SN/A***************************************************************************/
330SN/A
340SN/A/* $OpenBSD: if_ixgb.h,v 1.8 2006/08/04 14:25:24 brad Exp $ */
350SN/A
360SN/A#ifndef _IXGB_H_DEFINED_
370SN/A#define _IXGB_H_DEFINED_
380SN/A
390SN/A#include "bpfilter.h"
400SN/A#include "vlan.h"
411693SN/A
421693SN/A#include <sys/param.h>
431693SN/A#include <sys/systm.h>
441693SN/A#include <sys/sockio.h>
450SN/A#include <sys/mbuf.h>
460SN/A#include <sys/malloc.h>
470SN/A#include <sys/kernel.h>
480SN/A#include <sys/device.h>
496936SN/A#include <sys/socket.h>
506936SN/A
510SN/A#include <net/if.h>
526936SN/A#include <net/if_dl.h>
536936SN/A#include <net/if_media.h>
540SN/A
550SN/A#ifdef INET
560SN/A#include <netinet/in.h>
570SN/A#include <netinet/in_systm.h>
580SN/A#include <netinet/in_var.h>
590SN/A#include <netinet/ip.h>
606936SN/A#include <netinet/if_ether.h>
610SN/A#include <netinet/tcp.h>
620SN/A#include <netinet/udp.h>
630SN/A#endif
640SN/A
650SN/A#if NVLAN > 0
6612949Sprr#include <net/if_types.h>
6712949Sprr#include <net/if_vlan_var.h>
680SN/A#endif
690SN/A
706936SN/A#if NBPFILTER > 0
710SN/A#include <net/bpf.h>
720SN/A#endif
730SN/A
740SN/A#include <uvm/uvm_extern.h>
750SN/A
760SN/A#include <dev/pci/pcireg.h>
776936SN/A#include <dev/pci/pcivar.h>
789741SN/A#include <dev/pci/pcidevs.h>
796936SN/A
806936SN/A#include <dev/pci/ixgb_hw.h>
810SN/A#include <dev/pci/ixgb_ee.h>
820SN/A#include <dev/pci/ixgb_ids.h>
830SN/A
840SN/A/* Tunables */
851693SN/A
861693SN/A/*
87 * TxDescriptors Valid Range: 64-4096 Default Value: 2048 This value is the
88 * number of transmit descriptors allocated by the driver. Increasing this
89 * value allows the driver to queue more transmits. Each descriptor is 16
90 * bytes.
91 */
92#define IXGB_MAX_TXD			2048
93
94/*
95 * RxDescriptors Valid Range: 64-4096 Default Value: 1024 This value is the
96 * number of receive descriptors allocated by the driver. Increasing this
97 * value allows the driver to buffer more incoming packets. Each descriptor
98 * is 16 bytes.  A receive buffer is also allocated for each descriptor. The
99 * maximum MTU size is 16110.
100 */
101#define IXGB_MAX_RXD			1024
102
103/*
104 * TxIntDelay Valid Range: 0-65535 (0=off) Default Value: 32 This value
105 * delays the generation of transmit interrupts in units of 1.024
106 * microseconds. Transmit interrupt reduction can improve CPU efficiency if
107 * properly tuned for specific network traffic. If the system is reporting
108 * dropped transmits, this value may be set too high causing the driver to
109 * run out of available transmit descriptors.
110 */
111#define TIDV				32
112
113/*
114 * RxIntDelay Valid Range: 0-65535 (0=off) Default Value: 72 This value
115 * delays the generation of receive interrupts in units of 1.024
116 * microseconds.  Receive interrupt reduction can improve CPU efficiency if
117 * properly tuned for specific network traffic. Increasing this value adds
118 * extra latency to frame reception and can end up decreasing the throughput
119 * of TCP traffic. If the system is reporting dropped receives, this value
120 * may be set too high, causing the driver to run out of available receive
121 * descriptors.
122 */
123#define RDTR				72
124
125/*
126 * This parameter controls the duration of transmit watchdog timer.
127 */
128#define IXGB_TX_TIMEOUT			5	/* set to 5 seconds */
129
130/*
131 * This parameter controls when the driver calls the routine to reclaim
132 * transmit descriptors.
133 */
134#define IXGB_TX_CLEANUP_THRESHOLD	(sc->num_tx_desc / 8)
135
136/*
137 * Flow Control Types.
138 * 1. ixgb_fc_none - Flow Control Disabled
139 * 2. ixgb_fc_rx_pause - Flow Control Receive Only
140 * 3. ixgb_fc_tx_pause - Flow Control Transmit Only
141 * 4. ixgb_fc_full - Flow Control Enabled
142 */
143#define FLOW_CONTROL_NONE	ixgb_fc_none
144#define FLOW_CONTROL_RX_PAUSE	ixgb_fc_rx_pause
145#define FLOW_CONTROL_TX_PAUSE	ixgb_fc_tx_pause
146#define FLOW_CONTROL_FULL	ixgb_fc_full
147
148/*
149 * Set the flow control type. Assign one of the above flow control types to be enabled.
150 * Default Value: FLOW_CONTROL_FULL
151 */
152#define FLOW_CONTROL		FLOW_CONTROL_FULL
153
154/*
155 * Receive Flow control low threshold (when we send a resume frame) (FCRTL)
156 * Valid Range: 64 - 262,136 (0x40 - 0x3FFF8, 8 byte granularity) must be
157 * less than high threshold by at least 8 bytes Default Value:  163,840
158 * (0x28000)
159 */
160#define FCRTL			0x28000
161
162/*
163 * Receive Flow control high threshold (when we send a pause frame) (FCRTH)
164 * Valid Range: 1,536 - 262,136 (0x600 - 0x3FFF8, 8 byte granularity) Default
165 * Value: 196,608 (0x30000)
166 */
167#define FCRTH			0x30000
168
169/*
170 * Flow control request timeout (how long to pause the link partner's tx)
171 * (PAP 15:0) Valid Range: 1 - 65535 Default Value:  256 (0x100)
172 */
173#define FCPAUSE			0x100
174
175/* Tunables -- End */
176
177#define IXGB_MMBA		0x0010	/* Mem base address */
178#define IXGB_ROUNDUP(size, unit) (((size) + (unit) - 1) & ~((unit) - 1))
179
180#define MAX_NUM_MULTICAST_ADDRESSES	128
181
182/* Defines for printing debug information */
183#define DEBUG_INIT	0
184#define DEBUG_IOCTL	0
185#define DEBUG_HW	0
186
187#define INIT_DEBUGOUT(S)		if (DEBUG_INIT)  printf(S "\n")
188#define INIT_DEBUGOUT1(S, A)		if (DEBUG_INIT)  printf(S "\n", A)
189#define INIT_DEBUGOUT2(S, A, B)		if (DEBUG_INIT)  printf(S "\n", A, B)
190#define IOCTL_DEBUGOUT(S)		if (DEBUG_IOCTL) printf(S "\n")
191#define IOCTL_DEBUGOUT1(S, A)		if (DEBUG_IOCTL) printf(S "\n", A)
192#define IOCTL_DEBUGOUT2(S, A, B)	if (DEBUG_IOCTL) printf(S "\n", A, B)
193#define HW_DEBUGOUT(S)			if (DEBUG_HW) printf(S "\n")
194#define HW_DEBUGOUT1(S, A)		if (DEBUG_HW) printf(S "\n", A)
195#define HW_DEBUGOUT2(S, A, B)		if (DEBUG_HW) printf(S "\n", A, B)
196
197/* Supported RX Buffer Sizes */
198#define IXGB_RXBUFFER_2048	2048
199#define IXGB_RXBUFFER_4096	4096
200#define IXGB_RXBUFFER_8192	8192
201#define IXGB_RXBUFFER_16384	16384
202
203#define IXGB_MAX_SCATTER	100
204
205struct ixgb_buffer {
206	struct mbuf    *m_head;
207	bus_dmamap_t    map;	/* bus_dma map for packet */
208};
209
210struct ixgb_q {
211	bus_dmamap_t    map;	/* bus_dma map for packet */
212};
213
214/*
215 * Bus dma allocation structure used by
216 * ixgb_dma_malloc and ixgb_dma_free.
217 */
218struct ixgb_dma_alloc {
219	bus_addr_t		dma_paddr;
220	caddr_t			dma_vaddr;
221	bus_dma_tag_t		dma_tag;
222	bus_dmamap_t		dma_map;
223	bus_dma_segment_t	dma_seg;
224	bus_size_t		dma_size;
225	int			dma_nseg;
226};
227
228typedef enum _XSUM_CONTEXT_T {
229	OFFLOAD_NONE,
230	OFFLOAD_TCP_IP,
231	OFFLOAD_UDP_IP
232} XSUM_CONTEXT_T;
233
234/* Our adapter structure */
235struct ixgb_softc {
236	struct device	sc_dv;
237	struct arpcom	interface_data;
238	struct ixgb_hw	hw;
239
240	/* OpenBSD operating-system-specific structures */
241	struct ixgb_osdep osdep;
242	struct ifmedia	media;
243	int		io_rid;
244
245	void		*sc_intrhand;
246	struct timeout	ixgb_intr_enable;
247	struct timeout	timer_handle;
248	int		if_flags;
249	void		*sc_powerhook;
250	void		*sc_shutdownhook;
251
252	/* Info about the board itself */
253	u_int32_t	part_num;
254	u_int8_t	link_active;
255	u_int16_t	link_speed;
256	u_int16_t	link_duplex;
257	u_int32_t	tx_int_delay;
258	u_int32_t	tx_abs_int_delay;
259	u_int32_t	rx_int_delay;
260	u_int32_t	rx_abs_int_delay;
261
262	int		raidc;
263
264	XSUM_CONTEXT_T	active_checksum_context;
265
266	/*
267	 * Transmit definitions
268	 *
269	 * We have an array of num_tx_desc descriptors (handled by the
270	 * controller) paired with an array of tx_buffers (at
271	 * tx_buffer_area). The index of the next available descriptor is
272	 * next_avail_tx_desc. The number of remaining tx_desc is
273	 * num_tx_desc_avail.
274	 */
275	struct ixgb_dma_alloc	txdma;		/* bus_dma glue for tx desc */
276	struct ixgb_tx_desc	*tx_desc_base;
277	u_int32_t		next_avail_tx_desc;
278	u_int32_t		oldest_used_tx_desc;
279	volatile u_int16_t	num_tx_desc_avail;
280	u_int16_t		num_tx_desc;
281	u_int32_t		txd_cmd;
282	struct ixgb_buffer	*tx_buffer_area;
283	bus_dma_tag_t		txtag;		/* dma tag for tx */
284
285	/*
286	 * Receive definitions
287	 *
288	 * we have an array of num_rx_desc rx_desc (handled by the controller),
289	 * and paired with an array of rx_buffers (at rx_buffer_area). The
290	 * next pair to check on receive is at offset next_rx_desc_to_check
291	 */
292	struct ixgb_dma_alloc	rxdma;		/* bus_dma glue for rx desc */
293	struct ixgb_rx_desc	*rx_desc_base;
294	u_int32_t		next_rx_desc_to_check;
295	u_int16_t		num_rx_desc;
296	u_int32_t		rx_buffer_len;
297	struct ixgb_buffer	*rx_buffer_area;
298	bus_dma_tag_t		rxtag;		/* dma tag for Rx */
299	u_int32_t		next_rx_desc_to_use;
300
301	/* Jumbo frame */
302	struct mbuf		*fmp;
303	struct mbuf		*lmp;
304
305	/* Misc stats maintained by the driver */
306	unsigned long		dropped_pkts;
307	unsigned long		mbuf_alloc_failed;
308	unsigned long		mbuf_cluster_failed;
309	unsigned long		no_tx_desc_avail1;
310	unsigned long		no_tx_desc_avail2;
311	unsigned long		no_tx_map_avail;
312	unsigned long		no_tx_dma_setup;
313	unsigned long		watchdog_events;
314
315	struct ixgb_hw_stats	stats;
316};
317
318#endif /* _IXGB_H_DEFINED_ */
319