mbox series

[net,0/2] Fix issues when PF sets MAC address for VF

Message ID 20241031060247.1290941-1-wei.fang@nxp.com (mailing list archive)
Headers show
Series Fix issues when PF sets MAC address for VF | expand

Message

Wei Fang Oct. 31, 2024, 6:02 a.m. UTC
The ENETC PF driver provides enetc_pf_set_vf_mac() to configure the MAC
address for the ENETC VF, but there are two issues when configuring the
MAC address of the VF through this interface. For specific issues, please
refer to the commit message of the following two patches. Therefore, this
patch set is used to fix these two issues.

Wei Fang (2):
  net: enetc: allocate vf_state during PF probes
  net: enetc: prevent PF from configuring MAC address for an enabled VF

 .../net/ethernet/freescale/enetc/enetc_pf.c   | 25 ++++++++++++-------
 1 file changed, 16 insertions(+), 9 deletions(-)

Comments

Jakub Kicinski Nov. 3, 2024, 8:50 p.m. UTC | #1
On Thu, 31 Oct 2024 14:02:45 +0800 Wei Fang wrote:
>   net: enetc: allocate vf_state during PF probes
>   net: enetc: prevent PF from configuring MAC address for an enabled VF

This combination of changes would imply that nobody sets the MAC
address on VFs via this driver, correct? Patch 1 fixes a crash
if address is set before VFs are enabled, patch 2 forces setting
the MAC before VFs are enabled (which would previously crash).
Which leads me to believe this will cause regressions to all users,
if such users exist.

The fact that the MAC address is not picked up by a running VM is
normal, I'd say even maybe expected. IIUC hypervisor will enable 
SRIOV at the start of day, then allocate, configure and assign VFs
to VMs. It will FLR the VF after configuration.

Your change will make it impossible to reconfigure VF with a MAC
of a new VM, if any other VF is in use.

Long story short, I don't believe the patch 2 is necessary at all,
maybe you can print a warning to the logs, if you really want.
patchwork-bot+netdevbpf@kernel.org Nov. 3, 2024, 9 p.m. UTC | #2
Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 31 Oct 2024 14:02:45 +0800 you wrote:
> The ENETC PF driver provides enetc_pf_set_vf_mac() to configure the MAC
> address for the ENETC VF, but there are two issues when configuring the
> MAC address of the VF through this interface. For specific issues, please
> refer to the commit message of the following two patches. Therefore, this
> patch set is used to fix these two issues.
> 
> Wei Fang (2):
>   net: enetc: allocate vf_state during PF probes
>   net: enetc: prevent PF from configuring MAC address for an enabled VF
> 
> [...]

Here is the summary with links:
  - [net,1/2] net: enetc: allocate vf_state during PF probes
    https://git.kernel.org/netdev/net/c/e15c5506dd39
  - [net,2/2] net: enetc: prevent PF from configuring MAC address for an enabled VF
    (no matching commit)

You are awesome, thank you!
Wei Fang Nov. 4, 2024, 2:41 a.m. UTC | #3
> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: 2024年11月4日 4:51
> To: Wei Fang <wei.fang@nxp.com>
> Cc: davem@davemloft.net; edumazet@google.com; pabeni@redhat.com;
> andrew+netdev@lunn.ch; Claudiu Manoil <claudiu.manoil@nxp.com>;
> Vladimir Oltean <vladimir.oltean@nxp.com>; netdev@vger.kernel.org;
> linux-kernel@vger.kernel.org; imx@lists.linux.dev
> Subject: Re: [PATCH net 0/2] Fix issues when PF sets MAC address for VF
> 
> On Thu, 31 Oct 2024 14:02:45 +0800 Wei Fang wrote:
> >   net: enetc: allocate vf_state during PF probes
> >   net: enetc: prevent PF from configuring MAC address for an enabled VF
> 
> This combination of changes would imply that nobody sets the MAC
> address on VFs via this driver, correct? Patch 1 fixes a crash
> if address is set before VFs are enabled, patch 2 forces setting
> the MAC before VFs are enabled (which would previously crash).
> Which leads me to believe this will cause regressions to all users,
> if such users exist.

To be honest, I don't know much about the LS1028A platform. Apparently,
Before this patch, users could only modify the MAC address of VF through
the PF driver after the VF is enabled. However, the VF driver only obtains
the MAC address from the register and set it into net_device during probe.
Since VF has been enabled, the VF driver has already completed the probe.
Therefore, if users want to the VF network to work properly, they need to
re-probe the VF driver. If users do disable/enable SRIOV or unbind/bind
VF driver to re-probe the VF driver, such as you mentioned below, assign
the VF to a VM, patch 2 will indeed cause a regression issue.

> 
> The fact that the MAC address is not picked up by a running VM is
> normal, I'd say even maybe expected. IIUC hypervisor will enable
> SRIOV at the start of day, then allocate, configure and assign VFs
> to VMs. It will FLR the VF after configuration.
> 
> Your change will make it impossible to reconfigure VF with a MAC
> of a new VM, if any other VF is in use.
> 
> Long story short, I don't believe the patch 2 is necessary at all,
> maybe you can print a warning to the logs, if you really want.

I think your concern is reasonable, the best way is that we add the
PSI-to-VSI messaging in the future, so that is wont cause regression
issue. Thanks.