From patchwork Thu Sep 5 12:43:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 1158414 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46PL2t418Zz9sN1 for ; Thu, 5 Sep 2019 22:43:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389471AbfIEMna (ORCPT ); Thu, 5 Sep 2019 08:43:30 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:58416 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389449AbfIEMn3 (ORCPT ); Thu, 5 Sep 2019 08:43:29 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from tariqt@mellanox.com) with ESMTPS (AES256-SHA encrypted); 5 Sep 2019 15:43:23 +0300 Received: from dev-l-vrt-207-011.mtl.labs.mlnx. (dev-l-vrt-207-011.mtl.labs.mlnx [10.134.207.11]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x85ChNGY021437; Thu, 5 Sep 2019 15:43:23 +0300 From: Tariq Toukan To: Stephen Hemminger , David Ahern Cc: netdev@vger.kernel.org, Moshe Shemesh , Aya Levin , Jiri Pirko , Tariq Toukan Subject: [PATCH iproute2 1/4] devlink: Add helper for left justification print Date: Thu, 5 Sep 2019 15:43:04 +0300 Message-Id: <1567687387-12993-2-git-send-email-tariqt@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1567687387-12993-1-git-send-email-tariqt@mellanox.com> References: <1567687387-12993-1-git-send-email-tariqt@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Aya Levin Introduce a helper function which wraps code that adds a left hand side space separator unless it follows a newline. Fixes: e3d0f0c0e3d8 ("devlink: add option to generate JSON output") Signed-off-by: Aya Levin Acked-by: Jiri Pirko Signed-off-by: Tariq Toukan --- devlink/devlink.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 2f084c020765..f1b9b2da39d7 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -355,6 +355,12 @@ static bool dl_no_arg(struct dl *dl) return dl_argc(dl) == 0; } +static void __pr_out_indent_newline(struct dl *dl) +{ + if (!g_indent_newline && !dl->json_output) + pr_out(" "); +} + static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = { [DEVLINK_ATTR_BUS_NAME] = MNL_TYPE_NUL_STRING, [DEVLINK_ATTR_DEV_NAME] = MNL_TYPE_NUL_STRING, @@ -1799,14 +1805,11 @@ static void pr_out_port_handle_end(struct dl *dl) static void pr_out_str(struct dl *dl, const char *name, const char *val) { - if (dl->json_output) { + __pr_out_indent_newline(dl); + if (dl->json_output) jsonw_string_field(dl->jw, name, val); - } else { - if (g_indent_newline) - pr_out("%s %s", name, val); - else - pr_out(" %s %s", name, val); - } + else + pr_out("%s %s", name, val); } static void pr_out_bool(struct dl *dl, const char *name, bool val) @@ -1819,29 +1822,23 @@ static void pr_out_bool(struct dl *dl, const char *name, bool val) static void pr_out_uint(struct dl *dl, const char *name, unsigned int val) { - if (dl->json_output) { + __pr_out_indent_newline(dl); + if (dl->json_output) jsonw_uint_field(dl->jw, name, val); - } else { - if (g_indent_newline) - pr_out("%s %u", name, val); - else - pr_out(" %s %u", name, val); - } + else + pr_out("%s %u", name, val); } static void pr_out_u64(struct dl *dl, const char *name, uint64_t val) { + __pr_out_indent_newline(dl); if (val == (uint64_t) -1) return pr_out_str(dl, name, "unlimited"); - if (dl->json_output) { + if (dl->json_output) jsonw_u64_field(dl->jw, name, val); - } else { - if (g_indent_newline) - pr_out("%s %"PRIu64, name, val); - else - pr_out(" %s %"PRIu64, name, val); - } + else + pr_out("%s %"PRIu64, name, val); } static void pr_out_bool_value(struct dl *dl, bool value) @@ -5835,14 +5832,12 @@ static void pr_out_region_handle_end(struct dl *dl) static void pr_out_region_snapshots_start(struct dl *dl, bool array) { + __pr_out_indent_newline(dl); if (dl->json_output) { jsonw_name(dl->jw, "snapshot"); jsonw_start_array(dl->jw); } else { - if (g_indent_newline) - pr_out("snapshot %s", array ? "[" : ""); - else - pr_out(" snapshot %s", array ? "[" : ""); + pr_out("snapshot %s", array ? "[" : ""); } } From patchwork Thu Sep 5 12:43:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 1158416 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46PL2x29zZz9s4Y for ; Thu, 5 Sep 2019 22:43:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389460AbfIEMna (ORCPT ); Thu, 5 Sep 2019 08:43:30 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:58414 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389450AbfIEMn3 (ORCPT ); Thu, 5 Sep 2019 08:43:29 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from tariqt@mellanox.com) with ESMTPS (AES256-SHA encrypted); 5 Sep 2019 15:43:23 +0300 Received: from dev-l-vrt-207-011.mtl.labs.mlnx. (dev-l-vrt-207-011.mtl.labs.mlnx [10.134.207.11]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x85ChNGZ021437; Thu, 5 Sep 2019 15:43:23 +0300 From: Tariq Toukan To: Stephen Hemminger , David Ahern Cc: netdev@vger.kernel.org, Moshe Shemesh , Aya Levin , Jiri Pirko , Tariq Toukan Subject: [PATCH iproute2 2/4] devlink: Left justification on FMSG output Date: Thu, 5 Sep 2019 15:43:05 +0300 Message-Id: <1567687387-12993-3-git-send-email-tariqt@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1567687387-12993-1-git-send-email-tariqt@mellanox.com> References: <1567687387-12993-1-git-send-email-tariqt@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Aya Levin FMSG output is dynamic, space separator must be on the left hand side of the value. Otherwise output has redundant left indentation regardless the hierarchy. Before the patch: Common config: SQ: stride size: 64 size: 1024 CQ: stride size: 64 size: 1024 SQs: channel ix: 0 tc: 0 txq ix: 0 sqn: 10 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 6 HW status: 0 channel ix: 1 tc: 0 txq ix: 1 sqn: 14 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 10 HW status: 0 channel ix: 2 tc: 0 txq ix: 2 sqn: 18 HW state: 1 stopped: false cc: 5 pc: 5 CQ: cqn: 14 HW status: 0 channel ix: 3 tc: 0 txq ix: 3 sqn: 22 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 18 HW status: 0 With the patch: Common config: SQ: stride size: 64 size: 1024 CQ: stride size: 64 size: 1024 SQs: channel ix: 0 tc: 0 txq ix: 0 sqn: 10 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 6 HW status: 0 channel ix: 1 tc: 0 txq ix: 1 sqn: 14 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 10 HW status: 0 channel ix: 2 tc: 0 txq ix: 2 sqn: 18 HW state: 1 stopped: false cc: 5 pc: 5 CQ: cqn: 14 HW status: 0 channel ix: 3 tc: 0 txq ix: 3 sqn: 22 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 18 HW status: 0 Fixes: 844a61764c6f ("devlink: Add helper functions for name and value separately") Signed-off-by: Aya Levin Acked-by: Jiri Pirko Signed-off-by: Tariq Toukan --- devlink/devlink.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index f1b9b2da39d7..1bfc3283a832 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -1843,26 +1843,29 @@ static void pr_out_u64(struct dl *dl, const char *name, uint64_t val) static void pr_out_bool_value(struct dl *dl, bool value) { + __pr_out_indent_newline(dl); if (dl->json_output) jsonw_bool(dl->jw, value); else - pr_out(" %s", value ? "true" : "false"); + pr_out("%s", value ? "true" : "false"); } static void pr_out_uint_value(struct dl *dl, unsigned int value) { + __pr_out_indent_newline(dl); if (dl->json_output) jsonw_uint(dl->jw, value); else - pr_out(" %u", value); + pr_out("%u", value); } static void pr_out_uint64_value(struct dl *dl, uint64_t value) { + __pr_out_indent_newline(dl); if (dl->json_output) jsonw_u64(dl->jw, value); else - pr_out(" %"PRIu64, value); + pr_out("%"PRIu64, value); } static bool is_binary_eol(int i) @@ -1889,18 +1892,20 @@ static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len) static void pr_out_str_value(struct dl *dl, const char *value) { + __pr_out_indent_newline(dl); if (dl->json_output) jsonw_string(dl->jw, value); else - pr_out(" %s", value); + pr_out("%s", value); } static void pr_out_name(struct dl *dl, const char *name) { + __pr_out_indent_newline(dl); if (dl->json_output) jsonw_name(dl->jw, name); else - pr_out(" %s:", name); + pr_out("%s:", name); } static void pr_out_region_chunk_start(struct dl *dl, uint64_t addr) From patchwork Thu Sep 5 12:43:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 1158415 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46PL2v0zJXz9sNf for ; Thu, 5 Sep 2019 22:43:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389475AbfIEMnb (ORCPT ); Thu, 5 Sep 2019 08:43:31 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:58417 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389445AbfIEMn3 (ORCPT ); Thu, 5 Sep 2019 08:43:29 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from tariqt@mellanox.com) with ESMTPS (AES256-SHA encrypted); 5 Sep 2019 15:43:23 +0300 Received: from dev-l-vrt-207-011.mtl.labs.mlnx. (dev-l-vrt-207-011.mtl.labs.mlnx [10.134.207.11]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x85ChNGa021437; Thu, 5 Sep 2019 15:43:23 +0300 From: Tariq Toukan To: Stephen Hemminger , David Ahern Cc: netdev@vger.kernel.org, Moshe Shemesh , Aya Levin , Jiri Pirko , Tariq Toukan Subject: [PATCH iproute2 3/4] devlink: Fix inconsistency between command input and output Date: Thu, 5 Sep 2019 15:43:06 +0300 Message-Id: <1567687387-12993-4-git-send-email-tariqt@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1567687387-12993-1-git-send-email-tariqt@mellanox.com> References: <1567687387-12993-1-git-send-email-tariqt@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Aya Levin In devlink health show command the reporter's name parameter is called reporter, but in the output the reporter's name is referred to as name Before this patch: $ devlink health show pci/0000:04:00.0 reporter tx pci/0000:04:00.0: name tx state healthy error 0 recover 0 grace_period 500 auto_recover true After this patch: $ devlink health show pci/0000:04:00.0 reporter tx pci/0000:04:00.0: reporter tx state healthy error 0 recover 0 grace_period 500 auto_recover true Fixes: 2f1242efe9d0 ("devlink: Add devlink health show command") Signed-off-by: Aya Levin Reported-by: Jiri Pirko Acked-by: Jiri Pirko Signed-off-by: Tariq Toukan --- devlink/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 1bfc3283a832..722b6a101673 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -6377,7 +6377,7 @@ static void pr_out_health(struct dl *dl, struct nlattr **tb_health) pr_out_handle_start_arr(dl, tb_health); - pr_out_str(dl, "name", + pr_out_str(dl, "reporter", mnl_attr_get_str(tb[DEVLINK_ATTR_HEALTH_REPORTER_NAME])); if (!dl->json_output) { __pr_out_newline(); From patchwork Thu Sep 5 12:43:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 1158417 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46PL2z01zYz9sN1 for ; Thu, 5 Sep 2019 22:43:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389456AbfIEMn3 (ORCPT ); Thu, 5 Sep 2019 08:43:29 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:58415 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389447AbfIEMn3 (ORCPT ); Thu, 5 Sep 2019 08:43:29 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from tariqt@mellanox.com) with ESMTPS (AES256-SHA encrypted); 5 Sep 2019 15:43:23 +0300 Received: from dev-l-vrt-207-011.mtl.labs.mlnx. (dev-l-vrt-207-011.mtl.labs.mlnx [10.134.207.11]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x85ChNGb021437; Thu, 5 Sep 2019 15:43:23 +0300 From: Tariq Toukan To: Stephen Hemminger , David Ahern Cc: netdev@vger.kernel.org, Moshe Shemesh , Aya Levin , Jiri Pirko , Tariq Toukan Subject: [PATCH iproute2 4/4] devlink: Fix devlink health set command Date: Thu, 5 Sep 2019 15:43:07 +0300 Message-Id: <1567687387-12993-5-git-send-email-tariqt@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1567687387-12993-1-git-send-email-tariqt@mellanox.com> References: <1567687387-12993-1-git-send-email-tariqt@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Aya Levin Prior to this patch both the reporter's name and the grace period attributes shared the same bit. This caused zeroing grace period when setting auto recovery. Let each parameter has its own bit. Fixes: b18d89195b16 ("devlink: Add devlink health set command") Signed-off-by: Aya Levin Acked-by: Jiri Pirko Signed-off-by: Tariq Toukan --- devlink/devlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 722b6a101673..306abfb5222b 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -231,11 +231,11 @@ static void ifname_map_free(struct ifname_map *ifname_map) #define DL_OPT_FLASH_FILE_NAME BIT(25) #define DL_OPT_FLASH_COMPONENT BIT(26) #define DL_OPT_HEALTH_REPORTER_NAME BIT(27) -#define DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD BIT(27) -#define DL_OPT_HEALTH_REPORTER_AUTO_RECOVER BIT(28) +#define DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD BIT(28) #define DL_OPT_TRAP_NAME BIT(29) #define DL_OPT_TRAP_ACTION BIT(30) #define DL_OPT_TRAP_GROUP_NAME BIT(31) +#define DL_OPT_HEALTH_REPORTER_AUTO_RECOVER BIT(32) struct dl_opts { uint64_t present; /* flags of present items */