igbvf.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /*******************************************************************************
  2. Intel(R) 82576 Virtual Function Linux driver
  3. Copyright(c) 2009 - 2012 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, see <http://www.gnu.org/licenses/>.
  13. The full GNU General Public License is included in this distribution in
  14. the file called "COPYING".
  15. Contact Information:
  16. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  17. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  18. *******************************************************************************/
  19. /* Linux PRO/1000 Ethernet Driver main header file */
  20. #ifndef _IGBVF_H_
  21. #define _IGBVF_H_
  22. #include <linux/types.h>
  23. #include <linux/timer.h>
  24. #include <linux/io.h>
  25. #include <linux/netdevice.h>
  26. #include <linux/if_vlan.h>
  27. #include "vf.h"
  28. /* Forward declarations */
  29. struct igbvf_info;
  30. struct igbvf_adapter;
  31. /* Interrupt defines */
  32. #define IGBVF_START_ITR 488 /* ~8000 ints/sec */
  33. #define IGBVF_4K_ITR 980
  34. #define IGBVF_20K_ITR 196
  35. #define IGBVF_70K_ITR 56
  36. enum latency_range {
  37. lowest_latency = 0,
  38. low_latency = 1,
  39. bulk_latency = 2,
  40. latency_invalid = 255
  41. };
  42. /* Interrupt modes, as used by the IntMode parameter */
  43. #define IGBVF_INT_MODE_LEGACY 0
  44. #define IGBVF_INT_MODE_MSI 1
  45. #define IGBVF_INT_MODE_MSIX 2
  46. /* Tx/Rx descriptor defines */
  47. #define IGBVF_DEFAULT_TXD 256
  48. #define IGBVF_MAX_TXD 4096
  49. #define IGBVF_MIN_TXD 80
  50. #define IGBVF_DEFAULT_RXD 256
  51. #define IGBVF_MAX_RXD 4096
  52. #define IGBVF_MIN_RXD 80
  53. #define IGBVF_MIN_ITR_USECS 10 /* 100000 irq/sec */
  54. #define IGBVF_MAX_ITR_USECS 10000 /* 100 irq/sec */
  55. /* RX descriptor control thresholds.
  56. * PTHRESH - MAC will consider prefetch if it has fewer than this number of
  57. * descriptors available in its onboard memory.
  58. * Setting this to 0 disables RX descriptor prefetch.
  59. * HTHRESH - MAC will only prefetch if there are at least this many descriptors
  60. * available in host memory.
  61. * If PTHRESH is 0, this should also be 0.
  62. * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
  63. * descriptors until either it has this many to write back, or the
  64. * ITR timer expires.
  65. */
  66. #define IGBVF_RX_PTHRESH 16
  67. #define IGBVF_RX_HTHRESH 8
  68. #define IGBVF_RX_WTHRESH 1
  69. /* this is the size past which hardware will drop packets when setting LPE=0 */
  70. #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
  71. #define IGBVF_FC_PAUSE_TIME 0x0680 /* 858 usec */
  72. /* How many Tx Descriptors do we need to call netif_wake_queue ? */
  73. #define IGBVF_TX_QUEUE_WAKE 32
  74. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  75. #define IGBVF_RX_BUFFER_WRITE 16 /* Must be power of 2 */
  76. #define AUTO_ALL_MODES 0
  77. #define IGBVF_EEPROM_APME 0x0400
  78. #define IGBVF_MNG_VLAN_NONE (-1)
  79. /* Number of packet split data buffers (not including the header buffer) */
  80. #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
  81. enum igbvf_boards {
  82. board_vf,
  83. board_i350_vf,
  84. };
  85. struct igbvf_queue_stats {
  86. u64 packets;
  87. u64 bytes;
  88. };
  89. /* wrappers around a pointer to a socket buffer,
  90. * so a DMA handle can be stored along with the buffer
  91. */
  92. struct igbvf_buffer {
  93. dma_addr_t dma;
  94. struct sk_buff *skb;
  95. union {
  96. /* Tx */
  97. struct {
  98. unsigned long time_stamp;
  99. union e1000_adv_tx_desc *next_to_watch;
  100. u16 length;
  101. u16 mapped_as_page;
  102. };
  103. /* Rx */
  104. struct {
  105. struct page *page;
  106. u64 page_dma;
  107. unsigned int page_offset;
  108. };
  109. };
  110. };
  111. union igbvf_desc {
  112. union e1000_adv_rx_desc rx_desc;
  113. union e1000_adv_tx_desc tx_desc;
  114. struct e1000_adv_tx_context_desc tx_context_desc;
  115. };
  116. struct igbvf_ring {
  117. struct igbvf_adapter *adapter; /* backlink */
  118. union igbvf_desc *desc; /* pointer to ring memory */
  119. dma_addr_t dma; /* phys address of ring */
  120. unsigned int size; /* length of ring in bytes */
  121. unsigned int count; /* number of desc. in ring */
  122. u16 next_to_use;
  123. u16 next_to_clean;
  124. u16 head;
  125. u16 tail;
  126. /* array of buffer information structs */
  127. struct igbvf_buffer *buffer_info;
  128. struct napi_struct napi;
  129. char name[IFNAMSIZ + 5];
  130. u32 eims_value;
  131. u32 itr_val;
  132. enum latency_range itr_range;
  133. u16 itr_register;
  134. int set_itr;
  135. struct sk_buff *rx_skb_top;
  136. struct igbvf_queue_stats stats;
  137. };
  138. /* board specific private data structure */
  139. struct igbvf_adapter {
  140. struct timer_list watchdog_timer;
  141. struct timer_list blink_timer;
  142. struct work_struct reset_task;
  143. struct work_struct watchdog_task;
  144. const struct igbvf_info *ei;
  145. unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
  146. u32 bd_number;
  147. u32 rx_buffer_len;
  148. u32 polling_interval;
  149. u16 mng_vlan_id;
  150. u16 link_speed;
  151. u16 link_duplex;
  152. spinlock_t tx_queue_lock; /* prevent concurrent tail updates */
  153. /* track device up/down/testing state */
  154. unsigned long state;
  155. /* Interrupt Throttle Rate */
  156. u32 requested_itr; /* ints/sec or adaptive */
  157. u32 current_itr; /* Actual ITR register value, not ints/sec */
  158. /* Tx */
  159. struct igbvf_ring *tx_ring /* One per active queue */
  160. ____cacheline_aligned_in_smp;
  161. unsigned int restart_queue;
  162. u32 txd_cmd;
  163. u32 tx_int_delay;
  164. u32 tx_abs_int_delay;
  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. /* Tx stats */
  170. u32 tx_timeout_count;
  171. u32 tx_fifo_head;
  172. u32 tx_head_addr;
  173. u32 tx_fifo_size;
  174. u32 tx_dma_failed;
  175. /* Rx */
  176. struct igbvf_ring *rx_ring;
  177. u32 rx_int_delay;
  178. u32 rx_abs_int_delay;
  179. /* Rx stats */
  180. u64 hw_csum_err;
  181. u64 hw_csum_good;
  182. u64 rx_hdr_split;
  183. u32 alloc_rx_buff_failed;
  184. u32 rx_dma_failed;
  185. unsigned int rx_ps_hdr_size;
  186. u32 max_frame_size;
  187. u32 min_frame_size;
  188. /* OS defined structs */
  189. struct net_device *netdev;
  190. struct pci_dev *pdev;
  191. struct net_device_stats net_stats;
  192. spinlock_t stats_lock; /* prevent concurrent stats updates */
  193. /* structs defined in e1000_hw.h */
  194. struct e1000_hw hw;
  195. /* The VF counters don't clear on read so we have to get a base
  196. * count on driver start up and always subtract that base on
  197. * on the first update, thus the flag..
  198. */
  199. struct e1000_vf_stats stats;
  200. u64 zero_base;
  201. struct igbvf_ring test_tx_ring;
  202. struct igbvf_ring test_rx_ring;
  203. u32 test_icr;
  204. u32 msg_enable;
  205. struct msix_entry *msix_entries;
  206. int int_mode;
  207. u32 eims_enable_mask;
  208. u32 eims_other;
  209. u32 int_counter0;
  210. u32 int_counter1;
  211. u32 eeprom_wol;
  212. u32 wol;
  213. u32 pba;
  214. bool fc_autoneg;
  215. unsigned long led_status;
  216. unsigned int flags;
  217. unsigned long last_reset;
  218. };
  219. struct igbvf_info {
  220. enum e1000_mac_type mac;
  221. unsigned int flags;
  222. u32 pba;
  223. void (*init_ops)(struct e1000_hw *);
  224. s32 (*get_variants)(struct igbvf_adapter *);
  225. };
  226. /* hardware capability, feature, and workaround flags */
  227. #define IGBVF_FLAG_RX_CSUM_DISABLED BIT(0)
  228. #define IGBVF_FLAG_RX_LB_VLAN_BSWAP BIT(1)
  229. #define IGBVF_RX_DESC_ADV(R, i) \
  230. (&((((R).desc))[i].rx_desc))
  231. #define IGBVF_TX_DESC_ADV(R, i) \
  232. (&((((R).desc))[i].tx_desc))
  233. #define IGBVF_TX_CTXTDESC_ADV(R, i) \
  234. (&((((R).desc))[i].tx_context_desc))
  235. enum igbvf_state_t {
  236. __IGBVF_TESTING,
  237. __IGBVF_RESETTING,
  238. __IGBVF_DOWN
  239. };
  240. extern char igbvf_driver_name[];
  241. extern const char igbvf_driver_version[];
  242. void igbvf_check_options(struct igbvf_adapter *);
  243. void igbvf_set_ethtool_ops(struct net_device *);
  244. int igbvf_up(struct igbvf_adapter *);
  245. void igbvf_down(struct igbvf_adapter *);
  246. void igbvf_reinit_locked(struct igbvf_adapter *);
  247. int igbvf_setup_rx_resources(struct igbvf_adapter *, struct igbvf_ring *);
  248. int igbvf_setup_tx_resources(struct igbvf_adapter *, struct igbvf_ring *);
  249. void igbvf_free_rx_resources(struct igbvf_ring *);
  250. void igbvf_free_tx_resources(struct igbvf_ring *);
  251. void igbvf_update_stats(struct igbvf_adapter *);
  252. extern unsigned int copybreak;
  253. #endif /* _IGBVF_H_ */