From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
Gal Pressman <gal@nvidia.com>,
Leon Romanovsky <leonro@nvidia.com>, Jiri Pirko <jiri@nvidia.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Simon Horman <horms@kernel.org>
Subject: [PATCH V7 net-next 05/11] devlink: pass struct devlink_port * as arg to devlink_nl_param_fill()
Date: Sat, 6 Sep 2025 18:29:47 -0700 [thread overview]
Message-ID: <20250907012953.301746-6-saeed@kernel.org> (raw)
In-Reply-To: <20250907012953.301746-1-saeed@kernel.org>
From: Jiri Pirko <jiri@nvidia.com>
As the follow-up patch will need to get struct devlink_port *, avoid
unnecessary lookup and instead of port_index pass the struct
devlink_port * directly.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
---
net/devlink/param.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/net/devlink/param.c b/net/devlink/param.c
index 33134940c266..76f95b8d1bdb 100644
--- a/net/devlink/param.c
+++ b/net/devlink/param.c
@@ -237,7 +237,7 @@ devlink_nl_param_value_fill_one(struct sk_buff *msg,
}
static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
- unsigned int port_index,
+ struct devlink_port *devlink_port,
struct devlink_param_item *param_item,
enum devlink_command cmd,
u32 portid, u32 seq, int flags)
@@ -283,7 +283,8 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
if (cmd == DEVLINK_CMD_PORT_PARAM_GET ||
cmd == DEVLINK_CMD_PORT_PARAM_NEW ||
cmd == DEVLINK_CMD_PORT_PARAM_DEL)
- if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX, port_index))
+ if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX,
+ devlink_port->index))
goto genlmsg_cancel;
param_attr = nla_nest_start_noflag(msg, DEVLINK_ATTR_PARAM);
@@ -325,7 +326,7 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
}
static void devlink_param_notify(struct devlink *devlink,
- unsigned int port_index,
+ struct devlink_port *devlink_port,
struct devlink_param_item *param_item,
enum devlink_command cmd)
{
@@ -346,7 +347,7 @@ static void devlink_param_notify(struct devlink *devlink,
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return;
- err = devlink_nl_param_fill(msg, devlink, port_index, param_item, cmd,
+ err = devlink_nl_param_fill(msg, devlink, devlink_port, param_item, cmd,
0, 0, 0);
if (err) {
nlmsg_free(msg);
@@ -363,7 +364,7 @@ static void devlink_params_notify(struct devlink *devlink,
unsigned long param_id;
xa_for_each(&devlink->params, param_id, param_item)
- devlink_param_notify(devlink, 0, param_item, cmd);
+ devlink_param_notify(devlink, NULL, param_item, cmd);
}
void devlink_params_notify_register(struct devlink *devlink)
@@ -387,7 +388,7 @@ static int devlink_nl_param_get_dump_one(struct sk_buff *msg,
int err = 0;
xa_for_each_start(&devlink->params, param_id, param_item, state->idx) {
- err = devlink_nl_param_fill(msg, devlink, 0, param_item,
+ err = devlink_nl_param_fill(msg, devlink, NULL, param_item,
DEVLINK_CMD_PARAM_GET,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, flags);
@@ -498,7 +499,7 @@ int devlink_nl_param_get_doit(struct sk_buff *skb,
if (!msg)
return -ENOMEM;
- err = devlink_nl_param_fill(msg, devlink, 0, param_item,
+ err = devlink_nl_param_fill(msg, devlink, NULL, param_item,
DEVLINK_CMD_PARAM_GET,
info->snd_portid, info->snd_seq, 0);
if (err) {
@@ -510,7 +511,7 @@ int devlink_nl_param_get_doit(struct sk_buff *skb,
}
static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,
- unsigned int port_index,
+ struct devlink_port *devlink_port,
struct xarray *params,
struct genl_info *info,
enum devlink_command cmd)
@@ -560,7 +561,7 @@ static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,
return err;
}
- devlink_param_notify(devlink, port_index, param_item, cmd);
+ devlink_param_notify(devlink, devlink_port, param_item, cmd);
return 0;
}
@@ -568,7 +569,7 @@ int devlink_nl_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, 0, &devlink->params,
+ return __devlink_nl_cmd_param_set_doit(devlink, NULL, &devlink->params,
info, DEVLINK_CMD_PARAM_NEW);
}
@@ -627,7 +628,7 @@ static int devlink_param_register(struct devlink *devlink,
if (err)
goto err_xa_insert;
- devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_NEW);
+ devlink_param_notify(devlink, NULL, param_item, DEVLINK_CMD_PARAM_NEW);
return 0;
err_xa_insert:
@@ -643,7 +644,7 @@ static void devlink_param_unregister(struct devlink *devlink,
param_item = devlink_param_find_by_id(&devlink->params, param->id);
if (WARN_ON(!param_item))
return;
- devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_DEL);
+ devlink_param_notify(devlink, NULL, param_item, DEVLINK_CMD_PARAM_DEL);
xa_erase(&devlink->params, param->id);
kfree(param_item);
}
@@ -804,7 +805,7 @@ void devl_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
param_item->driverinit_value = init_val;
param_item->driverinit_value_valid = true;
- devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_NEW);
+ devlink_param_notify(devlink, NULL, param_item, DEVLINK_CMD_PARAM_NEW);
}
EXPORT_SYMBOL_GPL(devl_param_driverinit_value_set);
@@ -843,6 +844,6 @@ void devl_param_value_changed(struct devlink *devlink, u32 param_id)
param_item = devlink_param_find_by_id(&devlink->params, param_id);
WARN_ON(!param_item);
- devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_NEW);
+ devlink_param_notify(devlink, NULL, param_item, DEVLINK_CMD_PARAM_NEW);
}
EXPORT_SYMBOL_GPL(devl_param_value_changed);
--
2.51.0
next prev parent reply other threads:[~2025-09-07 1:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-07 1:29 [PATCH V7 net-next 00/11] *devlink, mlx5: Add new parameters for link management and SRIOV/eSwitch configurations Saeed Mahameed
2025-09-07 1:29 ` [PATCH V7 net-next 01/11] devlink: Add 'total_vfs' generic device param Saeed Mahameed
2025-09-07 1:29 ` [PATCH V7 net-next 02/11] net/mlx5: Implement cqe_compress_type via devlink params Saeed Mahameed
2025-10-17 21:51 ` Daniel Zahka
2025-10-17 21:54 ` Daniel Zahka
2025-10-20 5:24 ` Tariq Toukan
2025-10-22 13:42 ` Dragos Tatulea
2025-10-22 16:26 ` Daniel Zahka
2025-09-07 1:29 ` [PATCH V7 net-next 03/11] net/mlx5: Implement devlink enable_sriov parameter Saeed Mahameed
2025-09-07 1:29 ` [PATCH V7 net-next 04/11] net/mlx5: Implement devlink total_vfs parameter Saeed Mahameed
2025-09-07 1:29 ` Saeed Mahameed [this message]
2025-09-07 1:29 ` [PATCH V7 net-next 06/11] devlink: Implement port params registration Saeed Mahameed
2025-09-07 1:29 ` [PATCH V7 net-next 07/11] devlink: Implement get/dump netlink commands for port params Saeed Mahameed
2025-09-07 1:29 ` [PATCH V7 net-next 08/11] devlink: Implement set netlink command " Saeed Mahameed
2025-09-07 1:29 ` [PATCH V7 net-next 09/11] devlink: Throw extack messages on param value validation error Saeed Mahameed
2025-09-07 1:29 ` [PATCH V7 net-next 10/11] devlink: Implement devlink param multi attribute nested data values Saeed Mahameed
2025-09-07 1:29 ` [PATCH V7 net-next 11/11] net/mlx5: Implement eSwitch hairpin per prio buffers devlink params Saeed Mahameed
2025-09-10 2:13 ` [PATCH V7 net-next 00/11] *devlink, mlx5: Add new parameters for link management and SRIOV/eSwitch configurations Jakub Kicinski
2025-09-10 2:30 ` patchwork-bot+netdevbpf
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=20250907012953.301746-6-saeed@kernel.org \
--to=saeed@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=leonro@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).