diff mbox series

[v3,09/11] net/octeontx: support allmulticast

Message ID 20220524084235.17796-9-hkalra@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers show
Series [v3,01/11] event/octeontx: fix SSO fastpath | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Harman Kalra May 24, 2022, 8:42 a.m. UTC
Implement allmulticast operations for octeontx driver:
rte_eth_allmulticast_enable()/rte_eth_allmulticast_disable().

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/net/octeontx/base/octeontx_bgx.c | 19 ++++++++++
 drivers/net/octeontx/base/octeontx_bgx.h |  1 +
 drivers/net/octeontx/octeontx_ethdev.c   | 46 ++++++++++++++++++++++++
 3 files changed, 66 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/octeontx/base/octeontx_bgx.c b/drivers/net/octeontx/base/octeontx_bgx.c
index 81a8cbecaf..1eacecbccc 100644
--- a/drivers/net/octeontx/base/octeontx_bgx.c
+++ b/drivers/net/octeontx/base/octeontx_bgx.c
@@ -144,6 +144,25 @@  octeontx_bgx_port_status(int port, octeontx_mbox_bgx_port_status_t *stat)
 	return res;
 }
 
+int
+octeontx_bgx_port_multicast_set(int port, int en)
+{
+	struct octeontx_mbox_hdr hdr;
+	uint8_t	prom;
+	int res;
+
+	hdr.coproc = OCTEONTX_BGX_COPROC;
+	hdr.msg = MBOX_BGX_PORT_SET_MCAST;
+	hdr.vfid = port;
+	prom = en ? 1 : 0;
+
+	res = octeontx_mbox_send(&hdr, &prom, sizeof(prom), NULL, 0);
+	if (res < 0)
+		return -EACCES;
+
+	return res;
+}
+
 int
 octeontx_bgx_port_xstats(int port, octeontx_mbox_bgx_port_stats_t *stats)
 {
diff --git a/drivers/net/octeontx/base/octeontx_bgx.h b/drivers/net/octeontx/base/octeontx_bgx.h
index c5662202ac..3213d04e99 100644
--- a/drivers/net/octeontx/base/octeontx_bgx.h
+++ b/drivers/net/octeontx/base/octeontx_bgx.h
@@ -166,6 +166,7 @@  int octeontx_bgx_port_stats_clr(int port);
 int octeontx_bgx_port_xstats(int port, octeontx_mbox_bgx_port_stats_t *stats);
 int octeontx_bgx_port_link_status(int port);
 int octeontx_bgx_port_promisc_set(int port, int en);
+int octeontx_bgx_port_multicast_set(int port, int en);
 int octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr);
 int octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr, int index);
 int octeontx_bgx_port_mac_del(int port, uint32_t index);
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index c15014bdde..3aca53fb98 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -847,6 +847,50 @@  octeontx_dev_link_update(struct rte_eth_dev *dev,
 	return rte_eth_linkstatus_set(dev, &link);
 }
 
+static int
+octeontx_port_mcast_set(struct octeontx_nic *nic, int en)
+{
+	struct rte_eth_dev *dev;
+	int res;
+
+	res = 0;
+	PMD_INIT_FUNC_TRACE();
+	dev = nic->dev;
+
+	res = octeontx_bgx_port_multicast_set(nic->port_id, en);
+	if (res < 0) {
+		octeontx_log_err("failed to set multicast mode %d",
+				nic->port_id);
+		return res;
+	}
+
+	/* Set proper flag for the mode */
+	dev->data->all_multicast = (en != 0) ? 1 : 0;
+
+	octeontx_log_dbg("port %d : multicast mode %s",
+			nic->port_id, en ? "set" : "unset");
+
+	return 0;
+}
+
+static int
+octeontx_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
+
+	PMD_INIT_FUNC_TRACE();
+	return octeontx_port_mcast_set(nic, 1);
+}
+
+static int
+octeontx_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
+
+	PMD_INIT_FUNC_TRACE();
+	return octeontx_port_mcast_set(nic, 0);
+}
+
 static inline int octeontx_dev_total_xstat(void)
 {
 	return NUM_BGX_XSTAT;
@@ -1480,6 +1524,8 @@  static const struct eth_dev_ops octeontx_dev_ops = {
 	.xstats_get_by_id	 = octeontx_dev_xstats_get_by_id,
 	.xstats_get_names	 = octeontx_dev_xstats_get_names,
 	.xstats_get_names_by_id	 = octeontx_dev_xstats_get_names_by_id,
+	.allmulticast_enable      = octeontx_allmulticast_enable,
+	.allmulticast_disable     = octeontx_allmulticast_disable,
 };
 
 /* Create Ethdev interface per BGX LMAC ports */