LCOV - code coverage report
Current view: top level - drivers/net/nfp - nfp_net_common.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 2 0.0 %
Date: 2024-01-22 16:13:49 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2014-2018 Netronome Systems, Inc.
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef __NFP_NET_COMMON_H__
       7                 :            : #define __NFP_NET_COMMON_H__
       8                 :            : 
       9                 :            : #include <bus_pci_driver.h>
      10                 :            : #include <ethdev_driver.h>
      11                 :            : #include <nfp_common.h>
      12                 :            : #include <nfp_dev.h>
      13                 :            : #include <rte_spinlock.h>
      14                 :            : 
      15                 :            : #include "nfp_net_ctrl.h"
      16                 :            : 
      17                 :            : /* Interrupt definitions */
      18                 :            : #define NFP_NET_IRQ_LSC_IDX             0
      19                 :            : 
      20                 :            : /* Default values for RX/TX configuration */
      21                 :            : #define DEFAULT_RX_FREE_THRESH  32
      22                 :            : #define DEFAULT_RX_PTHRESH      8
      23                 :            : #define DEFAULT_RX_HTHRESH      8
      24                 :            : #define DEFAULT_RX_WTHRESH      0
      25                 :            : 
      26                 :            : #define DEFAULT_TX_RS_THRESH    32
      27                 :            : #define DEFAULT_TX_FREE_THRESH  32
      28                 :            : #define DEFAULT_TX_PTHRESH      32
      29                 :            : #define DEFAULT_TX_HTHRESH      0
      30                 :            : #define DEFAULT_TX_WTHRESH      0
      31                 :            : #define DEFAULT_TX_RSBIT_THRESH 32
      32                 :            : 
      33                 :            : /* Alignment for dma zones */
      34                 :            : #define NFP_MEMZONE_ALIGN       128
      35                 :            : 
      36                 :            : /* Number of supported physical ports */
      37                 :            : #define NFP_MAX_PHYPORTS        12
      38                 :            : 
      39                 :            : #define NFP_BEAT_LENGTH         8
      40                 :            : 
      41                 :            : /*
      42                 :            :  * Each PF has corresponding word to beat:
      43                 :            :  * Offset | Usage
      44                 :            :  *   0    | magic number
      45                 :            :  *   8    | beat of Pf0
      46                 :            :  *   16   | beat of Pf1
      47                 :            :  *   24   | beat of Pf2
      48                 :            :  *   32   | beat of Pf3
      49                 :            :  */
      50                 :            : #define NFP_BEAT_OFFSET(_x)     (((_x) + 1) * NFP_BEAT_LENGTH)
      51                 :            : 
      52                 :            : /* Firmware application ID's */
      53                 :            : enum nfp_app_fw_id {
      54                 :            :         NFP_APP_FW_CORE_NIC               = 0x1,
      55                 :            :         NFP_APP_FW_FLOWER_NIC             = 0x3,
      56                 :            : };
      57                 :            : 
      58                 :            : enum nfp_net_meta_format {
      59                 :            :         NFP_NET_METAFORMAT_SINGLE,
      60                 :            :         NFP_NET_METAFORMAT_CHAINED,
      61                 :            : };
      62                 :            : 
      63                 :            : /* Parsed control BAR TLV capabilities */
      64                 :            : struct nfp_net_tlv_caps {
      65                 :            :         uint32_t mbox_off;               /**< VNIC mailbox area offset */
      66                 :            :         uint32_t mbox_len;               /**< VNIC mailbox area length */
      67                 :            :         uint32_t mbox_cmsg_types;        /**< Cmsgs which can be passed through the mailbox */
      68                 :            : };
      69                 :            : 
      70                 :            : struct nfp_multi_pf {
      71                 :            :         /** Support multiple PF */
      72                 :            :         bool enabled;
      73                 :            :         /** Function index */
      74                 :            :         uint8_t function_id;
      75                 :            :         /** Pointer to CPP area for beat to keepalive */
      76                 :            :         struct nfp_cpp_area *beat_area;
      77                 :            :         /** Pointer to mapped beat address used for keepalive */
      78                 :            :         uint8_t *beat_addr;
      79                 :            : };
      80                 :            : 
      81                 :            : struct nfp_pf_dev {
      82                 :            :         /** Backpointer to associated pci device */
      83                 :            :         struct rte_pci_device *pci_dev;
      84                 :            : 
      85                 :            :         enum nfp_app_fw_id app_fw_id;
      86                 :            : 
      87                 :            :         /** Pointer to the app running on the PF */
      88                 :            :         void *app_fw_priv;
      89                 :            : 
      90                 :            :         /** The eth table reported by firmware */
      91                 :            :         struct nfp_eth_table *nfp_eth_table;
      92                 :            : 
      93                 :            :         uint8_t *ctrl_bar;
      94                 :            : 
      95                 :            :         struct nfp_cpp *cpp;
      96                 :            :         struct nfp_cpp_area *ctrl_area;
      97                 :            :         struct nfp_cpp_area *qc_area;
      98                 :            : 
      99                 :            :         uint8_t *qc_bar;
     100                 :            : 
     101                 :            :         struct nfp_hwinfo *hwinfo;
     102                 :            :         struct nfp_rtsym_table *sym_tbl;
     103                 :            : 
     104                 :            :         /** Service id of cpp bridge service */
     105                 :            :         uint32_t cpp_bridge_id;
     106                 :            : 
     107                 :            :         /** Multiple PF configuration */
     108                 :            :         struct nfp_multi_pf multi_pf;
     109                 :            : };
     110                 :            : 
     111                 :            : struct nfp_app_fw_nic {
     112                 :            :         /** Backpointer to the PF device */
     113                 :            :         struct nfp_pf_dev *pf_dev;
     114                 :            : 
     115                 :            :         /**
     116                 :            :          * Array of physical ports belonging to this CoreNIC app.
     117                 :            :          * This is really a list of vNIC's, one for each physical port.
     118                 :            :          */
     119                 :            :         struct nfp_net_hw *ports[NFP_MAX_PHYPORTS];
     120                 :            : 
     121                 :            :         bool multiport;
     122                 :            :         uint8_t total_phyports;
     123                 :            : };
     124                 :            : 
     125                 :            : struct nfp_net_hw {
     126                 :            :         /** The parent class */
     127                 :            :         struct nfp_hw super;
     128                 :            : 
     129                 :            :         /** Backpointer to the PF this port belongs to */
     130                 :            :         struct nfp_pf_dev *pf_dev;
     131                 :            : 
     132                 :            :         /** Backpointer to the eth_dev of this port */
     133                 :            :         struct rte_eth_dev *eth_dev;
     134                 :            : 
     135                 :            :         /** Info from the firmware */
     136                 :            :         struct nfp_net_fw_ver ver;
     137                 :            :         uint32_t max_mtu;
     138                 :            :         uint32_t mtu;
     139                 :            :         uint32_t rx_offset;
     140                 :            :         enum nfp_net_meta_format meta_format;
     141                 :            : 
     142                 :            :         /** NFP ASIC params */
     143                 :            :         const struct nfp_dev_info *dev_info;
     144                 :            : 
     145                 :            :         uint8_t *tx_bar;
     146                 :            :         uint8_t *rx_bar;
     147                 :            : 
     148                 :            :         int stride_rx;
     149                 :            :         int stride_tx;
     150                 :            : 
     151                 :            :         uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS];
     152                 :            :         uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
     153                 :            : 
     154                 :            :         uint32_t max_tx_queues;
     155                 :            :         uint32_t max_rx_queues;
     156                 :            :         uint16_t flbufsz;
     157                 :            :         uint16_t device_id;
     158                 :            :         uint16_t vendor_id;
     159                 :            :         uint16_t subsystem_device_id;
     160                 :            :         uint16_t subsystem_vendor_id;
     161                 :            : 
     162                 :            :         /** Records starting point for counters */
     163                 :            :         struct rte_eth_stats eth_stats_base;
     164                 :            :         struct rte_eth_xstat *eth_xstats_base;
     165                 :            : 
     166                 :            :         struct nfp_cpp *cpp;
     167                 :            :         struct nfp_cpp_area *ctrl_area;
     168                 :            :         struct nfp_cpp_area *mac_stats_area;
     169                 :            :         uint8_t *mac_stats_bar;
     170                 :            :         uint8_t *mac_stats;
     171                 :            : 
     172                 :            :         /** Sequential physical port number, only valid for CoreNIC firmware */
     173                 :            :         uint8_t idx;
     174                 :            :         /** Internal port number as seen from NFP */
     175                 :            :         uint8_t nfp_idx;
     176                 :            : 
     177                 :            :         struct nfp_net_tlv_caps tlv_caps;
     178                 :            : 
     179                 :            :         struct nfp_net_ipsec_data *ipsec_data;
     180                 :            : };
     181                 :            : 
     182                 :            : static inline uint32_t
     183                 :            : nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
     184                 :            :                 uint16_t queue)
     185                 :            : {
     186                 :          0 :         return dev_info->qc_addr_offset + NFP_QCP_QUEUE_ADDR_SZ *
     187                 :          0 :                         (queue & dev_info->qc_idx_mask);
     188                 :            : }
     189                 :            : 
     190                 :            : /* Prototypes for common NFP functions */
     191                 :            : int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
     192                 :            : int nfp_net_configure(struct rte_eth_dev *dev);
     193                 :            : int nfp_net_common_init(struct rte_pci_device *pci_dev, struct nfp_net_hw *hw);
     194                 :            : void nfp_net_log_device_information(const struct nfp_net_hw *hw);
     195                 :            : void nfp_net_enable_queues(struct rte_eth_dev *dev);
     196                 :            : void nfp_net_disable_queues(struct rte_eth_dev *dev);
     197                 :            : void nfp_net_params_setup(struct nfp_net_hw *hw);
     198                 :            : int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
     199                 :            : int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
     200                 :            :                 struct rte_intr_handle *intr_handle);
     201                 :            : uint32_t nfp_check_offloads(struct rte_eth_dev *dev);
     202                 :            : int nfp_net_promisc_enable(struct rte_eth_dev *dev);
     203                 :            : int nfp_net_promisc_disable(struct rte_eth_dev *dev);
     204                 :            : int nfp_net_allmulticast_enable(struct rte_eth_dev *dev);
     205                 :            : int nfp_net_allmulticast_disable(struct rte_eth_dev *dev);
     206                 :            : int nfp_net_link_update_common(struct rte_eth_dev *dev,
     207                 :            :                 struct nfp_net_hw *hw,
     208                 :            :                 struct rte_eth_link *link,
     209                 :            :                 uint32_t link_status);
     210                 :            : int nfp_net_link_update(struct rte_eth_dev *dev,
     211                 :            :                 __rte_unused int wait_to_complete);
     212                 :            : int nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
     213                 :            : int nfp_net_stats_reset(struct rte_eth_dev *dev);
     214                 :            : uint32_t nfp_net_xstats_size(const struct rte_eth_dev *dev);
     215                 :            : int nfp_net_xstats_get_names(struct rte_eth_dev *dev,
     216                 :            :                 struct rte_eth_xstat_name *xstats_names,
     217                 :            :                 unsigned int size __rte_unused);
     218                 :            : int nfp_net_xstats_get(struct rte_eth_dev *dev,
     219                 :            :                 struct rte_eth_xstat *xstats,
     220                 :            :                 unsigned int n __rte_unused);
     221                 :            : int nfp_net_xstats_get_names_by_id(struct rte_eth_dev *dev,
     222                 :            :                 const uint64_t *ids,
     223                 :            :                 struct rte_eth_xstat_name *xstats_names,
     224                 :            :                 unsigned int size);
     225                 :            : int nfp_net_xstats_get_by_id(struct rte_eth_dev *dev,
     226                 :            :                 const uint64_t *ids,
     227                 :            :                 uint64_t *values,
     228                 :            :                 unsigned int n);
     229                 :            : int nfp_net_xstats_reset(struct rte_eth_dev *dev);
     230                 :            : int nfp_net_infos_get(struct rte_eth_dev *dev,
     231                 :            :                 struct rte_eth_dev_info *dev_info);
     232                 :            : const uint32_t *nfp_net_supported_ptypes_get(struct rte_eth_dev *dev);
     233                 :            : int nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id);
     234                 :            : int nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id);
     235                 :            : void nfp_net_params_setup(struct nfp_net_hw *hw);
     236                 :            : void nfp_net_cfg_queue_setup(struct nfp_net_hw *hw);
     237                 :            : void nfp_net_irq_unmask(struct rte_eth_dev *dev);
     238                 :            : void nfp_net_dev_interrupt_handler(void *param);
     239                 :            : void nfp_net_dev_interrupt_delayed_handler(void *param);
     240                 :            : int nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
     241                 :            : int nfp_net_vlan_offload_set(struct rte_eth_dev *dev, int mask);
     242                 :            : int nfp_net_reta_update(struct rte_eth_dev *dev,
     243                 :            :                 struct rte_eth_rss_reta_entry64 *reta_conf,
     244                 :            :                 uint16_t reta_size);
     245                 :            : int nfp_net_reta_query(struct rte_eth_dev *dev,
     246                 :            :                 struct rte_eth_rss_reta_entry64 *reta_conf,
     247                 :            :                 uint16_t reta_size);
     248                 :            : int nfp_net_rss_hash_update(struct rte_eth_dev *dev,
     249                 :            :                 struct rte_eth_rss_conf *rss_conf);
     250                 :            : int nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
     251                 :            :                 struct rte_eth_rss_conf *rss_conf);
     252                 :            : int nfp_net_rss_config_default(struct rte_eth_dev *dev);
     253                 :            : void nfp_net_stop_rx_queue(struct rte_eth_dev *dev);
     254                 :            : void nfp_net_close_rx_queue(struct rte_eth_dev *dev);
     255                 :            : void nfp_net_stop_tx_queue(struct rte_eth_dev *dev);
     256                 :            : void nfp_net_close_tx_queue(struct rte_eth_dev *dev);
     257                 :            : int nfp_net_set_vxlan_port(struct nfp_net_hw *hw, size_t idx, uint16_t port);
     258                 :            : void nfp_net_rx_desc_limits(struct nfp_net_hw *hw,
     259                 :            :                 uint16_t *min_rx_desc,
     260                 :            :                 uint16_t *max_rx_desc);
     261                 :            : void nfp_net_tx_desc_limits(struct nfp_net_hw *hw,
     262                 :            :                 uint16_t *min_tx_desc,
     263                 :            :                 uint16_t *max_tx_desc);
     264                 :            : int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name);
     265                 :            : void nfp_net_init_metadata_format(struct nfp_net_hw *hw);
     266                 :            : void nfp_net_cfg_read_version(struct nfp_net_hw *hw);
     267                 :            : int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size);
     268                 :            : bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
     269                 :            : struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev);
     270                 :            : int nfp_net_stop(struct rte_eth_dev *dev);
     271                 :            : int nfp_net_flow_ctrl_get(struct rte_eth_dev *dev,
     272                 :            :                 struct rte_eth_fc_conf *fc_conf);
     273                 :            : int nfp_net_flow_ctrl_set(struct rte_eth_dev *dev,
     274                 :            :                 struct rte_eth_fc_conf *fc_conf);
     275                 :            : 
     276                 :            : #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
     277                 :            :         ((struct nfp_app_fw_nic *)app_fw_priv)
     278                 :            : 
     279                 :            : #define NFP_PRIV_TO_APP_FW_FLOWER(app_fw_priv)\
     280                 :            :         ((struct nfp_app_fw_flower *)app_fw_priv)
     281                 :            : 
     282                 :            : #endif /* __NFP_NET_COMMON_H__ */

Generated by: LCOV version 1.14