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 161 0.0 %
Date: 2025-11-01 17:50:34 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 52 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                 :            : #define VCPF_CFQ_MB_INDEX                0xFF
     110                 :            : int
     111                 :          0 : vcpf_add_queues(struct cpfl_adapter_ext *adapter)
     112                 :            : {
     113                 :            :         struct virtchnl2_add_queues add_cfgq;
     114                 :            :         struct idpf_cmd_info args;
     115                 :            :         int err;
     116                 :            : 
     117                 :            :         memset(&add_cfgq, 0, sizeof(struct virtchnl2_add_queues));
     118                 :            :         u16 num_cfgq = 1;
     119                 :            : 
     120                 :          0 :         add_cfgq.num_tx_q = rte_cpu_to_le_16(num_cfgq);
     121                 :          0 :         add_cfgq.num_rx_q = rte_cpu_to_le_16(num_cfgq);
     122                 :          0 :         add_cfgq.mbx_q_index = VCPF_CFQ_MB_INDEX;
     123                 :            : 
     124                 :          0 :         add_cfgq.vport_id = rte_cpu_to_le_32(VCPF_CFGQ_VPORT_ID);
     125                 :            :         add_cfgq.num_tx_complq = 0;
     126                 :            :         add_cfgq.num_rx_bufq = 0;
     127                 :            : 
     128                 :            :         memset(&args, 0, sizeof(args));
     129                 :          0 :         args.ops = VIRTCHNL2_OP_ADD_QUEUES;
     130                 :          0 :         args.in_args = (uint8_t *)&add_cfgq;
     131                 :          0 :         args.in_args_size = sizeof(add_cfgq);
     132                 :          0 :         args.out_buffer = adapter->base.mbx_resp;
     133                 :          0 :         args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
     134                 :            : 
     135                 :          0 :         err = idpf_vc_cmd_execute(&adapter->base, &args);
     136         [ #  # ]:          0 :         if (err) {
     137                 :          0 :                 PMD_DRV_LOG(ERR,
     138                 :            :                             "Failed to execute command VIRTCHNL2_OP_ADD_QUEUES");
     139                 :          0 :                 return err;
     140                 :            :         }
     141                 :            : 
     142         [ #  # ]:          0 :         rte_memcpy(adapter->addq_recv_info, args.out_buffer, IDPF_DFLT_MBX_BUF_SIZE);
     143                 :            : 
     144                 :            :         return err;
     145                 :            : }
     146                 :            : 
     147                 :            : int
     148                 :          0 : vcpf_del_queues(struct cpfl_adapter_ext *adapter)
     149                 :            : {
     150                 :            :         struct virtchnl2_del_ena_dis_queues *del_cfgq;
     151                 :            :         u16 num_chunks;
     152                 :            :         struct idpf_cmd_info args;
     153                 :            :         int i, err, size;
     154                 :            : 
     155                 :          0 :         num_chunks = adapter->cfgq_in.cfgq_add->chunks.num_chunks;
     156                 :          0 :         size = idpf_struct_size(del_cfgq, chunks.chunks, (num_chunks - 1));
     157                 :          0 :         del_cfgq = rte_zmalloc("del_cfgq", size, 0);
     158         [ #  # ]:          0 :         if (!del_cfgq) {
     159                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to allocate virtchnl2_del_ena_dis_queues");
     160                 :            :                 err = -ENOMEM;
     161                 :          0 :                 return err;
     162                 :            :         }
     163                 :            : 
     164                 :          0 :         del_cfgq->vport_id = rte_cpu_to_le_32(VCPF_CFGQ_VPORT_ID);
     165                 :          0 :         del_cfgq->chunks.num_chunks = num_chunks;
     166                 :            : 
     167                 :            :         /* fill config queue chunk data */
     168         [ #  # ]:          0 :         for (i = 0; i < num_chunks; i++) {
     169                 :          0 :                 del_cfgq->chunks.chunks[i].type =
     170                 :          0 :                         adapter->cfgq_in.cfgq_add->chunks.chunks[i].type;
     171                 :          0 :                 del_cfgq->chunks.chunks[i].start_queue_id =
     172                 :          0 :                         adapter->cfgq_in.cfgq_add->chunks.chunks[i].start_queue_id;
     173                 :          0 :                 del_cfgq->chunks.chunks[i].num_queues =
     174                 :          0 :                         adapter->cfgq_in.cfgq_add->chunks.chunks[i].num_queues;
     175                 :            :         }
     176                 :            : 
     177                 :            :         memset(&args, 0, sizeof(args));
     178                 :          0 :         args.ops = VIRTCHNL2_OP_DEL_QUEUES;
     179                 :          0 :         args.in_args = (uint8_t *)del_cfgq;
     180                 :          0 :         args.in_args_size = idpf_struct_size(del_cfgq, chunks.chunks,
     181                 :            :                                                 (del_cfgq->chunks.num_chunks - 1));
     182                 :          0 :         args.out_buffer = adapter->base.mbx_resp;
     183                 :          0 :         args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
     184                 :            : 
     185                 :          0 :         err = idpf_vc_cmd_execute(&adapter->base, &args);
     186                 :          0 :         rte_free(del_cfgq);
     187         [ #  # ]:          0 :         if (err) {
     188                 :          0 :                 PMD_DRV_LOG(ERR,
     189                 :            :                             "Failed to execute command VIRTCHNL2_OP_DEL_QUEUES");
     190                 :          0 :                 return err;
     191                 :            :         }
     192                 :            : 
     193         [ #  # ]:          0 :         if (adapter->cfgq_info) {
     194                 :          0 :                 rte_free(adapter->cfgq_info);
     195                 :          0 :                 adapter->cfgq_info = NULL;
     196                 :            :         }
     197                 :          0 :         adapter->cfgq_in.num_cfgq = 0;
     198         [ #  # ]:          0 :         if (adapter->cfgq_in.cfgq_add) {
     199                 :          0 :                 rte_free(adapter->cfgq_in.cfgq_add);
     200                 :          0 :                 adapter->cfgq_in.cfgq_add = NULL;
     201                 :            :         }
     202         [ #  # ]:          0 :         if (adapter->cfgq_in.cfgq) {
     203                 :          0 :                 rte_free(adapter->cfgq_in.cfgq);
     204                 :          0 :                 adapter->cfgq_in.cfgq = NULL;
     205                 :            :         }
     206                 :            :         return err;
     207                 :            : }
     208                 :            : 
     209                 :            : int
     210                 :          0 : cpfl_config_ctlq_rx(struct cpfl_adapter_ext *adapter)
     211                 :            : {
     212                 :            :         struct cpfl_vport *vport = &adapter->ctrl_vport;
     213                 :            :         struct virtchnl2_config_rx_queues *vc_rxqs = NULL;
     214                 :            :         struct virtchnl2_rxq_info *rxq_info;
     215                 :            :         struct idpf_cmd_info args;
     216                 :            :         uint16_t num_qs;
     217                 :            :         int size, err, i;
     218                 :            : 
     219         [ #  # ]:          0 :         if (adapter->base.hw.device_id != IXD_DEV_ID_VCPF) {
     220         [ #  # ]:          0 :                 if (vport->base.rxq_model != VIRTCHNL2_QUEUE_MODEL_SINGLE) {
     221                 :          0 :                         PMD_DRV_LOG(ERR, "This rxq model isn't supported.");
     222                 :            :                         err = -EINVAL;
     223                 :          0 :                         return err;
     224                 :            :                 }
     225                 :            :         }
     226                 :            : 
     227                 :          0 :         num_qs = adapter->num_rx_cfgq;
     228                 :            : 
     229                 :          0 :         size = sizeof(*vc_rxqs) + (num_qs - 1) *
     230                 :            :                 sizeof(struct virtchnl2_rxq_info);
     231                 :          0 :         vc_rxqs = rte_zmalloc("cfg_rxqs", size, 0);
     232         [ #  # ]:          0 :         if (!vc_rxqs) {
     233                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to allocate virtchnl2_config_rx_queues");
     234                 :            :                 err = -ENOMEM;
     235                 :          0 :                 return err;
     236                 :            :         }
     237                 :            : 
     238         [ #  # ]:          0 :         if (adapter->base.hw.device_id == IXD_DEV_ID_VCPF)
     239                 :          0 :                 vc_rxqs->vport_id = rte_cpu_to_le_32(VCPF_CFGQ_VPORT_ID);
     240                 :            :         else
     241                 :          0 :                 vc_rxqs->vport_id = vport->base.vport_id;
     242                 :            : 
     243                 :          0 :         vc_rxqs->num_qinfo = num_qs;
     244                 :            : 
     245         [ #  # ]:          0 :         for (i = 0; i < num_qs; i++) {
     246                 :            :                 rxq_info = &vc_rxqs->qinfo[i];
     247                 :          0 :                 rxq_info->dma_ring_addr = adapter->ctlqp[2 * i + 1]->desc_ring.pa;
     248                 :          0 :                 rxq_info->type = VIRTCHNL2_QUEUE_TYPE_CONFIG_RX;
     249                 :          0 :                 rxq_info->queue_id = adapter->cfgq_info[2 * i + 1].id;
     250                 :          0 :                 rxq_info->model = VIRTCHNL2_QUEUE_MODEL_SINGLE;
     251                 :          0 :                 rxq_info->data_buffer_size = adapter->cfgq_info[2 * i + 1].buf_size;
     252         [ #  # ]:          0 :                 if (adapter->base.hw.device_id != IXD_DEV_ID_VCPF)
     253                 :          0 :                         rxq_info->max_pkt_size = vport->base.max_pkt_len;
     254                 :          0 :                 rxq_info->desc_ids = VIRTCHNL2_RXDID_2_FLEX_SQ_NIC_M;
     255                 :          0 :                 rxq_info->qflags |= VIRTCHNL2_RX_DESC_SIZE_32BYTE;
     256                 :          0 :                 rxq_info->ring_len = adapter->cfgq_info[2 * i + 1].len;
     257                 :            :         }
     258                 :            : 
     259                 :            :         memset(&args, 0, sizeof(args));
     260                 :          0 :         args.ops = VIRTCHNL2_OP_CONFIG_RX_QUEUES;
     261                 :          0 :         args.in_args = (uint8_t *)vc_rxqs;
     262                 :          0 :         args.in_args_size = size;
     263                 :          0 :         args.out_buffer = adapter->base.mbx_resp;
     264                 :          0 :         args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
     265                 :            : 
     266                 :          0 :         err = idpf_vc_cmd_execute(&adapter->base, &args);
     267                 :          0 :         rte_free(vc_rxqs);
     268         [ #  # ]:          0 :         if (err)
     269                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_CONFIG_RX_QUEUES");
     270                 :            : 
     271                 :            :         return err;
     272                 :            : }
     273                 :            : 
     274                 :            : int
     275                 :          0 : cpfl_config_ctlq_tx(struct cpfl_adapter_ext *adapter)
     276                 :            : {
     277                 :            :         struct cpfl_vport *vport = &adapter->ctrl_vport;
     278                 :            :         struct virtchnl2_config_tx_queues *vc_txqs = NULL;
     279                 :            :         struct virtchnl2_txq_info *txq_info;
     280                 :            :         struct idpf_cmd_info args;
     281                 :            :         uint16_t num_qs;
     282                 :            :         int size, err, i;
     283                 :            : 
     284         [ #  # ]:          0 :         if (adapter->base.hw.device_id != IXD_DEV_ID_VCPF) {
     285         [ #  # ]:          0 :                 if (vport->base.txq_model != VIRTCHNL2_QUEUE_MODEL_SINGLE) {
     286                 :          0 :                         PMD_DRV_LOG(ERR, "This txq model isn't supported.");
     287                 :            :                         err = -EINVAL;
     288                 :          0 :                         return err;
     289                 :            :                 }
     290                 :            :         }
     291                 :            : 
     292                 :          0 :         num_qs = adapter->num_tx_cfgq;
     293                 :            : 
     294                 :          0 :         size = sizeof(*vc_txqs) + (num_qs - 1) *
     295                 :            :                 sizeof(struct virtchnl2_txq_info);
     296                 :          0 :         vc_txqs = rte_zmalloc("cfg_txqs", size, 0);
     297         [ #  # ]:          0 :         if (!vc_txqs) {
     298                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to allocate virtchnl2_config_tx_queues");
     299                 :            :                 err = -ENOMEM;
     300                 :          0 :                 return err;
     301                 :            :         }
     302                 :            : 
     303         [ #  # ]:          0 :         if (adapter->base.hw.device_id == IXD_DEV_ID_VCPF)
     304                 :          0 :                 vc_txqs->vport_id = rte_cpu_to_le_32(VCPF_CFGQ_VPORT_ID);
     305                 :            :         else
     306                 :          0 :                 vc_txqs->vport_id = vport->base.vport_id;
     307                 :            : 
     308                 :          0 :         vc_txqs->num_qinfo = num_qs;
     309                 :            : 
     310         [ #  # ]:          0 :         for (i = 0; i < num_qs; i++) {
     311                 :            :                 txq_info = &vc_txqs->qinfo[i];
     312                 :          0 :                 txq_info->dma_ring_addr = adapter->ctlqp[2 * i]->desc_ring.pa;
     313                 :          0 :                 txq_info->type = VIRTCHNL2_QUEUE_TYPE_CONFIG_TX;
     314                 :          0 :                 txq_info->queue_id = adapter->cfgq_info[2 * i].id;
     315                 :          0 :                 txq_info->model = VIRTCHNL2_QUEUE_MODEL_SINGLE;
     316                 :          0 :                 txq_info->sched_mode = VIRTCHNL2_TXQ_SCHED_MODE_QUEUE;
     317                 :          0 :                 txq_info->ring_len = adapter->cfgq_info[2 * i].len;
     318                 :            :         }
     319                 :            : 
     320                 :            :         memset(&args, 0, sizeof(args));
     321                 :          0 :         args.ops = VIRTCHNL2_OP_CONFIG_TX_QUEUES;
     322                 :          0 :         args.in_args = (uint8_t *)vc_txqs;
     323                 :          0 :         args.in_args_size = size;
     324                 :          0 :         args.out_buffer = adapter->base.mbx_resp;
     325                 :          0 :         args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
     326                 :            : 
     327                 :          0 :         err = idpf_vc_cmd_execute(&adapter->base, &args);
     328                 :          0 :         rte_free(vc_txqs);
     329         [ #  # ]:          0 :         if (err)
     330                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_CONFIG_TX_QUEUES");
     331                 :            : 
     332                 :            :         return err;
     333                 :            : }

Generated by: LCOV version 1.14