Commit 5ff9424e authored by Jiri Pirko's avatar Jiri Pirko Committed by Jakub Kicinski

devlink: bring port new reply back

In the offending fixes commit I mistakenly removed the reply message of
the port new command. I was under impression it is a new port
notification, partly due to the "notify" in the name of the helper
function. Bring the code sending reply with new port message back, this
time putting it directly to devlink_nl_cmd_port_new_doit()

Fixes: c496daeb ("devlink: remove duplicate port notification")
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230531142025.2605001-1-jiri@resnulli.usSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a03a91bd
...@@ -282,7 +282,8 @@ int mlx5_devlink_sf_port_fn_state_set(struct devlink_port *dl_port, ...@@ -282,7 +282,8 @@ 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, static int mlx5_sf_add(struct mlx5_core_dev *dev, struct mlx5_sf_table *table,
const struct devlink_port_new_attrs *new_attr, const struct devlink_port_new_attrs *new_attr,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack,
struct devlink_port **dl_port)
{ {
struct mlx5_eswitch *esw = dev->priv.eswitch; struct mlx5_eswitch *esw = dev->priv.eswitch;
struct mlx5_sf *sf; struct mlx5_sf *sf;
...@@ -296,6 +297,7 @@ static int mlx5_sf_add(struct mlx5_core_dev *dev, struct mlx5_sf_table *table, ...@@ -296,6 +297,7 @@ static int mlx5_sf_add(struct mlx5_core_dev *dev, struct mlx5_sf_table *table,
new_attr->controller, new_attr->sfnum); new_attr->controller, new_attr->sfnum);
if (err) if (err)
goto esw_err; goto esw_err;
*dl_port = &sf->dl_port;
trace_mlx5_sf_add(dev, sf->port_index, sf->controller, sf->hw_fn_id, new_attr->sfnum); trace_mlx5_sf_add(dev, sf->port_index, sf->controller, sf->hw_fn_id, new_attr->sfnum);
return 0; return 0;
...@@ -336,7 +338,8 @@ mlx5_sf_new_check_attr(struct mlx5_core_dev *dev, const struct devlink_port_new_ ...@@ -336,7 +338,8 @@ mlx5_sf_new_check_attr(struct mlx5_core_dev *dev, const struct devlink_port_new_
int mlx5_devlink_sf_port_new(struct devlink *devlink, int mlx5_devlink_sf_port_new(struct devlink *devlink,
const struct devlink_port_new_attrs *new_attr, const struct devlink_port_new_attrs *new_attr,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack,
struct devlink_port **dl_port)
{ {
struct mlx5_core_dev *dev = devlink_priv(devlink); struct mlx5_core_dev *dev = devlink_priv(devlink);
struct mlx5_sf_table *table; struct mlx5_sf_table *table;
...@@ -352,7 +355,7 @@ int mlx5_devlink_sf_port_new(struct devlink *devlink, ...@@ -352,7 +355,7 @@ int mlx5_devlink_sf_port_new(struct devlink *devlink,
"Port add is only supported in eswitch switchdev mode or SF ports are disabled."); "Port add is only supported in eswitch switchdev mode or SF ports are disabled.");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
err = mlx5_sf_add(dev, table, new_attr, extack); err = mlx5_sf_add(dev, table, new_attr, extack, dl_port);
mlx5_sf_table_put(table); mlx5_sf_table_put(table);
return err; return err;
} }
......
...@@ -20,7 +20,8 @@ void mlx5_sf_table_cleanup(struct mlx5_core_dev *dev); ...@@ -20,7 +20,8 @@ void mlx5_sf_table_cleanup(struct mlx5_core_dev *dev);
int mlx5_devlink_sf_port_new(struct devlink *devlink, int mlx5_devlink_sf_port_new(struct devlink *devlink,
const struct devlink_port_new_attrs *add_attr, const struct devlink_port_new_attrs *add_attr,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack,
struct devlink_port **dl_port);
int mlx5_devlink_sf_port_del(struct devlink *devlink, int mlx5_devlink_sf_port_del(struct devlink *devlink,
struct devlink_port *dl_port, struct devlink_port *dl_port,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
......
...@@ -1434,6 +1434,7 @@ struct devlink_ops { ...@@ -1434,6 +1434,7 @@ struct devlink_ops {
* @devlink: Devlink instance * @devlink: Devlink instance
* @attrs: attributes of the new port * @attrs: attributes of the new port
* @extack: extack for reporting error messages * @extack: extack for reporting error messages
* @devlink_port: pointer to store new devlink port pointer
* *
* Devlink core will call this device driver function upon user request * Devlink core will call this device driver function upon user request
* to create a new port function of a specified flavor and optional * to create a new port function of a specified flavor and optional
...@@ -1446,7 +1447,8 @@ struct devlink_ops { ...@@ -1446,7 +1447,8 @@ struct devlink_ops {
*/ */
int (*port_new)(struct devlink *devlink, int (*port_new)(struct devlink *devlink,
const struct devlink_port_new_attrs *attrs, const struct devlink_port_new_attrs *attrs,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack,
struct devlink_port **devlink_port);
/** /**
* Rate control callbacks. * Rate control callbacks.
......
...@@ -1347,6 +1347,9 @@ static int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, ...@@ -1347,6 +1347,9 @@ static int devlink_nl_cmd_port_new_doit(struct sk_buff *skb,
struct netlink_ext_ack *extack = info->extack; struct netlink_ext_ack *extack = info->extack;
struct devlink_port_new_attrs new_attrs = {}; struct devlink_port_new_attrs new_attrs = {};
struct devlink *devlink = info->user_ptr[0]; struct devlink *devlink = info->user_ptr[0];
struct devlink_port *devlink_port;
struct sk_buff *msg;
int err;
if (!devlink->ops->port_new) if (!devlink->ops->port_new)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1377,7 +1380,30 @@ static int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, ...@@ -1377,7 +1380,30 @@ static int devlink_nl_cmd_port_new_doit(struct sk_buff *skb,
new_attrs.sfnum_valid = true; new_attrs.sfnum_valid = true;
} }
return devlink->ops->port_new(devlink, &new_attrs, extack); err = devlink->ops->port_new(devlink, &new_attrs,
extack, &devlink_port);
if (err)
return err;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) {
err = -ENOMEM;
goto err_out_port_del;
}
err = devlink_nl_port_fill(msg, devlink_port, DEVLINK_CMD_NEW,
info->snd_portid, info->snd_seq, 0, NULL);
if (WARN_ON_ONCE(err))
goto err_out_msg_free;
err = genlmsg_reply(msg, info);
if (err)
goto err_out_port_del;
return 0;
err_out_msg_free:
nlmsg_free(msg);
err_out_port_del:
devlink_port->ops->port_del(devlink, devlink_port, NULL);
return err;
} }
static int devlink_nl_cmd_port_del_doit(struct sk_buff *skb, static int devlink_nl_cmd_port_del_doit(struct sk_buff *skb,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment