ethdev: allow returning error on VLAN offload ops
[dpdk.git] / drivers / net / bnxt / bnxt_ethdev.c
index 8419f8b..b6c1dae 100644 (file)
@@ -145,7 +145,7 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
        ETH_RSS_NONFRAG_IPV6_TCP |      \
        ETH_RSS_NONFRAG_IPV6_UDP)
 
-static void bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask);
+static int bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask);
 
 /***********************/
 
@@ -574,6 +574,11 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
        int vlan_mask = 0;
        int rc;
 
+       if (bp->rx_cp_nr_rings > RTE_ETHDEV_QUEUE_STAT_CNTRS) {
+               RTE_LOG(ERR, PMD,
+                       "RxQ cnt %d > CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS %d\n",
+                       bp->rx_cp_nr_rings, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+       }
        bp->dev_stopped = 0;
 
        rc = bnxt_init_nic(bp);
@@ -586,7 +591,9 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
                vlan_mask |= ETH_VLAN_FILTER_MASK;
        if (eth_dev->data->dev_conf.rxmode.hw_vlan_strip)
                vlan_mask |= ETH_VLAN_STRIP_MASK;
-       bnxt_vlan_offload_set_op(eth_dev, vlan_mask);
+       rc = bnxt_vlan_offload_set_op(eth_dev, vlan_mask);
+       if (rc)
+               goto error;
 
        return 0;
 
@@ -657,13 +664,14 @@ static void bnxt_mac_addr_remove_op(struct rte_eth_dev *eth_dev,
        uint64_t pool_mask = eth_dev->data->mac_pool_sel[index];
        struct bnxt_vnic_info *vnic;
        struct bnxt_filter_info *filter, *temp_filter;
-       int i;
+       uint32_t pool = RTE_MIN(MAX_FF_POOLS, ETH_64_POOLS);
+       uint32_t i;
 
        /*
         * Loop through all VNICs from the specified filter flow pools to
         * remove the corresponding MAC addr filter
         */
-       for (i = 0; i < MAX_FF_POOLS; i++) {
+       for (i = 0; i < pool; i++) {
                if (!(pool_mask & (1ULL << i)))
                        continue;
 
@@ -1344,7 +1352,7 @@ static int bnxt_vlan_filter_set_op(struct rte_eth_dev *eth_dev,
                return bnxt_del_vlan_filter(bp, vlan_id);
 }
 
-static void
+static int
 bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask)
 {
        struct bnxt *bp = (struct bnxt *)dev->data->dev_private;
@@ -1376,6 +1384,8 @@ bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask)
 
        if (mask & ETH_VLAN_EXTEND_MASK)
                RTE_LOG(ERR, PMD, "Extend VLAN Not supported\n");
+
+       return 0;
 }
 
 static void
@@ -1722,10 +1732,12 @@ bnxt_match_and_validate_ether_filter(struct bnxt *bp,
                RTE_LOG(ERR, PMD, "unsupported ether_type(0x%04x) in"
                        " ethertype filter.", efilter->ether_type);
                *ret = -EINVAL;
+               goto exit;
        }
        if (efilter->queue >= bp->rx_nr_rings) {
                RTE_LOG(ERR, PMD, "Invalid queue %d\n", efilter->queue);
                *ret = -EINVAL;
+               goto exit;
        }
 
        vnic0 = STAILQ_FIRST(&bp->ff_pool[0]);
@@ -1733,6 +1745,7 @@ bnxt_match_and_validate_ether_filter(struct bnxt *bp,
        if (vnic == NULL) {
                RTE_LOG(ERR, PMD, "Invalid queue %d\n", efilter->queue);
                *ret = -EINVAL;
+               goto exit;
        }
 
        if (efilter->flags & RTE_ETHTYPE_FLAGS_DROP) {
@@ -1761,6 +1774,7 @@ bnxt_match_and_validate_ether_filter(struct bnxt *bp,
        if (match)
                *ret = -EEXIST;
 
+exit:
        return mfilter;
 }
 
@@ -2029,6 +2043,11 @@ bnxt_cfg_ntuple_filter(struct bnxt *bp,
                        goto free_filter;
                STAILQ_INSERT_TAIL(&vnic->filter, bfilter, next);
        } else {
+               if (mfilter == NULL) {
+                       /* This should not happen. But for Coverity! */
+                       ret = -ENOENT;
+                       goto free_filter;
+               }
                ret = bnxt_hwrm_clear_ntuple_filter(bp, mfilter);
 
                STAILQ_REMOVE(&vnic->filter, mfilter, bnxt_filter_info,
@@ -2785,7 +2804,6 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
                RTE_LOG(INFO, PMD, "%s\n", bnxt_version);
 
        rte_eth_copy_pci_info(eth_dev, pci_dev);
-       eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
 
        bp = eth_dev->data->dev_private;