All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/4] Update devlink binary output
@ 2019-11-12 12:07 Aya Levin
  2019-11-12 12:07 ` [PATCH net-next 1/4] devlink: Allow large formatted message of " Aya Levin
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Aya Levin @ 2019-11-12 12:07 UTC (permalink / raw)
  To: David Miller, Jiri Pirko; +Cc: netdev, Aya Levin

This series changes the devlink binary interface:
-The first patch forces binary values to be enclosed in an array. In
 addition, devlink_fmsg_binary_pair_put breaks the binary value into
 chunks to comply with devlink's restriction for value length.
-The second patch removes redundant code and uses the fixed devlink
 interface (devlink_fmsg_binary_pair_put).
-The third patch make self test to use the updated devlink
 interface.
-The fourth, adds a verification of dumping a very large binary
 content. This test verifies breaking the data into chunks in a valid
 JSON output.

Series was generated against net-next commit:
ca22d6977b9b Merge branch 'stmmac-next'

Regards,
Aya

Aya Levin (4):
  devlink: Allow large formatted message of binary output
  net/mlx5: Dump of fw_fatal use updated devlink binary interface
  netdevsim: Update dummy reporter's devlink binary interface
  selftests: Add a test of large binary to devlink health test

 drivers/net/ethernet/mellanox/mlx5/core/health.c   | 18 +---------------
 drivers/net/netdevsim/health.c                     |  8 +-------
 include/net/devlink.h                              |  4 +---
 net/core/devlink.c                                 | 24 ++++++++++++++--------
 .../selftests/drivers/net/netdevsim/devlink.sh     |  9 ++++++++
 5 files changed, 27 insertions(+), 36 deletions(-)

-- 
2.14.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/4] devlink: Allow large formatted message of binary output
  2019-11-12 12:07 [PATCH net-next 0/4] Update devlink binary output Aya Levin
@ 2019-11-12 12:07 ` Aya Levin
  2019-11-12 12:07 ` [PATCH net-next 2/4] net/mlx5: Dump of fw_fatal use updated devlink binary interface Aya Levin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Aya Levin @ 2019-11-12 12:07 UTC (permalink / raw)
  To: David Miller, Jiri Pirko; +Cc: netdev, Aya Levin

Devlink supports pair output of name and value. When the value is
binary, it must be presented in an array. If the length of the binary
value exceeds fmsg limitation, break the value into chunks internally.

Signed-off-by: Aya Levin <ayal@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
---
 include/net/devlink.h |  4 +---
 net/core/devlink.c    | 24 +++++++++++++++---------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/include/net/devlink.h b/include/net/devlink.h
index 92ebc25bd88c..47f87b2fcf63 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -971,8 +971,6 @@ int devlink_fmsg_u8_put(struct devlink_fmsg *fmsg, u8 value);
 int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value);
 int devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value);
 int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value);
-int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value,
-			    u16 value_len);
 
 int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name,
 			       bool value);
@@ -985,7 +983,7 @@ int devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name,
 int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,
 				 const char *value);
 int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name,
-				 const void *value, u16 value_len);
+				 const void *value, u32 value_len);
 
 struct devlink_health_reporter *
 devlink_health_reporter_create(struct devlink *devlink,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index b1cde50f788d..1338f5fbc7d2 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -4419,12 +4419,11 @@ int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value)
 }
 EXPORT_SYMBOL_GPL(devlink_fmsg_string_put);
 
-int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value,
-			    u16 value_len)
+static int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value,
+				   u16 value_len)
 {
 	return devlink_fmsg_put_value(fmsg, value, value_len, NLA_BINARY);
 }
-EXPORT_SYMBOL_GPL(devlink_fmsg_binary_put);
 
 int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name,
 			       bool value)
@@ -4532,19 +4531,26 @@ int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,
 EXPORT_SYMBOL_GPL(devlink_fmsg_string_pair_put);
 
 int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name,
-				 const void *value, u16 value_len)
+				 const void *value, u32 value_len)
 {
+	u32 data_size;
+	u32 offset;
 	int err;
 
-	err = devlink_fmsg_pair_nest_start(fmsg, name);
+	err = devlink_fmsg_arr_pair_nest_start(fmsg, name);
 	if (err)
 		return err;
 
-	err = devlink_fmsg_binary_put(fmsg, value, value_len);
-	if (err)
-		return err;
+	for (offset = 0; offset < value_len; offset += data_size) {
+		data_size = value_len - offset;
+		if (data_size > DEVLINK_FMSG_MAX_SIZE)
+			data_size = DEVLINK_FMSG_MAX_SIZE;
+		err = devlink_fmsg_binary_put(fmsg, value + offset, data_size);
+		if (err)
+			return err;
+	}
 
-	err = devlink_fmsg_pair_nest_end(fmsg);
+	err = devlink_fmsg_arr_pair_nest_end(fmsg);
 	if (err)
 		return err;
 
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/4] net/mlx5: Dump of fw_fatal use updated devlink binary interface
  2019-11-12 12:07 [PATCH net-next 0/4] Update devlink binary output Aya Levin
  2019-11-12 12:07 ` [PATCH net-next 1/4] devlink: Allow large formatted message of " Aya Levin
