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=-8.5 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,USER_AGENT_MUTT 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 1E624C43381 for ; Fri, 22 Feb 2019 18:09:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB67D205C9 for ; Fri, 22 Feb 2019 18:09:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="XNopVNMT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726572AbfBVSJA (ORCPT ); Fri, 22 Feb 2019 13:09:00 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42421 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725986AbfBVSJA (ORCPT ); Fri, 22 Feb 2019 13:09:00 -0500 Received: by mail-wr1-f68.google.com with SMTP id r5so3318419wrg.9 for ; Fri, 22 Feb 2019 10:08:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/VvsTug+4SBY+zaU+b99cdu7H58mPqovgp6MZK908FY=; b=XNopVNMTle23u26VSN8L2bGvl7yG9TLQHXYrR4S/C2Tp/EZCPcbGM3+/uOa5ECn0fT Wjn7AoIdnuHWzqvEmfBmtQ6f0Aeo0CXS4mB5qGrTTL6xEf7IKwQTp6+fpXf0cQPbC1Tv aKTyCIYUU42N+50J4nBOWL6NTxJd+JHf+61gEGKvEdXLjwoB3SeZiPM1jpvkGEQQTx/2 VQNIuvrOFfQICLv79cLD4YFRyTa8vfwSP53ahupYlKl5NtDHu05+BJGDdEtpVTxzzotz 7WDmrOV+XUe+C9HzEw9Qhp5BAfbJvaw5Dv/1Xj81ETgt6547bfn/cG5JJG5Nn3ZGFZIs MR4A== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/VvsTug+4SBY+zaU+b99cdu7H58mPqovgp6MZK908FY=; b=fALvjGj78zucFA+ruz91u9yJS+MnKWKxhS2A6AgxbjHUo2xx8OvZEN2IaFZnV6Pzby 7/u7eR6usBHscuCQcsGUi2iBTZri6v77rEdsByLetFKafGrT2mrI+wwV/kIaSWgx1gNH roZPN0pT2+7W6Rk+rfR8Y7pR0mWYML1tMbQLUf6dlvFboQsMmugapH5UczrnDCOJSmaS +fTikKsJ0EWKSQ8z5vpz6gCh8L41b5uz40p+ZBeY7tMsRBLh/q17NfyCvnOYnNBCZvfU LFsfmENbhD81l43aawmqOF1TpkcXzKx4BoXKajzRoHB5s7fJNMfAp/me8TfKObRrVoZh MZWg== X-Gm-Message-State: AHQUAuaJOiiXTpwcHBB1l8qKHmxCknthcX5gTIGmAPrhs7xQ3QdxlfZB 3L8uiRY/+0NZHE3unu+nrVLcaaIvA9Y= X-Google-Smtp-Source: AHgI3IY9g2bO/WqwvL39mmZ6qmm7k2AiVFRE0POWmT7DkAKAuQv1FbE2kE4fEQpCjW0R5USL4BiikQ== X-Received: by 2002:a5d:6a8e:: with SMTP id s14mr3843765wru.31.1550858937640; Fri, 22 Feb 2019 10:08:57 -0800 (PST) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id y139sm1585949wmd.22.2019.02.22.10.08.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 10:08:57 -0800 (PST) Date: Fri, 22 Feb 2019 18:59:15 +0100 From: Jiri Pirko To: Stephen Hemminger 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: <20190222175915.GB2759@nanopsycho.orion> 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> <20190222100125.20d8dd54@shemminger-XPS-13-9360> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190222100125.20d8dd54@shemminger-XPS-13-9360> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fri, Feb 22, 2019 at 07:01:25PM CET, stephen@networkplumber.org wrote: >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? Okay, I'll take care of it in March. Promise.