devlink: small port_new/del() cleanup
Subsystems (4)
Jiri Pirko
maintainercover devlink: small port_new/del() cleanup
From: Jiri Pirko <[email protected]>
This patchset cleans up couple of leftovers after recent devlink locking changes. Previously, both port_new/dev() commands were called without holding instance lock. Currently all devlink commands are called with instance lock held.
The first patch just removes redundant port notification. The second one removes couple of outdated comments.
The last patch changes port_dev() to have devlink_port pointer as an arg instead of port_index, which makes it similar to the rest of port related ops.
Jiri Pirko (3):
devlink: remove duplicate port notification
devlink: remove no longer true locking comment from port_new/del()
devlink: pass devlink_port pointer to ops->port_del() instead of index
.../ethernet/mellanox/mlx5/core/sf/devlink.c | 14 ++--- .../net/ethernet/mellanox/mlx5/core/sf/sf.h | 6 +- include/net/devlink.h | 12 +--- net/devlink/leftover.c | 56 ++----------------- 4 files changed, 16 insertions(+), 72 deletions(-)
Signature · 1 line
2.39.2
Jiri Pirko
maintainerPATCH 1/3 devlink: remove duplicate port notification
From: Jiri Pirko <[email protected]>
The notification about created port is send from devl_port_register() function called from ops->port_new(). No need to send it again here, so remove the call and the helper function.
--- .../ethernet/mellanox/mlx5/core/sf/devlink.c | 9 ++-- .../net/ethernet/mellanox/mlx5/core/sf/sf.h | 3 +- include/net/devlink.h | 4 +- net/devlink/leftover.c | 45 +------------------ 4 files changed, 6 insertions(+), 55 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c +3 -6
@@ -282,8 +282,7 @@ int mlx5_devlink_sf_port_fn_state_set(struct devlink_port *dl_port,static int mlx5_sf_add (struct mlx5_core_dev *dev,struct mlx5_sf_table *table,const struct devlink_port_new_attrs *new_attr, -struct netlink_ext_ack *extack, -unsigned int *new_port_index) +struct netlink_ext_ack *extack) {struct mlx5_eswitch *esw = dev->priv.eswitch;struct mlx5_sf *sf;
@@ -297,7 +296,6 @@ static int mlx5_sf_add(struct mlx5_core_dev *dev, struct mlx5_sf_table *table, new_attr->controller, new_attr->sfnum);if (err) goto esw_err; - *new_port_index = sf->port_index;trace_mlx5_sf_add (dev, sf->port_index, sf->controller, sf->hw_fn_id, new_attr->sfnum);return 0 ;
@@ -338,8 +336,7 @@ mlx5_sf_new_check_attr(struct mlx5_core_dev *dev, const struct devlink_port_new_int mlx5_devlink_sf_port_new (struct devlink *devlink,const struct devlink_port_new_attrs *new_attr, -struct netlink_ext_ack *extack, -unsigned int *new_port_index) +struct netlink_ext_ack *extack) {struct mlx5_core_dev *dev =devlink_priv (devlink);struct mlx5_sf_table *table;
@@ -355,7 +352,7 @@ int mlx5_devlink_sf_port_new(struct devlink *devlink, "Port add is only supported in eswitch switchdev mode or SF ports are disabled.");return -EOPNOTSUPP ; } - err =mlx5_sf_add (dev, table, new_attr, extack, new_port_index); + err =mlx5_sf_add (dev, table, new_attr, extack);mlx5_sf_table_put (table);return err; }
drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h +1 -2
@@ -20,8 +20,7 @@ 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, -unsigned int *new_port_index); +struct netlink_ext_ack *extack);int mlx5_devlink_sf_port_del (struct devlink *devlink,unsigned int port_index,struct netlink_ext_ack *extack); int mlx5_devlink_sf_port_fn_state_get(struct devlink_port *dl_port,
include/net/devlink.h +1 -3
@@ -1500,7 +1500,6 @@ struct devlink_ops {* @devlink: Devlink instance * @attrs: attributes of the new port * @extack: extack for reporting error messages -* @new_port_index: index of the new port * * Devlink core will call this device driver function upon user request * to create a new port function of a specified flavor and optional
@@ -1515,8 +1514,7 @@ struct devlink_ops {*/ int (*port_new)(struct devlink *devlink,const struct devlink_port_new_attrs *attrs, -struct netlink_ext_ack *extack, -unsigned int *new_port_index); +struct netlink_ext_ack *extack);/** * port_del() - Delete a port function * @devlink: Devlink instance
net/devlink/leftover.c +1 -44
63 lines not on this page · raw message
Signature · 1 line
2.39.2
Re: [patch net-next 1/3] devlink: remove duplicate port notification
Quoted 7 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
The notification about created port is send from
devl_port_register()function called fromops->port_new(). No need to send it again here, so remove the call and the helper function.Signed-off-by Jiri Pirko <[email protected]>
Jiri Pirko
maintainerPATCH 2/3 devlink: remove no longer true locking comment from port_new/del()
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
All commands are called holding instance lock. Remove the outdated comment that says otherwise.
--- include/net/devlink.h | 4 ---- 1 file changed, 4 deletions(-)
include/net/devlink.h +0 -4
@@ -1506,8 +1506,6 @@ struct devlink_ops {* attributes * * Notes: -* - Called without devlink instance lock being held. Drivers must -* implement own means of synchronization * - On success, drivers must register a port with devlink core * * Return: 0 on success, negative value otherwise.
@@ -1525,8 +1523,6 @@ struct devlink_ops {* to delete a previously created port function * * Notes: -* - Called without devlink instance lock being held. Drivers must -* implement own means of synchronization * - On success, drivers must unregister the corresponding devlink * port *
Signature · 1 line
2.39.2
Re: [patch net-next 2/3] devlink: remove no longer true locking comment from port_new/del()
Quoted 6 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
All commands are called holding instance lock. Remove the outdated comment that says otherwise.
Signed-off-by Jiri Pirko <[email protected]>
Jiri Pirko
maintainerPATCH 3/3 devlink: pass devlink_port pointer to ops->port_del() instead of index
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c | 5 +++-- drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h | 3 ++- include/net/devlink.h | 4 ++-- net/devlink/leftover.c | 11 +++-------- 4 files changed, 10 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c +3 -2
@@ -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;
drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h +2 -1
@@ -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,
include/net/devlink.h +2 -2
@@ -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
net/devlink/leftover.c +3 -8
@@ -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,
Signature · 1 line
2.39.2
Re: [patch net-next 3/3] devlink: pass devlink_port pointer to ops->port_del() instead of index
Quoted 10 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Historically there was a reason why
port_dev()along with for exampleport_split()did getport_indexinstead of thedevlink_portpointer. With the locking changes that were done which ensured devlink instance mutex is hold for every command, the port ops could getdevlink_portpointer directly. Change the forgottenport_dev()op to be as others and passdevlink_portpointer instead ofport_index.Signed-off-by Jiri Pirko <[email protected]>
Quoted 10 lines · On Tue, 23 May 2023 14:37:58 +0200 Jiri Pirko wrote:
This patchset cleans up couple of leftovers after recent devlink locking changes. Previously, both port_new/dev() commands were called without holding instance lock. Currently all devlink commands are called with instance lock held.
The first patch just removes redundant port notification. The second one removes couple of outdated comments.
The last patch changesport_dev()to havedevlink_portpointer as an arg instead ofport_index, which makes it similar to the rest of port related ops.
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 8 lines · On Tue, 23 May 2023 14:37:58 +0200 you wrote:
From: Jiri Pirko <[email protected]>
This patchset cleans up couple of leftovers after recent devlink locking changes. Previously, both port_new/dev() commands were called without holding instance lock. Currently all devlink commands are called with instance lock held.
[...]
Here is the summary with links:
- [net-next,1/3] devlink: remove duplicate port notification
https://git.kernel.org/netdev/net-next/c/c496daeb8630 - [net-next,2/3] devlink: remove no longer true locking comment from port_new/del() https://git.kernel.org/netdev/net-next/c/1bb1b5789850 - [net-next,3/3] devlink: pass devlink_port pointer to ops->port_del() instead of index https://git.kernel.org/netdev/net-next/c/9277649c66fe
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html