Commit 9c54873b authored by Vasundhara Volam's avatar Vasundhara Volam Committed by David S. Miller

devlink: Add port param set command

Add port param set command to set the value for a parameter.
Value can be set to any of the supported configuration modes.

v7->v8: Append "Acked-by: Jiri Pirko <jiri@mellanox.com>"

Cc: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarVasundhara Volam <vasundhara-v.volam@broadcom.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f4601dee
...@@ -90,6 +90,7 @@ enum devlink_command { ...@@ -90,6 +90,7 @@ enum devlink_command {
DEVLINK_CMD_REGION_READ, DEVLINK_CMD_REGION_READ,
DEVLINK_CMD_PORT_PARAM_GET, /* can dump */ DEVLINK_CMD_PORT_PARAM_GET, /* can dump */
DEVLINK_CMD_PORT_PARAM_SET,
/* add new commands above here */ /* add new commands above here */
__DEVLINK_CMD_MAX, __DEVLINK_CMD_MAX,
......
...@@ -3096,10 +3096,11 @@ static int devlink_nl_cmd_param_get_doit(struct sk_buff *skb, ...@@ -3096,10 +3096,11 @@ static int devlink_nl_cmd_param_get_doit(struct sk_buff *skb,
return genlmsg_reply(msg, info); return genlmsg_reply(msg, info);
} }
static int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,
struct genl_info *info) struct list_head *param_list,
struct genl_info *info,
enum devlink_command cmd)
{ {
struct devlink *devlink = info->user_ptr[0];
enum devlink_param_type param_type; enum devlink_param_type param_type;
struct devlink_param_gset_ctx ctx; struct devlink_param_gset_ctx ctx;
enum devlink_param_cmode cmode; enum devlink_param_cmode cmode;
...@@ -3108,7 +3109,7 @@ static int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, ...@@ -3108,7 +3109,7 @@ static int devlink_nl_cmd_param_set_doit(struct sk_buff *skb,
union devlink_param_value value; union devlink_param_value value;
int err = 0; int err = 0;
param_item = devlink_param_get_from_info(&devlink->param_list, info); param_item = devlink_param_get_from_info(param_list, info);
if (!param_item) if (!param_item)
return -EINVAL; return -EINVAL;
param = param_item->param; param = param_item->param;
...@@ -3148,10 +3149,19 @@ static int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, ...@@ -3148,10 +3149,19 @@ static int devlink_nl_cmd_param_set_doit(struct sk_buff *skb,
return err; return err;
} }
devlink_param_notify(devlink, param_item, DEVLINK_CMD_PARAM_NEW); devlink_param_notify(devlink, param_item, cmd);
return 0; return 0;
} }
static int devlink_nl_cmd_param_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
return __devlink_nl_cmd_param_set_doit(devlink, &devlink->param_list,
info, DEVLINK_CMD_PARAM_NEW);
}
static int devlink_param_register_one(struct devlink *devlink, static int devlink_param_register_one(struct devlink *devlink,
struct list_head *param_list, struct list_head *param_list,
const struct devlink_param *param) const struct devlink_param *param)
...@@ -3263,6 +3273,16 @@ static int devlink_nl_cmd_port_param_get_doit(struct sk_buff *skb, ...@@ -3263,6 +3273,16 @@ static int devlink_nl_cmd_port_param_get_doit(struct sk_buff *skb,
return genlmsg_reply(msg, info); return genlmsg_reply(msg, info);
} }
static int devlink_nl_cmd_port_param_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[0];
return __devlink_nl_cmd_param_set_doit(devlink_port->devlink,
&devlink_port->param_list,
info, 0);
}
static int devlink_nl_region_snapshot_id_put(struct sk_buff *msg, static int devlink_nl_region_snapshot_id_put(struct sk_buff *msg,
struct devlink *devlink, struct devlink *devlink,
struct devlink_snapshot *snapshot) struct devlink_snapshot *snapshot)
...@@ -3908,6 +3928,13 @@ static const struct genl_ops devlink_nl_ops[] = { ...@@ -3908,6 +3928,13 @@ static const struct genl_ops devlink_nl_ops[] = {
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT, .internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
/* can be retrieved by unprivileged users */ /* can be retrieved by unprivileged users */
}, },
{
.cmd = DEVLINK_CMD_PORT_PARAM_SET,
.doit = devlink_nl_cmd_port_param_set_doit,
.policy = devlink_nl_policy,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{ {
.cmd = DEVLINK_CMD_REGION_GET, .cmd = DEVLINK_CMD_REGION_GET,
.doit = devlink_nl_cmd_region_get_doit, .doit = devlink_nl_cmd_region_get_doit,
......
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