Xenomai  3.0.8
e1000.h
1 /*******************************************************************************
2 
3  Intel PRO/1000 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 
30 /* Linux PRO/1000 Ethernet Driver main header file */
31 
32 #ifndef _E1000_H_
33 #define _E1000_H_
34 
35 #include "kcompat.h"
36 
37 #include "e1000_api.h"
38 
39 #define BAR_0 0
40 #define BAR_1 1
41 #define BAR_5 5
42 
43 #define INTEL_E1000_ETHERNET_DEVICE(device_id) {\
44  PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
45 
46 struct e1000_adapter;
47 
48 #define E1000_DBG(args...)
49 
50 #define E1000_ERR(args...) printk(KERN_ERR "e1000: " args)
51 
52 #define PFX "e1000: "
53 #define DPRINTK(nlevel, klevel, fmt, args...) \
54  (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
55  printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
56  __FUNCTION__ , ## args))
57 
58 #define E1000_MAX_INTR 10
59 
60 /* TX/RX descriptor defines */
61 #define E1000_DEFAULT_TXD 256
62 #define E1000_MAX_TXD 256
63 #define E1000_MIN_TXD 80
64 #define E1000_MAX_82544_TXD 4096
65 
66 #define E1000_DEFAULT_RXD 256
67 #define E1000_MAX_RXD 256
68 
69 #define E1000_MIN_RXD 80
70 #define E1000_MAX_82544_RXD 4096
71 
72 #define E1000_MIN_ITR_USECS 10 /* 100000 irq/sec */
73 #define E1000_MAX_ITR_USECS 10000 /* 100 irq/sec */
74 
75 #ifdef CONFIG_E1000_MQ
76 #define E1000_MAX_TX_QUEUES 4
77 #endif
78 
79 /* this is the size past which hardware will drop packets when setting LPE=0 */
80 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
81 
82 /* Supported Rx Buffer Sizes */
83 #define E1000_RXBUFFER_128 128 /* Used for packet split */
84 #define E1000_RXBUFFER_256 256 /* Used for packet split */
85 #define E1000_RXBUFFER_512 512
86 #define E1000_RXBUFFER_1024 1024
87 #define E1000_RXBUFFER_2048 2048
88 #define E1000_RXBUFFER_4096 4096
89 #define E1000_RXBUFFER_8192 8192
90 #define E1000_RXBUFFER_16384 16384
91 
92 /* SmartSpeed delimiters */
93 #define E1000_SMARTSPEED_DOWNSHIFT 3
94 #define E1000_SMARTSPEED_MAX 15
95 
96 /* Packet Buffer allocations */
97 #define E1000_PBA_BYTES_SHIFT 0xA
98 #define E1000_TX_HEAD_ADDR_SHIFT 7
99 #define E1000_PBA_TX_MASK 0xFFFF0000
100 
101 /* Early Receive defines */
102 #define E1000_ERT_2048 0x100
103 
104 #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
105 
106 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
107 #define E1000_TX_QUEUE_WAKE 16
108 /* How many Rx Buffers do we bundle into one write to the hardware ? */
109 #define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */
110 
111 #define AUTO_ALL_MODES 0
112 #define E1000_EEPROM_82544_APM 0x0004
113 #define E1000_EEPROM_APME 0x0400
114 
115 #ifndef E1000_MASTER_SLAVE
116 /* Switch to override PHY master/slave setting */
117 #define E1000_MASTER_SLAVE e1000_ms_hw_default
118 #endif
119 
120 #ifdef NETIF_F_HW_VLAN_TX
121 #define E1000_MNG_VLAN_NONE -1
122 #endif
123 /* Number of packet split data buffers (not including the header buffer) */
124 #define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1
125 
126 /* wrapper around a pointer to a socket buffer,
127  * so a DMA handle can be stored along with the buffer */
128 struct e1000_buffer {
129  struct rtskb *skb;
130  dma_addr_t dma;
131  unsigned long time_stamp;
132  u16 length;
133  u16 next_to_watch;
134 };
135 
136 struct e1000_rx_buffer {
137  struct rtskb *skb;
138  dma_addr_t dma;
139  struct page *page;
140 };
141 
142 #ifdef CONFIG_E1000_MQ
143 struct e1000_queue_stats {
144  u64 packets;
145  u64 bytes;
146 };
147 #endif
148 
149 struct e1000_ps_page { struct page *ps_page[PS_PAGE_BUFFERS]; };
150 struct e1000_ps_page_dma { u64 ps_page_dma[PS_PAGE_BUFFERS]; };
151 
152 struct e1000_tx_ring {
153  /* pointer to the descriptor ring memory */
154  void *desc;
155  /* physical address of the descriptor ring */
156  dma_addr_t dma;
157  /* length of descriptor ring in bytes */
158  unsigned int size;
159  /* number of descriptors in the ring */
160  unsigned int count;
161  /* next descriptor to associate a buffer with */
162  unsigned int next_to_use;
163  /* next descriptor to check for DD status bit */
164  unsigned int next_to_clean;
165  /* array of buffer information structs */
166  struct e1000_buffer *buffer_info;
167 
168 #ifdef CONFIG_E1000_MQ
169  /* for tx ring cleanup - needed for multiqueue */
170  spinlock_t tx_queue_lock;
171 #endif
172  rtdm_lock_t tx_lock;
173  u16 tdh;
174  u16 tdt;
175 #ifdef CONFIG_E1000_MQ
176  struct e1000_queue_stats tx_stats;
177 #endif
178  bool last_tx_tso;
179 };
180 
181 struct e1000_rx_ring {
182  struct e1000_adapter *adapter; /* back link */
183  /* pointer to the descriptor ring memory */
184  void *desc;
185  /* physical address of the descriptor ring */
186  dma_addr_t dma;
187  /* length of descriptor ring in bytes */
188  unsigned int size;
189  /* number of descriptors in the ring */
190  unsigned int count;
191  /* next descriptor to associate a buffer with */
192  unsigned int next_to_use;
193  /* next descriptor to check for DD status bit */
194  unsigned int next_to_clean;
195 #ifdef CONFIG_E1000_NAPI
196  struct napi_struct napi;
197 #endif
198  /* array of buffer information structs */
199  struct e1000_rx_buffer *buffer_info;
200  /* arrays of page information for packet split */
201  struct e1000_ps_page *ps_page;
202  struct e1000_ps_page_dma *ps_page_dma;
203  struct sk_buff *rx_skb_top;
204 
205  /* cpu for rx queue */
206  int cpu;
207 
208  u16 rdh;
209  u16 rdt;
210 #ifdef CONFIG_E1000_MQ
211  struct e1000_queue_stats rx_stats;
212 #endif
213 };
214 
215 #define E1000_DESC_UNUSED(R) \
216  ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
217  (R)->next_to_clean - (R)->next_to_use - 1)
218 
219 #define E1000_RX_DESC_PS(R, i) \
220  (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
221 #define E1000_RX_DESC_EXT(R, i) \
222  (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
223 #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
224 #define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc)
225 #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
226 #define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc)
227 
228 #ifdef SIOCGMIIPHY
229 /* PHY register snapshot values */
230 struct e1000_phy_regs {
231  u16 bmcr; /* basic mode control register */
232  u16 bmsr; /* basic mode status register */
233  u16 advertise; /* auto-negotiation advertisement */
234  u16 lpa; /* link partner ability register */
235  u16 expansion; /* auto-negotiation expansion reg */
236  u16 ctrl1000; /* 1000BASE-T control register */
237  u16 stat1000; /* 1000BASE-T status register */
238  u16 estatus; /* extended status register */
239 };
240 #endif
241 
242 /* board specific private data structure */
243 
244 struct e1000_adapter {
245  struct timer_list tx_fifo_stall_timer;
246  struct timer_list watchdog_timer;
247  struct timer_list phy_info_timer;
248 #ifdef NETIF_F_HW_VLAN_TX
249  struct vlan_group *vlgrp;
250  u16 mng_vlan_id;
251 #endif
252  u32 bd_number;
253  u32 rx_buffer_len;
254  u32 wol;
255  u32 smartspeed;
256  u32 en_mng_pt;
257  u16 link_speed;
258  u16 link_duplex;
259  rtdm_lock_t stats_lock;
260 #ifdef CONFIG_E1000_NAPI
261  spinlock_t tx_queue_lock;
262 #endif
263  atomic_t irq_sem;
264  unsigned int total_tx_bytes;
265  unsigned int total_tx_packets;
266  unsigned int total_rx_bytes;
267  unsigned int total_rx_packets;
268  /* Interrupt Throttle Rate */
269  u32 itr;
270  u32 itr_setting;
271  u16 tx_itr;
272  u16 rx_itr;
273 
274  struct work_struct reset_task;
275  struct work_struct watchdog_task;
276  bool fc_autoneg;
277 
278 #ifdef ETHTOOL_PHYS_ID
279  struct timer_list blink_timer;
280  unsigned long led_status;
281 #endif
282 
283  /* TX */
284  struct e1000_tx_ring *tx_ring; /* One per active queue */
285 #ifdef CONFIG_E1000_MQ
286  struct e1000_tx_ring **cpu_tx_ring; /* per-cpu */
287 #endif
288  unsigned int restart_queue;
289  unsigned long tx_queue_len;
290  u32 txd_cmd;
291  u32 tx_int_delay;
292  u32 tx_abs_int_delay;
293  u32 gotc;
294  u64 gotc_old;
295  u64 tpt_old;
296  u64 colc_old;
297  u32 tx_timeout_count;
298  u32 tx_fifo_head;
299  u32 tx_head_addr;
300  u32 tx_fifo_size;
301  u8 tx_timeout_factor;
302  atomic_t tx_fifo_stall;
303  bool pcix_82544;
304  bool detect_tx_hung;
305 
306  /* RX */
307 #ifdef CONFIG_E1000_NAPI
308  bool (*clean_rx) (struct e1000_adapter *adapter,
309  struct e1000_rx_ring *rx_ring,
310  int *work_done, int work_to_do);
311 #else
312  bool (*clean_rx) (struct e1000_adapter *adapter,
313  struct e1000_rx_ring *rx_ring,
314  nanosecs_abs_t *time_stamp);
315 #endif
316  void (*alloc_rx_buf) (struct e1000_adapter *adapter,
317  struct e1000_rx_ring *rx_ring,
318  int cleaned_count);
319  struct e1000_rx_ring *rx_ring; /* One per active queue */
320 #ifdef CONFIG_E1000_NAPI
321  //struct napi_struct napi;
322 #endif
323  int num_tx_queues;
324  int num_rx_queues;
325 
326  u64 hw_csum_err;
327  u64 hw_csum_good;
328  u64 rx_hdr_split;
329  u32 alloc_rx_buff_failed;
330  u32 rx_int_delay;
331  u32 rx_abs_int_delay;
332  bool rx_csum;
333  unsigned int rx_ps_pages;
334  u32 gorc;
335  u64 gorc_old;
336  u16 rx_ps_bsize0;
337  u32 max_frame_size;
338  u32 min_frame_size;
339 
340 
341  /* OS defined structs */
342  struct rtnet_device *netdev;
343  struct pci_dev *pdev;
344  struct net_device_stats net_stats;
345 
346  rtdm_irq_t irq_handle;
347  char data_received;
348 
349  /* structs defined in e1000_hw.h */
350  struct e1000_hw hw;
351  struct e1000_hw_stats stats;
352  struct e1000_phy_info phy_info;
353  struct e1000_phy_stats phy_stats;
354 
355 #ifdef SIOCGMIIPHY
356  /* Snapshot of PHY registers */
357  struct e1000_phy_regs phy_regs;
358 #endif
359 
360 #ifdef ETHTOOL_TEST
361  u32 test_icr;
362  struct e1000_tx_ring test_tx_ring;
363  struct e1000_rx_ring test_rx_ring;
364 #endif
365 
366 
367  int msg_enable;
368  /* to not mess up cache alignment, always add to the bottom */
369  unsigned long state;
370  u32 eeprom_wol;
371 
372  u32 *config_space;
373 
374  /* hardware capability, feature, and workaround flags */
375  unsigned int flags;
376 
377 };
378 
379 #define E1000_FLAG_HAS_SMBUS (1 << 0)
380 #define E1000_FLAG_HAS_MANC2H (1 << 1)
381 #define E1000_FLAG_HAS_MSI (1 << 2)
382 #define E1000_FLAG_MSI_ENABLED (1 << 3)
383 #define E1000_FLAG_HAS_INTR_MODERATION (1 << 4)
384 #define E1000_FLAG_RX_NEEDS_RESTART (1 << 5)
385 #define E1000_FLAG_BAD_TX_CARRIER_STATS_FD (1 << 6)
386 #define E1000_FLAG_INT_ASSERT_AUTO_MASK (1 << 7)
387 #define E1000_FLAG_QUAD_PORT_A (1 << 8)
388 #define E1000_FLAG_SMART_POWER_DOWN (1 << 9)
389 #ifdef NETIF_F_TSO
390 #define E1000_FLAG_HAS_TSO (1 << 10)
391 #ifdef NETIF_F_TSO6
392 #define E1000_FLAG_HAS_TSO6 (1 << 11)
393 #endif
394 #define E1000_FLAG_TSO_FORCE (1 << 12)
395 #endif
396 #define E1000_FLAG_RX_RESTART_NOW (1 << 13)
397 
398 enum e1000_state_t {
399  __E1000_TESTING,
400  __E1000_RESETTING,
401  __E1000_DOWN
402 };
403 
404 extern char e1000_driver_name[];
405 extern const char e1000_driver_version[];
406 
407 extern void e1000_power_up_phy(struct e1000_hw *hw);
408 
409 extern void e1000_set_ethtool_ops(struct net_device *netdev);
410 extern void e1000_check_options(struct e1000_adapter *adapter);
411 
412 extern int e1000_up(struct e1000_adapter *adapter);
413 extern void e1000_down(struct e1000_adapter *adapter);
414 extern void e1000_reinit_locked(struct e1000_adapter *adapter);
415 extern void e1000_reset(struct e1000_adapter *adapter);
416 extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
417 extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
418 extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
419 extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
420 extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
421 extern void e1000_update_stats(struct e1000_adapter *adapter);
422 #ifdef ETHTOOL_OPS_COMPAT
423 extern int ethtool_ioctl(struct ifreq *ifr);
424 #endif
425 
426 #endif /* _E1000_H_ */
ipipe_spinlock_t rtdm_lock_t
Lock variable.
Definition: driver.h:551
uint64_t nanosecs_abs_t
RTDM type for representing absolute dates.
Definition: rtdm.h:43
Copyright © 2011 Gilles Chanteperdrix gilles.chanteperdrix@xenomai.org.
Definition: atomic.h:24