LCOV - code coverage report
Current view: top level - drivers/net/intel/cpfl - cpfl_vchnl.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 99 0.0 %
Date: 2025-02-01 18:54:23 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 26 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2023 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "cpfl_ethdev.h"
       6                 :            : #include <idpf_common_virtchnl.h>
       7                 :            : 
       8                 :            : int
       9                 :          0 : cpfl_cc_vport_list_get(struct cpfl_adapter_ext *adapter,
      10                 :            :                        struct cpfl_vport_id *vi,
      11                 :            :                        struct cpchnl2_get_vport_list_response *response)
      12                 :            : {
      13                 :            :         struct cpchnl2_get_vport_list_request request;
      14                 :            :         struct idpf_cmd_info args;
      15                 :            :         int err;
      16                 :            : 
      17                 :            :         memset(&request, 0, sizeof(request));
      18                 :          0 :         request.func_type = vi->func_type;
      19                 :          0 :         request.pf_id = vi->pf_id;
      20                 :          0 :         request.vf_id = vi->vf_id;
      21                 :            : 
      22                 :            :         memset(&args, 0, sizeof(args));
      23                 :          0 :         args.ops = CPCHNL2_OP_GET_VPORT_LIST;
      24                 :          0 :         args.in_args = (uint8_t *)&request;
      25                 :          0 :         args.in_args_size = sizeof(struct cpchnl2_get_vport_list_request);
      26                 :          0 :         args.out_buffer = adapter->base.mbx_resp;
      27                 :          0 :         args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
      28                 :            : 
      29                 :          0 :         err = idpf_vc_cmd_execute(&adapter->base, &args);
      30         [ #  # ]:          0 :         if (err != 0) {
      31                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to execute command of CPCHNL2_OP_GET_VPORT_LIST");
      32                 :          0 :                 return err;
      33                 :            :         }
      34                 :            : 
      35         [ #  # ]:          0 :         rte_memcpy(response, args.out_buffer, IDPF_DFLT_MBX_BUF_SIZE);
      36                 :            : 
      37                 :            :         return 0;
      38                 :            : }
      39                 :            : 
      40                 :            : int
      41                 :          0 : cpfl_cc_vport_info_get(struct cpfl_adapter_ext *adapter,
      42                 :            :                        struct cpchnl2_vport_id *vport_id,
      43                 :            :                        struct cpfl_vport_id *vi,
      44                 :            :                        struct cpchnl2_get_vport_info_response *response)
      45                 :            : {
      46                 :            :         struct cpchnl2_get_vport_info_request request;
      47                 :            :         struct idpf_cmd_info args;
      48                 :            :         int err;
      49                 :            : 
      50                 :          0 :         request.vport.vport_id = vport_id->vport_id;
      51                 :          0 :         request.vport.vport_type = vport_id->vport_type;
      52                 :          0 :         request.func.func_type = vi->func_type;
      53                 :          0 :         request.func.pf_id = vi->pf_id;
      54                 :          0 :         request.func.vf_id = vi->vf_id;
      55                 :            : 
      56                 :            :         memset(&args, 0, sizeof(args));
      57                 :          0 :         args.ops = CPCHNL2_OP_GET_VPORT_INFO;
      58                 :          0 :         args.in_args = (uint8_t *)&request;
      59                 :          0 :         args.in_args_size = sizeof(struct cpchnl2_get_vport_info_request);
      60                 :          0 :         args.out_buffer = adapter->base.mbx_resp;
      61                 :          0 :         args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
      62                 :            : 
      63                 :          0 :         err = idpf_vc_cmd_execute(&adapter->base, &args);
      64         [ #  # ]:          0 :         if (err != 0) {
      65                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to execute command of CPCHNL2_OP_GET_VPORT_INFO");
      66                 :          0 :                 return err;
      67                 :            :         }
      68                 :            : 
      69         [ #  # ]:          0 :         rte_memcpy(response, args.out_buffer, sizeof(*response));
      70                 :            : 
      71                 :            :         return 0;
      72                 :            : }
      73                 :            : 
      74                 :            : int
      75                 :          0 : cpfl_vc_create_ctrl_vport(struct cpfl_adapter_ext *adapter)
      76                 :            : {
      77                 :            :         struct virtchnl2_create_vport vport_msg;
      78                 :            :         struct idpf_cmd_info args;
      79                 :            :         int err = -1;
      80                 :            : 
      81                 :            :         memset(&vport_msg, 0, sizeof(struct virtchnl2_create_vport));
      82                 :            :         vport_msg.vport_type = rte_cpu_to_le_16(VIRTCHNL2_VPORT_TYPE_DEFAULT);
      83                 :            :         vport_msg.txq_model = rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
      84                 :            :         vport_msg.rxq_model = rte_cpu_to_le_16(VIRTCHNL2_QUEUE_MODEL_SINGLE);
      85                 :          0 :         vport_msg.num_tx_q = CPFL_TX_CFGQ_NUM;
      86                 :            :         vport_msg.num_tx_complq = 0;
      87                 :          0 :         vport_msg.num_rx_q = CPFL_RX_CFGQ_NUM;
      88                 :            :         vport_msg.num_rx_bufq = 0;
      89                 :            : 
      90                 :            :         memset(&args, 0, sizeof(args));
      91                 :          0 :         args.ops = VIRTCHNL2_OP_CREATE_VPORT;
      92                 :          0 :         args.in_args = (uint8_t *)&vport_msg;
      93                 :          0 :         args.in_args_size = sizeof(vport_msg);
      94                 :          0 :         args.out_buffer = adapter->base.mbx_resp;
      95                 :          0 :         args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
      96                 :            : 
      97                 :          0 :         err = idpf_vc_cmd_execute(&adapter->base, &args);
      98         [ #  # ]:          0 :         if (err) {
      99                 :          0 :                 PMD_DRV_LOG(ERR,
     100                 :            :                             "Failed to execute command of VIRTCHNL2_OP_CREATE_VPORT");
     101                 :          0 :                 return err;
     102                 :            :         }
     103                 :            : 
     104                 :          0 :         memcpy(adapter->ctrl_vport_recv_info, args.out_buffer,
     105                 :            :                IDPF_DFLT_MBX_BUF_SIZE);
     106                 :          0 :         return err;
     107                 :            : }
     108                 :            : 
     109                 :            : int
     110                 :          0 : cpfl_config_ctlq_rx(struct cpfl_adapter_ext *adapter)
     111                 :            : {
     112                 :            :         struct cpfl_vport *vport = &adapter->ctrl_vport;
     113                 :            :         struct virtchnl2_config_rx_queues *vc_rxqs = NULL;
     114                 :            :         struct virtchnl2_rxq_info *rxq_info;
     115                 :            :         struct idpf_cmd_info args;
     116                 :            :         uint16_t num_qs;
     117                 :            :         int size, err, i;
     118                 :            : 
     119         [ #  # ]:          0 :         if (vport->base.rxq_model != VIRTCHNL2_QUEUE_MODEL_SINGLE) {
     120                 :          0 :                 PMD_DRV_LOG(ERR, "This rxq model isn't supported.");
     121                 :            :                 err = -EINVAL;
     122                 :          0 :                 return err;
     123                 :            :         }
     124                 :            : 
     125                 :            :         num_qs = CPFL_RX_CFGQ_NUM;
     126                 :            :         size = sizeof(*vc_rxqs) + (num_qs - 1) *
     127                 :            :                 sizeof(struct virtchnl2_rxq_info);
     128                 :          0 :         vc_rxqs = rte_zmalloc("cfg_rxqs", size, 0);
     129         [ #  # ]:          0 :         if (!vc_rxqs) {
     130                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to allocate virtchnl2_config_rx_queues");
     131                 :            :                 err = -ENOMEM;
     132                 :          0 :                 return err;
     133                 :            :         }
     134                 :          0 :         vc_rxqs->vport_id = vport->base.vport_id;
     135                 :          0 :         vc_rxqs->num_qinfo = num_qs;
     136                 :            : 
     137         [ #  # ]:          0 :         for (i = 0; i < num_qs; i++) {
     138                 :            :                 rxq_info = &vc_rxqs->qinfo[i];
     139                 :          0 :                 rxq_info->dma_ring_addr = adapter->ctlqp[2 * i + 1]->desc_ring.pa;
     140                 :          0 :                 rxq_info->type = VIRTCHNL2_QUEUE_TYPE_CONFIG_RX;
     141                 :          0 :                 rxq_info->queue_id = adapter->cfgq_info[2 * i + 1].id;
     142                 :          0 :                 rxq_info->model = VIRTCHNL2_QUEUE_MODEL_SINGLE;
     143                 :          0 :                 rxq_info->data_buffer_size = adapter->cfgq_info[2 * i + 1].buf_size;
     144                 :          0 :                 rxq_info->max_pkt_size = vport->base.max_pkt_len;
     145                 :          0 :                 rxq_info->desc_ids = VIRTCHNL2_RXDID_2_FLEX_SQ_NIC_M;
     146                 :          0 :                 rxq_info->qflags |= VIRTCHNL2_RX_DESC_SIZE_32BYTE;
     147                 :          0 :                 rxq_info->ring_len = adapter->cfgq_info[2 * i + 1].len;
     148                 :            :         }
     149                 :            : 
     150                 :            :         memset(&args, 0, sizeof(args));
     151                 :          0 :         args.ops = VIRTCHNL2_OP_CONFIG_RX_QUEUES;
     152                 :          0 :         args.in_args = (uint8_t *)vc_rxqs;
     153                 :          0 :         args.in_args_size = size;
     154                 :          0 :         args.out_buffer = adapter->base.mbx_resp;
     155                 :          0 :         args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
     156                 :            : 
     157                 :          0 :         err = idpf_vc_cmd_execute(&adapter->base, &args);
     158                 :          0 :         rte_free(vc_rxqs);
     159         [ #  # ]:          0 :         if (err)
     160                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_CONFIG_RX_QUEUES");
     161                 :            : 
     162                 :            :         return err;
     163                 :            : }
     164                 :            : 
     165                 :            : int
     166                 :          0 : cpfl_config_ctlq_tx(struct cpfl_adapter_ext *adapter)
     167                 :            : {
     168                 :            :         struct cpfl_vport *vport = &adapter->ctrl_vport;
     169                 :            :         struct virtchnl2_config_tx_queues *vc_txqs = NULL;
     170                 :            :         struct virtchnl2_txq_info *txq_info;
     171                 :            :         struct idpf_cmd_info args;
     172                 :            :         uint16_t num_qs;
     173                 :            :         int size, err, i;
     174                 :            : 
     175         [ #  # ]:          0 :         if (vport->base.txq_model != VIRTCHNL2_QUEUE_MODEL_SINGLE) {
     176                 :          0 :                 PMD_DRV_LOG(ERR, "This txq model isn't supported.");
     177                 :            :                 err = -EINVAL;
     178                 :          0 :                 return err;
     179                 :            :         }
     180                 :            : 
     181                 :            :         num_qs = CPFL_TX_CFGQ_NUM;
     182                 :            :         size = sizeof(*vc_txqs) + (num_qs - 1) *
     183                 :            :                 sizeof(struct virtchnl2_txq_info);
     184                 :          0 :         vc_txqs = rte_zmalloc("cfg_txqs", size, 0);
     185         [ #  # ]:          0 :         if (!vc_txqs) {
     186                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to allocate virtchnl2_config_tx_queues");
     187                 :            :                 err = -ENOMEM;
     188                 :          0 :                 return err;
     189                 :            :         }
     190                 :          0 :         vc_txqs->vport_id = vport->base.vport_id;
     191                 :          0 :         vc_txqs->num_qinfo = num_qs;
     192                 :            : 
     193         [ #  # ]:          0 :         for (i = 0; i < num_qs; i++) {
     194                 :            :                 txq_info = &vc_txqs->qinfo[i];
     195                 :          0 :                 txq_info->dma_ring_addr = adapter->ctlqp[2 * i]->desc_ring.pa;
     196                 :          0 :                 txq_info->type = VIRTCHNL2_QUEUE_TYPE_CONFIG_TX;
     197                 :          0 :                 txq_info->queue_id = adapter->cfgq_info[2 * i].id;
     198                 :          0 :                 txq_info->model = VIRTCHNL2_QUEUE_MODEL_SINGLE;
     199                 :          0 :                 txq_info->sched_mode = VIRTCHNL2_TXQ_SCHED_MODE_QUEUE;
     200                 :          0 :                 txq_info->ring_len = adapter->cfgq_info[2 * i].len;
     201                 :            :         }
     202                 :            : 
     203                 :            :         memset(&args, 0, sizeof(args));
     204                 :          0 :         args.ops = VIRTCHNL2_OP_CONFIG_TX_QUEUES;
     205                 :          0 :         args.in_args = (uint8_t *)vc_txqs;
     206                 :          0 :         args.in_args_size = size;
     207                 :          0 :         args.out_buffer = adapter->base.mbx_resp;
     208                 :          0 :         args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
     209                 :            : 
     210                 :          0 :         err = idpf_vc_cmd_execute(&adapter->base, &args);
     211                 :          0 :         rte_free(vc_txqs);
     212         [ #  # ]:          0 :         if (err)
     213                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_CONFIG_TX_QUEUES");
     214                 :            : 
     215                 :            :         return err;
     216                 :            : }

Generated by: LCOV version 1.14