Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4625142imw; Tue, 12 Jul 2022 11:11:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sREOozNrL1qLJQ5chAPfqzf7QH1hWZe2DBATTIBDtr9GDOX0oKFZECiGpQM/FUrWVx/nJP X-Received: by 2002:a17:906:8470:b0:72b:5088:be5f with SMTP id hx16-20020a170906847000b0072b5088be5fmr13054269ejc.459.1657649500029; Tue, 12 Jul 2022 11:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657649500; cv=none; d=google.com; s=arc-20160816; b=xOzxa+EzRPuYsvh0RiV91ilqsNGe/dCl2mQfMAtmeBcuxrX7JjDYsX5VBGHlx/zupG hVixiX5j/BKk1fUnRxc4e4fTN4uJ4RCcOOUGy121nrMgK+flxi83RO9Cq4Y3OtSq49j+ tl+gZCWT0SH0rFNMC9l2/QjRuZm26Dv/vXwnHWP5tmL9NP92aQhhUNPNVg8EHKIKyLfS BmWssYDqcdbV5W+wQ1IFFF6W+do2Y1Q0KWUe0lybS7EJ2+87llNIWnNhCSBL+R/r6lJP iRfESYSJMXfNyR7wRpi65yzJKUK+oyI07rgDURZE851RiRiL116S+k5oY35CYs/DXxWG Ghdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DGz+BY3xnZELHM6ryZfTEhs4BFSh6HG4c9xaRhOdDBo=; b=oW6o/aVVlL4TDICnrbsdq07EZvtfgIuBypEOhKB4aGyFR9eyH9xdHxIjw4xy5dO0GE 8geEKXb9iVGyKwHDE5UB4Npj6nRbkC//jTTZSYEl0zrzdLn2p/YxnStUfvBvAjqIO4us wDYHOmgVM+bv0A8oDEGXnVR3AXtMt/+K82DvY4X/cW4JbQXGu8tZUDXLRyce31phuhIj u4Id72TavOSLpi0TvubaG2brThaxKWeA59dmCT58NQjkFvgxxqMABGLjmxkXDcFknewq /FFLtRlE1aUUQ7bSXNvdL4GSzI6Uo9iD7P+PJoEfY1YFH/tVYenlu6cvt1bwHi56fvb4 TCsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20210112.gappssmtp.com header.s=20210112 header.b=eATREUwe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv11-20020a17090760cb00b006fe9e0df24dsi12882864ejc.876.2022.07.12.11.11.10; Tue, 12 Jul 2022 11:11:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@resnulli-us.20210112.gappssmtp.com header.s=20210112 header.b=eATREUwe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231567AbiGLSIe (ORCPT + 99 others); Tue, 12 Jul 2022 14:08:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbiGLSI3 (ORCPT ); Tue, 12 Jul 2022 14:08:29 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF81AB1950 for ; Tue, 12 Jul 2022 11:08:26 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id r14so12322841wrg.1 for ; Tue, 12 Jul 2022 11:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DGz+BY3xnZELHM6ryZfTEhs4BFSh6HG4c9xaRhOdDBo=; b=eATREUwe5KadLfNjw8E2OW3DLp6+xaXH9pE7xPuScqZ/3UTqteOJA4331fRQnqqLyl oAM//6GD5o7X7rzo41Dhzgi//jvDgdDAKpaN6K/IXpbcpKZqoNClJIXZpeTsMfaOqiMz TopiZP54AuO0nG/77QILQysk/4jc75EA07J7SD1PyzpZXuw/p8mo/umz5Jb8o2Q4VKNw wre9k0na3PvIpnwuEQ78yb4LnMB8u6GB3fpwoGWG6PfDfPmprrhxFsSyouCH2uOzGG2E uDn9ts3DGWA7aREWeNVDwcVvNrYV25QjtZO9hgCJCl1Fvb28MUyhtojAqU+CzDcYULLm psPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DGz+BY3xnZELHM6ryZfTEhs4BFSh6HG4c9xaRhOdDBo=; b=Fc4e+4lQO/J6PYCT+AGcyZDyJ7Vn0IJfv+tUoEk8PLh/eyJRrw7VX20cCRxYTIUE3+ F38tLWCWmAdRLMWU3/dwtYtR78uqNwq6Y+71z8MjjPpoQcBdrzHG5xwLFpyZtoLSRWXS SCwFams1iQM7kdIcbtDlz0aCwHFg/h2r6L2RdDQxjawXYGjpV+CBY4FxxYexspMJN+rC tGtVDri0cXwKarqXfKRveIA+GA+m9+Ci/KkqZcKNHrFy7pLDh3lw59GTsaBey3Yfp5Ft 2vnhDOsadIVzA/Wy0+SNEaA5uNIN5t3bGjbZFG1rnOG0nM4IWpbgNSHPwlMzy5Q7p41y M7Ow== X-Gm-Message-State: AJIora9ZFm5AbUmNoAI/57K/sEJtjhnpgGDn5/bsLgHEw8CkHS9+4N/M dZJ3R+HUXbla/rh4Moi6JrTmLAqQUwxZB2We5Hk= X-Received: by 2002:adf:fcca:0:b0:21d:68ff:2e5a with SMTP id f10-20020adffcca000000b0021d68ff2e5amr23300797wrs.453.1657649305307; Tue, 12 Jul 2022 11:08:25 -0700 (PDT) Received: from localhost (host-213-179-129-39.customer.m-online.net. [213.179.129.39]) by smtp.gmail.com with ESMTPSA id d20-20020a05600c4c1400b003a1980d55c4sm12883840wmp.47.2022.07.12.11.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 11:08:24 -0700 (PDT) Date: Tue, 12 Jul 2022 20:08:23 +0200 From: Jiri Pirko To: Vikas Gupta Cc: Jiri Pirko , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , dsahern@kernel.org, stephen@networkplumber.org, Eric Dumazet , pabeni@redhat.com, ast@kernel.org, leon@kernel.org, linux-doc@vger.kernel.org, corbet@lwn.net, Michael Chan , Andrew Gospodarek Subject: Re: [PATCH net-next v2 1/3] devlink: introduce framework for selftests Message-ID: References: <20220628164241.44360-1-vikas.gupta@broadcom.com> <20220707182950.29348-1-vikas.gupta@broadcom.com> <20220707182950.29348-2-vikas.gupta@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tue, Jul 12, 2022 at 06:41:49PM CEST, vikas.gupta@broadcom.com wrote: >Hi Jiri, > >On Tue, Jul 12, 2022 at 11:58 AM Jiri Pirko wrote: >> >> Tue, Jul 12, 2022 at 08:16:11AM CEST, vikas.gupta@broadcom.com wrote: >> >Hi Jiri, >> > >> >On Mon, Jul 11, 2022 at 6:10 PM Jiri Pirko wrote: >> > >> >> Thu, Jul 07, 2022 at 08:29:48PM CEST, vikas.gupta@broadcom.com wrote: [...] >> >> > * enum devlink_trap_action - Packet trap action. >> >> > * @DEVLINK_TRAP_ACTION_DROP: Packet is dropped by the device and a copy >> >> is not >> >> >@@ -576,6 +598,10 @@ enum devlink_attr { >> >> > DEVLINK_ATTR_LINECARD_TYPE, /* string */ >> >> > DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES, /* nested */ >> >> > >> >> >+ DEVLINK_ATTR_SELFTESTS_MASK, /* u32 */ >> >> >> >> I don't see why this is u32 bitset. Just have one attr per test >> >> (NLA_FLAG) in a nested attr instead. >> >> >> > >> >As per your suggestion, for an example it should be like as below >> > >> > DEVLINK_ATTR_SELFTESTS, /* nested */ >> > >> > DEVLINK_ATTR_SELFTESTS_SOMETEST1 /* flag */ >> > >> > DEVLINK_ATTR_SELFTESTS_SOMETEST2 /* flag */ >> >> Yeah, but have the flags in separate enum, no need to pullute the >> devlink_attr enum by them. >> >> >> > >> >.... >> > >> >..... >> > >> > DEVLINK_ATTR_SLEFTESTS_RESULT_VAL, /* u8 */ >> > >> > >> > >> > If we have this way then we need to have a mapping (probably a function) >> >for drivers to tell them what tests need to be executed based on the flags >> >that are set. >> > Does this look OK? >> > The rationale behind choosing a mask is that we could directly pass the >> >mask-value to the drivers. >> >> If you have separate enum, you can use the attrs as bits internally in >> kernel. Add a helper that would help the driver to work with it. >> Pass a struct containing u32 (or u8) not to drivers. Once there are more >> tests than that, this structure can be easily extended and the helpers >> changed. This would make this scalable. No need for UAPI change or even >> internel driver api change. > >As per your suggestion, selftest attributes can be declared in separate >enum as below > >enum { > > DEVLINK_SELFTEST_SOMETEST, /* flag */ > > DEVLINK_SELFTEST_SOMETEST1, > > DEVLINK_SELFTEST_SOMETEST2, > >.... > >...... > > __DEVLINK_SELFTEST_MAX, > > DEVLINK_SELFTEST_MAX = __DEVLINK_SELFTEST_MAX - 1 > >}; >Below examples could be the flow of parameters/data from user to >kernel and vice-versa > > >Kernel to user for show command . Users can know what all tests are >supported by the driver. A return from kernel to user. >______ >|NEST | >|_____ |TEST1|TEST4|TEST7|... > > >User to kernel to execute test: If user wants to execute test4, test8, test1... >______ >|NEST | >|_____ |TEST4|TEST8|TEST1|... > > >Result Kernel to user execute test RES(u8) >______ >|NEST | >|_____ |RES4|RES8|RES1|... Hmm, I think it is not good idea to rely on the order, a netlink library can perhaps reorder it? Not sure here. > >Results are populated in the same order as the user passed the TESTs >flags. Does the above result format from kernel to user look OK ? >Else we need to have below way to form a result format, a nest should >be made for result> but since test flags are in different enum other than >devlink_attr and RES being part of devlink_attr, I believe it's not >good practice to make the below structure. Not a structure, no. Have it as another nest (could be the same attr as the parent nest: ______ |NEST | |_____ |NEST| |NEST| |NEST| TEST4,RES4 TEST8,RES8 TEST1, RES1 also, it is flexible to add another attr if needed (like maybe result message string containing error message? IDK). >______ >|NEST | >|_____ | TEST4, RES4|TEST8,RES8|TEST1,RES1|... > >Let me know if my understanding is correct. [...]