1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 1999 - 2008 Intel Corporation. */
7 #include <linux/stddef.h>
8 #include <linux/module.h>
9 #include <linux/types.h>
10 #include <asm/byteorder.h>
12 #include <linux/errno.h>
13 #include <linux/ioport.h>
14 #include <linux/pci.h>
15 #include <linux/kernel.h>
16 #include <linux/netdevice.h>
17 #include <linux/etherdevice.h>
18 #include <linux/skbuff.h>
19 #include <linux/delay.h>
20 #include <linux/timer.h>
21 #include <linux/slab.h>
22 #include <linux/vmalloc.h>
23 #include <linux/interrupt.h>
24 #include <linux/string.h>
25 #include <linux/pagemap.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/bitops.h>
30 #include <linux/capability.h>
33 #include <linux/tcp.h>
34 #include <linux/udp.h>
35 #include <net/pkt_sched.h>
36 #include <linux/list.h>
37 #include <linux/reboot.h>
38 #include <net/checksum.h>
40 #include <linux/ethtool.h>
41 #include <linux/if_vlan.h>
51 /* TX/RX descriptor defines */
52 #define DEFAULT_TXD 256
56 /* hardware cannot reliably support more than 512 descriptors owned by
57 * hardware descriptor cache otherwise an unreliable ring under heavy
58 * receive load may result */
59 #define DEFAULT_RXD 512
63 /* Supported Rx Buffer Sizes */
64 #define IXGB_RXBUFFER_2048 2048
65 #define IXGB_RXBUFFER_4096 4096
66 #define IXGB_RXBUFFER_8192 8192
67 #define IXGB_RXBUFFER_16384 16384
69 /* How many Rx Buffers do we bundle into one write to the hardware ? */
70 #define IXGB_RX_BUFFER_WRITE 8 /* Must be power of 2 */
72 /* wrapper around a pointer to a socket buffer,
73 * so a DMA handle can be stored along with the buffer */
77 unsigned long time_stamp
;
83 struct ixgb_desc_ring
{
84 /* pointer to the descriptor ring memory */
86 /* physical address of the descriptor ring */
88 /* length of descriptor ring in bytes */
90 /* number of descriptors in the ring */
92 /* next descriptor to associate a buffer with */
93 unsigned int next_to_use
;
94 /* next descriptor to check for DD status bit */
95 unsigned int next_to_clean
;
96 /* array of buffer information structs */
97 struct ixgb_buffer
*buffer_info
;
100 #define IXGB_DESC_UNUSED(R) \
101 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
102 (R)->next_to_clean - (R)->next_to_use - 1)
104 #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
105 #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
106 #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
107 #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
109 /* board specific private data structure */
111 struct ixgb_adapter
{
112 struct timer_list watchdog_timer
;
113 unsigned long active_vlans
[BITS_TO_LONGS(VLAN_N_VID
)];
119 struct work_struct tx_timeout_task
;
122 struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp
;
123 unsigned int restart_queue
;
124 unsigned long timeo_start
;
127 u64 hw_csum_tx_error
;
129 u32 tx_timeout_count
;
130 bool tx_int_delay_enable
;
134 struct ixgb_desc_ring rx_ring
;
135 u64 hw_csum_rx_error
;
140 /* OS defined structs */
141 struct napi_struct napi
;
142 struct net_device
*netdev
;
143 struct pci_dev
*pdev
;
145 /* structs defined in ixgb_hw.h */
148 struct ixgb_hw_stats stats
;
149 u32 alloc_rx_buff_failed
;
162 /* Exported from other modules */
163 void ixgb_check_options(struct ixgb_adapter
*adapter
);
164 void ixgb_set_ethtool_ops(struct net_device
*netdev
);
165 extern char ixgb_driver_name
[];
166 extern const char ixgb_driver_version
[];
168 void ixgb_set_speed_duplex(struct net_device
*netdev
);
170 int ixgb_up(struct ixgb_adapter
*adapter
);
171 void ixgb_down(struct ixgb_adapter
*adapter
, bool kill_watchdog
);
172 void ixgb_reset(struct ixgb_adapter
*adapter
);
173 int ixgb_setup_rx_resources(struct ixgb_adapter
*adapter
);
174 int ixgb_setup_tx_resources(struct ixgb_adapter
*adapter
);
175 void ixgb_free_rx_resources(struct ixgb_adapter
*adapter
);
176 void ixgb_free_tx_resources(struct ixgb_adapter
*adapter
);
177 void ixgb_update_stats(struct ixgb_adapter
*adapter
);
180 #endif /* _IXGB_H_ */