All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: stephen@networkplumber.org, dsahern@gmail.com,
	Jiri Pirko <jiri@nvidia.com>,
	jiri@resnulli.us
Cc: netdev@vger.kernel.org, Saeed Mahameed <saeedm@nvidia.com>
Subject: [PATCH iproute2 05/10] devlink: rename param_ctx to dl_param
Date: Thu, 27 Feb 2025 18:18:32 -0800	[thread overview]
Message-ID: <20250228021837.880041-6-saeed@kernel.org> (raw)
In-Reply-To: <20250228021837.880041-1-saeed@kernel.org>

From: Saeed Mahameed <saeedm@nvidia.com>

dl_param structure will be used in down stream patches to store and help
process devlink param values that are read from user input and kernel.

Rename it to reflect a more suitable name for it's purpose.

Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 devlink/devlink.c | 62 +++++++++++++++++++++++------------------------
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 09afc300..b41b06f9 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -3627,7 +3627,7 @@ static int cmd_dev_param_show_cb(const struct nlmsghdr *nlh, void *data)
 	return MNL_CB_OK;
 }
 
-struct param_ctx {
+struct dl_param {
 	struct dl *dl;
 	enum devlink_dyn_attr_type type;
 	bool cmode_found;
@@ -3648,8 +3648,8 @@ static int cmd_param_set_cb(const struct nlmsghdr *nlh, void *data)
 	struct nlattr *param_value_attr;
 	enum devlink_dyn_attr_type type;
 	enum devlink_param_cmode cmode;
-	struct param_ctx *ctx = data;
-	struct dl *dl = ctx->dl;
+	struct dl_param *param = data;
+	struct dl *dl = param->dl;
 	int err;
 
 	mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
@@ -3686,23 +3686,23 @@ static int cmd_param_set_cb(const struct nlmsghdr *nlh, void *data)
 
 		cmode = mnl_attr_get_u8(nla_value[DEVLINK_ATTR_PARAM_VALUE_CMODE]);
 		if (cmode == dl->opts.cmode) {
-			ctx->cmode_found = true;
+			param->cmode_found = true;
 			val_attr = nla_value[DEVLINK_ATTR_PARAM_VALUE_DATA];
 			switch (type) {
 			case DEVLINK_DYN_ATTR_TYPE_U8:
-				ctx->value.vu8 = mnl_attr_get_u8(val_attr);
+				param->value.vu8 = mnl_attr_get_u8(val_attr);
 				break;
 			case DEVLINK_DYN_ATTR_TYPE_U16:
-				ctx->value.vu16 = mnl_attr_get_u16(val_attr);
+				param->value.vu16 = mnl_attr_get_u16(val_attr);
 				break;
 			case DEVLINK_DYN_ATTR_TYPE_U32:
-				ctx->value.vu32 = mnl_attr_get_u32(val_attr);
+				param->value.vu32 = mnl_attr_get_u32(val_attr);
 				break;
 			case DEVLINK_DYN_ATTR_TYPE_STRING:
-				ctx->value.vstr = mnl_attr_get_str(val_attr);
+				param->value.vstr = mnl_attr_get_str(val_attr);
 				break;
 			case DEVLINK_DYN_ATTR_TYPE_FLAG:
-				ctx->value.vbool = val_attr ? true : false;
+				param->value.vbool = val_attr ? true : false;
 				break;
 			default:
 				break;
@@ -3710,13 +3710,13 @@ static int cmd_param_set_cb(const struct nlmsghdr *nlh, void *data)
 			break;
 		}
 	}
-	ctx->type = type;
+	param->type = type;
 	return MNL_CB_OK;
 }
 
 static int cmd_dev_param_set(struct dl *dl)
 {
-	struct param_ctx ctx = {};
+	struct dl_param kparam = {}; /* kernel param */
 	struct nlmsghdr *nlh;
 	bool conv_exists;
 	uint32_t val_u32 = 0;
@@ -3737,11 +3737,11 @@ static int cmd_dev_param_set(struct dl *dl)
 			       NLM_F_REQUEST | NLM_F_ACK);
 	dl_opts_put(nlh, dl);
 
-	ctx.dl = dl;
-	err = mnlu_gen_socket_sndrcv(&dl->nlg, nlh, cmd_param_set_cb, &ctx);
+	kparam.dl = dl;
+	err = mnlu_gen_socket_sndrcv(&dl->nlg, nlh, cmd_param_set_cb, &kparam);
 	if (err)
 		return err;
-	if (!ctx.cmode_found) {
+	if (!kparam.cmode_found) {
 		pr_err("Configuration mode not supported\n");
 		return -ENOTSUP;
 	}
@@ -3753,8 +3753,8 @@ static int cmd_dev_param_set(struct dl *dl)
 	conv_exists = param_val_conv_exists(param_val_conv, PARAM_VAL_CONV_LEN,
 					    dl->opts.param_name);
 
-	mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_TYPE, ctx.type);
-	switch (ctx.type) {
+	mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_TYPE, kparam.type);
+	switch (kparam.type) {
 	case DEVLINK_DYN_ATTR_TYPE_U8:
 		if (conv_exists) {
 			err = param_val_conv_uint_get(param_val_conv,
@@ -3768,7 +3768,7 @@ static int cmd_dev_param_set(struct dl *dl)
 		}
 		if (err)
 			goto err_param_value_parse;
-		if (val_u8 == ctx.value.vu8)
+		if (val_u8 == kparam.value.vu8)
 			return 0;
 		mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA, val_u8);
 		break;
@@ -3785,7 +3785,7 @@ static int cmd_dev_param_set(struct dl *dl)
 		}
 		if (err)
 			goto err_param_value_parse;
-		if (val_u16 == ctx.value.vu16)
+		if (val_u16 == kparam.value.vu16)
 			return 0;
 		mnl_attr_put_u16(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA, val_u16);
 		break;
@@ -3800,7 +3800,7 @@ static int cmd_dev_param_set(struct dl *dl)
 			err = get_u32(&val_u32, dl->opts.param_value, 10);
 		if (err)
 			goto err_param_value_parse;
-		if (val_u32 == ctx.value.vu32)
+		if (val_u32 == kparam.value.vu32)
 			return 0;
 		mnl_attr_put_u32(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA, val_u32);
 		break;
@@ -3808,7 +3808,7 @@ static int cmd_dev_param_set(struct dl *dl)
 		err = strtobool(dl->opts.param_value, &val_bool);
 		if (err)
 			goto err_param_value_parse;
-		if (val_bool == ctx.value.vbool)
+		if (val_bool == kparam.value.vbool)
 			return 0;
 		if (val_bool)
 			mnl_attr_put(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA,
@@ -3817,7 +3817,7 @@ static int cmd_dev_param_set(struct dl *dl)
 	case DEVLINK_DYN_ATTR_TYPE_STRING:
 		mnl_attr_put_strz(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA,
 				  dl->opts.param_value);
-		if (!strcmp(dl->opts.param_value, ctx.value.vstr))
+		if (!strcmp(dl->opts.param_value, kparam.value.vstr))
 			return 0;
 		break;
 	default:
@@ -5224,7 +5224,7 @@ static int cmd_port_function_set(struct dl *dl)
 
 static int cmd_port_param_set(struct dl *dl)
 {
-	struct param_ctx ctx = {};
+	struct dl_param kparam = {}; /* kernel param */
 	struct nlmsghdr *nlh;
 	bool conv_exists;
 	uint32_t val_u32 = 0;
@@ -5245,8 +5245,8 @@ static int cmd_port_param_set(struct dl *dl)
 					  NLM_F_REQUEST | NLM_F_ACK);
 	dl_opts_put(nlh, dl);
 
-	ctx.dl = dl;
-	err = mnlu_gen_socket_sndrcv(&dl->nlg, nlh, cmd_param_set_cb, &ctx);
+	kparam.dl = dl;
+	err = mnlu_gen_socket_sndrcv(&dl->nlg, nlh, cmd_param_set_cb, &kparam);
 	if (err)
 		return err;
 
@@ -5257,8 +5257,8 @@ static int cmd_port_param_set(struct dl *dl)
 	conv_exists = param_val_conv_exists(param_val_conv, PARAM_VAL_CONV_LEN,
 					    dl->opts.param_name);
 
-	mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_TYPE, ctx.type);
-	switch (ctx.type) {
+	mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_TYPE, kparam.type);
+	switch (kparam.type) {
 	case DEVLINK_DYN_ATTR_TYPE_U8:
 		if (conv_exists) {
 			err = param_val_conv_uint_get(param_val_conv,
@@ -5272,7 +5272,7 @@ static int cmd_port_param_set(struct dl *dl)
 		}
 		if (err)
 			goto err_param_value_parse;
-		if (val_u8 == ctx.value.vu8)
+		if (val_u8 == kparam.value.vu8)
 			return 0;
 		mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA, val_u8);
 		break;
@@ -5289,7 +5289,7 @@ static int cmd_port_param_set(struct dl *dl)
 		}
 		if (err)
 			goto err_param_value_parse;
-		if (val_u16 == ctx.value.vu16)
+		if (val_u16 == kparam.value.vu16)
 			return 0;
 		mnl_attr_put_u16(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA, val_u16);
 		break;
@@ -5304,7 +5304,7 @@ static int cmd_port_param_set(struct dl *dl)
 			err = get_u32(&val_u32, dl->opts.param_value, 10);
 		if (err)
 			goto err_param_value_parse;
-		if (val_u32 == ctx.value.vu32)
+		if (val_u32 == kparam.value.vu32)
 			return 0;
 		mnl_attr_put_u32(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA, val_u32);
 		break;
@@ -5312,7 +5312,7 @@ static int cmd_port_param_set(struct dl *dl)
 		err = strtobool(dl->opts.param_value, &val_bool);
 		if (err)
 			goto err_param_value_parse;
-		if (val_bool == ctx.value.vbool)
+		if (val_bool == kparam.value.vbool)
 			return 0;
 		if (val_bool)
 			mnl_attr_put(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA,
@@ -5321,7 +5321,7 @@ static int cmd_port_param_set(struct dl *dl)
 	case DEVLINK_DYN_ATTR_TYPE_STRING:
 		mnl_attr_put_strz(nlh, DEVLINK_ATTR_PARAM_VALUE_DATA,
 				  dl->opts.param_value);
-		if (!strcmp(dl->opts.param_value, ctx.value.vstr))
+		if (!strcmp(dl->opts.param_value, kparam.value.vstr))
 			return 0;
 		break;
 	default:
-- 
2.48.1


  parent reply	other threads:[~2025-02-28  2:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28  2:18 [PATCH iproute2 00/10] devlink params nested multi-attribute values Saeed Mahameed
2025-02-28  2:18 ` [PATCH iproute2 01/10] update kernel headers Saeed Mahameed
2025-02-28  2:18 ` [PATCH iproute2 02/10] devlink: use dynamic attributes enum Saeed Mahameed
2025-02-28  2:18 ` [PATCH iproute2 03/10] devlink: param show: handle multi-attribute values Saeed Mahameed
2025-02-28  2:18 ` [PATCH iproute2 04/10] devlink: param set: reuse cmd_dev_param_set_cb for port params set Saeed Mahameed
2025-02-28  2:18 ` Saeed Mahameed [this message]
2025-02-28  2:18 ` [PATCH iproute2 06/10] devlink: helper function to read user param input into dl_param Saeed Mahameed
2025-02-28  2:18 ` [PATCH iproute2 07/10] devlink: helper function to compare dl_params Saeed Mahameed
2025-02-28  2:18 ` [PATCH iproute2 08/10] devlink: helper function to put param value mnl attributes from dl_params Saeed Mahameed
2025-02-28  2:18 ` [PATCH iproute2 09/10] devlink: helper function to parse param vlaue attributes into dl_param Saeed Mahameed
2025-02-28  2:18 ` [PATCH iproute2 10/10] devlink: params set: add support for nested attributes values Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250228021837.880041-6-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=jiri@nvidia.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.