net/bnxt: use correct flags during VLAN configuration
[dpdk.git] / drivers / net / bnxt / bnxt_ethdev.c
index 7fa69b4..936a6d5 100644 (file)
@@ -249,7 +249,19 @@ static int bnxt_init_chip(struct bnxt *bp)
 
        /* VNIC configuration */
        for (i = 0; i < bp->nr_vnics; i++) {
+               struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
                struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
+               uint32_t size = sizeof(*vnic->fw_grp_ids) * bp->max_ring_grps;
+
+               vnic->fw_grp_ids = rte_zmalloc("vnic_fw_grp_ids", size, 0);
+               if (!vnic->fw_grp_ids) {
+                       PMD_DRV_LOG(ERR,
+                                   "Failed to alloc %d bytes for group ids\n",
+                                   size);
+                       rc = -ENOMEM;
+                       goto err_out;
+               }
+               memset(vnic->fw_grp_ids, -1, size);
 
                rc = bnxt_hwrm_vnic_alloc(bp, vnic);
                if (rc) {
@@ -258,12 +270,15 @@ static int bnxt_init_chip(struct bnxt *bp)
                        goto err_out;
                }
 
-               rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic);
-               if (rc) {
-                       PMD_DRV_LOG(ERR,
-                               "HWRM vnic %d ctx alloc failure rc: %x\n",
-                               i, rc);
-                       goto err_out;
+               /* Alloc RSS context only if RSS mode is enabled */
+               if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS) {
+                       rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic);
+                       if (rc) {
+                               PMD_DRV_LOG(ERR,
+                                       "HWRM vnic %d ctx alloc failure rc: %x\n",
+                                       i, rc);
+                               goto err_out;
+                       }
                }
 
                rc = bnxt_hwrm_vnic_cfg(bp, vnic);
@@ -506,6 +521,7 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 {
        struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
        uint64_t rx_offloads = eth_dev->data->dev_conf.rxmode.offloads;
+       int rc;
 
        bp->rx_queues = (void *)eth_dev->data->rx_queues;
        bp->tx_queues = (void *)eth_dev->data->tx_queues;
@@ -513,19 +529,23 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
        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_check_vf_rings(bp);
+               if (rc) {
+                       PMD_DRV_LOG(ERR, "HWRM insufficient resources\n");
+                       return -ENOSPC;
+               }
 
-               rc = bnxt_hwrm_func_reserve_vf_resc(bp);
+               rc = bnxt_hwrm_func_reserve_vf_resc(bp, false);
                if (rc) {
                        PMD_DRV_LOG(ERR, "HWRM resource alloc fail:%x\n", rc);
                        return -ENOSPC;
                }
-
+       } else {
                /* 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;
+                       return rc;
                }
        }
 
@@ -536,7 +556,9 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
            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) > bp->max_ring_grps) {
+           (uint32_t)(eth_dev->data->nb_rx_queues) > bp->max_ring_grps ||
+           (!(eth_dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS) &&
+            bp->max_vnics < eth_dev->data->nb_rx_queues)) {
                PMD_DRV_LOG(ERR,
                        "Insufficient resources to support requested config\n");
                PMD_DRV_LOG(ERR,
@@ -544,9 +566,9 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
                        eth_dev->data->nb_tx_queues,
                        eth_dev->data->nb_rx_queues);
                PMD_DRV_LOG(ERR,
-                       "Res available: TxQ %d, RxQ %d, CQ %d Stat %d, Grp %d\n",
+                       "MAX: TxQ %d, RxQ %d, CQ %d Stat %d, Grp %d, Vnic %d\n",
                        bp->max_tx_rings, bp->max_rx_rings, bp->max_cp_rings,
-                       bp->max_stat_ctx, bp->max_ring_grps);
+                       bp->max_stat_ctx, bp->max_ring_grps, bp->max_vnics);
                return -ENOSPC;
        }
 
@@ -1306,9 +1328,9 @@ static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id)
        struct bnxt_vnic_info *vnic;
        unsigned int i;
        int rc = 0;
-       uint32_t en = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN |
-               HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN_MASK;
-       uint32_t chk = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN;
+       uint32_t en = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN |
+               HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK;
+       uint32_t chk = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN;
 
        /* Cycle through all VNICs */
        for (i = 0; i < bp->nr_vnics; i++) {
@@ -1355,8 +1377,8 @@ static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id)
                                memcpy(new_filter->l2_addr, filter->l2_addr,
                                       ETHER_ADDR_LEN);
                                /* MAC + VLAN ID filter */
-                               new_filter->l2_ovlan = vlan_id;
-                               new_filter->l2_ovlan_mask = 0xF000;
+                               new_filter->l2_ivlan = vlan_id;
+                               new_filter->l2_ivlan_mask = 0xF000;
                                new_filter->enables |= en;
                                rc = bnxt_hwrm_set_l2_filter(bp,
                                                             vnic->fw_vnic_id,
@@ -1582,6 +1604,7 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
 
        for (i = 0; i < bp->nr_vnics; i++) {
                struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
+               uint16_t size = 0;
 
                vnic->mru = bp->eth_dev->data->mtu + ETHER_HDR_LEN +
                                        ETHER_CRC_LEN + VLAN_TAG_SIZE * 2;
@@ -1589,9 +1612,14 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
                if (rc)
                        break;
 
-               rc = bnxt_hwrm_vnic_plcmode_cfg(bp, vnic);
-               if (rc)
-                       return rc;
+               size = rte_pktmbuf_data_room_size(bp->rx_queues[0]->mb_pool);
+               size -= RTE_PKTMBUF_HEADROOM;
+
+               if (size < new_mtu) {
+                       rc = bnxt_hwrm_vnic_plcmode_cfg(bp, vnic);
+                       if (rc)
+                               return rc;
+               }
        }
 
        return rc;