DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/bnx2x: add multicast MAC address filtering
@ 2020-02-28 20:04 Dey, Souvik
  2020-03-03 23:28 ` [dpdk-dev] [EXT] " Rasesh Mody
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Dey, Souvik @ 2020-02-28 20:04 UTC (permalink / raw)
  To: rmody, shshaikh, jerinj, ferruh.yigit, thomas; +Cc: dev, stable, Dey, Souvik

Add support the set_mc_addr_list device operation in the bnx2xvf PMD.

The configured addresses are stored in the device private area, so
they can be flushed before adding new ones.
Without this v6 multicast packets were properly forwarded to the
Guest VF.



Signed-off-by: "Dey, Souvik" <sodey@rbbn.com>
---
 drivers/net/bnx2x/bnx2x.h        |  3 ++
 drivers/net/bnx2x/bnx2x_ethdev.c | 36 ++++++++++++++++++++++++
 drivers/net/bnx2x/bnx2x_vfpf.c   | 59 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/bnx2x/bnx2x_vfpf.h   |  3 ++
 4 files changed, 101 insertions(+)

diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 1dbc981..3f9bb67 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -1376,6 +1376,9 @@ struct bnx2x_softc {
 	uint8_t prio_to_cos[BNX2X_MAX_PRIORITY];
 
 	int panic;
+	/* Array of Multicast addrs */
+	struct rte_ether_addr mc_addrs[VF_MAX_MULTICAST_PER_VF];
+    uint16_t mc_addrs_num; /* Multicast mac addresses number */
 }; /* struct bnx2x_softc */
 
 /* IOCTL sub-commands for edebug and firmware upgrade */
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 7864b5b..3ce9e7d 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -239,6 +239,10 @@ bnx2x_dev_start(struct rte_eth_dev *dev)
 		if (rte_intr_enable(&sc->pci_dev->intr_handle))
 			PMD_DRV_LOG(ERR, sc, "rte_intr_enable failed");
 	}
+	/* Configure the previously stored Multicast address list */
+	if (IS_VF(sc)) {
+        bnx2x_vfpf_set_mcast(sc, sc->mc_addrs, sc->mc_addrs_num);
+    }
 
 	bnx2x_dev_rxtx_init(dev);
 
@@ -266,6 +270,13 @@ bnx2x_dev_stop(struct rte_eth_dev *dev)
 		bnx2x_periodic_stop(dev);
 	}
 
+	/* Remove the configured Multicast list
+	 * Sending NULL for the list of address and the
+	 * Number is set to 0 denoting DEL_CMD */
+	if (IS_VF(sc)) {
+        bnx2x_vfpf_set_mcast(sc, NULL, 0);
+    }
+
 	ret = bnx2x_nic_unload(sc, UNLOAD_NORMAL, FALSE);
 	if (ret) {
 		PMD_DRV_LOG(DEBUG, sc, "bnx2x_nic_unload failed (%d)", ret);
@@ -349,6 +360,30 @@ bnx2x_dev_allmulticast_disable(struct rte_eth_dev *dev)
 }
 
 static int
+bnx2x_dev_set_mc_addr_list(struct rte_eth_dev *dev,
+		struct rte_ether_addr *mc_addrs, uint32_t mc_addrs_num)
+{
+    struct bnx2x_softc *sc = dev->data->dev_private;
+    int err;
+    PMD_INIT_FUNC_TRACE(sc);
+    /* flush previous addresses */
+    err = bnx2x_vfpf_set_mcast(sc, NULL, 0);
+    if (err)
+        return err;
+    sc->mc_addrs_num = 0;
+
+    /* Add new ones */
+    err = bnx2x_vfpf_set_mcast(sc, mc_addrs, mc_addrs_num );
+    if (err)
+        return err;
+
+    sc->mc_addrs_num = mc_addrs_num;
+    memcpy(sc->mc_addrs, mc_addrs, mc_addrs_num * sizeof(*mc_addrs));
+
+    return 0;
+}
+
+static int
 bnx2x_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
 {
 	struct bnx2x_softc *sc = dev->data->dev_private;
@@ -562,6 +597,7 @@ static const struct eth_dev_ops bnx2xvf_eth_dev_ops = {
 	.promiscuous_disable          = bnx2x_promisc_disable,
 	.allmulticast_enable          = bnx2x_dev_allmulticast_enable,
 	.allmulticast_disable         = bnx2x_dev_allmulticast_disable,
+	.set_mc_addr_list             = bnx2x_dev_set_mc_addr_list,
 	.link_update                  = bnx2xvf_dev_link_update,
 	.stats_get                    = bnx2x_dev_stats_get,
 	.xstats_get                   = bnx2x_dev_xstats_get,
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c
index 8f7559c..3bcc85d 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/bnx2x/bnx2x_vfpf.c
@@ -703,3 +703,62 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
 
 	return rc;
 }
+
+int
+bnx2x_vfpf_set_mcast(struct bnx2x_softc *sc,
+					struct rte_ether_addr *mc_addrs, uint32_t mc_addrs_num)
+{
+    struct vf_set_q_filters_tlv *query;
+    struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
+    int rc = 0;
+    uint32_t i = 0;
+    query = &sc->vf2pf_mbox->query[0].set_q_filters;
+    bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
+                sizeof(*query));
+    /* We support PFVF_MAX_MULTICAST_PER_VF mcast addresses tops */
+    if (mc_addrs_num > VF_MAX_MULTICAST_PER_VF) {
+        PMD_DRV_LOG(ERR, sc,
+		"VF supports not more than %d multicast MAC addresses",
+		VF_MAX_MULTICAST_PER_VF);
+
+        rc = -EINVAL;
+        goto out;
+    }
+
+    for (i = 0; i < mc_addrs_num; i++) {
+        PMD_DRV_LOG(DEBUG, sc, "Adding mcast MAC:%x:%x:%x:%x:%x:%x",
+                mc_addrs[i].addr_bytes[0],
+                mc_addrs[i].addr_bytes[1],
+                mc_addrs[i].addr_bytes[2],
+                mc_addrs[i].addr_bytes[3],
+                mc_addrs[i].addr_bytes[4],
+                mc_addrs[i].addr_bytes[5]);
+        memcpy(query->multicast[i], mc_addrs[i].addr_bytes, ETH_ALEN);
+        i++;
+    }
+
+    query->vf_qid = 0;
+    query->flags = BNX2X_VF_MULTICAST_CHANGED;
+    query->multicast_cnt = i;
+
+    /* add list termination tlv */
+    bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+              BNX2X_VF_TLV_LIST_END,
+              sizeof(struct channel_list_end_tlv));
+
+    rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+    if (rc)
+        goto out;
+
+    if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
+        PMD_DRV_LOG(ERR, sc, "Set Rx mode/multicast failed: %d",
+                reply->status);
+        rc = -EINVAL;
+    }
+
+out:
+    bnx2x_vf_finalize(sc, &query->first_tlv);
+
+    return rc;
+
+}
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.h b/drivers/net/bnx2x/bnx2x_vfpf.h
index ce0259a..0c7cb65 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.h
+++ b/drivers/net/bnx2x/bnx2x_vfpf.h
@@ -331,5 +331,8 @@ struct bnx2x_vf_mbx_msg {
 int bnx2x_vf_teardown_queue(struct bnx2x_softc *sc, int qid);
 int bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set);
 int bnx2x_vf_config_rss(struct bnx2x_softc *sc, struct ecore_config_rss_params *params);
+int bnx2x_vfpf_set_mcast(struct bnx2x_softc *sc,
+				struct rte_ether_addr *mc_addrs,
+				uint32_t mc_addrs_num);
 
 #endif /* BNX2X_VFPF_H */
-- 
2.9.3.windows.1


-----------------------------------------------------------------------------------------------------------------------
Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. that
is confidential and/or proprietary for the sole use of the intended recipient.  Any review, disclosure, reliance or
distribution by others or forwarding without express permission is strictly prohibited.  If you are not the intended
recipient, please notify the sender immediately and then delete all copies, including any attachments.
-----------------------------------------------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH] net/bnx2x: add multicast MAC address filtering
@ 2020-03-03  4:18 sodey
  0 siblings, 0 replies; 8+ messages in thread
From: sodey @ 2020-03-03  4:18 UTC (permalink / raw)
  To: rmody, shshaikh, jerinj, ferruh.yigit, thomas; +Cc: dev, stable, Dey, Souvik

From: "Dey, Souvik" <sodey@rbbn.com>

Add support the set_mc_addr_list device operation in the bnx2xvf PMD.

The configured addresses are stored in the device private area, so
they can be flushed before adding new ones.
Without this v6 multicast packets were properly forwarded to the
Guest VF.


Signed-off-by: "Dey, Souvik" <sodey@rbbn.com>
---

 drivers/net/bnx2x/bnx2x.h        |  4 +++
 drivers/net/bnx2x/bnx2x_ethdev.c | 35 +++++++++++++++++++++++-
 drivers/net/bnx2x/bnx2x_vfpf.c   | 58 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/bnx2x/bnx2x_vfpf.h   |  3 +++
 4 files changed, 99 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 1dbc981..3cadb5d 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -1376,6 +1376,10 @@ struct bnx2x_softc {
 	uint8_t prio_to_cos[BNX2X_MAX_PRIORITY];
 
 	int panic;
+	/* Array of Multicast addrs */
+	struct rte_ether_addr mc_addrs[VF_MAX_MULTICAST_PER_VF];
+	/* Multicast mac addresses number */
+	uint16_t mc_addrs_num;
 }; /* struct bnx2x_softc */
 
 /* IOCTL sub-commands for edebug and firmware upgrade */
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 7864b5b..30588b1 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -240,6 +240,9 @@ bnx2x_dev_start(struct rte_eth_dev *dev)
 			PMD_DRV_LOG(ERR, sc, "rte_intr_enable failed");
 	}
 
+	/* Configure the previously stored Multicast address list */
+	if (IS_VF(sc))
+		bnx2x_vfpf_set_mcast(sc, sc->mc_addrs, sc->mc_addrs_num);
 	bnx2x_dev_rxtx_init(dev);
 
 	bnx2x_print_device_info(sc);
@@ -265,7 +268,12 @@ bnx2x_dev_stop(struct rte_eth_dev *dev)
 		/* stop the periodic callout */
 		bnx2x_periodic_stop(dev);
 	}
-
+	/* Remove the configured Multicast list
+	 * Sending NULL for the list of address and the
+	 * Number is set to 0 denoting DEL_CMD
+	 */
+	if (IS_VF(sc))
+		bnx2x_vfpf_set_mcast(sc, NULL, 0);
 	ret = bnx2x_nic_unload(sc, UNLOAD_NORMAL, FALSE);
 	if (ret) {
 		PMD_DRV_LOG(DEBUG, sc, "bnx2x_nic_unload failed (%d)", ret);
@@ -349,6 +357,30 @@ bnx2x_dev_allmulticast_disable(struct rte_eth_dev *dev)
 }
 
 static int
+bnx2x_dev_set_mc_addr_list(struct rte_eth_dev *dev,
+		struct rte_ether_addr *mc_addrs, uint32_t mc_addrs_num)
+{
+	struct bnx2x_softc *sc = dev->data->dev_private;
+	int err;
+	PMD_INIT_FUNC_TRACE(sc);
+	/* flush previous addresses */
+	err = bnx2x_vfpf_set_mcast(sc, NULL, 0);
+	if (err)
+		return err;
+	sc->mc_addrs_num = 0;
+
+	/* Add new ones */
+	err = bnx2x_vfpf_set_mcast(sc, mc_addrs, mc_addrs_num);
+	if (err)
+		return err;
+
+	sc->mc_addrs_num = mc_addrs_num;
+	memcpy(sc->mc_addrs, mc_addrs, mc_addrs_num * sizeof(*mc_addrs));
+
+	return 0;
+}
+
+static int
 bnx2x_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
 {
 	struct bnx2x_softc *sc = dev->data->dev_private;
@@ -562,6 +594,7 @@ static const struct eth_dev_ops bnx2xvf_eth_dev_ops = {
 	.promiscuous_disable          = bnx2x_promisc_disable,
 	.allmulticast_enable          = bnx2x_dev_allmulticast_enable,
 	.allmulticast_disable         = bnx2x_dev_allmulticast_disable,
+	.set_mc_addr_list             = bnx2x_dev_set_mc_addr_list,
 	.link_update                  = bnx2xvf_dev_link_update,
 	.stats_get                    = bnx2x_dev_stats_get,
 	.xstats_get                   = bnx2x_dev_xstats_get,
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c
index 8f7559c..097ccfe 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/bnx2x/bnx2x_vfpf.c
@@ -703,3 +703,61 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
 
 	return rc;
 }
+
+int
+bnx2x_vfpf_set_mcast(struct bnx2x_softc *sc,
+					struct rte_ether_addr *mc_addrs,
+					uint32_t mc_addrs_num)
+{
+	struct vf_set_q_filters_tlv *query;
+	struct vf_common_reply_tlv *reply =
+			&sc->vf2pf_mbox->resp.common_reply;
+	int rc = 0;
+	uint32_t i = 0;
+	query = &sc->vf2pf_mbox->query[0].set_q_filters;
+	bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
+				sizeof(*query));
+	/* We support PFVF_MAX_MULTICAST_PER_VF mcast addresses tops */
+	if (mc_addrs_num > VF_MAX_MULTICAST_PER_VF) {
+		PMD_DRV_LOG(ERR, sc,
+		"VF supports not more than %d multicast MAC addresses",
+		VF_MAX_MULTICAST_PER_VF);
+
+		rc = -EINVAL;
+		goto out;
+	}
+
+	for (i = 0; i < mc_addrs_num; i++) {
+		PMD_DRV_LOG(DEBUG, sc, "Adding mcast MAC:%x:%x:%x:%x:%x:%x",
+				mc_addrs[i].addr_bytes[0],
+				mc_addrs[i].addr_bytes[1],
+				mc_addrs[i].addr_bytes[2],
+				mc_addrs[i].addr_bytes[3],
+				mc_addrs[i].addr_bytes[4],
+				mc_addrs[i].addr_bytes[5]);
+		memcpy(query->multicast[i], mc_addrs[i].addr_bytes, ETH_ALEN);
+	}
+
+	query->vf_qid = 0;
+	query->flags = BNX2X_VF_MULTICAST_CHANGED;
+	query->multicast_cnt = i;
+
+	/* add list termination tlv */
+	bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+				BNX2X_VF_TLV_LIST_END,
+				sizeof(struct channel_list_end_tlv));
+	rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	if (rc)
+		goto out;
+
+	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
+		PMD_DRV_LOG(ERR, sc, "Set Rx mode/multicast failed: %d",
+				reply->status);
+		rc = -EINVAL;
+	}
+
+out:
+	bnx2x_vf_finalize(sc, &query->first_tlv);
+
+	return rc;
+}
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.h b/drivers/net/bnx2x/bnx2x_vfpf.h
index ce0259a..7aab8b1 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.h
+++ b/drivers/net/bnx2x/bnx2x_vfpf.h
@@ -331,5 +331,8 @@ struct bnx2x_vf_mbx_msg {
 int bnx2x_vf_teardown_queue(struct bnx2x_softc *sc, int qid);
 int bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set);
 int bnx2x_vf_config_rss(struct bnx2x_softc *sc, struct ecore_config_rss_params *params);
+int bnx2x_vfpf_set_mcast(struct bnx2x_softc *sc,
+			struct rte_ether_addr *mc_addrs,
+			uint32_t mc_addrs_num);
 
 #endif /* BNX2X_VFPF_H */
-- 
2.9.3


-----------------------------------------------------------------------------------------------------------------------
Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. that
is confidential and/or proprietary for the sole use of the intended recipient.  Any review, disclosure, reliance or
distribution by others or forwarding without express permission is strictly prohibited.  If you are not the intended
recipient, please notify the sender immediately and then delete all copies, including any attachments.
-----------------------------------------------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-04-14 13:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-28 20:04 [dpdk-dev] [PATCH] net/bnx2x: add multicast MAC address filtering Dey, Souvik
2020-03-03 23:28 ` [dpdk-dev] [EXT] " Rasesh Mody
2020-04-05 13:09   ` Jerin Jacob
2020-04-06 16:21     ` Dey, Souvik
2020-04-05 21:54 ` [dpdk-dev] " Stephen Hemminger
2020-04-13 23:09 ` [dpdk-dev] [PATCH v2] " Rasesh Mody
2020-04-14 13:23   ` Jerin Jacob
2020-03-03  4:18 [dpdk-dev] [PATCH] " sodey

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).