LCOV - code coverage report
Current view: top level - drivers/net/sxe2 - sxe2_cmd_chnl.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1216 0.0 %
Date: 2026-10-01 18:19:24 Functions: 0 66 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 374 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                 :            : #include "sxe2_ioctl_chnl_func.h"
       6                 :            : #include "sxe2_drv_cmd.h"
       7                 :            : #include "sxe2_cmd_chnl.h"
       8                 :            : #include "sxe2_ethdev.h"
       9                 :            : #include "sxe2_common_log.h"
      10                 :            : 
      11                 :            : static union sxe2_drv_trace_info sxe2_drv_trace_id;
      12                 :            : 
      13                 :          0 : static void sxe2_drv_trace_id_alloc(uint64_t *trace_id)
      14                 :            : {
      15                 :          0 :         union sxe2_drv_trace_info *trace = NULL;
      16                 :          0 :         uint64_t trace_id_count = 0;
      17                 :            : 
      18                 :          0 :         trace = &sxe2_drv_trace_id;
      19                 :            : 
      20                 :          0 :         trace_id_count = trace->sxe2_drv_trace_id_param.count;
      21                 :          0 :         ++trace_id_count;
      22                 :          0 :         trace->sxe2_drv_trace_id_param.count =
      23                 :          0 :                         (trace_id_count & SXE2_DRV_TRACE_ID_COUNT_MASK);
      24                 :            : 
      25                 :          0 :         *trace_id = trace->id;
      26                 :            : }
      27                 :            : 
      28                 :          0 : static void __sxe2_drv_cmd_params_fill(struct sxe2_adapter *adapter,
      29                 :            :                 struct sxe2_drv_cmd_params *cmd, uint32_t opc,
      30                 :            :                 void *in_data, uint32_t in_len, void *out_data, uint32_t out_len)
      31                 :            : {
      32                 :          0 :         cmd->timeout = SXE2_DRV_CMD_DFLT_TIMEOUT;
      33                 :          0 :         cmd->opcode  = opc;
      34                 :          0 :         cmd->vsi_id  = adapter->vsi_ctxt.dpdk_vsi_id;
      35                 :          0 :         cmd->repr_id = (adapter->repr_priv_data != NULL) ?
      36                 :            :                         adapter->repr_priv_data->repr_id : 0xFFFF;
      37                 :          0 :         cmd->req_len = in_len;
      38                 :          0 :         cmd->req_data = in_data;
      39                 :          0 :         cmd->resp_len = out_len;
      40                 :          0 :         cmd->resp_data = out_data;
      41                 :            : 
      42                 :          0 :         sxe2_drv_trace_id_alloc(&cmd->trace_id);
      43                 :            : }
      44                 :            : 
      45                 :            : #define sxe2_drv_cmd_params_fill(adapter, cmd, opc, in_data, in_len, out_data, out_len) \
      46                 :            :         do { \
      47                 :            :                 struct sxe2_adapter *_ad = (adapter); \
      48                 :            :                 PMD_DEV_LOG_DEBUG(_ad, DRV, "cmd opcode:%s", #opc); \
      49                 :            :                 __sxe2_drv_cmd_params_fill(_ad, cmd, opc, in_data, in_len, out_data, out_len); \
      50                 :            :         } while (0)
      51                 :            : 
      52                 :          0 : int32_t sxe2_drv_dev_caps_get(struct sxe2_adapter *adapter, struct sxe2_drv_dev_caps_resp *dev_caps)
      53                 :            : {
      54                 :          0 :         int32_t ret = 0;
      55                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
      56                 :          0 :         struct sxe2_drv_cmd_params param = {0};
      57                 :            : 
      58         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_DEV_GET_CAPS,
      59                 :            :                         NULL, 0, dev_caps,
      60                 :            :                         sizeof(struct sxe2_drv_dev_caps_resp));
      61                 :            : 
      62                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
      63         [ #  # ]:          0 :         if (ret)
      64                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "get dev caps failed, ret=%d", ret);
      65                 :            : 
      66                 :          0 :         return ret;
      67                 :            : }
      68                 :            : 
      69                 :          0 : int32_t sxe2_drv_switchdev_info_get(struct sxe2_adapter *adapter,
      70                 :            :                                     struct sxe2_switchdev_info *switchdev_info)
      71                 :            : {
      72                 :          0 :         int32_t ret = 0;
      73                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
      74                 :          0 :         struct sxe2_drv_cmd_params param = {0};
      75                 :            : 
      76         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_DEV_GET_SWITCHDEV_INFO,
      77                 :            :                                  NULL, 0, switchdev_info,
      78                 :            :                                  sizeof(struct sxe2_switchdev_info));
      79                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
      80         [ #  # ]:          0 :         if (ret)
      81                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "get switchdev info failed, ret=%d", ret);
      82                 :            : 
      83                 :          0 :         return ret;
      84                 :            : }
      85                 :            : 
      86                 :          0 : int32_t sxe2_drv_dev_info_get(struct sxe2_adapter *adapter,
      87                 :            :                                 struct sxe2_drv_dev_info_resp *dev_info_resp)
      88                 :            : {
      89                 :          0 :         int32_t ret = 0;
      90                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
      91                 :          0 :         struct sxe2_drv_cmd_params param = {0};
      92                 :            : 
      93         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_DEV_GET_INFO,
      94                 :            :                         NULL, 0, dev_info_resp,
      95                 :            :                         sizeof(struct sxe2_drv_dev_info_resp));
      96                 :            : 
      97                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
      98         [ #  # ]:          0 :         if (ret)
      99                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "get dev info failed, ret=%d", ret);
     100                 :            : 
     101                 :          0 :         return ret;
     102                 :            : }
     103                 :            : 
     104                 :          0 : int32_t sxe2_drv_fc_state_get(struct sxe2_adapter *adapter,
     105                 :            :                               struct sxe2_drv_vsi_fc_get_resp *dev_fc_state_resp)
     106                 :            : {
     107                 :          0 :         int32_t ret = 0;
     108                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     109                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     110                 :          0 :         struct sxe2_drv_vsi_fc_get_req req = {0};
     111                 :            : 
     112                 :          0 :         req.vsi_id = adapter->vsi_ctxt.main_vsi->vsi_id;
     113         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VSI_FC_GET,
     114                 :            :                                 &req, sizeof(req),
     115                 :            :                                 dev_fc_state_resp,
     116                 :            :                                 sizeof(*dev_fc_state_resp));
     117                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     118         [ #  # ]:          0 :         if (ret) {
     119                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "get fc state failed, ret=%d", ret);
     120                 :          0 :                 ret = -EIO;
     121                 :            :         }
     122                 :          0 :         return ret;
     123                 :            : }
     124                 :            : 
     125                 :          0 : int32_t sxe2_drv_dev_fw_info_get(struct sxe2_adapter *adapter,
     126                 :            :                                 struct sxe2_drv_dev_fw_info_resp *dev_fw_info_resp)
     127                 :            : {
     128                 :          0 :         int32_t ret = 0;
     129                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     130                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     131                 :            : 
     132         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_DEV_GET_FW_INFO,
     133                 :            :                         NULL, 0, dev_fw_info_resp,
     134                 :            :                         sizeof(struct sxe2_drv_dev_fw_info_resp));
     135                 :            : 
     136                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     137         [ #  # ]:          0 :         if (ret)
     138                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "get dev fw info failed, ret=%d", ret);
     139                 :            : 
     140                 :          0 :         return ret;
     141                 :            : }
     142                 :            : 
     143                 :          0 : int32_t sxe2_drv_vsi_add(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi)
     144                 :            : {
     145                 :          0 :         int32_t ret = 0;
     146                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     147                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     148                 :          0 :         struct sxe2_drv_vsi_create_req_resp vsi_req = {0};
     149                 :          0 :         struct sxe2_drv_vsi_create_req_resp vsi_resp = {0};
     150                 :            : 
     151                 :          0 :         vsi_req.vsi_id = vsi->vsi_id;
     152                 :            : 
     153                 :          0 :         vsi_req.used_queues.queues_cnt = RTE_MIN(vsi->txqs.q_cnt, vsi->rxqs.q_cnt);
     154                 :          0 :         vsi_req.used_queues.base_idx_in_pf = vsi->txqs.base_idx_in_func;
     155                 :          0 :         vsi_req.used_msix.msix_vectors_cnt = vsi->irqs.avail_cnt;
     156                 :          0 :         vsi_req.used_msix.base_idx_in_func = vsi->irqs.base_idx_in_pf;
     157                 :            : 
     158         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VSI_CREATE,
     159                 :            :                         &vsi_req,  sizeof(struct sxe2_drv_vsi_create_req_resp),
     160                 :            :                         &vsi_resp, sizeof(struct sxe2_drv_vsi_create_req_resp));
     161                 :            : 
     162                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     163         [ #  # ]:          0 :         if (ret) {
     164                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "dev add vsi failed, ret=%d", ret);
     165                 :          0 :                 goto l_end;
     166                 :            :         }
     167                 :            : 
     168                 :          0 :         vsi->vsi_id = vsi_resp.vsi_id;
     169                 :          0 :         vsi->vsi_type = vsi_resp.vsi_type;
     170                 :            : 
     171                 :          0 : l_end:
     172                 :          0 :         return ret;
     173                 :            : }
     174                 :            : 
     175                 :          0 : int32_t sxe2_drv_vsi_del(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi)
     176                 :            : {
     177                 :          0 :         int32_t ret = 0;
     178                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     179                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     180                 :          0 :         struct sxe2_drv_vsi_free_req vsi_req = {0};
     181                 :            : 
     182                 :          0 :         vsi_req.vsi_id = vsi->vsi_id;
     183                 :            : 
     184         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VSI_FREE,
     185                 :            :                                 &vsi_req, sizeof(struct sxe2_drv_vsi_free_req),
     186                 :            :                                 NULL, 0);
     187                 :            : 
     188                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     189         [ #  # ]:          0 :         if (ret)
     190                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "dev del vsi failed, ret=%d", ret);
     191                 :            : 
     192                 :          0 :         return ret;
     193                 :            : }
     194                 :            : 
     195                 :            : #define SXE2_RXQ_CTXT_CFG_BUF_LEN_ALIGN  (1 << 7)
     196                 :            : #define SXE2_RX_HDR_SIZE 256
     197                 :            : 
     198                 :          0 : static int32_t sxe2_rxq_buf_split_fill(struct sxe2_rx_queue *rxq,
     199                 :            :                                    struct sxe2_drv_rxq_ctxt *ctxt)
     200                 :            : {
     201                 :          0 :         uint32_t proto_hdr;
     202                 :            : 
     203                 :          0 :         proto_hdr = rxq->rx_seg[0].proto_hdr;
     204         [ #  # ]:          0 :         if (proto_hdr == RTE_PTYPE_UNKNOWN) {
     205                 :          0 :                 PMD_LOG_ERR(RX, "Buffer split protocol must be configured");
     206                 :          0 :                 return -EINVAL;
     207                 :            :         }
     208                 :            : 
     209   [ #  #  #  # ]:          0 :         switch (proto_hdr & RTE_PTYPE_L4_MASK) {
     210                 :          0 :         case RTE_PTYPE_L4_TCP:
     211                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_L4_TCP;
     212                 :          0 :                 goto l_end;
     213                 :          0 :         case RTE_PTYPE_L4_UDP:
     214                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_L4_UDP;
     215                 :          0 :                 goto l_end;
     216                 :          0 :         case RTE_PTYPE_L4_SCTP:
     217                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_L4_SCTP;
     218                 :          0 :                 goto l_end;
     219                 :            :         }
     220                 :            : 
     221      [ #  #  # ]:          0 :         switch (proto_hdr & RTE_PTYPE_L3_MASK) {
     222                 :          0 :         case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
     223                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_L3_IPV4;
     224                 :          0 :                 goto l_end;
     225                 :          0 :         case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
     226                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_L3_IPV6;
     227                 :          0 :                 goto l_end;
     228                 :            :         }
     229                 :            : 
     230         [ #  # ]:          0 :         switch (proto_hdr & RTE_PTYPE_L2_MASK) {
     231                 :          0 :         case RTE_PTYPE_L2_ETHER:
     232                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_L2_ETHER;
     233                 :          0 :                 goto l_end;
     234                 :            :         }
     235                 :            : 
     236   [ #  #  #  # ]:          0 :         switch (proto_hdr & RTE_PTYPE_INNER_L4_MASK) {
     237                 :          0 :         case RTE_PTYPE_INNER_L4_TCP:
     238                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_TCP;
     239                 :          0 :                 goto l_end;
     240                 :          0 :         case RTE_PTYPE_INNER_L4_UDP:
     241                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_UDP;
     242                 :          0 :                 goto l_end;
     243                 :          0 :         case RTE_PTYPE_INNER_L4_SCTP:
     244                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_SCTP;
     245                 :          0 :                 goto l_end;
     246                 :            :         }
     247                 :            : 
     248      [ #  #  # ]:          0 :         switch (proto_hdr & RTE_PTYPE_INNER_L3_MASK) {
     249                 :          0 :         case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
     250                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_INNER_L3_IPV4;
     251                 :          0 :                 goto l_end;
     252                 :          0 :         case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
     253                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_INNER_L3_IPV6;
     254                 :          0 :                 goto l_end;
     255                 :            :         }
     256                 :            : 
     257         [ #  # ]:          0 :         switch (proto_hdr & RTE_PTYPE_INNER_L2_MASK) {
     258                 :          0 :         case RTE_PTYPE_INNER_L2_ETHER:
     259                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_INNER_L2_ETHER;
     260                 :          0 :                 goto l_end;
     261                 :            :         }
     262                 :            : 
     263         [ #  # ]:          0 :         switch (proto_hdr & RTE_PTYPE_TUNNEL_MASK) {
     264                 :          0 :         case RTE_PTYPE_TUNNEL_GRENAT:
     265                 :          0 :                 ctxt->split_type_mask = SXE2_PTYPE_TUNNEL_GRENAT;
     266                 :          0 :                 goto l_end;
     267                 :            :         }
     268                 :            : 
     269                 :          0 :         PMD_LOG_ERR(RX, "Buffer split protocol is not supported");
     270                 :          0 :         return -ENOTSUP;
     271                 :          0 : l_end:
     272                 :          0 :         ctxt->hdr_len = SXE2_RX_HDR_SIZE;
     273                 :          0 :         return 0;
     274                 :            : }
     275                 :            : 
     276                 :          0 : static int32_t sxe2_rxq_ctxt_cfg_fill(struct sxe2_rx_queue *rxq,
     277                 :            :                 struct sxe2_drv_rxq_cfg_req *req, uint16_t rxq_cnt)
     278                 :            : {
     279                 :          0 :         struct sxe2_adapter *adapter = rxq->vsi->adapter;
     280                 :          0 :         struct sxe2_drv_rxq_ctxt *ctxt = req->cfg;
     281                 :          0 :         struct rte_eth_dev_data *dev_data = adapter->dev_info.dev_data;
     282                 :          0 :         int32_t ret = 0;
     283                 :            : 
     284                 :          0 :         req->vsi_id = adapter->vsi_ctxt.main_vsi->vsi_id;
     285                 :          0 :         req->q_cnt = rxq_cnt;
     286                 :          0 :         req->max_frame_size = dev_data->mtu + SXE2_ETH_OVERHEAD;
     287                 :            : 
     288         [ #  # ]:          0 :         if (adapter->is_dev_repr)
     289                 :          0 :                 ctxt->queue_id = adapter->repr_priv_data->repr_q_id;
     290                 :            :         else
     291                 :          0 :                 ctxt->queue_id = rxq->queue_id;
     292                 :            : 
     293                 :          0 :         ctxt->depth = rxq->ring_depth;
     294                 :          0 :         ctxt->buf_len = RTE_ALIGN(rxq->rx_buf_len, SXE2_RXQ_CTXT_CFG_BUF_LEN_ALIGN);
     295                 :          0 :         ctxt->dma_addr = rxq->base_addr;
     296                 :            : 
     297         [ #  # ]:          0 :         if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO) {
     298                 :          0 :                 ctxt->lro_en = 1;
     299                 :          0 :                 ctxt->max_lro_size = dev_data->dev_conf.rxmode.max_lro_pkt_size;
     300                 :            :         } else {
     301                 :          0 :                 ctxt->lro_en = 0;
     302                 :            :         }
     303                 :            : 
     304         [ #  # ]:          0 :         if (rxq->offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
     305                 :          0 :                 ctxt->keep_crc_en = 1;
     306                 :            :         else
     307                 :          0 :                 ctxt->keep_crc_en = 0;
     308                 :            : 
     309         [ #  # ]:          0 :         if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
     310                 :          0 :                 ret = sxe2_rxq_buf_split_fill(rxq, ctxt);
     311         [ #  # ]:          0 :                 if (ret)
     312                 :          0 :                         goto l_end;
     313                 :          0 :                 ctxt->split_en = 1;
     314                 :            :         } else {
     315                 :          0 :                 ctxt->split_en = 0;
     316                 :            :         }
     317                 :            : 
     318                 :          0 :         ctxt->desc_size = sizeof(union sxe2_rx_desc);
     319                 :          0 : l_end:
     320                 :          0 :         return ret;
     321                 :            : }
     322                 :            : 
     323                 :          0 : int32_t sxe2_drv_rxq_ctxt_cfg(struct sxe2_adapter *adapter,
     324                 :            :                               struct sxe2_rx_queue *rxq,
     325                 :            :                               uint16_t rxq_cnt)
     326                 :            : {
     327                 :          0 :         int32_t ret = 0;
     328                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     329                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     330                 :          0 :         struct sxe2_drv_rxq_cfg_req *req = NULL;
     331                 :          0 :         uint16_t len = 0;
     332                 :            : 
     333                 :          0 :         len = sizeof(*req) + rxq_cnt * sizeof(struct sxe2_drv_rxq_ctxt);
     334                 :          0 :         req = rte_zmalloc("sxe2_rxq_cfg", len, 0);
     335         [ #  # ]:          0 :         if (req == NULL) {
     336                 :          0 :                 PMD_LOG_ERR(RX, "rxq cfg mem alloc failed");
     337                 :          0 :                 ret = -ENOMEM;
     338                 :          0 :                 goto l_end;
     339                 :            :         }
     340                 :            : 
     341                 :          0 :         ret = sxe2_rxq_ctxt_cfg_fill(rxq, req, rxq_cnt);
     342         [ #  # ]:          0 :         if (ret) {
     343                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "rxq cfg failed, ret=%d", ret);
     344                 :          0 :                 ret = -EINVAL;
     345                 :          0 :                 goto l_end;
     346                 :            :         }
     347                 :            : 
     348         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_RXQ_CFG_ENABLE,
     349                 :            :                         req, len, NULL, 0);
     350                 :            : 
     351                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     352         [ #  # ]:          0 :         if (ret)
     353                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "rxq cfg failed, ret=%d", ret);
     354                 :            : 
     355                 :          0 : l_end:
     356                 :          0 :         rte_free(req);
     357                 :          0 :         return ret;
     358                 :            : }
     359                 :            : 
     360                 :          0 : static void sxe2_txq_ctxt_cfg_fill(struct sxe2_tx_queue *txq,
     361                 :            :                                    struct sxe2_drv_txq_cfg_req *req,
     362                 :            :                                    uint16_t txq_cnt)
     363                 :            : {
     364                 :          0 :         struct sxe2_adapter *adapter = txq->vsi->adapter;
     365                 :          0 :         struct sxe2_drv_txq_ctxt *ctxt = req->cfg;
     366                 :          0 :         uint16_t q_idx = 0;
     367                 :            : 
     368                 :          0 :         req->vsi_id = txq->vsi->vsi_id;
     369                 :          0 :         req->q_cnt = txq_cnt;
     370                 :            : 
     371         [ #  # ]:          0 :         for (q_idx = 0; q_idx < txq_cnt; q_idx++) {
     372                 :          0 :                 ctxt = &req->cfg[q_idx];
     373                 :          0 :                 ctxt->depth = txq[q_idx].ring_depth;
     374                 :          0 :                 ctxt->dma_addr = txq[q_idx].base_addr;
     375         [ #  # ]:          0 :                 if (adapter->is_dev_repr)
     376                 :          0 :                         ctxt->queue_id = adapter->repr_priv_data->repr_q_id;
     377                 :            :                 else
     378                 :          0 :                         ctxt->queue_id = txq[q_idx].queue_id;
     379                 :            : 
     380                 :          0 :                 ctxt->sched_mode = sxe2_sched_mode_get(adapter);
     381                 :            :         }
     382                 :          0 : }
     383                 :            : 
     384                 :          0 : int32_t sxe2_drv_txq_ctxt_cfg(struct sxe2_adapter *adapter,
     385                 :            :                               struct sxe2_tx_queue *txq,
     386                 :            :                               uint16_t txq_cnt)
     387                 :            : {
     388                 :          0 :         int32_t ret = 0;
     389                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     390                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     391                 :          0 :         struct sxe2_drv_txq_cfg_req *req;
     392                 :          0 :         uint16_t len = 0;
     393                 :            : 
     394                 :          0 :         len = sizeof(*req) + txq_cnt * sizeof(struct sxe2_drv_txq_ctxt);
     395                 :          0 :         req = rte_zmalloc("sxe2_txq_cfg", len, 0);
     396         [ #  # ]:          0 :         if (req == NULL) {
     397                 :          0 :                 PMD_LOG_ERR(TX, "txq cfg mem alloc failed");
     398                 :          0 :                 ret = -ENOMEM;
     399                 :          0 :                 goto l_end;
     400                 :            :         }
     401                 :            : 
     402                 :          0 :         sxe2_txq_ctxt_cfg_fill(txq, req, txq_cnt);
     403                 :            : 
     404         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_TXQ_CFG_ENABLE,
     405                 :            :                         req, len, NULL, 0);
     406                 :            : 
     407                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     408         [ #  # ]:          0 :         if (ret)
     409                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "txq cfg failed, ret=%d", ret);
     410                 :            : 
     411                 :          0 : l_end:
     412                 :          0 :         rte_free(req);
     413                 :          0 :         return ret;
     414                 :            : }
     415                 :            : 
     416                 :          0 : int32_t sxe2_drv_rxq_switch(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq, bool enable)
     417                 :            : {
     418                 :          0 :         int32_t ret = 0;
     419                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     420                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     421                 :          0 :         struct sxe2_drv_q_switch_req req;
     422                 :            : 
     423                 :          0 :         req.vsi_id = rte_cpu_to_le_16(rxq->vsi->vsi_id);
     424         [ #  # ]:          0 :         if (adapter->is_dev_repr)
     425                 :          0 :                 req.q_idx = adapter->repr_priv_data->repr_q_id;
     426                 :            :         else
     427                 :          0 :                 req.q_idx = rxq->queue_id;
     428                 :            : 
     429                 :          0 :         req.is_enable  = (uint8_t)enable;
     430         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_RXQ_DISABLE,
     431                 :            :                         &req, sizeof(req), NULL, 0);
     432                 :            : 
     433                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     434         [ #  # ]:          0 :         if (ret)
     435                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "rxq switch failed, enable: %d, ret:%d",
     436                 :            :                         enable, ret);
     437                 :            : 
     438                 :          0 :         return ret;
     439                 :            : }
     440                 :            : 
     441                 :          0 : int32_t sxe2_drv_txq_switch(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq, bool enable)
     442                 :            : {
     443                 :          0 :         int32_t ret = 0;
     444                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     445                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     446                 :          0 :         struct sxe2_drv_q_switch_req req;
     447                 :            : 
     448                 :          0 :         req.vsi_id = rte_cpu_to_le_16(txq->vsi->vsi_id);
     449         [ #  # ]:          0 :         if (adapter->is_dev_repr)
     450                 :          0 :                 req.q_idx = adapter->repr_priv_data->repr_q_id;
     451                 :            :         else
     452                 :          0 :                 req.q_idx = txq->queue_id;
     453                 :            : 
     454                 :          0 :         req.is_enable  = (uint8_t)enable;
     455                 :          0 :         req.sched_mode = sxe2_sched_mode_get(adapter);
     456         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_TXQ_DISABLE,
     457                 :            :                         &req, sizeof(req), NULL, 0);
     458                 :            : 
     459                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     460         [ #  # ]:          0 :         if (ret) {
     461                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "txq switch failed, enable: %d, ret:%d",
     462                 :            :                                 enable, ret);
     463                 :            :         }
     464                 :            : 
     465                 :          0 :         return ret;
     466                 :            : }
     467                 :            : 
     468                 :          0 : int32_t sxe2_drv_vsi_info_get(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi)
     469                 :            : {
     470                 :          0 :         int32_t ret = 0;
     471                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     472                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     473                 :          0 :         struct sxe2_drv_vsi_info_get_req vsi_info_get_req = {0};
     474                 :          0 :         struct sxe2_drv_vsi_info_get_resp vsi_info_get_resp = {0};
     475                 :            : 
     476                 :          0 :         vsi_info_get_req.vsi_id = vsi->vsi_id;
     477         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VSI_INFO_GET,
     478                 :            :                         &vsi_info_get_req, sizeof(vsi_info_get_req),
     479                 :            :                         &vsi_info_get_resp, sizeof(vsi_info_get_resp));
     480                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     481         [ #  # ]:          0 :         if (ret) {
     482                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "vsi %u info get failed, ret=%d", vsi->vsi_id, ret);
     483                 :          0 :                 goto l_end;
     484                 :            :         }
     485                 :            : 
     486                 :          0 :         vsi->txqs.q_cnt = vsi_info_get_resp.used_queues.queues_cnt;
     487                 :          0 :         vsi->txqs.base_idx_in_func = vsi_info_get_resp.used_queues.base_idx_in_pf;
     488                 :            : 
     489                 :          0 :         vsi->rxqs.q_cnt = vsi_info_get_resp.used_queues.queues_cnt;
     490                 :          0 :         vsi->rxqs.base_idx_in_func = vsi_info_get_resp.used_queues.base_idx_in_pf;
     491                 :            : 
     492                 :          0 :         vsi->irqs.avail_cnt = vsi_info_get_resp.used_msix.msix_vectors_cnt;
     493                 :          0 :         vsi->irqs.base_idx_in_pf = vsi_info_get_resp.used_msix.base_idx_in_func;
     494                 :            : 
     495                 :          0 : l_end:
     496                 :          0 :         return ret;
     497                 :            : }
     498                 :            : 
     499                 :          0 : int32_t sxe2_drv_mac_link_status_get(struct sxe2_adapter *adapter)
     500                 :            : {
     501                 :          0 :         int32_t ret = 0;
     502                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     503                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     504                 :          0 :         struct sxe2_drv_link_info_resp resp = {0};
     505                 :            : 
     506         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_LINK_STATUS_GET,
     507                 :            :                                  NULL, 0,
     508                 :            :                                  &resp, sizeof(resp));
     509                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     510         [ #  # ]:          0 :         if (ret) {
     511                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "link status get failed, ret=%d", ret);
     512                 :          0 :                 goto l_end;
     513                 :            :         }
     514                 :          0 :         adapter->link_ctxt.speed = resp.speed;
     515                 :          0 :         adapter->link_ctxt.link_up = resp.status;
     516                 :            : 
     517                 :          0 : l_end:
     518                 :          0 :         return ret;
     519                 :            : }
     520                 :            : 
     521                 :          0 : int32_t sxe2_drv_rxq_bind_irq(struct sxe2_adapter *adapter, uint16_t rxq_idx, uint16_t msix_idx)
     522                 :            : {
     523                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     524                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     525                 :          0 :         struct sxe2_drv_queue_irq_bind_req req = {0};
     526                 :          0 :         int32_t ret = 0;
     527                 :            : 
     528                 :          0 :         req.msix_idx = msix_idx;
     529                 :          0 :         req.q_idx = rxq_idx;
     530                 :          0 :         req.itr_idx = 0;
     531                 :          0 :         req.bind = true;
     532                 :            : 
     533         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_EVT_IRQ_BAND_RXQ,
     534                 :            :                                  &req, sizeof(req),
     535                 :            :                                  NULL, 0);
     536                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     537         [ #  # ]:          0 :         if (ret)
     538                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "rxq %u bind irq failed, ret=%d", rxq_idx, ret);
     539                 :            : 
     540                 :          0 :         return ret;
     541                 :            : }
     542                 :            : 
     543                 :          0 : int32_t sxe2_drv_rxq_unbind_irq(struct sxe2_adapter *adapter, uint16_t rxq_idx)
     544                 :            : {
     545                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     546                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     547                 :          0 :         struct sxe2_drv_queue_irq_bind_req req = {0};
     548                 :          0 :         int32_t ret = 0;
     549                 :            : 
     550                 :          0 :         req.bind = false;
     551                 :          0 :         req.q_idx = rxq_idx;
     552                 :            : 
     553         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_EVT_IRQ_BAND_RXQ,
     554                 :            :                                  &req, sizeof(req),
     555                 :            :                                  NULL, 0);
     556                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     557         [ #  # ]:          0 :         if (ret)
     558                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "rxq %u unbind irq failed, ret=%d", rxq_idx, ret);
     559                 :            : 
     560                 :          0 :         return ret;
     561                 :            : }
     562                 :            : 
     563                 :          0 : int32_t sxe2_drv_get_mac_stats(struct sxe2_adapter *adapter)
     564                 :            : {
     565                 :          0 :         int32_t ret = 0;
     566                 :          0 :         uint8_t i = 0;
     567                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     568                 :          0 :         struct sxe2_vsi *vsi = adapter->vsi_ctxt.main_vsi;
     569                 :          0 :         struct sxe2_stats *stats = &vsi->vsi_stats.vsi_hw_stats;
     570                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     571                 :          0 :         struct sxe2_drv_mac_stats_resp resp = {0};
     572                 :            : 
     573         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_MAC_STATS_GET,
     574                 :            :                                  NULL, 0,
     575                 :            :                                  &resp, sizeof(resp));
     576                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     577         [ #  # ]:          0 :         if (ret) {
     578                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "vsi stats get failed, ret=%d", ret);
     579                 :          0 :                 goto l_end;
     580                 :            :         }
     581                 :            : 
     582                 :          0 :         stats->rx_out_of_buffer        = rte_le_to_cpu_64(resp.rx_out_of_buffer);
     583                 :          0 :         stats->rx_qblock_drop          = rte_le_to_cpu_64(resp.rx_qblock_drop);
     584                 :          0 :         stats->tx_frame_good           = rte_le_to_cpu_64(resp.tx_frame_good);
     585                 :          0 :         stats->rx_frame_good           = rte_le_to_cpu_64(resp.rx_frame_good);
     586                 :          0 :         stats->rx_crc_errors           = rte_le_to_cpu_64(resp.rx_crc_errors);
     587                 :          0 :         stats->tx_bytes_good           = rte_le_to_cpu_64(resp.tx_bytes_good);
     588                 :          0 :         stats->rx_bytes_good           = rte_le_to_cpu_64(resp.rx_bytes_good);
     589                 :          0 :         stats->tx_multicast_good       = rte_le_to_cpu_64(resp.tx_multicast_good);
     590                 :          0 :         stats->tx_broadcast_good       = rte_le_to_cpu_64(resp.tx_broadcast_good);
     591                 :          0 :         stats->rx_multicast_good       = rte_le_to_cpu_64(resp.rx_multicast_good);
     592                 :          0 :         stats->rx_broadcast_good       = rte_le_to_cpu_64(resp.rx_broadcast_good);
     593                 :          0 :         stats->rx_len_errors           = rte_le_to_cpu_64(resp.rx_len_errors);
     594                 :          0 :         stats->rx_out_of_range_errors  = rte_le_to_cpu_64(resp.rx_out_of_range_errors);
     595                 :          0 :         stats->rx_oversize_pkts_phy    = rte_le_to_cpu_64(resp.rx_oversize_pkts_phy);
     596                 :          0 :         stats->rx_symbol_err        = rte_le_to_cpu_64(resp.rx_symbol_err);
     597                 :          0 :         stats->rx_pause_frame               = rte_le_to_cpu_64(resp.rx_pause_frame);
     598                 :          0 :         stats->tx_pause_frame               = rte_le_to_cpu_64(resp.tx_pause_frame);
     599                 :          0 :         stats->rx_discards_phy              = rte_le_to_cpu_64(resp.rx_discards_phy);
     600                 :          0 :         stats->rx_discards_ips_phy     = rte_le_to_cpu_64(resp.rx_discards_ips_phy);
     601                 :          0 :         stats->tx_dropped_link_down    = rte_le_to_cpu_64(resp.tx_dropped_link_down);
     602                 :          0 :         stats->rx_undersize_good       = rte_le_to_cpu_64(resp.rx_undersize_good);
     603                 :          0 :         stats->rx_runt_error        = rte_le_to_cpu_64(resp.rx_runt_error);
     604                 :          0 :         stats->tx_bytes_good_bad       = rte_le_to_cpu_64(resp.tx_bytes_good_bad);
     605                 :          0 :         stats->tx_frame_good_bad       = rte_le_to_cpu_64(resp.tx_frame_good_bad);
     606                 :          0 :         stats->rx_jabbers              = rte_le_to_cpu_64(resp.rx_jabbers);
     607                 :          0 :         stats->rx_size_64              = rte_le_to_cpu_64(resp.rx_size_64);
     608                 :          0 :         stats->rx_size_65_127          = rte_le_to_cpu_64(resp.rx_size_65_127);
     609                 :          0 :         stats->rx_size_128_255         = rte_le_to_cpu_64(resp.rx_size_128_255);
     610                 :          0 :         stats->rx_size_256_511         = rte_le_to_cpu_64(resp.rx_size_256_511);
     611                 :          0 :         stats->rx_size_512_1023        = rte_le_to_cpu_64(resp.rx_size_512_1023);
     612                 :          0 :         stats->rx_size_1024_1522       = rte_le_to_cpu_64(resp.rx_size_1024_1522);
     613                 :          0 :         stats->rx_size_1523_max        = rte_le_to_cpu_64(resp.rx_size_1523_max);
     614                 :          0 :         stats->rx_pcs_symbol_err_phy   = rte_le_to_cpu_64(resp.rx_pcs_symbol_err_phy);
     615                 :          0 :         stats->rx_corrected_bits_phy   = rte_le_to_cpu_64(resp.rx_corrected_bits_phy);
     616                 :          0 :         stats->rx_err_lane_0_phy       = rte_le_to_cpu_64(resp.rx_err_lane_0_phy);
     617                 :          0 :         stats->rx_err_lane_1_phy       = rte_le_to_cpu_64(resp.rx_err_lane_1_phy);
     618                 :          0 :         stats->rx_err_lane_2_phy       = rte_le_to_cpu_64(resp.rx_err_lane_2_phy);
     619                 :          0 :         stats->rx_err_lane_3_phy       = rte_le_to_cpu_64(resp.rx_err_lane_3_phy);
     620                 :          0 :         stats->rx_illegal_bytes        = rte_le_to_cpu_64(resp.rx_illegal_bytes);
     621                 :          0 :         stats->rx_oversize_good        = rte_le_to_cpu_64(resp.rx_oversize_good);
     622                 :          0 :         stats->tx_unicast              = rte_le_to_cpu_64(resp.tx_unicast);
     623                 :          0 :         stats->tx_broadcast            = rte_le_to_cpu_64(resp.tx_broadcast);
     624                 :          0 :         stats->tx_multicast            = rte_le_to_cpu_64(resp.tx_multicast);
     625                 :          0 :         stats->tx_vlan_packet_good     = rte_le_to_cpu_64(resp.tx_vlan_packet_good);
     626                 :          0 :         stats->tx_size_64              = rte_le_to_cpu_64(resp.tx_size_64);
     627                 :          0 :         stats->tx_size_65_127          = rte_le_to_cpu_64(resp.tx_size_65_127);
     628                 :          0 :         stats->tx_size_128_255         = rte_le_to_cpu_64(resp.tx_size_128_255);
     629                 :          0 :         stats->tx_size_256_511         = rte_le_to_cpu_64(resp.tx_size_256_511);
     630                 :          0 :         stats->tx_size_512_1023        = rte_le_to_cpu_64(resp.tx_size_512_1023);
     631                 :          0 :         stats->tx_size_1024_1522       = rte_le_to_cpu_64(resp.tx_size_1024_1522);
     632                 :          0 :         stats->tx_size_1523_max        = rte_le_to_cpu_64(resp.tx_size_1523_max);
     633                 :          0 :         stats->tx_underflow_error      = rte_le_to_cpu_64(resp.tx_underflow_error);
     634                 :          0 :         stats->rx_byte_good_bad        = rte_le_to_cpu_64(resp.rx_byte_good_bad);
     635                 :          0 :         stats->rx_frame_good_bad       = rte_le_to_cpu_64(resp.rx_frame_good_bad);
     636                 :          0 :         stats->rx_unicast_good         = rte_le_to_cpu_64(resp.rx_unicast_good);
     637                 :          0 :         stats->rx_vlan_packets         = rte_le_to_cpu_64(resp.rx_vlan_packets);
     638                 :            : 
     639         [ #  # ]:          0 :         for (i = 0; i < SXE2_MAX_USER_PRIORITY; i++) {
     640                 :          0 :                 stats->rx_prio_buf_discard[i]  =
     641                 :          0 :                         rte_le_to_cpu_64(resp.rx_prio_buf_discard[i]);
     642                 :          0 :                 stats->prio_xoff_rx[i]  =
     643                 :          0 :                         rte_le_to_cpu_64(resp.prio_xoff_rx[i]);
     644                 :          0 :                 stats->prio_xoff_tx[i]  =
     645                 :          0 :                         rte_le_to_cpu_64(resp.prio_xoff_tx[i]);
     646                 :          0 :                 stats->prio_xon_rx[i]  =
     647                 :          0 :                         rte_le_to_cpu_64(resp.prio_xon_rx[i]);
     648                 :          0 :                 stats->prio_xon_tx[i]  =
     649                 :          0 :                         rte_le_to_cpu_64(resp.prio_xon_tx[i]);
     650                 :          0 :                 stats->prio_xon_2_xoff[i]  =
     651                 :          0 :                         rte_le_to_cpu_64(resp.prio_xon_2_xoff[i]);
     652                 :            :         }
     653                 :            : 
     654                 :          0 : l_end:
     655                 :          0 :         return ret;
     656                 :            : }
     657                 :            : 
     658                 :          0 : int32_t sxe2_drv_mac_stats_reset(struct sxe2_adapter *adapter)
     659                 :            : {
     660                 :          0 :         int32_t ret = 0;
     661                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     662                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     663                 :            : 
     664         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_MAC_STATS_CLEAR,
     665                 :            :                                  NULL, 0,
     666                 :            :                                  NULL, 0);
     667                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     668         [ #  # ]:          0 :         if (ret) {
     669                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "mac stats reset failed, ret=%d", ret);
     670                 :          0 :                 goto l_end;
     671                 :            :         }
     672                 :            : 
     673                 :          0 : l_end:
     674                 :          0 :         return ret;
     675                 :            : }
     676                 :            : 
     677                 :          0 : int32_t sxe2_drv_get_vsi_stats(struct sxe2_adapter *adapter)
     678                 :            : {
     679                 :          0 :         int32_t ret = 0;
     680                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     681                 :          0 :         struct sxe2_vsi *vsi = adapter->vsi_ctxt.main_vsi;
     682                 :          0 :         struct sxe2_stats *new_stats = &vsi->vsi_stats.vsi_hw_stats;
     683                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     684                 :          0 :         struct sxe2_drv_vsi_stats_req req = {0};
     685                 :          0 :         struct sxe2_drv_vsi_stats_resp resp = {0};
     686                 :            : 
     687                 :          0 :         req.vsi_id = rte_cpu_to_le_16(vsi->vsi_id);
     688                 :          0 :         req.sw_stats.rx_bytes = rte_cpu_to_le_64(vsi->vsi_stats.stats.ibytes);
     689                 :          0 :         req.sw_stats.rx_packets = rte_cpu_to_le_64(vsi->vsi_stats.stats.ipackets);
     690                 :          0 :         req.sw_stats.tx_bytes = rte_cpu_to_le_64(vsi->vsi_stats.stats.obytes);
     691                 :          0 :         req.sw_stats.tx_packets = rte_cpu_to_le_64(vsi->vsi_stats.stats.opackets);
     692                 :            : 
     693         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VSI_STATS_GET,
     694                 :            :                                  &req, sizeof(req),
     695                 :            :                                  &resp, sizeof(resp));
     696                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     697         [ #  # ]:          0 :         if (ret) {
     698                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "vsi stats get failed, ret=%d", ret);
     699                 :          0 :                 goto l_end;
     700                 :            :         }
     701                 :            : 
     702                 :          0 :         new_stats->rx_vsi_unicast_packets   = rte_le_to_cpu_64(resp.rx_vsi_unicast_packets);
     703                 :          0 :         new_stats->rx_vsi_bytes             = rte_le_to_cpu_64(resp.rx_vsi_bytes);
     704                 :          0 :         new_stats->tx_vsi_unicast_packets   = rte_le_to_cpu_64(resp.tx_vsi_unicast_packets);
     705                 :          0 :         new_stats->tx_vsi_bytes             = rte_le_to_cpu_64(resp.tx_vsi_bytes);
     706                 :          0 :         new_stats->rx_vsi_multicast_packets = rte_le_to_cpu_64(resp.rx_vsi_multicast_packets);
     707                 :          0 :         new_stats->tx_vsi_multicast_packets = rte_le_to_cpu_64(resp.tx_vsi_multicast_packets);
     708                 :          0 :         new_stats->rx_vsi_broadcast_packets = rte_le_to_cpu_64(resp.rx_vsi_broadcast_packets);
     709                 :          0 :         new_stats->tx_vsi_broadcast_packets = rte_le_to_cpu_64(resp.tx_vsi_broadcast_packets);
     710                 :          0 :         new_stats->opackets = new_stats->tx_vsi_unicast_packets +
     711                 :          0 :                               new_stats->tx_vsi_multicast_packets +
     712                 :            :                               new_stats->tx_vsi_broadcast_packets;
     713                 :          0 :         new_stats->obytes = new_stats->tx_vsi_bytes;
     714                 :          0 :         new_stats->ipackets = new_stats->rx_vsi_unicast_packets +
     715                 :          0 :                               new_stats->rx_vsi_multicast_packets +
     716                 :            :                               new_stats->rx_vsi_broadcast_packets;
     717                 :          0 :         new_stats->ibytes = new_stats->rx_vsi_bytes;
     718                 :            : 
     719                 :          0 : l_end:
     720                 :          0 :         return ret;
     721                 :            : }
     722                 :            : 
     723                 :          0 : int32_t sxe2_drv_vsi_stats_reset(struct sxe2_adapter *adapter)
     724                 :            : {
     725                 :          0 :         int32_t ret = 0;
     726                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     727                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     728                 :            : 
     729         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VSI_STATS_CLEAR,
     730                 :            :                                  NULL, 0, NULL, 0);
     731                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     732         [ #  # ]:          0 :         if (ret) {
     733                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "vsi stats reset failed, ret=%d", ret);
     734                 :          0 :                 goto l_end;
     735                 :            :         }
     736                 :            : 
     737                 :          0 : l_end:
     738                 :          0 :         return ret;
     739                 :            : }
     740                 :            : 
     741                 :          0 : int32_t sxe2_drv_promisc_config(struct sxe2_adapter *adapter, bool set)
     742                 :            : {
     743                 :          0 :         int32_t ret = 0;
     744                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     745                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     746                 :          0 :         struct sxe2_promisc_filter_cfg_req promisc_filter_cfg_req = {0};
     747                 :            : 
     748                 :          0 :         promisc_filter_cfg_req.vsi_id = adapter->vsi_ctxt.dpdk_vsi_id;
     749                 :          0 :         promisc_filter_cfg_req.is_add = set;
     750                 :          0 :         promisc_filter_cfg_req.type = SXE2_PROMISC_FILTER_TYPE_PROMISC;
     751                 :            : 
     752         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_PROMISC_CFG,
     753                 :            :                                  &promisc_filter_cfg_req,
     754                 :            :                                  sizeof(promisc_filter_cfg_req),
     755                 :            :                                  NULL, 0);
     756                 :            : 
     757                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     758         [ #  # ]:          0 :         if (ret)
     759                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "promisc config failed, ret=%d", ret);
     760                 :            : 
     761                 :          0 :         return ret;
     762                 :            : }
     763                 :            : 
     764                 :          0 : int32_t sxe2_drv_allmulti_config(struct sxe2_adapter *adapter, bool set)
     765                 :            : {
     766                 :          0 :         int32_t ret = 0;
     767                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     768                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     769                 :          0 :         struct sxe2_promisc_filter_cfg_req promisc_filter_cfg_req = {0};
     770                 :            : 
     771                 :          0 :         promisc_filter_cfg_req.vsi_id = adapter->vsi_ctxt.dpdk_vsi_id;
     772                 :          0 :         promisc_filter_cfg_req.is_add = set;
     773                 :          0 :         promisc_filter_cfg_req.type = SXE2_PROMISC_FILTER_TYPE_ALLMULTI;
     774                 :            : 
     775         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_ALLMULTI_CFG,
     776                 :            :                                  &promisc_filter_cfg_req,
     777                 :            :                                  sizeof(promisc_filter_cfg_req),
     778                 :            :                                  NULL, 0);
     779                 :            : 
     780                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     781         [ #  # ]:          0 :         if (ret)
     782                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "allmulti config failed, ret=%d", ret);
     783                 :            : 
     784                 :          0 :         return ret;
     785                 :            : }
     786                 :            : 
     787                 :          0 : int32_t sxe2_drv_switchdev_uplink_config(struct sxe2_adapter *adapter,  bool set)
     788                 :            : {
     789                 :          0 :         int32_t ret = 0;
     790                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     791                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     792                 :          0 :         struct sxe2_switchdev_uplink_info switchdev_uplink_info_req = {0};
     793                 :            : 
     794                 :          0 :         switchdev_uplink_info_req.pf_id = adapter->pf_idx;
     795                 :          0 :         switchdev_uplink_info_req.is_set = set;
     796                 :            : 
     797         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_SWITCH_UPLINK,
     798                 :            :                                  &switchdev_uplink_info_req,
     799                 :            :                                  sizeof(switchdev_uplink_info_req),
     800                 :            :                                  NULL, 0);
     801                 :            : 
     802                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     803         [ #  # ]:          0 :         if (ret)
     804                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "switchdev uplink info config failed, ret=%d", ret);
     805                 :            : 
     806                 :          0 :         return ret;
     807                 :            : }
     808                 :            : 
     809                 :          0 : int32_t sxe2_drv_switchdev_repr_vf_config(struct sxe2_adapter *adapter,
     810                 :            :                                       struct sxe2_switchdev_repr_info *repr_vf,
     811                 :            :                                       bool set)
     812                 :            : {
     813                 :          0 :         int32_t ret = 0;
     814                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     815                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     816                 :          0 :         struct sxe2_switchdev_repr_info switchdev_repr_info_req = {0};
     817                 :            : 
     818                 :          0 :         switchdev_repr_info_req.pf_id = adapter->pf_idx;
     819                 :          0 :         switchdev_repr_info_req.is_set = set;
     820                 :          0 :         switchdev_repr_info_req.cp_vsi_id = repr_vf->cp_vsi_id;
     821                 :          0 :         switchdev_repr_info_req.repr_pf_id = repr_vf->repr_pf_id;
     822                 :          0 :         switchdev_repr_info_req.repr_vf_id = repr_vf->repr_vf_id;
     823                 :          0 :         switchdev_repr_info_req.repr_q_id = repr_vf->repr_q_id;
     824                 :            : 
     825         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_SWITCH_REPR,
     826                 :            :                         &switchdev_repr_info_req,
     827                 :            :                         sizeof(switchdev_repr_info_req),
     828                 :            :                         NULL, 0);
     829                 :            : 
     830                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     831         [ #  # ]:          0 :         if (ret)
     832                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "switchdev repr info config failed, ret=%d", ret);
     833                 :            : 
     834                 :          0 :         return ret;
     835                 :            : }
     836                 :            : 
     837                 :          0 : int32_t sxe2_drv_switchdev_mode_get(struct sxe2_adapter *adapter, bool *is_switchdev)
     838                 :            : {
     839                 :          0 :         int32_t ret = 0;
     840                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     841                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     842                 :          0 :         struct sxe2_switchdev_mode_info switchdev_mode_info_req = {0};
     843                 :          0 :         struct sxe2_switchdev_mode_info switchdev_mode_info_resp = {0};
     844                 :            : 
     845                 :          0 :         switchdev_mode_info_req.pf_id = adapter->pf_idx;
     846                 :            : 
     847         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_SWITCH_MODE,
     848                 :            :                                  &switchdev_mode_info_req,
     849                 :            :                                  sizeof(switchdev_mode_info_req),
     850                 :            :                                  &switchdev_mode_info_resp,
     851                 :            :                                  sizeof(switchdev_mode_info_resp));
     852                 :            : 
     853                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     854         [ #  # ]:          0 :         if (ret)
     855                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "switchdev mode info get failed, ret=%d", ret);
     856                 :            :         else
     857                 :          0 :                 *is_switchdev = (bool)switchdev_mode_info_resp.is_switchdev;
     858                 :            : 
     859                 :          0 :         return ret;
     860                 :            : }
     861                 :            : 
     862                 :          0 : int32_t sxe2_drv_switchdev_cpvsi_get(struct sxe2_adapter *adapter, uint16_t *cp_vsi_id)
     863                 :            : {
     864                 :          0 :         int32_t ret = 0;
     865                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     866                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     867                 :          0 :         struct sxe2_switchdev_cpvsi_info switchdev_cpvsi_resp = {0};
     868                 :            : 
     869         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_SWITCH_CPVSI,
     870                 :            :                                  NULL, 0,
     871                 :            :                                  &switchdev_cpvsi_resp,
     872                 :            :                                  sizeof(switchdev_cpvsi_resp));
     873                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     874         [ #  # ]:          0 :         if (ret)
     875                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "switchdev cpvsi info get failed, ret=%d", ret);
     876                 :            :         else
     877                 :          0 :                 *cp_vsi_id = switchdev_cpvsi_resp.cp_vsi_id;
     878                 :            : 
     879                 :          0 :         return ret;
     880                 :            : }
     881                 :            : 
     882                 :          0 : int32_t sxe2_drv_uc_config(struct sxe2_adapter *adapter, struct rte_ether_addr *addr, bool add)
     883                 :            : {
     884                 :          0 :         int32_t ret = 0;
     885                 :          0 :         int32_t i;
     886                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     887                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     888                 :          0 :         struct sxe2_mac_filter_cfg_req mac_filter_cfg_req = {0};
     889                 :            : 
     890                 :          0 :         mac_filter_cfg_req.vsi_id = adapter->vsi_ctxt.dpdk_vsi_id;
     891         [ #  # ]:          0 :         for (i = 0; i < SXE2_ETH_ALEN; i++)
     892                 :          0 :                 mac_filter_cfg_req.addr[i] = addr->addr_bytes[i];
     893                 :          0 :         mac_filter_cfg_req.is_add = add;
     894                 :          0 :         mac_filter_cfg_req.type = SXE2_MAC_FILTER_TYPE_UC;
     895                 :            : 
     896         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_MAC_ADDR_UC,
     897                 :            :                                  &mac_filter_cfg_req,
     898                 :            :                                  sizeof(mac_filter_cfg_req),
     899                 :            :                                  NULL, 0);
     900                 :            : 
     901                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     902         [ #  # ]:          0 :         if (ret)
     903                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "uc config query failed, ret=%d", ret);
     904                 :            : 
     905                 :          0 :         return ret;
     906                 :            : }
     907                 :            : 
     908                 :          0 : int32_t sxe2_drv_mc_config(struct sxe2_adapter *adapter, struct rte_ether_addr *addr, bool add)
     909                 :            : {
     910                 :          0 :         int32_t ret = 0;
     911                 :          0 :         int32_t i;
     912                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     913                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     914                 :          0 :         struct sxe2_mac_filter_cfg_req mac_filter_cfg_req = {0};
     915                 :            : 
     916                 :          0 :         mac_filter_cfg_req.vsi_id = adapter->vsi_ctxt.dpdk_vsi_id;
     917         [ #  # ]:          0 :         for (i = 0; i < SXE2_ETH_ALEN; i++)
     918                 :          0 :                 mac_filter_cfg_req.addr[i] = addr->addr_bytes[i];
     919                 :            : 
     920                 :          0 :         mac_filter_cfg_req.is_add = add;
     921                 :          0 :         mac_filter_cfg_req.type = SXE2_MAC_FILTER_TYPE_MC;
     922                 :            : 
     923         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_MAC_ADDR_MC,
     924                 :            :                                   &mac_filter_cfg_req, sizeof(mac_filter_cfg_req),
     925                 :            :                                  NULL, 0);
     926                 :            : 
     927                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     928         [ #  # ]:          0 :         if (ret)
     929                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "mac config query failed, ret=%d", ret);
     930                 :            : 
     931                 :          0 :         return ret;
     932                 :            : }
     933                 :            : 
     934                 :          0 : int32_t sxe2_drv_vlan_config_query(struct sxe2_adapter *adapter)
     935                 :            : {
     936                 :          0 :         int32_t ret = 0;
     937                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     938                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     939                 :          0 :         struct sxe2_drv_vlan_cfg_query_resp vlan_cfg_query_resp = {0};
     940                 :            : 
     941         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VLAN_CFG_QUERY,
     942                 :            :                                  NULL, 0,
     943                 :            :                                  &vlan_cfg_query_resp,
     944                 :            :                                  sizeof(vlan_cfg_query_resp));
     945                 :            : 
     946                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     947         [ #  # ]:          0 :         if (ret)
     948                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "vlan config query failed, ret=%d", ret);
     949                 :            : 
     950                 :          0 :         adapter->filter_ctxt.vlan_info.port_vlan_exist = vlan_cfg_query_resp.port_vlan_exist;
     951                 :          0 :         adapter->filter_ctxt.vlan_info.is_switchdev = vlan_cfg_query_resp.is_switchdev;
     952                 :            : 
     953                 :            : 
     954                 :          0 :         adapter->filter_ctxt.vlan_info.tpid = vlan_cfg_query_resp.tpid;
     955                 :          0 :         adapter->filter_ctxt.vlan_info.vid = vlan_cfg_query_resp.vid;
     956                 :            : 
     957                 :          0 :         adapter->filter_ctxt.vlan_info.outer_insert = vlan_cfg_query_resp.outer_insert;
     958                 :          0 :         adapter->filter_ctxt.vlan_info.outer_strip = vlan_cfg_query_resp.outer_strip;
     959                 :          0 :         adapter->filter_ctxt.vlan_info.inner_insert = vlan_cfg_query_resp.inner_insert;
     960                 :          0 :         adapter->filter_ctxt.vlan_info.inner_strip = vlan_cfg_query_resp.inner_strip;
     961                 :            : 
     962                 :          0 :         return ret;
     963                 :            : }
     964                 :            : 
     965                 :          0 : int32_t sxe2_drv_vlan_filter_id_config(struct sxe2_adapter *adapter,
     966                 :            :                                        struct sxe2_vlan *vlan, bool on)
     967                 :            : {
     968                 :          0 :         int32_t ret = 0;
     969                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     970                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     971                 :          0 :         struct sxe2_vlan_filter_cfg_req vlan_filter_cfg_req = {0};
     972                 :            : 
     973                 :          0 :         vlan_filter_cfg_req.vsi_id = adapter->vsi_ctxt.dpdk_vsi_id;
     974                 :          0 :         vlan_filter_cfg_req.tpid_id = vlan->tpid;
     975                 :          0 :         vlan_filter_cfg_req.vlan_id = vlan->vid;
     976                 :          0 :         vlan_filter_cfg_req.prio = vlan->prio;
     977                 :          0 :         vlan_filter_cfg_req.is_add = on;
     978                 :            : 
     979         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VLAN_FILTER_ADD_DEL,
     980                 :            :                                  &vlan_filter_cfg_req, sizeof(vlan_filter_cfg_req),
     981                 :            :                                  NULL, 0);
     982                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
     983         [ #  # ]:          0 :         if (ret)
     984                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "vlan config failed, ret=%d", ret);
     985                 :            : 
     986                 :          0 :         return ret;
     987                 :            : }
     988                 :            : 
     989                 :          0 : int32_t sxe2_drv_vlan_insert_strip_cfg(struct sxe2_adapter *adapter)
     990                 :            : {
     991                 :          0 :         int32_t ret = 0;
     992                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
     993                 :          0 :         struct sxe2_drv_cmd_params param = {0};
     994                 :          0 :         struct sxe2_drv_vlan_offload_cfg_req vlan_offload_cfg_req = {0};
     995                 :            : 
     996                 :          0 :         vlan_offload_cfg_req.vsi_id = adapter->vsi_ctxt.dpdk_vsi_id;
     997                 :          0 :         vlan_offload_cfg_req.tpid = adapter->filter_ctxt.vlan_info.tpid;
     998                 :          0 :         vlan_offload_cfg_req.outer_insert = adapter->filter_ctxt.vlan_info.outer_insert;
     999                 :          0 :         vlan_offload_cfg_req.outer_strip = adapter->filter_ctxt.vlan_info.outer_strip;
    1000                 :          0 :         vlan_offload_cfg_req.inner_insert = adapter->filter_ctxt.vlan_info.inner_insert;
    1001                 :          0 :         vlan_offload_cfg_req.inner_strip = adapter->filter_ctxt.vlan_info.inner_strip;
    1002                 :            : 
    1003         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VLAN_OFFLOAD_CFG,
    1004                 :            :                                  &vlan_offload_cfg_req,
    1005                 :            :                                  sizeof(vlan_offload_cfg_req),
    1006                 :            :                                  NULL, 0);
    1007                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1008         [ #  # ]:          0 :         if (ret)
    1009                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "vlan config query failed, ret=%d", ret);
    1010                 :            : 
    1011                 :          0 :         return ret;
    1012                 :            : }
    1013                 :            : 
    1014                 :          0 : int32_t sxe2_drv_vlan_filter_switch(struct sxe2_adapter *adapter, bool on)
    1015                 :            : {
    1016                 :          0 :         int32_t ret = 0;
    1017                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1018                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1019                 :          0 :         struct sxe2_vlan_filter_switch_req vlan_filter_switch_req = {0};
    1020                 :            : 
    1021                 :          0 :         vlan_filter_switch_req.vsi_id = adapter->vsi_ctxt.dpdk_vsi_id;
    1022                 :          0 :         vlan_filter_switch_req.is_oper_enable = on;
    1023                 :            : 
    1024         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VLAN_FILTER_SWITCH,
    1025                 :            :                                  &vlan_filter_switch_req,
    1026                 :            :                                  sizeof(vlan_filter_switch_req),
    1027                 :            :                                  NULL, 0);
    1028                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1029         [ #  # ]:          0 :         if (ret)
    1030                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "vlan config filter failed, ret=%d", ret);
    1031                 :            : 
    1032                 :          0 :         return ret;
    1033                 :            : }
    1034                 :            : 
    1035                 :          0 : int32_t sxe2_drv_rss_key_set(struct sxe2_adapter *adapter, uint8_t *key, uint16_t key_size)
    1036                 :            : {
    1037                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1038                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1039                 :          0 :         struct sxe2_rss_key_req *req = NULL;
    1040                 :          0 :         int32_t ret = 0;
    1041                 :          0 :         uint16_t buf_size = sizeof(*req) + key_size;
    1042                 :            : 
    1043                 :          0 :         req = rte_zmalloc("drv_cmd_rss_key", buf_size, 0);
    1044         [ #  # ]:          0 :         if (!req) {
    1045                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to alloc rss key");
    1046                 :          0 :                 ret = -ENOMEM;
    1047                 :          0 :                 goto l_end;
    1048                 :            :         }
    1049                 :            : 
    1050                 :          0 :         req->vsi_id = rte_cpu_to_le_16(adapter->vsi_ctxt.dpdk_vsi_id);
    1051                 :          0 :         req->key_size = rte_cpu_to_le_16(key_size);
    1052         [ #  # ]:          0 :         rte_memcpy(req->key, key, key_size);
    1053                 :            : 
    1054         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_RSS_KEY_SET,
    1055                 :            :                                  req, buf_size,
    1056                 :            :                                  NULL, 0);
    1057                 :            : 
    1058                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1059         [ #  # ]:          0 :         if (ret) {
    1060                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to cmd set rss key, ret=%d", ret);
    1061                 :          0 :                 goto l_end;
    1062                 :            :         }
    1063                 :            : 
    1064                 :          0 : l_end:
    1065         [ #  # ]:          0 :         if (req) {
    1066                 :          0 :                 rte_free(req);
    1067                 :          0 :                 req = NULL;
    1068                 :            :         }
    1069                 :          0 :         return ret;
    1070                 :            : }
    1071                 :            : 
    1072                 :          0 : int32_t sxe2_drv_rss_lut_set(struct sxe2_adapter *adapter, uint8_t *lut, uint16_t lut_size)
    1073                 :            : {
    1074                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1075                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1076                 :          0 :         struct sxe2_rss_lut_req *req = NULL;
    1077                 :          0 :         int32_t ret = 0;
    1078                 :          0 :         uint16_t buf_size = sizeof(struct sxe2_rss_lut_req) + lut_size;
    1079                 :            : 
    1080                 :          0 :         req = rte_zmalloc("drv_cmd_rss_lut", buf_size, 0);
    1081         [ #  # ]:          0 :         if (!req) {
    1082                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to alloc rss lut");
    1083                 :          0 :                 ret = -ENOMEM;
    1084                 :          0 :                 goto l_end;
    1085                 :            :         }
    1086                 :            : 
    1087                 :          0 :         req->vsi_id = rte_cpu_to_le_16(adapter->vsi_ctxt.dpdk_vsi_id);
    1088                 :          0 :         req->lut_size = rte_cpu_to_le_16(lut_size);
    1089         [ #  # ]:          0 :         rte_memcpy(req->lut, lut, lut_size);
    1090                 :            : 
    1091         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_RSS_LUT_SET,
    1092                 :            :                                  req, buf_size,
    1093                 :            :                                  NULL, 0);
    1094                 :            : 
    1095                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1096         [ #  # ]:          0 :         if (ret) {
    1097                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to cmd set rss lut, ret=%d", ret);
    1098                 :          0 :                 goto l_end;
    1099                 :            :         }
    1100                 :            : 
    1101                 :          0 : l_end:
    1102         [ #  # ]:          0 :         if (req) {
    1103                 :          0 :                 rte_free(req);
    1104                 :          0 :                 req = NULL;
    1105                 :            :         }
    1106                 :          0 :         return ret;
    1107                 :            : }
    1108                 :            : 
    1109                 :          0 : int32_t sxe2_drv_rss_hash_ctrl_func(struct sxe2_adapter *adapter, enum sxe2_rss_hash_key_func func)
    1110                 :            : {
    1111                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1112                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1113                 :          0 :         struct sxe2_rss_func_req req = {0};
    1114                 :          0 :         int32_t ret = 0;
    1115                 :            : 
    1116                 :          0 :         req.vsi_id = rte_cpu_to_le_16(adapter->vsi_ctxt.dpdk_vsi_id);
    1117                 :          0 :         req.func = func;
    1118                 :            : 
    1119         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_RSS_FUNC_SET,
    1120                 :            :                                  &req, sizeof(req),
    1121                 :            :                                  NULL, 0);
    1122                 :            : 
    1123                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1124         [ #  # ]:          0 :         if (ret)
    1125                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to cmd set rss func, ret=%d", ret);
    1126                 :          0 :         return ret;
    1127                 :            : }
    1128                 :            : 
    1129                 :          0 : static void sxe2_drv_flow_bitmap_fill(uint32_t *bitmap, uint16_t *list)
    1130                 :            : {
    1131                 :          0 :         uint16_t index = 0;
    1132                 :          0 :         uint16_t i = 0;
    1133                 :          0 :         uint16_t map_size = sizeof(*bitmap) * SXE2_BITS_PER_BYTE;
    1134                 :            : 
    1135   [ #  #  #  #  :          0 :         while (list[i] != SXE2_FLOW_END) {
             #  #  #  # ]
    1136                 :          0 :                 index = list[i] / map_size;
    1137                 :          0 :                 bitmap[index] |= (1UL << (list[i] % map_size));
    1138                 :          0 :                 i++;
    1139                 :            :         }
    1140                 :            : }
    1141                 :            : 
    1142                 :          0 : int32_t sxe2_drv_rss_hf_add(struct sxe2_adapter *adapter,
    1143                 :            :                         struct sxe2_rss_hf_config *rss_conf)
    1144                 :            : {
    1145                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1146                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1147                 :          0 :         struct sxe2_rss_hf_req req = {0};
    1148                 :          0 :         int32_t ret = 0;
    1149                 :            : 
    1150                 :          0 :         req.vsi_id = rte_cpu_to_le_16(adapter->vsi_ctxt.dpdk_vsi_id);
    1151                 :          0 :         req.symm = rss_conf->symm;
    1152                 :          0 :         req.hdr_type = rte_cpu_to_le_32(SXE2_RSS_OUTER_HEADERS);
    1153                 :          0 :         sxe2_drv_flow_bitmap_fill(req.headers, rss_conf->hdrs);
    1154                 :          0 :         sxe2_drv_flow_bitmap_fill(req.hash_flds, rss_conf->flds);
    1155                 :            : 
    1156         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_RSS_HF_ADD,
    1157                 :            :                                  &req, sizeof(req),
    1158                 :            :                                  NULL, 0);
    1159                 :            : 
    1160                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1161         [ #  # ]:          0 :         if (ret)
    1162                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to cmd add rss hf, ret=%d", ret);
    1163                 :          0 :         return ret;
    1164                 :            : }
    1165                 :            : 
    1166                 :          0 : int32_t sxe2_drv_rss_hf_del(struct sxe2_adapter *adapter,
    1167                 :            :                                 struct sxe2_rss_hf_config *rss_conf)
    1168                 :            : {
    1169                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1170                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1171                 :          0 :         struct sxe2_rss_hf_req req = {0};
    1172                 :          0 :         int32_t ret = 0;
    1173                 :            : 
    1174                 :          0 :         req.vsi_id = rte_cpu_to_le_16(adapter->vsi_ctxt.dpdk_vsi_id);
    1175                 :          0 :         req.symm = rss_conf->symm;
    1176                 :          0 :         req.hdr_type = rte_cpu_to_le_32(SXE2_RSS_OUTER_HEADERS);
    1177                 :          0 :         sxe2_drv_flow_bitmap_fill(req.headers, rss_conf->hdrs);
    1178                 :          0 :         sxe2_drv_flow_bitmap_fill(req.hash_flds, rss_conf->flds);
    1179                 :            : 
    1180         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_RSS_HF_DEL,
    1181                 :            :                 &req, sizeof(req), NULL, 0);
    1182                 :            : 
    1183                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1184         [ #  # ]:          0 :         if (ret)
    1185                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to cmd del rss hf, ret=%d", ret);
    1186                 :          0 :         return ret;
    1187                 :            : }
    1188                 :            : 
    1189                 :          0 : int32_t sxe2_drv_rss_hf_clear(struct sxe2_adapter *adapter)
    1190                 :            : {
    1191                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1192                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1193                 :          0 :         int32_t ret = 0;
    1194                 :            : 
    1195         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_RSS_HF_CLEAR,
    1196                 :            :                                  NULL, 0,
    1197                 :            :                                  NULL, 0);
    1198                 :            : 
    1199                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1200         [ #  # ]:          0 :         if (ret)
    1201                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to cmd clear rss hf, ret=%d", ret);
    1202                 :            : 
    1203                 :          0 :         return ret;
    1204                 :            : }
    1205                 :            : 
    1206                 :          0 : int32_t sxe2_drv_ptp_gettime(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq)
    1207                 :            : {
    1208                 :          0 :         (void)adapter;
    1209                 :          0 :         (void)rxq;
    1210                 :          0 :         return 0;
    1211                 :            : }
    1212                 :            : 
    1213                 :          0 : int32_t sxe2_drv_root_tree_alloc(struct rte_eth_dev *dev)
    1214                 :            : {
    1215                 :          0 :         struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
    1216                 :          0 :         struct sxe2_tm_context *tm_ctxt = &adapter->tm_ctxt;
    1217                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1218                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1219                 :          0 :         struct sxe2_tm_res tm_resp;
    1220                 :          0 :         int32_t ret;
    1221                 :            : 
    1222         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_SCHED_ROOT_TREE_ALLOC,
    1223                 :            :                                  NULL, 0,
    1224                 :            :                                  &tm_resp, sizeof(tm_resp));
    1225                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1226         [ #  # ]:          0 :         if (ret) {
    1227                 :          0 :                 PMD_LOG_ERR(DRV, "add sched root failed, ret:%d", ret);
    1228                 :          0 :                 goto l_end;
    1229                 :            :         }
    1230                 :            : 
    1231                 :          0 :         tm_ctxt->root_teid = tm_resp.teid;
    1232                 :            : 
    1233                 :          0 : l_end:
    1234                 :          0 :         return ret;
    1235                 :            : }
    1236                 :            : 
    1237                 :          0 : int32_t sxe2_drv_root_tree_release(struct rte_eth_dev *dev)
    1238                 :            : {
    1239                 :          0 :         struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
    1240                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1241                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1242                 :          0 :         struct sxe2_tm_res tm_res = {0};
    1243                 :          0 :         int32_t ret;
    1244                 :            : 
    1245                 :          0 :         tm_res.teid = adapter->tm_ctxt.root_teid;
    1246                 :            : 
    1247         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_SCHED_ROOT_TREE_RELEASE,
    1248                 :            :                                  &tm_res, sizeof(tm_res),
    1249                 :            :                                  NULL, 0);
    1250                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1251         [ #  # ]:          0 :         if (ret) {
    1252                 :          0 :                 PMD_LOG_ERR(DRV, "release sched root failed, ret:%d", ret);
    1253                 :          0 :                 goto l_end;
    1254                 :            :         }
    1255                 :            : 
    1256                 :          0 : l_end:
    1257                 :          0 :         return ret;
    1258                 :            : }
    1259                 :            : 
    1260                 :          0 : static void sxe2_drv_tm_node_to_info(struct sxe2_adapter *adapter,
    1261                 :            :                 struct sxe2_tm_node *node, struct sxe2_tm_info *info)
    1262                 :            : {
    1263                 :          0 :         uint32_t rate = 0;
    1264                 :            : 
    1265                 :          0 :         if (node->shaper_profile->profile.committed.rate == UINT64_MAX)
    1266                 :            :                 rate = UINT32_MAX;
    1267                 :            :         else
    1268                 :          0 :                 rate = (uint32_t)(node->shaper_profile->profile.committed.rate * 8 / 1000);
    1269                 :            : 
    1270                 :          0 :         info->committed = rte_cpu_to_le_32(rate);
    1271                 :            : 
    1272   [ #  #  #  # ]:          0 :         if (node->shaper_profile->profile.peak.rate == UINT64_MAX)
    1273                 :            :                 rate = UINT32_MAX;
    1274                 :            :         else
    1275                 :          0 :                 rate = (uint32_t)(node->shaper_profile->profile.peak.rate * 8 / 1000);
    1276                 :            : 
    1277                 :          0 :         info->peak = rte_cpu_to_le_32(rate);
    1278                 :            : 
    1279                 :          0 :         info->priority = (adapter->tm_ctxt.prio_max - 1 - node->priority);
    1280                 :            : 
    1281                 :          0 :         info->weight = rte_cpu_to_le_16(node->hw_weight);
    1282                 :            : }
    1283                 :            : 
    1284                 :          0 : static int32_t sxe2_drv_tm_commit_node(struct sxe2_adapter *adapter,
    1285                 :            :                 struct sxe2_tm_node *tm_node)
    1286                 :            : {
    1287                 :          0 :         struct sxe2_drv_cmd_params cmd = { 0 };
    1288                 :          0 :         struct sxe2_tm_add_mid_msg msg_mid = {0};
    1289                 :          0 :         struct sxe2_tm_add_queue_msg msg_queue = {0};
    1290                 :          0 :         struct sxe2_tm_res res = {0};
    1291                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1292                 :          0 :         int32_t ret;
    1293                 :          0 :         uint32_t i;
    1294                 :            : 
    1295         [ #  # ]:          0 :         if (tm_node->type == SXE2_TM_NODE_TYPE_VSIG) {
    1296                 :          0 :                 goto l_add;
    1297         [ #  # ]:          0 :         } else if (tm_node->type == SXE2_TM_NODE_TYPE_MID) {
    1298         [ #  # ]:          0 :                 sxe2_drv_tm_node_to_info(adapter, tm_node, &msg_mid.info);
    1299                 :          0 :                 msg_mid.parent_teid = rte_cpu_to_le_16(tm_node->parent->teid);
    1300                 :          0 :                 msg_mid.adj_lvl = adapter->sched_ctxt.adj_lvl;
    1301                 :            : 
    1302         [ #  # ]:          0 :                 sxe2_drv_cmd_params_fill(adapter, &cmd,
    1303                 :            :                                          SXE2_DRV_CMD_SCHED_TM_ADD_MID_NODE,
    1304                 :            :                                          &msg_mid, sizeof(msg_mid),
    1305                 :            :                                          &res, sizeof(res));
    1306                 :          0 :                 ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1307         [ #  # ]:          0 :                 if (ret) {
    1308                 :          0 :                         PMD_LOG_ERR(DRV, "add tm mid node failed, ret:%d", ret);
    1309                 :          0 :                         goto l_end;
    1310                 :            :                 }
    1311         [ #  # ]:          0 :         } else if (tm_node->type == SXE2_TM_NODE_TYPE_QUEUE) {
    1312         [ #  # ]:          0 :                 sxe2_drv_tm_node_to_info(adapter, tm_node, &msg_queue.info);
    1313                 :          0 :                 msg_queue.parent_teid = rte_cpu_to_le_16(tm_node->parent->teid);
    1314                 :          0 :                 msg_queue.queue_id = rte_cpu_to_le_16(tm_node->id);
    1315                 :          0 :                 msg_queue.adj_lvl = adapter->sched_ctxt.adj_lvl;
    1316                 :            : 
    1317         [ #  # ]:          0 :                 sxe2_drv_cmd_params_fill(adapter, &cmd,
    1318                 :            :                                          SXE2_DRV_CMD_SCHED_TM_ADD_QUEUE_NODE,
    1319                 :            :                                          &msg_queue, sizeof(msg_queue),
    1320                 :            :                                          &res, sizeof(res));
    1321                 :          0 :                 ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1322         [ #  # ]:          0 :                 if (ret) {
    1323                 :          0 :                         PMD_LOG_ERR(DRV, "add tm queue failed, ret:%d", ret);
    1324                 :          0 :                         goto l_end;
    1325                 :            :                 }
    1326                 :            :         } else {
    1327                 :          0 :                 PMD_LOG_ERR(DRV, "commit tm node failed, type:%d", tm_node->type);
    1328                 :          0 :                 ret = -EINVAL;
    1329                 :          0 :                 goto l_end;
    1330                 :            :         }
    1331                 :            : 
    1332                 :          0 :         tm_node->teid = rte_le_to_cpu_16(res.teid);
    1333                 :            : 
    1334                 :            : l_add:
    1335         [ #  # ]:          0 :         for (i = 0; i < tm_node->child_cnt; i++) {
    1336                 :          0 :                 ret = sxe2_drv_tm_commit_node(adapter, tm_node->children[i]);
    1337         [ #  # ]:          0 :                 if (ret)
    1338                 :          0 :                         goto l_end;
    1339                 :            :         }
    1340                 :          0 : l_end:
    1341                 :          0 :         return ret;
    1342                 :            : }
    1343                 :            : 
    1344                 :          0 : int32_t sxe2_drv_tm_commit(struct sxe2_adapter *adapter)
    1345                 :            : {
    1346                 :          0 :         struct sxe2_drv_cmd_params cmd = { 0 };
    1347                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1348                 :          0 :         struct sxe2_tm_res tm_res = {0};
    1349                 :          0 :         int32_t ret;
    1350                 :            : 
    1351                 :          0 :         tm_res.teid = adapter->tm_ctxt.root_teid;
    1352         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_SCHED_ROOT_CHILDREN_DELETE,
    1353                 :            :                                  &tm_res, sizeof(tm_res),
    1354                 :            :                                  NULL, 0);
    1355                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1356         [ #  # ]:          0 :         if (ret) {
    1357                 :          0 :                 PMD_LOG_ERR(DRV, "del tm root failed, ret:%d", ret);
    1358                 :          0 :                 goto l_end;
    1359                 :            :         }
    1360                 :            : 
    1361                 :          0 :         ret = sxe2_drv_tm_commit_node(adapter, adapter->tm_ctxt.root);
    1362         [ #  # ]:          0 :         if (ret) {
    1363                 :          0 :                 PMD_LOG_ERR(DRV, "commit tm node failed, ret:%d", ret);
    1364                 :          0 :                 goto l_end;
    1365                 :            :         }
    1366                 :            : 
    1367                 :          0 :         PMD_LOG_DEBUG(DRV, "commit tm success");
    1368                 :          0 : l_end:
    1369                 :          0 :         return ret;
    1370                 :            : }
    1371                 :            : 
    1372                 :          0 : int32_t sxe2_drv_ipsec_get_capa(struct sxe2_adapter *adapter)
    1373                 :            : {
    1374                 :          0 :         int32_t ret = -1;
    1375                 :          0 :         struct sxe2_drv_cmd_params cmd = { 0 };
    1376                 :          0 :         struct sxe2_drv_ipsec_capa_resq resp;
    1377                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1378                 :            : 
    1379         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_IPSEC_CAP_GET,
    1380                 :            :                                  NULL, 0,
    1381                 :            :                                  &resp, sizeof(resp));
    1382                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1383         [ #  # ]:          0 :         if (ret) {
    1384                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to get ipsec specifications, ret=%d", ret);
    1385                 :          0 :                 goto l_end;
    1386                 :            :         }
    1387                 :            : 
    1388                 :          0 :         adapter->security_ctx.ipsec_ctx.max_tx_sa = rte_le_to_cpu_16(resp.tx_sa_cnt);
    1389                 :          0 :         adapter->security_ctx.ipsec_ctx.max_rx_sa = rte_le_to_cpu_16(resp.rx_sa_cnt);
    1390                 :          0 :         adapter->security_ctx.ipsec_ctx.max_tcam = rte_le_to_cpu_16(resp.ip_id_cnt);
    1391                 :          0 :         adapter->security_ctx.ipsec_ctx.max_udp_group = rte_le_to_cpu_16(resp.udp_group_cnt);
    1392                 :            : 
    1393                 :          0 :         PMD_DEV_LOG_INFO(adapter, DRV, "Max tx sa:%u, max rx sa:%u, max tcam:%u, udp group:%u.",
    1394                 :            :                          rte_le_to_cpu_16(resp.tx_sa_cnt),
    1395                 :            :                          rte_le_to_cpu_16(resp.rx_sa_cnt),
    1396                 :            :                          rte_le_to_cpu_16(resp.ip_id_cnt),
    1397                 :            :                          rte_le_to_cpu_16(resp.udp_group_cnt));
    1398                 :            : 
    1399                 :          0 : l_end:
    1400                 :          0 :         return ret;
    1401                 :            : }
    1402                 :            : 
    1403                 :          0 : int32_t sxe2_drv_ipsec_resource_clear(struct sxe2_adapter *adapter)
    1404                 :            : {
    1405                 :          0 :         int32_t ret = -1;
    1406                 :          0 :         struct sxe2_drv_cmd_params cmd = { 0 };
    1407                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1408                 :            : 
    1409         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_IPSEC_RESOURCE_CLEAR,
    1410                 :            :                                  NULL, 0,
    1411                 :            :                                  NULL, 0);
    1412                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1413         [ #  # ]:          0 :         if (ret) {
    1414                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to clear ipsec resource, ret=%d", ret);
    1415                 :          0 :                 goto l_end;
    1416                 :            :         }
    1417                 :            : 
    1418                 :          0 : l_end:
    1419                 :          0 :         return ret;
    1420                 :            : }
    1421                 :            : 
    1422                 :          0 : int32_t sxe2_drv_ipsec_txsa_add(struct sxe2_adapter *adapter,
    1423                 :            :                 struct sxe2_ipsec_tx_sa *tx_sa)
    1424                 :            : {
    1425                 :          0 :         struct sxe2_drv_cmd_params cmd               = { 0 };
    1426                 :          0 :         struct sxe2_drv_ipsec_txsa_add_req req   = { 0 };
    1427                 :          0 :         struct sxe2_drv_ipsec_txsa_add_resp resp = { 0 };
    1428                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1429                 :          0 :         int32_t ret                                   = -1;
    1430                 :          0 :         uint32_t mode                                  = 0;
    1431                 :          0 :         uint32_t i                                     = 0;
    1432                 :            : 
    1433         [ #  # ]:          0 :         if (tx_sa->algo == SXE2_IPSEC_ALGO_SM4_CBC_AND_SM3_96_HMAC)
    1434                 :          0 :                 mode |= IPSEC_TX_ENGINE_SM4;
    1435         [ #  # ]:          0 :         if (tx_sa->mode == SXE2_IPSEC_MODE_ENC_AND_AUTH)
    1436                 :          0 :                 mode |= IPSEC_TX_ENCRYPT;
    1437                 :          0 :         req.mode = rte_cpu_to_le_32(mode);
    1438         [ #  # ]:          0 :         for (i = 0; i < SXE2_IPSEC_KEY_LEN; i++) {
    1439                 :          0 :                 req.encrypt_keys[i] = tx_sa->enc_key[i];
    1440                 :          0 :                 req.auth_keys[i] = tx_sa->auth_key[i];
    1441                 :            :         }
    1442                 :            : 
    1443         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_IPSEC_TXSA_ADD,
    1444                 :            :                                  &req, sizeof(req),
    1445                 :            :                                  &resp, sizeof(resp));
    1446                 :            : 
    1447                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1448         [ #  # ]:          0 :         if (ret) {
    1449                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "failed to add tx sa, ret=%d", ret);
    1450                 :          0 :                 goto l_end;
    1451                 :            :         }
    1452                 :          0 :         tx_sa->hw_sa_id = rte_le_to_cpu_16(resp.index);
    1453                 :            : 
    1454                 :          0 : l_end:
    1455                 :          0 :         return ret;
    1456                 :            : }
    1457                 :            : 
    1458                 :          0 : int32_t sxe2_drv_ipsec_rxsa_add(struct sxe2_adapter *adapter,
    1459                 :            :                 struct sxe2_ipsec_rx_sa *rx_sa,
    1460                 :            :                 struct sxe2_ipsec_rx_tcam *rx_tcam,
    1461                 :            :                 struct sxe2_ipsec_rx_udp_group *rx_udp_group)
    1462                 :            : {
    1463                 :          0 :         struct sxe2_drv_cmd_params cmd               = { 0 };
    1464                 :          0 :         struct sxe2_drv_ipsec_rxsa_add_req req   = { 0 };
    1465                 :          0 :         struct sxe2_drv_ipsec_rxsa_add_resp resp = { 0 };
    1466                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1467                 :          0 :         int32_t ret                                   = -1;
    1468                 :          0 :         uint32_t mode                                  = 0;
    1469                 :          0 :         uint32_t i                                     = 0;
    1470                 :            : 
    1471         [ #  # ]:          0 :         if (rx_sa->algo == SXE2_IPSEC_ALGO_SM4_CBC_AND_SM3_96_HMAC)
    1472                 :          0 :                 mode |= IPSEC_RX_ENGINE_SM4;
    1473         [ #  # ]:          0 :         if (rx_sa->mode == SXE2_IPSEC_MODE_ENC_AND_AUTH)
    1474                 :          0 :                 mode |= IPSEC_RX_DECRYPT;
    1475         [ #  # ]:          0 :         if (rx_tcam->ip_addr.type == RTE_SECURITY_IPSEC_TUNNEL_IPV6) {
    1476                 :          0 :                 mode |= IPSEC_RX_IPV6;
    1477                 :          0 :                 memcpy(req.ipaddr, rx_tcam->ip_addr.dst_ipv6, sizeof(req.ipaddr));
    1478                 :            :         } else {
    1479                 :          0 :                 req.ipaddr[0] = rx_tcam->ip_addr.dst_ipv4;
    1480                 :            :         }
    1481                 :          0 :         req.mode = rte_cpu_to_le_32(mode);
    1482                 :          0 :         req.spi = rte_cpu_to_le_32(rx_sa->spi);
    1483         [ #  # ]:          0 :         if (rx_udp_group != NULL) {
    1484                 :          0 :                 req.udp_port = rte_cpu_to_le_32((uint32_t)rx_udp_group->udp_port);
    1485                 :          0 :                 req.sport_en = rx_udp_group->sport_en;
    1486                 :          0 :                 req.dport_en = rx_udp_group->dport_en;
    1487                 :            :         }
    1488                 :            : 
    1489                 :          0 :         PMD_DEV_LOG_INFO(adapter, DRV, "Add rx sa, mode: 0x%x, spi: 0x%x, udp_port: %u, "
    1490                 :            :                          "sport_en: %u, dport_en: %u.",
    1491                 :            :                          req.mode, req.spi, req.udp_port, req.sport_en, req.dport_en);
    1492                 :            : 
    1493                 :            :         /* encrypt and auth keys */
    1494         [ #  # ]:          0 :         for (i = 0; i < SXE2_IPSEC_KEY_LEN; i++) {
    1495                 :          0 :                 req.encrypt_keys[i] = rx_sa->enc_key[i];
    1496                 :          0 :                 req.auth_keys[i] = rx_sa->auth_key[i];
    1497                 :            :         }
    1498                 :            : 
    1499         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_IPSEC_RXSA_ADD,
    1500                 :            :                                  &req, sizeof(req),
    1501                 :            :                                  &resp, sizeof(resp));
    1502                 :            : 
    1503                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1504         [ #  # ]:          0 :         if (ret) {
    1505                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to add rx sa, ret=%d", ret);
    1506                 :          0 :                 goto l_end;
    1507                 :            :         }
    1508                 :          0 :         rx_sa->hw_sa_id = rte_le_to_cpu_16(resp.sa_idx);
    1509                 :          0 :         rx_sa->hw_ip_id = resp.ip_id;
    1510                 :          0 :         rx_tcam->hw_ip_id = resp.ip_id;
    1511                 :          0 :         rx_sa->hw_udp_group_id = resp.udp_group_id;
    1512         [ #  # ]:          0 :         if (rx_udp_group != NULL)
    1513                 :          0 :                 rx_udp_group->hw_group_id = resp.udp_group_id;
    1514                 :            : 
    1515                 :          0 : l_end:
    1516                 :          0 :         return ret;
    1517                 :            : }
    1518                 :            : 
    1519                 :          0 : int32_t sxe2_drv_ipsec_rxsa_delete(struct sxe2_adapter *adapter,
    1520                 :            :                                         struct sxe2_ipsec_rx_sa *rx_sa)
    1521                 :            : {
    1522                 :          0 :         struct sxe2_drv_ipsec_rxsa_del_req req = { 0 };
    1523                 :          0 :         struct sxe2_drv_cmd_params cmd             = { 0 };
    1524                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1525                 :          0 :         int32_t ret                                 = -1;
    1526                 :            : 
    1527                 :          0 :         req.sa_idx = rte_cpu_to_le_16(rx_sa->hw_sa_id);
    1528                 :          0 :         req.spi = rte_cpu_to_le_32(rx_sa->spi);
    1529                 :          0 :         req.ip_id = rx_sa->hw_ip_id;
    1530                 :          0 :         req.group_id = rx_sa->hw_udp_group_id;
    1531                 :            : 
    1532         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_IPSEC_RXSA_DEL,
    1533                 :            :                                  &req, sizeof(req),
    1534                 :            :                                  NULL, 0);
    1535                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1536         [ #  # ]:          0 :         if (ret)
    1537                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV,
    1538                 :            :                                 "Failed to delete rx sa, sa id: %u, spi: %u, "
    1539                 :            :                                 "ip id: %u, udp group id: %u, ret: %d.",
    1540                 :            :                                 rx_sa->hw_sa_id, rx_sa->spi, rx_sa->hw_ip_id,
    1541                 :            :                                 rx_sa->hw_udp_group_id, ret);
    1542                 :            : 
    1543                 :          0 :         return ret;
    1544                 :            : }
    1545                 :            : 
    1546                 :          0 : int32_t sxe2_drv_ipsec_txsa_delete(struct sxe2_adapter *adapter,
    1547                 :            :                                            uint16_t sa_id)
    1548                 :            : {
    1549                 :          0 :         struct sxe2_drv_ipsec_txsa_del_req req = { 0 };
    1550                 :          0 :         struct sxe2_drv_cmd_params cmd             = { 0 };
    1551                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1552                 :          0 :         int32_t ret                                 = -1;
    1553                 :            : 
    1554                 :          0 :         req.sa_idx = rte_cpu_to_le_16(sa_id);
    1555         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_IPSEC_TXSA_DEL,
    1556                 :            :                                  &req, sizeof(req),
    1557                 :            :                                  NULL, 0);
    1558                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1559         [ #  # ]:          0 :         if (ret)
    1560                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV,
    1561                 :            :                                 "Failed to delete tx sa, sa id: %u, ret: %d.",
    1562                 :            :                                 sa_id, ret);
    1563                 :            : 
    1564                 :          0 :         return ret;
    1565                 :            : }
    1566                 :            : 
    1567                 :          0 : int32_t sxe2_drv_udp_tunnel_add(struct sxe2_adapter *adapter,
    1568                 :            :                             enum sxe2_udp_tunnel_protocol tunnel_proto,
    1569                 :            :                             uint16_t udp_port)
    1570                 :            : {
    1571                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1572                 :          0 :         struct sxe2_drv_udp_tunnel_req req = {};
    1573                 :          0 :         struct sxe2_drv_cmd_params cmd = {};
    1574                 :          0 :         int32_t ret = -1;
    1575                 :            : 
    1576                 :          0 :         req.type = tunnel_proto;
    1577                 :          0 :         req.port = udp_port;
    1578         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_UDPTUNNEL_ADD,
    1579                 :            :                                  &req, sizeof(req),
    1580                 :            :                                  NULL, 0);
    1581                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1582         [ #  # ]:          0 :         if (ret)
    1583                 :          0 :                 PMD_LOG_ERR(DRV, "Failed to add udp proto %d port %d, ret=%d",
    1584                 :            :                                 tunnel_proto, udp_port, ret);
    1585                 :            : 
    1586                 :          0 :         return ret;
    1587                 :            : }
    1588                 :            : 
    1589                 :          0 : int32_t sxe2_drv_udp_tunnel_del(struct sxe2_adapter *adapter,
    1590                 :            :                             enum sxe2_udp_tunnel_protocol tunnel_proto,
    1591                 :            :                             uint16_t udp_port)
    1592                 :            : {
    1593                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1594                 :          0 :         struct sxe2_drv_udp_tunnel_req req = {};
    1595                 :          0 :         struct sxe2_drv_cmd_params cmd = {};
    1596                 :          0 :         int32_t ret = -1;
    1597                 :            : 
    1598                 :          0 :         req.type = tunnel_proto;
    1599                 :          0 :         req.port = udp_port;
    1600         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_UDPTUNNEL_DEL,
    1601                 :            :                                  &req, sizeof(req),
    1602                 :            :                                  NULL, 0);
    1603                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1604         [ #  # ]:          0 :         if (ret)
    1605                 :          0 :                 PMD_LOG_ERR(DRV, "Failed to del udp proto %d port %d, ret=%d",
    1606                 :            :                                 tunnel_proto, udp_port, ret);
    1607                 :            : 
    1608                 :          0 :         return ret;
    1609                 :            : }
    1610                 :            : 
    1611                 :          0 : int32_t sxe2_drv_get_udp_tunnel_port(struct sxe2_adapter *adapter,
    1612                 :            :                                  enum sxe2_flow_udp_tunnel_protocol proto,
    1613                 :            :                                  uint16_t *port)
    1614                 :            : {
    1615                 :          0 :         int32_t ret = 0;
    1616                 :          0 :         static const uint16_t flow_proto_to_udp_tunnel_proto[SXE2_FLOW_UDP_TUNNEL_MAX] = {
    1617                 :            :                 [SXE2_FLOW_UDP_TUNNEL_PROTOCOL_VXLAN] = SXE2_UDP_TUNNEL_PROTOCOL_VXLAN,
    1618                 :            :                 [SXE2_FLOW_UDP_TUNNEL_PROTOCOL_VXLAN_GPE] = SXE2_UDP_TUNNEL_PROTOCOL_VXLAN_GPE,
    1619                 :            :                 [SXE2_FLOW_UDP_TUNNEL_PROTOCOL_GENEVE] = SXE2_UDP_TUNNEL_PROTOCOL_GENEVE,
    1620                 :            :                 [SXE2_FLOW_UDP_TUNNEL_PROTOCOL_GTP_U] = SXE2_UDP_TUNNEL_PROTOCOL_GTP_U,
    1621                 :            :                 [SXE2_FLOW_UDP_TUNNEL_PROTOCOL_NVGRE] = SXE2_UDP_TUNNEL_PROTOCOL_NVGRE,
    1622                 :            :         };
    1623                 :          0 :         struct sxe2_udp_tunnel_cfg tunnel_config = {};
    1624                 :            : 
    1625                 :          0 :         tunnel_config.protocol = flow_proto_to_udp_tunnel_proto[proto];
    1626                 :          0 :         ret = sxe2_drv_udp_tunnel_get(adapter, &tunnel_config);
    1627         [ #  # ]:          0 :         if (ret) {
    1628                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to get udp tunnel port, ret=%d", ret);
    1629                 :          0 :                 goto l_end;
    1630                 :            :         }
    1631                 :            : 
    1632                 :          0 :         *port = tunnel_config.fw_port;
    1633                 :          0 : l_end:
    1634                 :          0 :         return ret;
    1635                 :            : }
    1636                 :            : 
    1637                 :          0 : int32_t sxe2_drv_udp_tunnel_get(struct sxe2_adapter *adapter,
    1638                 :            :                             struct sxe2_udp_tunnel_cfg *tunnel_config)
    1639                 :            : {
    1640                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1641                 :          0 :         struct sxe2_drv_udp_tunnel_req req = {};
    1642                 :          0 :         struct sxe2_drv_udp_tunnel_resp resp = {};
    1643                 :          0 :         struct sxe2_drv_cmd_params cmd = {};
    1644                 :          0 :         int32_t ret = -1;
    1645                 :            : 
    1646                 :          0 :         req.type = tunnel_config->protocol;
    1647         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_UDPTUNNEL_GET,
    1648                 :            :                                  &req, sizeof(req),
    1649                 :            :                                  &resp, sizeof(resp));
    1650                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1651         [ #  # ]:          0 :         if (ret) {
    1652                 :          0 :                 PMD_LOG_ERR(DRV, "Failed to get udp proto %d port, ret=%d", req.type, ret);
    1653                 :          0 :                 goto l_end;
    1654                 :            :         }
    1655                 :            : 
    1656                 :          0 :         tunnel_config->fw_port   = resp.port;
    1657                 :          0 :         tunnel_config->fw_status = resp.enable;
    1658                 :          0 :         tunnel_config->fw_dst_en = resp.dst;
    1659                 :          0 :         tunnel_config->fw_src_en = resp.src;
    1660                 :          0 :         tunnel_config->fw_used   = resp.fw_used;
    1661                 :          0 : l_end:
    1662                 :          0 :         return ret;
    1663                 :            : }
    1664                 :            : 
    1665                 :          0 : int32_t sxe2_drv_queue_info_get_update(struct sxe2_adapter *adapter, struct eth_queue_stats *qstats)
    1666                 :            : {
    1667                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1668                 :          0 :         struct sxe2_queue_map_info resp = {0};
    1669                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1670                 :          0 :         struct rte_eth_dev_data *dev_data = adapter->dev_info.dev_data;
    1671                 :          0 :         uint16_t i;
    1672                 :          0 :         int32_t ret;
    1673                 :            : 
    1674         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_TX_RX_MAP_GET,
    1675                 :            :                                  NULL, 0,
    1676                 :            :                                  &resp, sizeof(resp));
    1677                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1678         [ #  # ]:          0 :         if (ret) {
    1679                 :          0 :                 PMD_LOG_ERR(DRV, "tx/rx queue map get failed, ret=%d", ret);
    1680                 :          0 :                 goto l_end;
    1681                 :            :         }
    1682                 :            : 
    1683                 :            :         /* Firmware has a limited number of queue counters, and reports them
    1684                 :            :          * for the first queues only. Later queues are not covered.
    1685                 :            :          */
    1686         [ #  # ]:          0 :         for (i = 0; i < RTE_MIN(SXE2_RXQ_STATS_MAP_MAX_NUM, dev_data->nb_rx_queues); i++) {
    1687                 :          0 :                 qstats[i].q_ipackets = resp.rxq_stats_map_info[i].rxq_lan_in_pkt_cnt;
    1688                 :          0 :                 qstats[i].q_ibytes = resp.rxq_stats_map_info[i].rxq_lan_in_byte_cnt;
    1689                 :            :         }
    1690                 :            : 
    1691         [ #  # ]:          0 :         for (i = 0; i < RTE_MIN(SXE2_TXQ_STATS_MAP_MAX_NUM, dev_data->nb_tx_queues); i++) {
    1692                 :          0 :                 qstats[i].q_opackets = resp.txq_stats_map_info[i].txq_lan_pkt_cnt;
    1693                 :          0 :                 qstats[i].q_obytes = resp.txq_stats_map_info[i].txq_lan_byte_cnt;
    1694                 :            :         }
    1695                 :            : 
    1696                 :          0 : l_end:
    1697                 :          0 :         return ret;
    1698                 :            : }
    1699                 :            : 
    1700                 :          0 : int32_t sxe2_drv_flow_filter_add(struct sxe2_adapter *adapter, struct sxe2_flow *flow)
    1701                 :            : {
    1702                 :          0 :         struct sxe2_drv_flow_filter_req req = { 0 };
    1703                 :          0 :         struct sxe2_drv_flow_filter_resp resp = { 0 };
    1704                 :          0 :         struct sxe2_drv_cmd_params cmd             = { 0 };
    1705                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1706                 :          0 :         int32_t ret                                 = -1;
    1707                 :            : 
    1708                 :          0 :         memcpy(&req.pattern_inner, &flow->pattern_inner, sizeof(req.pattern_inner));
    1709                 :          0 :         memcpy(&req.pattern_outer, &flow->pattern_outer, sizeof(req.pattern_outer));
    1710                 :          0 :         memcpy(&req.action, &flow->action, sizeof(req.action));
    1711                 :          0 :         memcpy(&req.meta, &flow->meta, sizeof(req.meta));
    1712                 :          0 :         req.engine_type = flow->engine_type;
    1713                 :          0 :         req.flow_id = 0;
    1714                 :            : 
    1715         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_FILTER_ADD, &req,
    1716                 :            :                            sizeof(req), &resp, sizeof(resp));
    1717                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1718         [ #  # ]:          0 :         if (ret) {
    1719                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to add flow filter, ret: %d.", ret);
    1720                 :          0 :                 goto l_end;
    1721                 :            :         }
    1722                 :          0 :         flow->flow_id = resp.flow_id;
    1723                 :            : 
    1724                 :          0 : l_end:
    1725                 :          0 :         flow->create_err = ret;
    1726                 :          0 :         return ret;
    1727                 :            : }
    1728                 :            : 
    1729                 :          0 : int32_t sxe2_drv_flow_filter_del(struct sxe2_adapter *adapter, struct sxe2_flow *flow)
    1730                 :            : {
    1731                 :          0 :         struct sxe2_drv_cmd_params cmd             = { 0 };
    1732                 :          0 :         struct sxe2_drv_flow_filter_req req = { 0 };
    1733                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1734                 :          0 :         int32_t ret                                 = -1;
    1735                 :          0 :         memcpy(&req.pattern_inner, &flow->pattern_inner, sizeof(req.pattern_inner));
    1736                 :          0 :         memcpy(&req.pattern_outer, &flow->pattern_outer, sizeof(req.pattern_outer));
    1737                 :          0 :         memcpy(&req.action, &flow->action, sizeof(req.action));
    1738                 :          0 :         memcpy(&req.meta, &flow->meta, sizeof(req.meta));
    1739                 :          0 :         req.engine_type = flow->engine_type;
    1740                 :          0 :         req.flow_id = flow->flow_id;
    1741                 :            : 
    1742         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_FILTER_DEL, &req,
    1743                 :            :                            sizeof(req), NULL, 0);
    1744                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1745         [ #  # ]:          0 :         if (ret)
    1746                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV,
    1747                 :            :                         "Failed to delete flow filter, flow id: %u, ret: %d.",
    1748                 :            :                         flow->flow_id, ret);
    1749                 :          0 :         return ret;
    1750                 :            : }
    1751                 :            : 
    1752                 :          0 : int32_t sxe2_drv_flow_fnav_get_stat_id(struct sxe2_adapter *adapter, uint32_t *stat_id)
    1753                 :            : {
    1754                 :          0 :         struct sxe2_drv_flow_fnav_get_stat_id_req req = { 0 };
    1755                 :          0 :         struct sxe2_drv_flow_fnav_get_stat_id_resp resp = { 0 };
    1756                 :          0 :         struct sxe2_drv_cmd_params cmd             = { 0 };
    1757                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1758                 :          0 :         int32_t ret                                 = -1;
    1759                 :            : 
    1760         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_FNAV_STAT_ALLOC,
    1761                 :            :                                  &req, sizeof(req),
    1762                 :            :                                  &resp, sizeof(resp));
    1763                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1764         [ #  # ]:          0 :         if (ret) {
    1765                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to get fnav stat id, ret: %d.", ret);
    1766                 :          0 :                 goto l_end;
    1767                 :            :         }
    1768                 :          0 :         *stat_id = resp.stat_id;
    1769                 :            : 
    1770                 :          0 : l_end:
    1771                 :          0 :         return ret;
    1772                 :            : }
    1773                 :            : 
    1774                 :          0 : int32_t sxe2_drv_flow_fnav_free_stat(struct sxe2_adapter *adapter, uint32_t stat_id)
    1775                 :            : {
    1776                 :          0 :         struct sxe2_drv_flow_fnav_free_stat_id_req req = { 0 };
    1777                 :          0 :         struct sxe2_drv_cmd_params cmd             = { 0 };
    1778                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1779                 :          0 :         int32_t ret                                 = -1;
    1780                 :            : 
    1781                 :          0 :         req.stat_id = stat_id;
    1782         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_FNAV_STAT_FREE,
    1783                 :            :                                  &req, sizeof(req),
    1784                 :            :                                  NULL, 0);
    1785                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1786         [ #  # ]:          0 :         if (ret) {
    1787                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to free fnav stat id, ret: %d.", ret);
    1788                 :          0 :                 goto l_end;
    1789                 :            :         }
    1790                 :            : 
    1791                 :          0 : l_end:
    1792                 :          0 :         return ret;
    1793                 :            : }
    1794                 :            : 
    1795                 :          0 : int32_t sxe2_drv_flow_fnav_query_stat(struct sxe2_adapter *adapter,
    1796                 :            :                 struct sxe2_flow_cid_mgr *mgr)
    1797                 :            : {
    1798                 :          0 :         struct sxe2_drv_flow_fnav_query_stat_req req = { 0 };
    1799                 :          0 :         struct sxe2_drv_flow_fnav_query_stat_resp resp = { 0 };
    1800                 :          0 :         struct sxe2_drv_cmd_params cmd             = { 0 };
    1801                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1802                 :          0 :         int32_t ret                                 = -1;
    1803                 :            : 
    1804                 :          0 :         req.stat_id = mgr->stat_index;
    1805                 :          0 :         req.stat_ctrl = mgr->count_type;
    1806                 :          0 :         req.is_clear = 1;
    1807                 :            : 
    1808         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_FNAV_STAT_QUERY,
    1809                 :            :                                  &req, sizeof(req),
    1810                 :            :                                  &resp, sizeof(resp));
    1811                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1812         [ #  # ]:          0 :         if (ret) {
    1813                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV,
    1814                 :            :                         "Failed to query fnav stat, stat id: %u, ret: %d.",
    1815                 :            :                         req.stat_id, ret);
    1816                 :          0 :                 goto l_end;
    1817                 :            :         }
    1818                 :          0 :         mgr->hits += resp.stat_hits;
    1819                 :          0 :         mgr->bytes += resp.stat_bytes;
    1820                 :            : 
    1821                 :          0 : l_end:
    1822                 :          0 :         return ret;
    1823                 :            : }
    1824                 :            : 
    1825                 :          0 : int32_t sxe2_drv_flow_acl_get_stat_id(struct sxe2_adapter *adapter, uint32_t *stat_id)
    1826                 :            : {
    1827                 :          0 :         struct sxe2_drv_flow_fnav_get_stat_id_req req = { 0 };
    1828                 :          0 :         struct sxe2_drv_flow_fnav_get_stat_id_resp resp = { 0 };
    1829                 :          0 :         struct sxe2_drv_cmd_params cmd             = { 0 };
    1830                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1831                 :          0 :         int32_t ret                                 = -1;
    1832                 :            : 
    1833         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_ACL_STAT_ALLOC,
    1834                 :            :                                 &req, sizeof(req),
    1835                 :            :                                 &resp, sizeof(resp));
    1836                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1837         [ #  # ]:          0 :         if (ret) {
    1838                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to get acl stat id, ret: %d.", ret);
    1839                 :          0 :                 goto l_end;
    1840                 :            :         }
    1841                 :          0 :         *stat_id = resp.stat_id;
    1842                 :            : 
    1843                 :          0 : l_end:
    1844                 :          0 :         return ret;
    1845                 :            : }
    1846                 :            : 
    1847                 :          0 : int32_t sxe2_drv_flow_acl_free_stat(struct sxe2_adapter *adapter, uint32_t stat_id)
    1848                 :            : {
    1849                 :          0 :         struct sxe2_drv_flow_fnav_free_stat_id_req req = { 0 };
    1850                 :          0 :         struct sxe2_drv_cmd_params cmd             = { 0 };
    1851                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1852                 :          0 :         int32_t ret                                 = -1;
    1853                 :            : 
    1854                 :          0 :         req.stat_id = stat_id;
    1855         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_ACL_STAT_FREE,
    1856                 :            :                                 &req, sizeof(req),
    1857                 :            :                                 NULL, 0);
    1858                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1859         [ #  # ]:          0 :         if (ret) {
    1860                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to free acl stat id, ret: %d.", ret);
    1861                 :          0 :                 goto l_end;
    1862                 :            :         }
    1863                 :            : 
    1864                 :          0 : l_end:
    1865                 :          0 :         return ret;
    1866                 :            : }
    1867                 :            : 
    1868                 :          0 : int32_t sxe2_drv_flow_acl_query_stat(struct sxe2_adapter *adapter,
    1869                 :            :                                      struct sxe2_flow_cid_mgr *mgr)
    1870                 :            : {
    1871                 :          0 :         struct sxe2_drv_flow_fnav_query_stat_req req = { 0 };
    1872                 :          0 :         struct sxe2_drv_flow_fnav_query_stat_resp resp = { 0 };
    1873                 :          0 :         struct sxe2_drv_cmd_params cmd             = { 0 };
    1874                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1875                 :          0 :         int32_t ret                                 = -1;
    1876                 :            : 
    1877                 :          0 :         req.stat_id = mgr->stat_index;
    1878                 :          0 :         req.stat_ctrl = mgr->count_type;
    1879                 :          0 :         req.is_clear = 1;
    1880                 :            : 
    1881         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_ACL_STAT_QUERY,
    1882                 :            :                                  &req, sizeof(req), &resp, sizeof(resp));
    1883                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &cmd);
    1884         [ #  # ]:          0 :         if (ret) {
    1885                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to query ACL stat, stat id: %u, ret: %d.",
    1886                 :            :                                 req.stat_id, ret);
    1887                 :          0 :                 goto l_end;
    1888                 :            :         }
    1889                 :          0 :         mgr->hits += resp.stat_hits;
    1890                 :          0 :         mgr->bytes += resp.stat_bytes;
    1891                 :            : 
    1892                 :          0 : l_end:
    1893                 :          0 :         return ret;
    1894                 :            : }
    1895                 :            : 
    1896                 :          0 : int32_t sxe2_drv_srcvsi_prune_config(struct sxe2_adapter *adapter,
    1897                 :            :                         uint16_t *vsi_list, uint16_t vsi_cnt, bool set)
    1898                 :            : {
    1899                 :          0 :         int32_t ret = 0;
    1900                 :          0 :         uint16_t idx;
    1901                 :          0 :         struct sxe2_common_device *cdev = adapter->cdev;
    1902                 :          0 :         struct sxe2_drv_cmd_params param = {0};
    1903                 :          0 :         struct sxe2_srcvsi_ext_cfg_req srcvsi_list_prune_cfg_req = {0};
    1904                 :            : 
    1905                 :          0 :         srcvsi_list_prune_cfg_req.vsi_id = adapter->vsi_ctxt.dpdk_vsi_id;
    1906                 :          0 :         srcvsi_list_prune_cfg_req.is_add = set;
    1907                 :          0 :         srcvsi_list_prune_cfg_req.srcvsi_cnt = vsi_cnt;
    1908         [ #  # ]:          0 :         for (idx = 0; idx < vsi_cnt; idx++)
    1909                 :          0 :                 srcvsi_list_prune_cfg_req.srcvsi_list[idx] = vsi_list[idx];
    1910                 :            : 
    1911         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &param, SXE2_DRV_CMD_VSI_SRCVSI_PRUNE,
    1912                 :            :                                  &srcvsi_list_prune_cfg_req,
    1913                 :            :                                  sizeof(srcvsi_list_prune_cfg_req),
    1914                 :            :                                  NULL, 0);
    1915                 :          0 :         ret = sxe2_drv_cmd_exec(cdev, &param);
    1916         [ #  # ]:          0 :         if (ret)
    1917                 :          0 :                 PMD_DEV_LOG_WARN(adapter, DRV, "srcvsi prune config failed, ret=%d", ret);
    1918                 :            : 
    1919                 :          0 :         return ret;
    1920                 :            : }
    1921                 :            : 
    1922                 :          0 : int32_t sxe2_drv_sfp_eeprom_read(struct sxe2_adapter *adapter, struct sxe2_sfp_read_info *sfp_info)
    1923                 :            : {
    1924                 :          0 :         int32_t ret = -1;
    1925                 :          0 :         struct sxe2_drv_sfp_req req = {0};
    1926                 :          0 :         struct sxe2_drv_sfp_resp *resp = NULL;
    1927                 :          0 :         struct sxe2_drv_cmd_params cmd = {0};
    1928                 :            : 
    1929                 :          0 :         resp = rte_zmalloc("read sfp data", sizeof(*resp) + sfp_info->len, 0);
    1930         [ #  # ]:          0 :         if (!resp) {
    1931                 :          0 :                 PMD_LOG_ERR(DRV, "Alloc memory failed");
    1932                 :          0 :                 ret = -ENOMEM;
    1933                 :          0 :                 goto l_end;
    1934                 :            :         }
    1935                 :            : 
    1936                 :          0 :         req.is_wr = false;
    1937                 :          0 :         req.is_qsfp = sfp_info->is_qsfp;
    1938                 :          0 :         req.page_cnt = rte_cpu_to_le_16(sfp_info->page_cnt);
    1939                 :          0 :         req.offset = rte_cpu_to_le_16(sfp_info->offset);
    1940                 :          0 :         req.data_len = rte_cpu_to_le_16(sfp_info->len);
    1941                 :          0 :         req.bus_addr = rte_cpu_to_le_16(sfp_info->bus_addr);
    1942                 :            : 
    1943                 :          0 :         PMD_DEV_LOG_INFO(adapter, DRV, "is_qsfp=%u, page_cnt=%u, offset=%u, datalen=%u, "
    1944                 :            :                          "bus_addr=%u", sfp_info->is_qsfp, sfp_info->page_cnt, sfp_info->offset,
    1945                 :            :                          sfp_info->len, sfp_info->bus_addr);
    1946                 :            : 
    1947         [ #  # ]:          0 :         sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_OPT_EEP_GET,
    1948                 :            :                                  &req, sizeof(req),
    1949                 :            :                                  resp, sizeof(*resp) + sfp_info->len);
    1950                 :          0 :         ret = sxe2_drv_cmd_exec(adapter->cdev, &cmd);
    1951         [ #  # ]:          0 :         if (ret) {
    1952                 :          0 :                 PMD_DEV_LOG_ERR(adapter, DRV, "Failed to read sfp, ret=%d", ret);
    1953                 :          0 :                 goto l_end;
    1954                 :            :         }
    1955                 :            : 
    1956                 :          0 :         ret = 0;
    1957         [ #  # ]:          0 :         rte_memcpy(sfp_info->data, resp->data, sfp_info->len);
    1958                 :            : 
    1959         [ #  # ]:          0 : l_end:
    1960         [ #  # ]:          0 :         if (resp) {
    1961                 :          0 :                 rte_free(resp);
    1962                 :          0 :                 resp = NULL;
    1963                 :            :         }
    1964                 :            : 
    1965                 :          0 :         return ret;
    1966                 :            : }

Generated by: LCOV version 1.14