net/mlx5: E-switch, Supporting setting devlink port function mac address
Enable user to set mac address of the PCI PF and VF port function. Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
1094795ce4
commit
330077d14d
@ -114,6 +114,7 @@ static const struct devlink_ops mlx5_devlink_ops = {
|
||||
.eswitch_encap_mode_set = mlx5_devlink_eswitch_encap_mode_set,
|
||||
.eswitch_encap_mode_get = mlx5_devlink_eswitch_encap_mode_get,
|
||||
.port_function_hw_addr_get = mlx5_devlink_port_function_hw_addr_get,
|
||||
.port_function_hw_addr_set = mlx5_devlink_port_function_hw_addr_set,
|
||||
#endif
|
||||
.flash_update = mlx5_devlink_flash_update,
|
||||
.info_get = mlx5_devlink_info_get,
|
||||
|
@ -1898,6 +1898,42 @@ int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_devlink_port_function_hw_addr_set(struct devlink *devlink,
|
||||
struct devlink_port *port,
|
||||
const u8 *hw_addr, int hw_addr_len,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct mlx5_eswitch *esw;
|
||||
struct mlx5_vport *vport;
|
||||
int err = -EOPNOTSUPP;
|
||||
u16 vport_num;
|
||||
|
||||
esw = mlx5_devlink_eswitch_get(devlink);
|
||||
if (IS_ERR(esw)) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Eswitch doesn't support set hw_addr");
|
||||
return PTR_ERR(esw);
|
||||
}
|
||||
|
||||
vport_num = mlx5_esw_devlink_port_index_to_vport_num(port->index);
|
||||
if (!is_port_function_supported(esw, vport_num)) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Port doesn't support set hw_addr");
|
||||
return -EINVAL;
|
||||
}
|
||||
vport = mlx5_eswitch_get_vport(esw, vport_num);
|
||||
if (IS_ERR(vport)) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Invalid port");
|
||||
return PTR_ERR(vport);
|
||||
}
|
||||
|
||||
mutex_lock(&esw->state_lock);
|
||||
if (vport->enabled)
|
||||
err = mlx5_esw_set_vport_mac_locked(esw, vport, hw_addr);
|
||||
else
|
||||
NL_SET_ERR_MSG_MOD(extack, "Eswitch vport is disabled");
|
||||
mutex_unlock(&esw->state_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
|
||||
u16 vport, int link_state)
|
||||
{
|
||||
|
@ -454,6 +454,10 @@ int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
|
||||
struct devlink_port *port,
|
||||
u8 *hw_addr, int *hw_addr_len,
|
||||
struct netlink_ext_ack *extack);
|
||||
int mlx5_devlink_port_function_hw_addr_set(struct devlink *devlink,
|
||||
struct devlink_port *port,
|
||||
const u8 *hw_addr, int hw_addr_len,
|
||||
struct netlink_ext_ack *extack);
|
||||
|
||||
void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user