LCOV - code coverage report
Current view: top level - drivers/net/rnp - rnp.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 2 0.0 %
Date: 2025-08-01 17:49:26 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 2 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2023 Mucse IC Design Ltd.
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef __RNP_H__
       6                 :            : #define __RNP_H__
       7                 :            : 
       8                 :            : #include <ethdev_driver.h>
       9                 :            : #include <rte_interrupts.h>
      10                 :            : 
      11                 :            : #include "base/rnp_hw.h"
      12                 :            : 
      13                 :            : #define PCI_VENDOR_ID_MUCSE     (0x8848)
      14                 :            : #define RNP_DEV_ID_N10G_X2      (0x1000)
      15                 :            : #define RNP_DEV_ID_N10G_X4      (0x1020)
      16                 :            : #define RNP_DEV_ID_N10G_X8      (0x1060)
      17                 :            : #define RNP_MAX_VF_NUM          (64)
      18                 :            : #define RNP_MISC_VEC_ID         RTE_INTR_VEC_ZERO_OFFSET
      19                 :            : /* maximum frame size supported */
      20                 :            : #define RNP_ETH_OVERHEAD \
      21                 :            :         (RTE_ETHER_HDR_LEN + RTE_VLAN_HLEN * 2)
      22                 :            : #define RNP_MAC_MAXFRM_SIZE     (9590)
      23                 :            : #define RNP_MAX_TSO_PKT         (16 * 1024)
      24                 :            : #define RNP_RX_MAX_MTU_SEG      (64)
      25                 :            : #define RNP_TX_MAX_MTU_SEG      (32)
      26                 :            : #define RNP_RX_MAX_SEG          (150)
      27                 :            : #define RNP_TX_MAX_SEG          (UINT8_MAX)
      28                 :            : #define RNP_MIN_DMA_BUF_SIZE    (1024)
      29                 :            : /* rss support info */
      30                 :            : #define RNP_RSS_INDIR_SIZE      (128)
      31                 :            : #define RNP_MAX_HASH_KEY_SIZE   (10)
      32                 :            : #define RNP_SUPPORT_RSS_OFFLOAD_ALL ( \
      33                 :            :                 RTE_ETH_RSS_IPV4 | \
      34                 :            :                 RTE_ETH_RSS_FRAG_IPV4 | \
      35                 :            :                 RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
      36                 :            :                 RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
      37                 :            :                 RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
      38                 :            :                 RTE_ETH_RSS_NONFRAG_IPV4_SCTP |\
      39                 :            :                 RTE_ETH_RSS_IPV6 | \
      40                 :            :                 RTE_ETH_RSS_FRAG_IPV6 | \
      41                 :            :                 RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
      42                 :            :                 RTE_ETH_RSS_IPV6_EX | \
      43                 :            :                 RTE_ETH_RSS_IPV6_TCP_EX | \
      44                 :            :                 RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
      45                 :            :                 RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
      46                 :            :                 RTE_ETH_RSS_IPV6_UDP_EX | \
      47                 :            :                 RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
      48                 :            : /* rx checksum offload */
      49                 :            : #define RNP_RX_CHECKSUM_SUPPORT ( \
      50                 :            :                 RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
      51                 :            :                 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
      52                 :            :                 RTE_ETH_RX_OFFLOAD_TCP_CKSUM | \
      53                 :            :                 RTE_ETH_RX_OFFLOAD_SCTP_CKSUM | \
      54                 :            :                 RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM)
      55                 :            : /* Ring info special */
      56                 :            : #define RNP_MAX_BD_COUNT        (4096)
      57                 :            : #define RNP_MIN_BD_COUNT        (128)
      58                 :            : #define RNP_BD_ALIGN            (2)
      59                 :            : /* Hardware resource info */
      60                 :            : #define RNP_MAX_MSIX_NUM                (64)
      61                 :            : #define RNP_MAX_RX_QUEUE_NUM            (128)
      62                 :            : #define RNP_MAX_TX_QUEUE_NUM            (128)
      63                 :            : /* l2 filter hardware resource info */
      64                 :            : #define RNP_MAX_MAC_ADDRS               (128)   /* max unicast extract mac num */
      65                 :            : #define RNP_MAX_HASH_UC_MAC_SIZE        (4096)  /* max unicast hash mac num */
      66                 :            : #define RNP_MAX_HASH_MC_MAC_SIZE        (4096)  /* max multicast hash mac num */
      67                 :            : #define RNP_MAX_UC_HASH_TABLE           (128)   /* max unicast hash mac filter table */
      68                 :            : #define RNP_MAC_MC_HASH_TABLE           (128)   /* max multicast hash mac filter table*/
      69                 :            : #define RNP_MAX_VFTA_SIZE               (128)   /* max pf vlan hash table size */
      70                 :            : /* Peer port own independent resource */
      71                 :            : #define RNP_PORT_MAX_MACADDR         (32)
      72                 :            : #define RNP_PORT_MAX_MC_HASH_TB      (8)
      73                 :            : #define RNP_PORT_MAX_MC_MAC_SIZE     (RNP_PORT_MAX_MC_HASH_TB * 32)
      74                 :            : #define RNP_PORT_HASH_SHIFT          (26 - (RNP_PORT_MAX_MC_MAC_SIZE >> 7))
      75                 :            : /* hardware media type */
      76                 :            : enum rnp_media_type {
      77                 :            :         RNP_MEDIA_TYPE_UNKNOWN,
      78                 :            :         RNP_MEDIA_TYPE_FIBER,
      79                 :            :         RNP_MEDIA_TYPE_COPPER,
      80                 :            :         RNP_MEDIA_TYPE_BACKPLANE,
      81                 :            :         RNP_MEDIA_TYPE_NONE,
      82                 :            : };
      83                 :            : 
      84                 :            : struct rnp_phy_meta {
      85                 :            :         uint32_t speed_cap;
      86                 :            :         uint32_t supported_link;
      87                 :            :         uint16_t link_duplex;
      88                 :            :         uint16_t link_autoneg;
      89                 :            :         uint32_t phy_identifier;
      90                 :            :         uint16_t phy_type;
      91                 :            :         uint8_t media_type;
      92                 :            :         bool is_sgmii;
      93                 :            :         bool is_backplane;
      94                 :            :         bool fec;
      95                 :            : };
      96                 :            : 
      97                 :            : struct rnp_port_attr {
      98                 :            :         uint16_t max_mac_addrs;   /* max support mac address */
      99                 :            :         uint16_t max_uc_mac_hash; /* max hash unicast mac size */
     100                 :            :         uint16_t max_mc_mac_hash; /* max hash multicast mac size */
     101                 :            :         uint16_t uc_hash_tb_size; /* max unicast hash table block num */
     102                 :            :         uint16_t mc_hash_tb_size; /* max multicast hash table block num */
     103                 :            :         uint16_t hash_table_shift;/* hash mac table shift num */
     104                 :            :         uint16_t max_rx_queues;   /* belong to this port rxq resource */
     105                 :            :         uint16_t max_tx_queues;   /* belong to this port txq resource */
     106                 :            : 
     107                 :            :         struct rnp_phy_meta phy_meta;
     108                 :            : 
     109                 :            :         bool link_ready;
     110                 :            :         bool pre_link;
     111                 :            :         bool duplex;
     112                 :            :         uint32_t speed;
     113                 :            : 
     114                 :            :         uint16_t port_id;       /* platform manage port sequence id */
     115                 :            :         uint8_t port_offset;    /* port queue offset */
     116                 :            :         uint8_t sw_id;          /* software port init sequence id */
     117                 :            :         uint16_t nr_lane;       /* phy lane of This PF:0~3 */
     118                 :            : };
     119                 :            : 
     120                 :            : struct rnp_proc_priv {
     121                 :            :         const struct rnp_mac_ops *mac_ops;
     122                 :            :         const struct rnp_mbx_ops *mbx_ops;
     123                 :            : };
     124                 :            : 
     125                 :            : struct rnp_hw_eth_stats {
     126                 :            :         uint64_t rx_trans_drop;         /* rx eth to dma fifo full drop */
     127                 :            :         uint64_t rx_trunc_drop;         /* rx mac to eth to host copy fifo full drop */
     128                 :            :         uint64_t rx_glen_drop;          /* pkts length bigger than hw limit */
     129                 :            :         uint64_t rx_slen_drop;          /* pkts length less than hw limit */
     130                 :            :         uint64_t rx_cksum_e_drop;       /* rx cksum error pkts drop */
     131                 :            :         uint64_t rx_iph_e_drop;         /* rx ip header error drop */
     132                 :            : };
     133                 :            : 
     134                 :            : struct rnp_hw_mac_stats {
     135                 :            :         uint64_t rx_all_pkts;     /* Include good and bad frame packets */
     136                 :            :         uint64_t rx_all_bytes;    /* Include good and bad frame octes */
     137                 :            :         uint64_t rx_unicast;      /* rx good unicast packets */
     138                 :            :         uint64_t rx_broadcast;    /* rx good broadcast packets */
     139                 :            :         uint64_t rx_multicast;    /* rx good multicast packets */
     140                 :            :         uint64_t rx_pause;        /* Rx pause frame packets */
     141                 :            :         uint64_t rx_vlan;         /* Rx vlan frame packets */
     142                 :            :         uint64_t rx_oversize_9k;
     143                 :            :         uint64_t rx_64octes_pkts;
     144                 :            :         uint64_t rx_65to127_octes_pkts;
     145                 :            :         uint64_t rx_128to255_octes_pkts;
     146                 :            :         uint64_t rx_256to511_octes_pkts;
     147                 :            :         uint64_t rx_512to1023_octes_pkts;
     148                 :            :         uint64_t rx_1024tomax_octes_pkts;
     149                 :            :         uint64_t rx_len_err;      /* Bigger or less than len support */
     150                 :            :         uint64_t rx_len_invalid;  /* frame len isn't equal real len */
     151                 :            :         uint64_t rx_watchdog_err; /* Rx with a watchdog time out error */
     152                 :            :         uint64_t rx_crc_err;
     153                 :            :         uint64_t rx_runt_err;     /* Frame less-than-64-byte with a CRC error*/
     154                 :            :         uint64_t rx_jabber_err;   /* Jumbo Frame Crc Error */
     155                 :            :         uint64_t rx_undersize_err;/* Frame less than 64 bytes Error */
     156                 :            : 
     157                 :            :         uint64_t tx_all_pkts;     /* Include good and bad frame num */
     158                 :            :         uint64_t tx_all_bytes;    /* Include good and bad frame octes */
     159                 :            :         uint64_t tx_pause_pkts;
     160                 :            :         uint64_t tx_vlan_pkts;
     161                 :            :         uint64_t tx_all_multicast;
     162                 :            :         uint64_t tx_all_unicast;
     163                 :            :         uint64_t tx_all_broadcast;
     164                 :            :         uint64_t tx_64octes_pkts;
     165                 :            :         uint64_t tx_65to127_octes_pkts;
     166                 :            :         uint64_t tx_128to255_octes_pkts;
     167                 :            :         uint64_t tx_256to511_octes_pkts;
     168                 :            :         uint64_t tx_512to1023_octes_pkts;
     169                 :            :         uint64_t tx_1024tomax_octes_pkts;
     170                 :            :         uint64_t tx_underflow_err;
     171                 :            : };
     172                 :            : 
     173                 :            : enum rnp_vlan_type {
     174                 :            :         RNP_CVLAN_TYPE = 0,
     175                 :            :         RNP_SVLAN_TYPE = 1,
     176                 :            : };
     177                 :            : 
     178                 :            : struct rnp_vlan_filter {
     179                 :            :         union {
     180                 :            :                 /* indep vlan hash filter table used */
     181                 :            :                 uint64_t vlans_bitmap[BITS_TO_LONGS(VLAN_N_VID)];
     182                 :            :                 /* PF vlan filter table used */
     183                 :            :                 uint32_t vfta_entries[RNP_MAX_VFTA_SIZE];
     184                 :            :         };
     185                 :            : };
     186                 :            : 
     187                 :            : struct rnp_eth_port {
     188                 :            :         struct rnp_proc_priv *proc_priv;
     189                 :            :         struct rte_ether_addr mac_addr;
     190                 :            :         struct rte_eth_dev *eth_dev;
     191                 :            :         struct rnp_port_attr attr;
     192                 :            :         struct rnp_tx_queue *tx_queues[RNP_MAX_RX_QUEUE_NUM];
     193                 :            :         struct rnp_hw *hw;
     194                 :            : 
     195                 :            :         struct rnp_hw_eth_stats eth_stats_old;
     196                 :            :         struct rnp_hw_eth_stats eth_stats;
     197                 :            :         struct rnp_hw_mac_stats mac_stats;
     198                 :            : 
     199                 :            :         struct rte_eth_rss_conf rss_conf;
     200                 :            :         uint16_t last_rx_num;
     201                 :            :         bool rxq_num_changed;
     202                 :            :         bool reta_has_cfg;
     203                 :            :         bool hw_rss_en;
     204                 :            :         uint32_t indirtbl[RNP_RSS_INDIR_SIZE];
     205                 :            :         uint32_t mc_hash_table[RNP_MAC_MC_HASH_TABLE];
     206                 :            :         uint8_t hash_filter_type;
     207                 :            : 
     208                 :            :         uint16_t cur_mtu;
     209                 :            :         bool jumbo_en;
     210                 :            : 
     211                 :            :         enum rnp_vlan_type outvlan_type;
     212                 :            :         enum rnp_vlan_type invlan_type;
     213                 :            :         struct rnp_vlan_filter vfta;
     214                 :            :         rte_spinlock_t rx_mac_lock;
     215                 :            :         bool port_stopped;
     216                 :            : };
     217                 :            : 
     218                 :            : enum rnp_pf_op {
     219                 :            :         RNP_PF_OP_DONE,
     220                 :            :         RNP_PF_OP_CLOSING = 1,
     221                 :            :         RNP_PF_OP_PROCESS,
     222                 :            : };
     223                 :            : 
     224                 :            : struct rnp_eth_adapter {
     225                 :            :         struct rnp_hw hw;
     226                 :            :         struct rte_pci_device *pdev;
     227                 :            :         struct rte_eth_dev *eth_dev; /* alloc eth_dev by platform */
     228                 :            : 
     229                 :            :         struct rte_mempool *reset_pool;
     230                 :            :         struct rnp_eth_port *ports[RNP_MAX_PORT_OF_PF];
     231                 :            :         RTE_ATOMIC(uint16_t) pf_op;
     232                 :            :         uint16_t closed_ports;
     233                 :            :         uint16_t inited_ports;
     234                 :            :         bool intr_registered;
     235                 :            : };
     236                 :            : 
     237                 :            : #define RNP_DEV_TO_PORT(eth_dev) \
     238                 :            :         ((struct rnp_eth_port *)(eth_dev)->data->dev_private)
     239                 :            : #define RNP_DEV_TO_ADAPTER(eth_dev) \
     240                 :            :         ((struct rnp_eth_adapter *)(RNP_DEV_TO_PORT(eth_dev))->hw->back)
     241                 :            : #define RNP_DEV_TO_PROC_PRIV(eth_dev) \
     242                 :            :         ((struct rnp_proc_priv *)(eth_dev)->process_private)
     243                 :            : #define RNP_DEV_PP_TO_MBX_OPS(priv) \
     244                 :            :         (((RNP_DEV_TO_PROC_PRIV(priv))->mbx_ops))
     245                 :            : #define RNP_DEV_PP_TO_MAC_OPS(priv) \
     246                 :            :         (((RNP_DEV_TO_PROC_PRIV(priv))->mac_ops))
     247                 :            : 
     248                 :            : static inline int
     249                 :            : rnp_pf_own_ports(uint32_t id)
     250                 :            : {
     251                 :          0 :         return (id == 0) ? 1 : (id == 1) ? 2 : 4;
     252                 :            : }
     253                 :            : 
     254                 :            : static inline int
     255                 :            : rnp_pf_is_multiple_ports(uint32_t device_id)
     256                 :            : {
     257         [ #  # ]:          0 :         uint32_t verbit = (device_id >> 5) & 0x3;
     258                 :            : 
     259                 :            :         return rnp_pf_own_ports(verbit) == 1 ? 0 : 1;
     260                 :            : }
     261                 :            : 
     262                 :            : #endif /* __RNP_H__ */

Generated by: LCOV version 1.14