Xenomai  3.1
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 #ifdef NETIF_F_HW_VLAN_TX
246  struct vlan_group *vlgrp;
247  u16 mng_vlan_id;
248 #endif
249  u32 bd_number;
250  u32 rx_buffer_len;
251  u32 wol;
252  u32 smartspeed;
253  u32 en_mng_pt;
254  u16 link_speed;
255  u16 link_duplex;
256  rtdm_lock_t stats_lock;
257 #ifdef CONFIG_E1000_NAPI
258  spinlock_t tx_queue_lock;
259 #endif
260  atomic_t irq_sem;
261  unsigned int total_tx_bytes;
262  unsigned int total_tx_packets;
263  unsigned int total_rx_bytes;
264  unsigned int total_rx_packets;
265  /* Interrupt Throttle Rate */
266  u32 itr;
267  u32 itr_setting;
268  u16 tx_itr;
269  u16 rx_itr;
270 
271  bool fc_autoneg;
272 
273 #ifdef ETHTOOL_PHYS_ID
274  struct timer_list blink_timer;
275  unsigned long led_status;
276 #endif
277 
278  /* TX */
279  struct e1000_tx_ring *tx_ring; /* One per active queue */
280 #ifdef CONFIG_E1000_MQ
281  struct e1000_tx_ring **cpu_tx_ring; /* per-cpu */
282 #endif
283  unsigned int restart_queue;
284  unsigned long tx_queue_len;
285  u32 txd_cmd;
286  u32 tx_int_delay;
287  u32 tx_abs_int_delay;
288  u32 gotc;
289  u64 gotc_old;
290  u64 tpt_old;
291  u64 colc_old;
292  u32 tx_timeout_count;
293  u32 tx_fifo_head;
294  u32 tx_head_addr;
295  u32 tx_fifo_size;
296  u8 tx_timeout_factor;
297  atomic_t tx_fifo_stall;
298  bool pcix_82544;
299  bool detect_tx_hung;
300 
301  /* RX */
302 #ifdef CONFIG_E1000_NAPI
303  bool (*clean_rx) (struct e1000_adapter *adapter,
304  struct e1000_rx_ring *rx_ring,
305  int *work_done, int work_to_do);
306 #else
307  bool (*clean_rx) (struct e1000_adapter *adapter,
308  struct e1000_rx_ring *rx_ring,
309  nanosecs_abs_t *time_stamp);
310 #endif
311  void (*alloc_rx_buf) (struct e1000_adapter *adapter,
312  struct e1000_rx_ring *rx_ring,
313  int cleaned_count);
314  struct e1000_rx_ring *rx_ring; /* One per active queue */
315 #ifdef CONFIG_E1000_NAPI
316  //struct napi_struct napi;
317 #endif
318  int num_tx_queues;
319  int num_rx_queues;
320 
321  u64 hw_csum_err;
322  u64 hw_csum_good;
323  u64 rx_hdr_split;
324  u32 alloc_rx_buff_failed;
325  u32 rx_int_delay;
326  u32 rx_abs_int_delay;
327  bool rx_csum;
328  unsigned int rx_ps_pages;
329  u32 gorc;
330  u64 gorc_old;
331  u16 rx_ps_bsize0;
332  u32 max_frame_size;
333  u32 min_frame_size;
334 
335 
336  /* OS defined structs */
337  struct rtnet_device *netdev;
338  struct pci_dev *pdev;
339  struct net_device_stats net_stats;
340 
341  rtdm_irq_t irq_handle;
342  char data_received;
343 
344  /* structs defined in e1000_hw.h */
345  struct e1000_hw hw;
346  struct e1000_hw_stats stats;
347  struct e1000_phy_info phy_info;
348  struct e1000_phy_stats phy_stats;
349 
350 #ifdef SIOCGMIIPHY
351  /* Snapshot of PHY registers */
352  struct e1000_phy_regs phy_regs;
353 #endif
354 
355 #ifdef ETHTOOL_TEST
356  u32 test_icr;
357  struct e1000_tx_ring test_tx_ring;
358  struct e1000_rx_ring test_rx_ring;
359 #endif
360 
361 
362  int msg_enable;
363  /* to not mess up cache alignment, always add to the bottom */
364  unsigned long state;
365  u32 eeprom_wol;
366 
367  u32 *config_space;
368 
369  /* hardware capability, feature, and workaround flags */
370  unsigned int flags;
371 
372  struct work_struct reset_task;
373  struct delayed_work watchdog_task;
374  struct delayed_work fifo_stall_task;
375  struct delayed_work phy_info_task;
376 };
377 
378 #define E1000_FLAG_HAS_SMBUS (1 << 0)
379 #define E1000_FLAG_HAS_MANC2H (1 << 1)
380 #define E1000_FLAG_HAS_MSI (1 << 2)
381 #define E1000_FLAG_MSI_ENABLED (1 << 3)
382 #define E1000_FLAG_HAS_INTR_MODERATION (1 << 4)
383 #define E1000_FLAG_RX_NEEDS_RESTART (1 << 5)
384 #define E1000_FLAG_BAD_TX_CARRIER_STATS_FD (1 << 6)
385 #define E1000_FLAG_INT_ASSERT_AUTO_MASK (1 << 7)
386 #define E1000_FLAG_QUAD_PORT_A (1 << 8)
387 #define E1000_FLAG_SMART_POWER_DOWN (1 << 9)
388 #ifdef NETIF_F_TSO
389 #define E1000_FLAG_HAS_TSO (1 << 10)
390 #ifdef NETIF_F_TSO6
391 #define E1000_FLAG_HAS_TSO6 (1 << 11)
392 #endif
393 #define E1000_FLAG_TSO_FORCE (1 << 12)
394 #endif
395 #define E1000_FLAG_RX_RESTART_NOW (1 << 13)
396 
397 enum e1000_state_t {
398  __E1000_TESTING,
399  __E1000_RESETTING,
400  __E1000_DOWN
401 };
402 
403 extern char e1000_driver_name[];
404 extern const char e1000_driver_version[];
405 
406 extern void e1000_power_up_phy(struct e1000_hw *hw);
407 
408 extern void e1000_set_ethtool_ops(struct net_device *netdev);
409 extern void e1000_check_options(struct e1000_adapter *adapter);
410 
411 extern int e1000_up(struct e1000_adapter *adapter);
412 extern void e1000_down(struct e1000_adapter *adapter);
413 extern void e1000_reinit_locked(struct e1000_adapter *adapter);
414 extern void e1000_reset(struct e1000_adapter *adapter);
415 extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
416 extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
417 extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
418 extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
419 extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
420 extern void e1000_update_stats(struct e1000_adapter *adapter);
421 #ifdef ETHTOOL_OPS_COMPAT
422 extern int ethtool_ioctl(struct ifreq *ifr);
423 #endif
424 
425 #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