@ 2019-11-12 12:07 ` Aya Levin
  2019-11-12 12:07 ` [PATCH net-next 3/4] netdevsim: Update dummy reporter's " Aya Levin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Aya Levin @ 2019-11-12 12:07 UTC (permalink / raw)
  To: David Miller, Jiri Pirko; +Cc: netdev, Aya Levin

Remove redundant code from fw_fatal reporter's dump callback. Use
updated devlink interface of binary fmsg pair which breaks the output
into chunks internally.

Signed-off-by: Aya Levin <ayal@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/health.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index e718170a80c3..d9f4e8c59c1f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -555,7 +555,6 @@ mlx5_fw_fatal_reporter_recover(struct devlink_health_reporter *reporter,
 	return mlx5_health_try_recover(dev);
 }
 
-#define MLX5_CR_DUMP_CHUNK_SIZE 256
 static int
 mlx5_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter,
 			    struct devlink_fmsg *fmsg, void *priv_ctx,
@@ -564,8 +563,6 @@ mlx5_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter,
 	struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter);
 	u32 crdump_size = dev->priv.health.crdump_size;
 	u32 *cr_data;
-	u32 data_size;
-	u32 offset;
 	int err;
 
 	if (!mlx5_core_is_pf(dev))
@@ -586,20 +583,7 @@ mlx5_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter,
 			goto free_data;
 	}
 
-	err = devlink_fmsg_arr_pair_nest_start(fmsg, "crdump_data");
-	if (err)
-		goto free_data;
-	for (offset = 0; offset < crdump_size; offset += data_size) {
-		if (crdump_size - offset < MLX5_CR_DUMP_CHUNK_SIZE)
-			data_size = crdump_size - offset;
-		else
-			data_size = MLX5_CR_DUMP_CHUNK_SIZE;
-		err = devlink_fmsg_binary_put(fmsg, (char *)cr_data + offset,
-					      data_size);
-		if (err)
-			goto free_data;
-	}
-	err = devlink_fmsg_arr_pair_nest_end(fmsg);
+	err = devlink_fmsg_binary_pair_put(fmsg, "crdump_data", cr_data, crdump_size);
 
 free_data:
 	kvfree(cr_data);
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/4] netdevsim: Update dummy reporter's devlink binary interface
  2019-11-12 12:07 [PATCH net-next 0/4] Update devlink binary output Aya Levin
  2019-11-12 12:07 ` [PATCH net-next 1/4] devlink: Allow large formatted message of " Aya Levin
  2019-11-12 12:07 ` [PATCH net-next 2/4] net/mlx5: Dump of fw_fatal use updated devlink binary interface Aya Levin
