[dpdk-dev] [PATCH v6 5/8] net/mvneta: support for promiscuous

Andrzej Ostruszka amo at semihalf.com
Mon Oct 1 11:26:07 CEST 2018


From: Zyta Szpak <zr at semihalf.com>

Add callbacks for enabling/disabling of promiscuous mode.

Signed-off-by: Yelena Krivosheev <yelena at marvell.com>
Signed-off-by: Zyta Szpak <zr at semihalf.com>
---
 doc/guides/nics/features/mvneta.ini |  1 +
 doc/guides/nics/mvneta.rst          |  1 +
 drivers/net/mvneta/mvneta_ethdev.c  | 54 +++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/doc/guides/nics/features/mvneta.ini b/doc/guides/nics/features/mvneta.ini
index 581ed31..6a140a3 100644
--- a/doc/guides/nics/features/mvneta.ini
+++ b/doc/guides/nics/features/mvneta.ini
@@ -8,6 +8,7 @@ Speed capabilities   = Y
 Link status          = Y
 MTU update           = Y
 Jumbo frame          = Y
+Promiscuous mode     = Y
 CRC offload          = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
diff --git a/doc/guides/nics/mvneta.rst b/doc/guides/nics/mvneta.rst
index 290bb1a..dc93164 100644
--- a/doc/guides/nics/mvneta.rst
+++ b/doc/guides/nics/mvneta.rst
@@ -31,6 +31,7 @@ Features of the MVNETA PMD are:
 - Speed capabilities
 - Jumbo frame
 - MTU update
+- Promiscuous mode
 - Link status
 - CRC offload
 - L3 checksum offload
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index 3c450d2..d3b8885 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -547,6 +547,58 @@ mvneta_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
 }
 
 /**
+ * DPDK callback to enable promiscuous mode.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ */
+static void
+mvneta_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	struct mvneta_priv *priv = dev->data->dev_private;
+	int ret, en;
+
+	if (!priv->ppio)
+		return;
+
+	neta_ppio_get_promisc(priv->ppio, &en);
+	if (en) {
+		MVNETA_LOG(INFO, "Promiscuous already enabled");
+		return;
+	}
+
+	ret = neta_ppio_set_promisc(priv->ppio, 1);
+	if (ret)
+		MVNETA_LOG(ERR, "Failed to enable promiscuous mode");
+}
+
+/**
+ * DPDK callback to disable allmulticast mode.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ */
+static void
+mvneta_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	struct mvneta_priv *priv = dev->data->dev_private;
+	int ret, en;
+
+	if (!priv->ppio)
+		return;
+
+	neta_ppio_get_promisc(priv->ppio, &en);
+	if (!en) {
+		MVNETA_LOG(INFO, "Promiscuous already disabled");
+		return;
+	}
+
+	ret = neta_ppio_set_promisc(priv->ppio, 0);
+	if (ret)
+		MVNETA_LOG(ERR, "Failed to disable promiscuous mode");
+}
+
+/**
  * DPDK callback to set the primary MAC address.
  *
  * @param dev
@@ -580,6 +632,8 @@ static const struct eth_dev_ops mvneta_ops = {
 	.dev_set_link_down = mvneta_dev_set_link_down,
 	.dev_close = mvneta_dev_close,
 	.link_update = mvneta_link_update,
+	.promiscuous_enable = mvneta_promiscuous_enable,
+	.promiscuous_disable = mvneta_promiscuous_disable,
 	.mac_addr_set = mvneta_mac_addr_set,
 	.mtu_set = mvneta_mtu_set,
 	.dev_infos_get = mvneta_dev_infos_get,
-- 
2.7.4



More information about the dev mailing list