igb.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /*******************************************************************************
  2. Intel(R) Gigabit Ethernet Linux driver
  3. Copyright(c) 2007 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  18. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  19. *******************************************************************************/
  20. /* Linux PRO/1000 Ethernet Driver main header file */
  21. #ifndef _IGB_H_
  22. #define _IGB_H_
  23. #include "e1000_mac.h"
  24. #include "e1000_82575.h"
  25. struct igb_adapter;
  26. /* Interrupt defines */
  27. #define IGB_MAX_TX_CLEAN 72
  28. #define IGB_MIN_DYN_ITR 3000
  29. #define IGB_MAX_DYN_ITR 96000
  30. #define IGB_START_ITR 6000
  31. #define IGB_DYN_ITR_PACKET_THRESHOLD 2
  32. #define IGB_DYN_ITR_LENGTH_LOW 200
  33. #define IGB_DYN_ITR_LENGTH_HIGH 1000
  34. /* TX/RX descriptor defines */
  35. #define IGB_DEFAULT_TXD 256
  36. #define IGB_MIN_TXD 80
  37. #define IGB_MAX_TXD 4096
  38. #define IGB_DEFAULT_RXD 256
  39. #define IGB_MIN_RXD 80
  40. #define IGB_MAX_RXD 4096
  41. #define IGB_DEFAULT_ITR 3 /* dynamic */
  42. #define IGB_MAX_ITR_USECS 10000
  43. #define IGB_MIN_ITR_USECS 10
  44. /* Transmit and receive queues */
  45. #define IGB_MAX_RX_QUEUES 4
  46. /* RX descriptor control thresholds.
  47. * PTHRESH - MAC will consider prefetch if it has fewer than this number of
  48. * descriptors available in its onboard memory.
  49. * Setting this to 0 disables RX descriptor prefetch.
  50. * HTHRESH - MAC will only prefetch if there are at least this many descriptors
  51. * available in host memory.
  52. * If PTHRESH is 0, this should also be 0.
  53. * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
  54. * descriptors until either it has this many to write back, or the
  55. * ITR timer expires.
  56. */
  57. #define IGB_RX_PTHRESH 16
  58. #define IGB_RX_HTHRESH 8
  59. #define IGB_RX_WTHRESH 1
  60. /* this is the size past which hardware will drop packets when setting LPE=0 */
  61. #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
  62. /* Supported Rx Buffer Sizes */
  63. #define IGB_RXBUFFER_128 128 /* Used for packet split */
  64. #define IGB_RXBUFFER_256 256 /* Used for packet split */
  65. #define IGB_RXBUFFER_512 512
  66. #define IGB_RXBUFFER_1024 1024
  67. #define IGB_RXBUFFER_2048 2048
  68. #define IGB_RXBUFFER_4096 4096
  69. #define IGB_RXBUFFER_8192 8192
  70. #define IGB_RXBUFFER_16384 16384
  71. /* Packet Buffer allocations */
  72. /* How many Tx Descriptors do we need to call netif_wake_queue ? */
  73. #define IGB_TX_QUEUE_WAKE 16
  74. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  75. #define IGB_RX_BUFFER_WRITE 16 /* Must be power of 2 */
  76. #define AUTO_ALL_MODES 0
  77. #define IGB_EEPROM_APME 0x0400
  78. #ifndef IGB_MASTER_SLAVE
  79. /* Switch to override PHY master/slave setting */
  80. #define IGB_MASTER_SLAVE e1000_ms_hw_default
  81. #endif
  82. #define IGB_MNG_VLAN_NONE -1
  83. /* wrapper around a pointer to a socket buffer,
  84. * so a DMA handle can be stored along with the buffer */
  85. struct igb_buffer {
  86. struct sk_buff *skb;
  87. dma_addr_t dma;
  88. union {
  89. /* TX */
  90. struct {
  91. unsigned long time_stamp;
  92. u32 length;
  93. };
  94. /* RX */
  95. struct {
  96. struct page *page;
  97. u64 page_dma;
  98. };
  99. };
  100. };
  101. struct igb_queue_stats {
  102. u64 packets;
  103. u64 bytes;
  104. };
  105. struct igb_ring {
  106. struct igb_adapter *adapter; /* backlink */
  107. void *desc; /* descriptor ring memory */
  108. dma_addr_t dma; /* phys address of the ring */
  109. unsigned int size; /* length of desc. ring in bytes */
  110. unsigned int count; /* number of desc. in the ring */
  111. u16 next_to_use;
  112. u16 next_to_clean;
  113. u16 head;
  114. u16 tail;
  115. struct igb_buffer *buffer_info; /* array of buffer info structs */
  116. u32 eims_value;
  117. u32 itr_val;
  118. u16 itr_register;
  119. u16 cpu;
  120. unsigned int total_bytes;
  121. unsigned int total_packets;
  122. union {
  123. /* TX */
  124. struct {
  125. spinlock_t tx_clean_lock;
  126. spinlock_t tx_lock;
  127. bool detect_tx_hung;
  128. };
  129. /* RX */
  130. struct {
  131. /* arrays of page information for packet split */
  132. struct sk_buff *pending_skb;
  133. int pending_skb_page;
  134. int no_itr_adjust;
  135. struct igb_queue_stats rx_stats;
  136. struct napi_struct napi;
  137. };
  138. };
  139. char name[IFNAMSIZ + 5];
  140. };
  141. #define IGB_DESC_UNUSED(R) \
  142. ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
  143. (R)->next_to_clean - (R)->next_to_use - 1)
  144. #define E1000_RX_DESC_ADV(R, i) \
  145. (&(((union e1000_adv_rx_desc *)((R).desc))[i]))
  146. #define E1000_TX_DESC_ADV(R, i) \
  147. (&(((union e1000_adv_tx_desc *)((R).desc))[i]))
  148. #define E1000_TX_CTXTDESC_ADV(R, i) \
  149. (&(((struct e1000_adv_tx_context_desc *)((R).desc))[i]))
  150. #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
  151. #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
  152. #define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc)
  153. /* board specific private data structure */
  154. struct igb_adapter {
  155. struct timer_list watchdog_timer;
  156. struct timer_list phy_info_timer;
  157. struct vlan_group *vlgrp;
  158. u16 mng_vlan_id;
  159. u32 bd_number;
  160. u32 rx_buffer_len;
  161. u32 wol;
  162. u32 en_mng_pt;
  163. u16 link_speed;
  164. u16 link_duplex;
  165. unsigned int total_tx_bytes;
  166. unsigned int total_tx_packets;
  167. unsigned int total_rx_bytes;
  168. unsigned int total_rx_packets;
  169. /* Interrupt Throttle Rate */
  170. u32 itr;
  171. u32 itr_setting;
  172. u16 tx_itr;
  173. u16 rx_itr;
  174. int set_itr;
  175. struct work_struct reset_task;
  176. struct work_struct watchdog_task;
  177. bool fc_autoneg;
  178. u8 tx_timeout_factor;
  179. struct timer_list blink_timer;
  180. unsigned long led_status;
  181. /* TX */
  182. struct igb_ring *tx_ring; /* One per active queue */
  183. unsigned int restart_queue;
  184. unsigned long tx_queue_len;
  185. u32 txd_cmd;
  186. u32 gotc;
  187. u64 gotc_old;
  188. u64 tpt_old;
  189. u64 colc_old;
  190. u32 tx_timeout_count;
  191. /* RX */
  192. struct igb_ring *rx_ring; /* One per active queue */
  193. int num_tx_queues;
  194. int num_rx_queues;
  195. u64 hw_csum_err;
  196. u64 hw_csum_good;
  197. u64 rx_hdr_split;
  198. u32 alloc_rx_buff_failed;
  199. bool rx_csum;
  200. u32 gorc;
  201. u64 gorc_old;
  202. u16 rx_ps_hdr_size;
  203. u32 max_frame_size;
  204. u32 min_frame_size;
  205. /* OS defined structs */
  206. struct net_device *netdev;
  207. struct napi_struct napi;
  208. struct pci_dev *pdev;
  209. struct net_device_stats net_stats;
  210. /* structs defined in e1000_hw.h */
  211. struct e1000_hw hw;
  212. struct e1000_hw_stats stats;
  213. struct e1000_phy_info phy_info;
  214. struct e1000_phy_stats phy_stats;
  215. u32 test_icr;
  216. struct igb_ring test_tx_ring;
  217. struct igb_ring test_rx_ring;
  218. int msg_enable;
  219. struct msix_entry *msix_entries;
  220. u32 eims_enable_mask;
  221. /* to not mess up cache alignment, always add to the bottom */
  222. unsigned long state;
  223. unsigned int msi_enabled;
  224. u32 eeprom_wol;
  225. };
  226. enum e1000_state_t {
  227. __IGB_TESTING,
  228. __IGB_RESETTING,
  229. __IGB_DOWN
  230. };
  231. enum igb_boards {
  232. board_82575,
  233. };
  234. extern char igb_driver_name[];
  235. extern char igb_driver_version[];
  236. extern char *igb_get_hw_dev_name(struct e1000_hw *hw);
  237. extern int igb_up(struct igb_adapter *);
  238. extern void igb_down(struct igb_adapter *);
  239. extern void igb_reinit_locked(struct igb_adapter *);
  240. extern void igb_reset(struct igb_adapter *);
  241. extern int igb_set_spd_dplx(struct igb_adapter *, u16);
  242. extern int igb_setup_tx_resources(struct igb_adapter *, struct igb_ring *);
  243. extern int igb_setup_rx_resources(struct igb_adapter *, struct igb_ring *);
  244. extern void igb_update_stats(struct igb_adapter *);
  245. extern void igb_set_ethtool_ops(struct net_device *);
  246. #endif /* _IGB_H_ */