From: Petr Machata <petrm@nvidia.com>
To: Daniel Machon <daniel.machon@microchip.com>
Cc: <netdev@vger.kernel.org>, <dsahern@kernel.org>,
<stephen@networkplumber.org>, <petrm@nvidia.com>,
<UNGLinuxDriver@microchip.com>
Subject: Re: [PATCH iproute2-next 5/9] dcb: app: modify dcb_app_parse_mapping_cb for dcb-rewr reuse
Date: Tue, 23 May 2023 18:29:28 +0200 [thread overview]
Message-ID: <878rdf57m9.fsf@nvidia.com> (raw)
In-Reply-To: <20230510-dcb-rewr-v1-5-83adc1f93356@microchip.com>
Daniel Machon <daniel.machon@microchip.com> writes:
> When parsing APP table entries, priority and protocol is assigned from
> value and key, respectively. Rewrite requires it opposite.
>
> Modify the existing dcb_app_parse_mapping_cb for dcb-rewr reuse, by
> using the newly introduced dcbnl attribute in the dcb_app_table struct.
>
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
> ---
> dcb/dcb_app.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/dcb/dcb_app.c b/dcb/dcb_app.c
> index 23d6bb2a0013..46af67112748 100644
> --- a/dcb/dcb_app.c
> +++ b/dcb/dcb_app.c
> @@ -232,10 +232,17 @@ void dcb_app_parse_mapping_cb(__u32 key, __u64 value, void *data)
> struct dcb_app_parse_mapping *pm = data;
> struct dcb_app app = {
> .selector = pm->selector,
> - .priority = value,
> - .protocol = key,
> };
>
> + if (pm->tab->attr == DCB_ATTR_IEEE_APP_TABLE) {
> + app.priority = value;
> + app.protocol = key;
> +
> + } else {
> + app.priority = key;
> + app.protocol = value;
> + }
> +
> if (pm->err)
> return;
? (Or thereabouts... again, not tested.)
modified dcb/dcb_app.c
@@ -225,22 +225,40 @@ static void dcb_app_table_sort(struct dcb_app_table *tab)
struct dcb_app_parse_mapping {
__u8 selector;
struct dcb_app_table *tab;
+ int (*push)(struct dcb_app_table *tab,
+ __u8 selector, __u32 key, __u64 value);
int err;
};
-static void dcb_app_parse_mapping_cb(__u32 key, __u64 value, void *data)
+static int dcb_app_push_app(struct dcb_app_table *tab,
+ __u8 selector, __u32 key, __u64 value)
{
- struct dcb_app_parse_mapping *pm = data;
struct dcb_app app = {
- .selector = pm->selector,
+ .selector = selector,
.priority = value,
.protocol = key,
};
+ return dcb_app_table_push(tab, &app);
+}
+
+static int dcb_app_push_rewr(struct dcb_app_table *tab,
+ __u8 selector, __u32 key, __u64 value)
+{
+ struct dcb_app app = {
+ .selector = selector,
+ .priority = key,
+ .protocol = value,
+ };
+ return dcb_app_table_push(tab, &app);
+}
+
+static void dcb_app_parse_mapping_cb(__u32 key, __u64 value, void *data)
+{
+ struct dcb_app_parse_mapping *pm = data;
if (pm->err)
return;
-
- pm->err = dcb_app_table_push(pm->tab, &app);
+ pm->err = pm->push(pm->tab, pm->selector, key, value);
}
static int dcb_app_parse_mapping_ethtype_prio(__u32 key, char *value, void *data)
@@ -640,6 +658,7 @@ static int dcb_cmd_app_parse_add_del(struct dcb *dcb, const char *dev,
{
struct dcb_app_parse_mapping pm = {
.tab = tab,
+ .push = dcb_app_push_app,
};
int ret;
next prev parent reply other threads:[~2023-05-23 16:35 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-22 18:41 [PATCH iproute2-next 0/9] Introduce new dcb-rewr subcommand Daniel Machon
2023-05-22 18:41 ` [PATCH iproute2-next 1/9] dcb: app: expose dcb-app functions in new header Daniel Machon
2023-05-23 11:18 ` Petr Machata
2023-05-24 6:39 ` Daniel.Machon
2023-05-24 9:28 ` Petr Machata
2023-05-22 18:41 ` [PATCH iproute2-next 2/9] dcb: app: add new dcbnl attribute field Daniel Machon
2023-05-22 18:41 ` [PATCH iproute2-next 3/9] dcb: app: modify dcb-app print functions for dcb-rewr reuse Daniel Machon
2023-05-22 21:33 ` Stephen Hemminger
2023-05-25 7:20 ` Daniel Machon
2023-05-23 13:23 ` Petr Machata
2023-05-24 6:47 ` Daniel.Machon
2023-05-24 9:37 ` Petr Machata
2023-05-22 18:41 ` [PATCH iproute2-next 4/9] dcb: app: modify dcb_app_table_remove_replaced() " Daniel Machon
2023-05-23 14:42 ` Petr Machata
2023-05-22 18:41 ` [PATCH iproute2-next 5/9] dcb: app: modify dcb_app_parse_mapping_cb " Daniel Machon
2023-05-23 16:29 ` Petr Machata [this message]
2023-05-22 18:41 ` [PATCH iproute2-next 6/9] dcb: rewr: add new dcb-rewr subcommand Daniel Machon
2023-05-23 16:35 ` Petr Machata
2023-05-24 6:51 ` Daniel.Machon
2023-05-22 18:41 ` [PATCH iproute2-next 7/9] man: dcb-rewr: add new manpage for dcb-rewr Daniel Machon
2023-05-23 16:56 ` Petr Machata
2023-05-22 18:41 ` [PATCH iproute2-next 8/9] man: dcb: add additional references under 'SEE ALSO' Daniel Machon
2023-05-22 18:41 ` [PATCH iproute2-next 9/9] man: dcb-app: clean up a few mistakes Daniel Machon
2023-05-23 16:49 ` Petr Machata
2023-05-24 6:56 ` Daniel.Machon
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=878rdf57m9.fsf@nvidia.com \
--to=petrm@nvidia.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=daniel.machon@microchip.com \
--cc=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/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;
as well as URLs for NNTP newsgroup(s).