From: Qin Ke <qin...@corigine.com>

Add support of dynamic config of allmulticast mode for NFP
by adding enable and disable callback function.

Signed-off-by: Qin Ke <qin...@corigine.com>
Reviewed-by: Chaoyong He <chaoyong...@corigine.com>
---
 doc/guides/nics/features/nfp.ini     |  1 +
 drivers/common/nfp/nfp_common_ctrl.h |  1 +
 drivers/net/nfp/nfp_ethdev.c         |  2 +
 drivers/net/nfp/nfp_ethdev_vf.c      |  2 +
 drivers/net/nfp/nfp_net_common.c     | 60 ++++++++++++++++++++++++++++
 drivers/net/nfp/nfp_net_common.h     |  2 +
 6 files changed, 68 insertions(+)

diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 73efd41e43..1a09c4cbaf 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -11,6 +11,7 @@ Rx interrupt         = Y
 Queue start/stop     = Y
 MTU update           = Y
 Promiscuous mode     = Y
+Allmulticast mode    = Y
 TSO                  = Y
 RSS hash             = Y
 RSS key update       = Y
diff --git a/drivers/common/nfp/nfp_common_ctrl.h 
b/drivers/common/nfp/nfp_common_ctrl.h
index 7033c8ea00..fdd97e5902 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -219,6 +219,7 @@ struct nfp_net_fw_ver {
 #define NFP_NET_CFG_CTRL_WORD1          0x0098
 #define NFP_NET_CFG_CTRL_PKT_TYPE         (0x1 << 0)
 #define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
+#define NFP_NET_CFG_CTRL_MCAST_FILTER     (0x1 << 2) /**< Multicast Filter */
 #define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match 
lookup */
 #define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup 
*/
 #define NFP_NET_CFG_CTRL_IN_ORDER         (0x1 << 11) /**< Virtio in-order 
flag */
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 4fae2e5540..8babfc00b5 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -402,6 +402,8 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = {
        .dev_close              = nfp_net_close,
        .promiscuous_enable     = nfp_net_promisc_enable,
        .promiscuous_disable    = nfp_net_promisc_disable,
+       .allmulticast_enable    = nfp_net_allmulticast_enable,
+       .allmulticast_disable   = nfp_net_allmulticast_disable,
        .link_update            = nfp_net_link_update,
        .stats_get              = nfp_net_stats_get,
        .stats_reset            = nfp_net_stats_reset,
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index f3aa649054..e1bd5555e9 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -199,6 +199,8 @@ static const struct eth_dev_ops nfp_netvf_eth_dev_ops = {
        .dev_close              = nfp_netvf_close,
        .promiscuous_enable     = nfp_net_promisc_enable,
        .promiscuous_disable    = nfp_net_promisc_disable,
+       .allmulticast_enable    = nfp_net_allmulticast_enable,
+       .allmulticast_disable   = nfp_net_allmulticast_disable,
        .link_update            = nfp_net_link_update,
        .stats_get              = nfp_net_stats_get,
        .stats_reset            = nfp_net_stats_reset,
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 4efcdff76f..2326c812c7 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -583,6 +583,66 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev)
        return 0;
 }
 
+static int
+nfp_net_set_allmulticast_mode(struct rte_eth_dev *dev,
+               bool enable)
+{
+       int ret;
+       uint32_t update;
+       struct nfp_hw *hw;
+       uint32_t cap_extend;
+       uint32_t ctrl_extend;
+       uint32_t new_ctrl_extend;
+       struct nfp_net_hw *net_hw;
+
+       net_hw = nfp_net_get_hw(dev);
+       hw = &net_hw->super;
+
+       cap_extend = hw->cap_ext;
+       if ((cap_extend & NFP_NET_CFG_CTRL_MCAST_FILTER) == 0) {
+               PMD_DRV_LOG(ERR, "Allmulticast mode not supported");
+               return -ENOTSUP;
+       }
+
+       /*
+        * Allmulticast mode enabled when NFP_NET_CFG_CTRL_MCAST_FILTER bit is 
0.
+        * Allmulticast mode disabled when NFP_NET_CFG_CTRL_MCAST_FILTER bit is 
1.
+        */
+       ctrl_extend = hw->ctrl_ext;
+       if (enable) {
+               if ((ctrl_extend & NFP_NET_CFG_CTRL_MCAST_FILTER) == 0)
+                       return 0;
+
+               new_ctrl_extend = ctrl_extend & ~NFP_NET_CFG_CTRL_MCAST_FILTER;
+       } else {
+               if ((ctrl_extend & NFP_NET_CFG_CTRL_MCAST_FILTER) != 0)
+                       return 0;
+
+               new_ctrl_extend = ctrl_extend | NFP_NET_CFG_CTRL_MCAST_FILTER;
+       }
+
+       update = NFP_NET_CFG_UPDATE_GEN;
+
+       ret = nfp_ext_reconfig(hw, new_ctrl_extend, update);
+       if (ret != 0)
+               return ret;
+
+       hw->ctrl_ext = new_ctrl_extend;
+       return 0;
+}
+
+int
+nfp_net_allmulticast_enable(struct rte_eth_dev *dev)
+{
+       return nfp_net_set_allmulticast_mode(dev, true);
+}
+
+int
+nfp_net_allmulticast_disable(struct rte_eth_dev *dev)
+{
+       return nfp_net_set_allmulticast_mode(dev, false);
+}
+
 int
 nfp_net_link_update_common(struct rte_eth_dev *dev,
                struct nfp_net_hw *hw,
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 1f9001c81d..2cad10668c 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -174,6 +174,8 @@ int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 uint32_t nfp_check_offloads(struct rte_eth_dev *dev);
 int nfp_net_promisc_enable(struct rte_eth_dev *dev);
 int nfp_net_promisc_disable(struct rte_eth_dev *dev);
+int nfp_net_allmulticast_enable(struct rte_eth_dev *dev);
+int nfp_net_allmulticast_disable(struct rte_eth_dev *dev);
 int nfp_net_link_update_common(struct rte_eth_dev *dev,
                struct nfp_net_hw *hw,
                struct rte_eth_link *link,
-- 
2.39.1

Reply via email to