ixgbe.h 31 KB

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