LCOV - code coverage report
Current view: top level - drivers/net/bnxt - bnxt_reps.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 404 0.0 %
Date: 2024-01-22 15:35:40 Functions: 0 25 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 168 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2014-2023 Broadcom
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "bnxt.h"
       7                 :            : #include "bnxt_ring.h"
       8                 :            : #include "bnxt_reps.h"
       9                 :            : #include "bnxt_rxq.h"
      10                 :            : #include "bnxt_rxr.h"
      11                 :            : #include "bnxt_txq.h"
      12                 :            : #include "bnxt_txr.h"
      13                 :            : #include "bnxt_hwrm.h"
      14                 :            : #include "hsi_struct_def_dpdk.h"
      15                 :            : #include "bnxt_tf_common.h"
      16                 :            : #include "ulp_port_db.h"
      17                 :            : #include "ulp_flow_db.h"
      18                 :            : 
      19                 :            : static const struct eth_dev_ops bnxt_rep_dev_ops = {
      20                 :            :         .dev_infos_get = bnxt_rep_dev_info_get_op,
      21                 :            :         .dev_configure = bnxt_rep_dev_configure_op,
      22                 :            :         .dev_start = bnxt_rep_dev_start_op,
      23                 :            :         .rx_queue_setup = bnxt_rep_rx_queue_setup_op,
      24                 :            :         .rx_queue_release = bnxt_rep_rx_queue_release_op,
      25                 :            :         .tx_queue_setup = bnxt_rep_tx_queue_setup_op,
      26                 :            :         .tx_queue_release = bnxt_rep_tx_queue_release_op,
      27                 :            :         .link_update = bnxt_rep_link_update_op,
      28                 :            :         .dev_close = bnxt_rep_dev_close_op,
      29                 :            :         .dev_stop = bnxt_rep_dev_stop_op,
      30                 :            :         .stats_get = bnxt_rep_stats_get_op,
      31                 :            :         .stats_reset = bnxt_rep_stats_reset_op,
      32                 :            :         .flow_ops_get = bnxt_flow_ops_get_op
      33                 :            : };
      34                 :            : 
      35                 :            : uint16_t
      36                 :          0 : bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf)
      37                 :            : {
      38                 :            :         struct bnxt_representor *vfr_bp = NULL;
      39                 :            :         struct bnxt_rx_ring_info *rep_rxr;
      40                 :            :         struct rte_eth_dev *vfr_eth_dev;
      41                 :            :         struct rte_mbuf **prod_rx_buf;
      42                 :            :         struct bnxt_rx_queue *rep_rxq;
      43                 :            :         uint16_t mask;
      44                 :            :         uint8_t que;
      45                 :            : 
      46                 :          0 :         vfr_eth_dev = &rte_eth_devices[port_id];
      47                 :          0 :         vfr_bp = vfr_eth_dev ? vfr_eth_dev->data->dev_private : NULL;
      48                 :            : 
      49         [ #  # ]:          0 :         if (unlikely(vfr_bp == NULL))
      50                 :            :                 return 1;
      51                 :            : 
      52                 :            :         /* If rxq_id happens to be > nr_rings, use ring 0 */
      53         [ #  # ]:          0 :         que = queue_id < vfr_bp->rx_nr_rings ? queue_id : 0;
      54                 :          0 :         rep_rxq = vfr_bp->rx_queues[que];
      55                 :            :         /* Ideally should not happen now, paranoid check */
      56         [ #  # ]:          0 :         if (!rep_rxq)
      57                 :            :                 return 1;
      58                 :          0 :         rep_rxr = rep_rxq->rx_ring;
      59                 :          0 :         mask = rep_rxr->rx_ring_struct->ring_mask;
      60                 :            : 
      61                 :            :         /* Put this mbuf on the RxQ of the Representor */
      62                 :          0 :         prod_rx_buf = &rep_rxr->rx_buf_ring[rep_rxr->rx_raw_prod & mask];
      63         [ #  # ]:          0 :         if (*prod_rx_buf == NULL) {
      64                 :          0 :                 *prod_rx_buf = mbuf;
      65                 :          0 :                 vfr_bp->rx_bytes[que] += mbuf->pkt_len;
      66                 :          0 :                 vfr_bp->rx_pkts[que]++;
      67                 :          0 :                 rep_rxr->rx_raw_prod++;
      68                 :            :         } else {
      69                 :            :                 /* Representor Rx ring full, drop pkt */
      70                 :          0 :                 vfr_bp->rx_drop_bytes[que] += mbuf->pkt_len;
      71         [ #  # ]:          0 :                 vfr_bp->rx_drop_pkts[que]++;
      72                 :            :                 rte_mbuf_raw_free(mbuf);
      73                 :            :         }
      74                 :            : 
      75                 :            :         return 0;
      76                 :            : }
      77                 :            : 
      78                 :            : static uint16_t
      79                 :          0 : bnxt_rep_rx_burst(void *rx_queue,
      80                 :            :                      struct rte_mbuf **rx_pkts,
      81                 :            :                      uint16_t nb_pkts)
      82                 :            : {
      83                 :            :         struct bnxt_rx_queue *rxq = rx_queue;
      84                 :            :         struct rte_mbuf **cons_rx_buf;
      85                 :            :         struct bnxt_rx_ring_info *rxr;
      86                 :            :         uint16_t nb_rx_pkts = 0;
      87                 :            :         uint16_t mask, i;
      88                 :            : 
      89         [ #  # ]:          0 :         if (!rxq)
      90                 :            :                 return 0;
      91                 :            : 
      92                 :          0 :         rxr = rxq->rx_ring;
      93                 :          0 :         mask = rxr->rx_ring_struct->ring_mask;
      94         [ #  # ]:          0 :         for (i = 0; i < nb_pkts; i++) {
      95                 :          0 :                 cons_rx_buf = &rxr->rx_buf_ring[rxr->rx_cons & mask];
      96         [ #  # ]:          0 :                 if (*cons_rx_buf == NULL)
      97                 :          0 :                         return nb_rx_pkts;
      98                 :          0 :                 rx_pkts[nb_rx_pkts] = *cons_rx_buf;
      99                 :          0 :                 rx_pkts[nb_rx_pkts]->port = rxq->port_id;
     100                 :          0 :                 *cons_rx_buf = NULL;
     101                 :          0 :                 nb_rx_pkts++;
     102                 :          0 :                 rxr->rx_cons++;
     103                 :            :         }
     104                 :            : 
     105                 :            :         return nb_rx_pkts;
     106                 :            : }
     107                 :            : 
     108                 :            : static uint16_t
     109                 :          0 : bnxt_rep_tx_burst(void *tx_queue,
     110                 :            :                      struct rte_mbuf **tx_pkts,
     111                 :            :                      uint16_t nb_pkts)
     112                 :            : {
     113                 :            :         struct bnxt_vf_rep_tx_queue *vfr_txq = tx_queue;
     114                 :            :         struct bnxt_tx_queue *ptxq;
     115                 :            :         struct bnxt *parent;
     116                 :            :         struct  bnxt_representor *vf_rep_bp;
     117                 :            :         int qid;
     118                 :            :         int rc;
     119                 :            :         int i;
     120                 :            : 
     121         [ #  # ]:          0 :         if (!vfr_txq)
     122                 :            :                 return 0;
     123                 :            : 
     124                 :          0 :         qid = vfr_txq->txq->queue_id;
     125                 :          0 :         vf_rep_bp = vfr_txq->bp;
     126                 :          0 :         parent = vf_rep_bp->parent_dev->data->dev_private;
     127                 :          0 :         pthread_mutex_lock(&parent->rep_info->vfr_lock);
     128                 :          0 :         ptxq = parent->tx_queues[qid];
     129                 :            : 
     130                 :          0 :         ptxq->vfr_tx_cfa_action = vf_rep_bp->vfr_tx_cfa_action;
     131                 :            : 
     132         [ #  # ]:          0 :         for (i = 0; i < nb_pkts; i++) {
     133                 :          0 :                 vf_rep_bp->tx_bytes[qid] += tx_pkts[i]->pkt_len;
     134                 :          0 :                 vf_rep_bp->tx_pkts[qid]++;
     135                 :            :         }
     136                 :            : 
     137                 :          0 :         rc = bnxt_xmit_pkts(ptxq, tx_pkts, nb_pkts);
     138                 :          0 :         ptxq->vfr_tx_cfa_action = 0;
     139                 :          0 :         pthread_mutex_unlock(&parent->rep_info->vfr_lock);
     140                 :            : 
     141                 :          0 :         return rc;
     142                 :            : }
     143                 :            : 
     144                 :            : static int
     145                 :          0 : bnxt_get_dflt_vnic_svif(struct bnxt *bp, struct bnxt_representor *vf_rep_bp)
     146                 :            : {
     147                 :            :         struct bnxt_rep_info *rep_info;
     148                 :            :         int rc;
     149                 :            : 
     150                 :          0 :         rc = bnxt_hwrm_get_dflt_vnic_svif(bp, vf_rep_bp->fw_fid,
     151                 :            :                                           &vf_rep_bp->dflt_vnic_id,
     152                 :            :                                           &vf_rep_bp->svif);
     153         [ #  # ]:          0 :         if (rc) {
     154                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to get default vnic id of VF\n");
     155                 :          0 :                 vf_rep_bp->dflt_vnic_id = BNXT_DFLT_VNIC_ID_INVALID;
     156                 :          0 :                 vf_rep_bp->svif = BNXT_SVIF_INVALID;
     157                 :            :         } else {
     158                 :          0 :                 PMD_DRV_LOG(INFO, "vf_rep->dflt_vnic_id = %d\n",
     159                 :            :                                 vf_rep_bp->dflt_vnic_id);
     160                 :            :         }
     161         [ #  # ]:          0 :         if (vf_rep_bp->dflt_vnic_id != BNXT_DFLT_VNIC_ID_INVALID &&
     162         [ #  # ]:          0 :             vf_rep_bp->svif != BNXT_SVIF_INVALID) {
     163                 :          0 :                 rep_info = &bp->rep_info[vf_rep_bp->vf_id];
     164                 :          0 :                 rep_info->conduit_valid = true;
     165                 :            :         }
     166                 :            : 
     167                 :          0 :         return rc;
     168                 :            : }
     169                 :            : 
     170                 :          0 : int bnxt_representor_init(struct rte_eth_dev *eth_dev, void *params)
     171                 :            : {
     172                 :          0 :         struct bnxt_representor *vf_rep_bp = eth_dev->data->dev_private;
     173                 :            :         struct bnxt_representor *rep_params =
     174                 :            :                                  (struct bnxt_representor *)params;
     175                 :            :         struct rte_eth_link *link;
     176                 :            :         struct bnxt *parent_bp;
     177                 :            :         uint16_t first_vf_id;
     178                 :            :         int rc = 0;
     179                 :            : 
     180                 :          0 :         PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR init\n", eth_dev->data->port_id);
     181                 :          0 :         vf_rep_bp->vf_id = rep_params->vf_id;
     182                 :          0 :         vf_rep_bp->switch_domain_id = rep_params->switch_domain_id;
     183                 :          0 :         vf_rep_bp->parent_dev = rep_params->parent_dev;
     184                 :          0 :         vf_rep_bp->rep_based_pf = rep_params->rep_based_pf;
     185                 :          0 :         vf_rep_bp->flags = rep_params->flags;
     186                 :          0 :         vf_rep_bp->rep_q_r2f = rep_params->rep_q_r2f;
     187                 :          0 :         vf_rep_bp->rep_q_f2r = rep_params->rep_q_f2r;
     188                 :          0 :         vf_rep_bp->rep_fc_r2f = rep_params->rep_fc_r2f;
     189                 :          0 :         vf_rep_bp->rep_fc_f2r = rep_params->rep_fc_f2r;
     190                 :            : 
     191                 :          0 :         eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR |
     192                 :            :                                         RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
     193                 :          0 :         eth_dev->data->representor_id = rep_params->vf_id;
     194                 :          0 :         eth_dev->data->backer_port_id = rep_params->parent_dev->data->port_id;
     195                 :            : 
     196                 :          0 :         rte_eth_random_addr(vf_rep_bp->dflt_mac_addr);
     197                 :          0 :         memcpy(vf_rep_bp->mac_addr, vf_rep_bp->dflt_mac_addr,
     198                 :            :                sizeof(vf_rep_bp->mac_addr));
     199                 :          0 :         eth_dev->data->mac_addrs =
     200                 :            :                 (struct rte_ether_addr *)&vf_rep_bp->mac_addr;
     201                 :          0 :         eth_dev->dev_ops = &bnxt_rep_dev_ops;
     202                 :            : 
     203                 :            :         /* No data-path, but need stub Rx/Tx functions to avoid crash
     204                 :            :          * when testing with ovs-dpdk
     205                 :            :          */
     206                 :          0 :         eth_dev->rx_pkt_burst = bnxt_rep_rx_burst;
     207                 :          0 :         eth_dev->tx_pkt_burst = bnxt_rep_tx_burst;
     208                 :            :         /* Link state. Inherited from PF or trusted VF */
     209                 :          0 :         parent_bp = vf_rep_bp->parent_dev->data->dev_private;
     210                 :          0 :         link = &parent_bp->eth_dev->data->dev_link;
     211                 :            : 
     212                 :          0 :         eth_dev->data->dev_link.link_speed = link->link_speed;
     213                 :          0 :         eth_dev->data->dev_link.link_duplex = link->link_duplex;
     214                 :          0 :         eth_dev->data->dev_link.link_status = link->link_status;
     215                 :          0 :         eth_dev->data->dev_link.link_autoneg = link->link_autoneg;
     216                 :            : 
     217                 :          0 :         bnxt_print_link_info(eth_dev);
     218                 :            : 
     219                 :          0 :         PMD_DRV_LOG(INFO,
     220                 :            :                     "Switch domain id %d: Representor Device %d init done\n",
     221                 :            :                     vf_rep_bp->switch_domain_id, vf_rep_bp->vf_id);
     222                 :            : 
     223         [ #  # ]:          0 :         if (BNXT_REP_BASED_PF(vf_rep_bp)) {
     224                 :          0 :                 vf_rep_bp->fw_fid = vf_rep_bp->rep_based_pf + 1;
     225                 :          0 :                 vf_rep_bp->parent_pf_idx = vf_rep_bp->rep_based_pf;
     226         [ #  # ]:          0 :                 if (!(BNXT_REP_PF(vf_rep_bp))) {
     227                 :            :                         /* VF representor for the remote PF,get first_vf_id */
     228                 :          0 :                         rc = bnxt_hwrm_first_vf_id_query(parent_bp,
     229                 :            :                                                          vf_rep_bp->fw_fid,
     230                 :            :                                                          &first_vf_id);
     231         [ #  # ]:          0 :                         if (rc)
     232                 :            :                                 return rc;
     233         [ #  # ]:          0 :                         if (first_vf_id == 0xffff) {
     234                 :          0 :                                 PMD_DRV_LOG(ERR,
     235                 :            :                                             "Invalid first_vf_id fid:%x\n",
     236                 :            :                                             vf_rep_bp->fw_fid);
     237                 :          0 :                                 return -EINVAL;
     238                 :            :                         }
     239                 :          0 :                         PMD_DRV_LOG(INFO, "first_vf_id = %x parent_fid:%x\n",
     240                 :            :                                     first_vf_id, vf_rep_bp->fw_fid);
     241                 :          0 :                         vf_rep_bp->fw_fid = rep_params->vf_id + first_vf_id;
     242                 :            :                 }
     243                 :            :         }  else {
     244                 :          0 :                 vf_rep_bp->fw_fid = rep_params->vf_id + parent_bp->first_vf_id;
     245         [ #  # ]:          0 :                 if (BNXT_VF_IS_TRUSTED(parent_bp))
     246                 :          0 :                         vf_rep_bp->parent_pf_idx = parent_bp->parent->fid - 1;
     247                 :            :                 else
     248                 :          0 :                         vf_rep_bp->parent_pf_idx = parent_bp->fw_fid - 1;
     249                 :            :         }
     250                 :            : 
     251                 :          0 :         PMD_DRV_LOG(INFO, "vf_rep->fw_fid = %d\n", vf_rep_bp->fw_fid);
     252                 :            : 
     253                 :          0 :         return 0;
     254                 :            : }
     255                 :            : 
     256                 :          0 : int bnxt_representor_uninit(struct rte_eth_dev *eth_dev)
     257                 :            : {
     258                 :            :         struct bnxt *parent_bp;
     259                 :          0 :         struct bnxt_representor *rep =
     260                 :          0 :                 (struct bnxt_representor *)eth_dev->data->dev_private;
     261                 :            :         uint16_t vf_id;
     262                 :            : 
     263         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
     264                 :            :                 return 0;
     265                 :            : 
     266                 :          0 :         PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR uninit\n", eth_dev->data->port_id);
     267                 :          0 :         eth_dev->data->mac_addrs = NULL;
     268                 :            : 
     269                 :          0 :         parent_bp = rep->parent_dev->data->dev_private;
     270         [ #  # ]:          0 :         if (!parent_bp) {
     271                 :          0 :                 PMD_DRV_LOG(DEBUG, "BNXT Port:%d already freed\n",
     272                 :            :                             eth_dev->data->port_id);
     273                 :          0 :                 return 0;
     274                 :            :         }
     275                 :            : 
     276                 :          0 :         parent_bp->num_reps--;
     277                 :          0 :         vf_id = rep->vf_id;
     278         [ #  # ]:          0 :         if (parent_bp->rep_info)
     279                 :          0 :                 memset(&parent_bp->rep_info[vf_id], 0,
     280                 :            :                        sizeof(parent_bp->rep_info[vf_id]));
     281                 :            :                 /* mark that this representor has been freed */
     282                 :            :         return 0;
     283                 :            : }
     284                 :            : 
     285                 :          0 : int bnxt_rep_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_compl)
     286                 :            : {
     287                 :            :         struct bnxt *parent_bp;
     288                 :          0 :         struct bnxt_representor *rep =
     289                 :          0 :                 (struct bnxt_representor *)eth_dev->data->dev_private;
     290                 :            :         struct rte_eth_link *link;
     291                 :            :         int rc;
     292                 :            : 
     293                 :          0 :         parent_bp = rep->parent_dev->data->dev_private;
     294         [ #  # ]:          0 :         if (!parent_bp)
     295                 :            :                 return 0;
     296                 :            : 
     297                 :          0 :         rc = bnxt_link_update_op(parent_bp->eth_dev, wait_to_compl);
     298                 :            : 
     299                 :            :         /* Link state. Inherited from PF or trusted VF */
     300                 :          0 :         link = &parent_bp->eth_dev->data->dev_link;
     301                 :            : 
     302                 :          0 :         eth_dev->data->dev_link.link_speed = link->link_speed;
     303                 :          0 :         eth_dev->data->dev_link.link_duplex = link->link_duplex;
     304                 :          0 :         eth_dev->data->dev_link.link_status = link->link_status;
     305                 :          0 :         eth_dev->data->dev_link.link_autoneg = link->link_autoneg;
     306                 :          0 :         bnxt_print_link_info(eth_dev);
     307                 :            : 
     308                 :          0 :         return rc;
     309                 :            : }
     310                 :            : 
     311                 :          0 : static int bnxt_tf_vfr_alloc(struct rte_eth_dev *vfr_ethdev)
     312                 :            : {
     313                 :            :         int rc;
     314                 :          0 :         struct bnxt_representor *vfr = vfr_ethdev->data->dev_private;
     315                 :          0 :         struct rte_eth_dev *parent_dev = vfr->parent_dev;
     316                 :          0 :         struct bnxt *parent_bp = parent_dev->data->dev_private;
     317                 :            : 
     318   [ #  #  #  # ]:          0 :         if (!parent_bp || !parent_bp->ulp_ctx) {
     319                 :          0 :                 BNXT_TF_DBG(ERR, "Invalid arguments\n");
     320                 :          0 :                 return 0;
     321                 :            :         }
     322                 :            :         /* update the port id so you can backtrack to ethdev */
     323                 :          0 :         vfr->dpdk_port_id = vfr_ethdev->data->port_id;
     324                 :            : 
     325                 :            :         /* If pair is present, then delete the pair */
     326         [ #  # ]:          0 :         if (bnxt_hwrm_cfa_pair_exists(parent_bp, vfr))
     327                 :          0 :                 (void)bnxt_hwrm_cfa_pair_free(parent_bp, vfr);
     328                 :            : 
     329                 :            :         /* Update the ULP portdata base with the new VFR interface */
     330                 :          0 :         rc = ulp_port_db_port_update(parent_bp->ulp_ctx, vfr_ethdev);
     331         [ #  # ]:          0 :         if (rc) {
     332                 :          0 :                 BNXT_TF_DBG(ERR, "Failed to update ulp port details vfr:%u\n",
     333                 :            :                             vfr->vf_id);
     334                 :          0 :                 return rc;
     335                 :            :         }
     336                 :            : 
     337                 :            :         /* Create the default rules for the VFR */
     338                 :          0 :         rc = bnxt_ulp_create_vfr_default_rules(vfr_ethdev);
     339         [ #  # ]:          0 :         if (rc) {
     340                 :          0 :                 BNXT_TF_DBG(ERR, "Failed to create VFR default rules vfr:%u\n",
     341                 :            :                             vfr->vf_id);
     342                 :          0 :                 return rc;
     343                 :            :         }
     344                 :            :         /* update the port id so you can backtrack to ethdev */
     345                 :          0 :         vfr->dpdk_port_id = vfr_ethdev->data->port_id;
     346                 :            : 
     347                 :          0 :         rc = bnxt_hwrm_cfa_pair_alloc(parent_bp, vfr);
     348         [ #  # ]:          0 :         if (rc) {
     349                 :          0 :                 BNXT_TF_DBG(ERR, "Failed in hwrm vfr alloc vfr:%u rc=%d\n",
     350                 :            :                             vfr->vf_id, rc);
     351                 :          0 :                 (void)bnxt_ulp_delete_vfr_default_rules(vfr);
     352                 :            :         }
     353                 :          0 :         BNXT_TF_DBG(DEBUG, "BNXT Port:%d VFR created and initialized\n",
     354                 :            :                     vfr->dpdk_port_id);
     355                 :          0 :         return rc;
     356                 :            : }
     357                 :            : 
     358                 :          0 : static int bnxt_vfr_alloc(struct rte_eth_dev *vfr_ethdev)
     359                 :            : {
     360                 :            :         int rc = 0;
     361                 :          0 :         struct bnxt_representor *vfr = vfr_ethdev->data->dev_private;
     362                 :            :         struct bnxt *parent_bp;
     363                 :            : 
     364   [ #  #  #  # ]:          0 :         if (!vfr || !vfr->parent_dev) {
     365                 :          0 :                 PMD_DRV_LOG(ERR,
     366                 :            :                                 "No memory allocated for representor\n");
     367                 :          0 :                 return -ENOMEM;
     368                 :            :         }
     369                 :            : 
     370                 :          0 :         parent_bp = vfr->parent_dev->data->dev_private;
     371   [ #  #  #  # ]:          0 :         if (parent_bp && !parent_bp->ulp_ctx) {
     372                 :          0 :                 PMD_DRV_LOG(ERR,
     373                 :            :                             "ulp context not allocated for parent\n");
     374                 :          0 :                 return -EIO;
     375                 :            :         }
     376                 :            : 
     377                 :            :         /* Check if representor has been already allocated in FW */
     378         [ #  # ]:          0 :         if (vfr->vfr_tx_cfa_action)
     379                 :            :                 return 0;
     380                 :            : 
     381                 :            :         /*
     382                 :            :          * Alloc VF rep rules in CFA after default VNIC is created.
     383                 :            :          * Otherwise the FW will create the VF-rep rules with
     384                 :            :          * default drop action.
     385                 :            :          */
     386                 :          0 :         rc = bnxt_tf_vfr_alloc(vfr_ethdev);
     387         [ #  # ]:          0 :         if (!rc)
     388                 :          0 :                 PMD_DRV_LOG(DEBUG, "allocated representor %d in FW\n",
     389                 :            :                             vfr->vf_id);
     390                 :            :         else
     391                 :          0 :                 PMD_DRV_LOG(ERR,
     392                 :            :                             "Failed to alloc representor %d in FW\n",
     393                 :            :                             vfr->vf_id);
     394                 :            : 
     395                 :            :         return rc;
     396                 :            : }
     397                 :            : 
     398                 :          0 : static void bnxt_vfr_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq)
     399                 :            : {
     400                 :            :         struct rte_mbuf **sw_ring;
     401                 :            :         unsigned int i;
     402                 :            : 
     403   [ #  #  #  # ]:          0 :         if (!rxq || !rxq->rx_ring)
     404                 :            :                 return;
     405                 :            : 
     406                 :          0 :         sw_ring = rxq->rx_ring->rx_buf_ring;
     407         [ #  # ]:          0 :         if (sw_ring) {
     408         [ #  # ]:          0 :                 for (i = 0; i < rxq->rx_ring->rx_ring_struct->ring_size; i++) {
     409         [ #  # ]:          0 :                         if (sw_ring[i]) {
     410         [ #  # ]:          0 :                                 if (sw_ring[i] != &rxq->fake_mbuf)
     411                 :            :                                         rte_pktmbuf_free_seg(sw_ring[i]);
     412                 :          0 :                                 sw_ring[i] = NULL;
     413                 :            :                         }
     414                 :            :                 }
     415                 :            :         }
     416                 :            : }
     417                 :            : 
     418                 :            : static void bnxt_rep_free_rx_mbufs(struct bnxt_representor *rep_bp)
     419                 :            : {
     420                 :            :         struct bnxt_rx_queue *rxq;
     421                 :            :         unsigned int i;
     422                 :            : 
     423   [ #  #  #  # ]:          0 :         for (i = 0; i < rep_bp->rx_nr_rings; i++) {
     424                 :          0 :                 rxq = rep_bp->rx_queues[i];
     425                 :          0 :                 bnxt_vfr_rx_queue_release_mbufs(rxq);
     426                 :            :         }
     427                 :            : }
     428                 :            : 
     429                 :          0 : int bnxt_rep_dev_start_op(struct rte_eth_dev *eth_dev)
     430                 :            : {
     431                 :          0 :         struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
     432                 :            :         struct bnxt_rep_info *rep_info;
     433                 :            :         struct bnxt *parent_bp;
     434                 :            :         int rc;
     435                 :            : 
     436                 :          0 :         parent_bp = rep_bp->parent_dev->data->dev_private;
     437                 :          0 :         rep_info = &parent_bp->rep_info[rep_bp->vf_id];
     438                 :            : 
     439                 :          0 :         BNXT_TF_DBG(DEBUG, "BNXT Port:%d VFR start\n", eth_dev->data->port_id);
     440                 :          0 :         pthread_mutex_lock(&rep_info->vfr_start_lock);
     441         [ #  # ]:          0 :         if (!rep_info->conduit_valid) {
     442                 :          0 :                 rc = bnxt_get_dflt_vnic_svif(parent_bp, rep_bp);
     443   [ #  #  #  # ]:          0 :                 if (rc || !rep_info->conduit_valid) {
     444                 :          0 :                         pthread_mutex_unlock(&rep_info->vfr_start_lock);
     445                 :          0 :                         return rc;
     446                 :            :                 }
     447                 :            :         }
     448                 :          0 :         pthread_mutex_unlock(&rep_info->vfr_start_lock);
     449                 :            : 
     450                 :          0 :         rc = bnxt_vfr_alloc(eth_dev);
     451         [ #  # ]:          0 :         if (rc) {
     452                 :          0 :                 eth_dev->data->dev_link.link_status = 0;
     453                 :            :                 bnxt_rep_free_rx_mbufs(rep_bp);
     454                 :            :                 return rc;
     455                 :            :         }
     456                 :          0 :         eth_dev->rx_pkt_burst = &bnxt_rep_rx_burst;
     457                 :          0 :         eth_dev->tx_pkt_burst = &bnxt_rep_tx_burst;
     458                 :          0 :         bnxt_rep_link_update_op(eth_dev, 1);
     459                 :            : 
     460                 :          0 :         return 0;
     461                 :            : }
     462                 :            : 
     463                 :          0 : static int bnxt_tf_vfr_free(struct bnxt_representor *vfr)
     464                 :            : {
     465                 :          0 :         BNXT_TF_DBG(DEBUG, "BNXT Port:%d VFR ulp free\n", vfr->dpdk_port_id);
     466                 :          0 :         return bnxt_ulp_delete_vfr_default_rules(vfr);
     467                 :            : }
     468                 :            : 
     469                 :          0 : static int bnxt_vfr_free(struct bnxt_representor *vfr)
     470                 :            : {
     471                 :            :         int rc = 0;
     472                 :            :         struct bnxt *parent_bp;
     473                 :            : 
     474   [ #  #  #  # ]:          0 :         if (!vfr || !vfr->parent_dev) {
     475                 :          0 :                 PMD_DRV_LOG(ERR,
     476                 :            :                             "No memory allocated for representor\n");
     477                 :          0 :                 return -ENOMEM;
     478                 :            :         }
     479                 :            : 
     480                 :          0 :         parent_bp = vfr->parent_dev->data->dev_private;
     481         [ #  # ]:          0 :         if (!parent_bp) {
     482                 :          0 :                 PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR already freed\n",
     483                 :            :                             vfr->dpdk_port_id);
     484                 :          0 :                 return 0;
     485                 :            :         }
     486                 :            : 
     487                 :            :         /* Check if representor has been already freed in FW */
     488         [ #  # ]:          0 :         if (!vfr->vfr_tx_cfa_action)
     489                 :            :                 return 0;
     490                 :            : 
     491                 :          0 :         rc = bnxt_tf_vfr_free(vfr);
     492         [ #  # ]:          0 :         if (rc) {
     493                 :          0 :                 PMD_DRV_LOG(ERR,
     494                 :            :                             "Failed to free representor %d in FW\n",
     495                 :            :                             vfr->vf_id);
     496                 :            :         }
     497                 :            : 
     498                 :          0 :         PMD_DRV_LOG(DEBUG, "freed representor %d in FW\n",
     499                 :            :                     vfr->vf_id);
     500                 :          0 :         vfr->vfr_tx_cfa_action = 0;
     501                 :            : 
     502                 :          0 :         rc = bnxt_hwrm_cfa_pair_free(parent_bp, vfr);
     503                 :            : 
     504                 :          0 :         return rc;
     505                 :            : }
     506                 :            : 
     507                 :          0 : int bnxt_rep_dev_stop_op(struct rte_eth_dev *eth_dev)
     508                 :            : {
     509                 :          0 :         struct bnxt_representor *vfr_bp = eth_dev->data->dev_private;
     510                 :            : 
     511                 :            :         /* Avoid crashes as we are about to free queues */
     512                 :          0 :         bnxt_stop_rxtx(eth_dev);
     513                 :            : 
     514                 :          0 :         BNXT_TF_DBG(DEBUG, "BNXT Port:%d VFR stop\n", eth_dev->data->port_id);
     515                 :            : 
     516                 :          0 :         bnxt_vfr_free(vfr_bp);
     517                 :            : 
     518         [ #  # ]:          0 :         if (eth_dev->data->dev_started)
     519                 :          0 :                 eth_dev->data->dev_link.link_status = 0;
     520                 :            : 
     521                 :            :         bnxt_rep_free_rx_mbufs(vfr_bp);
     522                 :            : 
     523                 :          0 :         return 0;
     524                 :            : }
     525                 :            : 
     526                 :          0 : int bnxt_rep_dev_close_op(struct rte_eth_dev *eth_dev)
     527                 :            : {
     528                 :          0 :         BNXT_TF_DBG(DEBUG, "BNXT Port:%d VFR close\n", eth_dev->data->port_id);
     529                 :          0 :         bnxt_representor_uninit(eth_dev);
     530                 :          0 :         return 0;
     531                 :            : }
     532                 :            : 
     533                 :          0 : int bnxt_rep_dev_info_get_op(struct rte_eth_dev *eth_dev,
     534                 :            :                                 struct rte_eth_dev_info *dev_info)
     535                 :            : {
     536                 :          0 :         struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
     537                 :            :         struct bnxt *parent_bp;
     538                 :            :         unsigned int max_rx_rings;
     539                 :            :         int rc = 0;
     540                 :            : 
     541                 :            :         /* MAC Specifics */
     542                 :          0 :         parent_bp = rep_bp->parent_dev->data->dev_private;
     543         [ #  # ]:          0 :         if (!parent_bp) {
     544                 :          0 :                 PMD_DRV_LOG(ERR, "Rep parent NULL!\n");
     545                 :          0 :                 return rc;
     546                 :            :         }
     547                 :          0 :         PMD_DRV_LOG(DEBUG, "Representor dev_info_get_op\n");
     548                 :          0 :         dev_info->max_mac_addrs = parent_bp->max_l2_ctx;
     549                 :          0 :         dev_info->max_hash_mac_addrs = 0;
     550                 :            : 
     551                 :          0 :         max_rx_rings = parent_bp->rx_nr_rings ?
     552         [ #  # ]:          0 :                 RTE_MIN(parent_bp->rx_nr_rings, BNXT_MAX_VF_REP_RINGS) :
     553                 :            :                 BNXT_MAX_VF_REP_RINGS;
     554                 :            : 
     555                 :            :         /* For the sake of symmetry, max_rx_queues = max_tx_queues */
     556                 :          0 :         dev_info->max_rx_queues = max_rx_rings;
     557                 :          0 :         dev_info->max_tx_queues = max_rx_rings;
     558                 :          0 :         dev_info->reta_size = bnxt_rss_hash_tbl_size(parent_bp);
     559                 :          0 :         dev_info->hash_key_size = 40;
     560                 :          0 :         dev_info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP;
     561                 :            : 
     562                 :            :         /* MTU specifics */
     563                 :          0 :         dev_info->min_mtu = RTE_ETHER_MIN_MTU;
     564                 :          0 :         dev_info->max_mtu = BNXT_MAX_MTU;
     565                 :            : 
     566                 :            :         /* Fast path specifics */
     567                 :          0 :         dev_info->min_rx_bufsize = 1;
     568                 :          0 :         dev_info->max_rx_pktlen = BNXT_MAX_PKT_LEN;
     569                 :            : 
     570                 :          0 :         dev_info->rx_offload_capa = bnxt_get_rx_port_offloads(parent_bp);
     571                 :          0 :         dev_info->tx_offload_capa = bnxt_get_tx_port_offloads(parent_bp);
     572                 :          0 :         dev_info->flow_type_rss_offloads = BNXT_ETH_RSS_SUPPORT;
     573                 :            : 
     574                 :          0 :         dev_info->switch_info.name = eth_dev->device->name;
     575                 :          0 :         dev_info->switch_info.domain_id = rep_bp->switch_domain_id;
     576                 :          0 :         dev_info->switch_info.port_id =
     577                 :          0 :                         rep_bp->vf_id & BNXT_SWITCH_PORT_ID_VF_MASK;
     578                 :            : 
     579                 :          0 :         return 0;
     580                 :            : }
     581                 :            : 
     582                 :          0 : int bnxt_rep_dev_configure_op(struct rte_eth_dev *eth_dev)
     583                 :            : {
     584                 :          0 :         struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
     585                 :            : 
     586                 :          0 :         PMD_DRV_LOG(DEBUG, "Representor dev_configure_op\n");
     587                 :          0 :         rep_bp->rx_queues = (void *)eth_dev->data->rx_queues;
     588                 :          0 :         rep_bp->tx_nr_rings = eth_dev->data->nb_tx_queues;
     589                 :          0 :         rep_bp->rx_nr_rings = eth_dev->data->nb_rx_queues;
     590                 :            : 
     591                 :          0 :         return 0;
     592                 :            : }
     593                 :            : 
     594                 :          0 : static int bnxt_init_rep_rx_ring(struct bnxt_rx_queue *rxq,
     595                 :            :                                  unsigned int socket_id)
     596                 :            : {
     597                 :            :         struct bnxt_rx_ring_info *rxr;
     598                 :            :         struct bnxt_ring *ring;
     599                 :            : 
     600                 :          0 :         rxr = rte_zmalloc_socket("bnxt_rep_rx_ring",
     601                 :            :                                  sizeof(struct bnxt_rx_ring_info),
     602                 :            :                                  RTE_CACHE_LINE_SIZE, socket_id);
     603         [ #  # ]:          0 :         if (rxr == NULL)
     604                 :            :                 return -ENOMEM;
     605                 :          0 :         rxq->rx_ring = rxr;
     606                 :            : 
     607                 :          0 :         ring = rte_zmalloc_socket("bnxt_rep_rx_ring_struct",
     608                 :            :                                   sizeof(struct bnxt_ring),
     609                 :            :                                   RTE_CACHE_LINE_SIZE, socket_id);
     610         [ #  # ]:          0 :         if (ring == NULL)
     611                 :            :                 return -ENOMEM;
     612                 :          0 :         rxr->rx_ring_struct = ring;
     613                 :          0 :         ring->ring_size = rte_align32pow2(rxq->nb_rx_desc);
     614                 :          0 :         ring->ring_mask = ring->ring_size - 1;
     615                 :            : 
     616                 :          0 :         return 0;
     617                 :            : }
     618                 :            : 
     619                 :          0 : int bnxt_rep_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
     620                 :            :                                uint16_t queue_idx,
     621                 :            :                                uint16_t nb_desc,
     622                 :            :                                unsigned int socket_id,
     623                 :            :                                __rte_unused const struct rte_eth_rxconf *rx_conf,
     624                 :            :                                __rte_unused struct rte_mempool *mp)
     625                 :            : {
     626                 :          0 :         struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
     627                 :          0 :         struct bnxt *parent_bp = rep_bp->parent_dev->data->dev_private;
     628                 :            :         struct bnxt_rx_queue *parent_rxq;
     629                 :            :         struct bnxt_rx_queue *rxq;
     630                 :            :         struct rte_mbuf **buf_ring;
     631                 :            :         int rc = 0;
     632                 :            : 
     633         [ #  # ]:          0 :         if (queue_idx >= rep_bp->rx_nr_rings) {
     634                 :          0 :                 PMD_DRV_LOG(ERR,
     635                 :            :                             "Cannot create Rx ring %d. %d rings available\n",
     636                 :            :                             queue_idx, rep_bp->rx_nr_rings);
     637                 :          0 :                 return -EINVAL;
     638                 :            :         }
     639                 :            : 
     640         [ #  # ]:          0 :         if (!nb_desc || nb_desc > MAX_RX_DESC_CNT) {
     641                 :          0 :                 PMD_DRV_LOG(ERR, "nb_desc %d is invalid\n", nb_desc);
     642                 :          0 :                 return -EINVAL;
     643                 :            :         }
     644                 :            : 
     645         [ #  # ]:          0 :         if (!parent_bp->rx_queues) {
     646                 :          0 :                 PMD_DRV_LOG(ERR, "Parent Rx qs not configured yet\n");
     647                 :          0 :                 return -EINVAL;
     648                 :            :         }
     649                 :            : 
     650                 :          0 :         parent_rxq = parent_bp->rx_queues[queue_idx];
     651         [ #  # ]:          0 :         if (!parent_rxq) {
     652                 :          0 :                 PMD_DRV_LOG(ERR, "Parent RxQ has not been configured yet\n");
     653                 :          0 :                 return -EINVAL;
     654                 :            :         }
     655                 :            : 
     656         [ #  # ]:          0 :         if (nb_desc != parent_rxq->nb_rx_desc) {
     657                 :          0 :                 PMD_DRV_LOG(ERR, "nb_desc %d do not match parent rxq", nb_desc);
     658                 :          0 :                 return -EINVAL;
     659                 :            :         }
     660                 :            : 
     661         [ #  # ]:          0 :         if (eth_dev->data->rx_queues) {
     662                 :          0 :                 rxq = eth_dev->data->rx_queues[queue_idx];
     663         [ #  # ]:          0 :                 if (rxq)
     664                 :          0 :                         bnxt_rx_queue_release_op(eth_dev, queue_idx);
     665                 :            :         }
     666                 :            : 
     667                 :          0 :         rxq = rte_zmalloc_socket("bnxt_vfr_rx_queue",
     668                 :            :                                  sizeof(struct bnxt_rx_queue),
     669                 :            :                                  RTE_CACHE_LINE_SIZE, socket_id);
     670         [ #  # ]:          0 :         if (!rxq) {
     671                 :          0 :                 PMD_DRV_LOG(ERR, "bnxt_vfr_rx_queue allocation failed!\n");
     672                 :          0 :                 return -ENOMEM;
     673                 :            :         }
     674                 :            : 
     675                 :          0 :         eth_dev->data->rx_queues[queue_idx] = rxq;
     676                 :            : 
     677                 :          0 :         rxq->nb_rx_desc = nb_desc;
     678                 :            : 
     679                 :          0 :         rc = bnxt_init_rep_rx_ring(rxq, socket_id);
     680         [ #  # ]:          0 :         if (rc)
     681                 :          0 :                 goto out;
     682                 :            : 
     683                 :          0 :         buf_ring = rte_zmalloc_socket("bnxt_rx_vfr_buf_ring",
     684                 :            :                                       sizeof(struct rte_mbuf *) *
     685                 :          0 :                                       rxq->rx_ring->rx_ring_struct->ring_size,
     686                 :            :                                       RTE_CACHE_LINE_SIZE, socket_id);
     687         [ #  # ]:          0 :         if (!buf_ring) {
     688                 :          0 :                 PMD_DRV_LOG(ERR, "bnxt_rx_vfr_buf_ring allocation failed!\n");
     689                 :            :                 rc = -ENOMEM;
     690                 :          0 :                 goto out;
     691                 :            :         }
     692                 :            : 
     693                 :          0 :         rxq->rx_ring->rx_buf_ring = buf_ring;
     694                 :          0 :         rxq->queue_id = queue_idx;
     695                 :          0 :         rxq->port_id = eth_dev->data->port_id;
     696                 :            : 
     697                 :          0 :         return 0;
     698                 :            : 
     699                 :          0 : out:
     700                 :            :         if (rxq)
     701                 :          0 :                 bnxt_rep_rx_queue_release_op(eth_dev, queue_idx);
     702                 :            : 
     703                 :          0 :         return rc;
     704                 :            : }
     705                 :            : 
     706                 :          0 : void bnxt_rep_rx_queue_release_op(struct rte_eth_dev *dev, uint16_t queue_idx)
     707                 :            : {
     708                 :          0 :         struct bnxt_rx_queue *rxq = dev->data->rx_queues[queue_idx];
     709                 :            : 
     710         [ #  # ]:          0 :         if (!rxq)
     711                 :            :                 return;
     712                 :            : 
     713                 :          0 :         bnxt_rx_queue_release_mbufs(rxq);
     714                 :            : 
     715                 :          0 :         bnxt_free_ring(rxq->rx_ring->rx_ring_struct);
     716                 :          0 :         rte_free(rxq->rx_ring->rx_ring_struct);
     717                 :          0 :         rte_free(rxq->rx_ring);
     718                 :            : 
     719                 :          0 :         rte_free(rxq);
     720                 :            : }
     721                 :            : 
     722                 :          0 : int bnxt_rep_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
     723                 :            :                                uint16_t queue_idx,
     724                 :            :                                uint16_t nb_desc,
     725                 :            :                                unsigned int socket_id,
     726                 :            :                                __rte_unused const struct rte_eth_txconf *tx_conf)
     727                 :            : {
     728                 :          0 :         struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
     729                 :          0 :         struct bnxt *parent_bp = rep_bp->parent_dev->data->dev_private;
     730                 :            :         struct bnxt_tx_queue *parent_txq, *txq;
     731                 :            :         struct bnxt_vf_rep_tx_queue *vfr_txq;
     732                 :            : 
     733         [ #  # ]:          0 :         if (queue_idx >= rep_bp->rx_nr_rings) {
     734                 :          0 :                 PMD_DRV_LOG(ERR,
     735                 :            :                             "Cannot create Tx rings %d. %d rings available\n",
     736                 :            :                             queue_idx, rep_bp->rx_nr_rings);
     737                 :          0 :                 return -EINVAL;
     738                 :            :         }
     739                 :            : 
     740         [ #  # ]:          0 :         if (!nb_desc || nb_desc > MAX_TX_DESC_CNT) {
     741                 :          0 :                 PMD_DRV_LOG(ERR, "nb_desc %d is invalid", nb_desc);
     742                 :          0 :                 return -EINVAL;
     743                 :            :         }
     744                 :            : 
     745         [ #  # ]:          0 :         if (!parent_bp->tx_queues) {
     746                 :          0 :                 PMD_DRV_LOG(ERR, "Parent Tx qs not configured yet\n");
     747                 :          0 :                 return -EINVAL;
     748                 :            :         }
     749                 :            : 
     750                 :          0 :         parent_txq = parent_bp->tx_queues[queue_idx];
     751         [ #  # ]:          0 :         if (!parent_txq) {
     752                 :          0 :                 PMD_DRV_LOG(ERR, "Parent TxQ has not been configured yet\n");
     753                 :          0 :                 return -EINVAL;
     754                 :            :         }
     755                 :            : 
     756         [ #  # ]:          0 :         if (nb_desc != parent_txq->nb_tx_desc) {
     757                 :          0 :                 PMD_DRV_LOG(ERR, "nb_desc %d do not match parent txq", nb_desc);
     758                 :          0 :                 return -EINVAL;
     759                 :            :         }
     760                 :            : 
     761         [ #  # ]:          0 :         if (eth_dev->data->tx_queues) {
     762                 :          0 :                 vfr_txq = eth_dev->data->tx_queues[queue_idx];
     763         [ #  # ]:          0 :                 if (vfr_txq != NULL)
     764                 :          0 :                         bnxt_rep_tx_queue_release_op(eth_dev, queue_idx);
     765                 :            :         }
     766                 :            : 
     767                 :          0 :         vfr_txq = rte_zmalloc_socket("bnxt_vfr_tx_queue",
     768                 :            :                                      sizeof(struct bnxt_vf_rep_tx_queue),
     769                 :            :                                      RTE_CACHE_LINE_SIZE, socket_id);
     770         [ #  # ]:          0 :         if (!vfr_txq) {
     771                 :          0 :                 PMD_DRV_LOG(ERR, "bnxt_vfr_tx_queue allocation failed!");
     772                 :          0 :                 return -ENOMEM;
     773                 :            :         }
     774                 :          0 :         txq = rte_zmalloc_socket("bnxt_tx_queue",
     775                 :            :                                  sizeof(struct bnxt_tx_queue),
     776                 :            :                                  RTE_CACHE_LINE_SIZE, socket_id);
     777         [ #  # ]:          0 :         if (!txq) {
     778                 :          0 :                 PMD_DRV_LOG(ERR, "bnxt_tx_queue allocation failed!");
     779                 :          0 :                 rte_free(vfr_txq);
     780                 :          0 :                 return -ENOMEM;
     781                 :            :         }
     782                 :            : 
     783                 :          0 :         txq->nb_tx_desc = nb_desc;
     784                 :          0 :         txq->queue_id = queue_idx;
     785                 :          0 :         txq->port_id = eth_dev->data->port_id;
     786                 :          0 :         vfr_txq->txq = txq;
     787                 :          0 :         vfr_txq->bp = rep_bp;
     788                 :          0 :         eth_dev->data->tx_queues[queue_idx] = vfr_txq;
     789                 :            : 
     790                 :          0 :         return 0;
     791                 :            : }
     792                 :            : 
     793                 :          0 : void bnxt_rep_tx_queue_release_op(struct rte_eth_dev *dev, uint16_t queue_idx)
     794                 :            : {
     795                 :          0 :         struct bnxt_vf_rep_tx_queue *vfr_txq = dev->data->tx_queues[queue_idx];
     796                 :            : 
     797         [ #  # ]:          0 :         if (!vfr_txq)
     798                 :            :                 return;
     799                 :            : 
     800                 :          0 :         rte_free(vfr_txq->txq);
     801                 :          0 :         rte_free(vfr_txq);
     802                 :          0 :         dev->data->tx_queues[queue_idx] = NULL;
     803                 :            : }
     804                 :            : 
     805                 :          0 : int bnxt_rep_stats_get_op(struct rte_eth_dev *eth_dev,
     806                 :            :                              struct rte_eth_stats *stats)
     807                 :            : {
     808                 :          0 :         struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
     809                 :            :         unsigned int i;
     810                 :            : 
     811                 :            :         memset(stats, 0, sizeof(*stats));
     812         [ #  # ]:          0 :         for (i = 0; i < rep_bp->rx_nr_rings; i++) {
     813                 :          0 :                 stats->obytes += rep_bp->tx_bytes[i];
     814                 :          0 :                 stats->opackets += rep_bp->tx_pkts[i];
     815                 :          0 :                 stats->ibytes += rep_bp->rx_bytes[i];
     816                 :          0 :                 stats->ipackets += rep_bp->rx_pkts[i];
     817                 :          0 :                 stats->imissed += rep_bp->rx_drop_pkts[i];
     818                 :            : 
     819                 :          0 :                 stats->q_ipackets[i] = rep_bp->rx_pkts[i];
     820                 :          0 :                 stats->q_ibytes[i] = rep_bp->rx_bytes[i];
     821                 :          0 :                 stats->q_opackets[i] = rep_bp->tx_pkts[i];
     822                 :          0 :                 stats->q_obytes[i] = rep_bp->tx_bytes[i];
     823                 :          0 :                 stats->q_errors[i] = rep_bp->rx_drop_pkts[i];
     824                 :            :         }
     825                 :            : 
     826                 :          0 :         return 0;
     827                 :            : }
     828                 :            : 
     829                 :          0 : int bnxt_rep_stats_reset_op(struct rte_eth_dev *eth_dev)
     830                 :            : {
     831                 :          0 :         struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
     832                 :            :         unsigned int i;
     833                 :            : 
     834         [ #  # ]:          0 :         for (i = 0; i < rep_bp->rx_nr_rings; i++) {
     835                 :          0 :                 rep_bp->tx_pkts[i] = 0;
     836                 :          0 :                 rep_bp->tx_bytes[i] = 0;
     837                 :          0 :                 rep_bp->rx_pkts[i] = 0;
     838                 :          0 :                 rep_bp->rx_bytes[i] = 0;
     839                 :          0 :                 rep_bp->rx_drop_pkts[i] = 0;
     840                 :            :         }
     841                 :          0 :         return 0;
     842                 :            : }
     843                 :            : 
     844                 :          0 : int bnxt_rep_stop_all(struct bnxt *bp)
     845                 :            : {
     846                 :            :         uint16_t vf_id;
     847                 :            :         struct rte_eth_dev *rep_eth_dev;
     848                 :            :         int ret;
     849                 :            : 
     850                 :            :         /* No vfrep ports just exit */
     851         [ #  # ]:          0 :         if (!bp->rep_info)
     852                 :            :                 return 0;
     853                 :            : 
     854   [ #  #  #  # ]:          0 :         for (vf_id = 0; vf_id < BNXT_MAX_VF_REPS(bp); vf_id++) {
     855                 :          0 :                 rep_eth_dev = bp->rep_info[vf_id].vfr_eth_dev;
     856         [ #  # ]:          0 :                 if (!rep_eth_dev)
     857                 :          0 :                         continue;
     858                 :          0 :                 ret = bnxt_rep_dev_stop_op(rep_eth_dev);
     859         [ #  # ]:          0 :                 if (ret != 0)
     860                 :          0 :                         return ret;
     861                 :            :         }
     862                 :            : 
     863                 :            :         return 0;
     864                 :            : }

Generated by: LCOV version 1.14