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

Generated by: LCOV version 1.14