Xenomai  3.0.8
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 
101 struct e1000_adapter;
102 
103 #include "e1000_hw.h"
104 
105 #ifdef DBG
106 #define E1000_DBG(args...) printk(KERN_DEBUG "e1000: " args)
107 #else
108 #define E1000_DBG(args...)
109 #endif
110 
111 #define E1000_ERR(args...) printk(KERN_ERR "e1000: " args)
112 
113 #define PFX "e1000: "
114 #define DPRINTK(nlevel, klevel, fmt, args...) \
115  (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
116  printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
117  __FUNCTION__ , ## args))
118 
119 #define E1000_MAX_INTR 10
120 
121 /* TX/RX descriptor defines */
122 #define E1000_DEFAULT_TXD 256
123 #define E1000_MAX_TXD 256
124 #define E1000_MIN_TXD 80
125 #define E1000_MAX_82544_TXD 4096
126 
127 #define E1000_DEFAULT_RXD 256
128 #define E1000_MAX_RXD 256
129 #define E1000_MIN_RXD 80
130 #define E1000_MAX_82544_RXD 4096
131 
132 /* Supported Rx Buffer Sizes */
133 #define E1000_RXBUFFER_128 128 /* Used for packet split */
134 #define E1000_RXBUFFER_256 256 /* Used for packet split */
135 #define E1000_RXBUFFER_512 512
136 #define E1000_RXBUFFER_1024 1024
137 #define E1000_RXBUFFER_2048 2048
138 #define E1000_RXBUFFER_4096 4096
139 #define E1000_RXBUFFER_8192 8192
140 #define E1000_RXBUFFER_16384 16384
141 
142 /* SmartSpeed delimiters */
143 #define E1000_SMARTSPEED_DOWNSHIFT 3
144 #define E1000_SMARTSPEED_MAX 15
145 
146 /* Packet Buffer allocations */
147 #define E1000_PBA_BYTES_SHIFT 0xA
148 #define E1000_TX_HEAD_ADDR_SHIFT 7
149 #define E1000_PBA_TX_MASK 0xFFFF0000
150 
151 /* Flow Control Watermarks */
152 #define E1000_FC_HIGH_DIFF 0x1638 /* High: 5688 bytes below Rx FIFO size */
153 #define E1000_FC_LOW_DIFF 0x1640 /* Low: 5696 bytes below Rx FIFO size */
154 
155 #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
156 
157 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
158 #define E1000_TX_QUEUE_WAKE 16
159 /* How many Rx Buffers do we bundle into one write to the hardware ? */
160 #define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */
161 
162 #define AUTO_ALL_MODES 0
163 #define E1000_EEPROM_82544_APM 0x0004
164 #define E1000_EEPROM_ICH8_APME 0x0004
165 #define E1000_EEPROM_APME 0x0400
166 
167 #ifndef E1000_MASTER_SLAVE
168 /* Switch to override PHY master/slave setting */
169 #define E1000_MASTER_SLAVE e1000_ms_hw_default
170 #endif
171 
172 #ifdef NETIF_F_HW_VLAN_TX
173 #define E1000_MNG_VLAN_NONE -1
174 #endif
175 /* Number of packet split data buffers (not including the header buffer) */
176 #define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1
177 
178 /* only works for sizes that are powers of 2 */
179 #define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
180 
181 /* wrapper around a pointer to a socket buffer,
182  * so a DMA handle can be stored along with the buffer */
183 struct e1000_buffer {
184  struct rtskb *skb;
185  dma_addr_t dma;
186  unsigned long time_stamp;
187  uint16_t length;
188  uint16_t next_to_watch;
189 };
190 
191 
192 struct e1000_ps_page { struct page *ps_page[PS_PAGE_BUFFERS]; };
193 struct e1000_ps_page_dma { uint64_t ps_page_dma[PS_PAGE_BUFFERS]; };
194 
195 struct e1000_tx_ring {
196  /* pointer to the descriptor ring memory */
197  void *desc;
198  /* physical address of the descriptor ring */
199  dma_addr_t dma;
200  /* length of descriptor ring in bytes */
201  unsigned int size;
202  /* number of descriptors in the ring */
203  unsigned int count;
204  /* next descriptor to associate a buffer with */
205  unsigned int next_to_use;
206  /* next descriptor to check for DD status bit */
207  unsigned int next_to_clean;
208  /* array of buffer information structs */
209  struct e1000_buffer *buffer_info;
210 
211  rtdm_lock_t tx_lock;
212  uint16_t tdh;
213  uint16_t tdt;
214  boolean_t last_tx_tso;
215 };
216 
217 struct e1000_rx_ring {
218  /* pointer to the descriptor ring memory */
219  void *desc;
220  /* physical address of the descriptor ring */
221  dma_addr_t dma;
222  /* length of descriptor ring in bytes */
223  unsigned int size;
224  /* number of descriptors in the ring */
225  unsigned int count;
226  /* next descriptor to associate a buffer with */
227  unsigned int next_to_use;
228  /* next descriptor to check for DD status bit */
229  unsigned int next_to_clean;
230  /* array of buffer information structs */
231  struct e1000_buffer *buffer_info;
232  /* arrays of page information for packet split */
233  struct e1000_ps_page *ps_page;
234  struct e1000_ps_page_dma *ps_page_dma;
235 
236  /* cpu for rx queue */
237  int cpu;
238 
239  uint16_t rdh;
240  uint16_t rdt;
241 };
242 
243 #define E1000_DESC_UNUSED(R) \
244  ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
245  (R)->next_to_clean - (R)->next_to_use - 1)
246 
247 #define E1000_RX_DESC_PS(R, i) \
248  (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
249 #define E1000_RX_DESC_EXT(R, i) \
250  (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
251 #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
252 #define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc)
253 #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
254 #define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc)
255 
256 /* board specific private data structure */
257 
258 struct e1000_adapter {
259  struct timer_list tx_fifo_stall_timer;
260  struct timer_list watchdog_timer;
261  struct timer_list phy_info_timer;
262 #ifdef NETIF_F_HW_VLAN_TX
263  struct vlan_group *vlgrp;
264  uint16_t mng_vlan_id;
265 #endif
266  uint32_t bd_number;
267  uint32_t rx_buffer_len;
268  uint32_t part_num;
269  uint32_t wol;
270  uint32_t ksp3_port_a;
271  uint32_t smartspeed;
272  uint32_t en_mng_pt;
273  uint16_t link_speed;
274  uint16_t link_duplex;
275 #ifdef CONFIG_E1000_NAPI
276  spinlock_t tx_queue_lock;
277 #endif
278  atomic_t irq_sem;
279  struct work_struct reset_task;
280  uint8_t fc_autoneg;
281 
282 #ifdef ETHTOOL_PHYS_ID
283  struct timer_list blink_timer;
284  unsigned long led_status;
285 #endif
286 
287  /* TX */
288  struct e1000_tx_ring *tx_ring; /* One per active queue */
289  unsigned long tx_queue_len;
290  uint32_t txd_cmd;
291  uint32_t tx_int_delay;
292  uint32_t tx_abs_int_delay;
293  uint32_t gotcl;
294  uint64_t gotcl_old;
295  uint64_t tpt_old;
296  uint64_t colc_old;
297  uint32_t tx_timeout_count;
298  uint32_t tx_fifo_head;
299  uint32_t tx_head_addr;
300  uint32_t tx_fifo_size;
301  uint8_t tx_timeout_factor;
302  atomic_t tx_fifo_stall;
303  boolean_t pcix_82544;
304  boolean_t detect_tx_hung;
305 
306  /* RX */
307 #ifdef CONFIG_E1000_NAPI
308  boolean_t (*clean_rx) (struct e1000_adapter *adapter,
309  struct e1000_rx_ring *rx_ring,
310  int *work_done, int work_to_do);
311 #else
312  boolean_t (*clean_rx) (struct e1000_adapter *adapter,
313  struct e1000_rx_ring *rx_ring);
314 #endif
315  void (*alloc_rx_buf) (struct e1000_adapter *adapter,
316  struct e1000_rx_ring *rx_ring,
317  int cleaned_count);
318  struct e1000_rx_ring *rx_ring; /* One per active queue */
319 #ifdef CONFIG_E1000_NAPI
320  struct net_device *polling_netdev; /* One per active queue */
321 #endif
322  int num_tx_queues;
323  int num_rx_queues;
324 
325  uint64_t hw_csum_err;
326  uint64_t hw_csum_good;
327  uint64_t rx_hdr_split;
328  uint32_t alloc_rx_buff_failed;
329  uint32_t rx_int_delay;
330  uint32_t rx_abs_int_delay;
331  boolean_t rx_csum;
332  unsigned int rx_ps_pages;
333  uint32_t gorcl;
334  uint64_t gorcl_old;
335  uint16_t rx_ps_bsize0;
336 
337  /* Interrupt Throttle Rate */
338  uint32_t itr;
339 
340  /* OS defined structs */
341  struct rtnet_device *netdev;
342  struct pci_dev *pdev;
343  struct net_device_stats net_stats;
344 
345  rtdm_irq_t irq_handle;
346  boolean_t data_received;
347 
348  /* structs defined in e1000_hw.h */
349  struct e1000_hw hw;
350  struct e1000_hw_stats stats;
351  struct e1000_phy_info phy_info;
352  struct e1000_phy_stats phy_stats;
353 
354 #ifdef ETHTOOL_TEST
355  uint32_t test_icr;
356  struct e1000_tx_ring test_tx_ring;
357  struct e1000_rx_ring test_rx_ring;
358 #endif
359 
360 #ifdef E1000_COUNT_ICR
361  uint64_t icr_txdw;
362  uint64_t icr_txqe;
363  uint64_t icr_lsc;
364  uint64_t icr_rxseq;
365  uint64_t icr_rxdmt;
366  uint64_t icr_rxo;
367  uint64_t icr_rxt;
368  uint64_t icr_mdac;
369  uint64_t icr_rxcfg;
370  uint64_t icr_gpi;
371 #endif
372 
373  uint32_t *config_space;
374  int msg_enable;
375 #ifdef CONFIG_PCI_MSI
376  boolean_t have_msi;
377 #endif
378  /* to not mess up cache alignment, always add to the bottom */
379 #ifdef NETIF_F_TSO
380  boolean_t tso_force;
381 #endif
382  boolean_t smart_power_down; /* phy smart power down */
383  unsigned long flags;
384 };
385 
386 enum e1000_state_t {
387  __E1000_DRIVER_TESTING,
388  __E1000_RESETTING,
389 };
390 #endif /* _E1000_H_ */
ipipe_spinlock_t rtdm_lock_t
Lock variable.
Definition: driver.h:551
Copyright © 2011 Gilles Chanteperdrix gilles.chanteperdrix@xenomai.org.
Definition: atomic.h:24