igbvf.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /*******************************************************************************
  2. Intel(R) 82576 Virtual Function Linux driver
  3. Copyright(c) 2009 - 2010 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 _IGBVF_H_
  22. #define _IGBVF_H_
  23. #include <linux/types.h>
  24. #include <linux/timer.h>
  25. #include <linux/io.h>
  26. #include <linux/netdevice.h>
  27. #include "vf.h"
  28. /* Forward declarations */
  29. struct igbvf_info;
  30. struct igbvf_adapter;
  31. /* Interrupt defines */
  32. #define IGBVF_START_ITR 648 /* ~6000 ints/sec */
  33. /* Interrupt modes, as used by the IntMode parameter */
  34. #define IGBVF_INT_MODE_LEGACY 0
  35. #define IGBVF_INT_MODE_MSI 1
  36. #define IGBVF_INT_MODE_MSIX 2
  37. /* Tx/Rx descriptor defines */
  38. #define IGBVF_DEFAULT_TXD 256
  39. #define IGBVF_MAX_TXD 4096
  40. #define IGBVF_MIN_TXD 80
  41. #define IGBVF_DEFAULT_RXD 256
  42. #define IGBVF_MAX_RXD 4096
  43. #define IGBVF_MIN_RXD 80
  44. #define IGBVF_MIN_ITR_USECS 10 /* 100000 irq/sec */
  45. #define IGBVF_MAX_ITR_USECS 10000 /* 100 irq/sec */
  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 IGBVF_RX_PTHRESH 16
  58. #define IGBVF_RX_HTHRESH 8
  59. #define IGBVF_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. #define IGBVF_FC_PAUSE_TIME 0x0680 /* 858 usec */
  63. /* How many Tx Descriptors do we need to call netif_wake_queue ? */
  64. #define IGBVF_TX_QUEUE_WAKE 32
  65. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  66. #define IGBVF_RX_BUFFER_WRITE 16 /* Must be power of 2 */
  67. #define AUTO_ALL_MODES 0
  68. #define IGBVF_EEPROM_APME 0x0400
  69. #define IGBVF_MNG_VLAN_NONE (-1)
  70. /* Number of packet split data buffers (not including the header buffer) */
  71. #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
  72. enum igbvf_boards {
  73. board_vf,
  74. board_i350_vf,
  75. };
  76. struct igbvf_queue_stats {
  77. u64 packets;
  78. u64 bytes;
  79. };
  80. /*
  81. * wrappers around a pointer to a socket buffer,
  82. * so a DMA handle can be stored along with the buffer
  83. */
  84. struct igbvf_buffer {
  85. dma_addr_t dma;
  86. struct sk_buff *skb;
  87. union {
  88. /* Tx */
  89. struct {
  90. unsigned long time_stamp;
  91. u16 length;
  92. u16 next_to_watch;
  93. u16 mapped_as_page;
  94. };
  95. /* Rx */
  96. struct {
  97. struct page *page;
  98. u64 page_dma;
  99. unsigned int page_offset;
  100. };
  101. };
  102. };
  103. union igbvf_desc {
  104. union e1000_adv_rx_desc rx_desc;
  105. union e1000_adv_tx_desc tx_desc;
  106. struct e1000_adv_tx_context_desc tx_context_desc;
  107. };
  108. struct igbvf_ring {
  109. struct igbvf_adapter *adapter; /* backlink */
  110. union igbvf_desc *desc; /* pointer to ring memory */
  111. dma_addr_t dma; /* phys address of ring */
  112. unsigned int size; /* length of ring in bytes */
  113. unsigned int count; /* number of desc. in ring */
  114. u16 next_to_use;
  115. u16 next_to_clean;
  116. u16 head;
  117. u16 tail;
  118. /* array of buffer information structs */
  119. struct igbvf_buffer *buffer_info;
  120. struct napi_struct napi;
  121. char name[IFNAMSIZ + 5];
  122. u32 eims_value;
  123. u32 itr_val;
  124. u16 itr_register;
  125. int set_itr;
  126. struct sk_buff *rx_skb_top;
  127. struct igbvf_queue_stats stats;
  128. };
  129. /* board specific private data structure */
  130. struct igbvf_adapter {
  131. struct timer_list watchdog_timer;
  132. struct timer_list blink_timer;
  133. struct work_struct reset_task;
  134. struct work_struct watchdog_task;
  135. const struct igbvf_info *ei;
  136. struct vlan_group *vlgrp;
  137. u32 bd_number;
  138. u32 rx_buffer_len;
  139. u32 polling_interval;
  140. u16 mng_vlan_id;
  141. u16 link_speed;
  142. u16 link_duplex;
  143. spinlock_t tx_queue_lock; /* prevent concurrent tail updates */
  144. /* track device up/down/testing state */
  145. unsigned long state;
  146. /* Interrupt Throttle Rate */
  147. u32 itr;
  148. u32 itr_setting;
  149. u16 tx_itr;
  150. u16 rx_itr;
  151. /*
  152. * Tx
  153. */
  154. struct igbvf_ring *tx_ring /* One per active queue */
  155. ____cacheline_aligned_in_smp;
  156. unsigned int restart_queue;
  157. u32 txd_cmd;
  158. u32 tx_int_delay;
  159. u32 tx_abs_int_delay;
  160. unsigned int total_tx_bytes;
  161. unsigned int total_tx_packets;
  162. unsigned int total_rx_bytes;
  163. unsigned int total_rx_packets;
  164. /* Tx stats */
  165. u32 tx_timeout_count;
  166. u32 tx_fifo_head;
  167. u32 tx_head_addr;
  168. u32 tx_fifo_size;
  169. u32 tx_dma_failed;
  170. /*
  171. * Rx
  172. */
  173. struct igbvf_ring *rx_ring;
  174. u32 rx_int_delay;
  175. u32 rx_abs_int_delay;
  176. /* Rx stats */
  177. u64 hw_csum_err;
  178. u64 hw_csum_good;
  179. u64 rx_hdr_split;
  180. u32 alloc_rx_buff_failed;
  181. u32 rx_dma_failed;
  182. unsigned int rx_ps_hdr_size;
  183. u32 max_frame_size;
  184. u32 min_frame_size;
  185. /* OS defined structs */
  186. struct net_device *netdev;
  187. struct pci_dev *pdev;
  188. struct net_device_stats net_stats;
  189. spinlock_t stats_lock; /* prevent concurrent stats updates */
  190. /* structs defined in e1000_hw.h */
  191. struct e1000_hw hw;
  192. /* The VF counters don't clear on read so we have to get a base
  193. * count on driver start up and always subtract that base on
  194. * on the first update, thus the flag..
  195. */
  196. struct e1000_vf_stats stats;
  197. u64 zero_base;
  198. struct igbvf_ring test_tx_ring;
  199. struct igbvf_ring test_rx_ring;
  200. u32 test_icr;
  201. u32 msg_enable;
  202. struct msix_entry *msix_entries;
  203. int int_mode;
  204. u32 eims_enable_mask;
  205. u32 eims_other;
  206. u32 int_counter0;
  207. u32 int_counter1;
  208. u32 eeprom_wol;
  209. u32 wol;
  210. u32 pba;
  211. bool fc_autoneg;
  212. unsigned long led_status;
  213. unsigned int flags;
  214. unsigned long last_reset;
  215. };
  216. struct igbvf_info {
  217. enum e1000_mac_type mac;
  218. unsigned int flags;
  219. u32 pba;
  220. void (*init_ops)(struct e1000_hw *);
  221. s32 (*get_variants)(struct igbvf_adapter *);
  222. };
  223. /* hardware capability, feature, and workaround flags */
  224. #define IGBVF_FLAG_RX_CSUM_DISABLED (1 << 0)
  225. #define IGBVF_RX_DESC_ADV(R, i) \
  226. (&((((R).desc))[i].rx_desc))
  227. #define IGBVF_TX_DESC_ADV(R, i) \
  228. (&((((R).desc))[i].tx_desc))
  229. #define IGBVF_TX_CTXTDESC_ADV(R, i) \
  230. (&((((R).desc))[i].tx_context_desc))
  231. enum igbvf_state_t {
  232. __IGBVF_TESTING,
  233. __IGBVF_RESETTING,
  234. __IGBVF_DOWN
  235. };
  236. enum latency_range {
  237. lowest_latency = 0,
  238. low_latency = 1,
  239. bulk_latency = 2,
  240. latency_invalid = 255
  241. };
  242. extern char igbvf_driver_name[];
  243. extern const char igbvf_driver_version[];
  244. extern void igbvf_check_options(struct igbvf_adapter *);
  245. extern void igbvf_set_ethtool_ops(struct net_device *);
  246. extern int igbvf_up(struct igbvf_adapter *);
  247. extern void igbvf_down(struct igbvf_adapter *);
  248. extern void igbvf_reinit_locked(struct igbvf_adapter *);
  249. extern int igbvf_setup_rx_resources(struct igbvf_adapter *, struct igbvf_ring *);
  250. extern int igbvf_setup_tx_resources(struct igbvf_adapter *, struct igbvf_ring *);
  251. extern void igbvf_free_rx_resources(struct igbvf_ring *);
  252. extern void igbvf_free_tx_resources(struct igbvf_ring *);
  253. extern void igbvf_update_stats(struct igbvf_adapter *);
  254. extern unsigned int copybreak;
  255. #endif /* _IGBVF_H_ */