* [PATCH iproute2 master 0/3] devlink dumpit fixes
@ 2019-07-10 11:03 Tariq Toukan
2019-07-10 11:03 ` [PATCH iproute2 master 1/3] devlink: Change devlink health dump show command to dumpit Tariq Toukan
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Tariq Toukan @ 2019-07-10 11:03 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, moshe, ayal, Tariq Toukan
Hi,
This series from Aya contains several fixes for devlink health
dump show command with binary data.
In patch 1 we replace the usage of doit with a dumpit, which
is non-blocking and allows transferring larger amount of data.
Patches 2 and 3 fix the output for binary data prints, for both
json and non-json.
Series generated against master commit:
2eb23f3e7aaf devlink: Show devlink port number
Regards,
Tariq
Aya Levin (3):
devlink: Change devlink health dump show command to dumpit
devlink: Fix binary values print
devlink: Remove enclosing array brackets binary print with json format
devlink/devlink.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH iproute2 master 1/3] devlink: Change devlink health dump show command to dumpit
2019-07-10 11:03 [PATCH iproute2 master 0/3] devlink dumpit fixes Tariq Toukan
@ 2019-07-10 11:03 ` Tariq Toukan
2019-07-10 11:47 ` Jiri Pirko
2019-07-10 11:03 ` [PATCH iproute2 master 2/3] devlink: Fix binary values print Tariq Toukan
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Tariq Toukan @ 2019-07-10 11:03 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, moshe, ayal, Tariq Toukan
From: Aya Levin <ayal@mellanox.com>
Although devlink health dump show command is given per reporter, it
returns large amounts of data. Trying to use the doit cb results in
OUT-OF-BUFFER error. This complementary patch raises the DUMP flag in
order to invoke the dumpit cb. We're safe as no existing drivers
implement the dump health reporter option yet.
Fixes: 041e6e651a8e ("devlink: Add devlink health dump show command")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
devlink/devlink.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index ac8c0fb149b6..e3e1e27ab312 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -6078,13 +6078,13 @@ static int cmd_fmsg_object_cb(const struct nlmsghdr *nlh, void *data)
return MNL_CB_OK;
}
-static int cmd_health_object_common(struct dl *dl, uint8_t cmd)
+static int cmd_health_object_common(struct dl *dl, uint8_t cmd, uint16_t flags)
{
struct fmsg_cb_data data;
struct nlmsghdr *nlh;
int err;
- nlh = mnlg_msg_prepare(dl->nlg, cmd, NLM_F_REQUEST | NLM_F_ACK);
+ nlh = mnlg_msg_prepare(dl->nlg, cmd, flags | NLM_F_REQUEST | NLM_F_ACK);
err = dl_argv_parse_put(nlh, dl,
DL_OPT_HANDLE | DL_OPT_HEALTH_REPORTER_NAME, 0);
@@ -6099,12 +6099,16 @@ static int cmd_health_object_common(struct dl *dl, uint8_t cmd)
static int cmd_health_dump_show(struct dl *dl)
{
- return cmd_health_object_common(dl, DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET);
+ return cmd_health_object_common(dl,
+ DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET,
+ NLM_F_DUMP);
}
static int cmd_health_diagnose(struct dl *dl)
{
- return cmd_health_object_common(dl, DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE);
+ return cmd_health_object_common(dl,
+ DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
+ 0);
}
static int cmd_health_recover(struct dl *dl)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH iproute2 master 2/3] devlink: Fix binary values print
2019-07-10 11:03 [PATCH iproute2 master 0/3] devlink dumpit fixes Tariq Toukan
2019-07-10 11:03 ` [PATCH iproute2 master 1/3] devlink: Change devlink health dump show command to dumpit Tariq Toukan
@ 2019-07-10 11:03 ` Tariq Toukan
2019-07-10 11:03 ` [PATCH iproute2 master 3/3] devlink: Remove enclosing array brackets binary print with json format Tariq Toukan
2019-07-15 20:51 ` [PATCH iproute2 master 0/3] devlink dumpit fixes Stephen Hemminger
3 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2019-07-10 11:03 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, moshe, ayal, Tariq Toukan
From: Aya Levin <ayal@mellanox.com>
Fix function pr_out_binary_value() to start printing the binary buffer
from offset 0 instead of offset 1. Remove redundant new line at the
beginning of the output
Example:
With patch:
mlx5e_txqsq:
05 00 00 00 05 00 00 00 01 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 8e 6e 3a 13 07 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0
Without patch
mlx5e_txqsq:
00 00 00 05 00 00 00 01 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 8e 6e 3a 13 07 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c0
Fixes: 844a61764c6f ("devlink: Add helper functions for name and value separately")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
devlink/devlink.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index e3e1e27ab312..4bced4e60ae8 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -1779,29 +1779,31 @@ static void pr_out_uint64_value(struct dl *dl, uint64_t value)
pr_out(" %"PRIu64, value);
}
+static bool is_binary_eol(int i)
+{
+ return !(i%16);
+}
+
static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
{
- int i = 1;
+ int i = 0;
if (dl->json_output)
jsonw_start_array(dl->jw);
- else
- pr_out("\n");
while (i < len) {
- if (dl->json_output) {
+ if (dl->json_output)
jsonw_printf(dl->jw, "%d", data[i]);
- } else {
- pr_out(" %02x", data[i]);
- if (!(i % 16))
- pr_out("\n");
- }
+ else
+ pr_out("%02x ", data[i]);
i++;
+ if (!dl->json_output && is_binary_eol(i))
+ __pr_out_newline();
}
if (dl->json_output)
jsonw_end_array(dl->jw);
- else if ((i - 1) % 16)
- pr_out("\n");
+ else if (!is_binary_eol(i))
+ __pr_out_newline();
}
static void pr_out_str_value(struct dl *dl, const char *value)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH iproute2 master 3/3] devlink: Remove enclosing array brackets binary print with json format
2019-07-10 11:03 [PATCH iproute2 master 0/3] devlink dumpit fixes Tariq Toukan
2019-07-10 11:03 ` [PATCH iproute2 master 1/3] devlink: Change devlink health dump show command to dumpit Tariq Toukan
2019-07-10 11:03 ` [PATCH iproute2 master 2/3] devlink: Fix binary values print Tariq Toukan
@ 2019-07-10 11:03 ` Tariq Toukan
2019-07-15 20:51 ` [PATCH iproute2 master 0/3] devlink dumpit fixes Stephen Hemminger
3 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2019-07-10 11:03 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, moshe, ayal, Tariq Toukan
From: Aya Levin <ayal@mellanox.com>
Keep pr_out_binary_value function only for printing. Inner relations
like array grouping should be done outside the function.
Fixes: 844a61764c6f ("devlink: Add helper functions for name and value separately")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
devlink/devlink.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 4bced4e60ae8..7532c3f888f9 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -1788,9 +1788,6 @@ static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
{
int i = 0;
- if (dl->json_output)
- jsonw_start_array(dl->jw);
-
while (i < len) {
if (dl->json_output)
jsonw_printf(dl->jw, "%d", data[i]);
@@ -1800,9 +1797,7 @@ static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
if (!dl->json_output && is_binary_eol(i))
__pr_out_newline();
}
- if (dl->json_output)
- jsonw_end_array(dl->jw);
- else if (!is_binary_eol(i))
+ if (!dl->json_output && !is_binary_eol(i))
__pr_out_newline();
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2 master 1/3] devlink: Change devlink health dump show command to dumpit
2019-07-10 11:03 ` [PATCH iproute2 master 1/3] devlink: Change devlink health dump show command to dumpit Tariq Toukan
@ 2019-07-10 11:47 ` Jiri Pirko
0 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2019-07-10 11:47 UTC (permalink / raw)
To: Tariq Toukan; +Cc: Stephen Hemminger, netdev, moshe, ayal
Wed, Jul 10, 2019 at 01:03:19PM CEST, tariqt@mellanox.com wrote:
>From: Aya Levin <ayal@mellanox.com>
>
>Although devlink health dump show command is given per reporter, it
>returns large amounts of data. Trying to use the doit cb results in
>OUT-OF-BUFFER error. This complementary patch raises the DUMP flag in
>order to invoke the dumpit cb. We're safe as no existing drivers
>implement the dump health reporter option yet.
>
>Fixes: 041e6e651a8e ("devlink: Add devlink health dump show command")
>Signed-off-by: Aya Levin <ayal@mellanox.com>
>Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2 master 0/3] devlink dumpit fixes
2019-07-10 11:03 [PATCH iproute2 master 0/3] devlink dumpit fixes Tariq Toukan
` (2 preceding siblings ...)
2019-07-10 11:03 ` [PATCH iproute2 master 3/3] devlink: Remove enclosing array brackets binary print with json format Tariq Toukan
@ 2019-07-15 20:51 ` Stephen Hemminger
3 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2019-07-15 20:51 UTC (permalink / raw)
To: Tariq Toukan; +Cc: netdev, moshe, ayal
On Wed, 10 Jul 2019 14:03:18 +0300
Tariq Toukan <tariqt@mellanox.com> wrote:
> Hi,
>
> This series from Aya contains several fixes for devlink health
> dump show command with binary data.
>
> In patch 1 we replace the usage of doit with a dumpit, which
> is non-blocking and allows transferring larger amount of data.
>
> Patches 2 and 3 fix the output for binary data prints, for both
> json and non-json.
>
> Series generated against master commit:
> 2eb23f3e7aaf devlink: Show devlink port number
>
> Regards,
> Tariq
>
> Aya Levin (3):
> devlink: Change devlink health dump show command to dumpit
> devlink: Fix binary values print
> devlink: Remove enclosing array brackets binary print with json format
>
> devlink/devlink.c | 41 +++++++++++++++++++++--------------------
> 1 file changed, 21 insertions(+), 20 deletions(-)
>
Applied
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-07-15 20:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-10 11:03 [PATCH iproute2 master 0/3] devlink dumpit fixes Tariq Toukan
2019-07-10 11:03 ` [PATCH iproute2 master 1/3] devlink: Change devlink health dump show command to dumpit Tariq Toukan
2019-07-10 11:47 ` Jiri Pirko
2019-07-10 11:03 ` [PATCH iproute2 master 2/3] devlink: Fix binary values print Tariq Toukan
2019-07-10 11:03 ` [PATCH iproute2 master 3/3] devlink: Remove enclosing array brackets binary print with json format Tariq Toukan
2019-07-15 20:51 ` [PATCH iproute2 master 0/3] devlink dumpit fixes Stephen Hemminger
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).