[dpdk-dev] [PATCH v1 14/58] net/octeontx2: add promiscuous and allmulticast mode

jerinj at marvell.com jerinj at marvell.com
Sun Jun 2 17:23:50 CEST 2019


From: Vamsi Attunuru <vattunuru at marvell.com>

Add promiscuous and allmulticast mode for PF devices and
update the respective feature list.

Signed-off-by: Vamsi Attunuru <vattunuru at marvell.com>
Signed-off-by: Sunil Kumar Kori <skori at marvell.com>
---
 doc/guides/nics/features/octeontx2.ini     |  2 +
 doc/guides/nics/features/octeontx2_vec.ini |  2 +
 drivers/net/octeontx2/otx2_ethdev.c        |  4 ++
 drivers/net/octeontx2/otx2_ethdev.h        |  6 ++
 drivers/net/octeontx2/otx2_ethdev_ops.c    | 82 ++++++++++++++++++++++
 5 files changed, 96 insertions(+)

diff --git a/doc/guides/nics/features/octeontx2.ini b/doc/guides/nics/features/octeontx2.ini
index 3835b5069..40da1bb68 100644
--- a/doc/guides/nics/features/octeontx2.ini
+++ b/doc/guides/nics/features/octeontx2.ini
@@ -12,6 +12,8 @@ SR-IOV               = Y
 Multiprocess aware   = Y
 Link status          = Y
 Link status event    = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
diff --git a/doc/guides/nics/features/octeontx2_vec.ini b/doc/guides/nics/features/octeontx2_vec.ini
index e18443742..1b89be452 100644
--- a/doc/guides/nics/features/octeontx2_vec.ini
+++ b/doc/guides/nics/features/octeontx2_vec.ini
@@ -12,6 +12,8 @@ SR-IOV               = Y
 Multiprocess aware   = Y
 Link status          = Y
 Link status event    = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c
index 937ba6399..826ce7f4e 100644
--- a/drivers/net/octeontx2/otx2_ethdev.c
+++ b/drivers/net/octeontx2/otx2_ethdev.c
@@ -237,6 +237,10 @@ static const struct eth_dev_ops otx2_eth_dev_ops = {
 	.stats_get                = otx2_nix_dev_stats_get,
 	.stats_reset              = otx2_nix_dev_stats_reset,
 	.get_reg                  = otx2_nix_dev_get_reg,
+	.promiscuous_enable       = otx2_nix_promisc_enable,
+	.promiscuous_disable      = otx2_nix_promisc_disable,
+	.allmulticast_enable      = otx2_nix_allmulticast_enable,
+	.allmulticast_disable     = otx2_nix_allmulticast_disable,
 	.queue_stats_mapping_set  = otx2_nix_queue_stats_mapping,
 	.xstats_get               = otx2_nix_xstats_get,
 	.xstats_get_names         = otx2_nix_xstats_get_names,
diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h
index 223dd5a5a..549bc26e4 100644
--- a/drivers/net/octeontx2/otx2_ethdev.h
+++ b/drivers/net/octeontx2/otx2_ethdev.h
@@ -157,6 +157,12 @@ otx2_eth_pmd_priv(struct rte_eth_dev *eth_dev)
 void otx2_nix_info_get(struct rte_eth_dev *eth_dev,
 		       struct rte_eth_dev_info *dev_info);
 
+void otx2_nix_promisc_config(struct rte_eth_dev *eth_dev, int en);
+void otx2_nix_promisc_enable(struct rte_eth_dev *eth_dev);
+void otx2_nix_promisc_disable(struct rte_eth_dev *eth_dev);
+void otx2_nix_allmulticast_enable(struct rte_eth_dev *eth_dev);
+void otx2_nix_allmulticast_disable(struct rte_eth_dev *eth_dev);
+
 /* Link */
 void otx2_nix_toggle_flag_link_cfg(struct otx2_eth_dev *dev, bool set);
 int otx2_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete);
diff --git a/drivers/net/octeontx2/otx2_ethdev_ops.c b/drivers/net/octeontx2/otx2_ethdev_ops.c
index 9f86635d4..77cfa2cec 100644
--- a/drivers/net/octeontx2/otx2_ethdev_ops.c
+++ b/drivers/net/octeontx2/otx2_ethdev_ops.c
@@ -4,6 +4,88 @@
 
 #include "otx2_ethdev.h"
 
+static void
+nix_cgx_promisc_config(struct rte_eth_dev *eth_dev, int en)
+{
+	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+	struct otx2_mbox *mbox = dev->mbox;
+
+	if (otx2_dev_is_vf(dev))
+		return;
+
+	if (en)
+		otx2_mbox_alloc_msg_cgx_promisc_enable(mbox);
+	else
+		otx2_mbox_alloc_msg_cgx_promisc_disable(mbox);
+
+	otx2_mbox_process(mbox);
+}
+
+void
+otx2_nix_promisc_config(struct rte_eth_dev *eth_dev, int en)
+{
+	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+	struct otx2_mbox *mbox = dev->mbox;
+	struct nix_rx_mode *req;
+
+	if (otx2_dev_is_vf(dev))
+		return;
+
+	req = otx2_mbox_alloc_msg_nix_set_rx_mode(mbox);
+
+	if (en)
+		req->mode = NIX_RX_MODE_UCAST | NIX_RX_MODE_PROMISC;
+
+	otx2_mbox_process(mbox);
+	eth_dev->data->promiscuous = en;
+}
+
+void
+otx2_nix_promisc_enable(struct rte_eth_dev *eth_dev)
+{
+	otx2_nix_promisc_config(eth_dev, 1);
+	nix_cgx_promisc_config(eth_dev, 1);
+}
+
+void
+otx2_nix_promisc_disable(struct rte_eth_dev *eth_dev)
+{
+	otx2_nix_promisc_config(eth_dev, 0);
+	nix_cgx_promisc_config(eth_dev, 0);
+}
+
+static void
+nix_allmulticast_config(struct rte_eth_dev *eth_dev, int en)
+{
+	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+	struct otx2_mbox *mbox = dev->mbox;
+	struct nix_rx_mode *req;
+
+	if (otx2_dev_is_vf(dev))
+		return;
+
+	req = otx2_mbox_alloc_msg_nix_set_rx_mode(mbox);
+
+	if (en)
+		req->mode = NIX_RX_MODE_UCAST | NIX_RX_MODE_ALLMULTI;
+	else if (eth_dev->data->promiscuous)
+		req->mode = NIX_RX_MODE_UCAST | NIX_RX_MODE_PROMISC;
+
+	otx2_mbox_process(mbox);
+}
+
+void
+otx2_nix_allmulticast_enable(struct rte_eth_dev *eth_dev)
+{
+	nix_allmulticast_config(eth_dev, 1);
+}
+
+void
+otx2_nix_allmulticast_disable(struct rte_eth_dev *eth_dev)
+{
+	nix_allmulticast_config(eth_dev, 0);
+}
+
 void
 otx2_nix_info_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *devinfo)
 {
-- 
2.21.0



More information about the dev mailing list