mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 15:29:16 +00:00
devlink: pass devlink_port pointer to ops->port_del() instead of index
Historically there was a reason why port_dev() along with for example port_split() did get port_index instead of the devlink_port pointer. With the locking changes that were done which ensured devlink instance mutex is hold for every command, the port ops could get devlink_port pointer directly. Change the forgotten port_dev() op to be as others and pass devlink_port pointer instead of port_index. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
1bb1b57898
commit
9277649c66
@ -376,7 +376,8 @@ static void mlx5_sf_dealloc(struct mlx5_sf_table *table, struct mlx5_sf *sf)
|
||||
}
|
||||
}
|
||||
|
||||
int mlx5_devlink_sf_port_del(struct devlink *devlink, unsigned int port_index,
|
||||
int mlx5_devlink_sf_port_del(struct devlink *devlink,
|
||||
struct devlink_port *dl_port,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct mlx5_core_dev *dev = devlink_priv(devlink);
|
||||
@ -391,7 +392,7 @@ int mlx5_devlink_sf_port_del(struct devlink *devlink, unsigned int port_index,
|
||||
"Port del is only supported in eswitch switchdev mode or SF ports are disabled.");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
sf = mlx5_sf_lookup_by_index(table, port_index);
|
||||
sf = mlx5_sf_lookup_by_index(table, dl_port->index);
|
||||
if (!sf) {
|
||||
err = -ENODEV;
|
||||
goto sf_err;
|
||||
|
@ -21,7 +21,8 @@ void mlx5_sf_table_cleanup(struct mlx5_core_dev *dev);
|
||||
int mlx5_devlink_sf_port_new(struct devlink *devlink,
|
||||
const struct devlink_port_new_attrs *add_attr,
|
||||
struct netlink_ext_ack *extack);
|
||||
int mlx5_devlink_sf_port_del(struct devlink *devlink, unsigned int port_index,
|
||||
int mlx5_devlink_sf_port_del(struct devlink *devlink,
|
||||
struct devlink_port *dl_port,
|
||||
struct netlink_ext_ack *extack);
|
||||
int mlx5_devlink_sf_port_fn_state_get(struct devlink_port *dl_port,
|
||||
enum devlink_port_fn_state *state,
|
||||
|
@ -1516,7 +1516,7 @@ struct devlink_ops {
|
||||
/**
|
||||
* port_del() - Delete a port function
|
||||
* @devlink: Devlink instance
|
||||
* @port_index: port function index to delete
|
||||
* @port: The devlink port
|
||||
* @extack: extack for reporting error messages
|
||||
*
|
||||
* Devlink core will call this device driver function upon user request
|
||||
@ -1528,7 +1528,7 @@ struct devlink_ops {
|
||||
*
|
||||
* Return: 0 on success, negative value otherwise.
|
||||
*/
|
||||
int (*port_del)(struct devlink *devlink, unsigned int port_index,
|
||||
int (*port_del)(struct devlink *devlink, struct devlink_port *port,
|
||||
struct netlink_ext_ack *extack);
|
||||
/**
|
||||
* port_fn_state_get() - Get the state of a port function
|
||||
|
@ -1396,20 +1396,14 @@ static int devlink_nl_cmd_port_new_doit(struct sk_buff *skb,
|
||||
static int devlink_nl_cmd_port_del_doit(struct sk_buff *skb,
|
||||
struct genl_info *info)
|
||||
{
|
||||
struct devlink_port *devlink_port = info->user_ptr[1];
|
||||
struct netlink_ext_ack *extack = info->extack;
|
||||
struct devlink *devlink = info->user_ptr[0];
|
||||
unsigned int port_index;
|
||||
|
||||
if (!devlink->ops->port_del)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (GENL_REQ_ATTR_CHECK(info, DEVLINK_ATTR_PORT_INDEX)) {
|
||||
NL_SET_ERR_MSG(extack, "Port index is not specified");
|
||||
return -EINVAL;
|
||||
}
|
||||
port_index = nla_get_u32(info->attrs[DEVLINK_ATTR_PORT_INDEX]);
|
||||
|
||||
return devlink->ops->port_del(devlink, port_index, extack);
|
||||
return devlink->ops->port_del(devlink, devlink_port, extack);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -6341,6 +6335,7 @@ const struct genl_small_ops devlink_nl_ops[56] = {
|
||||
.cmd = DEVLINK_CMD_PORT_DEL,
|
||||
.doit = devlink_nl_cmd_port_del_doit,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
|
||||
},
|
||||
{
|
||||
.cmd = DEVLINK_CMD_LINECARD_GET,
|
||||
|
Loading…
x
Reference in New Issue
Block a user