Xenomai  3.1
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 #ifdef NETIF_F_HW_VLAN_TX
260  struct vlan_group *vlgrp;
261  uint16_t mng_vlan_id;
262 #endif
263  uint32_t bd_number;
264  uint32_t rx_buffer_len;
265  uint32_t part_num;
266  uint32_t wol;
267  uint32_t ksp3_port_a;
268  uint32_t smartspeed;
269  uint32_t en_mng_pt;
270  uint16_t link_speed;
271  uint16_t link_duplex;
272 #ifdef CONFIG_E1000_NAPI
273  spinlock_t tx_queue_lock;
274 #endif
275  atomic_t irq_sem;
276  struct work_struct reset_task;
277  uint8_t fc_autoneg;
278 
279 #ifdef ETHTOOL_PHYS_ID
280  struct timer_list blink_timer;
281  unsigned long led_status;
282 #endif
283 
284  /* TX */
285  struct e1000_tx_ring *tx_ring; /* One per active queue */
286  unsigned long tx_queue_len;
287  uint32_t txd_cmd;
288  uint32_t tx_int_delay;
289  uint32_t tx_abs_int_delay;
290  uint32_t gotcl;
291  uint64_t gotcl_old;
292  uint64_t tpt_old;
293  uint64_t colc_old;
294  uint32_t tx_timeout_count;
295  uint32_t tx_fifo_head;
296  uint32_t tx_head_addr;
297  uint32_t tx_fifo_size;
298  uint8_t tx_timeout_factor;
299  atomic_t tx_fifo_stall;
300  boolean_t pcix_82544;
301  boolean_t detect_tx_hung;
302 
303  /* RX */
304 #ifdef CONFIG_E1000_NAPI
305  boolean_t (*clean_rx) (struct e1000_adapter *adapter,
306  struct e1000_rx_ring *rx_ring,
307  int *work_done, int work_to_do);
308 #else
309  boolean_t (*clean_rx) (struct e1000_adapter *adapter,
310  struct e1000_rx_ring *rx_ring);
311 #endif
312  void (*alloc_rx_buf) (struct e1000_adapter *adapter,
313  struct e1000_rx_ring *rx_ring,
314  int cleaned_count);
315  struct e1000_rx_ring *rx_ring; /* One per active queue */
316 #ifdef CONFIG_E1000_NAPI
317  struct net_device *polling_netdev; /* One per active queue */
318 #endif
319  int num_tx_queues;
320  int num_rx_queues;
321 
322  uint64_t hw_csum_err;
323  uint64_t hw_csum_good;
324  uint64_t rx_hdr_split;
325  uint32_t alloc_rx_buff_failed;
326  uint32_t rx_int_delay;
327  uint32_t rx_abs_int_delay;
328  boolean_t rx_csum;
329  unsigned int rx_ps_pages;
330  uint32_t gorcl;
331  uint64_t gorcl_old;
332  uint16_t rx_ps_bsize0;
333 
334  /* Interrupt Throttle Rate */
335  uint32_t itr;
336 
337  /* OS defined structs */
338  struct rtnet_device *netdev;
339  struct pci_dev *pdev;
340  struct net_device_stats net_stats;
341 
342  rtdm_irq_t irq_handle;
343  boolean_t data_received;
344 
345  /* structs defined in e1000_hw.h */
346  struct e1000_hw hw;
347  struct e1000_hw_stats stats;
348  struct e1000_phy_info phy_info;
349  struct e1000_phy_stats phy_stats;
350 
351 #ifdef ETHTOOL_TEST
352  uint32_t test_icr;
353  struct e1000_tx_ring test_tx_ring;
354  struct e1000_rx_ring test_rx_ring;
355 #endif
356 
357 #ifdef E1000_COUNT_ICR
358  uint64_t icr_txdw;
359  uint64_t icr_txqe;
360  uint64_t icr_lsc;
361  uint64_t icr_rxseq;
362  uint64_t icr_rxdmt;
363  uint64_t icr_rxo;
364  uint64_t icr_rxt;
365  uint64_t icr_mdac;
366  uint64_t icr_rxcfg;
367  uint64_t icr_gpi;
368 #endif
369 
370  uint32_t *config_space;
371  int msg_enable;
372 #ifdef CONFIG_PCI_MSI
373  boolean_t have_msi;
374 #endif
375  /* to not mess up cache alignment, always add to the bottom */
376 #ifdef NETIF_F_TSO
377  boolean_t tso_force;
378 #endif
379  boolean_t smart_power_down; /* phy smart power down */
380  unsigned long flags;
381 
382  struct delayed_work watchdog_task;
383  struct delayed_work fifo_stall_task;
384  struct delayed_work phy_info_task;
385 };
386 
387 enum e1000_state_t {
388  __E1000_DRIVER_TESTING,
389  __E1000_RESETTING,
390 };
391 #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