[v2,3/3] net/enic: allow multicast in MAC address add callback

Message ID 20240808061433.14971-4-hyonkim@cisco.com (mailing list archive)
State Changes Requested
Delegated to: Ferruh Yigit
Headers
Series net/enic: support VF and fix minor issues |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS

Commit Message

Hyong Youb Kim Aug. 8, 2024, 6:14 a.m. UTC
enic_set_mac_address() (mac_addr_add callback) currently allows only
non-zero, unicast address to be added. It is overly restrictive.
rte_eth_dev_mac_addr_add() itself allows multicast addresses. And,
some applications do use rte_eth_dev_mac_addr_add() to accept
multicast addresses. So, remove the unicast check in
enic_set_mac_address().

Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
Reviewed-by: John Daley <johndale@cisco.com>
---
 drivers/net/enic/enic_main.c | 20 --------------------
 1 file changed, 20 deletions(-)
  

Comments

Ferruh Yigit Aug. 8, 2024, 8:50 a.m. UTC | #1
On 8/8/2024 7:14 AM, Hyong Youb Kim wrote:
> enic_set_mac_address() (mac_addr_add callback) currently allows only
> non-zero, unicast address to be added. It is overly restrictive.
> rte_eth_dev_mac_addr_add() itself allows multicast addresses. And,
> some applications do use rte_eth_dev_mac_addr_add() to accept
> multicast addresses. So, remove the unicast check in
> enic_set_mac_address().
> 

What is the usecase to set Multicast MAC address as device default MAC
address?

Also, just a reminder that we have 'rte_eth_dev_set_mc_addr_list()' API
to set multicast MAC addresses.
  
Hyong Youb Kim Aug. 9, 2024, 6:49 a.m. UTC | #2
> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@amd.com>
> Sent: Thursday, August 8, 2024 5:51 PM
> To: Hyong Youb Kim (hyonkim) <hyonkim@cisco.com>
> Cc: dev@dpdk.org; John Daley (johndale) <johndale@cisco.com>
> Subject: Re: [PATCH v2 3/3] net/enic: allow multicast in MAC address add
> callback
> 
> On 8/8/2024 7:14 AM, Hyong Youb Kim wrote:
> > enic_set_mac_address() (mac_addr_add callback) currently allows only
> > non-zero, unicast address to be added. It is overly restrictive.
> > rte_eth_dev_mac_addr_add() itself allows multicast addresses. And,
> > some applications do use rte_eth_dev_mac_addr_add() to accept
> > multicast addresses. So, remove the unicast check in
> > enic_set_mac_address().
> >
> 
> What is the usecase to set Multicast MAC address as device default MAC
> address?
> 
> Also, just a reminder that we have 'rte_eth_dev_set_mc_addr_list()' API
> to set multicast MAC addresses.

I am aware of mc_addr_list().. Some people seem to use mac_addr_add()
as 'add a MAC filter'.

For the VIC adapter, there is no difference between the default MAC and
other MAC addresses added to allow/accept. They are all MAC filters in HW. 
I believe some other NICs also do not distinguish 'default' vs. additional
allowed MAC addresses (can be unicast or multicast).

The app in question is VPP. There might be others. It uses
rte_eth_dev_mac_addr_add() to add multicast MAC filters like all-hosts
address. I am not defending such usage. But given that (1)
rte_eth_dev_mac_addr_add() accepts multicast, and (2) adding
multicast works fine on multiple NICs, such usage is probably acceptable.

I am guessing some app developers find it easier to use mac_addr_add()
than mc_addr_list()..

We could tighten the semantics of rte_eth_dev_mac_addr_add() and
check if the given MAC is a valid unicast address in that API function.

Thanks.
-Hyong
  

Patch

diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index e59b0a5077..b755b15d92 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -32,21 +32,6 @@ 
 #include "vnic_intr.h"
 #include "vnic_nic.h"
 
-static int is_zero_addr(uint8_t *addr)
-{
-	return !(addr[0] |  addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
-}
-
-static int is_mcast_addr(uint8_t *addr)
-{
-	return addr[0] & 1;
-}
-
-static int is_eth_addr_valid(uint8_t *addr)
-{
-	return !is_mcast_addr(addr) && !is_zero_addr(addr);
-}
-
 void
 enic_rxmbuf_queue_release(__rte_unused struct enic *enic, struct vnic_rq *rq)
 {
@@ -177,11 +162,6 @@  int enic_set_mac_address(struct enic *enic, uint8_t *mac_addr)
 {
 	int err;
 
-	if (!is_eth_addr_valid(mac_addr)) {
-		dev_err(enic, "invalid mac address\n");
-		return -EINVAL;
-	}
-
 	err = enic_dev_add_addr(enic, mac_addr);
 	if (err)
 		dev_err(enic, "add mac addr failed\n");