From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Qin Ke <qin.ke@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH] net/nfp: add support of dynamic config of allmulticast mode
Date: Thu, 2 Nov 2023 13:37:44 +0800 [thread overview]
Message-ID: <20231102053744.2358687-1-chaoyong.he@corigine.com> (raw)
From: Qin Ke <qin.ke@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.ke@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@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
next reply other threads:[~2023-11-02 5:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-02 5:37 Chaoyong He [this message]
2023-11-02 13:32 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231102053744.2358687-1-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=oss-drivers@corigine.com \
--cc=qin.ke@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).