LCOV - code coverage report
Current view: top level - drivers/net/sxe2 - sxe2_ethdev.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 3 0.0 %
Date: 2026-08-01 17:54:00 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 6 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef SXE2_ETHDEV_H
       6                 :            : #define SXE2_ETHDEV_H
       7                 :            : 
       8                 :            : #include <rte_compat.h>
       9                 :            : #include <rte_kvargs.h>
      10                 :            : #include <rte_time.h>
      11                 :            : #include <ethdev_driver.h>
      12                 :            : #include <ethdev_pci.h>
      13                 :            : #include <rte_tm_driver.h>
      14                 :            : #include <rte_io.h>
      15                 :            : 
      16                 :            : #include "sxe2_common.h"
      17                 :            : #include "sxe2_vsi.h"
      18                 :            : #include "sxe2_rss.h"
      19                 :            : #include "sxe2_irq.h"
      20                 :            : #include "sxe2_queue.h"
      21                 :            : #include "sxe2_mac.h"
      22                 :            : #include "sxe2_osal.h"
      23                 :            : #include "sxe2_security.h"
      24                 :            : #include "sxe2_ipsec.h"
      25                 :            : #include "sxe2_tm.h"
      26                 :            : #include "sxe2_filter.h"
      27                 :            : 
      28                 :            : struct sxe2_link_msg {
      29                 :            :         uint32_t speed;
      30                 :            :         uint8_t status;
      31                 :            : };
      32                 :            : 
      33                 :            : enum sxe2_fnav_tunnel_flag_type {
      34                 :            :         SXE2_FNAV_TUN_FLAG_NO_TUNNEL,
      35                 :            :         SXE2_FNAV_TUN_FLAG_TUNNEL,
      36                 :            :         SXE2_FNAV_TUN_FLAG_ANY,
      37                 :            : };
      38                 :            : 
      39                 :            : #define SXE2_VF_MAX_NUM        256
      40                 :            : #define SXE2_VSI_MAX_NUM       768
      41                 :            : #define SXE2_FRAME_SIZE_MAX    9832
      42                 :            : #define SXE2_VLAN_TAG_SIZE     4
      43                 :            : #define SXE2_ETH_OVERHEAD \
      44                 :            :         (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + 2 * SXE2_VLAN_TAG_SIZE)
      45                 :            : #define SXE2_ETH_MAX_LEN (RTE_ETHER_MTU + SXE2_ETH_OVERHEAD)
      46                 :            : 
      47                 :            : #ifdef SXE2_TEST
      48                 :            : #define SXE2_RESET_ACTIVE_WAIT_COUNT   (5)
      49                 :            : #else
      50                 :            : #define SXE2_RESET_ACTIVE_WAIT_COUNT   (10000)
      51                 :            : #endif
      52                 :            : #define SXE2_NO_ACTIVE_CNT           (10)
      53                 :            : 
      54                 :            : #define SXE2_WOKER_DELAY_5MS         (5)
      55                 :            : #define SXE2_WOKER_DELAY_10MS        (10)
      56                 :            : #define SXE2_WOKER_DELAY_20MS        (20)
      57                 :            : #define SXE2_WOKER_DELAY_30MS        (30)
      58                 :            : 
      59                 :            : #define SXE2_RESET_DETEC_WAIT_COUNT    (100)
      60                 :            : #define SXE2_RESET_DONE_WAIT_COUNT     (250)
      61                 :            : #define SXE2_RESET_WAIT_MS             (10)
      62                 :            : 
      63                 :            : #define SXE2_RESET_WAIT_MIN   (10)
      64                 :            : #define SXE2_RESET_WAIT_MAX   (20)
      65                 :            : #define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16))
      66                 :            : #define lower_32_bits(n) ((uint32_t)((n) & 0xffffffff))
      67                 :            : 
      68                 :            : #define SXE2_REPRESENTOR_ID(pf, type, repr) \
      69                 :            :                 (((pf) << 14) + ((type) << 12) + ((repr) & 0xfff))
      70                 :            : 
      71                 :            : #define SXE2_I2C_EEPROM_DEV_ADDR        0xA0
      72                 :            : #define SXE2_I2C_EEPROM_DEV_ADDR2       0xA2
      73                 :            : #define SXE2_MODULE_TYPE_SFP            0x03
      74                 :            : #define SXE2_MODULE_TYPE_QSFP_PLUS      0x0D
      75                 :            : #define SXE2_MODULE_TYPE_QSFP28 0x11
      76                 :            : #define SXE2_MODULE_SFF_ADDR_MODE       0x04
      77                 :            : #define SXE2_MODULE_SFF_DIAG_CAPAB      0x40
      78                 :            : #define SXE2_MODULE_REVISION_ADDR       0x01
      79                 :            : #define SXE2_MODULE_SFF_8472_COMP       0x5E
      80                 :            : #define SXE2_MODULE_SFF_8472_SWAP       0x5C
      81                 :            : #define SXE2_MODULE_QSFP_MAX_LEN        640
      82                 :            : #define SXE2_MODULE_SFF_8472_UNSUP      0x0
      83                 :            : #define SXE2_MODULE_SFF_DDM_IMPLEMENTED 0x40
      84                 :            : #define SXE2_MODULE_SFF_SFP_TYPE   0x03
      85                 :            : #define SXE2_MODULE_TYPE_QSFP_PLUS      0x0D
      86                 :            : #define SXE2_MODULE_TYPE_QSFP28 0x11
      87                 :            : 
      88                 :            : #define SXE2_MODULE_SFF_8079            0x1
      89                 :            : #define SXE2_MODULE_SFF_8079_LEN        256
      90                 :            : #define SXE2_MODULE_SFF_8472            0x2
      91                 :            : #define SXE2_MODULE_SFF_8472_LEN        512
      92                 :            : #define SXE2_MODULE_SFF_8636            0x3
      93                 :            : #define SXE2_MODULE_SFF_8636_LEN        256
      94                 :            : #define SXE2_MODULE_SFF_8636_MAX_LEN     640
      95                 :            : #define SXE2_MODULE_SFF_8436            0x4
      96                 :            : #define SXE2_MODULE_SFF_8436_LEN        256
      97                 :            : #define SXE2_MODULE_SFF_8436_MAX_LEN     640
      98                 :            : 
      99                 :            : enum sxe2_wk_type {
     100                 :            :         SXE2_WK_MONITOR,
     101                 :            :         SXE2_WK_MONITOR_IM,
     102                 :            :         SXE2_WK_POST,
     103                 :            :         SXE2_WK_MBX,
     104                 :            : };
     105                 :            : 
     106                 :            : enum {
     107                 :            :         SXE2_FLAG_LEGACY_RX_ENABLE   = 0,
     108                 :            :         SXE2_FLAG_LRO_ENABLE = 1,
     109                 :            :         SXE2_FLAG_RXQ_DISABLED = 2,
     110                 :            :         SXE2_FLAG_TXQ_DISABLED = 3,
     111                 :            :         SXE2_FLAG_DRV_REMOVING = 4,
     112                 :            :         SXE2_FLAG_RESET_DETECTED = 5,
     113                 :            :         SXE2_FLAG_CORE_RESET_DONE = 6,
     114                 :            :         SXE2_FLAG_RESET_ACTIVED = 7,
     115                 :            :         SXE2_FLAG_RESET_PENDING = 8,
     116                 :            :         SXE2_FLAG_RESET_REQUEST = 9,
     117                 :            :         SXE2_FLAGS_RESET_PROCESS_DONE = 10,
     118                 :            :         SXE2_FLAG_RESET_FAILED = 11,
     119                 :            :         SXE2_FLAG_DRV_PROBE_DONE = 12,
     120                 :            :         SXE2_FLAG_NETDEV_REGISTED = 13,
     121                 :            :         SXE2_FLAG_DRV_UP = 15,
     122                 :            :         SXE2_FLAG_DCB_ENABLE = 16,
     123                 :            :         SXE2_FLAG_FLTR_SYNC = 17,
     124                 :            : 
     125                 :            :         SXE2_FLAG_EVENT_IRQ_DISABLED = 18,
     126                 :            :         SXE2_FLAG_SUSPEND = 19,
     127                 :            :         SXE2_FLAG_FNAV_ENABLE = 20,
     128                 :            : 
     129                 :            :         SXE2_FLAGS_NBITS
     130                 :            : };
     131                 :            : 
     132                 :            : struct sxe2_ptp_context {
     133                 :            :         uint64_t mbuf_rx_ts_flag;
     134                 :            :         int32_t mbuf_rx_ts_offset;
     135                 :            : };
     136                 :            : 
     137                 :            : struct sxe2_devargs {
     138                 :            :         uint8_t flow_dup_pattern_mode;
     139                 :            :         uint8_t func_flow_direct_en;
     140                 :            :         uint8_t fnav_stat_type;
     141                 :            :         uint8_t no_sched_mode;
     142                 :            :         uint8_t sched_layer_mode;
     143                 :            :         uint8_t rx_low_latency;
     144                 :            : };
     145                 :            : 
     146                 :            : #define SXE2_PCI_MAP_BAR_INVALID ((uint8_t)0xff)
     147                 :            : #define SXE2_PCI_MAP_INVALID_VAL ((uint32_t)0xffffffff)
     148                 :            : 
     149                 :            : enum sxe2_pci_map_resource {
     150                 :            :         SXE2_PCI_MAP_RES_INVALID = 0,
     151                 :            :         SXE2_PCI_MAP_RES_DOORBELL_TX,
     152                 :            :         SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL,
     153                 :            :         SXE2_PCI_MAP_RES_IRQ_DYN,
     154                 :            :         SXE2_PCI_MAP_RES_IRQ_ITR,
     155                 :            :         SXE2_PCI_MAP_RES_IRQ_MSIX,
     156                 :            :         SXE2_PCI_MAP_RES_PTP,
     157                 :            :         SXE2_PCI_MAP_RES_MAX_COUNT,
     158                 :            : };
     159                 :            : 
     160                 :            : enum sxe2_udp_tunnel_protocol {
     161                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_VXLAN = 0,
     162                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_VXLAN_GPE,
     163                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_GENEVE,
     164                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_GTP_C = 4,
     165                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_GTP_U,
     166                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_PFCP,
     167                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_ECPRI,
     168                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_MPLS,
     169                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_NVGRE = 10,
     170                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_L2TP,
     171                 :            :         SXE2_UDP_TUNNEL_PROTOCOL_TEREDO,
     172                 :            :         SXE2_UDP_TUNNEL_MAX,
     173                 :            : };
     174                 :            : 
     175                 :            : struct sxe2_pci_map_addr_info {
     176                 :            :         uint64_t addr_base;
     177                 :            :         uint8_t bar_idx;
     178                 :            :         uint8_t reg_width;
     179                 :            : };
     180                 :            : 
     181                 :            : struct sxe2_pci_map_segment_info {
     182                 :            :         enum sxe2_pci_map_resource      type;
     183                 :            :         void                            *addr;
     184                 :            :         uint64_t                        page_inner_offset;
     185                 :            :         uint64_t                        len;
     186                 :            : };
     187                 :            : 
     188                 :            : struct sxe2_pci_map_bar_info {
     189                 :            :         uint8_t    bar_idx;
     190                 :            :         uint8_t    map_cnt;
     191                 :            :         struct sxe2_pci_map_segment_info    *seg_info;
     192                 :            : };
     193                 :            : 
     194                 :            : struct sxe2_pci_map_context {
     195                 :            :         uint8_t    bar_cnt;
     196                 :            :         struct sxe2_pci_map_bar_info *bar_info;
     197                 :            :         struct sxe2_pci_map_addr_info *addr_info;
     198                 :            : };
     199                 :            : 
     200                 :            : struct sxe2_dev_mac_info {
     201                 :            :         uint8_t perm_addr[SXE2_ETH_ALEN];
     202                 :            : };
     203                 :            : 
     204                 :            : struct sxe2_pci_info {
     205                 :            :         uint64_t                     serial_number;
     206                 :            :         uint8_t                      bus_devid;
     207                 :            :         uint8_t                      bus_function;
     208                 :            :         uint16_t                     max_vfs;
     209                 :            : };
     210                 :            : 
     211                 :            : struct sxe2_fw_info {
     212                 :            :         uint8_t                      main_version_id;
     213                 :            :         uint8_t                      sub_version_id;
     214                 :            :         uint8_t                      fix_version_id;
     215                 :            :         uint8_t                      build_id;
     216                 :            : };
     217                 :            : 
     218                 :            : struct sxe2_dev_info {
     219                 :            :         struct rte_eth_dev_data        *dev_data;
     220                 :            :         struct sxe2_pci_info           pci;
     221                 :            :         struct sxe2_fw_info            fw;
     222                 :            :         struct sxe2_dev_mac_info       mac;
     223                 :            : };
     224                 :            : 
     225                 :            : enum sxe2_udp_tunnel_status {
     226                 :            :         SXE2_UDP_TUNNEL_DISABLE = 0x0,
     227                 :            :         SXE2_UDP_TUNNEL_ENABLE,
     228                 :            : };
     229                 :            : 
     230                 :            : struct sxe2_udp_tunnel_cfg {
     231                 :            :         uint8_t                 protocol;
     232                 :            :         uint8_t                 dev_status;
     233                 :            :         uint16_t                        dev_port;
     234                 :            :         uint16_t                        dev_ref_cnt;
     235                 :            : 
     236                 :            :         uint16_t                        fw_port;
     237                 :            :         uint8_t                 fw_status;
     238                 :            :         uint8_t                 fw_dst_en;
     239                 :            :         uint8_t                 fw_src_en;
     240                 :            :         uint8_t                 fw_used;
     241                 :            : };
     242                 :            : 
     243                 :            : struct sxe2_udp_tunnel_ctx {
     244                 :            :         struct sxe2_udp_tunnel_cfg   tunnel_conf[SXE2_UDP_TUNNEL_MAX];
     245                 :            :         rte_spinlock_t                lock;
     246                 :            : };
     247                 :            : 
     248                 :            : struct sxe2_repr_context {
     249                 :            :         uint16_t nb_vf;
     250                 :            :         uint16_t nb_repr_vf;
     251                 :            :         struct rte_eth_dev **vf_rep_eth_dev;
     252                 :            :         struct sxe2_drv_vsi_caps repr_vf_id[SXE2_VF_MAX_NUM];
     253                 :            : };
     254                 :            : 
     255                 :            : struct sxe2_repr_private_data {
     256                 :            :         struct rte_eth_dev *rep_eth_dev;
     257                 :            :         struct sxe2_adapter *parent_adapter;
     258                 :            : 
     259                 :            :         struct sxe2_vsi *cp_vsi;
     260                 :            :         uint16_t repr_q_id;
     261                 :            : 
     262                 :            :         uint16_t repr_id;
     263                 :            :         uint16_t repr_pf_id;
     264                 :            :         uint16_t repr_vf_id;
     265                 :            :         uint16_t repr_vf_vsi_id;
     266                 :            :         uint16_t repr_vf_k_vsi_id;
     267                 :            :         uint16_t repr_vf_u_vsi_id;
     268                 :            : };
     269                 :            : 
     270                 :            : struct sxe2_sched_hw_cap {
     271                 :            :         uint32_t tm_layers;
     272                 :            :         uint8_t root_max_children;
     273                 :            :         uint8_t prio_max;
     274                 :            :         uint8_t adj_lvl;
     275                 :            : };
     276                 :            : 
     277                 :            : struct sxe2_sfp_read_info {
     278                 :            :         uint8_t *data;
     279                 :            :         uint16_t offset;
     280                 :            :         uint16_t len;
     281                 :            :         uint16_t bus_addr;
     282                 :            :         uint16_t page_cnt;
     283                 :            :         bool is_qsfp;
     284                 :            : };
     285                 :            : 
     286                 :            : struct sxe2_link_context {
     287                 :            :         rte_spinlock_t link_lock;
     288                 :            :         bool link_up;
     289                 :            :         uint32_t  speed;
     290                 :            : };
     291                 :            : 
     292                 :            : struct sxe2_filter_context {
     293                 :            :         rte_spinlock_t filter_lock;
     294                 :            :         struct sxe2_vlan_info               vlan_info;
     295                 :            :         struct sxe2_uc_filter_list_head    uc_list;
     296                 :            :         struct sxe2_mc_filter_list_head    mc_list;
     297                 :            :         struct sxe2_vlan_filter_list_head  vlan_list;
     298                 :            :         uint8_t                                 uc_num;
     299                 :            :         uint8_t                                 mc_num;
     300                 :            :         uint8_t                                 vlan_num;
     301                 :            :         uint8_t                                 rsv;
     302                 :            :         uint32_t hw_promisc_flags;
     303                 :            :         uint32_t cur_promisc_flags;
     304                 :            : 
     305                 :            :         bool hw_uplink_config;
     306                 :            :         bool cur_uplink_config;
     307                 :            :         bool hw_repr_config;
     308                 :            :         bool cur_repr_config;
     309                 :            :         bool hw_l2_config;
     310                 :            :         bool cur_l2_config;
     311                 :            : };
     312                 :            : 
     313                 :            : struct sxe2_fc_state_ctxt {
     314                 :            :         uint8_t curr_state;
     315                 :            :         uint8_t cfg_state;
     316                 :            : };
     317                 :            : 
     318                 :            : struct sxe2_adapter {
     319                 :            :         struct sxe2_common_device      *cdev;
     320                 :            :         struct sxe2_dev_info            dev_info;
     321                 :            :         struct rte_pci_device            *pci_dev;
     322                 :            :         struct sxe2_repr_private_data  *repr_priv_data;
     323                 :            :         struct sxe2_pci_map_context   map_ctxt;
     324                 :            :         struct sxe2_irq_context       irq_ctxt;
     325                 :            :         struct sxe2_queue_context     q_ctxt;
     326                 :            :         struct sxe2_vsi_context       vsi_ctxt;
     327                 :            :         struct sxe2_filter_context    filter_ctxt;
     328                 :            :         struct sxe2_rss_context       rss_ctxt;
     329                 :            :         struct sxe2_flow_context      flow_ctxt;
     330                 :            :         struct sxe2_link_context      link_ctxt;
     331                 :            :         struct sxe2_ptp_context       ptp_ctxt;
     332                 :            :         struct sxe2_sched_hw_cap      sched_ctxt;
     333                 :            :         struct sxe2_tm_context        tm_ctxt;
     334                 :            :         struct sxe2_devargs           devargs;
     335                 :            :         struct sxe2_udp_tunnel_ctx    udp_tunnel_ctx;
     336                 :            :         struct sxe2_security_ctx      security_ctx;
     337                 :            :         struct sxe2_repr_context      repr_ctxt;
     338                 :            :         struct sxe2_switchdev_info    switchdev_info;
     339                 :            :         struct sxe2_fc_state_ctxt     fc_state_ctx;
     340                 :            :         bool                          rule_started;
     341                 :            :         bool                          flow_isolated;
     342                 :            :         bool                          flow_isolate_cfg;
     343                 :            :         uint16_t                           dev_port_id;
     344                 :            :         bool                          is_dev_repr;
     345                 :            :         uint64_t                           cap_flags;
     346                 :            :         enum sxe2_dev_type            dev_type;
     347                 :            :         struct rte_ether_addr           mac_addr;
     348                 :            :         uint8_t                              port_idx;
     349                 :            :         uint8_t                              pf_idx;
     350                 :            :         uint32_t                             tx_mode_flags;
     351                 :            :         uint32_t                             rx_mode_flags;
     352                 :            :         uint8_t                              started;
     353                 :            : };
     354                 :            : 
     355                 :            : #define SXE2_DEV_PRIVATE_TO_ADAPTER(dev) \
     356                 :            :         ((struct sxe2_adapter *)(dev)->data->dev_private)
     357                 :            : 
     358                 :            : void *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
     359                 :            :                             enum sxe2_pci_map_resource res_type,
     360                 :            :                             uint16_t idx_in_func);
     361                 :            : 
     362                 :            : bool sxe2_ethdev_check(struct rte_eth_dev *dev);
     363                 :            : 
     364                 :            : uint32_t sxe2_sched_mode_get(struct sxe2_adapter *adapter);
     365                 :            : 
     366                 :            : struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
     367                 :            :                                                     enum sxe2_pci_map_resource res_type);
     368                 :            : 
     369                 :            : int32_t sxe2_dev_pci_seg_map(struct sxe2_adapter *adapter,
     370                 :            :                              enum sxe2_pci_map_resource res_type,
     371                 :            :                              uint64_t org_len, uint64_t org_offset);
     372                 :            : 
     373                 :            : int32_t sxe2_dev_pci_res_seg_map(struct sxe2_adapter *adapter,
     374                 :            :                                  uint32_t res_type,
     375                 :            :                                  uint32_t item_cnt,
     376                 :            :                                  uint32_t item_base);
     377                 :            : 
     378                 :            : void sxe2_pci_map_write_reg(struct sxe2_adapter *adapter,
     379                 :            :                 enum sxe2_pci_map_resource res_type, uint16_t idx_in_func, uint32_t value);
     380                 :            : 
     381                 :            : uint32_t sxe2_pci_map_read_reg(struct sxe2_adapter *adapter,
     382                 :            :                 enum sxe2_pci_map_resource res_type, uint16_t idx_in_func);
     383                 :            : 
     384                 :            : void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, uint32_t res_type);
     385                 :            : 
     386                 :            : int32_t sxe2_dev_pci_map_init(struct rte_eth_dev *dev);
     387                 :            : 
     388                 :            : void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, uint32_t res_type);
     389                 :            : 
     390                 :            : int32_t sxe2_udp_tunnel_port_del_common(struct sxe2_adapter *ad,
     391                 :            :                 enum sxe2_udp_tunnel_protocol tunnel_proto, uint16_t udp_port);
     392                 :            : 
     393                 :            : int32_t sxe2_udp_tunnel_port_add_common(struct sxe2_adapter *ad,
     394                 :            :                 enum sxe2_udp_tunnel_protocol tunnel_proto, uint16_t udp_port);
     395                 :            : 
     396                 :            : void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev);
     397                 :            : 
     398                 :            : void sxe2_eth_uinit(struct rte_eth_dev *dev);
     399                 :            : 
     400                 :            : static inline bool
     401                 :          0 : sxe2_dev_port_vlan_check(struct rte_eth_dev *dev)
     402                 :            : {
     403         [ #  # ]:          0 :         struct sxe2_adapter *ad = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
     404                 :            : 
     405   [ #  #  #  # ]:          0 :         return ad->filter_ctxt.vlan_info.port_vlan_exist;
     406                 :            : }
     407                 :            : 
     408                 :            : #endif /* SXE2_ETHDEV_H */

Generated by: LCOV version 1.14