| .. | .. |
|---|
| 12 | 12 | #include <linux/aer.h> |
|---|
| 13 | 13 | #include <linux/if_vlan.h> |
|---|
| 14 | 14 | #include <linux/jiffies.h> |
|---|
| 15 | +#include <linux/phy.h> |
|---|
| 15 | 16 | |
|---|
| 16 | 17 | #include <linux/timecounter.h> |
|---|
| 17 | 18 | #include <linux/net_tstamp.h> |
|---|
| .. | .. |
|---|
| 30 | 31 | #include "ixgbe_ipsec.h" |
|---|
| 31 | 32 | |
|---|
| 32 | 33 | #include <net/xdp.h> |
|---|
| 33 | | -#include <net/busy_poll.h> |
|---|
| 34 | 34 | |
|---|
| 35 | 35 | /* common prefix used by pr_<> macros */ |
|---|
| 36 | 36 | #undef pr_fmt |
|---|
| .. | .. |
|---|
| 50 | 50 | #define IXGBE_MAX_RXD 4096 |
|---|
| 51 | 51 | #define IXGBE_MIN_RXD 64 |
|---|
| 52 | 52 | |
|---|
| 53 | | -#define IXGBE_ETH_P_LLDP 0x88CC |
|---|
| 54 | | - |
|---|
| 55 | 53 | /* flow control */ |
|---|
| 56 | 54 | #define IXGBE_MIN_FCRTL 0x40 |
|---|
| 57 | 55 | #define IXGBE_MAX_FCRTL 0x7FF80 |
|---|
| .. | .. |
|---|
| 68 | 66 | #define IXGBE_RXBUFFER_3K 3072 |
|---|
| 69 | 67 | #define IXGBE_RXBUFFER_4K 4096 |
|---|
| 70 | 68 | #define IXGBE_MAX_RXBUFFER 16384 /* largest size for a single descriptor */ |
|---|
| 69 | + |
|---|
| 70 | +#define IXGBE_PKT_HDR_PAD (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2)) |
|---|
| 71 | 71 | |
|---|
| 72 | 72 | /* Attempt to maximize the headroom available for incoming frames. We |
|---|
| 73 | 73 | * use a 2K buffer for receives and need 1536/1534 to store the data for |
|---|
| .. | .. |
|---|
| 226 | 226 | }; |
|---|
| 227 | 227 | |
|---|
| 228 | 228 | struct ixgbe_rx_buffer { |
|---|
| 229 | | - struct sk_buff *skb; |
|---|
| 230 | | - dma_addr_t dma; |
|---|
| 231 | | - struct page *page; |
|---|
| 232 | | -#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536) |
|---|
| 233 | | - __u32 page_offset; |
|---|
| 234 | | -#else |
|---|
| 235 | | - __u16 page_offset; |
|---|
| 236 | | -#endif |
|---|
| 237 | | - __u16 pagecnt_bias; |
|---|
| 229 | + union { |
|---|
| 230 | + struct { |
|---|
| 231 | + struct sk_buff *skb; |
|---|
| 232 | + dma_addr_t dma; |
|---|
| 233 | + struct page *page; |
|---|
| 234 | + __u32 page_offset; |
|---|
| 235 | + __u16 pagecnt_bias; |
|---|
| 236 | + }; |
|---|
| 237 | + struct { |
|---|
| 238 | + bool discard; |
|---|
| 239 | + struct xdp_buff *xdp; |
|---|
| 240 | + }; |
|---|
| 241 | + }; |
|---|
| 238 | 242 | }; |
|---|
| 239 | 243 | |
|---|
| 240 | 244 | struct ixgbe_queue_stats { |
|---|
| .. | .. |
|---|
| 271 | 275 | __IXGBE_TX_DETECT_HANG, |
|---|
| 272 | 276 | __IXGBE_HANG_CHECK_ARMED, |
|---|
| 273 | 277 | __IXGBE_TX_XDP_RING, |
|---|
| 278 | + __IXGBE_TX_DISABLED, |
|---|
| 274 | 279 | }; |
|---|
| 275 | 280 | |
|---|
| 276 | 281 | #define ring_uses_build_skb(ring) \ |
|---|
| .. | .. |
|---|
| 347 | 352 | struct ixgbe_rx_queue_stats rx_stats; |
|---|
| 348 | 353 | }; |
|---|
| 349 | 354 | struct xdp_rxq_info xdp_rxq; |
|---|
| 355 | + struct xsk_buff_pool *xsk_pool; |
|---|
| 356 | + u16 ring_idx; /* {rx,tx,xdp}_ring back reference idx */ |
|---|
| 357 | + u16 rx_buf_len; |
|---|
| 350 | 358 | } ____cacheline_internodealigned_in_smp; |
|---|
| 351 | 359 | |
|---|
| 352 | 360 | enum ixgbe_ring_f_enum { |
|---|
| .. | .. |
|---|
| 455 | 463 | char name[IFNAMSIZ + 9]; |
|---|
| 456 | 464 | |
|---|
| 457 | 465 | /* for dynamic allocation of rings associated with this q_vector */ |
|---|
| 458 | | - struct ixgbe_ring ring[0] ____cacheline_internodealigned_in_smp; |
|---|
| 466 | + struct ixgbe_ring ring[] ____cacheline_internodealigned_in_smp; |
|---|
| 459 | 467 | }; |
|---|
| 460 | 468 | |
|---|
| 461 | 469 | #ifdef CONFIG_IXGBE_HWMON |
|---|
| .. | .. |
|---|
| 553 | 561 | struct net_device *netdev; |
|---|
| 554 | 562 | struct bpf_prog *xdp_prog; |
|---|
| 555 | 563 | struct pci_dev *pdev; |
|---|
| 564 | + struct mii_bus *mii_bus; |
|---|
| 556 | 565 | |
|---|
| 557 | 566 | unsigned long state; |
|---|
| 558 | 567 | |
|---|
| .. | .. |
|---|
| 581 | 590 | #define IXGBE_FLAG_FCOE_ENABLED BIT(21) |
|---|
| 582 | 591 | #define IXGBE_FLAG_SRIOV_CAPABLE BIT(22) |
|---|
| 583 | 592 | #define IXGBE_FLAG_SRIOV_ENABLED BIT(23) |
|---|
| 584 | | -#define IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE BIT(24) |
|---|
| 585 | 593 | #define IXGBE_FLAG_RX_HWTSTAMP_ENABLED BIT(25) |
|---|
| 586 | 594 | #define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER BIT(26) |
|---|
| 587 | 595 | #define IXGBE_FLAG_DCB_CAPABLE BIT(27) |
|---|
| 588 | | -#define IXGBE_FLAG_GENEVE_OFFLOAD_CAPABLE BIT(28) |
|---|
| 589 | 596 | |
|---|
| 590 | 597 | u32 flags2; |
|---|
| 591 | 598 | #define IXGBE_FLAG2_RSC_CAPABLE BIT(0) |
|---|
| .. | .. |
|---|
| 599 | 606 | #define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP BIT(9) |
|---|
| 600 | 607 | #define IXGBE_FLAG2_PTP_PPS_ENABLED BIT(10) |
|---|
| 601 | 608 | #define IXGBE_FLAG2_PHY_INTERRUPT BIT(11) |
|---|
| 602 | | -#define IXGBE_FLAG2_UDP_TUN_REREG_NEEDED BIT(12) |
|---|
| 603 | 609 | #define IXGBE_FLAG2_VLAN_PROMISC BIT(13) |
|---|
| 604 | 610 | #define IXGBE_FLAG2_EEE_CAPABLE BIT(14) |
|---|
| 605 | 611 | #define IXGBE_FLAG2_EEE_ENABLED BIT(15) |
|---|
| 606 | 612 | #define IXGBE_FLAG2_RX_LEGACY BIT(16) |
|---|
| 607 | 613 | #define IXGBE_FLAG2_IPSEC_ENABLED BIT(17) |
|---|
| 614 | +#define IXGBE_FLAG2_VF_IPSEC_ENABLED BIT(18) |
|---|
| 608 | 615 | |
|---|
| 609 | 616 | /* Tx fast path data */ |
|---|
| 610 | 617 | int num_tx_queues; |
|---|
| .. | .. |
|---|
| 624 | 631 | /* XDP */ |
|---|
| 625 | 632 | int num_xdp_queues; |
|---|
| 626 | 633 | struct ixgbe_ring *xdp_ring[MAX_XDP_QUEUES]; |
|---|
| 634 | + unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled rings */ |
|---|
| 627 | 635 | |
|---|
| 628 | 636 | /* TX */ |
|---|
| 629 | 637 | struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp; |
|---|
| .. | .. |
|---|
| 760 | 768 | #define IXGBE_RSS_KEY_SIZE 40 /* size of RSS Hash Key in bytes */ |
|---|
| 761 | 769 | u32 *rss_key; |
|---|
| 762 | 770 | |
|---|
| 763 | | -#ifdef CONFIG_XFRM_OFFLOAD |
|---|
| 771 | +#ifdef CONFIG_IXGBE_IPSEC |
|---|
| 764 | 772 | struct ixgbe_ipsec *ipsec; |
|---|
| 765 | | -#endif /* CONFIG_XFRM_OFFLOAD */ |
|---|
| 773 | +#endif /* CONFIG_IXGBE_IPSEC */ |
|---|
| 774 | + spinlock_t vfs_lock; |
|---|
| 766 | 775 | }; |
|---|
| 767 | 776 | |
|---|
| 768 | 777 | static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter) |
|---|
| .. | .. |
|---|
| 837 | 846 | #endif |
|---|
| 838 | 847 | |
|---|
| 839 | 848 | extern char ixgbe_driver_name[]; |
|---|
| 840 | | -extern const char ixgbe_driver_version[]; |
|---|
| 841 | 849 | #ifdef IXGBE_FCOE |
|---|
| 842 | 850 | extern char ixgbe_default_device_descr[]; |
|---|
| 843 | 851 | #endif /* IXGBE_FCOE */ |
|---|
| .. | .. |
|---|
| 994 | 1002 | void ixgbe_store_reta(struct ixgbe_adapter *adapter); |
|---|
| 995 | 1003 | s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg, |
|---|
| 996 | 1004 | u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm); |
|---|
| 997 | | -#ifdef CONFIG_XFRM_OFFLOAD |
|---|
| 1005 | +#ifdef CONFIG_IXGBE_IPSEC |
|---|
| 998 | 1006 | void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter); |
|---|
| 999 | 1007 | void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter); |
|---|
| 1000 | 1008 | void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter); |
|---|
| .. | .. |
|---|
| 1003 | 1011 | struct sk_buff *skb); |
|---|
| 1004 | 1012 | int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first, |
|---|
| 1005 | 1013 | struct ixgbe_ipsec_tx_data *itd); |
|---|
| 1014 | +void ixgbe_ipsec_vf_clear(struct ixgbe_adapter *adapter, u32 vf); |
|---|
| 1015 | +int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *mbuf, u32 vf); |
|---|
| 1016 | +int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter, u32 *mbuf, u32 vf); |
|---|
| 1006 | 1017 | #else |
|---|
| 1007 | | -static inline void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter) { }; |
|---|
| 1008 | | -static inline void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter) { }; |
|---|
| 1009 | | -static inline void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter) { }; |
|---|
| 1018 | +static inline void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter) { } |
|---|
| 1019 | +static inline void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter) { } |
|---|
| 1020 | +static inline void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter) { } |
|---|
| 1010 | 1021 | static inline void ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring, |
|---|
| 1011 | 1022 | union ixgbe_adv_rx_desc *rx_desc, |
|---|
| 1012 | | - struct sk_buff *skb) { }; |
|---|
| 1023 | + struct sk_buff *skb) { } |
|---|
| 1013 | 1024 | static inline int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring, |
|---|
| 1014 | 1025 | struct ixgbe_tx_buffer *first, |
|---|
| 1015 | | - struct ixgbe_ipsec_tx_data *itd) { return 0; }; |
|---|
| 1016 | | -#endif /* CONFIG_XFRM_OFFLOAD */ |
|---|
| 1026 | + struct ixgbe_ipsec_tx_data *itd) { return 0; } |
|---|
| 1027 | +static inline void ixgbe_ipsec_vf_clear(struct ixgbe_adapter *adapter, |
|---|
| 1028 | + u32 vf) { } |
|---|
| 1029 | +static inline int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, |
|---|
| 1030 | + u32 *mbuf, u32 vf) { return -EACCES; } |
|---|
| 1031 | +static inline int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter, |
|---|
| 1032 | + u32 *mbuf, u32 vf) { return -EACCES; } |
|---|
| 1033 | +#endif /* CONFIG_IXGBE_IPSEC */ |
|---|
| 1034 | + |
|---|
| 1035 | +static inline bool ixgbe_enabled_xdp_adapter(struct ixgbe_adapter *adapter) |
|---|
| 1036 | +{ |
|---|
| 1037 | + return !!adapter->xdp_prog; |
|---|
| 1038 | +} |
|---|
| 1039 | + |
|---|
| 1017 | 1040 | #endif /* _IXGBE_H_ */ |
|---|