LCOV - code coverage report
Current view: top level - drivers/net/vmxnet3 - vmxnet3_ethdev.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 5 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2010-2014 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _VMXNET3_ETHDEV_H_
       6                 :            : #define _VMXNET3_ETHDEV_H_
       7                 :            : 
       8                 :            : #include <rte_io.h>
       9                 :            : #include <rte_mbuf_dyn.h>
      10                 :            : 
      11                 :            : #define VMXNET3_MAX_MAC_ADDRS 1
      12                 :            : 
      13                 :            : /* UPT feature to negotiate */
      14                 :            : #define VMXNET3_F_RXCSUM      0x0001
      15                 :            : #define VMXNET3_F_RSS         0x0002
      16                 :            : #define VMXNET3_F_RXVLAN      0x0004
      17                 :            : #define VMXNET3_F_LRO         0x0008
      18                 :            : 
      19                 :            : /* Hash Types supported by device */
      20                 :            : #define VMXNET3_RSS_HASH_TYPE_NONE      0x0
      21                 :            : #define VMXNET3_RSS_HASH_TYPE_IPV4      0x01
      22                 :            : #define VMXNET3_RSS_HASH_TYPE_TCP_IPV4  0x02
      23                 :            : #define VMXNET3_RSS_HASH_TYPE_IPV6      0x04
      24                 :            : #define VMXNET3_RSS_HASH_TYPE_TCP_IPV6  0x08
      25                 :            : 
      26                 :            : #define VMXNET3_RSS_HASH_FUNC_NONE      0x0
      27                 :            : #define VMXNET3_RSS_HASH_FUNC_TOEPLITZ  0x01
      28                 :            : 
      29                 :            : #define VMXNET3_RSS_MAX_KEY_SIZE        40
      30                 :            : #define VMXNET3_RSS_MAX_IND_TABLE_SIZE  128
      31                 :            : #define VMXNET3_MAX_MSIX_VECT (VMXNET3_MAX_TX_QUEUES + \
      32                 :            :                                 VMXNET3_MAX_RX_QUEUES + 1)
      33                 :            : 
      34                 :            : #define VMXNET3_RSS_OFFLOAD_ALL ( \
      35                 :            :         RTE_ETH_RSS_IPV4 | \
      36                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
      37                 :            :         RTE_ETH_RSS_IPV6 | \
      38                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_TCP)
      39                 :            : 
      40                 :            : #define VMXNET3_V4_RSS_MASK ( \
      41                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
      42                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_UDP)
      43                 :            : 
      44                 :            : #define VMXNET3_MANDATORY_V4_RSS ( \
      45                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
      46                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_TCP)
      47                 :            : 
      48                 :            : /* RSS configuration structure - shared with device through GPA */
      49                 :            : typedef struct VMXNET3_RSSConf {
      50                 :            :         uint16_t   hashType;
      51                 :            :         uint16_t   hashFunc;
      52                 :            :         uint16_t   hashKeySize;
      53                 :            :         uint16_t   indTableSize;
      54                 :            :         uint8_t    hashKey[VMXNET3_RSS_MAX_KEY_SIZE];
      55                 :            :         /*
      56                 :            :          * indTable is only element that can be changed without
      57                 :            :          * device quiesce-reset-update-activation cycle
      58                 :            :          */
      59                 :            :         uint8_t    indTable[VMXNET3_RSS_MAX_IND_TABLE_SIZE];
      60                 :            : } VMXNET3_RSSConf;
      61                 :            : 
      62                 :            : typedef struct vmxnet3_mf_table {
      63                 :            :         void          *mfTableBase; /* Multicast addresses list */
      64                 :            :         uint64_t      mfTablePA;    /* Physical address of the list */
      65                 :            :         uint16_t      num_addrs;    /* number of multicast addrs */
      66                 :            : } vmxnet3_mf_table_t;
      67                 :            : 
      68                 :            : struct vmxnet3_intr {
      69                 :            :         enum vmxnet3_intr_mask_mode mask_mode;
      70                 :            :         enum vmxnet3_intr_type      type; /* MSI-X, MSI, or INTx? */
      71                 :            :         uint8_t num_intrs;                /* # of intr vectors */
      72                 :            :         uint8_t event_intr_idx;           /* idx of the intr vector for event */
      73                 :            :         uint8_t mod_levels[VMXNET3_EXT_MAX_INTRS]; /* moderation level */
      74                 :            :         bool lsc_only;                    /* no Rx queue interrupt */
      75                 :            : };
      76                 :            : 
      77                 :            : struct vmxnet3_hw {
      78                 :            :         uint8_t *hw_addr0;      /* BAR0: PT-Passthrough Regs    */
      79                 :            :         uint8_t *hw_addr1;      /* BAR1: VD-Virtual Device Regs */
      80                 :            :         /* BAR2: MSI-X Regs */
      81                 :            :         /* BAR3: Port IO    */
      82                 :            :         void *back;
      83                 :            : 
      84                 :            :         uint16_t device_id;
      85                 :            :         uint16_t vendor_id;
      86                 :            :         uint16_t subsystem_device_id;
      87                 :            :         uint16_t subsystem_vendor_id;
      88                 :            :         bool adapter_stopped;
      89                 :            : 
      90                 :            :         uint8_t perm_addr[RTE_ETHER_ADDR_LEN];
      91                 :            :         uint8_t num_tx_queues;
      92                 :            :         uint8_t num_rx_queues;
      93                 :            :         uint8_t bufs_per_pkt;
      94                 :            : 
      95                 :            :         uint8_t version;
      96                 :            : 
      97                 :            :         uint16_t txdata_desc_size; /* tx data ring buffer size */
      98                 :            :         uint16_t rxdata_desc_size; /* rx data ring buffer size */
      99                 :            :         uint16_t rxdata_buf_size; /* rx data buffer size */
     100                 :            : 
     101                 :            :         uint8_t num_intrs;
     102                 :            : 
     103                 :            :         Vmxnet3_TxQueueDesc   *tqd_start;       /* start address of all tx queue desc */
     104                 :            :         Vmxnet3_RxQueueDesc   *rqd_start;       /* start address of all rx queue desc */
     105                 :            : 
     106                 :            :         Vmxnet3_DriverShared  *shared;
     107                 :            :         uint64_t              sharedPA;
     108                 :            : 
     109                 :            :         uint64_t              queueDescPA;
     110                 :            :         uint16_t              queue_desc_len;
     111                 :            :         uint16_t              mtu;
     112                 :            :         bool                  queuesExtEnabled;
     113                 :            : 
     114                 :            :         VMXNET3_RSSConf       *rss_conf;
     115                 :            :         uint64_t              rss_confPA;
     116                 :            :         vmxnet3_mf_table_t    *mf_table;
     117                 :            :         uint32_t              shadow_vfta[VMXNET3_VFT_SIZE];
     118                 :            :         struct vmxnet3_intr   intr;
     119                 :            :         Vmxnet3_MemRegs       *memRegs;
     120                 :            :         uint64_t              memRegsPA;
     121                 :            : #define VMXNET3_VFT_TABLE_SIZE     (VMXNET3_VFT_SIZE * sizeof(uint32_t))
     122                 :            :         UPT1_TxStats          saved_tx_stats[VMXNET3_EXT_MAX_TX_QUEUES];
     123                 :            :         UPT1_RxStats          saved_rx_stats[VMXNET3_EXT_MAX_RX_QUEUES];
     124                 :            :         UPT1_TxStats          snapshot_tx_stats[VMXNET3_EXT_MAX_TX_QUEUES];
     125                 :            :         UPT1_RxStats          snapshot_rx_stats[VMXNET3_EXT_MAX_RX_QUEUES];
     126                 :            :         uint16_t              tx_prod_offset;
     127                 :            :         uint16_t              rx_prod_offset[2];
     128                 :            :         /* device capability bit map */
     129                 :            :         uint32_t              DCR_capabilities[8];
     130                 :            :         /* pass-through capability bit map */
     131                 :            :         uint32_t              PTCR_capabilities[8];
     132                 :            :         /* max number of capabilities */
     133                 :            :         uint32_t              max_capabilities[8];
     134                 :            :         /* used device capability bit map */
     135                 :            :         uint32_t              used_DCR_capabilities[8];
     136                 :            :         /* used pass-through capability bit map */
     137                 :            :         uint32_t              used_PTCR_capabilities[8];
     138                 :            :         bool                  uptv2_enabled;
     139                 :            : };
     140                 :            : 
     141                 :            : #define VMXNET3_REV_7           6               /* Vmxnet3 Rev. 7 */
     142                 :            : #define VMXNET3_REV_6           5               /* Vmxnet3 Rev. 6 */
     143                 :            : #define VMXNET3_REV_5           4               /* Vmxnet3 Rev. 5 */
     144                 :            : #define VMXNET3_REV_4           3               /* Vmxnet3 Rev. 4 */
     145                 :            : #define VMXNET3_REV_3           2               /* Vmxnet3 Rev. 3 */
     146                 :            : #define VMXNET3_REV_2           1               /* Vmxnet3 Rev. 2 */
     147                 :            : #define VMXNET3_REV_1           0               /* Vmxnet3 Rev. 1 */
     148                 :            : 
     149                 :            : #define VMXNET3_VERSION_GE_7(hw) ((hw)->version >= VMXNET3_REV_7 + 1)
     150                 :            : #define VMXNET3_VERSION_GE_6(hw) ((hw)->version >= VMXNET3_REV_6 + 1)
     151                 :            : #define VMXNET3_VERSION_GE_5(hw) ((hw)->version >= VMXNET3_REV_5 + 1)
     152                 :            : #define VMXNET3_VERSION_GE_4(hw) ((hw)->version >= VMXNET3_REV_4 + 1)
     153                 :            : #define VMXNET3_VERSION_GE_3(hw) ((hw)->version >= VMXNET3_REV_3 + 1)
     154                 :            : #define VMXNET3_VERSION_GE_2(hw) ((hw)->version >= VMXNET3_REV_2 + 1)
     155                 :            : 
     156                 :            : #define VMXNET3_GET_ADDR_LO(reg)   ((uint32_t)(reg))
     157                 :            : #define VMXNET3_GET_ADDR_HI(reg)   ((uint32_t)(((uint64_t)(reg)) >> 32))
     158                 :            : 
     159                 :            : /* Config space read/writes */
     160                 :            : 
     161                 :            : #define VMXNET3_PCI_REG(reg) rte_read32(reg)
     162                 :            : 
     163                 :            : static inline uint32_t
     164                 :            : vmxnet3_read_addr(volatile void *addr)
     165                 :            : {
     166                 :            :         return VMXNET3_PCI_REG(addr);
     167                 :            : }
     168                 :            : 
     169                 :            : #define VMXNET3_PCI_REG_WRITE(reg, value) rte_write32((value), (reg))
     170                 :            : 
     171                 :            : #define VMXNET3_PCI_BAR0_REG_ADDR(hw, reg) \
     172                 :            :         ((volatile uint32_t *)((char *)(hw)->hw_addr0 + (reg)))
     173                 :            : #define VMXNET3_READ_BAR0_REG(hw, reg) \
     174                 :            :         vmxnet3_read_addr(VMXNET3_PCI_BAR0_REG_ADDR((hw), (reg)))
     175                 :            : #define VMXNET3_WRITE_BAR0_REG(hw, reg, value) \
     176                 :            :         VMXNET3_PCI_REG_WRITE(VMXNET3_PCI_BAR0_REG_ADDR((hw), (reg)), (value))
     177                 :            : 
     178                 :            : #define VMXNET3_PCI_BAR1_REG_ADDR(hw, reg) \
     179                 :            :         ((volatile uint32_t *)((char *)(hw)->hw_addr1 + (reg)))
     180                 :            : #define VMXNET3_READ_BAR1_REG(hw, reg) \
     181                 :            :         vmxnet3_read_addr(VMXNET3_PCI_BAR1_REG_ADDR((hw), (reg)))
     182                 :            : #define VMXNET3_WRITE_BAR1_REG(hw, reg, value) \
     183                 :            :         VMXNET3_PCI_REG_WRITE(VMXNET3_PCI_BAR1_REG_ADDR((hw), (reg)), (value))
     184                 :            : 
     185                 :            : static inline uint8_t
     186                 :            : vmxnet3_get_ring_idx(struct vmxnet3_hw *hw, uint32_t rq_id)
     187                 :            : {
     188                 :          0 :         return (rq_id >= hw->num_rx_queues &&
     189   [ #  #  #  # ]:          0 :                 rq_id < 2U * hw->num_rx_queues) ? 1 : 0;
     190                 :            : }
     191                 :            : 
     192                 :            : static inline bool
     193                 :            : vmxnet3_rx_data_ring(struct vmxnet3_hw *hw, uint32_t rq_id)
     194                 :            : {
     195   [ #  #  #  # ]:          0 :         return (rq_id >= 2U * hw->num_rx_queues &&
     196         [ #  # ]:          0 :                 rq_id < 3U * hw->num_rx_queues);
     197                 :            : }
     198                 :            : 
     199                 :            : /*
     200                 :            :  * RX/TX function prototypes
     201                 :            :  */
     202                 :            : 
     203                 :            : void vmxnet3_dev_clear_queues(struct rte_eth_dev *dev);
     204                 :            : 
     205                 :            : void vmxnet3_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
     206                 :            : void vmxnet3_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
     207                 :            : 
     208                 :            : int vmxnet3_v4_rss_configure(struct rte_eth_dev *dev);
     209                 :            : 
     210                 :            : int  vmxnet3_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
     211                 :            :                                 uint16_t nb_rx_desc, unsigned int socket_id,
     212                 :            :                                 const struct rte_eth_rxconf *rx_conf,
     213                 :            :                                 struct rte_mempool *mb_pool);
     214                 :            : 
     215                 :            : uint32_t vmxnet3_dev_rx_queue_count(void *rx_queue);
     216                 :            : 
     217                 :            : int  vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
     218                 :            :                                 uint16_t nb_tx_desc, unsigned int socket_id,
     219                 :            :                                 const struct rte_eth_txconf *tx_conf);
     220                 :            : 
     221                 :            : int vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev);
     222                 :            : 
     223                 :            : int vmxnet3_rss_configure(struct rte_eth_dev *dev);
     224                 :            : 
     225                 :            : uint16_t vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
     226                 :            :                            uint16_t nb_pkts);
     227                 :            : uint16_t vmxnet3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
     228                 :            :                            uint16_t nb_pkts);
     229                 :            : uint16_t vmxnet3_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
     230                 :            :                         uint16_t nb_pkts);
     231                 :            : 
     232                 :            : #define VMXNET3_SEGS_DYNFIELD_NAME "rte_net_vmxnet3_dynfield_segs"
     233                 :            : typedef uint8_t vmxnet3_segs_dynfield_t;
     234                 :            : extern int vmxnet3_segs_dynfield_offset;
     235                 :            : 
     236                 :            : static inline vmxnet3_segs_dynfield_t *
     237                 :            : vmxnet3_segs_dynfield(struct rte_mbuf *mbuf)
     238                 :            : {
     239         [ #  # ]:          0 :         return RTE_MBUF_DYNFIELD(mbuf, \
     240                 :            :                 vmxnet3_segs_dynfield_offset, vmxnet3_segs_dynfield_t *);
     241                 :            : }
     242                 :            : 
     243                 :            : #endif /* _VMXNET3_ETHDEV_H_ */

Generated by: LCOV version 1.14