Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright(c) 2013 - 2018 Intel Corporation. */
0003 
0004 #ifndef _IAVF_H_
0005 #define _IAVF_H_
0006 
0007 #include <linux/module.h>
0008 #include <linux/pci.h>
0009 #include <linux/aer.h>
0010 #include <linux/netdevice.h>
0011 #include <linux/vmalloc.h>
0012 #include <linux/interrupt.h>
0013 #include <linux/ethtool.h>
0014 #include <linux/if_vlan.h>
0015 #include <linux/ip.h>
0016 #include <linux/tcp.h>
0017 #include <linux/sctp.h>
0018 #include <linux/ipv6.h>
0019 #include <linux/kernel.h>
0020 #include <linux/bitops.h>
0021 #include <linux/timer.h>
0022 #include <linux/workqueue.h>
0023 #include <linux/wait.h>
0024 #include <linux/delay.h>
0025 #include <linux/gfp.h>
0026 #include <linux/skbuff.h>
0027 #include <linux/dma-mapping.h>
0028 #include <linux/etherdevice.h>
0029 #include <linux/socket.h>
0030 #include <linux/jiffies.h>
0031 #include <net/ip6_checksum.h>
0032 #include <net/pkt_cls.h>
0033 #include <net/udp.h>
0034 #include <net/tc_act/tc_gact.h>
0035 #include <net/tc_act/tc_mirred.h>
0036 
0037 #include "iavf_type.h"
0038 #include <linux/avf/virtchnl.h>
0039 #include "iavf_txrx.h"
0040 #include "iavf_fdir.h"
0041 #include "iavf_adv_rss.h"
0042 #include <linux/bitmap.h>
0043 
0044 #define DEFAULT_DEBUG_LEVEL_SHIFT 3
0045 #define PFX "iavf: "
0046 
0047 int iavf_status_to_errno(enum iavf_status status);
0048 int virtchnl_status_to_errno(enum virtchnl_status_code v_status);
0049 
0050 /* VSI state flags shared with common code */
0051 enum iavf_vsi_state_t {
0052     __IAVF_VSI_DOWN,
0053     /* This must be last as it determines the size of the BITMAP */
0054     __IAVF_VSI_STATE_SIZE__,
0055 };
0056 
0057 /* dummy struct to make common code less painful */
0058 struct iavf_vsi {
0059     struct iavf_adapter *back;
0060     struct net_device *netdev;
0061     unsigned long active_cvlans[BITS_TO_LONGS(VLAN_N_VID)];
0062     unsigned long active_svlans[BITS_TO_LONGS(VLAN_N_VID)];
0063     u16 seid;
0064     u16 id;
0065     DECLARE_BITMAP(state, __IAVF_VSI_STATE_SIZE__);
0066     int base_vector;
0067     u16 qs_handle;
0068     void *priv;     /* client driver data reference. */
0069 };
0070 
0071 /* How many Rx Buffers do we bundle into one write to the hardware ? */
0072 #define IAVF_RX_BUFFER_WRITE    16  /* Must be power of 2 */
0073 #define IAVF_DEFAULT_TXD    512
0074 #define IAVF_DEFAULT_RXD    512
0075 #define IAVF_MAX_TXD        4096
0076 #define IAVF_MIN_TXD        64
0077 #define IAVF_MAX_RXD        4096
0078 #define IAVF_MIN_RXD        64
0079 #define IAVF_REQ_DESCRIPTOR_MULTIPLE    32
0080 #define IAVF_MAX_AQ_BUF_SIZE    4096
0081 #define IAVF_AQ_LEN     32
0082 #define IAVF_AQ_MAX_ERR 20 /* times to try before resetting AQ */
0083 
0084 #define MAXIMUM_ETHERNET_VLAN_SIZE (VLAN_ETH_FRAME_LEN + ETH_FCS_LEN)
0085 
0086 #define IAVF_RX_DESC(R, i) (&(((union iavf_32byte_rx_desc *)((R)->desc))[i]))
0087 #define IAVF_TX_DESC(R, i) (&(((struct iavf_tx_desc *)((R)->desc))[i]))
0088 #define IAVF_TX_CTXTDESC(R, i) \
0089     (&(((struct iavf_tx_context_desc *)((R)->desc))[i]))
0090 #define IAVF_MAX_REQ_QUEUES 16
0091 
0092 #define IAVF_HKEY_ARRAY_SIZE ((IAVF_VFQF_HKEY_MAX_INDEX + 1) * 4)
0093 #define IAVF_HLUT_ARRAY_SIZE ((IAVF_VFQF_HLUT_MAX_INDEX + 1) * 4)
0094 #define IAVF_MBPS_DIVISOR   125000 /* divisor to convert to Mbps */
0095 #define IAVF_MBPS_QUANTA    50
0096 
0097 #define IAVF_VIRTCHNL_VF_RESOURCE_SIZE (sizeof(struct virtchnl_vf_resource) + \
0098                     (IAVF_MAX_VF_VSI * \
0099                      sizeof(struct virtchnl_vsi_resource)))
0100 
0101 /* MAX_MSIX_Q_VECTORS of these are allocated,
0102  * but we only use one per queue-specific vector.
0103  */
0104 struct iavf_q_vector {
0105     struct iavf_adapter *adapter;
0106     struct iavf_vsi *vsi;
0107     struct napi_struct napi;
0108     struct iavf_ring_container rx;
0109     struct iavf_ring_container tx;
0110     u32 ring_mask;
0111     u8 itr_countdown;   /* when 0 should adjust adaptive ITR */
0112     u8 num_ringpairs;   /* total number of ring pairs in vector */
0113     u16 v_idx;      /* index in the vsi->q_vector array. */
0114     u16 reg_idx;        /* register index of the interrupt */
0115     char name[IFNAMSIZ + 15];
0116     bool arm_wb_state;
0117     cpumask_t affinity_mask;
0118     struct irq_affinity_notify affinity_notify;
0119 };
0120 
0121 /* Helper macros to switch between ints/sec and what the register uses.
0122  * And yes, it's the same math going both ways.  The lowest value
0123  * supported by all of the iavf hardware is 8.
0124  */
0125 #define EITR_INTS_PER_SEC_TO_REG(_eitr) \
0126     ((_eitr) ? (1000000000 / ((_eitr) * 256)) : 8)
0127 #define EITR_REG_TO_INTS_PER_SEC EITR_INTS_PER_SEC_TO_REG
0128 
0129 #define IAVF_DESC_UNUSED(R) \
0130     ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
0131     (R)->next_to_clean - (R)->next_to_use - 1)
0132 
0133 #define OTHER_VECTOR 1
0134 #define NONQ_VECS (OTHER_VECTOR)
0135 
0136 #define MIN_MSIX_Q_VECTORS 1
0137 #define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NONQ_VECS)
0138 
0139 #define IAVF_QUEUE_END_OF_LIST 0x7FF
0140 #define IAVF_FREE_VECTOR 0x7FFF
0141 struct iavf_mac_filter {
0142     struct list_head list;
0143     u8 macaddr[ETH_ALEN];
0144     struct {
0145         u8 is_new_mac:1;    /* filter is new, wait for PF decision */
0146         u8 remove:1;        /* filter needs to be removed */
0147         u8 add:1;           /* filter needs to be added */
0148         u8 is_primary:1;    /* filter is a default VF MAC */
0149         u8 add_handled:1;   /* received response for filter add */
0150         u8 padding:3;
0151     };
0152 };
0153 
0154 #define IAVF_VLAN(vid, tpid) ((struct iavf_vlan){ vid, tpid })
0155 struct iavf_vlan {
0156     u16 vid;
0157     u16 tpid;
0158 };
0159 
0160 struct iavf_vlan_filter {
0161     struct list_head list;
0162     struct iavf_vlan vlan;
0163     struct {
0164         u8 is_new_vlan:1;   /* filter is new, wait for PF answer */
0165         u8 remove:1;        /* filter needs to be removed */
0166         u8 add:1;       /* filter needs to be added */
0167         u8 padding:5;
0168     };
0169 };
0170 
0171 #define IAVF_MAX_TRAFFIC_CLASS  4
0172 /* State of traffic class creation */
0173 enum iavf_tc_state_t {
0174     __IAVF_TC_INVALID, /* no traffic class, default state */
0175     __IAVF_TC_RUNNING, /* traffic classes have been created */
0176 };
0177 
0178 /* channel info */
0179 struct iavf_channel_config {
0180     struct virtchnl_channel_info ch_info[IAVF_MAX_TRAFFIC_CLASS];
0181     enum iavf_tc_state_t state;
0182     u8 total_qps;
0183 };
0184 
0185 /* State of cloud filter */
0186 enum iavf_cloud_filter_state_t {
0187     __IAVF_CF_INVALID,   /* cloud filter not added */
0188     __IAVF_CF_ADD_PENDING, /* cloud filter pending add by the PF */
0189     __IAVF_CF_DEL_PENDING, /* cloud filter pending del by the PF */
0190     __IAVF_CF_ACTIVE,    /* cloud filter is active */
0191 };
0192 
0193 /* Driver state. The order of these is important! */
0194 enum iavf_state_t {
0195     __IAVF_STARTUP,     /* driver loaded, probe complete */
0196     __IAVF_REMOVE,      /* driver is being unloaded */
0197     __IAVF_INIT_VERSION_CHECK,  /* aq msg sent, awaiting reply */
0198     __IAVF_INIT_GET_RESOURCES,  /* aq msg sent, awaiting reply */
0199     __IAVF_INIT_EXTENDED_CAPS,  /* process extended caps which require aq msg exchange */
0200     __IAVF_INIT_CONFIG_ADAPTER,
0201     __IAVF_INIT_SW,     /* got resources, setting up structs */
0202     __IAVF_INIT_FAILED, /* init failed, restarting procedure */
0203     __IAVF_RESETTING,       /* in reset */
0204     __IAVF_COMM_FAILED,     /* communication with PF failed */
0205     /* Below here, watchdog is running */
0206     __IAVF_DOWN,            /* ready, can be opened */
0207     __IAVF_DOWN_PENDING,        /* descending, waiting for watchdog */
0208     __IAVF_TESTING,     /* in ethtool self-test */
0209     __IAVF_RUNNING,     /* opened, working */
0210 };
0211 
0212 enum iavf_critical_section_t {
0213     __IAVF_IN_REMOVE_TASK,  /* device being removed */
0214 };
0215 
0216 #define IAVF_CLOUD_FIELD_OMAC       0x01
0217 #define IAVF_CLOUD_FIELD_IMAC       0x02
0218 #define IAVF_CLOUD_FIELD_IVLAN  0x04
0219 #define IAVF_CLOUD_FIELD_TEN_ID 0x08
0220 #define IAVF_CLOUD_FIELD_IIP        0x10
0221 
0222 #define IAVF_CF_FLAGS_OMAC  IAVF_CLOUD_FIELD_OMAC
0223 #define IAVF_CF_FLAGS_IMAC  IAVF_CLOUD_FIELD_IMAC
0224 #define IAVF_CF_FLAGS_IMAC_IVLAN    (IAVF_CLOUD_FIELD_IMAC |\
0225                      IAVF_CLOUD_FIELD_IVLAN)
0226 #define IAVF_CF_FLAGS_IMAC_TEN_ID   (IAVF_CLOUD_FIELD_IMAC |\
0227                      IAVF_CLOUD_FIELD_TEN_ID)
0228 #define IAVF_CF_FLAGS_OMAC_TEN_ID_IMAC  (IAVF_CLOUD_FIELD_OMAC |\
0229                          IAVF_CLOUD_FIELD_IMAC |\
0230                          IAVF_CLOUD_FIELD_TEN_ID)
0231 #define IAVF_CF_FLAGS_IMAC_IVLAN_TEN_ID (IAVF_CLOUD_FIELD_IMAC |\
0232                          IAVF_CLOUD_FIELD_IVLAN |\
0233                          IAVF_CLOUD_FIELD_TEN_ID)
0234 #define IAVF_CF_FLAGS_IIP   IAVF_CLOUD_FIELD_IIP
0235 
0236 /* bookkeeping of cloud filters */
0237 struct iavf_cloud_filter {
0238     enum iavf_cloud_filter_state_t state;
0239     struct list_head list;
0240     struct virtchnl_filter f;
0241     unsigned long cookie;
0242     bool del;       /* filter needs to be deleted */
0243     bool add;       /* filter needs to be added */
0244 };
0245 
0246 #define IAVF_RESET_WAIT_MS 10
0247 #define IAVF_RESET_WAIT_DETECTED_COUNT 500
0248 #define IAVF_RESET_WAIT_COMPLETE_COUNT 2000
0249 
0250 /* board specific private data structure */
0251 struct iavf_adapter {
0252     struct work_struct reset_task;
0253     struct work_struct adminq_task;
0254     struct delayed_work client_task;
0255     wait_queue_head_t down_waitqueue;
0256     wait_queue_head_t vc_waitqueue;
0257     struct iavf_q_vector *q_vectors;
0258     struct list_head vlan_filter_list;
0259     struct list_head mac_filter_list;
0260     struct mutex crit_lock;
0261     struct mutex client_lock;
0262     /* Lock to protect accesses to MAC and VLAN lists */
0263     spinlock_t mac_vlan_list_lock;
0264     char misc_vector_name[IFNAMSIZ + 9];
0265     int num_active_queues;
0266     int num_req_queues;
0267 
0268     /* TX */
0269     struct iavf_ring *tx_rings;
0270     u32 tx_timeout_count;
0271     u32 tx_desc_count;
0272 
0273     /* RX */
0274     struct iavf_ring *rx_rings;
0275     u64 hw_csum_rx_error;
0276     u32 rx_desc_count;
0277     int num_msix_vectors;
0278     int num_iwarp_msix;
0279     int iwarp_base_vector;
0280     u32 client_pending;
0281     struct iavf_client_instance *cinst;
0282     struct msix_entry *msix_entries;
0283 
0284     u32 flags;
0285 #define IAVF_FLAG_RX_CSUM_ENABLED       BIT(0)
0286 #define IAVF_FLAG_PF_COMMS_FAILED       BIT(3)
0287 #define IAVF_FLAG_RESET_PENDING     BIT(4)
0288 #define IAVF_FLAG_RESET_NEEDED      BIT(5)
0289 #define IAVF_FLAG_WB_ON_ITR_CAPABLE     BIT(6)
0290 #define IAVF_FLAG_SERVICE_CLIENT_REQUESTED  BIT(9)
0291 #define IAVF_FLAG_CLIENT_NEEDS_OPEN     BIT(10)
0292 #define IAVF_FLAG_CLIENT_NEEDS_CLOSE        BIT(11)
0293 #define IAVF_FLAG_CLIENT_NEEDS_L2_PARAMS    BIT(12)
0294 #define IAVF_FLAG_PROMISC_ON            BIT(13)
0295 #define IAVF_FLAG_ALLMULTI_ON           BIT(14)
0296 #define IAVF_FLAG_LEGACY_RX         BIT(15)
0297 #define IAVF_FLAG_REINIT_ITR_NEEDED     BIT(16)
0298 #define IAVF_FLAG_QUEUES_DISABLED       BIT(17)
0299 #define IAVF_FLAG_SETUP_NETDEV_FEATURES     BIT(18)
0300 #define IAVF_FLAG_REINIT_MSIX_NEEDED        BIT(20)
0301 #define IAVF_FLAG_INITIAL_MAC_SET       BIT(23)
0302 /* duplicates for common code */
0303 #define IAVF_FLAG_DCB_ENABLED           0
0304     /* flags for admin queue service task */
0305     u64 aq_required;
0306 #define IAVF_FLAG_AQ_ENABLE_QUEUES      BIT_ULL(0)
0307 #define IAVF_FLAG_AQ_DISABLE_QUEUES     BIT_ULL(1)
0308 #define IAVF_FLAG_AQ_ADD_MAC_FILTER     BIT_ULL(2)
0309 #define IAVF_FLAG_AQ_ADD_VLAN_FILTER        BIT_ULL(3)
0310 #define IAVF_FLAG_AQ_DEL_MAC_FILTER     BIT_ULL(4)
0311 #define IAVF_FLAG_AQ_DEL_VLAN_FILTER        BIT_ULL(5)
0312 #define IAVF_FLAG_AQ_CONFIGURE_QUEUES       BIT_ULL(6)
0313 #define IAVF_FLAG_AQ_MAP_VECTORS        BIT_ULL(7)
0314 #define IAVF_FLAG_AQ_HANDLE_RESET       BIT_ULL(8)
0315 #define IAVF_FLAG_AQ_CONFIGURE_RSS      BIT_ULL(9) /* direct AQ config */
0316 #define IAVF_FLAG_AQ_GET_CONFIG         BIT_ULL(10)
0317 /* Newer style, RSS done by the PF so we can ignore hardware vagaries. */
0318 #define IAVF_FLAG_AQ_GET_HENA           BIT_ULL(11)
0319 #define IAVF_FLAG_AQ_SET_HENA           BIT_ULL(12)
0320 #define IAVF_FLAG_AQ_SET_RSS_KEY        BIT_ULL(13)
0321 #define IAVF_FLAG_AQ_SET_RSS_LUT        BIT_ULL(14)
0322 #define IAVF_FLAG_AQ_REQUEST_PROMISC        BIT_ULL(15)
0323 #define IAVF_FLAG_AQ_RELEASE_PROMISC        BIT_ULL(16)
0324 #define IAVF_FLAG_AQ_REQUEST_ALLMULTI       BIT_ULL(17)
0325 #define IAVF_FLAG_AQ_RELEASE_ALLMULTI       BIT_ULL(18)
0326 #define IAVF_FLAG_AQ_ENABLE_VLAN_STRIPPING  BIT_ULL(19)
0327 #define IAVF_FLAG_AQ_DISABLE_VLAN_STRIPPING BIT_ULL(20)
0328 #define IAVF_FLAG_AQ_ENABLE_CHANNELS        BIT_ULL(21)
0329 #define IAVF_FLAG_AQ_DISABLE_CHANNELS       BIT_ULL(22)
0330 #define IAVF_FLAG_AQ_ADD_CLOUD_FILTER       BIT_ULL(23)
0331 #define IAVF_FLAG_AQ_DEL_CLOUD_FILTER       BIT_ULL(24)
0332 #define IAVF_FLAG_AQ_ADD_FDIR_FILTER        BIT_ULL(25)
0333 #define IAVF_FLAG_AQ_DEL_FDIR_FILTER        BIT_ULL(26)
0334 #define IAVF_FLAG_AQ_ADD_ADV_RSS_CFG        BIT_ULL(27)
0335 #define IAVF_FLAG_AQ_DEL_ADV_RSS_CFG        BIT_ULL(28)
0336 #define IAVF_FLAG_AQ_REQUEST_STATS      BIT_ULL(29)
0337 #define IAVF_FLAG_AQ_GET_OFFLOAD_VLAN_V2_CAPS   BIT_ULL(30)
0338 #define IAVF_FLAG_AQ_ENABLE_CTAG_VLAN_STRIPPING     BIT_ULL(31)
0339 #define IAVF_FLAG_AQ_DISABLE_CTAG_VLAN_STRIPPING    BIT_ULL(32)
0340 #define IAVF_FLAG_AQ_ENABLE_STAG_VLAN_STRIPPING     BIT_ULL(33)
0341 #define IAVF_FLAG_AQ_DISABLE_STAG_VLAN_STRIPPING    BIT_ULL(34)
0342 #define IAVF_FLAG_AQ_ENABLE_CTAG_VLAN_INSERTION     BIT_ULL(35)
0343 #define IAVF_FLAG_AQ_DISABLE_CTAG_VLAN_INSERTION    BIT_ULL(36)
0344 #define IAVF_FLAG_AQ_ENABLE_STAG_VLAN_INSERTION     BIT_ULL(37)
0345 #define IAVF_FLAG_AQ_DISABLE_STAG_VLAN_INSERTION    BIT_ULL(38)
0346 
0347     /* flags for processing extended capability messages during
0348      * __IAVF_INIT_EXTENDED_CAPS. Each capability exchange requires
0349      * both a SEND and a RECV step, which must be processed in sequence.
0350      *
0351      * During the __IAVF_INIT_EXTENDED_CAPS state, the driver will
0352      * process one flag at a time during each state loop.
0353      */
0354     u64 extended_caps;
0355 #define IAVF_EXTENDED_CAP_SEND_VLAN_V2          BIT_ULL(0)
0356 #define IAVF_EXTENDED_CAP_RECV_VLAN_V2          BIT_ULL(1)
0357 
0358 #define IAVF_EXTENDED_CAPS              \
0359     (IAVF_EXTENDED_CAP_SEND_VLAN_V2 |       \
0360      IAVF_EXTENDED_CAP_RECV_VLAN_V2)
0361 
0362     /* OS defined structs */
0363     struct net_device *netdev;
0364     struct pci_dev *pdev;
0365 
0366     struct iavf_hw hw; /* defined in iavf_type.h */
0367 
0368     enum iavf_state_t state;
0369     enum iavf_state_t last_state;
0370     unsigned long crit_section;
0371 
0372     struct delayed_work watchdog_task;
0373     bool netdev_registered;
0374     bool link_up;
0375     enum virtchnl_link_speed link_speed;
0376     /* This is only populated if the VIRTCHNL_VF_CAP_ADV_LINK_SPEED is set
0377      * in vf_res->vf_cap_flags. Use ADV_LINK_SUPPORT macro to determine if
0378      * this field is valid. This field should be used going forward and the
0379      * enum virtchnl_link_speed above should be considered the legacy way of
0380      * storing/communicating link speeds.
0381      */
0382     u32 link_speed_mbps;
0383 
0384     enum virtchnl_ops current_op;
0385 #define CLIENT_ALLOWED(_a) ((_a)->vf_res ? \
0386                 (_a)->vf_res->vf_cap_flags & \
0387                 VIRTCHNL_VF_OFFLOAD_IWARP : \
0388                 0)
0389 #define CLIENT_ENABLED(_a) ((_a)->cinst)
0390 /* RSS by the PF should be preferred over RSS via other methods. */
0391 #define RSS_PF(_a) ((_a)->vf_res->vf_cap_flags & \
0392             VIRTCHNL_VF_OFFLOAD_RSS_PF)
0393 #define RSS_AQ(_a) ((_a)->vf_res->vf_cap_flags & \
0394             VIRTCHNL_VF_OFFLOAD_RSS_AQ)
0395 #define RSS_REG(_a) (!((_a)->vf_res->vf_cap_flags & \
0396                (VIRTCHNL_VF_OFFLOAD_RSS_AQ | \
0397             VIRTCHNL_VF_OFFLOAD_RSS_PF)))
0398 #define VLAN_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \
0399               VIRTCHNL_VF_OFFLOAD_VLAN)
0400 #define VLAN_V2_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \
0401                  VIRTCHNL_VF_OFFLOAD_VLAN_V2)
0402 #define VLAN_V2_FILTERING_ALLOWED(_a) \
0403     (VLAN_V2_ALLOWED((_a)) && \
0404      ((_a)->vlan_v2_caps.filtering.filtering_support.outer || \
0405       (_a)->vlan_v2_caps.filtering.filtering_support.inner))
0406 #define VLAN_FILTERING_ALLOWED(_a) \
0407     (VLAN_ALLOWED((_a)) || VLAN_V2_FILTERING_ALLOWED((_a)))
0408 #define ADV_LINK_SUPPORT(_a) ((_a)->vf_res->vf_cap_flags & \
0409                   VIRTCHNL_VF_CAP_ADV_LINK_SPEED)
0410 #define FDIR_FLTR_SUPPORT(_a) ((_a)->vf_res->vf_cap_flags & \
0411                    VIRTCHNL_VF_OFFLOAD_FDIR_PF)
0412 #define ADV_RSS_SUPPORT(_a) ((_a)->vf_res->vf_cap_flags & \
0413                  VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF)
0414     struct virtchnl_vf_resource *vf_res; /* incl. all VSIs */
0415     struct virtchnl_vsi_resource *vsi_res; /* our LAN VSI */
0416     struct virtchnl_version_info pf_version;
0417 #define PF_IS_V11(_a) (((_a)->pf_version.major == 1) && \
0418                ((_a)->pf_version.minor == 1))
0419     struct virtchnl_vlan_caps vlan_v2_caps;
0420     u16 msg_enable;
0421     struct iavf_eth_stats current_stats;
0422     struct iavf_vsi vsi;
0423     u32 aq_wait_count;
0424     /* RSS stuff */
0425     u64 hena;
0426     u16 rss_key_size;
0427     u16 rss_lut_size;
0428     u8 *rss_key;
0429     u8 *rss_lut;
0430     /* ADQ related members */
0431     struct iavf_channel_config ch_config;
0432     u8 num_tc;
0433     struct list_head cloud_filter_list;
0434     /* lock to protect access to the cloud filter list */
0435     spinlock_t cloud_filter_list_lock;
0436     u16 num_cloud_filters;
0437     /* snapshot of "num_active_queues" before setup_tc for qdisc add
0438      * is invoked. This information is useful during qdisc del flow,
0439      * to restore correct number of queues
0440      */
0441     int orig_num_active_queues;
0442 
0443 #define IAVF_MAX_FDIR_FILTERS 128   /* max allowed Flow Director filters */
0444     u16 fdir_active_fltr;
0445     struct list_head fdir_list_head;
0446     spinlock_t fdir_fltr_lock;  /* protect the Flow Director filter list */
0447 
0448     struct list_head adv_rss_list_head;
0449     spinlock_t adv_rss_lock;    /* protect the RSS management list */
0450 };
0451 
0452 
0453 /* Ethtool Private Flags */
0454 
0455 /* lan device, used by client interface */
0456 struct iavf_device {
0457     struct list_head list;
0458     struct iavf_adapter *vf;
0459 };
0460 
0461 /* needed by iavf_ethtool.c */
0462 extern char iavf_driver_name[];
0463 extern struct workqueue_struct *iavf_wq;
0464 
0465 static inline const char *iavf_state_str(enum iavf_state_t state)
0466 {
0467     switch (state) {
0468     case __IAVF_STARTUP:
0469         return "__IAVF_STARTUP";
0470     case __IAVF_REMOVE:
0471         return "__IAVF_REMOVE";
0472     case __IAVF_INIT_VERSION_CHECK:
0473         return "__IAVF_INIT_VERSION_CHECK";
0474     case __IAVF_INIT_GET_RESOURCES:
0475         return "__IAVF_INIT_GET_RESOURCES";
0476     case __IAVF_INIT_EXTENDED_CAPS:
0477         return "__IAVF_INIT_EXTENDED_CAPS";
0478     case __IAVF_INIT_CONFIG_ADAPTER:
0479         return "__IAVF_INIT_CONFIG_ADAPTER";
0480     case __IAVF_INIT_SW:
0481         return "__IAVF_INIT_SW";
0482     case __IAVF_INIT_FAILED:
0483         return "__IAVF_INIT_FAILED";
0484     case __IAVF_RESETTING:
0485         return "__IAVF_RESETTING";
0486     case __IAVF_COMM_FAILED:
0487         return "__IAVF_COMM_FAILED";
0488     case __IAVF_DOWN:
0489         return "__IAVF_DOWN";
0490     case __IAVF_DOWN_PENDING:
0491         return "__IAVF_DOWN_PENDING";
0492     case __IAVF_TESTING:
0493         return "__IAVF_TESTING";
0494     case __IAVF_RUNNING:
0495         return "__IAVF_RUNNING";
0496     default:
0497         return "__IAVF_UNKNOWN_STATE";
0498     }
0499 }
0500 
0501 static inline void iavf_change_state(struct iavf_adapter *adapter,
0502                      enum iavf_state_t state)
0503 {
0504     if (adapter->state != state) {
0505         adapter->last_state = adapter->state;
0506         adapter->state = state;
0507     }
0508     dev_dbg(&adapter->pdev->dev,
0509         "state transition from:%s to:%s\n",
0510         iavf_state_str(adapter->last_state),
0511         iavf_state_str(adapter->state));
0512 }
0513 
0514 int iavf_up(struct iavf_adapter *adapter);
0515 void iavf_down(struct iavf_adapter *adapter);
0516 int iavf_process_config(struct iavf_adapter *adapter);
0517 int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter);
0518 void iavf_schedule_reset(struct iavf_adapter *adapter);
0519 void iavf_schedule_request_stats(struct iavf_adapter *adapter);
0520 void iavf_reset(struct iavf_adapter *adapter);
0521 void iavf_set_ethtool_ops(struct net_device *netdev);
0522 void iavf_update_stats(struct iavf_adapter *adapter);
0523 void iavf_reset_interrupt_capability(struct iavf_adapter *adapter);
0524 int iavf_init_interrupt_scheme(struct iavf_adapter *adapter);
0525 void iavf_irq_enable_queues(struct iavf_adapter *adapter, u32 mask);
0526 void iavf_free_all_tx_resources(struct iavf_adapter *adapter);
0527 void iavf_free_all_rx_resources(struct iavf_adapter *adapter);
0528 
0529 void iavf_napi_add_all(struct iavf_adapter *adapter);
0530 void iavf_napi_del_all(struct iavf_adapter *adapter);
0531 
0532 int iavf_send_api_ver(struct iavf_adapter *adapter);
0533 int iavf_verify_api_ver(struct iavf_adapter *adapter);
0534 int iavf_send_vf_config_msg(struct iavf_adapter *adapter);
0535 int iavf_get_vf_config(struct iavf_adapter *adapter);
0536 int iavf_get_vf_vlan_v2_caps(struct iavf_adapter *adapter);
0537 int iavf_send_vf_offload_vlan_v2_msg(struct iavf_adapter *adapter);
0538 void iavf_set_queue_vlan_tag_loc(struct iavf_adapter *adapter);
0539 u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter);
0540 void iavf_irq_enable(struct iavf_adapter *adapter, bool flush);
0541 void iavf_configure_queues(struct iavf_adapter *adapter);
0542 void iavf_deconfigure_queues(struct iavf_adapter *adapter);
0543 void iavf_enable_queues(struct iavf_adapter *adapter);
0544 void iavf_disable_queues(struct iavf_adapter *adapter);
0545 void iavf_map_queues(struct iavf_adapter *adapter);
0546 int iavf_request_queues(struct iavf_adapter *adapter, int num);
0547 void iavf_add_ether_addrs(struct iavf_adapter *adapter);
0548 void iavf_del_ether_addrs(struct iavf_adapter *adapter);
0549 void iavf_add_vlans(struct iavf_adapter *adapter);
0550 void iavf_del_vlans(struct iavf_adapter *adapter);
0551 void iavf_set_promiscuous(struct iavf_adapter *adapter, int flags);
0552 void iavf_request_stats(struct iavf_adapter *adapter);
0553 int iavf_request_reset(struct iavf_adapter *adapter);
0554 void iavf_get_hena(struct iavf_adapter *adapter);
0555 void iavf_set_hena(struct iavf_adapter *adapter);
0556 void iavf_set_rss_key(struct iavf_adapter *adapter);
0557 void iavf_set_rss_lut(struct iavf_adapter *adapter);
0558 void iavf_enable_vlan_stripping(struct iavf_adapter *adapter);
0559 void iavf_disable_vlan_stripping(struct iavf_adapter *adapter);
0560 void iavf_virtchnl_completion(struct iavf_adapter *adapter,
0561                   enum virtchnl_ops v_opcode,
0562                   enum iavf_status v_retval, u8 *msg, u16 msglen);
0563 int iavf_config_rss(struct iavf_adapter *adapter);
0564 int iavf_lan_add_device(struct iavf_adapter *adapter);
0565 int iavf_lan_del_device(struct iavf_adapter *adapter);
0566 void iavf_client_subtask(struct iavf_adapter *adapter);
0567 void iavf_notify_client_message(struct iavf_vsi *vsi, u8 *msg, u16 len);
0568 void iavf_notify_client_l2_params(struct iavf_vsi *vsi);
0569 void iavf_notify_client_open(struct iavf_vsi *vsi);
0570 void iavf_notify_client_close(struct iavf_vsi *vsi, bool reset);
0571 void iavf_enable_channels(struct iavf_adapter *adapter);
0572 void iavf_disable_channels(struct iavf_adapter *adapter);
0573 void iavf_add_cloud_filter(struct iavf_adapter *adapter);
0574 void iavf_del_cloud_filter(struct iavf_adapter *adapter);
0575 void iavf_enable_vlan_stripping_v2(struct iavf_adapter *adapter, u16 tpid);
0576 void iavf_disable_vlan_stripping_v2(struct iavf_adapter *adapter, u16 tpid);
0577 void iavf_enable_vlan_insertion_v2(struct iavf_adapter *adapter, u16 tpid);
0578 void iavf_disable_vlan_insertion_v2(struct iavf_adapter *adapter, u16 tpid);
0579 int iavf_replace_primary_mac(struct iavf_adapter *adapter,
0580                  const u8 *new_mac);
0581 void
0582 iavf_set_vlan_offload_features(struct iavf_adapter *adapter,
0583                    netdev_features_t prev_features,
0584                    netdev_features_t features);
0585 void iavf_add_fdir_filter(struct iavf_adapter *adapter);
0586 void iavf_del_fdir_filter(struct iavf_adapter *adapter);
0587 void iavf_add_adv_rss_cfg(struct iavf_adapter *adapter);
0588 void iavf_del_adv_rss_cfg(struct iavf_adapter *adapter);
0589 struct iavf_mac_filter *iavf_add_filter(struct iavf_adapter *adapter,
0590                     const u8 *macaddr);
0591 int iavf_lock_timeout(struct mutex *lock, unsigned int msecs);
0592 #endif /* _IAVF_H_ */