From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6BDFC43381 for ; Fri, 22 Feb 2019 18:01:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 865782075C for ; Fri, 22 Feb 2019 18:01:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="MZgfWkZs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726555AbfBVSB3 (ORCPT ); Fri, 22 Feb 2019 13:01:29 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34149 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbfBVSB3 (ORCPT ); Fri, 22 Feb 2019 13:01:29 -0500 Received: by mail-pl1-f194.google.com with SMTP id d15so1441510plr.1 for ; Fri, 22 Feb 2019 10:01:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C0YrdczN+uR3k4/tyOiBnyXKlty5QsOz+gfZCsKRQac=; b=MZgfWkZsnJVhP4KJEsQl+aorZqEMPXGScTzu5IYq/nDoMLVvrQR1VI3WrsCVCc39X3 ArqqFpO11pDIumlUpRGsA0QBfxTYM4fKjLaw6t1O130HIArcLVUDuaMm6qutgZHnMeeN Dr3ta4Qcequ2monBKYswMBRWCCbWT1RFIZAoLZeVkAMasGKUvmCcK4sGPCl9HjtfOKSu cz8INwBtLottKI7kJ8CciOTFVyArS+xx5Edeikg+zsbnSADZetEAs4uRvZnAqetbJEzL +oDke67RFud3kVl/IdQK8QVtKKR9N3rkgfILczJi/NJwfgVCTVh2MhhYKc7Y8oS03X9h RmqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C0YrdczN+uR3k4/tyOiBnyXKlty5QsOz+gfZCsKRQac=; b=O+z0AOBA5fljOgFg+BJ1BlRtDRRb31DGlpKDbPx0tQhBwhsmR/QAnrfcEK/ZWiZJgt DBkpo0HX2jy8KcgrMC+I/uepc9FSMYeGzxtjfpdqxzGEfdX0F34lGasxOv7mcSMmUpj9 AuhQOg0y2r+ptJ+hVt9vFWDPEDWyAohyNzchpPVKK1+a+ObObybidkzgnF0vwcd3x7Ql xczRuEwNh0lBpHHzbvTJMw9B2vlwLFTUmZpKbwb91Ut5107GqQt8DFnxgc+qMJl8V9kf mrvqQy6+/VZdRmJ4u+kowoml53QIjDaVirqtIP3l6UU/+tVkSN601wgBoeujV6q8nlXp zv/A== X-Gm-Message-State: AHQUAubEEsS40xM8k8EN8Q9x8/N2+ZDs4H+dwlHUPMcNgSkFbcOITumj adaVOkgfBu3folGaFeu0uGjRug== X-Google-Smtp-Source: AHgI3IapQwNS/mPGsJcjHWBgu6vx6xMfC6m2fQrV+C/p9IcD1roV3c9B+dwiFoevA7NBClBxtC+4LA== X-Received: by 2002:a17:902:9306:: with SMTP id bc6mr5283449plb.59.1550858488287; Fri, 22 Feb 2019 10:01:28 -0800 (PST) Received: from shemminger-XPS-13-9360 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id e26sm1243990pfd.124.2019.02.22.10.01.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 10:01:28 -0800 (PST) Date: Fri, 22 Feb 2019 10:01:25 -0800 From: Stephen Hemminger To: Jiri Pirko Cc: Aya Levin , David Ahern , netdev@vger.kernel.org, Jiri Pirko , Moshe Shemesh , Eran Ben Elisha Subject: Re: [PATCH v2 iproute2-next 04/11] devlink: Add helper functions for name and value separately Message-ID: <20190222100125.20d8dd54@shemminger-XPS-13-9360> In-Reply-To: <20190222085832.GA2254@nanopsycho> References: <1550756567-18227-1-git-send-email-ayal@mellanox.com> <1550756567-18227-5-git-send-email-ayal@mellanox.com> <20190221100211.28cef41a@shemminger-XPS-13-9360> <20190222085832.GA2254@nanopsycho> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 22 Feb 2019 09:58:32 +0100 Jiri Pirko wrote: > Thu, Feb 21, 2019 at 07:02:11PM CET, stephen@networkplumber.org wrote: > >On Thu, 21 Feb 2019 15:42:40 +0200 > >Aya Levin wrote: > > > >> Add a new helper functions which outputs only values (without name > >> label) for different types: boolean, uint, uint64, string and binary. > >> In addition add a helper function which prints only the name label. > >> > >> Signed-off-by: Aya Levin > >> Reviewed-by: Moshe Shemesh > >> --- > >> devlink/devlink.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- > >> 1 file changed, 65 insertions(+), 1 deletion(-) > >> > >> diff --git a/devlink/devlink.c b/devlink/devlink.c > >> index b073ae020d52..5d69c4f24f29 100644 > >> --- a/devlink/devlink.c > >> +++ b/devlink/devlink.c > >> @@ -1588,7 +1588,6 @@ static void pr_out_port_handle_end(struct dl *dl) > >> pr_out("\n"); > >> } > >> > >> - > >> static void pr_out_str(struct dl *dl, const char *name, const char *val) > >> { > >> if (dl->json_output) { > >> @@ -1636,6 +1635,71 @@ 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) > >> +{ > >> + if (dl->json_output) > >> + jsonw_bool(dl->jw, value); > >> + else > >> + pr_out(" %s", value ? "true" : "false"); > >> +} > >> + > >> +static void pr_out_uint_value(struct dl *dl, unsigned int value) > >> +{ > >> + if (dl->json_output) > >> + jsonw_uint(dl->jw, value); > >> + else > >> + pr_out(" %u", value); > >> +} > >> + > >> +static void pr_out_uint64_value(struct dl *dl, uint64_t value) > >> +{ > >> + if (dl->json_output) > >> + jsonw_u64(dl->jw, value); > >> + else > >> + pr_out(" %lu", value); > >> +} > >> + > >> +static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len) > >> +{ > >> + int i = 1; > >> + > >> + if (dl->json_output) > >> + jsonw_start_array(dl->jw); > >> + else > >> + pr_out("\n"); > >> + > >> + while (i < len) { > >> + if (dl->json_output) { > >> + jsonw_printf(dl->jw, "%d", data[i]); > >> + } else { > >> + pr_out(" %02x", data[i]); > >> + if (!(i % 16)) > >> + pr_out("\n"); > >> + } > >> + i++; > >> + } > >> + if (dl->json_output) > >> + jsonw_end_array(dl->jw); > >> + else if ((i - 1) % 16) > >> + pr_out("\n"); > >> +} > >> + > >> +static void pr_out_str_value(struct dl *dl, const char *value) > >> +{ > >> + if (dl->json_output) > >> + jsonw_string(dl->jw, value); > >> + else > >> + pr_out(" %s", value); > >> +} > >> + > >> +static void pr_out_name(struct dl *dl, const char *name) > >> +{ > >> + if (dl->json_output) > >> + jsonw_name(dl->jw, name); > >> + else > >> + pr_out(" %s:", name); > >> +} > >> + > >> static void pr_out_region_chunk_start(struct dl *dl, uint64_t addr) > >> { > >> if (dl->json_output) { > > > >NAK > > > >Please convert devlink to use existing iproute2 json_print infrasructure > >rather than reinventing it. > > That requires whole devlink/devlink.c code change. Could this be done as > a follow-up? There is a tradeoff, if more code creeps in it is harder to do the code change. Can you commit to a timeframe to convert the JSON support code?