Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

{rdma,net}/mlx5: Query vports mac address from device

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.

Vports hold information for VFs/SFs such as the permanent mac address.
VF/SF mac 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, to align with other vport
information that are never reset, e.g GUID,mtu,promisc mode, etc ..

Signed-off-by: Adithya Jayachandran <ajayachandra@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Acked-by: Leon Romanovsky <leon@kernel.org> # RDMA

authored by

Adithya Jayachandran and committed by
Saeed Mahameed
eea31f21 3a866087

+25 -27
+1 -1
drivers/infiniband/hw/mlx5/main.c
··· 842 842 break; 843 843 844 844 case MLX5_VPORT_ACCESS_METHOD_NIC: 845 - err = mlx5_query_nic_vport_node_guid(dev->mdev, &tmp); 845 + err = mlx5_query_nic_vport_node_guid(dev->mdev, 0, false, &tmp); 846 846 break; 847 847 848 848 default:
+7 -13
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
··· 875 875 vport_num, 1, 876 876 vport->info.link_state); 877 877 878 - /* Host PF has its own mac/guid. */ 879 - if (vport_num) { 880 - mlx5_modify_nic_vport_mac_address(esw->dev, vport_num, 881 - vport->info.mac); 882 - mlx5_modify_nic_vport_node_guid(esw->dev, vport_num, 883 - vport->info.node_guid); 884 - } 878 + mlx5_query_nic_vport_mac_address(esw->dev, vport_num, true, 879 + vport->info.mac); 880 + mlx5_query_nic_vport_node_guid(esw->dev, vport_num, true, 881 + &vport->info.node_guid); 885 882 886 883 flags = (vport->info.vlan || vport->info.qos) ? 887 884 SET_VLAN_STRIP | SET_VLAN_INSERT : 0; ··· 943 946 if (ret) 944 947 goto err_vhca_mapping; 945 948 } 946 - 947 - /* External controller host PF has factory programmed MAC. 948 - * Read it from the device. 949 - */ 950 - if (mlx5_core_is_ecpf(esw->dev) && vport_num == MLX5_VPORT_PF) 951 - mlx5_query_nic_vport_mac_address(esw->dev, vport_num, true, vport->info.mac); 952 949 953 950 esw_vport_change_handle_locked(vport); 954 951 ··· 2226 2235 ivi->vf = vport - 1; 2227 2236 2228 2237 mutex_lock(&esw->state_lock); 2238 + 2239 + mlx5_query_nic_vport_mac_address(esw->dev, vport, true, 2240 + evport->info.mac); 2229 2241 ether_addr_copy(ivi->mac, evport->info.mac); 2230 2242 ivi->linkstate = evport->info.link_state; 2231 2243 ivi->vlan = evport->info.vlan;
+3
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
··· 4303 4303 struct mlx5_vport *vport = mlx5_devlink_port_vport_get(port); 4304 4304 4305 4305 mutex_lock(&esw->state_lock); 4306 + 4307 + mlx5_query_nic_vport_mac_address(esw->dev, vport->vport, true, 4308 + vport->info.mac); 4306 4309 ether_addr_copy(hw_addr, vport->info.mac); 4307 4310 *hw_addr_len = ETH_ALEN; 4308 4311 mutex_unlock(&esw->state_lock);
+12 -12
drivers/net/ethernet/mellanox/mlx5/core/vport.c
··· 78 78 } 79 79 80 80 static int mlx5_query_nic_vport_context(struct mlx5_core_dev *mdev, u16 vport, 81 - u32 *out) 81 + bool other_vport, u32 *out) 82 82 { 83 83 u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)] = {}; 84 84 85 85 MLX5_SET(query_nic_vport_context_in, in, opcode, 86 86 MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT); 87 87 MLX5_SET(query_nic_vport_context_in, in, vport_number, vport); 88 - if (vport) 89 - MLX5_SET(query_nic_vport_context_in, in, other_vport, 1); 88 + MLX5_SET(query_nic_vport_context_in, in, other_vport, other_vport); 90 89 91 90 return mlx5_cmd_exec_inout(mdev, query_nic_vport_context, in, out); 92 91 } ··· 96 97 u32 out[MLX5_ST_SZ_DW(query_nic_vport_context_out)] = {}; 97 98 int err; 98 99 99 - err = mlx5_query_nic_vport_context(mdev, vport, out); 100 + err = mlx5_query_nic_vport_context(mdev, vport, vport > 0, out); 100 101 if (!err) 101 102 *min_inline = MLX5_GET(query_nic_vport_context_out, out, 102 103 nic_vport_context.min_wqe_inline_mode); ··· 218 219 if (!out) 219 220 return -ENOMEM; 220 221 221 - err = mlx5_query_nic_vport_context(mdev, 0, out); 222 + err = mlx5_query_nic_vport_context(mdev, 0, false, out); 222 223 if (!err) 223 224 *mtu = MLX5_GET(query_nic_vport_context_out, out, 224 225 nic_vport_context.mtu); ··· 428 429 if (!out) 429 430 return -ENOMEM; 430 431 431 - err = mlx5_query_nic_vport_context(mdev, 0, out); 432 + err = mlx5_query_nic_vport_context(mdev, 0, false, out); 432 433 if (err) 433 434 goto out; 434 435 ··· 450 451 if (!out) 451 452 return -ENOMEM; 452 453 453 - err = mlx5_query_nic_vport_context(mdev, 0, out); 454 + err = mlx5_query_nic_vport_context(mdev, 0, false, out); 454 455 if (err) 455 456 goto out; 456 457 ··· 461 462 return err; 462 463 } 463 464 464 - int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid) 465 + int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, 466 + u16 vport, bool other_vport, u64 *node_guid) 465 467 { 466 468 u32 *out; 467 469 int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out); ··· 472 472 if (!out) 473 473 return -ENOMEM; 474 474 475 - err = mlx5_query_nic_vport_context(mdev, 0, out); 475 + err = mlx5_query_nic_vport_context(mdev, vport, other_vport, out); 476 476 if (err) 477 477 goto out; 478 478 ··· 529 529 if (!out) 530 530 return -ENOMEM; 531 531 532 - err = mlx5_query_nic_vport_context(mdev, 0, out); 532 + err = mlx5_query_nic_vport_context(mdev, 0, false, out); 533 533 if (err) 534 534 goto out; 535 535 ··· 804 804 if (!out) 805 805 return -ENOMEM; 806 806 807 - err = mlx5_query_nic_vport_context(mdev, vport, out); 807 + err = mlx5_query_nic_vport_context(mdev, vport, vport > 0, out); 808 808 if (err) 809 809 goto out; 810 810 ··· 908 908 if (!out) 909 909 return -ENOMEM; 910 910 911 - err = mlx5_query_nic_vport_context(mdev, 0, out); 911 + err = mlx5_query_nic_vport_context(mdev, 0, false, out); 912 912 if (err) 913 913 goto out; 914 914
+2 -1
include/linux/mlx5/vport.h
··· 73 73 int mlx5_query_nic_vport_system_image_guid(struct mlx5_core_dev *mdev, 74 74 u64 *system_image_guid); 75 75 int mlx5_query_nic_vport_sd_group(struct mlx5_core_dev *mdev, u8 *sd_group); 76 - int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid); 76 + int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, 77 + u16 vport, bool other_vport, u64 *node_guid); 77 78 int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev, 78 79 u16 vport, u64 node_guid); 79 80 int mlx5_query_nic_vport_qkey_viol_cntr(struct mlx5_core_dev *mdev,