ixgbe.h 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 1999 - 2018 Intel Corporation. */
  3. #ifndef _IXGBE_H_
  4. #define _IXGBE_H_
  5. #include <linux/bitops.h>
  6. #include <linux/types.h>
  7. #include <linux/pci.h>
  8. #include <linux/netdevice.h>
  9. #include <linux/cpumask.h>
  10. #include <linux/if_vlan.h>
  11. #include <linux/jiffies.h>
  12. #include <linux/phy.h>
  13. #include <linux/timecounter.h>
  14. #include <linux/net_tstamp.h>
  15. #include <linux/ptp_clock_kernel.h>
  16. #include "ixgbe_type.h"
  17. #include "ixgbe_common.h"
  18. #include "ixgbe_dcb.h"
  19. #if IS_ENABLED(CONFIG_FCOE)
  20. #define IXGBE_FCOE
  21. #include "ixgbe_fcoe.h"
  22. #endif /* IS_ENABLED(CONFIG_FCOE) */
  23. #ifdef CONFIG_IXGBE_DCA
  24. #include <linux/dca.h>
  25. #endif
  26. #include "ixgbe_ipsec.h"
  27. #include <net/xdp.h>
  28. /* common prefix used by pr_<> macros */
  29. #undef pr_fmt
  30. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  31. /* TX/RX descriptor defines */
  32. #define IXGBE_DEFAULT_TXD 512
  33. #define IXGBE_DEFAULT_TX_WORK 256
  34. #define IXGBE_MAX_TXD_82598 4096
  35. #define IXGBE_MAX_TXD_82599 8192
  36. #define IXGBE_MAX_TXD_X540 8192
  37. #define IXGBE_MAX_TXD_X550 32768
  38. #define IXGBE_MIN_TXD 64
  39. #if (PAGE_SIZE < 8192)
  40. #define IXGBE_DEFAULT_RXD 512
  41. #else
  42. #define IXGBE_DEFAULT_RXD 128
  43. #endif
  44. #define IXGBE_MAX_RXD_82598 4096
  45. #define IXGBE_MAX_RXD_82599 8192
  46. #define IXGBE_MAX_RXD_X540 8192
  47. #define IXGBE_MAX_RXD_X550 32768
  48. #define IXGBE_MIN_RXD 64
  49. /* flow control */
  50. #define IXGBE_MIN_FCRTL 0x40
  51. #define IXGBE_MAX_FCRTL 0x7FF80
  52. #define IXGBE_MIN_FCRTH 0x600
  53. #define IXGBE_MAX_FCRTH 0x7FFF0
  54. #define IXGBE_DEFAULT_FCPAUSE 0xFFFF
  55. #define IXGBE_MIN_FCPAUSE 0
  56. #define IXGBE_MAX_FCPAUSE 0xFFFF
  57. /* Supported Rx Buffer Sizes */
  58. #define IXGBE_RXBUFFER_256 256 /* Used for skb receive header */
  59. #define IXGBE_RXBUFFER_1536 1536
  60. #define IXGBE_RXBUFFER_2K 2048
  61. #define IXGBE_RXBUFFER_3K 3072
  62. #define IXGBE_RXBUFFER_4K 4096
  63. #define IXGBE_MAX_RXBUFFER 16384 /* largest size for a single descriptor */
  64. #define IXGBE_PKT_HDR_PAD (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2))
  65. /* Attempt to maximize the headroom available for incoming frames. We
  66. * use a 2K buffer for receives and need 1536/1534 to store the data for
  67. * the frame. This leaves us with 512 bytes of room. From that we need
  68. * to deduct the space needed for the shared info and the padding needed
  69. * to IP align the frame.
  70. *
  71. * Note: For cache line sizes 256 or larger this value is going to end
  72. * up negative. In these cases we should fall back to the 3K
  73. * buffers.
  74. */
  75. #if (PAGE_SIZE < 8192)
  76. #define IXGBE_MAX_2K_FRAME_BUILD_SKB (IXGBE_RXBUFFER_1536 - NET_IP_ALIGN)
  77. #define IXGBE_2K_TOO_SMALL_WITH_PADDING \
  78. ((NET_SKB_PAD + IXGBE_RXBUFFER_1536) > SKB_WITH_OVERHEAD(IXGBE_RXBUFFER_2K))
  79. static inline int ixgbe_compute_pad(int rx_buf_len)
  80. {
  81. int page_size, pad_size;
  82. page_size = ALIGN(rx_buf_len, PAGE_SIZE / 2);
  83. pad_size = SKB_WITH_OVERHEAD(page_size) - rx_buf_len;
  84. return pad_size;
  85. }
  86. static inline int ixgbe_skb_pad(void)
  87. {
  88. int rx_buf_len;
  89. /* If a 2K buffer cannot handle a standard Ethernet frame then
  90. * optimize padding for a 3K buffer instead of a 1.5K buffer.
  91. *
  92. * For a 3K buffer we need to add enough padding to allow for
  93. * tailroom due to NET_IP_ALIGN possibly shifting us out of
  94. * cache-line alignment.
  95. */
  96. if (IXGBE_2K_TOO_SMALL_WITH_PADDING)
  97. rx_buf_len = IXGBE_RXBUFFER_3K + SKB_DATA_ALIGN(NET_IP_ALIGN);
  98. else
  99. rx_buf_len = IXGBE_RXBUFFER_1536;
  100. /* if needed make room for NET_IP_ALIGN */
  101. rx_buf_len -= NET_IP_ALIGN;
  102. return ixgbe_compute_pad(rx_buf_len);
  103. }
  104. #define IXGBE_SKB_PAD ixgbe_skb_pad()
  105. #else
  106. #define IXGBE_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN)
  107. #endif
  108. /*
  109. * NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN means we
  110. * reserve 64 more, and skb_shared_info adds an additional 320 bytes more,
  111. * this adds up to 448 bytes of extra data.
  112. *
  113. * Since netdev_alloc_skb now allocates a page fragment we can use a value
  114. * of 256 and the resultant skb will have a truesize of 960 or less.
  115. */
  116. #define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_256
  117. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  118. #define IXGBE_RX_BUFFER_WRITE 16 /* Must be power of 2 */
  119. #define IXGBE_RX_DMA_ATTR \
  120. (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING)
  121. enum ixgbe_tx_flags {
  122. /* cmd_type flags */
  123. IXGBE_TX_FLAGS_HW_VLAN = 0x01,
  124. IXGBE_TX_FLAGS_TSO = 0x02,
  125. IXGBE_TX_FLAGS_TSTAMP = 0x04,
  126. /* olinfo flags */
  127. IXGBE_TX_FLAGS_CC = 0x08,
  128. IXGBE_TX_FLAGS_IPV4 = 0x10,
  129. IXGBE_TX_FLAGS_CSUM = 0x20,
  130. IXGBE_TX_FLAGS_IPSEC = 0x40,
  131. /* software defined flags */
  132. IXGBE_TX_FLAGS_SW_VLAN = 0x80,
  133. IXGBE_TX_FLAGS_FCOE = 0x100,
  134. };
  135. /* VLAN info */
  136. #define IXGBE_TX_FLAGS_VLAN_MASK 0xffff0000
  137. #define IXGBE_TX_FLAGS_VLAN_PRIO_MASK 0xe0000000
  138. #define IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT 29
  139. #define IXGBE_TX_FLAGS_VLAN_SHIFT 16
  140. #define IXGBE_MAX_VF_MC_ENTRIES 30
  141. #define IXGBE_MAX_VF_FUNCTIONS 64
  142. #define IXGBE_MAX_VFTA_ENTRIES 128
  143. #define MAX_EMULATION_MAC_ADDRS 16
  144. #define IXGBE_MAX_PF_MACVLANS 15
  145. #define VMDQ_P(p) ((p) + adapter->ring_feature[RING_F_VMDQ].offset)
  146. #define IXGBE_82599_VF_DEVICE_ID 0x10ED
  147. #define IXGBE_X540_VF_DEVICE_ID 0x1515
  148. #define UPDATE_VF_COUNTER_32bit(reg, last_counter, counter) \
  149. { \
  150. u32 current_counter = IXGBE_READ_REG(hw, reg); \
  151. if (current_counter < last_counter) \
  152. counter += 0x100000000LL; \
  153. last_counter = current_counter; \
  154. counter &= 0xFFFFFFFF00000000LL; \
  155. counter |= current_counter; \
  156. }
  157. #define UPDATE_VF_COUNTER_36bit(reg_lsb, reg_msb, last_counter, counter) \
  158. { \
  159. u64 current_counter_lsb = IXGBE_READ_REG(hw, reg_lsb); \
  160. u64 current_counter_msb = IXGBE_READ_REG(hw, reg_msb); \
  161. u64 current_counter = (current_counter_msb << 32) | \
  162. current_counter_lsb; \
  163. if (current_counter < last_counter) \
  164. counter += 0x1000000000LL; \
  165. last_counter = current_counter; \
  166. counter &= 0xFFFFFFF000000000LL; \
  167. counter |= current_counter; \
  168. }
  169. struct vf_stats {
  170. u64 gprc;
  171. u64 gorc;
  172. u64 gptc;
  173. u64 gotc;
  174. u64 mprc;
  175. };
  176. struct vf_data_storage {
  177. struct pci_dev *vfdev;
  178. unsigned char vf_mac_addresses[ETH_ALEN];
  179. u16 vf_mc_hashes[IXGBE_MAX_VF_MC_ENTRIES];
  180. u16 num_vf_mc_hashes;
  181. bool clear_to_send;
  182. struct vf_stats vfstats;
  183. struct vf_stats last_vfstats;
  184. struct vf_stats saved_rst_vfstats;
  185. bool pf_set_mac;
  186. u16 pf_vlan; /* When set, guest VLAN config not allowed. */
  187. u16 pf_qos;
  188. u16 tx_rate;
  189. int link_enable;
  190. int link_state;
  191. u8 spoofchk_enabled;
  192. bool rss_query_enabled;
  193. u8 trusted;
  194. int xcast_mode;
  195. unsigned int vf_api;
  196. u8 primary_abort_count;
  197. };
  198. enum ixgbevf_xcast_modes {
  199. IXGBEVF_XCAST_MODE_NONE = 0,
  200. IXGBEVF_XCAST_MODE_MULTI,
  201. IXGBEVF_XCAST_MODE_ALLMULTI,
  202. IXGBEVF_XCAST_MODE_PROMISC,
  203. };
  204. struct vf_macvlans {
  205. struct list_head l;
  206. int vf;
  207. bool free;
  208. bool is_macvlan;
  209. u8 vf_macvlan[ETH_ALEN];
  210. };
  211. #define IXGBE_MAX_TXD_PWR 14
  212. #define IXGBE_MAX_DATA_PER_TXD (1u << IXGBE_MAX_TXD_PWR)
  213. /* Tx Descriptors needed, worst case */
  214. #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IXGBE_MAX_DATA_PER_TXD)
  215. #define DESC_NEEDED (MAX_SKB_FRAGS + 4)
  216. /* wrapper around a pointer to a socket buffer,
  217. * so a DMA handle can be stored along with the buffer */
  218. struct ixgbe_tx_buffer {
  219. union ixgbe_adv_tx_desc *next_to_watch;
  220. unsigned long time_stamp;
  221. union {
  222. struct sk_buff *skb;
  223. struct xdp_frame *xdpf;
  224. };
  225. unsigned int bytecount;
  226. unsigned short gso_segs;
  227. __be16 protocol;
  228. DEFINE_DMA_UNMAP_ADDR(dma);
  229. DEFINE_DMA_UNMAP_LEN(len);
  230. u32 tx_flags;
  231. };
  232. struct ixgbe_rx_buffer {
  233. union {
  234. struct {
  235. struct sk_buff *skb;
  236. dma_addr_t dma;
  237. struct page *page;
  238. __u32 page_offset;
  239. __u16 pagecnt_bias;
  240. };
  241. struct {
  242. bool discard;
  243. struct xdp_buff *xdp;
  244. };
  245. };
  246. };
  247. struct ixgbe_queue_stats {
  248. u64 packets;
  249. u64 bytes;
  250. };
  251. struct ixgbe_tx_queue_stats {
  252. u64 restart_queue;
  253. u64 tx_busy;
  254. u64 tx_done_old;
  255. };
  256. struct ixgbe_rx_queue_stats {
  257. u64 rsc_count;
  258. u64 rsc_flush;
  259. u64 non_eop_descs;
  260. u64 alloc_rx_page;
  261. u64 alloc_rx_page_failed;
  262. u64 alloc_rx_buff_failed;
  263. u64 csum_err;
  264. };
  265. #define IXGBE_TS_HDR_LEN 8
  266. enum ixgbe_ring_state_t {
  267. __IXGBE_RX_3K_BUFFER,
  268. __IXGBE_RX_BUILD_SKB_ENABLED,
  269. __IXGBE_RX_RSC_ENABLED,
  270. __IXGBE_RX_CSUM_UDP_ZERO_ERR,
  271. __IXGBE_RX_FCOE,
  272. __IXGBE_TX_FDIR_INIT_DONE,
  273. __IXGBE_TX_XPS_INIT_DONE,
  274. __IXGBE_TX_DETECT_HANG,
  275. __IXGBE_HANG_CHECK_ARMED,
  276. __IXGBE_TX_XDP_RING,
  277. __IXGBE_TX_DISABLED,
  278. };
  279. #define ring_uses_build_skb(ring) \
  280. test_bit(__IXGBE_RX_BUILD_SKB_ENABLED, &(ring)->state)
  281. struct ixgbe_fwd_adapter {
  282. unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
  283. struct net_device *netdev;
  284. unsigned int tx_base_queue;
  285. unsigned int rx_base_queue;
  286. int pool;
  287. };
  288. #define check_for_tx_hang(ring) \
  289. test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
  290. #define set_check_for_tx_hang(ring) \
  291. set_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
  292. #define clear_check_for_tx_hang(ring) \
  293. clear_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
  294. #define ring_is_rsc_enabled(ring) \
  295. test_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
  296. #define set_ring_rsc_enabled(ring) \
  297. set_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
  298. #define clear_ring_rsc_enabled(ring) \
  299. clear_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
  300. #define ring_is_xdp(ring) \
  301. test_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
  302. #define set_ring_xdp(ring) \
  303. set_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
  304. #define clear_ring_xdp(ring) \
  305. clear_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
  306. struct ixgbe_ring {
  307. struct ixgbe_ring *next; /* pointer to next ring in q_vector */
  308. struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */
  309. struct net_device *netdev; /* netdev ring belongs to */
  310. struct bpf_prog *xdp_prog;
  311. struct device *dev; /* device for DMA mapping */
  312. void *desc; /* descriptor ring memory */
  313. union {
  314. struct ixgbe_tx_buffer *tx_buffer_info;
  315. struct ixgbe_rx_buffer *rx_buffer_info;
  316. };
  317. unsigned long state;
  318. u8 __iomem *tail;
  319. dma_addr_t dma; /* phys. address of descriptor ring */
  320. unsigned int size; /* length in bytes */
  321. u16 count; /* amount of descriptors */
  322. u8 queue_index; /* needed for multiqueue queue management */
  323. u8 reg_idx; /* holds the special value that gets
  324. * the hardware register offset
  325. * associated with this ring, which is
  326. * different for DCB and RSS modes
  327. */
  328. u16 next_to_use;
  329. u16 next_to_clean;
  330. unsigned long last_rx_timestamp;
  331. union {
  332. u16 next_to_alloc;
  333. struct {
  334. u8 atr_sample_rate;
  335. u8 atr_count;
  336. };
  337. };
  338. u8 dcb_tc;
  339. struct ixgbe_queue_stats stats;
  340. struct u64_stats_sync syncp;
  341. union {
  342. struct ixgbe_tx_queue_stats tx_stats;
  343. struct ixgbe_rx_queue_stats rx_stats;
  344. };
  345. u16 rx_offset;
  346. struct xdp_rxq_info xdp_rxq;
  347. spinlock_t tx_lock; /* used in XDP mode */
  348. struct xsk_buff_pool *xsk_pool;
  349. u16 ring_idx; /* {rx,tx,xdp}_ring back reference idx */
  350. u16 rx_buf_len;
  351. } ____cacheline_internodealigned_in_smp;
  352. enum ixgbe_ring_f_enum {
  353. RING_F_NONE = 0,
  354. RING_F_VMDQ, /* SR-IOV uses the same ring feature */
  355. RING_F_RSS,
  356. RING_F_FDIR,
  357. #ifdef IXGBE_FCOE
  358. RING_F_FCOE,
  359. #endif /* IXGBE_FCOE */
  360. RING_F_ARRAY_SIZE /* must be last in enum set */
  361. };
  362. #define IXGBE_MAX_RSS_INDICES 16
  363. #define IXGBE_MAX_RSS_INDICES_X550 63
  364. #define IXGBE_MAX_VMDQ_INDICES 64
  365. #define IXGBE_MAX_FDIR_INDICES 63 /* based on q_vector limit */
  366. #define IXGBE_MAX_FCOE_INDICES 8
  367. #define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
  368. #define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
  369. #define IXGBE_MAX_XDP_QS (IXGBE_MAX_FDIR_INDICES + 1)
  370. #define IXGBE_MAX_L2A_QUEUES 4
  371. #define IXGBE_BAD_L2A_QUEUE 3
  372. #define IXGBE_MAX_MACVLANS 63
  373. DECLARE_STATIC_KEY_FALSE(ixgbe_xdp_locking_key);
  374. struct ixgbe_ring_feature {
  375. u16 limit; /* upper limit on feature indices */
  376. u16 indices; /* current value of indices */
  377. u16 mask; /* Mask used for feature to ring mapping */
  378. u16 offset; /* offset to start of feature */
  379. } ____cacheline_internodealigned_in_smp;
  380. #define IXGBE_82599_VMDQ_8Q_MASK 0x78
  381. #define IXGBE_82599_VMDQ_4Q_MASK 0x7C
  382. #define IXGBE_82599_VMDQ_2Q_MASK 0x7E
  383. /*
  384. * FCoE requires that all Rx buffers be over 2200 bytes in length. Since
  385. * this is twice the size of a half page we need to double the page order
  386. * for FCoE enabled Rx queues.
  387. */
  388. static inline unsigned int ixgbe_rx_bufsz(struct ixgbe_ring *ring)
  389. {
  390. if (test_bit(__IXGBE_RX_3K_BUFFER, &ring->state))
  391. return IXGBE_RXBUFFER_3K;
  392. #if (PAGE_SIZE < 8192)
  393. if (ring_uses_build_skb(ring))
  394. return IXGBE_MAX_2K_FRAME_BUILD_SKB;
  395. #endif
  396. return IXGBE_RXBUFFER_2K;
  397. }
  398. static inline unsigned int ixgbe_rx_pg_order(struct ixgbe_ring *ring)
  399. {
  400. #if (PAGE_SIZE < 8192)
  401. if (test_bit(__IXGBE_RX_3K_BUFFER, &ring->state))
  402. return 1;
  403. #endif
  404. return 0;
  405. }
  406. #define ixgbe_rx_pg_size(_ring) (PAGE_SIZE << ixgbe_rx_pg_order(_ring))
  407. #define IXGBE_ITR_ADAPTIVE_MIN_INC 2
  408. #define IXGBE_ITR_ADAPTIVE_MIN_USECS 10
  409. #define IXGBE_ITR_ADAPTIVE_MAX_USECS 126
  410. #define IXGBE_ITR_ADAPTIVE_LATENCY 0x80
  411. #define IXGBE_ITR_ADAPTIVE_BULK 0x00
  412. struct ixgbe_ring_container {
  413. struct ixgbe_ring *ring; /* pointer to linked list of rings */
  414. unsigned long next_update; /* jiffies value of last update */
  415. unsigned int total_bytes; /* total bytes processed this int */
  416. unsigned int total_packets; /* total packets processed this int */
  417. u16 work_limit; /* total work allowed per interrupt */
  418. u8 count; /* total number of rings in vector */
  419. u8 itr; /* current ITR setting for ring */
  420. };
  421. /* iterator for handling rings in ring container */
  422. #define ixgbe_for_each_ring(pos, head) \
  423. for (pos = (head).ring; pos != NULL; pos = pos->next)
  424. #define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \
  425. ? 8 : 1)
  426. #define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS
  427. /* MAX_Q_VECTORS of these are allocated,
  428. * but we only use one per queue-specific vector.
  429. */
  430. struct ixgbe_q_vector {
  431. struct ixgbe_adapter *adapter;
  432. #ifdef CONFIG_IXGBE_DCA
  433. int cpu; /* CPU for DCA */
  434. #endif
  435. u16 v_idx; /* index of q_vector within array, also used for
  436. * finding the bit in EICR and friends that
  437. * represents the vector for this ring */
  438. u16 itr; /* Interrupt throttle rate written to EITR */
  439. struct ixgbe_ring_container rx, tx;
  440. struct napi_struct napi;
  441. struct rcu_head rcu; /* to avoid race with update stats on free */
  442. cpumask_t affinity_mask;
  443. int numa_node;
  444. char name[IFNAMSIZ + 9];
  445. /* for dynamic allocation of rings associated with this q_vector */
  446. struct ixgbe_ring ring[] ____cacheline_internodealigned_in_smp;
  447. };
  448. #ifdef CONFIG_IXGBE_HWMON
  449. #define IXGBE_HWMON_TYPE_LOC 0
  450. #define IXGBE_HWMON_TYPE_TEMP 1
  451. #define IXGBE_HWMON_TYPE_CAUTION 2
  452. #define IXGBE_HWMON_TYPE_MAX 3
  453. struct hwmon_attr {
  454. struct device_attribute dev_attr;
  455. struct ixgbe_hw *hw;
  456. struct ixgbe_thermal_diode_data *sensor;
  457. char name[12];
  458. };
  459. struct hwmon_buff {
  460. struct attribute_group group;
  461. const struct attribute_group *groups[2];
  462. struct attribute *attrs[IXGBE_MAX_SENSORS * 4 + 1];
  463. struct hwmon_attr hwmon_list[IXGBE_MAX_SENSORS * 4];
  464. unsigned int n_hwmon;
  465. };
  466. #endif /* CONFIG_IXGBE_HWMON */
  467. /*
  468. * microsecond values for various ITR rates shifted by 2 to fit itr register
  469. * with the first 3 bits reserved 0
  470. */
  471. #define IXGBE_MIN_RSC_ITR 24
  472. #define IXGBE_100K_ITR 40
  473. #define IXGBE_20K_ITR 200
  474. #define IXGBE_12K_ITR 336
  475. /* ixgbe_test_staterr - tests bits in Rx descriptor status and error fields */
  476. static inline __le32 ixgbe_test_staterr(union ixgbe_adv_rx_desc *rx_desc,
  477. const u32 stat_err_bits)
  478. {
  479. return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
  480. }
  481. static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)
  482. {
  483. u16 ntc = ring->next_to_clean;
  484. u16 ntu = ring->next_to_use;
  485. return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
  486. }
  487. #define IXGBE_RX_DESC(R, i) \
  488. (&(((union ixgbe_adv_rx_desc *)((R)->desc))[i]))
  489. #define IXGBE_TX_DESC(R, i) \
  490. (&(((union ixgbe_adv_tx_desc *)((R)->desc))[i]))
  491. #define IXGBE_TX_CTXTDESC(R, i) \
  492. (&(((struct ixgbe_adv_tx_context_desc *)((R)->desc))[i]))
  493. #define IXGBE_MAX_JUMBO_FRAME_SIZE 9728 /* Maximum Supported Size 9.5KB */
  494. #ifdef IXGBE_FCOE
  495. /* Use 3K as the baby jumbo frame size for FCoE */
  496. #define IXGBE_FCOE_JUMBO_FRAME_SIZE 3072
  497. #endif /* IXGBE_FCOE */
  498. #define OTHER_VECTOR 1
  499. #define NON_Q_VECTORS (OTHER_VECTOR)
  500. #define MAX_MSIX_VECTORS_82599 64
  501. #define MAX_Q_VECTORS_82599 64
  502. #define MAX_MSIX_VECTORS_82598 18
  503. #define MAX_Q_VECTORS_82598 16
  504. struct ixgbe_mac_addr {
  505. u8 addr[ETH_ALEN];
  506. u16 pool;
  507. u16 state; /* bitmask */
  508. };
  509. #define IXGBE_MAC_STATE_DEFAULT 0x1
  510. #define IXGBE_MAC_STATE_MODIFIED 0x2
  511. #define IXGBE_MAC_STATE_IN_USE 0x4
  512. #define MAX_Q_VECTORS MAX_Q_VECTORS_82599
  513. #define MAX_MSIX_COUNT MAX_MSIX_VECTORS_82599
  514. #define MIN_MSIX_Q_VECTORS 1
  515. #define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NON_Q_VECTORS)
  516. /* default to trying for four seconds */
  517. #define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)
  518. #define IXGBE_SFP_POLL_JIFFIES (2 * HZ) /* SFP poll every 2 seconds */
  519. #define IXGBE_PRIMARY_ABORT_LIMIT 5
  520. /* board specific private data structure */
  521. struct ixgbe_adapter {
  522. unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
  523. /* OS defined structs */
  524. struct net_device *netdev;
  525. struct bpf_prog *xdp_prog;
  526. struct pci_dev *pdev;
  527. struct mii_bus *mii_bus;
  528. unsigned long state;
  529. /* Some features need tri-state capability,
  530. * thus the additional *_CAPABLE flags.
  531. */
  532. u32 flags;
  533. #define IXGBE_FLAG_MSI_ENABLED BIT(1)
  534. #define IXGBE_FLAG_MSIX_ENABLED BIT(3)
  535. #define IXGBE_FLAG_RX_1BUF_CAPABLE BIT(4)
  536. #define IXGBE_FLAG_RX_PS_CAPABLE BIT(5)
  537. #define IXGBE_FLAG_RX_PS_ENABLED BIT(6)
  538. #define IXGBE_FLAG_DCA_ENABLED BIT(8)
  539. #define IXGBE_FLAG_DCA_CAPABLE BIT(9)
  540. #define IXGBE_FLAG_IMIR_ENABLED BIT(10)
  541. #define IXGBE_FLAG_MQ_CAPABLE BIT(11)
  542. #define IXGBE_FLAG_DCB_ENABLED BIT(12)
  543. #define IXGBE_FLAG_VMDQ_CAPABLE BIT(13)
  544. #define IXGBE_FLAG_VMDQ_ENABLED BIT(14)
  545. #define IXGBE_FLAG_FAN_FAIL_CAPABLE BIT(15)
  546. #define IXGBE_FLAG_NEED_LINK_UPDATE BIT(16)
  547. #define IXGBE_FLAG_NEED_LINK_CONFIG BIT(17)
  548. #define IXGBE_FLAG_FDIR_HASH_CAPABLE BIT(18)
  549. #define IXGBE_FLAG_FDIR_PERFECT_CAPABLE BIT(19)
  550. #define IXGBE_FLAG_FCOE_CAPABLE BIT(20)
  551. #define IXGBE_FLAG_FCOE_ENABLED BIT(21)
  552. #define IXGBE_FLAG_SRIOV_CAPABLE BIT(22)
  553. #define IXGBE_FLAG_SRIOV_ENABLED BIT(23)
  554. #define IXGBE_FLAG_RX_HWTSTAMP_ENABLED BIT(25)
  555. #define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER BIT(26)
  556. #define IXGBE_FLAG_DCB_CAPABLE BIT(27)
  557. u32 flags2;
  558. #define IXGBE_FLAG2_RSC_CAPABLE BIT(0)
  559. #define IXGBE_FLAG2_RSC_ENABLED BIT(1)
  560. #define IXGBE_FLAG2_TEMP_SENSOR_CAPABLE BIT(2)
  561. #define IXGBE_FLAG2_TEMP_SENSOR_EVENT BIT(3)
  562. #define IXGBE_FLAG2_SEARCH_FOR_SFP BIT(4)
  563. #define IXGBE_FLAG2_SFP_NEEDS_RESET BIT(5)
  564. #define IXGBE_FLAG2_FDIR_REQUIRES_REINIT BIT(7)
  565. #define IXGBE_FLAG2_RSS_FIELD_IPV4_UDP BIT(8)
  566. #define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP BIT(9)
  567. #define IXGBE_FLAG2_PTP_PPS_ENABLED BIT(10)
  568. #define IXGBE_FLAG2_PHY_INTERRUPT BIT(11)
  569. #define IXGBE_FLAG2_VLAN_PROMISC BIT(13)
  570. #define IXGBE_FLAG2_EEE_CAPABLE BIT(14)
  571. #define IXGBE_FLAG2_EEE_ENABLED BIT(15)
  572. #define IXGBE_FLAG2_RX_LEGACY BIT(16)
  573. #define IXGBE_FLAG2_IPSEC_ENABLED BIT(17)
  574. #define IXGBE_FLAG2_VF_IPSEC_ENABLED BIT(18)
  575. #define IXGBE_FLAG2_AUTO_DISABLE_VF BIT(19)
  576. /* Tx fast path data */
  577. int num_tx_queues;
  578. u16 tx_itr_setting;
  579. u16 tx_work_limit;
  580. u64 tx_ipsec;
  581. /* Rx fast path data */
  582. int num_rx_queues;
  583. u16 rx_itr_setting;
  584. u64 rx_ipsec;
  585. /* Port number used to identify VXLAN traffic */
  586. __be16 vxlan_port;
  587. __be16 geneve_port;
  588. /* XDP */
  589. int num_xdp_queues;
  590. struct ixgbe_ring *xdp_ring[IXGBE_MAX_XDP_QS];
  591. unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled rings */
  592. /* TX */
  593. struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp;
  594. u64 restart_queue;
  595. u64 lsc_int;
  596. u32 tx_timeout_count;
  597. /* RX */
  598. struct ixgbe_ring *rx_ring[MAX_RX_QUEUES];
  599. int num_rx_pools; /* == num_rx_queues in 82598 */
  600. int num_rx_queues_per_pool; /* 1 if 82598, can be many if 82599 */
  601. u64 hw_csum_rx_error;
  602. u64 hw_rx_no_dma_resources;
  603. u64 rsc_total_count;
  604. u64 rsc_total_flush;
  605. u64 non_eop_descs;
  606. u32 alloc_rx_page;
  607. u32 alloc_rx_page_failed;
  608. u32 alloc_rx_buff_failed;
  609. struct ixgbe_q_vector *q_vector[MAX_Q_VECTORS];
  610. /* DCB parameters */
  611. struct ieee_pfc *ixgbe_ieee_pfc;
  612. struct ieee_ets *ixgbe_ieee_ets;
  613. struct ixgbe_dcb_config dcb_cfg;
  614. struct ixgbe_dcb_config temp_dcb_cfg;
  615. u8 hw_tcs;
  616. u8 dcb_set_bitmap;
  617. u8 dcbx_cap;
  618. enum ixgbe_fc_mode last_lfc_mode;
  619. int num_q_vectors; /* current number of q_vectors for device */
  620. int max_q_vectors; /* true count of q_vectors for device */
  621. struct ixgbe_ring_feature ring_feature[RING_F_ARRAY_SIZE];
  622. struct msix_entry *msix_entries;
  623. u32 test_icr;
  624. struct ixgbe_ring test_tx_ring;
  625. struct ixgbe_ring test_rx_ring;
  626. /* structs defined in ixgbe_hw.h */
  627. struct ixgbe_hw hw;
  628. u16 msg_enable;
  629. struct ixgbe_hw_stats stats;
  630. u64 tx_busy;
  631. unsigned int tx_ring_count;
  632. unsigned int xdp_ring_count;
  633. unsigned int rx_ring_count;
  634. u32 link_speed;
  635. bool link_up;
  636. unsigned long sfp_poll_time;
  637. unsigned long link_check_timeout;
  638. struct timer_list service_timer;
  639. struct work_struct service_task;
  640. struct hlist_head fdir_filter_list;
  641. unsigned long fdir_overflow; /* number of times ATR was backed off */
  642. union ixgbe_atr_input fdir_mask;
  643. int fdir_filter_count;
  644. u32 fdir_pballoc;
  645. u32 atr_sample_rate;
  646. spinlock_t fdir_perfect_lock;
  647. #ifdef IXGBE_FCOE
  648. struct ixgbe_fcoe fcoe;
  649. #endif /* IXGBE_FCOE */
  650. u8 __iomem *io_addr; /* Mainly for iounmap use */
  651. u32 wol;
  652. u16 bridge_mode;
  653. char eeprom_id[NVM_VER_SIZE];
  654. u16 eeprom_cap;
  655. u32 interrupt_event;
  656. u32 led_reg;
  657. struct ptp_clock *ptp_clock;
  658. struct ptp_clock_info ptp_caps;
  659. struct work_struct ptp_tx_work;
  660. struct sk_buff *ptp_tx_skb;
  661. struct hwtstamp_config tstamp_config;
  662. unsigned long ptp_tx_start;
  663. unsigned long last_overflow_check;
  664. unsigned long last_rx_ptp_check;
  665. unsigned long last_rx_timestamp;
  666. spinlock_t tmreg_lock;
  667. struct cyclecounter hw_cc;
  668. struct timecounter hw_tc;
  669. u32 base_incval;
  670. u32 tx_hwtstamp_timeouts;
  671. u32 tx_hwtstamp_skipped;
  672. u32 rx_hwtstamp_cleared;
  673. void (*ptp_setup_sdp)(struct ixgbe_adapter *);
  674. /* SR-IOV */
  675. DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS);
  676. unsigned int num_vfs;
  677. struct vf_data_storage *vfinfo;
  678. int vf_rate_link_speed;
  679. struct vf_macvlans vf_mvs;
  680. struct vf_macvlans *mv_list;
  681. u32 timer_event_accumulator;
  682. u32 vferr_refcount;
  683. struct ixgbe_mac_addr *mac_table;
  684. struct kobject *info_kobj;
  685. #ifdef CONFIG_IXGBE_HWMON
  686. struct hwmon_buff *ixgbe_hwmon_buff;
  687. #endif /* CONFIG_IXGBE_HWMON */
  688. #ifdef CONFIG_DEBUG_FS
  689. struct dentry *ixgbe_dbg_adapter;
  690. #endif /*CONFIG_DEBUG_FS*/
  691. u8 default_up;
  692. /* Bitmask indicating in use pools */
  693. DECLARE_BITMAP(fwd_bitmask, IXGBE_MAX_MACVLANS + 1);
  694. #define IXGBE_MAX_LINK_HANDLE 10
  695. struct ixgbe_jump_table *jump_tables[IXGBE_MAX_LINK_HANDLE];
  696. unsigned long tables;
  697. /* maximum number of RETA entries among all devices supported by ixgbe
  698. * driver: currently it's x550 device in non-SRIOV mode
  699. */
  700. #define IXGBE_MAX_RETA_ENTRIES 512
  701. u8 rss_indir_tbl[IXGBE_MAX_RETA_ENTRIES];
  702. #define IXGBE_RSS_KEY_SIZE 40 /* size of RSS Hash Key in bytes */
  703. u32 *rss_key;
  704. #ifdef CONFIG_IXGBE_IPSEC
  705. struct ixgbe_ipsec *ipsec;
  706. #endif /* CONFIG_IXGBE_IPSEC */
  707. spinlock_t vfs_lock;
  708. };
  709. static inline int ixgbe_determine_xdp_q_idx(int cpu)
  710. {
  711. if (static_key_enabled(&ixgbe_xdp_locking_key))
  712. return cpu % IXGBE_MAX_XDP_QS;
  713. else
  714. return cpu;
  715. }
  716. static inline
  717. struct ixgbe_ring *ixgbe_determine_xdp_ring(struct ixgbe_adapter *adapter)
  718. {
  719. int index = ixgbe_determine_xdp_q_idx(smp_processor_id());
  720. return adapter->xdp_ring[index];
  721. }
  722. static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter)
  723. {
  724. switch (adapter->hw.mac.type) {
  725. case ixgbe_mac_82598EB:
  726. case ixgbe_mac_82599EB:
  727. case ixgbe_mac_X540:
  728. return IXGBE_MAX_RSS_INDICES;
  729. case ixgbe_mac_X550:
  730. case ixgbe_mac_X550EM_x:
  731. case ixgbe_mac_x550em_a:
  732. return IXGBE_MAX_RSS_INDICES_X550;
  733. default:
  734. return 0;
  735. }
  736. }
  737. struct ixgbe_fdir_filter {
  738. struct hlist_node fdir_node;
  739. union ixgbe_atr_input filter;
  740. u16 sw_idx;
  741. u64 action;
  742. };
  743. enum ixgbe_state_t {
  744. __IXGBE_TESTING,
  745. __IXGBE_RESETTING,
  746. __IXGBE_DOWN,
  747. __IXGBE_DISABLED,
  748. __IXGBE_REMOVING,
  749. __IXGBE_SERVICE_SCHED,
  750. __IXGBE_SERVICE_INITED,
  751. __IXGBE_IN_SFP_INIT,
  752. __IXGBE_PTP_RUNNING,
  753. __IXGBE_PTP_TX_IN_PROGRESS,
  754. __IXGBE_RESET_REQUESTED,
  755. };
  756. struct ixgbe_cb {
  757. union { /* Union defining head/tail partner */
  758. struct sk_buff *head;
  759. struct sk_buff *tail;
  760. };
  761. dma_addr_t dma;
  762. u16 append_cnt;
  763. bool page_released;
  764. };
  765. #define IXGBE_CB(skb) ((struct ixgbe_cb *)(skb)->cb)
  766. enum ixgbe_boards {
  767. board_82598,
  768. board_82599,
  769. board_X540,
  770. board_X550,
  771. board_X550EM_x,
  772. board_x550em_x_fw,
  773. board_x550em_a,
  774. board_x550em_a_fw,
  775. };
  776. extern const struct ixgbe_info ixgbe_82598_info;
  777. extern const struct ixgbe_info ixgbe_82599_info;
  778. extern const struct ixgbe_info ixgbe_X540_info;
  779. extern const struct ixgbe_info ixgbe_X550_info;
  780. extern const struct ixgbe_info ixgbe_X550EM_x_info;
  781. extern const struct ixgbe_info ixgbe_x550em_x_fw_info;
  782. extern const struct ixgbe_info ixgbe_x550em_a_info;
  783. extern const struct ixgbe_info ixgbe_x550em_a_fw_info;
  784. #ifdef CONFIG_IXGBE_DCB
  785. extern const struct dcbnl_rtnl_ops ixgbe_dcbnl_ops;
  786. #endif
  787. extern char ixgbe_driver_name[];
  788. #ifdef IXGBE_FCOE
  789. extern char ixgbe_default_device_descr[];
  790. #endif /* IXGBE_FCOE */
  791. int ixgbe_open(struct net_device *netdev);
  792. int ixgbe_close(struct net_device *netdev);
  793. void ixgbe_up(struct ixgbe_adapter *adapter);
  794. void ixgbe_down(struct ixgbe_adapter *adapter);
  795. void ixgbe_reinit_locked(struct ixgbe_adapter *adapter);
  796. void ixgbe_reset(struct ixgbe_adapter *adapter);
  797. void ixgbe_set_ethtool_ops(struct net_device *netdev);
  798. int ixgbe_setup_rx_resources(struct ixgbe_adapter *, struct ixgbe_ring *);
  799. int ixgbe_setup_tx_resources(struct ixgbe_ring *);
  800. void ixgbe_free_rx_resources(struct ixgbe_ring *);
  801. void ixgbe_free_tx_resources(struct ixgbe_ring *);
  802. void ixgbe_configure_rx_ring(struct ixgbe_adapter *, struct ixgbe_ring *);
  803. void ixgbe_configure_tx_ring(struct ixgbe_adapter *, struct ixgbe_ring *);
  804. void ixgbe_disable_rx(struct ixgbe_adapter *adapter);
  805. void ixgbe_disable_tx(struct ixgbe_adapter *adapter);
  806. void ixgbe_update_stats(struct ixgbe_adapter *adapter);
  807. int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter);
  808. bool ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
  809. u16 subdevice_id);
  810. #ifdef CONFIG_PCI_IOV
  811. void ixgbe_full_sync_mac_table(struct ixgbe_adapter *adapter);
  812. #endif
  813. int ixgbe_add_mac_filter(struct ixgbe_adapter *adapter,
  814. const u8 *addr, u16 queue);
  815. int ixgbe_del_mac_filter(struct ixgbe_adapter *adapter,
  816. const u8 *addr, u16 queue);
  817. void ixgbe_update_pf_promisc_vlvf(struct ixgbe_adapter *adapter, u32 vid);
  818. void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter);
  819. netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *, struct ixgbe_adapter *,
  820. struct ixgbe_ring *);
  821. void ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16);
  822. void ixgbe_write_eitr(struct ixgbe_q_vector *);
  823. int ixgbe_poll(struct napi_struct *napi, int budget);
  824. int ethtool_ioctl(struct ifreq *ifr);
  825. int ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw);
  826. int ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl);
  827. int ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl);
  828. int ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
  829. union ixgbe_atr_hash_dword input,
  830. union ixgbe_atr_hash_dword common,
  831. u8 queue);
  832. int ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
  833. union ixgbe_atr_input *input_mask);
  834. int ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
  835. union ixgbe_atr_input *input,
  836. u16 soft_id, u8 queue);
  837. int ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
  838. union ixgbe_atr_input *input,
  839. u16 soft_id);
  840. void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
  841. union ixgbe_atr_input *mask);
  842. int ixgbe_update_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
  843. struct ixgbe_fdir_filter *input,
  844. u16 sw_idx);
  845. void ixgbe_set_rx_mode(struct net_device *netdev);
  846. #ifdef CONFIG_IXGBE_DCB
  847. void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter);
  848. #endif
  849. int ixgbe_setup_tc(struct net_device *dev, u8 tc);
  850. void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32);
  851. void ixgbe_do_reset(struct net_device *netdev);
  852. #ifdef CONFIG_IXGBE_HWMON
  853. void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter);
  854. int ixgbe_sysfs_init(struct ixgbe_adapter *adapter);
  855. #endif /* CONFIG_IXGBE_HWMON */
  856. #ifdef IXGBE_FCOE
  857. void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter);
  858. int ixgbe_fso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first,
  859. u8 *hdr_len);
  860. int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
  861. union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb);
  862. int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
  863. struct scatterlist *sgl, unsigned int sgc);
  864. int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid,
  865. struct scatterlist *sgl, unsigned int sgc);
  866. int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid);
  867. int ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
  868. void ixgbe_free_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
  869. int ixgbe_fcoe_enable(struct net_device *netdev);
  870. int ixgbe_fcoe_disable(struct net_device *netdev);
  871. int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type);
  872. int ixgbe_fcoe_get_hbainfo(struct net_device *netdev,
  873. struct netdev_fcoe_hbainfo *info);
  874. u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter);
  875. #endif /* IXGBE_FCOE */
  876. #ifdef CONFIG_DEBUG_FS
  877. void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter);
  878. void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter);
  879. void ixgbe_dbg_init(void);
  880. void ixgbe_dbg_exit(void);
  881. #else
  882. static inline void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter) {}
  883. static inline void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter) {}
  884. static inline void ixgbe_dbg_init(void) {}
  885. static inline void ixgbe_dbg_exit(void) {}
  886. #endif /* CONFIG_DEBUG_FS */
  887. static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)
  888. {
  889. return netdev_get_tx_queue(ring->netdev, ring->queue_index);
  890. }
  891. void ixgbe_ptp_init(struct ixgbe_adapter *adapter);
  892. void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter);
  893. void ixgbe_ptp_stop(struct ixgbe_adapter *adapter);
  894. void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter);
  895. void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter);
  896. void ixgbe_ptp_tx_hang(struct ixgbe_adapter *adapter);
  897. void ixgbe_ptp_rx_pktstamp(struct ixgbe_q_vector *, struct sk_buff *);
  898. void ixgbe_ptp_rx_rgtstamp(struct ixgbe_q_vector *, struct sk_buff *skb);
  899. static inline void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring,
  900. union ixgbe_adv_rx_desc *rx_desc,
  901. struct sk_buff *skb)
  902. {
  903. if (unlikely(ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_TSIP))) {
  904. ixgbe_ptp_rx_pktstamp(rx_ring->q_vector, skb);
  905. return;
  906. }
  907. if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS)))
  908. return;
  909. ixgbe_ptp_rx_rgtstamp(rx_ring->q_vector, skb);
  910. /* Update the last_rx_timestamp timer in order to enable watchdog check
  911. * for error case of latched timestamp on a dropped packet.
  912. */
  913. rx_ring->last_rx_timestamp = jiffies;
  914. }
  915. int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
  916. int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
  917. void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter);
  918. void ixgbe_ptp_reset(struct ixgbe_adapter *adapter);
  919. void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter);
  920. #ifdef CONFIG_PCI_IOV
  921. void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter);
  922. #endif
  923. netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
  924. struct ixgbe_adapter *adapter,
  925. struct ixgbe_ring *tx_ring);
  926. u32 ixgbe_rss_indir_tbl_entries(struct ixgbe_adapter *adapter);
  927. void ixgbe_store_key(struct ixgbe_adapter *adapter);
  928. void ixgbe_store_reta(struct ixgbe_adapter *adapter);
  929. int ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
  930. u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm);
  931. #ifdef CONFIG_IXGBE_IPSEC
  932. void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter);
  933. void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter);
  934. void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter);
  935. void ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring,
  936. union ixgbe_adv_rx_desc *rx_desc,
  937. struct sk_buff *skb);
  938. int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first,
  939. struct ixgbe_ipsec_tx_data *itd);
  940. void ixgbe_ipsec_vf_clear(struct ixgbe_adapter *adapter, u32 vf);
  941. int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *mbuf, u32 vf);
  942. int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter, u32 *mbuf, u32 vf);
  943. #else
  944. static inline void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter) { }
  945. static inline void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter) { }
  946. static inline void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter) { }
  947. static inline void ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring,
  948. union ixgbe_adv_rx_desc *rx_desc,
  949. struct sk_buff *skb) { }
  950. static inline int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
  951. struct ixgbe_tx_buffer *first,
  952. struct ixgbe_ipsec_tx_data *itd) { return 0; }
  953. static inline void ixgbe_ipsec_vf_clear(struct ixgbe_adapter *adapter,
  954. u32 vf) { }
  955. static inline int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter,
  956. u32 *mbuf, u32 vf) { return -EACCES; }
  957. static inline int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter,
  958. u32 *mbuf, u32 vf) { return -EACCES; }
  959. #endif /* CONFIG_IXGBE_IPSEC */
  960. static inline bool ixgbe_enabled_xdp_adapter(struct ixgbe_adapter *adapter)
  961. {
  962. return !!adapter->xdp_prog;
  963. }
  964. #endif /* _IXGBE_H_ */