@ 2019-11-12 12:07 ` Aya Levin
  2019-11-12 12:07 ` [PATCH net-next 4/4] selftests: Add a test of large binary to devlink health test Aya Levin
  2019-11-12 19:26 ` [PATCH net-next 0/4] Update devlink binary output David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Aya Levin @ 2019-11-12 12:07 UTC (permalink / raw)
  To: David Miller, Jiri Pirko; +Cc: netdev, Aya Levin

Update dummy reporter's output to use updated devlink interface of
binary fmsg pair.

Signed-off-by: Aya Levin <ayal@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/netdevsim/health.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/netdevsim/health.c b/drivers/net/netdevsim/health.c
index 2716235a0336..9aa637d162eb 100644
--- a/drivers/net/netdevsim/health.c
+++ b/drivers/net/netdevsim/health.c
@@ -82,18 +82,12 @@ static int nsim_dev_dummy_fmsg_put(struct devlink_fmsg *fmsg, u32 binary_len)
 	if (err)
 		return err;
 
-	err = devlink_fmsg_arr_pair_nest_start(fmsg, "test_binary");
-	if (err)
-		return err;
 	binary = kmalloc(binary_len, GFP_KERNEL);
 	if (!binary)
 		return -ENOMEM;
 	get_random_bytes(binary, binary_len);
-	err = devlink_fmsg_binary_put(fmsg, binary, binary_len);
+	err = devlink_fmsg_binary_pair_put(fmsg, "test_binary", binary, binary_len);
 	kfree(binary);
-	if (err)
-		return err;
-	err = devlink_fmsg_arr_pair_nest_end(fmsg);
 	if (err)
 		return err;
 
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 4/4] selftests: Add a test of large binary to devlink health test
  2019-11-12 12:07 [PATCH net-next 0/4] Update devlink binary output Aya Levin
                   ` (2 preceding siblings ...)
  2019-11-12 12:07 ` [PATCH net-next 3/4] netdevsim: Update dummy reporter's " Aya Levin
@ 2019-11-12 12:07 ` Aya Levin
  2019-11-12 19:26 ` [PATCH net-next 0/4] Update devlink binary output David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Aya Levin @ 2019-11-12 12:07 UTC (permalink / raw)
  To: David Miller, Jiri Pirko; +Cc: netdev, Aya Levin

Add a test of 2 PAGEs size (exceeds devlink previous length limitation)
of binary data on a 'devlink health dump show' command. Set binary length
to 8192, issue a dump show command and clear it.

Signed-off-by: Aya Levin <ayal@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
---
 tools/testing/selftests/drivers/net/netdevsim/devlink.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
index 753c5b6abe0a..025a84c2ab5a 100755
--- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
+++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
@@ -431,6 +431,15 @@ dummy_reporter_test()
 
 	check_reporter_info dummy healthy 3 3 10 true
 
+	echo 8192> $DEBUGFS_DIR/health/binary_len
+	check_fail $? "Failed set dummy reporter binary len to 8192"
+
+	local dump=$(devlink health dump show $DL_HANDLE reporter dummy -j)
+	check_err $? "Failed show dump of dummy reporter"
+
+	devlink health dump clear $DL_HANDLE reporter dummy
+	check_err $? "Failed clear dump of dummy reporter"
+
 	log_test "dummy reporter test"
 }
 
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/4] Update devlink binary output
  2019-11-12 12:07 [PATCH net-next 0/4] Update devlink binary output Aya Levin
                   ` (3 preceding siblings ...)
  2019-11-12 12:07 ` [PATCH net-next 4/4] selftests: Add a test of large binary to devlink health test Aya Levin
@ 2019-11-12 19:26 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-11-12 19:26 UTC (permalink / raw)
  To: ayal; +Cc: jiri, netdev

From: Aya Levin <ayal@mellanox.com>
Date: Tue, 12 Nov 2019 14:07:48 +0200

> This series changes the devlink binary interface:
> -The first patch forces binary values to be enclosed in an array. In
>  addition, devlink_fmsg_binary_pair_put breaks the binary value into
>  chunks to comply with devlink's restriction for value length.
> -The second patch removes redundant code and uses the fixed devlink
>  interface (devlink_fmsg_binary_pair_put).
> -The third patch make self test to use the updated devlink
>  interface.
> -The fourth, adds a verification of dumping a very large binary
>  content. This test verifies breaking the data into chunks in a valid
>  JSON output.
> 
> Series was generated against net-next commit:
> ca22d6977b9b Merge branch 'stmmac-next'

Series applied, thank you.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-12 19:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12 12:07 [PATCH net-next 0/4] Update devlink binary output Aya Levin
2019-11-12 12:07 ` [PATCH net-next 1/4] devlink: Allow large formatted message of " Aya Levin
2019-11-12 12:07 ` [PATCH net-next 2/4] net/mlx5: Dump of fw_fatal use updated devlink binary interface Aya Levin
2019-11-12 12:07 ` [PATCH net-next 3/4] netdevsim: Update dummy reporter's " Aya Levin
2019-11-12 12:07 ` [PATCH net-next 4/4] selftests: Add a test of large binary to devlink health test Aya Levin
2019-11-12 19:26 ` [PATCH net-next 0/4] Update devlink binary output David Miller

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.