igbvf.h 7.0 KB

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