imx.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: enetc: set MAC address to the VF net_device
@ 2024-10-28  8:52 Wei Fang
  2024-10-28  9:23 ` Wei Fang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wei Fang @ 2024-10-28  8:52 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, claudiu.manoil,
	vladimir.oltean
  Cc: netdev, linux-kernel, imx

The MAC address of VF can be configured through the mailbox mechanism of
ENETC, but the previous implementation forgot to set the MAC address in
net_device, resulting in the SMAC of the sent frames still being the old
MAC address. Since the MAC address in the hardware has been changed, Rx
cannot receive frames with the DMAC address as the new MAC address. The
most obvious phenomenon is that after changing the MAC address, we can
see that the MAC address of eno0vf0 has not changed through the "ifconfig
eno0vf0" commandand the IP address cannot be obtained .

root@ls1028ardb:~# ifconfig eno0vf0 down
root@ls1028ardb:~# ifconfig eno0vf0 hw ether 00:04:9f:3a:4d:56 up
root@ls1028ardb:~# ifconfig eno0vf0
eno0vf0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 66:36:2c:3b:87:76  txqueuelen 1000  (Ethernet)
        RX packets 794  bytes 69239 (69.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11  bytes 2226 (2.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Fixes: beb74ac878c8 ("enetc: Add vf to pf messaging support")
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
 drivers/net/ethernet/freescale/enetc/enetc_vf.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
index dfcaac302e24..b15db70769e5 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
@@ -78,11 +78,18 @@ static int enetc_vf_set_mac_addr(struct net_device *ndev, void *addr)
 {
 	struct enetc_ndev_priv *priv = netdev_priv(ndev);
 	struct sockaddr *saddr = addr;
+	int err;
 
 	if (!is_valid_ether_addr(saddr->sa_data))
 		return -EADDRNOTAVAIL;
 
-	return enetc_msg_vsi_set_primary_mac_addr(priv, saddr);
+	err = enetc_msg_vsi_set_primary_mac_addr(priv, saddr);
+	if (err)
+		return err;
+
+	eth_hw_addr_set(ndev, saddr->sa_data);
+
+	return 0;
 }
 
 static int enetc_vf_set_features(struct net_device *ndev,
-- 
2.34.1


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

* RE: [PATCH net] net: enetc: set MAC address to the VF net_device
  2024-10-28  8:52 [PATCH net] net: enetc: set MAC address to the VF net_device Wei Fang
@ 2024-10-28  9:23 ` Wei Fang
  2024-10-28 11:51 ` Vladimir Oltean
  2024-10-28 12:01 ` Claudiu Manoil
  2 siblings, 0 replies; 4+ messages in thread
From: Wei Fang @ 2024-10-28  9:23 UTC (permalink / raw)
  To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, andrew+netdev@lunn.ch, Claudiu Manoil,
	Vladimir Oltean
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	imx@lists.linux.dev

> -----Original Message-----
> From: Wei Fang
> Sent: 2024年10月28日 17:08
> To: davem@davemloft.net; edumazet@google.com; kuba@kernel.org;
> pabeni@redhat.com; andrew+netdev@lunn.ch; Claudiu Manoil
> <claudiu.manoil@nxp.com>; Vladimir Oltean <vladimir.oltean@nxp.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; imx@lists.linux.dev
> Subject: [PATCH net] net: enetc: set MAC address to the VF net_device
> 
> The MAC address of VF can be configured through the mailbox mechanism of
> ENETC, but the previous implementation forgot to set the MAC address in
> net_device, resulting in the SMAC of the sent frames still being the old
> MAC address. Since the MAC address in the hardware has been changed, Rx
> cannot receive frames with the DMAC address as the new MAC address. The
> most obvious phenomenon is that after changing the MAC address, we can
> see that the MAC address of eno0vf0 has not changed through the "ifconfig
> eno0vf0" commandand the IP address cannot be obtained .
		        ^^^^
Sorry, there is missing a space. I'll fix it in v2.

