* [patch iproute2-next 1/2] devlink: load port-ifname map on demand
2022-08-25 8:04 [patch iproute2-next 0/2] devlink: allow parallel commands Jiri Pirko
@ 2022-08-25 8:04 ` Jiri Pirko
2022-08-25 8:04 ` [patch iproute2-next 2/2] devlink: fix parallel flash notifications processing Jiri Pirko
2022-09-01 2:40 ` [patch iproute2-next 0/2] devlink: allow parallel commands patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2022-08-25 8:04 UTC (permalink / raw)
To: netdev; +Cc: sthemmin, dsahern, vikas.gupta, jacob.e.keller, kuba, moshe,
saeedm
From: Jiri Pirko <jiri@nvidia.com>
So far, the port-ifname map was loaded during devlink init
no matter if actually needed or not. Port dump cmd which is utilized
for this in kernel takes lock for every devlink instance.
That may lead to unnecessary blockage of command.
Load the map only in time it is needed to lookup ifname.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
devlink/devlink.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index b69c89778804..b2439aef4d10 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -374,6 +374,7 @@ struct dl {
bool verbose;
bool stats;
bool hex;
+ bool map_loaded;
struct {
bool present;
char *bus_name;
@@ -817,13 +818,15 @@ static void ifname_map_fini(struct dl *dl)
}
}
-static int ifname_map_init(struct dl *dl)
+static void ifname_map_init(struct dl *dl)
{
- struct nlmsghdr *nlh;
- int err;
-
INIT_LIST_HEAD(&dl->ifname_map_list);
+}
+static int ifname_map_load(struct dl *dl)
+{
+ struct nlmsghdr *nlh;
+ int err;
nlh = mnlu_gen_socket_cmd_prepare(&dl->nlg, DEVLINK_CMD_PORT_GET,
NLM_F_REQUEST | NLM_F_ACK | NLM_F_DUMP);
@@ -841,7 +844,16 @@ static int ifname_map_lookup(struct dl *dl, const char *ifname,
uint32_t *p_port_index)
{
struct ifname_map *ifname_map;
+ int err;
+ if (!dl->map_loaded) {
+ err = ifname_map_load(dl);
+ if (err) {
+ pr_err("Failed to create index map\n");
+ return err;
+ }
+ dl->map_loaded = true;
+ }
list_for_each_entry(ifname_map, &dl->ifname_map_list, list) {
if (strcmp(ifname, ifname_map->ifname) == 0) {
*p_bus_name = ifname_map->bus_name;
@@ -9622,17 +9634,10 @@ static int dl_init(struct dl *dl)
return -errno;
}
- err = ifname_map_init(dl);
- if (err) {
- pr_err("Failed to create index map\n");
- goto err_ifname_map_create;
- }
+ ifname_map_init(dl);
+
new_json_obj_plain(dl->json_output);
return 0;
-
-err_ifname_map_create:
- mnlu_gen_socket_close(&dl->nlg);
- return err;
}
static void dl_fini(struct dl *dl)
--
2.37.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [patch iproute2-next 2/2] devlink: fix parallel flash notifications processing
2022-08-25 8:04 [patch iproute2-next 0/2] devlink: allow parallel commands Jiri Pirko
2022-08-25 8:04 ` [patch iproute2-next 1/2] devlink: load port-ifname map on demand Jiri Pirko
@ 2022-08-25 8:04 ` Jiri Pirko
2022-09-01 2:40 ` [patch iproute2-next 0/2] devlink: allow parallel commands patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2022-08-25 8:04 UTC (permalink / raw)
To: netdev; +Cc: sthemmin, dsahern, vikas.gupta, jacob.e.keller, kuba, moshe,
saeedm
From: Jiri Pirko <jiri@nvidia.com>
Now that it is possible to flash multiple devlink instances in parallel,
the notification processing callback needs to count in the fact that it
receives message that belongs to different devlink instance. So handle
the it gracefully and don't error out.
Reported-by: Vikas Gupta <vikas.gupta@broadcom.com>
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
devlink/devlink.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index b2439aef4d10..4f77e42f2d48 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -3812,12 +3812,12 @@ static int cmd_dev_flash_status_cb(const struct nlmsghdr *nlh, void *data)
mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME])
- return MNL_CB_ERROR;
+ return MNL_CB_STOP;
bus_name = mnl_attr_get_str(tb[DEVLINK_ATTR_BUS_NAME]);
dev_name = mnl_attr_get_str(tb[DEVLINK_ATTR_DEV_NAME]);
if (strcmp(bus_name, opts->bus_name) ||
strcmp(dev_name, opts->dev_name))
- return MNL_CB_ERROR;
+ return MNL_CB_STOP;
if (genl->cmd == DEVLINK_CMD_FLASH_UPDATE_END) {
pr_out("\n");
--
2.37.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [patch iproute2-next 0/2] devlink: allow parallel commands
2022-08-25 8:04 [patch iproute2-next 0/2] devlink: allow parallel commands Jiri Pirko
2022-08-25 8:04 ` [patch iproute2-next 1/2] devlink: load port-ifname map on demand Jiri Pirko
2022-08-25 8:04 ` [patch iproute2-next 2/2] devlink: fix parallel flash notifications processing Jiri Pirko
@ 2022-09-01 2:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-01 2:40 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, sthemmin, dsahern, vikas.gupta, jacob.e.keller, kuba,
moshe, saeedm
Hello:
This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:
On Thu, 25 Aug 2022 10:04:18 +0200 you wrote:
> From: Jiri Pirko <jiri@nvidia.com>
>
> This patchset contains couple of small patches that allow user to run
> devlink commands in parallel, if kernel is capable of doing so.
>
> Jiri Pirko (2):
> devlink: load port-ifname map on demand
> devlink: fix parallel flash notifications processing
>
> [...]
Here is the summary with links:
- [iproute2-next,1/2] devlink: load port-ifname map on demand
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=5cddbb274eab
- [iproute2-next,2/2] devlink: fix parallel flash notifications processing
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=2b392dac5be3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread