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

Generated by: LCOV version 1.14