> 
> root@ls1028ardb:~# ifconfig eno0vf0 down
> root@ls1028ardb:~# ifconfig eno0vf0 hw ether 00:04:9f:3a:4d:56 up
> root@ls1028ardb:~# ifconfig eno0vf0
> eno0vf0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
>         ether 66:36:2c:3b:87:76  txqueuelen 1000  (Ethernet)
>         RX packets 794  bytes 69239 (69.2 KB)
>         RX errors 0  dropped 0  overruns 0  frame 0
>         TX packets 11  bytes 2226 (2.2 KB)
>         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
> 
> Fixes: beb74ac878c8 ("enetc: Add vf to pf messaging support")
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
>  drivers/net/ethernet/freescale/enetc/enetc_vf.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c
> b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
> index dfcaac302e24..b15db70769e5 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
> @@ -78,11 +78,18 @@ static int enetc_vf_set_mac_addr(struct net_device
> *ndev, void *addr)
>  {
>  	struct enetc_ndev_priv *priv = netdev_priv(ndev);
>  	struct sockaddr *saddr = addr;
> +	int err;
> 
>  	if (!is_valid_ether_addr(saddr->sa_data))
>  		return -EADDRNOTAVAIL;
> 
> -	return enetc_msg_vsi_set_primary_mac_addr(priv, saddr);
> +	err = enetc_msg_vsi_set_primary_mac_addr(priv, saddr);
> +	if (err)
> +		return err;
> +
> +	eth_hw_addr_set(ndev, saddr->sa_data);
> +
> +	return 0;
>  }
> 
>  static int enetc_vf_set_features(struct net_device *ndev,
> --
> 2.34.1


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

* Re: [PATCH net] net: enetc: set MAC address to the VF net_device
  2024-10-28  8:52 [PATCH net] net: enetc: set MAC address to the VF net_device Wei Fang
  2024-10-28  9:23 ` Wei Fang
@ 2024-10-28 11:51 ` Vladimir Oltean
  2024-10-28 12:01 ` Claudiu Manoil
  2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Oltean @ 2024-10-28 11:51 UTC (permalink / raw)
  To: Wei Fang
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, claudiu.manoil,
	netdev, linux-kernel, imx

On Mon, Oct 28, 2024 at 04:52:42PM +0800, Wei Fang wrote:
> The MAC address of VF can be configured through the mailbox mechanism of
> ENETC, but the previous implementation forgot to set the MAC address in
> net_device, resulting in the SMAC of the sent frames still being the old
> MAC address. Since the MAC address in the hardware has been changed, Rx
> cannot receive frames with the DMAC address as the new MAC address. The
> most obvious phenomenon is that after changing the MAC address, we can
> see that the MAC address of eno0vf0 has not changed through the "ifconfig
> eno0vf0" commandand the IP address cannot be obtained .
> 
> root@ls1028ardb:~# ifconfig eno0vf0 down
> root@ls1028ardb:~# ifconfig eno0vf0 hw ether 00:04:9f:3a:4d:56 up
> root@ls1028ardb:~# ifconfig eno0vf0
> eno0vf0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
>         ether 66:36:2c:3b:87:76  txqueuelen 1000  (Ethernet)
>         RX packets 794  bytes 69239 (69.2 KB)
>         RX errors 0  dropped 0  overruns 0  frame 0
>         TX packets 11  bytes 2226 (2.2 KB)
>         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
> 
> Fixes: beb74ac878c8 ("enetc: Add vf to pf messaging support")
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

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

* RE: [PATCH net] net: enetc: set MAC address to the VF net_device
  2024-10-28  8:52 [PATCH net] net: enetc: set MAC address to the VF net_device Wei Fang
  2024-10-28  9:23 ` Wei Fang
  2024-10-28 11:51 ` Vladimir Oltean
@ 2024-10-28 12:01 ` Claudiu Manoil
  2 siblings, 0 replies; 4+ messages in thread
From: Claudiu Manoil @ 2024-10-28 12:01 UTC (permalink / raw)
  To: Wei Fang, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch,
	Vladimir Oltean
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	imx@lists.linux.dev

> -----Original Message-----
> From: Wei Fang <wei.fang@nxp.com>
> Sent: Monday, October 28, 2024 10:53 AM
[...]
> Subject: [PATCH net] net: enetc: set MAC address to the VF net_device
> 
> The MAC address of VF can be configured through the mailbox mechanism of
> ENETC, but the previous implementation forgot to set the MAC address in
> net_device, resulting in the SMAC of the sent frames still being the old
> MAC address. Since the MAC address in the hardware has been changed, Rx
> cannot receive frames with the DMAC address as the new MAC address. The
> most obvious phenomenon is that after changing the MAC address, we can
> see that the MAC address of eno0vf0 has not changed through the "ifconfig
> eno0vf0" commandand the IP address cannot be obtained .
> 
> root@ls1028ardb:~# ifconfig eno0vf0 down
> root@ls1028ardb:~# ifconfig eno0vf0 hw ether 00:04:9f:3a:4d:56 up
> root@ls1028ardb:~# ifconfig eno0vf0
> eno0vf0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
>         ether 66:36:2c:3b:87:76  txqueuelen 1000  (Ethernet)
>         RX packets 794  bytes 69239 (69.2 KB)
>         RX errors 0  dropped 0  overruns 0  frame 0
>         TX packets 11  bytes 2226 (2.2 KB)
>         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
> 
> Fixes: beb74ac878c8 ("enetc: Add vf to pf messaging support")
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---

Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>

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

end of thread, other threads:[~2024-10-28 12:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-28  8:52 [PATCH net] net: enetc: set MAC address to the VF net_device Wei Fang
2024-10-28  9:23 ` Wei Fang
2024-10-28 11:51 ` Vladimir Oltean
2024-10-28 12:01 ` Claudiu Manoil

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