Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright(c) 1999 - 2008 Intel Corporation. */
3
4#ifndef _IXGB_H_
5#define _IXGB_H_
6
7#include <linux/stddef.h>
8#include <linux/module.h>
9#include <linux/types.h>
10#include <asm/byteorder.h>
11#include <linux/mm.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>
28#include <asm/io.h>
29#include <asm/irq.h>
30#include <linux/capability.h>
31#include <linux/in.h>
32#include <linux/ip.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>
39
40#include <linux/ethtool.h>
41#include <linux/if_vlan.h>
42
43#define BAR_0 0
44#define BAR_1 1
45
46struct ixgb_adapter;
47#include "ixgb_hw.h"
48#include "ixgb_ee.h"
49#include "ixgb_ids.h"
50
51/* TX/RX descriptor defines */
52#define DEFAULT_TXD 256
53#define MAX_TXD 4096
54#define MIN_TXD 64
55
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
60#define MAX_RXD 512
61#define MIN_RXD 64
62
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
68
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 */
71
72/* wrapper around a pointer to a socket buffer,
73 * so a DMA handle can be stored along with the buffer */
74struct ixgb_buffer {
75 struct sk_buff *skb;
76 dma_addr_t dma;
77 unsigned long time_stamp;
78 u16 length;
79 u16 next_to_watch;
80 u16 mapped_as_page;
81};
82
83struct ixgb_desc_ring {
84 /* pointer to the descriptor ring memory */
85 void *desc;
86 /* physical address of the descriptor ring */
87 dma_addr_t dma;
88 /* length of descriptor ring in bytes */
89 unsigned int size;
90 /* number of descriptors in the ring */
91 unsigned int count;
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;
98};
99
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)
103
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)
108
109/* board specific private data structure */
110
111struct ixgb_adapter {
112 struct timer_list watchdog_timer;
113 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
114 u32 bd_number;
115 u32 rx_buffer_len;
116 u32 part_num;
117 u16 link_speed;
118 u16 link_duplex;
119 struct work_struct tx_timeout_task;
120
121 /* TX */
122 struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
123 unsigned int restart_queue;
124 unsigned long timeo_start;
125 u32 tx_cmd_type;
126 u64 hw_csum_tx_good;
127 u64 hw_csum_tx_error;
128 u32 tx_int_delay;
129 u32 tx_timeout_count;
130 bool tx_int_delay_enable;
131 bool detect_tx_hung;
132
133 /* RX */
134 struct ixgb_desc_ring rx_ring;
135 u64 hw_csum_rx_error;
136 u64 hw_csum_rx_good;
137 u32 rx_int_delay;
138 bool rx_csum;
139
140 /* OS defined structs */
141 struct napi_struct napi;
142 struct net_device *netdev;
143 struct pci_dev *pdev;
144
145 /* structs defined in ixgb_hw.h */
146 struct ixgb_hw hw;
147 u16 msg_enable;
148 struct ixgb_hw_stats stats;
149 u32 alloc_rx_buff_failed;
150 bool have_msi;
151 unsigned long flags;
152};
153
154enum ixgb_state_t {
155 /* TBD
156 __IXGB_TESTING,
157 __IXGB_RESETTING,
158 */
159 __IXGB_DOWN
160};
161
162/* Exported from other modules */
163void ixgb_check_options(struct ixgb_adapter *adapter);
164void ixgb_set_ethtool_ops(struct net_device *netdev);
165extern char ixgb_driver_name[];
166
167void ixgb_set_speed_duplex(struct net_device *netdev);
168
169int ixgb_up(struct ixgb_adapter *adapter);
170void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
171void ixgb_reset(struct ixgb_adapter *adapter);
172int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
173int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
174void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
175void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
176void ixgb_update_stats(struct ixgb_adapter *adapter);
177
178
179#endif /* _IXGB_H_ */
1/*******************************************************************************
2
3 Intel PRO/10GbE Linux driver
4 Copyright(c) 1999 - 2008 Intel Corporation.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28
29#ifndef _IXGB_H_
30#define _IXGB_H_
31
32#include <linux/stddef.h>
33#include <linux/module.h>
34#include <linux/types.h>
35#include <asm/byteorder.h>
36#include <linux/mm.h>
37#include <linux/errno.h>
38#include <linux/ioport.h>
39#include <linux/pci.h>
40#include <linux/kernel.h>
41#include <linux/netdevice.h>
42#include <linux/etherdevice.h>
43#include <linux/skbuff.h>
44#include <linux/delay.h>
45#include <linux/timer.h>
46#include <linux/slab.h>
47#include <linux/vmalloc.h>
48#include <linux/interrupt.h>
49#include <linux/string.h>
50#include <linux/pagemap.h>
51#include <linux/dma-mapping.h>
52#include <linux/bitops.h>
53#include <asm/io.h>
54#include <asm/irq.h>
55#include <linux/capability.h>
56#include <linux/in.h>
57#include <linux/ip.h>
58#include <linux/tcp.h>
59#include <linux/udp.h>
60#include <net/pkt_sched.h>
61#include <linux/list.h>
62#include <linux/reboot.h>
63#include <net/checksum.h>
64
65#include <linux/ethtool.h>
66#include <linux/if_vlan.h>
67
68#define BAR_0 0
69#define BAR_1 1
70#define BAR_5 5
71
72struct ixgb_adapter;
73#include "ixgb_hw.h"
74#include "ixgb_ee.h"
75#include "ixgb_ids.h"
76
77/* TX/RX descriptor defines */
78#define DEFAULT_TXD 256
79#define MAX_TXD 4096
80#define MIN_TXD 64
81
82/* hardware cannot reliably support more than 512 descriptors owned by
83 * hardware descriptor cache otherwise an unreliable ring under heavy
84 * receive load may result */
85#define DEFAULT_RXD 512
86#define MAX_RXD 512
87#define MIN_RXD 64
88
89/* Supported Rx Buffer Sizes */
90#define IXGB_RXBUFFER_2048 2048
91#define IXGB_RXBUFFER_4096 4096
92#define IXGB_RXBUFFER_8192 8192
93#define IXGB_RXBUFFER_16384 16384
94
95/* How many Rx Buffers do we bundle into one write to the hardware ? */
96#define IXGB_RX_BUFFER_WRITE 8 /* Must be power of 2 */
97
98/* wrapper around a pointer to a socket buffer,
99 * so a DMA handle can be stored along with the buffer */
100struct ixgb_buffer {
101 struct sk_buff *skb;
102 dma_addr_t dma;
103 unsigned long time_stamp;
104 u16 length;
105 u16 next_to_watch;
106 u16 mapped_as_page;
107};
108
109struct ixgb_desc_ring {
110 /* pointer to the descriptor ring memory */
111 void *desc;
112 /* physical address of the descriptor ring */
113 dma_addr_t dma;
114 /* length of descriptor ring in bytes */
115 unsigned int size;
116 /* number of descriptors in the ring */
117 unsigned int count;
118 /* next descriptor to associate a buffer with */
119 unsigned int next_to_use;
120 /* next descriptor to check for DD status bit */
121 unsigned int next_to_clean;
122 /* array of buffer information structs */
123 struct ixgb_buffer *buffer_info;
124};
125
126#define IXGB_DESC_UNUSED(R) \
127 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
128 (R)->next_to_clean - (R)->next_to_use - 1)
129
130#define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
131#define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
132#define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
133#define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
134
135/* board specific private data structure */
136
137struct ixgb_adapter {
138 struct timer_list watchdog_timer;
139 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
140 u32 bd_number;
141 u32 rx_buffer_len;
142 u32 part_num;
143 u16 link_speed;
144 u16 link_duplex;
145 struct work_struct tx_timeout_task;
146
147 /* TX */
148 struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
149 unsigned int restart_queue;
150 unsigned long timeo_start;
151 u32 tx_cmd_type;
152 u64 hw_csum_tx_good;
153 u64 hw_csum_tx_error;
154 u32 tx_int_delay;
155 u32 tx_timeout_count;
156 bool tx_int_delay_enable;
157 bool detect_tx_hung;
158
159 /* RX */
160 struct ixgb_desc_ring rx_ring;
161 u64 hw_csum_rx_error;
162 u64 hw_csum_rx_good;
163 u32 rx_int_delay;
164 bool rx_csum;
165
166 /* OS defined structs */
167 struct napi_struct napi;
168 struct net_device *netdev;
169 struct pci_dev *pdev;
170
171 /* structs defined in ixgb_hw.h */
172 struct ixgb_hw hw;
173 u16 msg_enable;
174 struct ixgb_hw_stats stats;
175 u32 alloc_rx_buff_failed;
176 bool have_msi;
177 unsigned long flags;
178};
179
180enum ixgb_state_t {
181 /* TBD
182 __IXGB_TESTING,
183 __IXGB_RESETTING,
184 */
185 __IXGB_DOWN
186};
187
188/* Exported from other modules */
189void ixgb_check_options(struct ixgb_adapter *adapter);
190void ixgb_set_ethtool_ops(struct net_device *netdev);
191extern char ixgb_driver_name[];
192extern const char ixgb_driver_version[];
193
194void ixgb_set_speed_duplex(struct net_device *netdev);
195
196int ixgb_up(struct ixgb_adapter *adapter);
197void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
198void ixgb_reset(struct ixgb_adapter *adapter);
199int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
200int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
201void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
202void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
203void ixgb_update_stats(struct ixgb_adapter *adapter);
204
205
206#endif /* _IXGB_H_ */