Commit 9277649c authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller
Browse files

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: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1bb1b578
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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;
+2 −1
Original line number Diff line number Diff line
@@ -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,
+2 −2
Original line number Diff line number Diff line
@@ -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
+3 −8
Original line number Diff line number Diff line
@@ -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,