[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a70812b5-63d4-461c-8458-b31e1ad25910@nvidia.com>
Date: Fri, 1 Mar 2024 17:29:14 -0800
From: William Tu <witu@...dia.com>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org, jiri@...dia.com, bodong@...dia.com,
tariqt@...dia.com, yossiku@...dia.com, kuba@...nel.org
Subject: Re: [PATCH RFC v2 iproute2-next] devlink: Add eswitch attr option for
shared descriptors
On 2/29/24 7:39 PM, Stephen Hemminger wrote:
> External email: Use caution opening links or attachments
>
>
> On Fri, 1 Mar 2024 04:02:14 +0200
> William Tu <witu@...dia.com> wrote:
>
>> + } else if ((dl_argv_match(dl, "shrdesc-mode")) &&
> So devlink has its own match problem.
>
> We stopped allowing new match arguments because they create
> ordering conflicts. For example in your new code if "shrdesc" is
> passed it matches the mode field.
Hi Stephen,
Thanks! in this case how do I introduce new argments?
Should I introduce dl_argv_exact_match like below, or should I handle it
specifically in "cmd_dev_eswitch_set(struct dl *dl)".
Thanks
William
diff --git a/devlink/devlink.c b/devlink/devlink.c
index affc29eb7cad..1521c2c24acf 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -466,6 +466,14 @@ static bool dl_argv_match(struct dl *dl, const char
*pattern)
return strcmpx(dl_argv(dl), pattern) == 0;
}
+static bool dl_argv_exact_match(struct dl *dl, const char *pattern)
+{
+ if (dl_argc(dl) == 0 || strlen(dl_argv(dl)) != strlen(pattern))
+ return false;
+
+ return strcmpx(dl_argv(dl), pattern) == 0;
+}
+
static bool dl_no_arg(struct dl *dl)
{
return dl_argc(dl) == 0;
@@ -1921,7 +1929,7 @@ static int dl_argv_parse(struct dl *dl, uint64_t
o_required,
if (err)
return err;
o_found |= DL_OPT_ESWITCH_ENCAP_MODE;
- } else if ((dl_argv_match(dl, "shrdesc-mode")) &&
+ } else if ((dl_argv_exact_match(dl, "shrdesc-mode")) &&
(o_all & DL_OPT_ESWITCH_SHRDESC_MODE)) {
const char *typestr;
@@ -1934,7 +1942,7 @@ static int dl_argv_parse(struct dl *dl, uint64_t
o_required,
if (err)
return err;
o_found |= DL_OPT_ESWITCH_SHRDESC_MODE;
- } else if (dl_argv_match(dl, "shrdesc-count") &&
+ } else if (dl_argv_exact_match(dl, "shrdesc-count") &&
(o_all & DL_OPT_ESWITCH_SHRDESC_COUNT)) {
dl_arg_inc(dl);
err = dl_argv_uint32_t(dl,
&opts->eswitch_shrdesc_count);
Powered by blists - more mailing lists