patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v2] net/iavf: support multicast configuration
@ 2020-10-10  2:53 Qi Zhang
  2020-10-28 11:20 ` Luca Boccassi
  0 siblings, 1 reply; 3+ messages in thread
From: Qi Zhang @ 2020-10-10  2:53 UTC (permalink / raw)
  To: bluca; +Cc: stable, ferruh.yigit, Qi Zhang, Wei Zhao

[ upstream commit 05e4c3aff35f41d527acfab86df55477fd8dcff2 ]

This patch enable add multicast address for iavf.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
---

To maintainer:

I know this is not a fix, but this is requested by an important
customer that will use DPDK 19.11 LTS, meanwhile this patch just add a missing
eth_dev op in AVF, it has low risk to bring any side effect.

 doc/guides/nics/features/iavf.ini |  1 +
 drivers/net/iavf/iavf.h           |  7 ++++
 drivers/net/iavf/iavf_ethdev.c    | 43 ++++++++++++++++++++++++
 drivers/net/iavf/iavf_vchnl.c     | 56 +++++++++++++++++++++++++++++++
 4 files changed, 107 insertions(+)

diff --git a/doc/guides/nics/features/iavf.ini b/doc/guides/nics/features/iavf.ini
index f08392a9c..80143059e 100644
--- a/doc/guides/nics/features/iavf.ini
+++ b/doc/guides/nics/features/iavf.ini
@@ -15,6 +15,7 @@ TSO                  = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 Unicast MAC filter   = Y
+Multicast MAC filter = Y
 RSS hash             = Y
 RSS key update       = Y
 RSS reta update      = Y
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 84f821354..482d4a677 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -103,6 +103,10 @@ struct iavf_info {
 	bool link_up;
 	uint32_t link_speed;
 
+	/* Multicast addrs */
+	struct rte_ether_addr mc_addrs[IAVF_NUM_MACADDR_MAX];
+	uint16_t mc_addrs_num;   /* Multicast mac addresses number */
+
 	struct iavf_vsi vsi;
 	bool vf_reset;
 	uint64_t flags;
@@ -230,4 +234,7 @@ int iavf_config_promisc(struct iavf_adapter *adapter, bool enable_unicast,
 int iavf_add_del_eth_addr(struct iavf_adapter *adapter,
 			 struct rte_ether_addr *addr, bool add);
 int iavf_add_del_vlan(struct iavf_adapter *adapter, uint16_t vlanid, bool add);
+int iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,
+			      struct rte_ether_addr *mc_addrs,
+			      uint32_t mc_addrs_num, bool add);
 #endif /* _IAVF_ETHDEV_H_ */
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 8ddd4aad9..357a4af04 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -72,6 +72,9 @@ static int iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
 					uint16_t queue_id);
 static int iavf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
 					 uint16_t queue_id);
+static int iavf_set_mc_addr_list(struct rte_eth_dev *dev,
+				 struct rte_ether_addr *mc_addr,
+				 uint32_t mc_addrs_num);
 
 int iavf_logtype_init;
 int iavf_logtype_driver;
@@ -107,6 +110,7 @@ static const struct eth_dev_ops iavf_eth_dev_ops = {
 	.allmulticast_disable       = iavf_dev_allmulticast_disable,
 	.mac_addr_add               = iavf_dev_add_mac_addr,
 	.mac_addr_remove            = iavf_dev_del_mac_addr,
+	.set_mc_addr_list           = iavf_set_mc_addr_list,
 	.vlan_filter_set            = iavf_dev_vlan_filter_set,
 	.vlan_offload_set           = iavf_dev_vlan_offload_set,
 	.rx_queue_start             = iavf_dev_rx_queue_start,
@@ -132,6 +136,35 @@ static const struct eth_dev_ops iavf_eth_dev_ops = {
 	.rx_queue_intr_disable      = iavf_dev_rx_queue_intr_disable,
 };
 
+static int
+iavf_set_mc_addr_list(struct rte_eth_dev *dev,
+		      struct rte_ether_addr *mc_addrs,
+		      uint32_t mc_addrs_num)
+{
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	struct iavf_adapter *adapter =
+		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	int err;
+
+	/* flush previous addresses */
+	err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num,
+					false);
+	if (err)
+		return err;
+
+	vf->mc_addrs_num = 0;
+
+	/* add new ones */
+	err = iavf_add_del_mc_addr_list(adapter, mc_addrs, mc_addrs_num, true);
+	if (err)
+		return err;
+
+	vf->mc_addrs_num = mc_addrs_num;
+	memcpy(vf->mc_addrs, mc_addrs, mc_addrs_num * sizeof(*mc_addrs));
+
+	return 0;
+}
+
 static int
 iavf_init_rss(struct iavf_adapter *adapter)
 {
@@ -461,6 +494,10 @@ iavf_dev_start(struct rte_eth_dev *dev)
 	/* Set all mac addrs */
 	iavf_add_del_all_mac_addr(adapter, TRUE);
 
+	/* Set all multicast addresses */
+	iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num,
+				  true);
+
 	if (iavf_start_queues(dev) != 0) {
 		PMD_DRV_LOG(ERR, "enable queues failed");
 		goto err_mac;
@@ -477,6 +514,7 @@ iavf_dev_start(struct rte_eth_dev *dev)
 static void
 iavf_dev_stop(struct rte_eth_dev *dev)
 {
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 	struct iavf_adapter *adapter =
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -499,6 +537,11 @@ iavf_dev_stop(struct rte_eth_dev *dev)
 
 	/* remove all mac addrs */
 	iavf_add_del_all_mac_addr(adapter, FALSE);
+
+	/* remove all multicast addresses */
+	iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num,
+				  false);
+
 	hw->adapter_stopped = 1;
 }
 
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 149673b9b..234196aa2 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -844,3 +844,59 @@ iavf_add_del_vlan(struct iavf_adapter *adapter, uint16_t vlanid, bool add)
 
 	return err;
 }
+
+int
+iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,
+			struct rte_ether_addr *mc_addrs,
+			uint32_t mc_addrs_num, bool add)
+{
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+	uint8_t cmd_buffer[sizeof(struct virtchnl_ether_addr_list) +
+		(IAVF_NUM_MACADDR_MAX * sizeof(struct virtchnl_ether_addr))];
+	struct virtchnl_ether_addr_list *list;
+	struct iavf_cmd_info args;
+	uint32_t i;
+	int err;
+
+	if (mc_addrs == NULL || mc_addrs_num == 0)
+		return 0;
+
+	if (mc_addrs_num > IAVF_NUM_MACADDR_MAX)
+		return -EINVAL;
+
+	list = (struct virtchnl_ether_addr_list *)cmd_buffer;
+	list->vsi_id = vf->vsi_res->vsi_id;
+	list->num_elements = mc_addrs_num;
+
+	for (i = 0; i < mc_addrs_num; i++) {
+		if (!IAVF_IS_MULTICAST(mc_addrs[i].addr_bytes)) {
+			PMD_DRV_LOG(ERR, "Invalid 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]);
+			return -EINVAL;
+		}
+
+		memcpy(list->list[i].addr, mc_addrs[i].addr_bytes,
+			sizeof(list->list[i].addr));
+	}
+
+	args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR : VIRTCHNL_OP_DEL_ETH_ADDR;
+	args.in_args = cmd_buffer;
+	args.in_args_size = sizeof(struct virtchnl_ether_addr_list) +
+		i * sizeof(struct virtchnl_ether_addr);
+	args.out_buffer = vf->aq_resp;
+	args.out_size = IAVF_AQ_BUF_SZ;
+	err = iavf_execute_vf_cmd(adapter, &args);
+
+	if (err) {
+		PMD_DRV_LOG(ERR, "fail to execute command %s",
+			add ? "OP_ADD_ETH_ADDR" : "OP_DEL_ETH_ADDR");
+		return err;
+	}
+
+	return 0;
+}
-- 
2.25.4


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

* Re: [dpdk-stable] [PATCH v2] net/iavf: support multicast configuration
  2020-10-10  2:53 [dpdk-stable] [PATCH v2] net/iavf: support multicast configuration Qi Zhang
@ 2020-10-28 11:20 ` Luca Boccassi
  2020-10-28 11:32   ` Zhang, Qi Z
  0 siblings, 1 reply; 3+ messages in thread
From: Luca Boccassi @ 2020-10-28 11:20 UTC (permalink / raw)
  To: Qi Zhang; +Cc: stable, ferruh.yigit, Wei Zhao

On Sat, 2020-10-10 at 10:53 +0800, Qi Zhang wrote:
> [ upstream commit 05e4c3aff35f41d527acfab86df55477fd8dcff2 ]
> 
> This patch enable add multicast address for iavf.
> 
> Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> Acked-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
> 
> To maintainer:
> 
> I know this is not a fix, but this is requested by an important
> customer that will use DPDK 19.11 LTS, meanwhile this patch just add a missing
> eth_dev op in AVF, it has low risk to bring any side effect.
> 
>  doc/guides/nics/features/iavf.ini |  1 +
>  drivers/net/iavf/iavf.h           |  7 ++++
>  drivers/net/iavf/iavf_ethdev.c    | 43 ++++++++++++++++++++++++
>  drivers/net/iavf/iavf_vchnl.c     | 56 +++++++++++++++++++++++++++++++
>  4 files changed, 107 insertions(+)

Next time please follow the guidelines and use --subject-prefix='PATCH
19.11' when sending, otherwise the mail gets filtered out.

What happens if someone upgrades from 19.11.6 with this patch, to say
20.08 which doesn't have it? Are there hard errors, or will the feature
simply be ignored?

-- 
Kind regards,
Luca Boccassi

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

* Re: [dpdk-stable] [PATCH v2] net/iavf: support multicast configuration
  2020-10-28 11:20 ` Luca Boccassi
