public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@nvidia.com>
To: Vikas Gupta <vikas.gupta@broadcom.com>
Cc: Jiri Pirko <jiri@resnulli.us>, Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	dsahern@kernel.org, stephen@networkplumber.org,
	Eric Dumazet <edumazet@google.com>,
	pabeni@redhat.com, ast@kernel.org, leon@kernel.org,
	linux-doc@vger.kernel.org, corbet@lwn.net,
	Michael Chan <michael.chan@broadcom.com>,
	Andrew Gospodarek <andrew.gospodarek@broadcom.com>
Subject: Re: [PATCH net-next v2 1/3] devlink: introduce framework for selftests
Date: Wed, 13 Jul 2022 09:28:12 +0200	[thread overview]
Message-ID: <Ys50DGXCi5lPaRBB@nanopsycho> (raw)
In-Reply-To: <CAHLZf_tzpG9J=_orUsD9xto_Q818S-YqOTFvWchFjRkR3LXhvA@mail.gmail.com>

Wed, Jul 13, 2022 at 08:40:50AM CEST, vikas.gupta@broadcom.com wrote:
>Hi Jiri,
>
>On Tue, Jul 12, 2022 at 11:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
>>
>> 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 <jiri@nvidia.com> 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 <jiri@nvidia.com> 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.
>> >>
>> >>
>> >> >
>> >> >....    <SOME MORE TESTS>
>> >> >
>> >> >.....
>> >> >
>> >> >        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 <test_flag,
>> >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).
>
>For above nesting we can have the attributes defined as below
>
>Attribute in  devlink_attr
>enum devlink_attr {
>  ....
>  ....
>        DEVLINK_SELFTESTS_INFO, /* nested */
>  ...
>...
>}
>
>enum devlink_selftests {
>        DEVLINK_SELFTESTS_SOMETEST0,   /* flag */
>        DEVLINK_SELFTESTS_SOMETEST1,
>        DEVLINK_SELFTESTS_SOMETEST2,
>        ...
>        ...
>}
>
>enum devlink_selftest_result {

for attrs, have "attr" in the name of the enum and "ATTR" in name of the
value.

>        DEVLINK_SELFTESTS_RESULT,       /* nested */
>        DEVLINK_SELFTESTS_TESTNUM,      /* u32  indicating the test

You can have 1 enum, containing both these and the test flags from
above.


>number in devlink_selftests enum */
>        DEVLINK_SELFTESTS_RESULT_VAL,   /* u8  skip, pass, fail.. */

Put enum name in the comment, instead of list possible values.


>        ...some future attrr...
>
>}
>enums in devlink_selftest_result can be put in devlink_attr though.

You can have them separate, I think it is about the time we try to put
new attrs what does not have potencial to be re-used to a separate enum.


>
>Does this look OK?
>
>Thanks,
>Vikas
>
>>
>>
>>
>> >______
>> >|NEST |
>> >|_____ | TEST4, RES4|TEST8,RES8|TEST1,RES1|...
>> >
>> >Let me know if my understanding is correct.
>>
>> [...]



  reply	other threads:[~2022-07-13  7:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220628164241.44360-1-vikas.gupta@broadcom.com>
2022-07-07 18:29 ` [PATCH net-next v2 0/3] add framework for selftests in devlink Vikas Gupta
2022-07-07 18:29   ` [PATCH net-next v2 1/3] devlink: introduce framework for selftests Vikas Gupta
2022-07-08  1:20     ` Jakub Kicinski
2022-07-10  9:00       ` Ido Schimmel
2022-07-08 14:48     ` kernel test robot
2022-07-11 12:40     ` Jiri Pirko
     [not found]       ` <CAHLZf_t9ihOQPvcQa8cZsDDVUX1wisrBjC30tHG_-Dz13zg=qQ@mail.gmail.com>
2022-07-12  6:28         ` Jiri Pirko
2022-07-12 16:41           ` Vikas Gupta
2022-07-12 18:08             ` Jiri Pirko
2022-07-13  6:40               ` Vikas Gupta
2022-07-13  7:28                 ` Jiri Pirko [this message]
2022-07-13 10:16                   ` Vikas Gupta
2022-07-13 10:22                     ` Jiri Pirko
2022-07-07 18:29   ` [PATCH net-next v2 2/3] bnxt_en: refactor NVM APIs Vikas Gupta
2022-07-07 18:29   ` [PATCH net-next v2 3/3] bnxt_en: implement callbacks for devlink selftests Vikas Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ys50DGXCi5lPaRBB@nanopsycho \
    --to=jiri@nvidia.com \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=ast@kernel.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stephen@networkplumber.org \
    --cc=vikas.gupta@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox