Message ID | 20230510-dcb-rewr-v1-5-83adc1f93356@microchip.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | David Ahern |
Headers | show |
Series | Introduce new dcb-rewr subcommand | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
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;
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;
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(-)