igb.h 20 KB

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