From patchwork Wed Jul 10 11:03:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 1130339 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 45kGWx3mjTz9s4V for ; Wed, 10 Jul 2019 21:03:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727184AbfGJLDf (ORCPT ); Wed, 10 Jul 2019 07:03:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54915 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725994AbfGJLDe (ORCPT ); Wed, 10 Jul 2019 07:03:34 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from tariqt@mellanox.com) with ESMTPS (AES256-SHA encrypted); 10 Jul 2019 14:03:30 +0300 Received: from dev-l-vrt-206-006.mtl.labs.mlnx (dev-l-vrt-206-006.mtl.labs.mlnx [10.134.206.6]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x6AB3URx020650; Wed, 10 Jul 2019 14:03:30 +0300 From: Tariq Toukan To: Stephen Hemminger Cc: netdev@vger.kernel.org, moshe@mellanox.com, ayal@mellanox.com, Tariq Toukan Subject: [PATCH iproute2 master 1/3] devlink: Change devlink health dump show command to dumpit Date: Wed, 10 Jul 2019 14:03:19 +0300 Message-Id: <1562756601-19171-2-git-send-email-tariqt@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1562756601-19171-1-git-send-email-tariqt@mellanox.com> References: <1562756601-19171-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 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 Signed-off-by: Tariq Toukan Acked-by: Jiri Pirko --- 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) From patchwork Wed Jul 10 11:03:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 1130338 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 45kGWv4Hr9z9s4V for ; Wed, 10 Jul 2019 21:03:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727217AbfGJLDf (ORCPT ); Wed, 10 Jul 2019 07:03:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54917 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727030AbfGJLDe (ORCPT ); Wed, 10 Jul 2019 07:03:34 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from tariqt@mellanox.com) with ESMTPS (AES256-SHA encrypted); 10 Jul 2019 14:03:30 +0300 Received: from dev-l-vrt-206-006.mtl.labs.mlnx (dev-l-vrt-206-006.mtl.labs.mlnx [10.134.206.6]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x6AB3US0020650; Wed, 10 Jul 2019 14:03:30 +0300 From: Tariq Toukan To: Stephen Hemminger Cc: netdev@vger.kernel.org, moshe@mellanox.com, ayal@mellanox.com, Tariq Toukan Subject: [PATCH iproute2 master 2/3] devlink: Fix binary values print Date: Wed, 10 Jul 2019 14:03:20 +0300 Message-Id: <1562756601-19171-3-git-send-email-tariqt@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1562756601-19171-1-git-send-email-tariqt@mellanox.com> References: <1562756601-19171-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 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 Signed-off-by: Tariq Toukan --- 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) From patchwork Wed Jul 10 11:03:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 1130336 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 45kGWr4DNmz9s4V for ; Wed, 10 Jul 2019 21:03:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727291AbfGJLDf (ORCPT ); Wed, 10 Jul 2019 07:03:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54918 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727110AbfGJLDe (ORCPT ); Wed, 10 Jul 2019 07:03:34 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from tariqt@mellanox.com) with ESMTPS (AES256-SHA encrypted); 10 Jul 2019 14:03:30 +0300 Received: from dev-l-vrt-206-006.mtl.labs.mlnx (dev-l-vrt-206-006.mtl.labs.mlnx [10.134.206.6]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x6AB3US1020650; Wed, 10 Jul 2019 14:03:30 +0300 From: Tariq Toukan To: Stephen Hemminger Cc: netdev@vger.kernel.org, moshe@mellanox.com, ayal@mellanox.com, Tariq Toukan Subject: [PATCH iproute2 master 3/3] devlink: Remove enclosing array brackets binary print with json format Date: Wed, 10 Jul 2019 14:03:21 +0300 Message-Id: <1562756601-19171-4-git-send-email-tariqt@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1562756601-19171-1-git-send-email-tariqt@mellanox.com> References: <1562756601-19171-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 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 Signed-off-by: Tariq Toukan --- 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(); }