@ 2020-10-28 11:32   ` Zhang, Qi Z
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang, Qi Z @ 2020-10-28 11:32 UTC (permalink / raw)
  To: Luca Boccassi; +Cc: stable, Yigit, Ferruh, Zhao1, Wei



> -----Original Message-----
> From: Luca Boccassi <bluca@debian.org>
> Sent: Wednesday, October 28, 2020 7:20 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: stable@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>; Zhao1, Wei
> <wei.zhao1@intel.com>
> Subject: Re: [dpdk-stable] [PATCH v2] net/iavf: support multicast configuration
> 
> On Sat, 2020-10-10 at 10:53 +0800, Qi Zhang wrote:
> > [ upstream commit 05e4c3aff35f41d527acfab86df55477fd8dcff2 ]
> >
> > This patch enable add multicast address for iavf.
> >
> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> > Acked-by: Qi Zhang <qi.z.zhang@intel.com>
> > ---
> >
> > To maintainer:
> >
> > I know this is not a fix, but this is requested by an important
> > customer that will use DPDK 19.11 LTS, meanwhile this patch just add a
> > missing eth_dev op in AVF, it has low risk to bring any side effect.
> >
> >  doc/guides/nics/features/iavf.ini |  1 +
> >  drivers/net/iavf/iavf.h           |  7 ++++
> >  drivers/net/iavf/iavf_ethdev.c    | 43 ++++++++++++++++++++++++
> >  drivers/net/iavf/iavf_vchnl.c     | 56
> +++++++++++++++++++++++++++++++
> >  4 files changed, 107 insertions(+)
> 
> Next time please follow the guidelines and use --subject-prefix='PATCH 19.11'
> when sending, otherwise the mail gets filtered out.

Got it, thanks.

> 
> What happens if someone upgrades from 19.11.6 with this patch, to say
> 20.08 which doesn't have it? Are there hard errors, or will the feature simply
> be ignored?

I think the unsupported error should be returned.
but I don't think this will be the real case, usually when a user current stick on 19.11 decide to upgrade, it will move to 20.11 directly.

Thanks
Qi

> 
> --
> Kind regards,
> Luca Boccassi

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

end of thread, other threads:[~2020-10-28 11:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-10  2:53 [dpdk-stable] [PATCH v2] net/iavf: support multicast configuration Qi Zhang
2020-10-28 11:20 ` Luca Boccassi
2020-10-28 11:32   ` Zhang, Qi Z

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