net/bnxt: support set VF QOS and MAC anti spoof
[dpdk.git] / drivers / net / bnxt / bnxt_ethdev.c
index 73795fc..f9bedf7 100644 (file)
@@ -142,6 +142,7 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
        ETH_RSS_NONFRAG_IPV6_UDP)
 
 static void bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask);
+
 /***********************/
 
 /*
@@ -294,7 +295,7 @@ static int bnxt_init_chip(struct bnxt *bp)
                else
                        bnxt_hwrm_vnic_tpa_cfg(bp, vnic, 0);
        }
-       rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, &bp->vnic_info[0]);
+       rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, &bp->vnic_info[0], 0, NULL);
        if (rc) {
                RTE_LOG(ERR, PMD,
                        "HWRM cfa l2 rx mask failure rc: %x\n", rc);
@@ -702,7 +703,7 @@ static void bnxt_promiscuous_enable_op(struct rte_eth_dev *eth_dev)
        vnic = &bp->vnic_info[0];
 
        vnic->flags |= BNXT_VNIC_INFO_PROMISC;
-       bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
+       bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL);
 }
 
 static void bnxt_promiscuous_disable_op(struct rte_eth_dev *eth_dev)
@@ -716,7 +717,7 @@ static void bnxt_promiscuous_disable_op(struct rte_eth_dev *eth_dev)
        vnic = &bp->vnic_info[0];
 
        vnic->flags &= ~BNXT_VNIC_INFO_PROMISC;
-       bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
+       bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL);
 }
 
 static void bnxt_allmulticast_enable_op(struct rte_eth_dev *eth_dev)
@@ -730,7 +731,7 @@ static void bnxt_allmulticast_enable_op(struct rte_eth_dev *eth_dev)
        vnic = &bp->vnic_info[0];
 
        vnic->flags |= BNXT_VNIC_INFO_ALLMULTI;
-       bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
+       bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL);
 }
 
 static void bnxt_allmulticast_disable_op(struct rte_eth_dev *eth_dev)
@@ -744,7 +745,7 @@ static void bnxt_allmulticast_disable_op(struct rte_eth_dev *eth_dev)
        vnic = &bp->vnic_info[0];
 
        vnic->flags &= ~BNXT_VNIC_INFO_ALLMULTI;
-       bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
+       bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL);
 }
 
 static int bnxt_reta_update_op(struct rte_eth_dev *eth_dev,
@@ -1368,7 +1369,7 @@ bnxt_dev_set_mc_addr_list_op(struct rte_eth_dev *eth_dev,
        vnic->mc_addr_cnt = i;
 
 allmulti:
-       return bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic);
+       return bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL);
 }
 
 static int
@@ -1477,6 +1478,42 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
        return rc;
 }
 
+static int
+bnxt_vlan_pvid_set_op(struct rte_eth_dev *dev, uint16_t pvid, int on)
+{
+       struct bnxt *bp = (struct bnxt *)dev->data->dev_private;
+       uint16_t vlan = bp->vlan;
+       int rc;
+
+       if (BNXT_NPAR_PF(bp) || BNXT_VF(bp)) {
+               RTE_LOG(ERR, PMD,
+                       "PVID cannot be modified for this function\n");
+               return -ENOTSUP;
+       }
+       bp->vlan = on ? pvid : 0;
+
+       rc = bnxt_hwrm_set_default_vlan(bp, 0, 0);
+       if (rc)
+               bp->vlan = vlan;
+       return rc;
+}
+
+static int
+bnxt_dev_led_on_op(struct rte_eth_dev *dev)
+{
+       struct bnxt *bp = (struct bnxt *)dev->data->dev_private;
+
+       return bnxt_hwrm_port_led_cfg(bp, true);
+}
+
+static int
+bnxt_dev_led_off_op(struct rte_eth_dev *dev)
+{
+       struct bnxt *bp = (struct bnxt *)dev->data->dev_private;
+
+       return bnxt_hwrm_port_led_cfg(bp, false);
+}
+
 /*
  * Initialization
  */
@@ -1512,6 +1549,7 @@ static const struct eth_dev_ops bnxt_dev_ops = {
        .udp_tunnel_port_del  = bnxt_udp_tunnel_port_del_op,
        .vlan_filter_set = bnxt_vlan_filter_set_op,
        .vlan_offload_set = bnxt_vlan_offload_set_op,
+       .vlan_pvid_set = bnxt_vlan_pvid_set_op,
        .mtu_set = bnxt_mtu_set_op,
        .mac_addr_set = bnxt_set_default_mac_addr_op,
        .xstats_get = bnxt_dev_xstats_get_op,
@@ -1521,6 +1559,8 @@ static const struct eth_dev_ops bnxt_dev_ops = {
        .set_mc_addr_list = bnxt_dev_set_mc_addr_list_op,
        .rxq_info_get = bnxt_rxq_info_get_op,
        .txq_info_get = bnxt_txq_info_get_op,
+       .dev_led_on = bnxt_dev_led_on_op,
+       .dev_led_off = bnxt_dev_led_off_op,
 };
 
 static bool bnxt_vf_pciid(uint16_t id)
@@ -1595,6 +1635,8 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
        eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
 
        bp = eth_dev->data->dev_private;
+
+       rte_atomic64_init(&bp->rx_mbuf_alloc_fail);
        bp->dev_stopped = 1;
 
        if (bnxt_vf_pciid(pci_dev->id.device_id))
@@ -1792,6 +1834,8 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
                }
        }
 
+       bnxt_hwrm_port_led_qcaps(bp);
+
        rc = bnxt_setup_int(bp);
        if (rc)
                goto error_free;
@@ -1893,6 +1937,20 @@ static struct rte_pci_driver bnxt_rte_pmd = {
        .remove = bnxt_pci_remove,
 };
 
+static bool
+is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
+{
+       if (strcmp(dev->data->drv_name, drv->driver.name))
+               return false;
+
+       return true;
+}
+
+bool is_bnxt_supported(struct rte_eth_dev *dev)
+{
+       return is_device_supported(dev, &bnxt_rte_pmd);
+}
+
 RTE_PMD_REGISTER_PCI(net_bnxt, bnxt_rte_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnxt, bnxt_pci_id_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnxt, "* igb_uio | uio_pci_generic | vfio-pci");