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

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
       3                 :            :  * Copyright(c) 2010-2017 Intel Corporation
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef _NGBE_ETHDEV_H_
       7                 :            : #define _NGBE_ETHDEV_H_
       8                 :            : 
       9                 :            : #include "ngbe_ptypes.h"
      10                 :            : #include <rte_time.h>
      11                 :            : #include <rte_ethdev.h>
      12                 :            : #include <rte_ethdev_core.h>
      13                 :            : 
      14                 :            : /* need update link, bit flag */
      15                 :            : #define NGBE_FLAG_NEED_LINK_UPDATE  ((uint32_t)(1 << 0))
      16                 :            : #define NGBE_FLAG_MAILBOX           ((uint32_t)(1 << 1))
      17                 :            : #define NGBE_FLAG_PHY_INTERRUPT     ((uint32_t)(1 << 2))
      18                 :            : #define NGBE_FLAG_MACSEC            ((uint32_t)(1 << 3))
      19                 :            : #define NGBE_FLAG_NEED_LINK_CONFIG  ((uint32_t)(1 << 4))
      20                 :            : #define NGBE_FLAG_OVERHEAT          ((uint32_t)(1 << 5))
      21                 :            : 
      22                 :            : #define NGBE_VFTA_SIZE 128
      23                 :            : #define NGBE_HKEY_MAX_INDEX 10
      24                 :            : /*Default value of Max Rx Queue*/
      25                 :            : #define NGBE_MAX_RX_QUEUE_NUM   8
      26                 :            : 
      27                 :            : #ifndef NBBY
      28                 :            : #define NBBY    8       /* number of bits in a byte */
      29                 :            : #endif
      30                 :            : #define NGBE_HWSTRIP_BITMAP_SIZE \
      31                 :            :         (NGBE_MAX_RX_QUEUE_NUM / (sizeof(uint32_t) * NBBY))
      32                 :            : 
      33                 :            : #define NGBE_QUEUE_ITR_INTERVAL_DEFAULT 500 /* 500us */
      34                 :            : 
      35                 :            : #define NGBE_MAX_MTU            9414
      36                 :            : /* The overhead from MTU to max frame size. */
      37                 :            : #define NGBE_ETH_OVERHEAD (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
      38                 :            : 
      39                 :            : #define NGBE_RSS_OFFLOAD_ALL ( \
      40                 :            :         RTE_ETH_RSS_IPV4 | \
      41                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
      42                 :            :         RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
      43                 :            :         RTE_ETH_RSS_IPV6 | \
      44                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
      45                 :            :         RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
      46                 :            :         RTE_ETH_RSS_IPV6_EX | \
      47                 :            :         RTE_ETH_RSS_IPV6_TCP_EX | \
      48                 :            :         RTE_ETH_RSS_IPV6_UDP_EX)
      49                 :            : 
      50                 :            : #define NGBE_MISC_VEC_ID               RTE_INTR_VEC_ZERO_OFFSET
      51                 :            : #define NGBE_RX_VEC_START              RTE_INTR_VEC_RXTX_OFFSET
      52                 :            : 
      53                 :            : /* structure for interrupt relative data */
      54                 :            : struct ngbe_interrupt {
      55                 :            :         uint32_t flags;
      56                 :            :         uint32_t mask_misc;
      57                 :            :         uint32_t mask_misc_orig; /* save mask during delayed handler */
      58                 :            :         uint64_t mask;
      59                 :            :         uint64_t mask_orig; /* save mask during delayed handler */
      60                 :            : };
      61                 :            : 
      62                 :            : #define NGBE_NB_STAT_MAPPING  32
      63                 :            : #define NB_QMAP_FIELDS_PER_QSM_REG 4
      64                 :            : #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
      65                 :            : struct ngbe_stat_mappings {
      66                 :            :         uint32_t tqsm[NGBE_NB_STAT_MAPPING];
      67                 :            :         uint32_t rqsm[NGBE_NB_STAT_MAPPING];
      68                 :            : };
      69                 :            : 
      70                 :            : struct ngbe_vfta {
      71                 :            :         uint32_t vfta[NGBE_VFTA_SIZE];
      72                 :            : };
      73                 :            : 
      74                 :            : struct ngbe_hwstrip {
      75                 :            :         uint32_t bitmap[NGBE_HWSTRIP_BITMAP_SIZE];
      76                 :            : };
      77                 :            : 
      78                 :            : /**
      79                 :            :  * Response sent back to ngbe driver from user app after callback
      80                 :            :  */
      81                 :            : enum ngbe_mb_event_rsp {
      82                 :            :         NGBE_MB_EVENT_NOOP_ACK,  /**< skip mbox request and ACK */
      83                 :            :         NGBE_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
      84                 :            :         NGBE_MB_EVENT_PROCEED,  /**< proceed with mbox request  */
      85                 :            :         NGBE_MB_EVENT_MAX       /**< max value of this enum */
      86                 :            : };
      87                 :            : 
      88                 :            : /**
      89                 :            :  * Data sent to the user application when the callback is executed.
      90                 :            :  */
      91                 :            : struct ngbe_mb_event_param {
      92                 :            :         uint16_t vfid;     /**< Virtual Function number */
      93                 :            :         uint16_t msg_type; /**< VF to PF message type, defined in ngbe_mbx.h */
      94                 :            :         uint16_t retval;   /**< return value */
      95                 :            :         void *msg;         /**< pointer to message */
      96                 :            : };
      97                 :            : 
      98                 :            : /*
      99                 :            :  * VF data which used by PF host only
     100                 :            :  */
     101                 :            : #define NGBE_MAX_VF_MC_ENTRIES      30
     102                 :            : 
     103                 :            : struct ngbe_uta_info {
     104                 :            :         uint8_t  uc_filter_type;
     105                 :            :         uint16_t uta_in_use;
     106                 :            :         uint32_t uta_shadow[NGBE_MAX_UTA];
     107                 :            : };
     108                 :            : 
     109                 :            : struct ngbe_vf_info {
     110                 :            :         uint8_t vf_mac_addresses[RTE_ETHER_ADDR_LEN];
     111                 :            :         uint16_t vf_mc_hashes[NGBE_MAX_VF_MC_ENTRIES];
     112                 :            :         uint16_t num_vf_mc_hashes;
     113                 :            :         bool clear_to_send;
     114                 :            :         uint16_t vlan_count;
     115                 :            :         uint8_t api_version;
     116                 :            :         uint16_t switch_domain_id;
     117                 :            :         uint16_t xcast_mode;
     118                 :            :         uint16_t mac_count;
     119                 :            : };
     120                 :            : 
     121                 :            : /*
     122                 :            :  * Structure to store private data for each driver instance (for each port).
     123                 :            :  */
     124                 :            : struct ngbe_adapter {
     125                 :            :         struct ngbe_hw             hw;
     126                 :            :         struct ngbe_hw_stats       stats;
     127                 :            :         struct ngbe_interrupt      intr;
     128                 :            :         struct ngbe_stat_mappings  stat_mappings;
     129                 :            :         struct ngbe_vfta           shadow_vfta;
     130                 :            :         struct ngbe_hwstrip        hwstrip;
     131                 :            :         struct ngbe_vf_info        *vfdata;
     132                 :            :         struct ngbe_uta_info       uta_info;
     133                 :            :         bool                       rx_bulk_alloc_allowed;
     134                 :            :         bool                       rx_vec_allowed;
     135                 :            :         struct rte_timecounter     systime_tc;
     136                 :            :         struct rte_timecounter     rx_tstamp_tc;
     137                 :            :         struct rte_timecounter     tx_tstamp_tc;
     138                 :            : 
     139                 :            :         /* For RSS reta table update */
     140                 :            :         uint8_t rss_reta_updated;
     141                 :            : };
     142                 :            : 
     143                 :            : static inline struct ngbe_adapter *
     144                 :            : ngbe_dev_adapter(struct rte_eth_dev *dev)
     145                 :            : {
     146   [ #  #  #  #  :          0 :         struct ngbe_adapter *ad = dev->data->dev_private;
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
     147                 :            : 
     148                 :            :         return ad;
     149                 :            : }
     150                 :            : 
     151                 :            : static inline struct ngbe_hw *
     152                 :            : ngbe_dev_hw(struct rte_eth_dev *dev)
     153                 :            : {
     154                 :            :         struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
     155   [ #  #  #  #  :          0 :         struct ngbe_hw *hw = &ad->hw;
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
     156                 :            : 
     157                 :            :         return hw;
     158                 :            : }
     159                 :            : 
     160                 :            : #define NGBE_DEV_STATS(dev) \
     161                 :            :         (&((struct ngbe_adapter *)(dev)->data->dev_private)->stats)
     162                 :            : 
     163                 :            : static inline struct ngbe_interrupt *
     164                 :            : ngbe_dev_intr(struct rte_eth_dev *dev)
     165                 :            : {
     166                 :            :         struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
     167                 :            :         struct ngbe_interrupt *intr = &ad->intr;
     168                 :            : 
     169                 :            :         return intr;
     170                 :            : }
     171                 :            : 
     172                 :            : #define NGBE_DEV_STAT_MAPPINGS(dev) \
     173                 :            :         (&((struct ngbe_adapter *)(dev)->data->dev_private)->stat_mappings)
     174                 :            : 
     175                 :            : #define NGBE_DEV_VFTA(dev) \
     176                 :            :         (&((struct ngbe_adapter *)(dev)->data->dev_private)->shadow_vfta)
     177                 :            : 
     178                 :            : #define NGBE_DEV_HWSTRIP(dev) \
     179                 :            :         (&((struct ngbe_adapter *)(dev)->data->dev_private)->hwstrip)
     180                 :            : 
     181                 :            : #define NGBE_DEV_VFDATA(dev) \
     182                 :            :         (&((struct ngbe_adapter *)(dev)->data->dev_private)->vfdata)
     183                 :            : 
     184                 :            : #define NGBE_DEV_UTA_INFO(dev) \
     185                 :            :         (&((struct ngbe_adapter *)(dev)->data->dev_private)->uta_info)
     186                 :            : 
     187                 :            : /*
     188                 :            :  * Rx/Tx function prototypes
     189                 :            :  */
     190                 :            : void ngbe_dev_clear_queues(struct rte_eth_dev *dev);
     191                 :            : 
     192                 :            : void ngbe_dev_free_queues(struct rte_eth_dev *dev);
     193                 :            : 
     194                 :            : void ngbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
     195                 :            : 
     196                 :            : void ngbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
     197                 :            : 
     198                 :            : int  ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
     199                 :            :                 uint16_t nb_rx_desc, unsigned int socket_id,
     200                 :            :                 const struct rte_eth_rxconf *rx_conf,
     201                 :            :                 struct rte_mempool *mb_pool);
     202                 :            : 
     203                 :            : int  ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
     204                 :            :                 uint16_t nb_tx_desc, unsigned int socket_id,
     205                 :            :                 const struct rte_eth_txconf *tx_conf);
     206                 :            : 
     207                 :            : uint32_t ngbe_dev_rx_queue_count(void *rx_queue);
     208                 :            : 
     209                 :            : int ngbe_dev_rx_descriptor_status(void *rx_queue, uint16_t offset);
     210                 :            : int ngbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset);
     211                 :            : 
     212                 :            : int ngbe_dev_rx_init(struct rte_eth_dev *dev);
     213                 :            : 
     214                 :            : void ngbe_dev_tx_init(struct rte_eth_dev *dev);
     215                 :            : 
     216                 :            : int ngbe_dev_rxtx_start(struct rte_eth_dev *dev);
     217                 :            : 
     218                 :            : void ngbe_dev_save_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
     219                 :            : void ngbe_dev_store_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
     220                 :            : void ngbe_dev_save_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
     221                 :            : void ngbe_dev_store_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
     222                 :            : 
     223                 :            : int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
     224                 :            : 
     225                 :            : int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
     226                 :            : 
     227                 :            : int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
     228                 :            : 
     229                 :            : int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
     230                 :            : 
     231                 :            : void ngbe_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
     232                 :            :         struct rte_eth_rxq_info *qinfo);
     233                 :            : 
     234                 :            : void ngbe_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
     235                 :            :         struct rte_eth_txq_info *qinfo);
     236                 :            : 
     237                 :            : int
     238                 :            : ngbe_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
     239                 :            :                       struct rte_eth_burst_mode *mode);
     240                 :            : int
     241                 :            : ngbe_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
     242                 :            :                       struct rte_eth_burst_mode *mode);
     243                 :            : 
     244                 :            : uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
     245                 :            :                 uint16_t nb_pkts);
     246                 :            : 
     247                 :            : uint16_t ngbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
     248                 :            :                                     uint16_t nb_pkts);
     249                 :            : 
     250                 :            : uint16_t ngbe_recv_pkts_sc_single_alloc(void *rx_queue,
     251                 :            :                 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
     252                 :            : uint16_t ngbe_recv_pkts_sc_bulk_alloc(void *rx_queue,
     253                 :            :                 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
     254                 :            : 
     255                 :            : uint16_t ngbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
     256                 :            :                 uint16_t nb_pkts);
     257                 :            : 
     258                 :            : uint16_t ngbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
     259                 :            :                 uint16_t nb_pkts);
     260                 :            : 
     261                 :            : uint16_t ngbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
     262                 :            :                 uint16_t nb_pkts);
     263                 :            : 
     264                 :            : int ngbe_dev_rss_hash_update(struct rte_eth_dev *dev,
     265                 :            :                               struct rte_eth_rss_conf *rss_conf);
     266                 :            : 
     267                 :            : int ngbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
     268                 :            :                                 struct rte_eth_rss_conf *rss_conf);
     269                 :            : 
     270                 :            : void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
     271                 :            :                                uint8_t queue, uint8_t msix_vector);
     272                 :            : 
     273                 :            : void ngbe_configure_port(struct rte_eth_dev *dev);
     274                 :            : 
     275                 :            : int
     276                 :            : ngbe_dev_link_update_share(struct rte_eth_dev *dev,
     277                 :            :                 int wait_to_complete);
     278                 :            : 
     279                 :            : /*
     280                 :            :  * misc function prototypes
     281                 :            :  */
     282                 :            : void ngbe_vlan_hw_filter_enable(struct rte_eth_dev *dev);
     283                 :            : 
     284                 :            : void ngbe_vlan_hw_filter_disable(struct rte_eth_dev *dev);
     285                 :            : 
     286                 :            : void ngbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
     287                 :            : 
     288                 :            : int ngbe_pf_host_init(struct rte_eth_dev *eth_dev);
     289                 :            : 
     290                 :            : void ngbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
     291                 :            : 
     292                 :            : void ngbe_pf_mbx_process(struct rte_eth_dev *eth_dev);
     293                 :            : 
     294                 :            : int ngbe_pf_host_configure(struct rte_eth_dev *eth_dev);
     295                 :            : 
     296                 :            : /* High threshold controlling when to start sending XOFF frames. */
     297                 :            : #define NGBE_FC_XOFF_HITH              128 /*KB*/
     298                 :            : /* Low threshold controlling when to start sending XON frames. */
     299                 :            : #define NGBE_FC_XON_LOTH               64 /*KB*/
     300                 :            : 
     301                 :            : /* Timer value included in XOFF frames. */
     302                 :            : #define NGBE_FC_PAUSE_TIME 0x680
     303                 :            : 
     304                 :            : #define NGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
     305                 :            : #define NGBE_LINK_UP_CHECK_TIMEOUT   1000 /* ms */
     306                 :            : #define NGBE_VMDQ_NUM_UC_MAC         4096 /* Maximum nb. of UC MAC addr. */
     307                 :            : 
     308                 :            : /*
     309                 :            :  *  Default values for Rx/Tx configuration
     310                 :            :  */
     311                 :            : #define NGBE_DEFAULT_RX_FREE_THRESH  32
     312                 :            : #define NGBE_DEFAULT_RX_PTHRESH      8
     313                 :            : #define NGBE_DEFAULT_RX_HTHRESH      8
     314                 :            : #define NGBE_DEFAULT_RX_WTHRESH      0
     315                 :            : 
     316                 :            : #define NGBE_DEFAULT_TX_FREE_THRESH  32
     317                 :            : #define NGBE_DEFAULT_TX_PTHRESH      32
     318                 :            : #define NGBE_DEFAULT_TX_HTHRESH      0
     319                 :            : #define NGBE_DEFAULT_TX_WTHRESH      0
     320                 :            : 
     321                 :            : /* Additional timesync values. */
     322                 :            : #define NGBE_INCVAL_1GB         0x2000000 /* all speed is same in Emerald */
     323                 :            : #define NGBE_INCVAL_SHIFT_1GB   22 /* all speed is same in Emerald */
     324                 :            : 
     325                 :            : #define NGBE_CYCLECOUNTER_MASK   0xffffffffffffffffULL
     326                 :            : 
     327                 :            : /* store statistics names and its offset in stats structure */
     328                 :            : struct rte_ngbe_xstats_name_off {
     329                 :            :         char name[RTE_ETH_XSTATS_NAME_SIZE];
     330                 :            :         unsigned int offset;
     331                 :            : };
     332                 :            : 
     333                 :            : const uint32_t *ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev,
     334                 :            :                                               size_t *no_of_elements);
     335                 :            : int ngbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
     336                 :            :                                       struct rte_ether_addr *mc_addr_set,
     337                 :            :                                       uint32_t nb_mc_addr);
     338                 :            : int ngbe_dev_rss_reta_update(struct rte_eth_dev *dev,
     339                 :            :                         struct rte_eth_rss_reta_entry64 *reta_conf,
     340                 :            :                         uint16_t reta_size);
     341                 :            : int ngbe_dev_rss_reta_query(struct rte_eth_dev *dev,
     342                 :            :                         struct rte_eth_rss_reta_entry64 *reta_conf,
     343                 :            :                         uint16_t reta_size);
     344                 :            : void ngbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
     345                 :            :                 uint16_t queue, bool on);
     346                 :            : void ngbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev,
     347                 :            :                                                   int mask);
     348                 :            : void ngbe_read_stats_registers(struct ngbe_hw *hw,
     349                 :            :                            struct ngbe_hw_stats *hw_stats);
     350                 :            : 
     351                 :            : #endif /* _NGBE_ETHDEV_H_ */

Generated by: LCOV version 1.14