LCOV - code coverage report
Current view: top level - drivers/net/iavf - iavf.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 22 0.0 %
Date: 2025-01-02 22:41:34 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 4 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2017 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _IAVF_ETHDEV_H_
       6                 :            : #define _IAVF_ETHDEV_H_
       7                 :            : 
       8                 :            : #include <sys/queue.h>
       9                 :            : 
      10                 :            : #include <rte_kvargs.h>
      11                 :            : #include <rte_tm_driver.h>
      12                 :            : 
      13                 :            : #include <iavf_prototype.h>
      14                 :            : #include <iavf_adminq_cmd.h>
      15                 :            : #include <iavf_type.h>
      16                 :            : 
      17                 :            : #include "iavf_log.h"
      18                 :            : 
      19                 :            : #define IAVF_AQ_LEN               32
      20                 :            : #define IAVF_AQ_BUF_SZ            4096
      21                 :            : #define IAVF_RESET_WAIT_CNT       2000
      22                 :            : #define IAVF_RESET_DETECTED_CNT   500
      23                 :            : #define IAVF_BUF_SIZE_MIN         1024
      24                 :            : #define IAVF_FRAME_SIZE_MAX       9728
      25                 :            : #define IAVF_QUEUE_BASE_ADDR_UNIT 128
      26                 :            : 
      27                 :            : #define IAVF_MAX_NUM_QUEUES_DFLT         16
      28                 :            : #define IAVF_MAX_NUM_QUEUES_LV           256
      29                 :            : #define IAVF_CFG_Q_NUM_PER_BUF           32
      30                 :            : #define IAVF_IRQ_MAP_NUM_PER_BUF         128
      31                 :            : #define IAVF_RXTX_QUEUE_CHUNKS_NUM       2
      32                 :            : 
      33                 :            : #define IAVF_NUM_MACADDR_MAX      64
      34                 :            : 
      35                 :            : #define IAVF_DEV_WATCHDOG_PERIOD     2000 /* microseconds, set 0 to disable*/
      36                 :            : 
      37                 :            : #define IAVF_DEFAULT_RX_PTHRESH      8
      38                 :            : #define IAVF_DEFAULT_RX_HTHRESH      8
      39                 :            : #define IAVF_DEFAULT_RX_WTHRESH      0
      40                 :            : 
      41                 :            : #define IAVF_DEFAULT_RX_FREE_THRESH  32
      42                 :            : 
      43                 :            : #define IAVF_DEFAULT_TX_PTHRESH      32
      44                 :            : #define IAVF_DEFAULT_TX_HTHRESH      0
      45                 :            : #define IAVF_DEFAULT_TX_WTHRESH      0
      46                 :            : 
      47                 :            : #define IAVF_DEFAULT_TX_FREE_THRESH  32
      48                 :            : #define IAVF_DEFAULT_TX_RS_THRESH 32
      49                 :            : 
      50                 :            : #define IAVF_BASIC_OFFLOAD_CAPS  ( \
      51                 :            :         VF_BASE_MODE_OFFLOADS | \
      52                 :            :         VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | \
      53                 :            :         VIRTCHNL_VF_OFFLOAD_RX_POLLING)
      54                 :            : 
      55                 :            : #define IAVF_RSS_OFFLOAD_ALL ( \
      56                 :            :         RTE_ETH_RSS_IPV4 | \
      57                 :            :         RTE_ETH_RSS_FRAG_IPV4 |         \
      58                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_TCP |  \
      59                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_UDP |  \
      60                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
      61                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
      62                 :            :         RTE_ETH_RSS_IPV6 | \
      63                 :            :         RTE_ETH_RSS_FRAG_IPV6 | \
      64                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
      65                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
      66                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
      67                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_OTHER)
      68                 :            : 
      69                 :            : #define IAVF_MISC_VEC_ID                RTE_INTR_VEC_ZERO_OFFSET
      70                 :            : #define IAVF_RX_VEC_START               RTE_INTR_VEC_RXTX_OFFSET
      71                 :            : 
      72                 :            : /* Default queue interrupt throttling time in microseconds */
      73                 :            : #define IAVF_ITR_INDEX_DEFAULT          0
      74                 :            : #define IAVF_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
      75                 :            : #define IAVF_QUEUE_ITR_INTERVAL_MAX     8160 /* 8160 us */
      76                 :            : 
      77                 :            : #define IAVF_ALARM_INTERVAL 50000 /* us */
      78                 :            : 
      79                 :            : /* The overhead from MTU to max frame size.
      80                 :            :  * Considering QinQ packet, the VLAN tag needs to be counted twice.
      81                 :            :  */
      82                 :            : #define IAVF_ETH_OVERHEAD \
      83                 :            :         (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + RTE_VLAN_HLEN * 2)
      84                 :            : #define IAVF_ETH_MAX_LEN (RTE_ETHER_MTU + IAVF_ETH_OVERHEAD)
      85                 :            : 
      86                 :            : #define IAVF_32_BIT_WIDTH (CHAR_BIT * 4)
      87                 :            : #define IAVF_48_BIT_WIDTH (CHAR_BIT * 6)
      88                 :            : #define IAVF_48_BIT_MASK  RTE_LEN2MASK(IAVF_48_BIT_WIDTH, uint64_t)
      89                 :            : 
      90                 :            : #define IAVF_RX_DESC_EXT_STATUS_FLEXBH_MASK  0x03
      91                 :            : #define IAVF_RX_DESC_EXT_STATUS_FLEXBH_FD_ID 0x01
      92                 :            : 
      93                 :            : #define IAVF_BITS_PER_BYTE 8
      94                 :            : 
      95                 :            : #define IAVF_VLAN_TAG_PCP_OFFSET 13
      96                 :            : 
      97                 :            : #define IAVF_L2TPV2_FLAGS_LEN   0x4000
      98                 :            : 
      99                 :            : struct iavf_adapter;
     100                 :            : struct iavf_rx_queue;
     101                 :            : struct iavf_tx_queue;
     102                 :            : 
     103                 :            : 
     104                 :            : struct iavf_ipsec_crypto_stats {
     105                 :            :         uint64_t icount;
     106                 :            :         uint64_t ibytes;
     107                 :            :         struct {
     108                 :            :                 uint64_t count;
     109                 :            :                 uint64_t sad_miss;
     110                 :            :                 uint64_t not_processed;
     111                 :            :                 uint64_t icv_check;
     112                 :            :                 uint64_t ipsec_length;
     113                 :            :                 uint64_t misc;
     114                 :            :         } ierrors;
     115                 :            : };
     116                 :            : 
     117                 :            : struct iavf_mbuf_stats {
     118                 :            :         uint64_t tx_pkt_errors;
     119                 :            : };
     120                 :            : 
     121                 :            : struct iavf_eth_xstats {
     122                 :            :         struct virtchnl_eth_stats eth_stats;
     123                 :            :         struct iavf_ipsec_crypto_stats ips_stats;
     124                 :            :         struct iavf_mbuf_stats mbuf_stats;
     125                 :            : };
     126                 :            : 
     127                 :            : /* Structure that defines a VSI, associated with a adapter. */
     128                 :            : struct iavf_vsi {
     129                 :            :         struct iavf_adapter *adapter; /* Backreference to associated adapter */
     130                 :            :         uint16_t vsi_id;
     131                 :            :         uint16_t nb_qps;         /* Number of queue pairs VSI can occupy */
     132                 :            :         uint16_t nb_used_qps;    /* Number of queue pairs VSI uses */
     133                 :            :         uint16_t max_macaddrs;   /* Maximum number of MAC addresses */
     134                 :            :         uint16_t base_vector;
     135                 :            :         uint16_t msix_intr;      /* The MSIX interrupt binds to VSI */
     136                 :            :         struct iavf_eth_xstats eth_stats_offset;
     137                 :            : };
     138                 :            : 
     139                 :            : struct rte_flow;
     140                 :            : TAILQ_HEAD(iavf_flow_list, rte_flow);
     141                 :            : 
     142                 :            : struct iavf_flow_parser_node;
     143                 :            : TAILQ_HEAD(iavf_parser_list, iavf_flow_parser_node);
     144                 :            : 
     145                 :            : struct iavf_fdir_conf {
     146                 :            :         struct virtchnl_fdir_add add_fltr;
     147                 :            :         struct virtchnl_fdir_del del_fltr;
     148                 :            :         uint64_t input_set;
     149                 :            :         uint32_t flow_id;
     150                 :            :         uint32_t mark_flag;
     151                 :            : };
     152                 :            : 
     153                 :            : struct iavf_fdir_info {
     154                 :            :         struct iavf_fdir_conf conf;
     155                 :            : };
     156                 :            : 
     157                 :            : struct iavf_fsub_conf {
     158                 :            :         struct virtchnl_flow_sub sub_fltr;
     159                 :            :         struct virtchnl_flow_unsub unsub_fltr;
     160                 :            :         uint64_t input_set;
     161                 :            :         uint32_t flow_id;
     162                 :            : };
     163                 :            : 
     164                 :            : struct iavf_qv_map {
     165                 :            :         uint16_t queue_id;
     166                 :            :         uint16_t vector_id;
     167                 :            : };
     168                 :            : 
     169                 :            : /* Message type read in admin queue from PF */
     170                 :            : enum iavf_aq_result {
     171                 :            :         IAVF_MSG_ERR = -1, /* Meet error when accessing admin queue */
     172                 :            :         IAVF_MSG_NON,      /* Read nothing from admin queue */
     173                 :            :         IAVF_MSG_SYS,      /* Read system msg from admin queue */
     174                 :            :         IAVF_MSG_CMD,      /* Read async command result */
     175                 :            : };
     176                 :            : 
     177                 :            : /* Struct to store Traffic Manager node configuration. */
     178                 :            : struct iavf_tm_node {
     179                 :            :         TAILQ_ENTRY(iavf_tm_node) node;
     180                 :            :         uint32_t id;
     181                 :            :         uint32_t tc;
     182                 :            :         uint32_t priority;
     183                 :            :         uint32_t weight;
     184                 :            :         uint32_t reference_count;
     185                 :            :         struct iavf_tm_node *parent;
     186                 :            :         struct iavf_tm_shaper_profile *shaper_profile;
     187                 :            :         struct rte_tm_node_params params;
     188                 :            : };
     189                 :            : 
     190                 :            : TAILQ_HEAD(iavf_tm_node_list, iavf_tm_node);
     191                 :            : 
     192                 :            : struct iavf_tm_shaper_profile {
     193                 :            :         TAILQ_ENTRY(iavf_tm_shaper_profile) node;
     194                 :            :         uint32_t shaper_profile_id;
     195                 :            :         uint32_t reference_count;
     196                 :            :         struct rte_tm_shaper_params profile;
     197                 :            : };
     198                 :            : 
     199                 :            : TAILQ_HEAD(iavf_shaper_profile_list, iavf_tm_shaper_profile);
     200                 :            : 
     201                 :            : /* node type of Traffic Manager */
     202                 :            : enum iavf_tm_node_type {
     203                 :            :         IAVF_TM_NODE_TYPE_PORT,
     204                 :            :         IAVF_TM_NODE_TYPE_TC,
     205                 :            :         IAVF_TM_NODE_TYPE_QUEUE,
     206                 :            :         IAVF_TM_NODE_TYPE_MAX,
     207                 :            : };
     208                 :            : 
     209                 :            : /* Struct to store all the Traffic Manager configuration. */
     210                 :            : struct iavf_tm_conf {
     211                 :            :         struct iavf_tm_node *root; /* root node - vf vsi */
     212                 :            :         struct iavf_tm_node_list tc_list; /* node list for all the TCs */
     213                 :            :         struct iavf_tm_node_list queue_list; /* node list for all the queues */
     214                 :            :         struct iavf_shaper_profile_list shaper_profile_list;
     215                 :            :         uint32_t nb_tc_node;
     216                 :            :         uint32_t nb_queue_node;
     217                 :            :         bool committed;
     218                 :            : };
     219                 :            : 
     220                 :            : /* Struct to store queue TC mapping. Queue is continuous in one TC */
     221                 :            : struct iavf_qtc_map {
     222                 :            :         uint8_t tc;
     223                 :            :         uint16_t start_queue_id;
     224                 :            :         uint16_t queue_count;
     225                 :            : };
     226                 :            : 
     227                 :            : /* Structure to store private data specific for VF instance. */
     228                 :            : struct iavf_info {
     229                 :            :         uint16_t num_queue_pairs;
     230                 :            :         uint16_t max_pkt_len; /* Maximum packet length */
     231                 :            :         uint16_t mac_num;     /* Number of MAC addresses */
     232                 :            :         bool promisc_unicast_enabled;
     233                 :            :         bool promisc_multicast_enabled;
     234                 :            : 
     235                 :            :         struct virtchnl_version_info virtchnl_version;
     236                 :            :         struct virtchnl_vf_resource *vf_res; /* VF resource */
     237                 :            :         struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
     238                 :            :         struct virtchnl_vlan_caps vlan_v2_caps;
     239                 :            :         uint64_t supported_rxdid;
     240                 :            :         uint8_t *proto_xtr; /* proto xtr type for all queues */
     241                 :            :         volatile RTE_ATOMIC(enum virtchnl_ops) pend_cmd; /* pending command not finished */
     242                 :            :         RTE_ATOMIC(uint32_t) pend_cmd_count;
     243                 :            :         int cmd_retval; /* return value of the cmd response from PF */
     244                 :            :         uint8_t *aq_resp; /* buffer to store the adminq response from PF */
     245                 :            : 
     246                 :            :         /** iAVF watchdog enable */
     247                 :            :         bool watchdog_enabled;
     248                 :            : 
     249                 :            :         /* Event from pf */
     250                 :            :         bool dev_closed;
     251                 :            :         bool link_up;
     252                 :            :         uint32_t link_speed;
     253                 :            : 
     254                 :            :         /* Multicast addrs */
     255                 :            :         struct rte_ether_addr mc_addrs[IAVF_NUM_MACADDR_MAX];
     256                 :            :         uint16_t mc_addrs_num;   /* Multicast mac addresses number */
     257                 :            : 
     258                 :            :         struct iavf_vsi vsi;
     259                 :            :         bool vf_reset;  /* true for VF reset pending, false for no VF reset */
     260                 :            :         uint64_t flags;
     261                 :            : 
     262                 :            :         uint8_t *rss_lut;
     263                 :            :         uint8_t *rss_key;
     264                 :            :         uint64_t rss_hf;
     265                 :            :         uint16_t nb_msix;   /* number of MSI-X interrupts on Rx */
     266                 :            :         uint16_t msix_base; /* msix vector base from */
     267                 :            :         uint16_t max_rss_qregion; /* max RSS queue region supported by PF */
     268                 :            :         struct iavf_qv_map *qv_map; /* queue vector mapping */
     269                 :            :         struct iavf_flow_list flow_list;
     270                 :            :         rte_spinlock_t flow_ops_lock;
     271                 :            :         rte_spinlock_t aq_lock;
     272                 :            :         struct iavf_parser_list rss_parser_list;
     273                 :            :         struct iavf_parser_list dist_parser_list;
     274                 :            :         struct iavf_parser_list ipsec_crypto_parser_list;
     275                 :            : 
     276                 :            :         struct iavf_fdir_info fdir; /* flow director info */
     277                 :            :         /* indicate large VF support enabled or not */
     278                 :            :         bool lv_enabled;
     279                 :            : 
     280                 :            :         struct virtchnl_qos_cap_list *qos_cap;
     281                 :            :         struct iavf_qtc_map *qtc_map;
     282                 :            :         struct iavf_tm_conf tm_conf;
     283                 :            : 
     284                 :            :         struct rte_eth_dev *eth_dev;
     285                 :            : 
     286                 :            :         bool in_reset_recovery;
     287                 :            : 
     288                 :            :         uint32_t ptp_caps;
     289                 :            :         rte_spinlock_t phc_time_aq_lock;
     290                 :            : };
     291                 :            : 
     292                 :            : #define IAVF_MAX_PKT_TYPE 1024
     293                 :            : 
     294                 :            : #define IAVF_MAX_QUEUE_NUM  2048
     295                 :            : 
     296                 :            : enum iavf_proto_xtr_type {
     297                 :            :         IAVF_PROTO_XTR_NONE,
     298                 :            :         IAVF_PROTO_XTR_VLAN,
     299                 :            :         IAVF_PROTO_XTR_IPV4,
     300                 :            :         IAVF_PROTO_XTR_IPV6,
     301                 :            :         IAVF_PROTO_XTR_IPV6_FLOW,
     302                 :            :         IAVF_PROTO_XTR_TCP,
     303                 :            :         IAVF_PROTO_XTR_IP_OFFSET,
     304                 :            :         IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID,
     305                 :            :         IAVF_PROTO_XTR_MAX,
     306                 :            : };
     307                 :            : 
     308                 :            : /**
     309                 :            :  * Cache devargs parse result.
     310                 :            :  */
     311                 :            : struct iavf_devargs {
     312                 :            :         uint8_t proto_xtr_dflt;
     313                 :            :         uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM];
     314                 :            :         uint16_t quanta_size;
     315                 :            :         uint32_t watchdog_period;
     316                 :            :         int auto_reset;
     317                 :            :         int no_poll_on_link_down;
     318                 :            :         uint64_t mbuf_check;
     319                 :            : };
     320                 :            : 
     321                 :            : struct iavf_security_ctx;
     322                 :            : 
     323                 :            : enum iavf_rx_burst_type {
     324                 :            :         IAVF_RX_DEFAULT,
     325                 :            :         IAVF_RX_FLEX_RXD,
     326                 :            :         IAVF_RX_BULK_ALLOC,
     327                 :            :         IAVF_RX_SCATTERED,
     328                 :            :         IAVF_RX_SCATTERED_FLEX_RXD,
     329                 :            :         IAVF_RX_SSE,
     330                 :            :         IAVF_RX_AVX2,
     331                 :            :         IAVF_RX_AVX2_OFFLOAD,
     332                 :            :         IAVF_RX_SSE_FLEX_RXD,
     333                 :            :         IAVF_RX_AVX2_FLEX_RXD,
     334                 :            :         IAVF_RX_AVX2_FLEX_RXD_OFFLOAD,
     335                 :            :         IAVF_RX_SSE_SCATTERED,
     336                 :            :         IAVF_RX_AVX2_SCATTERED,
     337                 :            :         IAVF_RX_AVX2_SCATTERED_OFFLOAD,
     338                 :            :         IAVF_RX_SSE_SCATTERED_FLEX_RXD,
     339                 :            :         IAVF_RX_AVX2_SCATTERED_FLEX_RXD,
     340                 :            :         IAVF_RX_AVX2_SCATTERED_FLEX_RXD_OFFLOAD,
     341                 :            :         IAVF_RX_AVX512,
     342                 :            :         IAVF_RX_AVX512_OFFLOAD,
     343                 :            :         IAVF_RX_AVX512_FLEX_RXD,
     344                 :            :         IAVF_RX_AVX512_FLEX_RXD_OFFLOAD,
     345                 :            :         IAVF_RX_AVX512_SCATTERED,
     346                 :            :         IAVF_RX_AVX512_SCATTERED_OFFLOAD,
     347                 :            :         IAVF_RX_AVX512_SCATTERED_FLEX_RXD,
     348                 :            :         IAVF_RX_AVX512_SCATTERED_FLEX_RXD_OFFLOAD,
     349                 :            : };
     350                 :            : 
     351                 :            : enum iavf_tx_burst_type {
     352                 :            :         IAVF_TX_DEFAULT,
     353                 :            :         IAVF_TX_SSE,
     354                 :            :         IAVF_TX_AVX2,
     355                 :            :         IAVF_TX_AVX2_OFFLOAD,
     356                 :            :         IAVF_TX_AVX512,
     357                 :            :         IAVF_TX_AVX512_OFFLOAD,
     358                 :            :         IAVF_TX_AVX512_CTX,
     359                 :            :         IAVF_TX_AVX512_CTX_OFFLOAD,
     360                 :            : };
     361                 :            : 
     362                 :            : #define IAVF_MBUF_CHECK_F_TX_MBUF        (1ULL << 0)
     363                 :            : #define IAVF_MBUF_CHECK_F_TX_SIZE        (1ULL << 1)
     364                 :            : #define IAVF_MBUF_CHECK_F_TX_SEGMENT     (1ULL << 2)
     365                 :            : #define IAVF_MBUF_CHECK_F_TX_OFFLOAD     (1ULL << 3)
     366                 :            : 
     367                 :            : /* Structure to store private data for each VF instance. */
     368                 :            : struct iavf_adapter {
     369                 :            :         struct iavf_hw hw;
     370                 :            :         struct rte_eth_dev_data *dev_data;
     371                 :            :         struct iavf_info vf;
     372                 :            :         struct iavf_security_ctx *security_ctx;
     373                 :            : 
     374                 :            :         bool rx_bulk_alloc_allowed;
     375                 :            :         /* For vector PMD */
     376                 :            :         bool rx_vec_allowed;
     377                 :            :         bool tx_vec_allowed;
     378                 :            :         alignas(RTE_CACHE_LINE_MIN_SIZE) uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE];
     379                 :            :         bool stopped;
     380                 :            :         bool closed;
     381                 :            :         bool no_poll;
     382                 :            :         enum iavf_rx_burst_type rx_burst_type;
     383                 :            :         enum iavf_tx_burst_type tx_burst_type;
     384                 :            :         uint16_t fdir_ref_cnt;
     385                 :            :         struct iavf_devargs devargs;
     386                 :            : };
     387                 :            : 
     388                 :            : /* IAVF_DEV_PRIVATE_TO */
     389                 :            : #define IAVF_DEV_PRIVATE_TO_ADAPTER(adapter) \
     390                 :            :         ((struct iavf_adapter *)adapter)
     391                 :            : #define IAVF_DEV_PRIVATE_TO_VF(adapter) \
     392                 :            :         (&((struct iavf_adapter *)adapter)->vf)
     393                 :            : #define IAVF_DEV_PRIVATE_TO_HW(adapter) \
     394                 :            :         (&((struct iavf_adapter *)adapter)->hw)
     395                 :            : #define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX(adapter) \
     396                 :            :         (((struct iavf_adapter *)adapter)->security_ctx)
     397                 :            : 
     398                 :            : /* IAVF_VSI_TO */
     399                 :            : #define IAVF_VSI_TO_HW(vsi) \
     400                 :            :         (&(((struct iavf_vsi *)vsi)->adapter->hw))
     401                 :            : #define IAVF_VSI_TO_VF(vsi) \
     402                 :            :         (&(((struct iavf_vsi *)vsi)->adapter->vf))
     403                 :            : 
     404                 :            : static inline void
     405                 :            : iavf_init_adminq_parameter(struct iavf_hw *hw)
     406                 :            : {
     407                 :          0 :         hw->aq.num_arq_entries = IAVF_AQ_LEN;
     408                 :          0 :         hw->aq.num_asq_entries = IAVF_AQ_LEN;
     409                 :          0 :         hw->aq.arq_buf_size = IAVF_AQ_BUF_SZ;
     410                 :          0 :         hw->aq.asq_buf_size = IAVF_AQ_BUF_SZ;
     411                 :            : }
     412                 :            : 
     413                 :            : static inline uint16_t
     414                 :            : iavf_calc_itr_interval(int16_t interval)
     415                 :            : {
     416                 :            :         if (interval < 0 || interval > IAVF_QUEUE_ITR_INTERVAL_MAX)
     417                 :            :                 interval = IAVF_QUEUE_ITR_INTERVAL_DEFAULT;
     418                 :            : 
     419                 :            :         /* Convert to hardware count, as writing each 1 represents 2 us */
     420                 :            :         return interval / 2;
     421                 :            : }
     422                 :            : 
     423                 :            : /* structure used for sending and checking response of virtchnl ops */
     424                 :            : struct iavf_cmd_info {
     425                 :            :         enum virtchnl_ops ops;
     426                 :            :         uint8_t *in_args;       /* buffer for sending */
     427                 :            :         uint32_t in_args_size;  /* buffer size for sending */
     428                 :            :         uint8_t *out_buffer;    /* buffer for response */
     429                 :            :         uint32_t out_size;      /* buffer size for response */
     430                 :            : };
     431                 :            : 
     432                 :            : /* notify current command done. Only call in case execute
     433                 :            :  * _atomic_set_cmd successfully.
     434                 :            :  */
     435                 :            : static inline void
     436                 :            : _notify_cmd(struct iavf_info *vf, int msg_ret)
     437                 :            : {
     438                 :          0 :         vf->cmd_retval = msg_ret;
     439                 :            :         rte_wmb();
     440                 :          0 :         vf->pend_cmd = VIRTCHNL_OP_UNKNOWN;
     441                 :          0 : }
     442                 :            : 
     443                 :            : /* clear current command. Only call in case execute
     444                 :            :  * _atomic_set_cmd successfully.
     445                 :            :  */
     446                 :            : static inline void
     447                 :            : _clear_cmd(struct iavf_info *vf)
     448                 :            : {
     449                 :            :         rte_wmb();
     450                 :          0 :         vf->pend_cmd = VIRTCHNL_OP_UNKNOWN;
     451                 :          0 :         vf->cmd_retval = VIRTCHNL_STATUS_SUCCESS;
     452                 :          0 : }
     453                 :            : 
     454                 :            : /* Check there is pending cmd in execution. If none, set new command. */
     455                 :            : static inline int
     456                 :          0 : _atomic_set_cmd(struct iavf_info *vf, enum virtchnl_ops ops)
     457                 :            : {
     458                 :            :         enum virtchnl_ops op_unk = VIRTCHNL_OP_UNKNOWN;
     459                 :          0 :         int ret = rte_atomic_compare_exchange_strong_explicit(&vf->pend_cmd, &op_unk, ops,
     460                 :            :                         rte_memory_order_acquire, rte_memory_order_acquire);
     461                 :            : 
     462         [ #  # ]:          0 :         if (!ret)
     463                 :          0 :                 PMD_DRV_LOG(ERR, "There is incomplete cmd %d", vf->pend_cmd);
     464                 :            : 
     465                 :          0 :         rte_atomic_store_explicit(&vf->pend_cmd_count, 1, rte_memory_order_relaxed);
     466                 :            : 
     467                 :          0 :         return !ret;
     468                 :            : }
     469                 :            : 
     470                 :            : /* Check there is pending cmd in execution. If none, set new command. */
     471                 :            : static inline int
     472                 :          0 : _atomic_set_async_response_cmd(struct iavf_info *vf, enum virtchnl_ops ops)
     473                 :            : {
     474                 :            :         enum virtchnl_ops op_unk = VIRTCHNL_OP_UNKNOWN;
     475                 :          0 :         int ret = rte_atomic_compare_exchange_strong_explicit(&vf->pend_cmd, &op_unk, ops,
     476                 :            :                         rte_memory_order_acquire, rte_memory_order_acquire);
     477                 :            : 
     478         [ #  # ]:          0 :         if (!ret)
     479                 :          0 :                 PMD_DRV_LOG(ERR, "There is incomplete cmd %d", vf->pend_cmd);
     480                 :            : 
     481                 :          0 :         rte_atomic_store_explicit(&vf->pend_cmd_count, 2, rte_memory_order_relaxed);
     482                 :            : 
     483                 :          0 :         return !ret;
     484                 :            : }
     485                 :            : int iavf_check_api_version(struct iavf_adapter *adapter);
     486                 :            : int iavf_get_vf_resource(struct iavf_adapter *adapter);
     487                 :            : void iavf_dev_event_post(struct rte_eth_dev *dev,
     488                 :            :                 enum rte_eth_event_type event,
     489                 :            :                 void *param, size_t param_alloc_size);
     490                 :            : void iavf_dev_event_handler_fini(void);
     491                 :            : int iavf_dev_event_handler_init(void);
     492                 :            : void iavf_handle_virtchnl_msg(struct rte_eth_dev *dev);
     493                 :            : int iavf_enable_vlan_strip(struct iavf_adapter *adapter);
     494                 :            : int iavf_disable_vlan_strip(struct iavf_adapter *adapter);
     495                 :            : int iavf_switch_queue(struct iavf_adapter *adapter, uint16_t qid,
     496                 :            :                      bool rx, bool on);
     497                 :            : int iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,
     498                 :            :                      bool rx, bool on);
     499                 :            : int iavf_enable_queues(struct iavf_adapter *adapter);
     500                 :            : int iavf_enable_queues_lv(struct iavf_adapter *adapter);
     501                 :            : int iavf_disable_queues(struct iavf_adapter *adapter);
     502                 :            : int iavf_disable_queues_lv(struct iavf_adapter *adapter);
     503                 :            : int iavf_configure_rss_lut(struct iavf_adapter *adapter);
     504                 :            : int iavf_configure_rss_key(struct iavf_adapter *adapter);
     505                 :            : int iavf_configure_queues(struct iavf_adapter *adapter,
     506                 :            :                         uint16_t num_queue_pairs, uint16_t index);
     507                 :            : int iavf_get_supported_rxdid(struct iavf_adapter *adapter);
     508                 :            : int iavf_config_vlan_strip_v2(struct iavf_adapter *adapter, bool enable);
     509                 :            : int iavf_config_vlan_insert_v2(struct iavf_adapter *adapter, bool enable);
     510                 :            : int iavf_add_del_vlan_v2(struct iavf_adapter *adapter, uint16_t vlanid,
     511                 :            :                          bool add);
     512                 :            : int iavf_get_vlan_offload_caps_v2(struct iavf_adapter *adapter);
     513                 :            : int iavf_config_irq_map(struct iavf_adapter *adapter);
     514                 :            : int iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num,
     515                 :            :                         uint16_t index);
     516                 :            : void iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add);
     517                 :            : int iavf_dev_link_update(struct rte_eth_dev *dev,
     518                 :            :                         __rte_unused int wait_to_complete);
     519                 :            : void iavf_dev_alarm_handler(void *param);
     520                 :            : int iavf_query_stats(struct iavf_adapter *adapter,
     521                 :            :                     struct virtchnl_eth_stats **pstats);
     522                 :            : int iavf_config_promisc(struct iavf_adapter *adapter, bool enable_unicast,
     523                 :            :                        bool enable_multicast);
     524                 :            : int iavf_add_del_eth_addr(struct iavf_adapter *adapter,
     525                 :            :                          struct rte_ether_addr *addr, bool add, uint8_t type);
     526                 :            : int iavf_add_del_vlan(struct iavf_adapter *adapter, uint16_t vlanid, bool add);
     527                 :            : int iavf_fdir_add(struct iavf_adapter *adapter, struct iavf_fdir_conf *filter);
     528                 :            : int iavf_fdir_del(struct iavf_adapter *adapter, struct iavf_fdir_conf *filter);
     529                 :            : int iavf_fdir_check(struct iavf_adapter *adapter,
     530                 :            :                 struct iavf_fdir_conf *filter);
     531                 :            : int iavf_add_del_rss_cfg(struct iavf_adapter *adapter,
     532                 :            :                          struct virtchnl_rss_cfg *rss_cfg, bool add);
     533                 :            : int iavf_get_hena_caps(struct iavf_adapter *adapter, uint64_t *caps);
     534                 :            : int iavf_set_hena(struct iavf_adapter *adapter, uint64_t hena);
     535                 :            : int iavf_rss_hash_set(struct iavf_adapter *ad, uint64_t rss_hf, bool add);
     536                 :            : int iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,
     537                 :            :                         struct rte_ether_addr *mc_addrs,
     538                 :            :                         uint32_t mc_addrs_num, bool add);
     539                 :            : int iavf_request_queues(struct rte_eth_dev *dev, uint16_t num);
     540                 :            : int iavf_get_max_rss_queue_region(struct iavf_adapter *adapter);
     541                 :            : int iavf_get_qos_cap(struct iavf_adapter *adapter);
     542                 :            : int iavf_set_q_bw(struct rte_eth_dev *dev,
     543                 :            :                   struct virtchnl_queues_bw_cfg *q_bw, uint16_t size);
     544                 :            : int iavf_set_q_tc_map(struct rte_eth_dev *dev,
     545                 :            :                         struct virtchnl_queue_tc_mapping *q_tc_mapping,
     546                 :            :                         uint16_t size);
     547                 :            : int iavf_set_vf_quanta_size(struct iavf_adapter *adapter, u16 start_queue_id,
     548                 :            :                             u16 num_queues);
     549                 :            : void iavf_tm_conf_init(struct rte_eth_dev *dev);
     550                 :            : void iavf_tm_conf_uninit(struct rte_eth_dev *dev);
     551                 :            : int iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
     552                 :            :                 uint8_t *msg, size_t msg_len,
     553                 :            :                 uint8_t *resp_msg, size_t resp_msg_len);
     554                 :            : extern const struct rte_tm_ops iavf_tm_ops;
     555                 :            : int iavf_get_ptp_cap(struct iavf_adapter *adapter);
     556                 :            : int iavf_get_phc_time(struct iavf_rx_queue *rxq);
     557                 :            : int iavf_flow_sub(struct iavf_adapter *adapter,
     558                 :            :                   struct iavf_fsub_conf *filter);
     559                 :            : int iavf_flow_unsub(struct iavf_adapter *adapter,
     560                 :            :                     struct iavf_fsub_conf *filter);
     561                 :            : int iavf_flow_sub_check(struct iavf_adapter *adapter,
     562                 :            :                         struct iavf_fsub_conf *filter);
     563                 :            : void iavf_dev_watchdog_enable(struct iavf_adapter *adapter);
     564                 :            : void iavf_dev_watchdog_disable(struct iavf_adapter *adapter);
     565                 :            : void iavf_handle_hw_reset(struct rte_eth_dev *dev);
     566                 :            : void iavf_set_no_poll(struct iavf_adapter *adapter, bool link_change);
     567                 :            : #endif /* _IAVF_ETHDEV_H_ */

Generated by: LCOV version 1.14