* [PATCH mlx5-next] {rdma,net}/mlx5: Query vports mac address from device
@ 2025-10-16 1:40 Saeed Mahameed
2025-10-19 12:59 ` Leon Romanovsky
2025-10-21 23:47 ` Jakub Kicinski
0 siblings, 2 replies; 6+ messages in thread
From: Saeed Mahameed @ 2025-10-16 1:40 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky
Cc: Jason Gunthorpe, linux-rdma, netdev, Tariq Toukan,
Adithya Jayachandran, Mark Bloch
From: Adithya Jayachandran <ajayachandra@nvidia.com>
Before this patch during either switchdev or legacy mode enablement we
cleared the mac address of vports between changes. This change allows us
to preserve the vports mac address between eswitch mode changes.
Signed-off-by: Adithya Jayachandran <ajayachandra@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
---
drivers/infiniband/hw/mlx5/main.c | 2 +-
.../net/ethernet/mellanox/mlx5/core/eswitch.c | 20 ++++++----------
.../mellanox/mlx5/core/eswitch_offloads.c | 3 +++
.../net/ethernet/mellanox/mlx5/core/vport.c | 24 +++++++++----------
include/linux/mlx5/vport.h | 3 ++-
5 files changed, 25 insertions(+), 27 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index fc1e86f6c409..90daa58126f4 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -842,7 +842,7 @@ static int mlx5_query_node_guid(struct mlx5_ib_dev *dev,
break;
case MLX5_VPORT_ACCESS_METHOD_NIC:
- err = mlx5_query_nic_vport_node_guid(dev->mdev, &tmp);
+ err = mlx5_query_nic_vport_node_guid(dev->mdev, 0, false, &tmp);
break;
default:
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index e2ffb87b94cb..25af8bd7f077 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -875,13 +875,10 @@ static int esw_vport_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport)
vport_num, 1,
vport->info.link_state);
- /* Host PF has its own mac/guid. */
- if (vport_num) {
- mlx5_modify_nic_vport_mac_address(esw->dev, vport_num,
- vport->info.mac);
- mlx5_modify_nic_vport_node_guid(esw->dev, vport_num,
- vport->info.node_guid);
- }
+ mlx5_query_nic_vport_mac_address(esw->dev, vport_num, true,
+ vport->info.mac);
+ mlx5_query_nic_vport_node_guid(esw->dev, vport_num, true,
+ &vport->info.node_guid);
flags = (vport->info.vlan || vport->info.qos) ?
SET_VLAN_STRIP | SET_VLAN_INSERT : 0;
@@ -947,12 +944,6 @@ int mlx5_esw_vport_enable(struct mlx5_eswitch *esw, struct mlx5_vport *vport,
goto err_vhca_mapping;
}
- /* External controller host PF has factory programmed MAC.
- * Read it from the device.
- */
- if (mlx5_core_is_ecpf(esw->dev) && vport_num == MLX5_VPORT_PF)
- mlx5_query_nic_vport_mac_address(esw->dev, vport_num, true, vport->info.mac);
-
esw_vport_change_handle_locked(vport);
esw->enabled_vports++;
@@ -2235,6 +2226,9 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
ivi->vf = vport - 1;
mutex_lock(&esw->state_lock);
+
+ mlx5_query_nic_vport_mac_address(esw->dev, vport, true,
+ evport->info.mac);
ether_addr_copy(ivi->mac, evport->info.mac);
ivi->linkstate = evport->info.link_state;
ivi->vlan = evport->info.vlan;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 4cf995be127d..880e238497b1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -4303,6 +4303,9 @@ int mlx5_devlink_port_fn_hw_addr_get(struct devlink_port *port,
struct mlx5_vport *vport = mlx5_devlink_port_vport_get(port);
mutex_lock(&esw->state_lock);
+
+ mlx5_query_nic_vport_mac_address(esw->dev, vport->vport, true,
+ vport->info.mac);
ether_addr_copy(hw_addr, vport->info.mac);
*hw_addr_len = ETH_ALEN;
mutex_unlock(&esw->state_lock);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
index 2ed2e530b07d..d1483f66cd0c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
@@ -78,15 +78,14 @@ int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,
}
static int mlx5_query_nic_vport_context(struct mlx5_core_dev *mdev, u16 vport,
- u32 *out)
+ bool other_vport, u32 *out)
{
u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)] = {};
MLX5_SET(query_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
MLX5_SET(query_nic_vport_context_in, in, vport_number, vport);
- if (vport)
- MLX5_SET(query_nic_vport_context_in, in, other_vport, 1);
+ MLX5_SET(query_nic_vport_context_in, in, other_vport, other_vport);
return mlx5_cmd_exec_inout(mdev, query_nic_vport_context, in, out);
}
@@ -97,7 +96,7 @@ int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,
u32 out[MLX5_ST_SZ_DW(query_nic_vport_context_out)] = {};
int err;
- err = mlx5_query_nic_vport_context(mdev, vport, out);
+ err = mlx5_query_nic_vport_context(mdev, vport, vport > 0, out);
if (!err)
*min_inline = MLX5_GET(query_nic_vport_context_out, out,
nic_vport_context.min_wqe_inline_mode);
@@ -219,7 +218,7 @@ int mlx5_query_nic_vport_mtu(struct mlx5_core_dev *mdev, u16 *mtu)
if (!out)
return -ENOMEM;
- err = mlx5_query_nic_vport_context(mdev, 0, out);
+ err = mlx5_query_nic_vport_context(mdev, 0, false, out);
if (!err)
*mtu = MLX5_GET(query_nic_vport_context_out, out,
nic_vport_context.mtu);
@@ -429,7 +428,7 @@ int mlx5_query_nic_vport_system_image_guid(struct mlx5_core_dev *mdev,
if (!out)
return -ENOMEM;
- err = mlx5_query_nic_vport_context(mdev, 0, out);
+ err = mlx5_query_nic_vport_context(mdev, 0, false, out);
if (err)
goto out;
@@ -451,7 +450,7 @@ int mlx5_query_nic_vport_sd_group(struct mlx5_core_dev *mdev, u8 *sd_group)
if (!out)
return -ENOMEM;
- err = mlx5_query_nic_vport_context(mdev, 0, out);
+ err = mlx5_query_nic_vport_context(mdev, 0, false, out);
if (err)
goto out;
@@ -462,7 +461,8 @@ int mlx5_query_nic_vport_sd_group(struct mlx5_core_dev *mdev, u8 *sd_group)
return err;
}
-int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid)
+int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev,
+ u16 vport, bool other_vport, u64 *node_guid)
{
u32 *out;
int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out);
@@ -472,7 +472,7 @@ int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid)
if (!out)
return -ENOMEM;
- err = mlx5_query_nic_vport_context(mdev, 0, out);
+ err = mlx5_query_nic_vport_context(mdev, vport, other_vport, out);
if (err)
goto out;
@@ -529,7 +529,7 @@ int mlx5_query_nic_vport_qkey_viol_cntr(struct mlx5_core_dev *mdev,
if (!out)
return -ENOMEM;
- err = mlx5_query_nic_vport_context(mdev, 0, out);
+ err = mlx5_query_nic_vport_context(mdev, 0, false, out);
if (err)
goto out;
@@ -804,7 +804,7 @@ int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev,
if (!out)
return -ENOMEM;
- err = mlx5_query_nic_vport_context(mdev, vport, out);
+ err = mlx5_query_nic_vport_context(mdev, vport, vport > 0, out);
if (err)
goto out;
@@ -908,7 +908,7 @@ int mlx5_nic_vport_query_local_lb(struct mlx5_core_dev *mdev, bool *status)
if (!out)
return -ENOMEM;
- err = mlx5_query_nic_vport_context(mdev, 0, out);
+ err = mlx5_query_nic_vport_context(mdev, 0, false, out);
if (err)
goto out;
diff --git a/include/linux/mlx5/vport.h b/include/linux/mlx5/vport.h
index c87b9507cfa1..f876bfc0669c 100644
--- a/include/linux/mlx5/vport.h
+++ b/include/linux/mlx5/vport.h
@@ -73,7 +73,8 @@ int mlx5_modify_nic_vport_mtu(struct mlx5_core_dev *mdev, u16 mtu);
int mlx5_query_nic_vport_system_image_guid(struct mlx5_core_dev *mdev,
u64 *system_image_guid);
int mlx5_query_nic_vport_sd_group(struct mlx5_core_dev *mdev, u8 *sd_group);
-int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid);
+int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev,
+ u16 vport, bool other_vport, u64 *node_guid);
int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
u16 vport, u64 node_guid);
int mlx5_query_nic_vport_qkey_viol_cntr(struct mlx5_core_dev *mdev,
--
2.51.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH mlx5-next] {rdma,net}/mlx5: Query vports mac address from device
2025-10-16 1:40 [PATCH mlx5-next] {rdma,net}/mlx5: Query vports mac address from device Saeed Mahameed
@ 2025-10-19 12:59 ` Leon Romanovsky
2025-10-21 23:47 ` Jakub Kicinski
1 sibling, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2025-10-19 12:59 UTC (permalink / raw)
To: Saeed Mahameed
Cc: Saeed Mahameed, Jason Gunthorpe, linux-rdma, netdev, Tariq Toukan,
Adithya Jayachandran, Mark Bloch
On Wed, Oct 15, 2025 at 06:40:55PM -0700, Saeed Mahameed wrote:
> From: Adithya Jayachandran <ajayachandra@nvidia.com>
>
> Before this patch during either switchdev or legacy mode enablement we
> cleared the mac address of vports between changes. This change allows us
> to preserve the vports mac address between eswitch mode changes.
>
> Signed-off-by: Adithya Jayachandran <ajayachandra@nvidia.com>
> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
> Reviewed-by: Mark Bloch <mbloch@nvidia.com>
> ---
> drivers/infiniband/hw/mlx5/main.c | 2 +-
> .../net/ethernet/mellanox/mlx5/core/eswitch.c | 20 ++++++----------
> .../mellanox/mlx5/core/eswitch_offloads.c | 3 +++
> .../net/ethernet/mellanox/mlx5/core/vport.c | 24 +++++++++----------
> include/linux/mlx5/vport.h | 3 ++-
> 5 files changed, 25 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
> index fc1e86f6c409..90daa58126f4 100644
> --- a/drivers/infiniband/hw/mlx5/main.c
> +++ b/drivers/infiniband/hw/mlx5/main.c
> @@ -842,7 +842,7 @@ static int mlx5_query_node_guid(struct mlx5_ib_dev *dev,
> break;
>
> case MLX5_VPORT_ACCESS_METHOD_NIC:
> - err = mlx5_query_nic_vport_node_guid(dev->mdev, &tmp);
> + err = mlx5_query_nic_vport_node_guid(dev->mdev, 0, false, &tmp);
> break;
IB changes are pretty straightforward.
Thanks,
Acked-by: Leon Romanovsky <leon@kernel.org> # RDMA
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH mlx5-next] {rdma,net}/mlx5: Query vports mac address from device
2025-10-16 1:40 [PATCH mlx5-next] {rdma,net}/mlx5: Query vports mac address from device Saeed Mahameed
2025-10-19 12:59 ` Leon Romanovsky
@ 2025-10-21 23:47 ` Jakub Kicinski
2025-10-22 2:12 ` Saeed Mahameed
1 sibling, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2025-10-21 23:47 UTC (permalink / raw)
To: Saeed Mahameed
Cc: Saeed Mahameed, Leon Romanovsky, Jason Gunthorpe, linux-rdma,
netdev, Tariq Toukan, Adithya Jayachandran, Mark Bloch
On Wed, 15 Oct 2025 18:40:55 -0700 Saeed Mahameed wrote:
> Before this patch during either switchdev or legacy mode enablement we
> cleared the mac address of vports between changes. This change allows us
> to preserve the vports mac address between eswitch mode changes.
Not knowing what exactly a vport is I can't tell whether this preserves
MAC addrs of reprs, the uplink, something else?
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH mlx5-next] {rdma,net}/mlx5: Query vports mac address from device
2025-10-21 23:47 ` Jakub Kicinski
@ 2025-10-22 2:12 ` Saeed Mahameed
2025-10-23 0:10 ` Jakub Kicinski
0 siblings, 1 reply; 6+ messages in thread
From: Saeed Mahameed @ 2025-10-22 2:12 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Saeed Mahameed, Leon Romanovsky, Jason Gunthorpe, linux-rdma,
netdev, Tariq Toukan, Adithya Jayachandran, Mark Bloch
On 21 Oct 16:47, Jakub Kicinski wrote:
>On Wed, 15 Oct 2025 18:40:55 -0700 Saeed Mahameed wrote:
>> Before this patch during either switchdev or legacy mode enablement we
>> cleared the mac address of vports between changes. This change allows us
>> to preserve the vports mac address between eswitch mode changes.
>
>Not knowing what exactly a vport is I can't tell whether this preserves
>MAC addrs of reprs, the uplink, something else?
vport == vf or sf, so VF/SF permanent mac address. It can be set either by
iproute vf interface or devlink function interface. For no obvious reason
we reset it to 0 on switchdev legacy mode changes.. this patch is fixing
that.
Of course vport holds more information than just the mac address, e.g GUID,
mtu, promisc mode, mulitcast mode, and other stuff.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH mlx5-next] {rdma,net}/mlx5: Query vports mac address from device
2025-10-22 2:12 ` Saeed Mahameed
@ 2025-10-23 0:10 ` Jakub Kicinski
2025-10-25 3:21 ` Saeed Mahameed
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2025-10-23 0:10 UTC (permalink / raw)
To: Saeed Mahameed
Cc: Saeed Mahameed, Leon Romanovsky, Jason Gunthorpe, linux-rdma,
netdev, Tariq Toukan, Adithya Jayachandran, Mark Bloch
On Tue, 21 Oct 2025 19:12:21 -0700 Saeed Mahameed wrote:
> On 21 Oct 16:47, Jakub Kicinski wrote:
> >On Wed, 15 Oct 2025 18:40:55 -0700 Saeed Mahameed wrote:
> >> Before this patch during either switchdev or legacy mode enablement we
> >> cleared the mac address of vports between changes. This change allows us
> >> to preserve the vports mac address between eswitch mode changes.
> >
> >Not knowing what exactly a vport is I can't tell whether this preserves
> >MAC addrs of reprs, the uplink, something else?
>
> vport == vf or sf, so VF/SF permanent mac address. It can be set either by
> iproute vf interface or devlink function interface. For no obvious reason
> we reset it to 0 on switchdev legacy mode changes.. this patch is fixing
> that.
>
> Of course vport holds more information than just the mac address, e.g GUID,
> mtu, promisc mode, mulitcast mode, and other stuff.
SG! Would be good to incorporate that into the commit msg if possible.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH mlx5-next] {rdma,net}/mlx5: Query vports mac address from device
2025-10-23 0:10 ` Jakub Kicinski
@ 2025-10-25 3:21 ` Saeed Mahameed
0 siblings, 0 replies; 6+ messages in thread
From: Saeed Mahameed @ 2025-10-25 3:21 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Saeed Mahameed, Leon Romanovsky, Jason Gunthorpe, linux-rdma,
netdev, Tariq Toukan, Adithya Jayachandran, Mark Bloch
On 22 Oct 17:10, Jakub Kicinski wrote:
>On Tue, 21 Oct 2025 19:12:21 -0700 Saeed Mahameed wrote:
>> On 21 Oct 16:47, Jakub Kicinski wrote:
>> >On Wed, 15 Oct 2025 18:40:55 -0700 Saeed Mahameed wrote:
>> >> Before this patch during either switchdev or legacy mode enablement we
>> >> cleared the mac address of vports between changes. This change allows us
>> >> to preserve the vports mac address between eswitch mode changes.
>> >
>> >Not knowing what exactly a vport is I can't tell whether this preserves
>> >MAC addrs of reprs, the uplink, something else?
>>
>> vport == vf or sf, so VF/SF permanent mac address. It can be set either by
>> iproute vf interface or devlink function interface. For no obvious reason
>> we reset it to 0 on switchdev legacy mode changes.. this patch is fixing
>> that.
>>
>> Of course vport holds more information than just the mac address, e.g GUID,
>> mtu, promisc mode, mulitcast mode, and other stuff.
>
>SG! Would be good to incorporate that into the commit msg if possible.
Makes sense, Done.
Applied to mlx5-next ! thanks for the review.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-25 3:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 1:40 [PATCH mlx5-next] {rdma,net}/mlx5: Query vports mac address from device Saeed Mahameed
2025-10-19 12:59 ` Leon Romanovsky
2025-10-21 23:47 ` Jakub Kicinski
2025-10-22 2:12 ` Saeed Mahameed
2025-10-23 0:10 ` Jakub Kicinski
2025-10-25 3:21 ` Saeed Mahameed
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).