1837f08fdSAnirudh Venkataramanan /* SPDX-License-Identifier: GPL-2.0 */ 2837f08fdSAnirudh Venkataramanan /* Copyright (c) 2018, Intel Corporation. */ 3837f08fdSAnirudh Venkataramanan 4837f08fdSAnirudh Venkataramanan #ifndef _ICE_H_ 5837f08fdSAnirudh Venkataramanan #define _ICE_H_ 6837f08fdSAnirudh Venkataramanan 7837f08fdSAnirudh Venkataramanan #include <linux/types.h> 8837f08fdSAnirudh Venkataramanan #include <linux/errno.h> 9837f08fdSAnirudh Venkataramanan #include <linux/kernel.h> 10837f08fdSAnirudh Venkataramanan #include <linux/module.h> 11462acf6aSTony Nguyen #include <linux/firmware.h> 12837f08fdSAnirudh Venkataramanan #include <linux/netdevice.h> 13837f08fdSAnirudh Venkataramanan #include <linux/compiler.h> 14dc49c772SAnirudh Venkataramanan #include <linux/etherdevice.h> 15cdedef59SAnirudh Venkataramanan #include <linux/skbuff.h> 163a858ba3SAnirudh Venkataramanan #include <linux/cpumask.h> 17fcea6f3dSAnirudh Venkataramanan #include <linux/rtnetlink.h> 183a858ba3SAnirudh Venkataramanan #include <linux/if_vlan.h> 19cdedef59SAnirudh Venkataramanan #include <linux/dma-mapping.h> 20837f08fdSAnirudh Venkataramanan #include <linux/pci.h> 21940b61afSAnirudh Venkataramanan #include <linux/workqueue.h> 22d69ea414SJacob Keller #include <linux/wait.h> 23837f08fdSAnirudh Venkataramanan #include <linux/aer.h> 24940b61afSAnirudh Venkataramanan #include <linux/interrupt.h> 25fcea6f3dSAnirudh Venkataramanan #include <linux/ethtool.h> 26940b61afSAnirudh Venkataramanan #include <linux/timer.h> 277ec59eeaSAnirudh Venkataramanan #include <linux/delay.h> 28837f08fdSAnirudh Venkataramanan #include <linux/bitmap.h> 293a858ba3SAnirudh Venkataramanan #include <linux/log2.h> 30d76a60baSAnirudh Venkataramanan #include <linux/ip.h> 31cf909e19SAnirudh Venkataramanan #include <linux/sctp.h> 32d76a60baSAnirudh Venkataramanan #include <linux/ipv6.h> 33efc2214bSMaciej Fijalkowski #include <linux/pkt_sched.h> 34940b61afSAnirudh Venkataramanan #include <linux/if_bridge.h> 35e3710a01SPaul M Stillwell Jr #include <linux/ctype.h> 36efc2214bSMaciej Fijalkowski #include <linux/bpf.h> 37ddf30f7fSAnirudh Venkataramanan #include <linux/avf/virtchnl.h> 3828bf2672SBrett Creeley #include <linux/cpu_rmap.h> 39*cdf1f1f1SJacob Keller #include <linux/dim.h> 401adf7eadSJacob Keller #include <net/devlink.h> 41d76a60baSAnirudh Venkataramanan #include <net/ipv6.h> 422d4238f5SKrzysztof Kazimierczak #include <net/xdp_sock.h> 43c7a21904SMichal Swiatkowski #include <net/xdp_sock_drv.h> 44a4e82a81STony Nguyen #include <net/geneve.h> 45a4e82a81STony Nguyen #include <net/gre.h> 46a4e82a81STony Nguyen #include <net/udp_tunnel.h> 47a4e82a81STony Nguyen #include <net/vxlan.h> 48d41f26b5SBruce Allan #if IS_ENABLED(CONFIG_DCB) 49d41f26b5SBruce Allan #include <scsi/iscsi_proto.h> 50d41f26b5SBruce Allan #endif /* CONFIG_DCB */ 51837f08fdSAnirudh Venkataramanan #include "ice_devids.h" 52837f08fdSAnirudh Venkataramanan #include "ice_type.h" 53940b61afSAnirudh Venkataramanan #include "ice_txrx.h" 5437b6f646SAnirudh Venkataramanan #include "ice_dcb.h" 559c20346bSAnirudh Venkataramanan #include "ice_switch.h" 56f31e4b6fSAnirudh Venkataramanan #include "ice_common.h" 579c20346bSAnirudh Venkataramanan #include "ice_sched.h" 58ddf30f7fSAnirudh Venkataramanan #include "ice_virtchnl_pf.h" 59007676b4SAnirudh Venkataramanan #include "ice_sriov.h" 60148beb61SHenry Tieman #include "ice_fdir.h" 612d4238f5SKrzysztof Kazimierczak #include "ice_xsk.h" 6228bf2672SBrett Creeley #include "ice_arfs.h" 63df006dd4SDave Ertman #include "ice_lag.h" 64837f08fdSAnirudh Venkataramanan 65837f08fdSAnirudh Venkataramanan #define ICE_BAR0 0 663a858ba3SAnirudh Venkataramanan #define ICE_REQ_DESC_MULTIPLE 32 678be92a76SPreethi Banala #define ICE_MIN_NUM_DESC 64 683b6bf296SBruce Allan #define ICE_MAX_NUM_DESC 8160 691aec6e1bSBrett Creeley #define ICE_DFLT_MIN_RX_DESC 512 70dd47e1fdSJesse Brandeburg #define ICE_DFLT_NUM_TX_DESC 256 71dd47e1fdSJesse Brandeburg #define ICE_DFLT_NUM_RX_DESC 2048 72ad71b256SBrett Creeley 735513b920SAnirudh Venkataramanan #define ICE_DFLT_TRAFFIC_CLASS BIT(0) 74940b61afSAnirudh Venkataramanan #define ICE_INT_NAME_STR_LEN (IFNAMSIZ + 16) 75f31e4b6fSAnirudh Venkataramanan #define ICE_AQ_LEN 64 7611836214SBrett Creeley #define ICE_MBXSQ_LEN 64 77f3fe97f6SBrett Creeley #define ICE_MIN_LAN_TXRX_MSIX 1 78f3fe97f6SBrett Creeley #define ICE_MIN_LAN_OICR_MSIX 1 79f3fe97f6SBrett Creeley #define ICE_MIN_MSIX (ICE_MIN_LAN_TXRX_MSIX + ICE_MIN_LAN_OICR_MSIX) 80da62c5ffSQi Zhang #define ICE_FDIR_MSIX 2 813a858ba3SAnirudh Venkataramanan #define ICE_NO_VSI 0xffff 823a858ba3SAnirudh Venkataramanan #define ICE_VSI_MAP_CONTIG 0 833a858ba3SAnirudh Venkataramanan #define ICE_VSI_MAP_SCATTER 1 843a858ba3SAnirudh Venkataramanan #define ICE_MAX_SCATTER_TXQS 16 853a858ba3SAnirudh Venkataramanan #define ICE_MAX_SCATTER_RXQS 16 86cdedef59SAnirudh Venkataramanan #define ICE_Q_WAIT_RETRY_LIMIT 10 87cdedef59SAnirudh Venkataramanan #define ICE_Q_WAIT_MAX_RETRY (5 * ICE_Q_WAIT_RETRY_LIMIT) 88d76a60baSAnirudh Venkataramanan #define ICE_MAX_LG_RSS_QS 256 89940b61afSAnirudh Venkataramanan #define ICE_RES_VALID_BIT 0x8000 90940b61afSAnirudh Venkataramanan #define ICE_RES_MISC_VEC_ID (ICE_RES_VALID_BIT - 1) 91da62c5ffSQi Zhang /* All VF control VSIs share the same IRQ, so assign a unique ID for them */ 92da62c5ffSQi Zhang #define ICE_RES_VF_CTRL_VEC_ID (ICE_RES_MISC_VEC_ID - 1) 933a858ba3SAnirudh Venkataramanan #define ICE_INVAL_Q_INDEX 0xffff 940f9d5027SAnirudh Venkataramanan #define ICE_INVAL_VFID 256 95837f08fdSAnirudh Venkataramanan 968134d5ffSBrett Creeley #define ICE_MAX_RXQS_PER_TC 256 /* Used when setting VSI context per TC Rx queues */ 97afd9d4abSAnirudh Venkataramanan #define ICE_MAX_RESET_WAIT 20 98afd9d4abSAnirudh Venkataramanan 99fcea6f3dSAnirudh Venkataramanan #define ICE_VSIQF_HKEY_ARRAY_SIZE ((VSIQF_HKEY_MAX_INDEX + 1) * 4) 100fcea6f3dSAnirudh Venkataramanan 101837f08fdSAnirudh Venkataramanan #define ICE_DFLT_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK) 102837f08fdSAnirudh Venkataramanan 103efc2214bSMaciej Fijalkowski #define ICE_MAX_MTU (ICE_AQ_SET_MAC_FRAME_SIZE_MAX - ICE_ETH_PKT_HDR_PAD) 1043a858ba3SAnirudh Venkataramanan 1053a858ba3SAnirudh Venkataramanan #define ICE_UP_TABLE_TRANSLATE(val, i) \ 1063a858ba3SAnirudh Venkataramanan (((val) << ICE_AQ_VSI_UP_TABLE_UP##i##_S) & \ 1073a858ba3SAnirudh Venkataramanan ICE_AQ_VSI_UP_TABLE_UP##i##_M) 1083a858ba3SAnirudh Venkataramanan 1092b245cb2SAnirudh Venkataramanan #define ICE_TX_DESC(R, i) (&(((struct ice_tx_desc *)((R)->desc))[i])) 110cdedef59SAnirudh Venkataramanan #define ICE_RX_DESC(R, i) (&(((union ice_32b_rx_flex_desc *)((R)->desc))[i])) 111d76a60baSAnirudh Venkataramanan #define ICE_TX_CTX_DESC(R, i) (&(((struct ice_tx_ctx_desc *)((R)->desc))[i])) 112cac2a27cSHenry Tieman #define ICE_TX_FDIRDESC(R, i) (&(((struct ice_fltr_desc *)((R)->desc))[i])) 113cdedef59SAnirudh Venkataramanan 1140b28b702SAnirudh Venkataramanan /* Macro for each VSI in a PF */ 1150b28b702SAnirudh Venkataramanan #define ice_for_each_vsi(pf, i) \ 1160b28b702SAnirudh Venkataramanan for ((i) = 0; (i) < (pf)->num_alloc_vsi; (i)++) 1170b28b702SAnirudh Venkataramanan 118d337f2afSAnirudh Venkataramanan /* Macros for each Tx/Rx ring in a VSI */ 119cdedef59SAnirudh Venkataramanan #define ice_for_each_txq(vsi, i) \ 120cdedef59SAnirudh Venkataramanan for ((i) = 0; (i) < (vsi)->num_txq; (i)++) 121cdedef59SAnirudh Venkataramanan 122cdedef59SAnirudh Venkataramanan #define ice_for_each_rxq(vsi, i) \ 123cdedef59SAnirudh Venkataramanan for ((i) = 0; (i) < (vsi)->num_rxq; (i)++) 124cdedef59SAnirudh Venkataramanan 125d337f2afSAnirudh Venkataramanan /* Macros for each allocated Tx/Rx ring whether used or not in a VSI */ 126f8ba7db8SJacob Keller #define ice_for_each_alloc_txq(vsi, i) \ 127f8ba7db8SJacob Keller for ((i) = 0; (i) < (vsi)->alloc_txq; (i)++) 128f8ba7db8SJacob Keller 129f8ba7db8SJacob Keller #define ice_for_each_alloc_rxq(vsi, i) \ 130f8ba7db8SJacob Keller for ((i) = 0; (i) < (vsi)->alloc_rxq; (i)++) 131f8ba7db8SJacob Keller 13267fe64d7SBrett Creeley #define ice_for_each_q_vector(vsi, i) \ 13367fe64d7SBrett Creeley for ((i) = 0; (i) < (vsi)->num_q_vectors; (i)++) 13467fe64d7SBrett Creeley 1355eda8afdSAkeem G Abodunrin #define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_MCAST_TX | \ 1365eda8afdSAkeem G Abodunrin ICE_PROMISC_UCAST_RX | ICE_PROMISC_MCAST_RX) 1375eda8afdSAkeem G Abodunrin 1385eda8afdSAkeem G Abodunrin #define ICE_UCAST_VLAN_PROMISC_BITS (ICE_PROMISC_UCAST_TX | \ 1395eda8afdSAkeem G Abodunrin ICE_PROMISC_MCAST_TX | \ 1405eda8afdSAkeem G Abodunrin ICE_PROMISC_UCAST_RX | \ 1415eda8afdSAkeem G Abodunrin ICE_PROMISC_MCAST_RX | \ 1425eda8afdSAkeem G Abodunrin ICE_PROMISC_VLAN_TX | \ 1435eda8afdSAkeem G Abodunrin ICE_PROMISC_VLAN_RX) 1445eda8afdSAkeem G Abodunrin 1455eda8afdSAkeem G Abodunrin #define ICE_MCAST_PROMISC_BITS (ICE_PROMISC_MCAST_TX | ICE_PROMISC_MCAST_RX) 1465eda8afdSAkeem G Abodunrin 1475eda8afdSAkeem G Abodunrin #define ICE_MCAST_VLAN_PROMISC_BITS (ICE_PROMISC_MCAST_TX | \ 1485eda8afdSAkeem G Abodunrin ICE_PROMISC_MCAST_RX | \ 1495eda8afdSAkeem G Abodunrin ICE_PROMISC_VLAN_TX | \ 1505eda8afdSAkeem G Abodunrin ICE_PROMISC_VLAN_RX) 1515eda8afdSAkeem G Abodunrin 1524015d11eSBrett Creeley #define ice_pf_to_dev(pf) (&((pf)->pdev->dev)) 1534015d11eSBrett Creeley 154eff380aaSAnirudh Venkataramanan struct ice_txq_meta { 155eff380aaSAnirudh Venkataramanan u32 q_teid; /* Tx-scheduler element identifier */ 156eff380aaSAnirudh Venkataramanan u16 q_id; /* Entry in VSI's txq_map bitmap */ 157eff380aaSAnirudh Venkataramanan u16 q_handle; /* Relative index of Tx queue within TC */ 158eff380aaSAnirudh Venkataramanan u16 vsi_idx; /* VSI index that Tx queue belongs to */ 159eff380aaSAnirudh Venkataramanan u8 tc; /* TC number that Tx queue belongs to */ 160eff380aaSAnirudh Venkataramanan }; 161eff380aaSAnirudh Venkataramanan 1623a858ba3SAnirudh Venkataramanan struct ice_tc_info { 1633a858ba3SAnirudh Venkataramanan u16 qoffset; 164c5a2a4a3SUsha Ketineni u16 qcount_tx; 165c5a2a4a3SUsha Ketineni u16 qcount_rx; 166c5a2a4a3SUsha Ketineni u8 netdev_tc; 1673a858ba3SAnirudh Venkataramanan }; 1683a858ba3SAnirudh Venkataramanan 1693a858ba3SAnirudh Venkataramanan struct ice_tc_cfg { 1703a858ba3SAnirudh Venkataramanan u8 numtc; /* Total number of enabled TCs */ 171f9867df6SAnirudh Venkataramanan u8 ena_tc; /* Tx map */ 1723a858ba3SAnirudh Venkataramanan struct ice_tc_info tc_info[ICE_MAX_TRAFFIC_CLASS]; 1733a858ba3SAnirudh Venkataramanan }; 1743a858ba3SAnirudh Venkataramanan 175940b61afSAnirudh Venkataramanan struct ice_res_tracker { 176940b61afSAnirudh Venkataramanan u16 num_entries; 177cbe66bfeSBrett Creeley u16 end; 178e94c0df9SGustavo A. R. Silva u16 list[]; 179940b61afSAnirudh Venkataramanan }; 180940b61afSAnirudh Venkataramanan 18103f7a986SAnirudh Venkataramanan struct ice_qs_cfg { 18294c4441bSAnirudh Venkataramanan struct mutex *qs_mutex; /* will be assigned to &pf->avail_q_mutex */ 18303f7a986SAnirudh Venkataramanan unsigned long *pf_map; 18403f7a986SAnirudh Venkataramanan unsigned long pf_map_size; 18503f7a986SAnirudh Venkataramanan unsigned int q_count; 18603f7a986SAnirudh Venkataramanan unsigned int scatter_count; 18703f7a986SAnirudh Venkataramanan u16 *vsi_map; 18803f7a986SAnirudh Venkataramanan u16 vsi_map_offset; 18903f7a986SAnirudh Venkataramanan u8 mapping_mode; 19003f7a986SAnirudh Venkataramanan }; 19103f7a986SAnirudh Venkataramanan 192940b61afSAnirudh Venkataramanan struct ice_sw { 193940b61afSAnirudh Venkataramanan struct ice_pf *pf; 194940b61afSAnirudh Venkataramanan u16 sw_id; /* switch ID for this switch */ 195940b61afSAnirudh Venkataramanan u16 bridge_mode; /* VEB/VEPA/Port Virtualizer */ 196fc0f39bcSBrett Creeley struct ice_vsi *dflt_vsi; /* default VSI for this switch */ 197fc0f39bcSBrett Creeley u8 dflt_vsi_ena:1; /* true if above dflt_vsi is enabled */ 198940b61afSAnirudh Venkataramanan }; 199940b61afSAnirudh Venkataramanan 200e97fb1aeSAnirudh Venkataramanan enum ice_pf_state { 2017e408e07SAnirudh Venkataramanan ICE_TESTING, 2027e408e07SAnirudh Venkataramanan ICE_DOWN, 2037e408e07SAnirudh Venkataramanan ICE_NEEDS_RESTART, 2047e408e07SAnirudh Venkataramanan ICE_PREPARED_FOR_RESET, /* set by driver when prepared */ 2057e408e07SAnirudh Venkataramanan ICE_RESET_OICR_RECV, /* set by driver after rcv reset OICR */ 2067e408e07SAnirudh Venkataramanan ICE_PFR_REQ, /* set by driver and peers */ 2077e408e07SAnirudh Venkataramanan ICE_CORER_REQ, /* set by driver and peers */ 2087e408e07SAnirudh Venkataramanan ICE_GLOBR_REQ, /* set by driver and peers */ 2097e408e07SAnirudh Venkataramanan ICE_CORER_RECV, /* set by OICR handler */ 2107e408e07SAnirudh Venkataramanan ICE_GLOBR_RECV, /* set by OICR handler */ 2117e408e07SAnirudh Venkataramanan ICE_EMPR_RECV, /* set by OICR handler */ 2127e408e07SAnirudh Venkataramanan ICE_SUSPENDED, /* set on module remove path */ 2137e408e07SAnirudh Venkataramanan ICE_RESET_FAILED, /* set by reset/rebuild */ 214ddf30f7fSAnirudh Venkataramanan /* When checking for the PF to be in a nominal operating state, the 215ddf30f7fSAnirudh Venkataramanan * bits that are grouped at the beginning of the list need to be 2167e408e07SAnirudh Venkataramanan * checked. Bits occurring before ICE_STATE_NOMINAL_CHECK_BITS will 217ddf30f7fSAnirudh Venkataramanan * be checked. If you need to add a bit into consideration for nominal 218ddf30f7fSAnirudh Venkataramanan * operating state, it must be added before 2197e408e07SAnirudh Venkataramanan * ICE_STATE_NOMINAL_CHECK_BITS. Do not move this entry's position 220ddf30f7fSAnirudh Venkataramanan * without appropriate consideration. 221ddf30f7fSAnirudh Venkataramanan */ 2227e408e07SAnirudh Venkataramanan ICE_STATE_NOMINAL_CHECK_BITS, 2237e408e07SAnirudh Venkataramanan ICE_ADMINQ_EVENT_PENDING, 2247e408e07SAnirudh Venkataramanan ICE_MAILBOXQ_EVENT_PENDING, 2257e408e07SAnirudh Venkataramanan ICE_MDD_EVENT_PENDING, 2267e408e07SAnirudh Venkataramanan ICE_VFLR_EVENT_PENDING, 2277e408e07SAnirudh Venkataramanan ICE_FLTR_OVERFLOW_PROMISC, 2287e408e07SAnirudh Venkataramanan ICE_VF_DIS, 2297e408e07SAnirudh Venkataramanan ICE_CFG_BUSY, 2307e408e07SAnirudh Venkataramanan ICE_SERVICE_SCHED, 2317e408e07SAnirudh Venkataramanan ICE_SERVICE_DIS, 2327e408e07SAnirudh Venkataramanan ICE_FD_FLUSH_REQ, 2337e408e07SAnirudh Venkataramanan ICE_OICR_INTR_DIS, /* Global OICR interrupt disabled */ 2347e408e07SAnirudh Venkataramanan ICE_MDD_VF_PRINT_PENDING, /* set when MDD event handle */ 2357e408e07SAnirudh Venkataramanan ICE_VF_RESETS_DISABLED, /* disable resets during ice_remove */ 2367e408e07SAnirudh Venkataramanan ICE_LINK_DEFAULT_OVERRIDE_PENDING, 2377e408e07SAnirudh Venkataramanan ICE_PHY_INIT_COMPLETE, 2387e408e07SAnirudh Venkataramanan ICE_FD_VF_FLUSH_CTX, /* set at FD Rx IRQ or timeout */ 2397e408e07SAnirudh Venkataramanan ICE_STATE_NBITS /* must be last */ 240837f08fdSAnirudh Venkataramanan }; 241837f08fdSAnirudh Venkataramanan 242e97fb1aeSAnirudh Venkataramanan enum ice_vsi_state { 243e97fb1aeSAnirudh Venkataramanan ICE_VSI_DOWN, 244e97fb1aeSAnirudh Venkataramanan ICE_VSI_NEEDS_RESTART, 245a476d72aSAnirudh Venkataramanan ICE_VSI_NETDEV_ALLOCD, 246a476d72aSAnirudh Venkataramanan ICE_VSI_NETDEV_REGISTERED, 247e97fb1aeSAnirudh Venkataramanan ICE_VSI_UMAC_FLTR_CHANGED, 248e97fb1aeSAnirudh Venkataramanan ICE_VSI_MMAC_FLTR_CHANGED, 249e97fb1aeSAnirudh Venkataramanan ICE_VSI_VLAN_FLTR_CHANGED, 250e97fb1aeSAnirudh Venkataramanan ICE_VSI_PROMISC_CHANGED, 251e97fb1aeSAnirudh Venkataramanan ICE_VSI_STATE_NBITS /* must be last */ 252e94d4478SAnirudh Venkataramanan }; 253e94d4478SAnirudh Venkataramanan 254940b61afSAnirudh Venkataramanan /* struct that defines a VSI, associated with a dev */ 255940b61afSAnirudh Venkataramanan struct ice_vsi { 256940b61afSAnirudh Venkataramanan struct net_device *netdev; 2573a858ba3SAnirudh Venkataramanan struct ice_sw *vsw; /* switch this VSI is on */ 2583a858ba3SAnirudh Venkataramanan struct ice_pf *back; /* back pointer to PF */ 259940b61afSAnirudh Venkataramanan struct ice_port_info *port_info; /* back pointer to port_info */ 260d337f2afSAnirudh Venkataramanan struct ice_ring **rx_rings; /* Rx ring array */ 261d337f2afSAnirudh Venkataramanan struct ice_ring **tx_rings; /* Tx ring array */ 2623a858ba3SAnirudh Venkataramanan struct ice_q_vector **q_vectors; /* q_vector array */ 263cdedef59SAnirudh Venkataramanan 264cdedef59SAnirudh Venkataramanan irqreturn_t (*irq_handler)(int irq, void *data); 265cdedef59SAnirudh Venkataramanan 266fcea6f3dSAnirudh Venkataramanan u64 tx_linearize; 267e97fb1aeSAnirudh Venkataramanan DECLARE_BITMAP(state, ICE_VSI_STATE_NBITS); 268e94d4478SAnirudh Venkataramanan unsigned int current_netdev_flags; 269fcea6f3dSAnirudh Venkataramanan u32 tx_restart; 270fcea6f3dSAnirudh Venkataramanan u32 tx_busy; 271fcea6f3dSAnirudh Venkataramanan u32 rx_buf_failed; 272fcea6f3dSAnirudh Venkataramanan u32 rx_page_failed; 27388865fc4SKarol Kolacinski u16 num_q_vectors; 27488865fc4SKarol Kolacinski u16 base_vector; /* IRQ base for OS reserved vectors */ 2753a858ba3SAnirudh Venkataramanan enum ice_vsi_type type; 276940b61afSAnirudh Venkataramanan u16 vsi_num; /* HW (absolute) index of this VSI */ 2773a858ba3SAnirudh Venkataramanan u16 idx; /* software index in pf->vsi[] */ 2783a858ba3SAnirudh Venkataramanan 2798ede0178SAnirudh Venkataramanan s16 vf_id; /* VF ID for SR-IOV VSIs */ 2808ede0178SAnirudh Venkataramanan 281d95276ceSAkeem G Abodunrin u16 ethtype; /* Ethernet protocol for pause frame */ 282148beb61SHenry Tieman u16 num_gfltr; 283148beb61SHenry Tieman u16 num_bfltr; 284d95276ceSAkeem G Abodunrin 285d76a60baSAnirudh Venkataramanan /* RSS config */ 286d76a60baSAnirudh Venkataramanan u16 rss_table_size; /* HW RSS table size */ 287d76a60baSAnirudh Venkataramanan u16 rss_size; /* Allocated RSS queues */ 288d76a60baSAnirudh Venkataramanan u8 *rss_hkey_user; /* User configured hash keys */ 289d76a60baSAnirudh Venkataramanan u8 *rss_lut_user; /* User configured lookup table entries */ 290d76a60baSAnirudh Venkataramanan u8 rss_lut_type; /* used to configure Get/Set RSS LUT AQ call */ 291d76a60baSAnirudh Venkataramanan 29228bf2672SBrett Creeley /* aRFS members only allocated for the PF VSI */ 29328bf2672SBrett Creeley #define ICE_MAX_ARFS_LIST 1024 29428bf2672SBrett Creeley #define ICE_ARFS_LST_MASK (ICE_MAX_ARFS_LIST - 1) 29528bf2672SBrett Creeley struct hlist_head *arfs_fltr_list; 29628bf2672SBrett Creeley struct ice_arfs_active_fltr_cntrs *arfs_fltr_cntrs; 29728bf2672SBrett Creeley spinlock_t arfs_lock; /* protects aRFS hash table and filter state */ 29828bf2672SBrett Creeley atomic_t *arfs_last_fltr_id; 29928bf2672SBrett Creeley 30048d40025SJacob Keller /* devlink port data */ 30148d40025SJacob Keller struct devlink_port devlink_port; 30248d40025SJacob Keller bool devlink_port_registered; 30348d40025SJacob Keller 304cdedef59SAnirudh Venkataramanan u16 max_frame; 305cdedef59SAnirudh Venkataramanan u16 rx_buf_len; 306cdedef59SAnirudh Venkataramanan 3073a858ba3SAnirudh Venkataramanan struct ice_aqc_vsi_props info; /* VSI properties */ 3083a858ba3SAnirudh Venkataramanan 309fcea6f3dSAnirudh Venkataramanan /* VSI stats */ 310fcea6f3dSAnirudh Venkataramanan struct rtnl_link_stats64 net_stats; 311fcea6f3dSAnirudh Venkataramanan struct ice_eth_stats eth_stats; 312fcea6f3dSAnirudh Venkataramanan struct ice_eth_stats eth_stats_prev; 313fcea6f3dSAnirudh Venkataramanan 314e94d4478SAnirudh Venkataramanan struct list_head tmp_sync_list; /* MAC filters to be synced */ 315e94d4478SAnirudh Venkataramanan struct list_head tmp_unsync_list; /* MAC filters to be unsynced */ 316e94d4478SAnirudh Venkataramanan 3170ab54c5fSJesse Brandeburg u8 irqs_ready:1; 3180ab54c5fSJesse Brandeburg u8 current_isup:1; /* Sync 'link up' logging */ 3190ab54c5fSJesse Brandeburg u8 stat_offsets_loaded:1; 320cd6d6b83SBrett Creeley u16 num_vlan; 321cdedef59SAnirudh Venkataramanan 3223a858ba3SAnirudh Venkataramanan /* queue information */ 3233a858ba3SAnirudh Venkataramanan u8 tx_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */ 3243a858ba3SAnirudh Venkataramanan u8 rx_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */ 32578b5713aSAnirudh Venkataramanan u16 *txq_map; /* index in pf->avail_txqs */ 32678b5713aSAnirudh Venkataramanan u16 *rxq_map; /* index in pf->avail_rxqs */ 3273a858ba3SAnirudh Venkataramanan u16 alloc_txq; /* Allocated Tx queues */ 3283a858ba3SAnirudh Venkataramanan u16 num_txq; /* Used Tx queues */ 3293a858ba3SAnirudh Venkataramanan u16 alloc_rxq; /* Allocated Rx queues */ 3303a858ba3SAnirudh Venkataramanan u16 num_rxq; /* Used Rx queues */ 33187324e74SHenry Tieman u16 req_txq; /* User requested Tx queues */ 33287324e74SHenry Tieman u16 req_rxq; /* User requested Rx queues */ 333ad71b256SBrett Creeley u16 num_rx_desc; 334ad71b256SBrett Creeley u16 num_tx_desc; 3353a858ba3SAnirudh Venkataramanan struct ice_tc_cfg tc_cfg; 336efc2214bSMaciej Fijalkowski struct bpf_prog *xdp_prog; 337efc2214bSMaciej Fijalkowski struct ice_ring **xdp_rings; /* XDP ring array */ 338efc2214bSMaciej Fijalkowski u16 num_xdp_txq; /* Used XDP queues */ 339efc2214bSMaciej Fijalkowski u8 xdp_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */ 340b126bd6bSKiran Patil 341b126bd6bSKiran Patil /* setup back reference, to which aggregator node this VSI 342b126bd6bSKiran Patil * corresponds to 343b126bd6bSKiran Patil */ 344b126bd6bSKiran Patil struct ice_agg_node *agg_node; 3453a858ba3SAnirudh Venkataramanan } ____cacheline_internodealigned_in_smp; 3463a858ba3SAnirudh Venkataramanan 3473a858ba3SAnirudh Venkataramanan /* struct that defines an interrupt vector */ 3483a858ba3SAnirudh Venkataramanan struct ice_q_vector { 3493a858ba3SAnirudh Venkataramanan struct ice_vsi *vsi; 3508244dd2dSBrett Creeley 3513a858ba3SAnirudh Venkataramanan u16 v_idx; /* index in the vsi->q_vector array. */ 352b07833a0SBrett Creeley u16 reg_idx; 353d337f2afSAnirudh Venkataramanan u8 num_ring_rx; /* total number of Rx rings in vector */ 3548244dd2dSBrett Creeley u8 num_ring_tx; /* total number of Tx rings in vector */ 355*cdf1f1f1SJacob Keller u8 wb_on_itr:1; /* if true, WB on ITR is enabled */ 3569e4ab4c2SBrett Creeley /* in usecs, need to use ice_intrl_to_usecs_reg() before writing this 3579e4ab4c2SBrett Creeley * value to the device 3589e4ab4c2SBrett Creeley */ 3599e4ab4c2SBrett Creeley u8 intrl; 3608244dd2dSBrett Creeley 3618244dd2dSBrett Creeley struct napi_struct napi; 3628244dd2dSBrett Creeley 3638244dd2dSBrett Creeley struct ice_ring_container rx; 3648244dd2dSBrett Creeley struct ice_ring_container tx; 3658244dd2dSBrett Creeley 3668244dd2dSBrett Creeley cpumask_t affinity_mask; 3678244dd2dSBrett Creeley struct irq_affinity_notify affinity_notify; 3688244dd2dSBrett Creeley 3698244dd2dSBrett Creeley char name[ICE_INT_NAME_STR_LEN]; 370*cdf1f1f1SJacob Keller 371*cdf1f1f1SJacob Keller u16 total_events; /* net_dim(): number of interrupts processed */ 372940b61afSAnirudh Venkataramanan } ____cacheline_internodealigned_in_smp; 373940b61afSAnirudh Venkataramanan 374940b61afSAnirudh Venkataramanan enum ice_pf_flags { 375940b61afSAnirudh Venkataramanan ICE_FLAG_FLTR_SYNC, 376940b61afSAnirudh Venkataramanan ICE_FLAG_RSS_ENA, 377ddf30f7fSAnirudh Venkataramanan ICE_FLAG_SRIOV_ENA, 37875d2b253SAnirudh Venkataramanan ICE_FLAG_SRIOV_CAPABLE, 37937b6f646SAnirudh Venkataramanan ICE_FLAG_DCB_CAPABLE, 38037b6f646SAnirudh Venkataramanan ICE_FLAG_DCB_ENA, 381148beb61SHenry Tieman ICE_FLAG_FD_ENA, 382462acf6aSTony Nguyen ICE_FLAG_ADV_FEATURES, 383ab4ab73fSBruce Allan ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, 384b4e813ddSBruce Allan ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA, 3856d599946STony Nguyen ICE_FLAG_NO_MEDIA, 38684a118abSDave Ertman ICE_FLAG_FW_LLDP_AGENT, 3873a257a14SAnirudh Venkataramanan ICE_FLAG_ETHTOOL_CTXT, /* set when ethtool holds RTNL lock */ 3887237f5b0SMaciej Fijalkowski ICE_FLAG_LEGACY_RX, 38901b5e89aSBrett Creeley ICE_FLAG_VF_TRUE_PROMISC_ENA, 3909d5c5a52SPaul Greenwalt ICE_FLAG_MDD_AUTO_RESET_VF, 391ea78ce4dSPaul Greenwalt ICE_FLAG_LINK_LENIENT_MODE_ENA, 392940b61afSAnirudh Venkataramanan ICE_PF_FLAGS_NBITS /* must be last */ 393940b61afSAnirudh Venkataramanan }; 394940b61afSAnirudh Venkataramanan 395b126bd6bSKiran Patil struct ice_agg_node { 396b126bd6bSKiran Patil u32 agg_id; 397b126bd6bSKiran Patil #define ICE_MAX_VSIS_IN_AGG_NODE 64 398b126bd6bSKiran Patil u32 num_vsis; 399b126bd6bSKiran Patil u8 valid; 400b126bd6bSKiran Patil }; 401b126bd6bSKiran Patil 402837f08fdSAnirudh Venkataramanan struct ice_pf { 403837f08fdSAnirudh Venkataramanan struct pci_dev *pdev; 404eb0208ecSPreethi Banala 405dce730f1SJacob Keller struct devlink_region *nvm_region; 4068d7aab35SJacob Keller struct devlink_region *devcaps_region; 407dce730f1SJacob Keller 408eb0208ecSPreethi Banala /* OS reserved IRQ details */ 409940b61afSAnirudh Venkataramanan struct msix_entry *msix_entries; 410cbe66bfeSBrett Creeley struct ice_res_tracker *irq_tracker; 411cbe66bfeSBrett Creeley /* First MSIX vector used by SR-IOV VFs. Calculated by subtracting the 412cbe66bfeSBrett Creeley * number of MSIX vectors needed for all SR-IOV VFs from the number of 413cbe66bfeSBrett Creeley * MSIX vectors allowed on this PF. 414cbe66bfeSBrett Creeley */ 415cbe66bfeSBrett Creeley u16 sriov_base_vector; 416eb0208ecSPreethi Banala 417148beb61SHenry Tieman u16 ctrl_vsi_idx; /* control VSI index in pf->vsi array */ 418148beb61SHenry Tieman 419940b61afSAnirudh Venkataramanan struct ice_vsi **vsi; /* VSIs created by the driver */ 420940b61afSAnirudh Venkataramanan struct ice_sw *first_sw; /* first switch created by firmware */ 421ddf30f7fSAnirudh Venkataramanan /* Virtchnl/SR-IOV config info */ 422ddf30f7fSAnirudh Venkataramanan struct ice_vf *vf; 42353bb6698SJesse Brandeburg u16 num_alloc_vfs; /* actual number of VFs allocated */ 42475d2b253SAnirudh Venkataramanan u16 num_vfs_supported; /* num VFs supported for this PF */ 42546c276ceSBrett Creeley u16 num_qps_per_vf; 42646c276ceSBrett Creeley u16 num_msix_per_vf; 4279d5c5a52SPaul Greenwalt /* used to ratelimit the MDD event logging */ 4289d5c5a52SPaul Greenwalt unsigned long last_printed_mdd_jiffies; 4297e408e07SAnirudh Venkataramanan DECLARE_BITMAP(state, ICE_STATE_NBITS); 430940b61afSAnirudh Venkataramanan DECLARE_BITMAP(flags, ICE_PF_FLAGS_NBITS); 43178b5713aSAnirudh Venkataramanan unsigned long *avail_txqs; /* bitmap to track PF Tx queue usage */ 43278b5713aSAnirudh Venkataramanan unsigned long *avail_rxqs; /* bitmap to track PF Rx queue usage */ 433940b61afSAnirudh Venkataramanan unsigned long serv_tmr_period; 434940b61afSAnirudh Venkataramanan unsigned long serv_tmr_prev; 435940b61afSAnirudh Venkataramanan struct timer_list serv_tmr; 436940b61afSAnirudh Venkataramanan struct work_struct serv_task; 437940b61afSAnirudh Venkataramanan struct mutex avail_q_mutex; /* protects access to avail_[rx|tx]qs */ 438940b61afSAnirudh Venkataramanan struct mutex sw_mutex; /* lock for protecting VSI alloc flow */ 439b94b013eSDave Ertman struct mutex tc_mutex; /* lock to protect TC changes */ 440837f08fdSAnirudh Venkataramanan u32 msg_enable; 441d69ea414SJacob Keller 442d69ea414SJacob Keller /* spinlock to protect the AdminQ wait list */ 443d69ea414SJacob Keller spinlock_t aq_wait_lock; 444d69ea414SJacob Keller struct hlist_head aq_wait_list; 445d69ea414SJacob Keller wait_queue_head_t aq_wait_queue; 446d69ea414SJacob Keller 447d76a60baSAnirudh Venkataramanan u32 hw_csum_rx_error; 44888865fc4SKarol Kolacinski u16 oicr_idx; /* Other interrupt cause MSIX vector index */ 44988865fc4SKarol Kolacinski u16 num_avail_sw_msix; /* remaining MSIX SW vectors left unclaimed */ 45078b5713aSAnirudh Venkataramanan u16 max_pf_txqs; /* Total Tx queues PF wide */ 45178b5713aSAnirudh Venkataramanan u16 max_pf_rxqs; /* Total Rx queues PF wide */ 45288865fc4SKarol Kolacinski u16 num_lan_msix; /* Total MSIX vectors for base driver */ 453f9867df6SAnirudh Venkataramanan u16 num_lan_tx; /* num LAN Tx queues setup */ 454f9867df6SAnirudh Venkataramanan u16 num_lan_rx; /* num LAN Rx queues setup */ 455940b61afSAnirudh Venkataramanan u16 next_vsi; /* Next free slot in pf->vsi[] - 0-based! */ 456940b61afSAnirudh Venkataramanan u16 num_alloc_vsi; 4570b28b702SAnirudh Venkataramanan u16 corer_count; /* Core reset count */ 4580b28b702SAnirudh Venkataramanan u16 globr_count; /* Global reset count */ 4590b28b702SAnirudh Venkataramanan u16 empr_count; /* EMP reset count */ 4600b28b702SAnirudh Venkataramanan u16 pfr_count; /* PF reset count */ 4610b28b702SAnirudh Venkataramanan 462769c500dSAkeem G Abodunrin u8 wol_ena : 1; /* software state of WoL */ 463769c500dSAkeem G Abodunrin u32 wakeup_reason; /* last wakeup reason */ 464fcea6f3dSAnirudh Venkataramanan struct ice_hw_port_stats stats; 465fcea6f3dSAnirudh Venkataramanan struct ice_hw_port_stats stats_prev; 466837f08fdSAnirudh Venkataramanan struct ice_hw hw; 4670ab54c5fSJesse Brandeburg u8 stat_prev_loaded:1; /* has previous stats been loaded */ 4687b9ffc76SAnirudh Venkataramanan u16 dcbx_cap; 469b3969fd7SSudheer Mogilappagari u32 tx_timeout_count; 470b3969fd7SSudheer Mogilappagari unsigned long tx_timeout_last_recovery; 471b3969fd7SSudheer Mogilappagari u32 tx_timeout_recovery_level; 472940b61afSAnirudh Venkataramanan char int_name[ICE_INT_NAME_STR_LEN]; 4730e674aebSAnirudh Venkataramanan u32 sw_int_count; 4741a3571b5SPaul Greenwalt 4751a3571b5SPaul Greenwalt __le64 nvm_phy_type_lo; /* NVM PHY type low */ 4761a3571b5SPaul Greenwalt __le64 nvm_phy_type_hi; /* NVM PHY type high */ 477ea78ce4dSPaul Greenwalt struct ice_link_default_override_tlv link_dflt_override; 478df006dd4SDave Ertman struct ice_lag *lag; /* Link Aggregation information */ 479b126bd6bSKiran Patil 480b126bd6bSKiran Patil #define ICE_INVALID_AGG_NODE_ID 0 481b126bd6bSKiran Patil #define ICE_PF_AGG_NODE_ID_START 1 482b126bd6bSKiran Patil #define ICE_MAX_PF_AGG_NODES 32 483b126bd6bSKiran Patil struct ice_agg_node pf_agg_node[ICE_MAX_PF_AGG_NODES]; 484b126bd6bSKiran Patil #define ICE_VF_AGG_NODE_ID_START 65 485b126bd6bSKiran Patil #define ICE_MAX_VF_AGG_NODES 32 486b126bd6bSKiran Patil struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES]; 487837f08fdSAnirudh Venkataramanan }; 488940b61afSAnirudh Venkataramanan 4893a858ba3SAnirudh Venkataramanan struct ice_netdev_priv { 4903a858ba3SAnirudh Venkataramanan struct ice_vsi *vsi; 4913a858ba3SAnirudh Venkataramanan }; 4923a858ba3SAnirudh Venkataramanan 493940b61afSAnirudh Venkataramanan /** 494940b61afSAnirudh Venkataramanan * ice_irq_dynamic_ena - Enable default interrupt generation settings 495f9867df6SAnirudh Venkataramanan * @hw: pointer to HW struct 496f9867df6SAnirudh Venkataramanan * @vsi: pointer to VSI struct, can be NULL 497cdedef59SAnirudh Venkataramanan * @q_vector: pointer to q_vector, can be NULL 498940b61afSAnirudh Venkataramanan */ 499c8b7abddSBruce Allan static inline void 500c8b7abddSBruce Allan ice_irq_dynamic_ena(struct ice_hw *hw, struct ice_vsi *vsi, 501cdedef59SAnirudh Venkataramanan struct ice_q_vector *q_vector) 502940b61afSAnirudh Venkataramanan { 503b07833a0SBrett Creeley u32 vector = (vsi && q_vector) ? q_vector->reg_idx : 504cbe66bfeSBrett Creeley ((struct ice_pf *)hw->back)->oicr_idx; 505940b61afSAnirudh Venkataramanan int itr = ICE_ITR_NONE; 506940b61afSAnirudh Venkataramanan u32 val; 507940b61afSAnirudh Venkataramanan 508940b61afSAnirudh Venkataramanan /* clear the PBA here, as this function is meant to clean out all 509940b61afSAnirudh Venkataramanan * previous interrupts and enable the interrupt 510940b61afSAnirudh Venkataramanan */ 511940b61afSAnirudh Venkataramanan val = GLINT_DYN_CTL_INTENA_M | GLINT_DYN_CTL_CLEARPBA_M | 512940b61afSAnirudh Venkataramanan (itr << GLINT_DYN_CTL_ITR_INDX_S); 513cdedef59SAnirudh Venkataramanan if (vsi) 514e97fb1aeSAnirudh Venkataramanan if (test_bit(ICE_VSI_DOWN, vsi->state)) 515cdedef59SAnirudh Venkataramanan return; 516940b61afSAnirudh Venkataramanan wr32(hw, GLINT_DYN_CTL(vector), val); 517940b61afSAnirudh Venkataramanan } 518cdedef59SAnirudh Venkataramanan 519c2a23e00SBrett Creeley /** 520462acf6aSTony Nguyen * ice_netdev_to_pf - Retrieve the PF struct associated with a netdev 521462acf6aSTony Nguyen * @netdev: pointer to the netdev struct 522462acf6aSTony Nguyen */ 523462acf6aSTony Nguyen static inline struct ice_pf *ice_netdev_to_pf(struct net_device *netdev) 524462acf6aSTony Nguyen { 525462acf6aSTony Nguyen struct ice_netdev_priv *np = netdev_priv(netdev); 526462acf6aSTony Nguyen 527462acf6aSTony Nguyen return np->vsi->back; 528462acf6aSTony Nguyen } 529462acf6aSTony Nguyen 530efc2214bSMaciej Fijalkowski static inline bool ice_is_xdp_ena_vsi(struct ice_vsi *vsi) 531efc2214bSMaciej Fijalkowski { 532efc2214bSMaciej Fijalkowski return !!vsi->xdp_prog; 533efc2214bSMaciej Fijalkowski } 534efc2214bSMaciej Fijalkowski 535efc2214bSMaciej Fijalkowski static inline void ice_set_ring_xdp(struct ice_ring *ring) 536efc2214bSMaciej Fijalkowski { 537efc2214bSMaciej Fijalkowski ring->flags |= ICE_TX_FLAGS_RING_XDP; 538efc2214bSMaciej Fijalkowski } 539efc2214bSMaciej Fijalkowski 540462acf6aSTony Nguyen /** 5411742b3d5SMagnus Karlsson * ice_xsk_pool - get XSK buffer pool bound to a ring 542b50f7bcaSJesse Brandeburg * @ring: ring to use 5432d4238f5SKrzysztof Kazimierczak * 5441742b3d5SMagnus Karlsson * Returns a pointer to xdp_umem structure if there is a buffer pool present, 5452d4238f5SKrzysztof Kazimierczak * NULL otherwise. 5462d4238f5SKrzysztof Kazimierczak */ 5471742b3d5SMagnus Karlsson static inline struct xsk_buff_pool *ice_xsk_pool(struct ice_ring *ring) 5482d4238f5SKrzysztof Kazimierczak { 54965bb559bSKrzysztof Kazimierczak u16 qid = ring->q_index; 5502d4238f5SKrzysztof Kazimierczak 5512d4238f5SKrzysztof Kazimierczak if (ice_ring_is_xdp(ring)) 5522d4238f5SKrzysztof Kazimierczak qid -= ring->vsi->num_xdp_txq; 5532d4238f5SKrzysztof Kazimierczak 554c7a21904SMichal Swiatkowski if (!ice_is_xdp_ena_vsi(ring->vsi)) 5552d4238f5SKrzysztof Kazimierczak return NULL; 5562d4238f5SKrzysztof Kazimierczak 557c7a21904SMichal Swiatkowski return xsk_get_pool_from_qid(ring->vsi->netdev, qid); 5582d4238f5SKrzysztof Kazimierczak } 5592d4238f5SKrzysztof Kazimierczak 5602d4238f5SKrzysztof Kazimierczak /** 561208ff751SAnirudh Venkataramanan * ice_get_main_vsi - Get the PF VSI 562208ff751SAnirudh Venkataramanan * @pf: PF instance 563208ff751SAnirudh Venkataramanan * 564208ff751SAnirudh Venkataramanan * returns pf->vsi[0], which by definition is the PF VSI 565c2a23e00SBrett Creeley */ 566208ff751SAnirudh Venkataramanan static inline struct ice_vsi *ice_get_main_vsi(struct ice_pf *pf) 567c2a23e00SBrett Creeley { 568208ff751SAnirudh Venkataramanan if (pf->vsi) 569208ff751SAnirudh Venkataramanan return pf->vsi[0]; 570c2a23e00SBrett Creeley 571c2a23e00SBrett Creeley return NULL; 572c2a23e00SBrett Creeley } 573c2a23e00SBrett Creeley 574148beb61SHenry Tieman /** 575148beb61SHenry Tieman * ice_get_ctrl_vsi - Get the control VSI 576148beb61SHenry Tieman * @pf: PF instance 577148beb61SHenry Tieman */ 578148beb61SHenry Tieman static inline struct ice_vsi *ice_get_ctrl_vsi(struct ice_pf *pf) 579148beb61SHenry Tieman { 580148beb61SHenry Tieman /* if pf->ctrl_vsi_idx is ICE_NO_VSI, control VSI was not set up */ 581148beb61SHenry Tieman if (!pf->vsi || pf->ctrl_vsi_idx == ICE_NO_VSI) 582148beb61SHenry Tieman return NULL; 583148beb61SHenry Tieman 584148beb61SHenry Tieman return pf->vsi[pf->ctrl_vsi_idx]; 585148beb61SHenry Tieman } 586148beb61SHenry Tieman 587df006dd4SDave Ertman /** 588df006dd4SDave Ertman * ice_set_sriov_cap - enable SRIOV in PF flags 589df006dd4SDave Ertman * @pf: PF struct 590df006dd4SDave Ertman */ 591df006dd4SDave Ertman static inline void ice_set_sriov_cap(struct ice_pf *pf) 592df006dd4SDave Ertman { 593df006dd4SDave Ertman if (pf->hw.func_caps.common_cap.sr_iov_1_1) 594df006dd4SDave Ertman set_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags); 595df006dd4SDave Ertman } 596df006dd4SDave Ertman 597df006dd4SDave Ertman /** 598df006dd4SDave Ertman * ice_clear_sriov_cap - disable SRIOV in PF flags 599df006dd4SDave Ertman * @pf: PF struct 600df006dd4SDave Ertman */ 601df006dd4SDave Ertman static inline void ice_clear_sriov_cap(struct ice_pf *pf) 602df006dd4SDave Ertman { 603df006dd4SDave Ertman clear_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags); 604df006dd4SDave Ertman } 605df006dd4SDave Ertman 6064ab95646SHenry Tieman #define ICE_FD_STAT_CTR_BLOCK_COUNT 256 6074ab95646SHenry Tieman #define ICE_FD_STAT_PF_IDX(base_idx) \ 6084ab95646SHenry Tieman ((base_idx) * ICE_FD_STAT_CTR_BLOCK_COUNT) 6094ab95646SHenry Tieman #define ICE_FD_SB_STAT_IDX(base_idx) ICE_FD_STAT_PF_IDX(base_idx) 6104ab95646SHenry Tieman 611df006dd4SDave Ertman bool netif_is_ice(struct net_device *dev); 6120e674aebSAnirudh Venkataramanan int ice_vsi_setup_tx_rings(struct ice_vsi *vsi); 6130e674aebSAnirudh Venkataramanan int ice_vsi_setup_rx_rings(struct ice_vsi *vsi); 614148beb61SHenry Tieman int ice_vsi_open_ctrl(struct ice_vsi *vsi); 615fcea6f3dSAnirudh Venkataramanan void ice_set_ethtool_ops(struct net_device *netdev); 616462acf6aSTony Nguyen void ice_set_ethtool_safe_mode_ops(struct net_device *netdev); 6178c243700SAnirudh Venkataramanan u16 ice_get_avail_txq_count(struct ice_pf *pf); 6188c243700SAnirudh Venkataramanan u16 ice_get_avail_rxq_count(struct ice_pf *pf); 61987324e74SHenry Tieman int ice_vsi_recfg_qs(struct ice_vsi *vsi, int new_rx, int new_tx); 6205a4a8673SBruce Allan void ice_update_vsi_stats(struct ice_vsi *vsi); 6215a4a8673SBruce Allan void ice_update_pf_stats(struct ice_pf *pf); 622fcea6f3dSAnirudh Venkataramanan int ice_up(struct ice_vsi *vsi); 623fcea6f3dSAnirudh Venkataramanan int ice_down(struct ice_vsi *vsi); 6240e674aebSAnirudh Venkataramanan int ice_vsi_cfg(struct ice_vsi *vsi); 6250e674aebSAnirudh Venkataramanan struct ice_vsi *ice_lb_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi); 626efc2214bSMaciej Fijalkowski int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog); 627efc2214bSMaciej Fijalkowski int ice_destroy_xdp_rings(struct ice_vsi *vsi); 628efc2214bSMaciej Fijalkowski int 629efc2214bSMaciej Fijalkowski ice_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames, 630efc2214bSMaciej Fijalkowski u32 flags); 631b66a972aSBrett Creeley int ice_set_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size); 632b66a972aSBrett Creeley int ice_get_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size); 633b66a972aSBrett Creeley int ice_set_rss_key(struct ice_vsi *vsi, u8 *seed); 634b66a972aSBrett Creeley int ice_get_rss_key(struct ice_vsi *vsi, u8 *seed); 635d76a60baSAnirudh Venkataramanan void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size); 63687324e74SHenry Tieman int ice_schedule_reset(struct ice_pf *pf, enum ice_reset_req reset); 637fcea6f3dSAnirudh Venkataramanan void ice_print_link_msg(struct ice_vsi *vsi, bool isup); 6380fee3577SLihong Yang const char *ice_stat_str(enum ice_status stat_err); 6390fee3577SLihong Yang const char *ice_aq_str(enum ice_aq_err aq_err); 64031765519SAnirudh Venkataramanan bool ice_is_wol_supported(struct ice_hw *hw); 64128bf2672SBrett Creeley int 64228bf2672SBrett Creeley ice_fdir_write_fltr(struct ice_pf *pf, struct ice_fdir_fltr *input, bool add, 64328bf2672SBrett Creeley bool is_tun); 644148beb61SHenry Tieman void ice_vsi_manage_fdir(struct ice_vsi *vsi, bool ena); 645cac2a27cSHenry Tieman int ice_add_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd); 646cac2a27cSHenry Tieman int ice_del_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd); 6474ab95646SHenry Tieman int ice_get_ethtool_fdir_entry(struct ice_hw *hw, struct ethtool_rxnfc *cmd); 6484ab95646SHenry Tieman int 6494ab95646SHenry Tieman ice_get_fdir_fltr_ids(struct ice_hw *hw, struct ethtool_rxnfc *cmd, 6504ab95646SHenry Tieman u32 *rule_locs); 651148beb61SHenry Tieman void ice_fdir_release_flows(struct ice_hw *hw); 65283af0039SHenry Tieman void ice_fdir_replay_flows(struct ice_hw *hw); 65383af0039SHenry Tieman void ice_fdir_replay_fltrs(struct ice_pf *pf); 654148beb61SHenry Tieman int ice_fdir_create_dflt_rules(struct ice_pf *pf); 655d69ea414SJacob Keller int ice_aq_wait_for_event(struct ice_pf *pf, u16 opcode, unsigned long timeout, 656d69ea414SJacob Keller struct ice_rq_event_info *event); 6570e674aebSAnirudh Venkataramanan int ice_open(struct net_device *netdev); 658e95fc857SKrzysztof Goreczny int ice_open_internal(struct net_device *netdev); 6590e674aebSAnirudh Venkataramanan int ice_stop(struct net_device *netdev); 66028bf2672SBrett Creeley void ice_service_task_schedule(struct ice_pf *pf); 661d76a60baSAnirudh Venkataramanan 662837f08fdSAnirudh Venkataramanan #endif /* _ICE_H_ */ 663