diff options
author | Jiri Pirko <jiri@nvidia.com> | 2023-05-23 14:38:01 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-05-24 10:34:26 +0100 |
commit | 9277649c66fe7cb0e2f8adb09621556bcfb052c7 (patch) | |
tree | 60b58207fb829af1dc46d492864ffea60464aab5 | |
parent | 1bb1b57898504da4e10d48b901556278e161c7fd (diff) |
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>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h | 3 | ||||
-rw-r--r-- | include/net/devlink.h | 4 | ||||
-rw-r--r-- | net/devlink/leftover.c | 11 |
4 files changed, 10 insertions, 13 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c index de15b9c85e1b..c7d4691cb65a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c @@ -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; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h b/drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h index 1f7d8cbd72e8..c5430b8dcdf6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h @@ -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, diff --git a/include/net/devlink.h b/include/net/devlink.h index 24a48f3d4c35..1bd56c8d6f3c 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -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 diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c index cb60e42b2761..0410137a4a31 100644 --- a/net/devlink/leftover.c +++ b/net/devlink/leftover.c @@ -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, |