Skip to content

Commit e5f6175

Browse files
Achiad Shochatdledford
authored andcommitted
net/mlx5_core: Break down the vport mac address query function
Introduce a new function called mlx5_query_nic_vport_context(). This function gets all the NIC vport attributes from the device. The MAC address is just one of the NIC vport attributes, so mlx5_query_nic_vport_mac_address() is now just a wrapper function above mlx5_query_nic_vport_context(). More NIC vport attributes will be used in following commits. Signed-off-by: Achiad Shochat <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent fc24fc5 commit e5f6175

File tree

1 file changed

+17
-10
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+17
-10
lines changed

drivers/net/ethernet/mellanox/mlx5/core/vport.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,25 @@ u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod)
5757
}
5858
EXPORT_SYMBOL(mlx5_query_vport_state);
5959

60+
static int mlx5_query_nic_vport_context(struct mlx5_core_dev *mdev, u32 *out,
61+
int outlen)
62+
{
63+
u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)];
64+
65+
memset(in, 0, sizeof(in));
66+
67+
MLX5_SET(query_nic_vport_context_in, in, opcode,
68+
MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
69+
70+
return mlx5_cmd_exec_check_status(mdev, in, sizeof(in), out, outlen);
71+
}
72+
6073
void mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev, u8 *addr)
6174
{
62-
u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)];
6375
u32 *out;
6476
int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out);
6577
u8 *out_addr;
78+
int err;
6679

6780
out = mlx5_vzalloc(outlen);
6881
if (!out)
@@ -71,15 +84,9 @@ void mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev, u8 *addr)
7184
out_addr = MLX5_ADDR_OF(query_nic_vport_context_out, out,
7285
nic_vport_context.permanent_address);
7386

74-
memset(in, 0, sizeof(in));
75-
76-
MLX5_SET(query_nic_vport_context_in, in, opcode,
77-
MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
78-
79-
memset(out, 0, outlen);
80-
mlx5_cmd_exec_check_status(mdev, in, sizeof(in), out, outlen);
81-
82-
ether_addr_copy(addr, &out_addr[2]);
87+
err = mlx5_query_nic_vport_context(mdev, out, outlen);
88+
if (!err)
89+
ether_addr_copy(addr, &out_addr[2]);
8390

8491
kvfree(out);
8592
}

0 commit comments

Comments
 (0)