net/bnxt: fix VF resource allocation
[dpdk.git] / drivers / net / bnxt / bnxt_ethdev.c
index 9edcc7b..62e02aa 100644 (file)
@@ -168,23 +168,12 @@ static void bnxt_free_mem(struct bnxt *bp)
        bnxt_free_stats(bp);
        bnxt_free_tx_rings(bp);
        bnxt_free_rx_rings(bp);
-       bnxt_free_def_cp_ring(bp);
 }
 
 static int bnxt_alloc_mem(struct bnxt *bp)
 {
        int rc;
 
-       /* Default completion ring */
-       rc = bnxt_init_def_ring_struct(bp, SOCKET_ID_ANY);
-       if (rc)
-               goto alloc_mem_err;
-
-       rc = bnxt_alloc_rings(bp, 0, NULL, NULL,
-                             bp->def_cp_ring, "def_cp");
-       if (rc)
-               goto alloc_mem_err;
-
        rc = bnxt_alloc_vnic_mem(bp);
        if (rc)
                goto alloc_mem_err;
@@ -417,9 +406,7 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
        /* PF/VF specifics */
        if (BNXT_PF(bp))
                dev_info->max_vfs = bp->pdev->max_vfs;
-       max_rx_rings = RTE_MIN(bp->max_vnics, RTE_MIN(bp->max_l2_ctx,
-                                               RTE_MIN(bp->max_rsscos_ctx,
-                                               bp->max_stat_ctx)));
+       max_rx_rings = RTE_MIN(bp->max_vnics, bp->max_stat_ctx);
        /* For the sake of symmetry, max_rx_queues = max_tx_queues */
        dev_info->max_rx_queues = max_rx_rings;
        dev_info->max_tx_queues = max_rx_rings;
@@ -505,15 +492,34 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 
        bp->rx_queues = (void *)eth_dev->data->rx_queues;
        bp->tx_queues = (void *)eth_dev->data->tx_queues;
+       bp->tx_nr_rings = eth_dev->data->nb_tx_queues;
+       bp->rx_nr_rings = eth_dev->data->nb_rx_queues;
+
+       if (BNXT_VF(bp) && (bp->flags & BNXT_FLAG_NEW_RM)) {
+               int rc;
+
+               rc = bnxt_hwrm_func_reserve_vf_resc(bp);
+               if (rc) {
+                       PMD_DRV_LOG(ERR, "HWRM resource alloc fail:%x\n", rc);
+                       return -ENOSPC;
+               }
+
+               /* legacy driver needs to get updated values */
+               rc = bnxt_hwrm_func_qcaps(bp);
+               if (rc) {
+                       PMD_DRV_LOG(ERR, "hwrm func qcaps fail:%d\n", rc);
+                       return -ENOSPC;
+               }
+       }
 
        /* Inherit new configurations */
        if (eth_dev->data->nb_rx_queues > bp->max_rx_rings ||
            eth_dev->data->nb_tx_queues > bp->max_tx_rings ||
-           eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues + 1 >
+           eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues >
            bp->max_cp_rings ||
            eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues >
            bp->max_stat_ctx ||
-           (uint32_t)(eth_dev->data->nb_rx_queues + 1) > bp->max_ring_grps) {
+           (uint32_t)(eth_dev->data->nb_rx_queues) > bp->max_ring_grps) {
                PMD_DRV_LOG(ERR,
                        "Insufficient resources to support requested config\n");
                PMD_DRV_LOG(ERR,
@@ -527,8 +533,6 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
                return -ENOSPC;
        }
 
-       bp->rx_nr_rings = eth_dev->data->nb_rx_queues;
-       bp->tx_nr_rings = eth_dev->data->nb_tx_queues;
        bp->rx_cp_nr_rings = bp->rx_nr_rings;
        bp->tx_cp_nr_rings = bp->tx_nr_rings;
 
@@ -2432,6 +2436,7 @@ bnxt_fdir_filter(struct rte_eth_dev *dev,
        switch (filter_op) {
        case RTE_ETH_FILTER_ADD:
        case RTE_ETH_FILTER_DELETE:
+               /* FALLTHROUGH */
                filter = bnxt_get_unused_filter(bp);
                if (filter == NULL) {
                        PMD_DRV_LOG(ERR,
@@ -2897,6 +2902,7 @@ static bool bnxt_dir_type_is_ape_bin_format(uint16_t dir_type)
        case BNX_DIR_TYPE_KONG_PATCH:
        case BNX_DIR_TYPE_BONO_FW:
        case BNX_DIR_TYPE_BONO_PATCH:
+               /* FALLTHROUGH */
                return true;
        }
 
@@ -2915,6 +2921,7 @@ static bool bnxt_dir_type_is_other_exec_format(uint16_t dir_type)
        case BNX_DIR_TYPE_ISCSI_BOOT:
        case BNX_DIR_TYPE_ISCSI_BOOT_IPV6:
        case BNX_DIR_TYPE_ISCSI_BOOT_IPV4N6:
+               /* FALLTHROUGH */
                return true;
        }
 
@@ -3148,10 +3155,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
        }
 skip_init:
        eth_dev->dev_ops = &bnxt_dev_ops;
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return 0;
        eth_dev->rx_pkt_burst = &bnxt_recv_pkts;
        eth_dev->tx_pkt_burst = &bnxt_xmit_pkts;
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        if (BNXT_PF(bp) && pci_dev->id.device_id != BROADCOM_DEV_ID_NS2) {
                snprintf(mz_name, RTE_MEMZONE_NAMESIZE,
@@ -3380,10 +3387,6 @@ skip_init:
        if (rc)
                goto error_free_int;
 
-       rc = bnxt_alloc_def_cp_ring(bp);
-       if (rc)
-               goto error_free_int;
-
        bnxt_enable_int(bp);
        bnxt_init_nic(bp);
 
@@ -3391,7 +3394,6 @@ skip_init:
 
 error_free_int:
        bnxt_disable_int(bp);
-       bnxt_free_def_cp_ring(bp);
        bnxt_hwrm_func_buf_unrgtr(bp);
        bnxt_free_int(bp);
        bnxt_free_mem(bp);