igb.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 2007 - 2018 Intel Corporation. */
  3. /* Linux PRO/1000 Ethernet Driver main header file */
  4. #ifndef _IGB_H_
  5. #define _IGB_H_
  6. #include "e1000_mac.h"
  7. #include "e1000_82575.h"
  8. #include <linux/timecounter.h>
  9. #include <linux/net_tstamp.h>
  10. #include <linux/ptp_clock_kernel.h>
  11. #include <linux/bitops.h>
  12. #include <linux/if_vlan.h>
  13. #include <linux/i2c.h>
  14. #include <linux/i2c-algo-bit.h>
  15. #include <linux/pci.h>
  16. #include <linux/mdio.h>
  17. #include <net/xdp.h>
  18. struct igb_adapter;
  19. #define E1000_PCS_CFG_IGN_SD 1
  20. /* Interrupt defines */
  21. #define IGB_START_ITR 648 /* ~6000 ints/sec */
  22. #define IGB_4K_ITR 980
  23. #define IGB_20K_ITR 196
  24. #define IGB_70K_ITR 56
  25. /* TX/RX descriptor defines */
  26. #define IGB_DEFAULT_TXD 256
  27. #define IGB_DEFAULT_TX_WORK 128
  28. #define IGB_MIN_TXD 64
  29. #define IGB_MAX_TXD 4096
  30. #define IGB_DEFAULT_RXD 256
  31. #define IGB_MIN_RXD 64
  32. #define IGB_MAX_RXD 4096
  33. #define IGB_DEFAULT_ITR 3 /* dynamic */
  34. #define IGB_MAX_ITR_USECS 10000
  35. #define IGB_MIN_ITR_USECS 10
  36. #define NON_Q_VECTORS 1
  37. #define MAX_Q_VECTORS 8
  38. #define MAX_MSIX_ENTRIES 10
  39. /* Transmit and receive queues */
  40. #define IGB_MAX_RX_QUEUES 8
  41. #define IGB_MAX_RX_QUEUES_82575 4
  42. #define IGB_MAX_RX_QUEUES_I211 2
  43. #define IGB_MAX_TX_QUEUES 8
  44. #define IGB_MAX_VF_MC_ENTRIES 30
  45. #define IGB_MAX_VF_FUNCTIONS 8
  46. #define IGB_MAX_VFTA_ENTRIES 128
  47. #define IGB_82576_VF_DEV_ID 0x10CA
  48. #define IGB_I350_VF_DEV_ID 0x1520
  49. /* NVM version defines */
  50. #define IGB_MAJOR_MASK 0xF000
  51. #define IGB_MINOR_MASK 0x0FF0
  52. #define IGB_BUILD_MASK 0x000F
  53. #define IGB_COMB_VER_MASK 0x00FF
  54. #define IGB_MAJOR_SHIFT 12
  55. #define IGB_MINOR_SHIFT 4
  56. #define IGB_COMB_VER_SHFT 8
  57. #define IGB_NVM_VER_INVALID 0xFFFF
  58. #define IGB_ETRACK_SHIFT 16
  59. #define NVM_ETRACK_WORD 0x0042
  60. #define NVM_COMB_VER_OFF 0x0083
  61. #define NVM_COMB_VER_PTR 0x003d
  62. /* Transmit and receive latency (for PTP timestamps) */
  63. #define IGB_I210_TX_LATENCY_10 9542
  64. #define IGB_I210_TX_LATENCY_100 1024
  65. #define IGB_I210_TX_LATENCY_1000 178
  66. #define IGB_I210_RX_LATENCY_10 20662
  67. #define IGB_I210_RX_LATENCY_100 2213
  68. #define IGB_I210_RX_LATENCY_1000 448
  69. /* XDP */
  70. #define IGB_XDP_PASS 0
  71. #define IGB_XDP_CONSUMED BIT(0)
  72. #define IGB_XDP_TX BIT(1)
  73. #define IGB_XDP_REDIR BIT(2)
  74. struct vf_data_storage {
  75. unsigned char vf_mac_addresses[ETH_ALEN];
  76. u16 vf_mc_hashes[IGB_MAX_VF_MC_ENTRIES];
  77. u16 num_vf_mc_hashes;
  78. u32 flags;
  79. unsigned long last_nack;
  80. u16 pf_vlan; /* When set, guest VLAN config not allowed. */
  81. u16 pf_qos;
  82. u16 tx_rate;
  83. bool spoofchk_enabled;
  84. bool trusted;
  85. };
  86. /* Number of unicast MAC filters reserved for the PF in the RAR registers */
  87. #define IGB_PF_MAC_FILTERS_RESERVED 3
  88. struct vf_mac_filter {
  89. struct list_head l;
  90. int vf;
  91. bool free;
  92. u8 vf_mac[ETH_ALEN];
  93. };
  94. #define IGB_VF_FLAG_CTS 0x00000001 /* VF is clear to send data */
  95. #define IGB_VF_FLAG_UNI_PROMISC 0x00000002 /* VF has unicast promisc */
  96. #define IGB_VF_FLAG_MULTI_PROMISC 0x00000004 /* VF has multicast promisc */
  97. #define IGB_VF_FLAG_PF_SET_MAC 0x00000008 /* PF has set MAC address */
  98. /* RX descriptor control thresholds.
  99. * PTHRESH - MAC will consider prefetch if it has fewer than this number of
  100. * descriptors available in its onboard memory.
  101. * Setting this to 0 disables RX descriptor prefetch.
  102. * HTHRESH - MAC will only prefetch if there are at least this many descriptors
  103. * available in host memory.
  104. * If PTHRESH is 0, this should also be 0.
  105. * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
  106. * descriptors until either it has this many to write back, or the
  107. * ITR timer expires.
  108. */
  109. #define IGB_RX_PTHRESH ((hw->mac.type == e1000_i354) ? 12 : 8)
  110. #define IGB_RX_HTHRESH 8
  111. #define IGB_TX_PTHRESH ((hw->mac.type == e1000_i354) ? 20 : 8)
  112. #define IGB_TX_HTHRESH 1
  113. #define IGB_RX_WTHRESH ((hw->mac.type == e1000_82576 && \
  114. (adapter->flags & IGB_FLAG_HAS_MSIX)) ? 1 : 4)
  115. #define IGB_TX_WTHRESH ((hw->mac.type == e1000_82576 && \
  116. (adapter->flags & IGB_FLAG_HAS_MSIX)) ? 1 : 16)
  117. /* this is the size past which hardware will drop packets when setting LPE=0 */
  118. #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
  119. #define IGB_ETH_PKT_HDR_PAD (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2))
  120. /* Supported Rx Buffer Sizes */
  121. #define IGB_RXBUFFER_256 256
  122. #define IGB_RXBUFFER_1536 1536
  123. #define IGB_RXBUFFER_2048 2048
  124. #define IGB_RXBUFFER_3072 3072
  125. #define IGB_RX_HDR_LEN IGB_RXBUFFER_256
  126. #define IGB_TS_HDR_LEN 16
  127. /* Attempt to maximize the headroom available for incoming frames. We
  128. * use a 2K buffer for receives and need 1536/1534 to store the data for
  129. * the frame. This leaves us with 512 bytes of room. From that we need
  130. * to deduct the space needed for the shared info and the padding needed
  131. * to IP align the frame.
  132. *
  133. * Note: For cache line sizes 256 or larger this value is going to end
  134. * up negative. In these cases we should fall back to the 3K
  135. * buffers.
  136. */
  137. #if (PAGE_SIZE < 8192)
  138. #define IGB_MAX_FRAME_BUILD_SKB (IGB_RXBUFFER_1536 - NET_IP_ALIGN)
  139. #define IGB_2K_TOO_SMALL_WITH_PADDING \
  140. ((NET_SKB_PAD + IGB_TS_HDR_LEN + IGB_RXBUFFER_1536) > SKB_WITH_OVERHEAD(IGB_RXBUFFER_2048))
  141. static inline int igb_compute_pad(int rx_buf_len)
  142. {
  143. int page_size, pad_size;
  144. page_size = ALIGN(rx_buf_len, PAGE_SIZE / 2);
  145. pad_size = SKB_WITH_OVERHEAD(page_size) - rx_buf_len;
  146. return pad_size;
  147. }
  148. static inline int igb_skb_pad(void)
  149. {
  150. int rx_buf_len;
  151. /* If a 2K buffer cannot handle a standard Ethernet frame then
  152. * optimize padding for a 3K buffer instead of a 1.5K buffer.
  153. *
  154. * For a 3K buffer we need to add enough padding to allow for
  155. * tailroom due to NET_IP_ALIGN possibly shifting us out of
  156. * cache-line alignment.
  157. */
  158. if (IGB_2K_TOO_SMALL_WITH_PADDING)
  159. rx_buf_len = IGB_RXBUFFER_3072 + SKB_DATA_ALIGN(NET_IP_ALIGN);
  160. else
  161. rx_buf_len = IGB_RXBUFFER_1536;
  162. /* if needed make room for NET_IP_ALIGN */
  163. rx_buf_len -= NET_IP_ALIGN;
  164. return igb_compute_pad(rx_buf_len);
  165. }
  166. #define IGB_SKB_PAD igb_skb_pad()
  167. #else
  168. #define IGB_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN)
  169. #endif
  170. /* How many Rx Buffers do we bundle into one write to the hardware ? */
  171. #define IGB_RX_BUFFER_WRITE 16 /* Must be power of 2 */
  172. #define IGB_RX_DMA_ATTR \
  173. (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING)
  174. #define AUTO_ALL_MODES 0
  175. #define IGB_EEPROM_APME 0x0400
  176. #ifndef IGB_MASTER_SLAVE
  177. /* Switch to override PHY master/slave setting */
  178. #define IGB_MASTER_SLAVE e1000_ms_hw_default
  179. #endif
  180. #define IGB_MNG_VLAN_NONE -1
  181. enum igb_tx_flags {
  182. /* cmd_type flags */
  183. IGB_TX_FLAGS_VLAN = 0x01,
  184. IGB_TX_FLAGS_TSO = 0x02,
  185. IGB_TX_FLAGS_TSTAMP = 0x04,
  186. /* olinfo flags */
  187. IGB_TX_FLAGS_IPV4 = 0x10,
  188. IGB_TX_FLAGS_CSUM = 0x20,
  189. };
  190. /* VLAN info */
  191. #define IGB_TX_FLAGS_VLAN_MASK 0xffff0000
  192. #define IGB_TX_FLAGS_VLAN_SHIFT 16
  193. /* The largest size we can write to the descriptor is 65535. In order to
  194. * maintain a power of two alignment we have to limit ourselves to 32K.
  195. */
  196. #define IGB_MAX_TXD_PWR 15
  197. #define IGB_MAX_DATA_PER_TXD (1u << IGB_MAX_TXD_PWR)
  198. /* Tx Descriptors needed, worst case */
  199. #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IGB_MAX_DATA_PER_TXD)
  200. #define DESC_NEEDED (MAX_SKB_FRAGS + 4)
  201. /* EEPROM byte offsets */
  202. #define IGB_SFF_8472_SWAP 0x5C
  203. #define IGB_SFF_8472_COMP 0x5E
  204. /* Bitmasks */
  205. #define IGB_SFF_ADDRESSING_MODE 0x4
  206. #define IGB_SFF_8472_UNSUP 0x00
  207. /* TX resources are shared between XDP and netstack
  208. * and we need to tag the buffer type to distinguish them
  209. */
  210. enum igb_tx_buf_type {
  211. IGB_TYPE_SKB = 0,
  212. IGB_TYPE_XDP,
  213. };
  214. /* wrapper around a pointer to a socket buffer,
  215. * so a DMA handle can be stored along with the buffer
  216. */
  217. struct igb_tx_buffer {
  218. union e1000_adv_tx_desc *next_to_watch;
  219. unsigned long time_stamp;
  220. enum igb_tx_buf_type type;
  221. union {
  222. struct sk_buff *skb;
  223. struct xdp_frame *xdpf;
  224. };
  225. unsigned int bytecount;
  226. u16 gso_segs;
  227. __be16 protocol;
  228. DEFINE_DMA_UNMAP_ADDR(dma);
  229. DEFINE_DMA_UNMAP_LEN(len);
  230. u32 tx_flags;
  231. };
  232. struct igb_rx_buffer {
  233. dma_addr_t dma;
  234. struct page *page;
  235. #if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)
  236. __u32 page_offset;
  237. #else
  238. __u16 page_offset;
  239. #endif
  240. __u16 pagecnt_bias;
  241. };
  242. struct igb_tx_queue_stats {
  243. u64 packets;
  244. u64 bytes;
  245. u64 restart_queue;
  246. u64 restart_queue2;
  247. };
  248. struct igb_rx_queue_stats {
  249. u64 packets;
  250. u64 bytes;
  251. u64 drops;
  252. u64 csum_err;
  253. u64 alloc_failed;
  254. };
  255. struct igb_ring_container {
  256. struct igb_ring *ring; /* pointer to linked list of rings */
  257. unsigned int total_bytes; /* total bytes processed this int */
  258. unsigned int total_packets; /* total packets processed this int */
  259. u16 work_limit; /* total work allowed per interrupt */
  260. u8 count; /* total number of rings in vector */
  261. u8 itr; /* current ITR setting for ring */
  262. };
  263. struct igb_ring {
  264. struct igb_q_vector *q_vector; /* backlink to q_vector */
  265. struct net_device *netdev; /* back pointer to net_device */
  266. struct bpf_prog *xdp_prog;
  267. struct device *dev; /* device pointer for dma mapping */
  268. union { /* array of buffer info structs */
  269. struct igb_tx_buffer *tx_buffer_info;
  270. struct igb_rx_buffer *rx_buffer_info;
  271. };
  272. void *desc; /* descriptor ring memory */
  273. unsigned long flags; /* ring specific flags */
  274. void __iomem *tail; /* pointer to ring tail register */
  275. dma_addr_t dma; /* phys address of the ring */
  276. unsigned int size; /* length of desc. ring in bytes */
  277. u16 count; /* number of desc. in the ring */
  278. u8 queue_index; /* logical index of the ring*/
  279. u8 reg_idx; /* physical index of the ring */
  280. bool launchtime_enable; /* true if LaunchTime is enabled */
  281. bool cbs_enable; /* indicates if CBS is enabled */
  282. s32 idleslope; /* idleSlope in kbps */
  283. s32 sendslope; /* sendSlope in kbps */
  284. s32 hicredit; /* hiCredit in bytes */
  285. s32 locredit; /* loCredit in bytes */
  286. /* everything past this point are written often */
  287. u16 next_to_clean;
  288. u16 next_to_use;
  289. u16 next_to_alloc;
  290. union {
  291. /* TX */
  292. struct {
  293. struct igb_tx_queue_stats tx_stats;
  294. struct u64_stats_sync tx_syncp;
  295. struct u64_stats_sync tx_syncp2;
  296. };
  297. /* RX */
  298. struct {
  299. struct sk_buff *skb;
  300. struct igb_rx_queue_stats rx_stats;
  301. struct u64_stats_sync rx_syncp;
  302. };
  303. };
  304. struct xdp_rxq_info xdp_rxq;
  305. } ____cacheline_internodealigned_in_smp;
  306. struct igb_q_vector {
  307. struct igb_adapter *adapter; /* backlink */
  308. int cpu; /* CPU for DCA */
  309. u32 eims_value; /* EIMS mask value */
  310. u16 itr_val;
  311. u8 set_itr;
  312. void __iomem *itr_register;
  313. struct igb_ring_container rx, tx;
  314. struct napi_struct napi;
  315. struct rcu_head rcu; /* to avoid race with update stats on free */
  316. char name[IFNAMSIZ + 9];
  317. /* for dynamic allocation of rings associated with this q_vector */
  318. struct igb_ring ring[] ____cacheline_internodealigned_in_smp;
  319. };
  320. enum e1000_ring_flags_t {
  321. IGB_RING_FLAG_RX_3K_BUFFER,
  322. IGB_RING_FLAG_RX_BUILD_SKB_ENABLED,
  323. IGB_RING_FLAG_RX_SCTP_CSUM,
  324. IGB_RING_FLAG_RX_LB_VLAN_BSWAP,
  325. IGB_RING_FLAG_TX_CTX_IDX,
  326. IGB_RING_FLAG_TX_DETECT_HANG
  327. };
  328. #define ring_uses_large_buffer(ring) \
  329. test_bit(IGB_RING_FLAG_RX_3K_BUFFER, &(ring)->flags)
  330. #define set_ring_uses_large_buffer(ring) \
  331. set_bit(IGB_RING_FLAG_RX_3K_BUFFER, &(ring)->flags)
  332. #define clear_ring_uses_large_buffer(ring) \
  333. clear_bit(IGB_RING_FLAG_RX_3K_BUFFER, &(ring)->flags)
  334. #define ring_uses_build_skb(ring) \
  335. test_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags)
  336. #define set_ring_build_skb_enabled(ring) \
  337. set_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags)
  338. #define clear_ring_build_skb_enabled(ring) \
  339. clear_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags)
  340. static inline unsigned int igb_rx_bufsz(struct igb_ring *ring)
  341. {
  342. #if (PAGE_SIZE < 8192)
  343. if (ring_uses_large_buffer(ring))
  344. return IGB_RXBUFFER_3072;
  345. if (ring_uses_build_skb(ring))
  346. return IGB_MAX_FRAME_BUILD_SKB;
  347. #endif
  348. return IGB_RXBUFFER_2048;
  349. }
  350. static inline unsigned int igb_rx_pg_order(struct igb_ring *ring)
  351. {
  352. #if (PAGE_SIZE < 8192)
  353. if (ring_uses_large_buffer(ring))
  354. return 1;
  355. #endif
  356. return 0;
  357. }
  358. #define igb_rx_pg_size(_ring) (PAGE_SIZE << igb_rx_pg_order(_ring))
  359. #define IGB_TXD_DCMD (E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_RS)
  360. #define IGB_RX_DESC(R, i) \
  361. (&(((union e1000_adv_rx_desc *)((R)->desc))[i]))
  362. #define IGB_TX_DESC(R, i) \
  363. (&(((union e1000_adv_tx_desc *)((R)->desc))[i]))
  364. #define IGB_TX_CTXTDESC(R, i) \
  365. (&(((struct e1000_adv_tx_context_desc *)((R)->desc))[i]))
  366. /* igb_test_staterr - tests bits within Rx descriptor status and error fields */
  367. static inline __le32 igb_test_staterr(union e1000_adv_rx_desc *rx_desc,
  368. const u32 stat_err_bits)
  369. {
  370. return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
  371. }
  372. /* igb_desc_unused - calculate if we have unused descriptors */
  373. static inline int igb_desc_unused(struct igb_ring *ring)
  374. {
  375. if (ring->next_to_clean > ring->next_to_use)
  376. return ring->next_to_clean - ring->next_to_use - 1;
  377. return ring->count + ring->next_to_clean - ring->next_to_use - 1;
  378. }
  379. #ifdef CONFIG_IGB_HWMON
  380. #define IGB_HWMON_TYPE_LOC 0
  381. #define IGB_HWMON_TYPE_TEMP 1
  382. #define IGB_HWMON_TYPE_CAUTION 2
  383. #define IGB_HWMON_TYPE_MAX 3
  384. struct hwmon_attr {
  385. struct device_attribute dev_attr;
  386. struct e1000_hw *hw;
  387. struct e1000_thermal_diode_data *sensor;
  388. char name[12];
  389. };
  390. struct hwmon_buff {
  391. struct attribute_group group;
  392. const struct attribute_group *groups[2];
  393. struct attribute *attrs[E1000_MAX_SENSORS * 4 + 1];
  394. struct hwmon_attr hwmon_list[E1000_MAX_SENSORS * 4];
  395. unsigned int n_hwmon;
  396. };
  397. #endif
  398. /* The number of L2 ether-type filter registers, Index 3 is reserved
  399. * for PTP 1588 timestamp
  400. */
  401. #define MAX_ETYPE_FILTER (4 - 1)
  402. /* ETQF filter list: one static filter per filter consumer. This is
  403. * to avoid filter collisions later. Add new filters here!!
  404. *
  405. * Current filters: Filter 3
  406. */
  407. #define IGB_ETQF_FILTER_1588 3
  408. #define IGB_N_EXTTS 2
  409. #define IGB_N_PEROUT 2
  410. #define IGB_N_SDP 4
  411. #define IGB_RETA_SIZE 128
  412. enum igb_filter_match_flags {
  413. IGB_FILTER_FLAG_ETHER_TYPE = 0x1,
  414. IGB_FILTER_FLAG_VLAN_TCI = 0x2,
  415. IGB_FILTER_FLAG_SRC_MAC_ADDR = 0x4,
  416. IGB_FILTER_FLAG_DST_MAC_ADDR = 0x8,
  417. };
  418. #define IGB_MAX_RXNFC_FILTERS 16
  419. /* RX network flow classification data structure */
  420. struct igb_nfc_input {
  421. /* Byte layout in order, all values with MSB first:
  422. * match_flags - 1 byte
  423. * etype - 2 bytes
  424. * vlan_tci - 2 bytes
  425. */
  426. u8 match_flags;
  427. __be16 etype;
  428. __be16 vlan_tci;
  429. u8 src_addr[ETH_ALEN];
  430. u8 dst_addr[ETH_ALEN];
  431. };
  432. struct igb_nfc_filter {
  433. struct hlist_node nfc_node;
  434. struct igb_nfc_input filter;
  435. unsigned long cookie;
  436. u16 etype_reg_index;
  437. u16 sw_idx;
  438. u16 action;
  439. };
  440. struct igb_mac_addr {
  441. u8 addr[ETH_ALEN];
  442. u8 queue;
  443. u8 state; /* bitmask */
  444. };
  445. #define IGB_MAC_STATE_DEFAULT 0x1
  446. #define IGB_MAC_STATE_IN_USE 0x2
  447. #define IGB_MAC_STATE_SRC_ADDR 0x4
  448. #define IGB_MAC_STATE_QUEUE_STEERING 0x8
  449. /* board specific private data structure */
  450. struct igb_adapter {
  451. unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
  452. struct net_device *netdev;
  453. struct bpf_prog *xdp_prog;
  454. unsigned long state;
  455. unsigned int flags;
  456. unsigned int num_q_vectors;
  457. struct msix_entry msix_entries[MAX_MSIX_ENTRIES];
  458. /* Interrupt Throttle Rate */
  459. u32 rx_itr_setting;
  460. u32 tx_itr_setting;
  461. u16 tx_itr;
  462. u16 rx_itr;
  463. /* TX */
  464. u16 tx_work_limit;
  465. u32 tx_timeout_count;
  466. int num_tx_queues;
  467. struct igb_ring *tx_ring[16];
  468. /* RX */
  469. int num_rx_queues;
  470. struct igb_ring *rx_ring[16];
  471. u32 max_frame_size;
  472. u32 min_frame_size;
  473. struct timer_list watchdog_timer;
  474. struct timer_list phy_info_timer;
  475. u16 mng_vlan_id;
  476. u32 bd_number;
  477. u32 wol;
  478. u32 en_mng_pt;
  479. u16 link_speed;
  480. u16 link_duplex;
  481. u8 __iomem *io_addr; /* Mainly for iounmap use */
  482. struct work_struct reset_task;
  483. struct work_struct watchdog_task;
  484. bool fc_autoneg;
  485. u8 tx_timeout_factor;
  486. struct timer_list blink_timer;
  487. unsigned long led_status;
  488. /* OS defined structs */
  489. struct pci_dev *pdev;
  490. spinlock_t stats64_lock;
  491. struct rtnl_link_stats64 stats64;
  492. /* structs defined in e1000_hw.h */
  493. struct e1000_hw hw;
  494. struct e1000_hw_stats stats;
  495. struct e1000_phy_info phy_info;
  496. u32 test_icr;
  497. struct igb_ring test_tx_ring;
  498. struct igb_ring test_rx_ring;
  499. int msg_enable;
  500. struct igb_q_vector *q_vector[MAX_Q_VECTORS];
  501. u32 eims_enable_mask;
  502. u32 eims_other;
  503. /* to not mess up cache alignment, always add to the bottom */
  504. u16 tx_ring_count;
  505. u16 rx_ring_count;
  506. unsigned int vfs_allocated_count;
  507. struct vf_data_storage *vf_data;
  508. int vf_rate_link_speed;
  509. u32 rss_queues;
  510. u32 wvbr;
  511. u32 *shadow_vfta;
  512. struct ptp_clock *ptp_clock;
  513. struct ptp_clock_info ptp_caps;
  514. struct delayed_work ptp_overflow_work;
  515. struct work_struct ptp_tx_work;
  516. struct sk_buff *ptp_tx_skb;
  517. struct hwtstamp_config tstamp_config;
  518. unsigned long ptp_tx_start;
  519. unsigned long last_rx_ptp_check;
  520. unsigned long last_rx_timestamp;
  521. unsigned int ptp_flags;
  522. spinlock_t tmreg_lock;
  523. struct cyclecounter cc;
  524. struct timecounter tc;
  525. u32 tx_hwtstamp_timeouts;
  526. u32 tx_hwtstamp_skipped;
  527. u32 rx_hwtstamp_cleared;
  528. bool pps_sys_wrap_on;
  529. struct ptp_pin_desc sdp_config[IGB_N_SDP];
  530. struct {
  531. struct timespec64 start;
  532. struct timespec64 period;
  533. } perout[IGB_N_PEROUT];
  534. char fw_version[32];
  535. #ifdef CONFIG_IGB_HWMON
  536. struct hwmon_buff *igb_hwmon_buff;
  537. bool ets;
  538. #endif
  539. struct i2c_algo_bit_data i2c_algo;
  540. struct i2c_adapter i2c_adap;
  541. struct i2c_client *i2c_client;
  542. u32 rss_indir_tbl_init;
  543. u8 rss_indir_tbl[IGB_RETA_SIZE];
  544. unsigned long link_check_timeout;
  545. int copper_tries;
  546. struct e1000_info ei;
  547. u16 eee_advert;
  548. /* RX network flow classification support */
  549. struct hlist_head nfc_filter_list;
  550. struct hlist_head cls_flower_list;
  551. unsigned int nfc_filter_count;
  552. /* lock for RX network flow classification filter */
  553. spinlock_t nfc_lock;
  554. bool etype_bitmap[MAX_ETYPE_FILTER];
  555. struct igb_mac_addr *mac_table;
  556. struct vf_mac_filter vf_macs;
  557. struct vf_mac_filter *vf_mac_list;
  558. /* lock for VF resources */
  559. spinlock_t vfs_lock;
  560. };
  561. /* flags controlling PTP/1588 function */
  562. #define IGB_PTP_ENABLED BIT(0)
  563. #define IGB_PTP_OVERFLOW_CHECK BIT(1)
  564. #define IGB_FLAG_HAS_MSI BIT(0)
  565. #define IGB_FLAG_DCA_ENABLED BIT(1)
  566. #define IGB_FLAG_QUAD_PORT_A BIT(2)
  567. #define IGB_FLAG_QUEUE_PAIRS BIT(3)
  568. #define IGB_FLAG_DMAC BIT(4)
  569. #define IGB_FLAG_RSS_FIELD_IPV4_UDP BIT(6)
  570. #define IGB_FLAG_RSS_FIELD_IPV6_UDP BIT(7)
  571. #define IGB_FLAG_WOL_SUPPORTED BIT(8)
  572. #define IGB_FLAG_NEED_LINK_UPDATE BIT(9)
  573. #define IGB_FLAG_MEDIA_RESET BIT(10)
  574. #define IGB_FLAG_MAS_CAPABLE BIT(11)
  575. #define IGB_FLAG_MAS_ENABLE BIT(12)
  576. #define IGB_FLAG_HAS_MSIX BIT(13)
  577. #define IGB_FLAG_EEE BIT(14)
  578. #define IGB_FLAG_VLAN_PROMISC BIT(15)
  579. #define IGB_FLAG_RX_LEGACY BIT(16)
  580. #define IGB_FLAG_FQTSS BIT(17)
  581. /* Media Auto Sense */
  582. #define IGB_MAS_ENABLE_0 0X0001
  583. #define IGB_MAS_ENABLE_1 0X0002
  584. #define IGB_MAS_ENABLE_2 0X0004
  585. #define IGB_MAS_ENABLE_3 0X0008
  586. /* DMA Coalescing defines */
  587. #define IGB_MIN_TXPBSIZE 20408
  588. #define IGB_TX_BUF_4096 4096
  589. #define IGB_DMCTLX_DCFLUSH_DIS 0x80000000 /* Disable DMA Coal Flush */
  590. #define IGB_82576_TSYNC_SHIFT 19
  591. enum e1000_state_t {
  592. __IGB_TESTING,
  593. __IGB_RESETTING,
  594. __IGB_DOWN,
  595. __IGB_PTP_TX_IN_PROGRESS,
  596. };
  597. enum igb_boards {
  598. board_82575,
  599. };
  600. extern char igb_driver_name[];
  601. int igb_xmit_xdp_ring(struct igb_adapter *adapter,
  602. struct igb_ring *ring,
  603. struct xdp_frame *xdpf);
  604. int igb_open(struct net_device *netdev);
  605. int igb_close(struct net_device *netdev);
  606. int igb_up(struct igb_adapter *);
  607. void igb_down(struct igb_adapter *);
  608. void igb_reinit_locked(struct igb_adapter *);
  609. void igb_reset(struct igb_adapter *);
  610. int igb_reinit_queues(struct igb_adapter *);
  611. void igb_write_rss_indir_tbl(struct igb_adapter *);
  612. int igb_set_spd_dplx(struct igb_adapter *, u32, u8);
  613. int igb_setup_tx_resources(struct igb_ring *);
  614. int igb_setup_rx_resources(struct igb_ring *);
  615. void igb_free_tx_resources(struct igb_ring *);
  616. void igb_free_rx_resources(struct igb_ring *);
  617. void igb_configure_tx_ring(struct igb_adapter *, struct igb_ring *);
  618. void igb_configure_rx_ring(struct igb_adapter *, struct igb_ring *);
  619. void igb_setup_tctl(struct igb_adapter *);
  620. void igb_setup_rctl(struct igb_adapter *);
  621. void igb_setup_srrctl(struct igb_adapter *, struct igb_ring *);
  622. netdev_tx_t igb_xmit_frame_ring(struct sk_buff *, struct igb_ring *);
  623. void igb_alloc_rx_buffers(struct igb_ring *, u16);
  624. void igb_update_stats(struct igb_adapter *);
  625. bool igb_has_link(struct igb_adapter *adapter);
  626. void igb_set_ethtool_ops(struct net_device *);
  627. void igb_power_up_link(struct igb_adapter *);
  628. void igb_set_fw_version(struct igb_adapter *);
  629. void igb_ptp_init(struct igb_adapter *adapter);
  630. void igb_ptp_stop(struct igb_adapter *adapter);
  631. void igb_ptp_reset(struct igb_adapter *adapter);
  632. void igb_ptp_suspend(struct igb_adapter *adapter);
  633. void igb_ptp_rx_hang(struct igb_adapter *adapter);
  634. void igb_ptp_tx_hang(struct igb_adapter *adapter);
  635. void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb);
  636. int igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va,
  637. ktime_t *timestamp);
  638. int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr);
  639. int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr);
  640. void igb_set_flag_queue_pairs(struct igb_adapter *, const u32);
  641. unsigned int igb_get_max_rss_queues(struct igb_adapter *);
  642. #ifdef CONFIG_IGB_HWMON
  643. void igb_sysfs_exit(struct igb_adapter *adapter);
  644. int igb_sysfs_init(struct igb_adapter *adapter);
  645. #endif
  646. static inline s32 igb_reset_phy(struct e1000_hw *hw)
  647. {
  648. if (hw->phy.ops.reset)
  649. return hw->phy.ops.reset(hw);
  650. return 0;
  651. }
  652. static inline s32 igb_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
  653. {
  654. if (hw->phy.ops.read_reg)
  655. return hw->phy.ops.read_reg(hw, offset, data);
  656. return 0;
  657. }
  658. static inline s32 igb_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
  659. {
  660. if (hw->phy.ops.write_reg)
  661. return hw->phy.ops.write_reg(hw, offset, data);
  662. return 0;
  663. }
  664. static inline s32 igb_get_phy_info(struct e1000_hw *hw)
  665. {
  666. if (hw->phy.ops.get_phy_info)
  667. return hw->phy.ops.get_phy_info(hw);
  668. return 0;
  669. }
  670. static inline struct netdev_queue *txring_txq(const struct igb_ring *tx_ring)
  671. {
  672. return netdev_get_tx_queue(tx_ring->netdev, tx_ring->queue_index);
  673. }
  674. int igb_add_filter(struct igb_adapter *adapter,
  675. struct igb_nfc_filter *input);
  676. int igb_erase_filter(struct igb_adapter *adapter,
  677. struct igb_nfc_filter *input);
  678. int igb_add_mac_steering_filter(struct igb_adapter *adapter,
  679. const u8 *addr, u8 queue, u8 flags);
  680. int igb_del_mac_steering_filter(struct igb_adapter *adapter,
  681. const u8 *addr, u8 queue, u8 flags);
  682. #endif /* _IGB_H_ */