Xenomai 3.3.2
Loading...
Searching...
No Matches
e1000.h
1/*******************************************************************************
2
3
4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc., 59
18 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 The full GNU General Public License is included in this distribution in the
21 file called LICENSE.
22
23 Contact Information:
24 Linux NICS <linux.nics@intel.com>
25 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
26 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27
28*******************************************************************************/
29
30
31/* Linux PRO/1000 Ethernet Driver main header file */
32
33#ifndef _E1000_H_
34#define _E1000_H_
35
36#include <linux/stddef.h>
37#include <linux/module.h>
38#include <linux/types.h>
39#include <asm/byteorder.h>
40#include <linux/init.h>
41#include <linux/mm.h>
42#include <linux/errno.h>
43#include <linux/ioport.h>
44#include <linux/pci.h>
45#include <linux/kernel.h>
46#include <linux/netdevice.h>
47#include <linux/etherdevice.h>
48#include <linux/skbuff.h>
49#include <linux/delay.h>
50#include <linux/timer.h>
51#include <linux/slab.h>
52#include <linux/vmalloc.h>
53#include <linux/interrupt.h>
54#include <linux/string.h>
55#include <linux/pagemap.h>
56#include <linux/bitops.h>
57#include <asm/io.h>
58#include <asm/irq.h>
59#include <linux/capability.h>
60#include <linux/in.h>
61#include <linux/ip.h>
62#include <linux/tcp.h>
63#include <linux/udp.h>
64#include <net/pkt_sched.h>
65#include <linux/list.h>
66#include <linux/reboot.h>
67#ifdef NETIF_F_ISO
68#undef NETIF_F_ISO
69#endif
70
71#ifdef NETIF_F_TSO
72#include <net/checksum.h>
73#endif
74#ifdef SIOCGMIIPHY
75#include <linux/mii.h>
76#endif
77#ifdef SIOCETHTOOL
78#include <linux/ethtool.h>
79#endif
80
81#ifdef NETIF_F_HW_VLAN_TX
82#undef NETIF_F_HW_VLAN_TX
83#endif
84
85#ifdef NETIF_F_HW_VLAN_TX
86#include <linux/if_vlan.h>
87#endif
88
89// RTNET
90#include <rtnet_port.h>
91
92
93#define BAR_0 0
94#define BAR_1 1
95#define BAR_5 5
96
97#include "kcompat.h"
98#define INTEL_E1000_ETHERNET_DEVICE(device_id) {\
99 PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
100
101struct e1000_adapter;
102
103#include "e1000_hw.h"
104
105#ifdef DBG
106#define E1000_DBG(args...) pr_debug(args)
107#else
108#define E1000_DBG(args...)
109#endif
110
111#undef pr_fmt
112#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
113
114#define DPRINTK(nlevel, klevel, fmt, args...) \
115 (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
116 printk(KERN_##klevel "%s: %s: %s: " fmt, KBUILD_MODNAME, \
117 adapter->netdev->name, __FUNCTION__, ##args))
118
119#define E1000_ERR(args...) pr_err(args)
120
121#define E1000_MAX_INTR 10
122
123/* TX/RX descriptor defines */
124#define E1000_DEFAULT_TXD 256
125#define E1000_MAX_TXD 256
126#define E1000_MIN_TXD 80
127#define E1000_MAX_82544_TXD 4096
128
129#define E1000_DEFAULT_RXD 256
130#define E1000_MAX_RXD 256
131#define E1000_MIN_RXD 80
132#define E1000_MAX_82544_RXD 4096
133
134/* Supported Rx Buffer Sizes */
135#define E1000_RXBUFFER_128 128 /* Used for packet split */
136#define E1000_RXBUFFER_256 256 /* Used for packet split */
137#define E1000_RXBUFFER_512 512
138#define E1000_RXBUFFER_1024 1024
139#define E1000_RXBUFFER_2048 2048
140#define E1000_RXBUFFER_4096 4096
141#define E1000_RXBUFFER_8192 8192
142#define E1000_RXBUFFER_16384 16384
143
144/* SmartSpeed delimiters */
145#define E1000_SMARTSPEED_DOWNSHIFT 3
146#define E1000_SMARTSPEED_MAX 15
147
148/* Packet Buffer allocations */
149#define E1000_PBA_BYTES_SHIFT 0xA
150#define E1000_TX_HEAD_ADDR_SHIFT 7
151#define E1000_PBA_TX_MASK 0xFFFF0000
152
153/* Flow Control Watermarks */
154#define E1000_FC_HIGH_DIFF 0x1638 /* High: 5688 bytes below Rx FIFO size */
155#define E1000_FC_LOW_DIFF 0x1640 /* Low: 5696 bytes below Rx FIFO size */
156
157#define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
158
159/* How many Tx Descriptors do we need to call netif_wake_queue ? */
160#define E1000_TX_QUEUE_WAKE 16
161/* How many Rx Buffers do we bundle into one write to the hardware ? */
162#define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */
163
164#define AUTO_ALL_MODES 0
165#define E1000_EEPROM_82544_APM 0x0004
166#define E1000_EEPROM_ICH8_APME 0x0004
167#define E1000_EEPROM_APME 0x0400
168
169#ifndef E1000_MASTER_SLAVE
170/* Switch to override PHY master/slave setting */
171#define E1000_MASTER_SLAVE e1000_ms_hw_default
172#endif
173
174#ifdef NETIF_F_HW_VLAN_TX
175#define E1000_MNG_VLAN_NONE -1
176#endif
177/* Number of packet split data buffers (not including the header buffer) */
178#define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1
179
180/* only works for sizes that are powers of 2 */
181#define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
182
183/* wrapper around a pointer to a socket buffer,
184 * so a DMA handle can be stored along with the buffer */
185struct e1000_buffer {
186 struct rtskb *skb;
187 dma_addr_t dma;
188 unsigned long time_stamp;
189 uint16_t length;
190 uint16_t next_to_watch;
191};
192
193
194struct e1000_ps_page { struct page *ps_page[PS_PAGE_BUFFERS]; };
195struct e1000_ps_page_dma { uint64_t ps_page_dma[PS_PAGE_BUFFERS]; };
196
197struct e1000_tx_ring {
198 /* pointer to the descriptor ring memory */
199 void *desc;
200 /* physical address of the descriptor ring */
201 dma_addr_t dma;
202 /* length of descriptor ring in bytes */
203 unsigned int size;
204 /* number of descriptors in the ring */
205 unsigned int count;
206 /* next descriptor to associate a buffer with */
207 unsigned int next_to_use;
208 /* next descriptor to check for DD status bit */
209 unsigned int next_to_clean;
210 /* array of buffer information structs */
211 struct e1000_buffer *buffer_info;
212
213 rtdm_lock_t tx_lock;
214 uint16_t tdh;
215 uint16_t tdt;
216 boolean_t last_tx_tso;
217};
218
219struct e1000_rx_ring {
220 /* pointer to the descriptor ring memory */
221 void *desc;
222 /* physical address of the descriptor ring */
223 dma_addr_t dma;
224 /* length of descriptor ring in bytes */
225 unsigned int size;
226 /* number of descriptors in the ring */
227 unsigned int count;
228 /* next descriptor to associate a buffer with */
229 unsigned int next_to_use;
230 /* next descriptor to check for DD status bit */
231 unsigned int next_to_clean;
232 /* array of buffer information structs */
233 struct e1000_buffer *buffer_info;
234 /* arrays of page information for packet split */
235 struct e1000_ps_page *ps_page;
236 struct e1000_ps_page_dma *ps_page_dma;
237
238 /* cpu for rx queue */
239 int cpu;
240
241 uint16_t rdh;
242 uint16_t rdt;
243};
244
245#define E1000_DESC_UNUSED(R) \
246 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
247 (R)->next_to_clean - (R)->next_to_use - 1)
248
249#define E1000_RX_DESC_PS(R, i) \
250 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
251#define E1000_RX_DESC_EXT(R, i) \
252 (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
253#define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
254#define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc)
255#define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
256#define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc)
257
258/* board specific private data structure */
259
260struct e1000_adapter {
261#ifdef NETIF_F_HW_VLAN_TX
262 struct vlan_group *vlgrp;
263 uint16_t mng_vlan_id;
264#endif
265 uint32_t bd_number;
266 uint32_t rx_buffer_len;
267 uint32_t part_num;
268 uint32_t wol;
269 uint32_t ksp3_port_a;
270 uint32_t smartspeed;
271 uint32_t en_mng_pt;
272 uint16_t link_speed;
273 uint16_t link_duplex;
274#ifdef CONFIG_E1000_NAPI
275 spinlock_t tx_queue_lock;
276#endif
277 atomic_t irq_sem;
278 struct work_struct reset_task;
279 uint8_t fc_autoneg;
280
281#ifdef ETHTOOL_PHYS_ID
282 struct timer_list blink_timer;
283 unsigned long led_status;
284#endif
285
286 /* TX */
287 struct e1000_tx_ring *tx_ring; /* One per active queue */
288 unsigned long tx_queue_len;
289 uint32_t txd_cmd;
290 uint32_t tx_int_delay;
291 uint32_t tx_abs_int_delay;
292 uint32_t gotcl;
293 uint64_t gotcl_old;
294 uint64_t tpt_old;
295 uint64_t colc_old;
296 uint32_t tx_timeout_count;
297 uint32_t tx_fifo_head;
298 uint32_t tx_head_addr;
299 uint32_t tx_fifo_size;
300 uint8_t tx_timeout_factor;
301 atomic_t tx_fifo_stall;
302 boolean_t pcix_82544;
303 boolean_t detect_tx_hung;
304
305 /* RX */
306#ifdef CONFIG_E1000_NAPI
307 boolean_t (*clean_rx) (struct e1000_adapter *adapter,
308 struct e1000_rx_ring *rx_ring,
309 int *work_done, int work_to_do);
310#else
311 boolean_t (*clean_rx) (struct e1000_adapter *adapter,
312 struct e1000_rx_ring *rx_ring);
313#endif
314 void (*alloc_rx_buf) (struct e1000_adapter *adapter,
315 struct e1000_rx_ring *rx_ring,
316 int cleaned_count);
317 struct e1000_rx_ring *rx_ring; /* One per active queue */
318#ifdef CONFIG_E1000_NAPI
319 struct net_device *polling_netdev; /* One per active queue */
320#endif
321 int num_tx_queues;
322 int num_rx_queues;
323
324 uint64_t hw_csum_err;
325 uint64_t hw_csum_good;
326 uint64_t rx_hdr_split;
327 uint32_t alloc_rx_buff_failed;
328 uint32_t rx_int_delay;
329 uint32_t rx_abs_int_delay;
330 boolean_t rx_csum;
331 unsigned int rx_ps_pages;
332 uint32_t gorcl;
333 uint64_t gorcl_old;
334 uint16_t rx_ps_bsize0;
335
336 /* Interrupt Throttle Rate */
337 uint32_t itr;
338
339 /* OS defined structs */
340 struct rtnet_device *netdev;
341 struct pci_dev *pdev;
342 struct net_device_stats net_stats;
343
344 rtdm_irq_t irq_handle;
345 boolean_t data_received;
346
347 /* structs defined in e1000_hw.h */
348 struct e1000_hw hw;
349 struct e1000_hw_stats stats;
350 struct e1000_phy_info phy_info;
351 struct e1000_phy_stats phy_stats;
352
353#ifdef ETHTOOL_TEST
354 uint32_t test_icr;
355 struct e1000_tx_ring test_tx_ring;
356 struct e1000_rx_ring test_rx_ring;
357#endif
358
359#ifdef E1000_COUNT_ICR
360 uint64_t icr_txdw;
361 uint64_t icr_txqe;
362 uint64_t icr_lsc;
363 uint64_t icr_rxseq;
364 uint64_t icr_rxdmt;
365 uint64_t icr_rxo;
366 uint64_t icr_rxt;
367 uint64_t icr_mdac;
368 uint64_t icr_rxcfg;
369 uint64_t icr_gpi;
370#endif
371
372 uint32_t *config_space;
373 int msg_enable;
374#ifdef CONFIG_PCI_MSI
375 boolean_t have_msi;
376#endif
377 /* to not mess up cache alignment, always add to the bottom */
378#ifdef NETIF_F_TSO
379 boolean_t tso_force;
380#endif
381 boolean_t smart_power_down; /* phy smart power down */
382 unsigned long flags;
383
384 struct delayed_work watchdog_task;
385 struct delayed_work fifo_stall_task;
386 struct delayed_work phy_info_task;
387};
388
389enum e1000_state_t {
390 __E1000_DRIVER_TESTING,
391 __E1000_RESETTING,
392};
393
394void e1000_check_options(struct e1000_adapter *adapter);
395#endif /* _E1000_H_ */
pipeline_spinlock_t rtdm_lock_t
Lock variable.
Definition driver.h:552
Copyright © 2011 Gilles Chanteperdrix gilles.chanteperdrix@xenomai.org.
Definition atomic.h:24