Add pcp-prio and new apptrust subcommand
Subsystems (2)
v3 cover Add pcp-prio and new apptrust subcommand
This patch series makes use of the newly introduced [1] DCB_APP_SEL_PCP selector, for PCP/DEI prioritization, and DCB_ATTR_IEEE_APP_TRUST attribute for configuring per-selector trust and trust-order.
========================================================================
New parameter "pcp-prio" to existing "app" subcommand:
========================================================================
A new pcp-prio parameter has been added to the app subcommand, which can be used to classify traffic based on PCP and DEI from the VLAN header. PCP and DEI is specified in a combination of numerical and symbolic form, where 'de' (drop-eligible) means DEI=1 and 'nd' (not-drop-eligible) means DEI=0.
Map PCP 1 and DEI 0 to priority 1
$ dcb app add dev eth0 pcp-prio 1nd:1
Map PCP 1 and DEI 1 to priority 1
$ dcb app add dev eth0 pcp-prio 1de:1
========================================================================
New apptrust subcommand for configuring per-selector trust and trust order:
========================================================================
This new command currently has a single parameter, which lets you specify an ordered list of trusted selectors. The microchip sparx5 driver is already enabled to offload said list of trusted selectors. The new command has been given the name apptrust, to indicate that the trust covers APP table selectors only. I found that 'apptrust' was better than plain 'trust' as the latter does not indicate the scope of what is to be trusted.
Example:
Trust selectors dscp and pcp, in that order:
$ dcb apptrust set dev eth0 order dscp pcp
Trust selectors ethtype, stream-port and pcp, in that order
$ dcb apptrust set dev eth0 order ethtype stream-port pcp
Show the trust order
$ dcb apptrust show dev eth0 order order: ethtype stream-port pcp
A concern was raised here [2], that 'apptrust' would not work well with matches(), so instead strcmp() has been used to match for the new subcommand, as suggested here [3]. Same goes with pcp-prio parameter for dcb app.
The man page for dcb_app has been extended to cover the new pcp-prio parameter, and a new man page for dcb_apptrust has been created.
[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/
[3] https://lore.kernel.org/netdev/Y0fP+9C0tE7P2xyK@shredder/
================================================================================
v2 -> v3:
- Add macro for maximum pcp/dei value.
v1 -> v2:
- Modified dcb_cmd_apptrust_set() to allow multiple consecutive parameters.
- Added dcb_apptrust_print() to print everything in case of no argument.
- Renamed pcp keys 0-7 to 0nd-7nd.
- Renamed selector names in dcb-apptrust to reflect names used in dcb-app.
- Updated dcb-app manpage to reflect new selector names, and removed part about hardware offload.
- Updated dcb-apptrust manpage to reflect new selector names, and modified the description of the 'order' parameter.
- Replaced uses of parse_one_of() with loops, for new 1nd:1 semantics to be parsed correctly, and not printing an error if selector was not found in list.
Daniel Machon (2):
dcb: add new pcp-prio parameter to dcb app
dcb: add new subcommand for apptrust
dcb/Makefile | 3 +- dcb/dcb.c | 4 +- dcb/dcb.h | 7 + dcb/dcb_app.c | 142 ++++++++++++++++++- dcb/dcb_apptrust.c | 307 ++++++++++++++++++++++++++++++++++++++++ man/man8/dcb-app.8 | 32 +++++ man/man8/dcb-apptrust.8 | 109 ++++++++++++++ 7 files changed, 595 insertions(+), 9 deletions(-) create mode 100644 dcb/dcb_apptrust.c create mode 100644 man/man8/dcb-apptrust.8
--
2.34.1
PATCH v3 1/2 dcb: add new pcp-prio parameter to dcb app
Add new pcp-prio parameter to the app subcommand, which can be used to classify traffic based on PCP and DEI from the VLAN header. PCP and DEI is specified in a combination of numerical and symbolic form, where 'de' (drop-eligible) means DEI=1 and 'nd' (not-drop-eligible) means DEI=0.
Map PCP 1 and DEI 0 to priority 1
$ dcb app add dev eth0 pcp-prio 1nd:1
Map PCP 1 and DEI 1 to priority 1
$ dcb app add dev eth0 pcp-prio 1de:1
Internally, PCP and DEI is encoded in the protocol field of the dcb_app struct. Each combination of PCP and DEI maps to a priority, thus needing a range of 0-15. A well formed dcb_app entry for PCP/DEI prioritization, could look like:
struct dcb_app pcp = {
.selector = DCB_APP_SEL_PCP,
.priority = 7,
.protocol = 15
}For mapping PCP=7 and DEI=1 to Prio=7.
Also, three helper functions for translating between std and non-std APP selectors, have been added to dcb_app.c and exposed through dcb.h.
--- dcb/dcb.h | 3 + dcb/dcb_app.c | 140 +++++++++++++++++++++++++++++++++++++++++++-- man/man8/dcb-app.8 | 32 +++++++++++ 3 files changed, 169 insertions(+), 6 deletions(-)
dcb/dcb.h +3 -0
@@ -57,6 +57,9 @@ void dcb_print_array_kw(const __u8 *array, size_t array_size,/* dcb_app.c */ int dcb_cmd_app (struct dcb *dcb,int argc,char **argv); +enum ieee_attrs_app dcb_app_attr_type_get (__u8 selector); +bool dcb_app_attr_type_validate (enum ieee_attrs_app type); +bool dcb_app_selector_validate (enum ieee_attrs_app type,__u8 selector);/* dcb_buffer.c */
dcb/dcb_app.c +134 -6
246 lines not on this page · raw message
man/man8/dcb-app.8 +32 -0
@@ -23,6 +23,7 @@ the DCB (Data Center Bridging) subsystem .RB "[ " dgram-port-prio " ]" .RB "[ " port-prio " ]" .RB "[ " dscp-prio " ]" +.RB "[ " pcp-prio " ]" .ti -8 .B dcb ets " { " add " | " del " | " replace " } " dev
@@ -33,6 +34,7 @@ the DCB (Data Center Bridging) subsystem .RB "[ " dgram-port-prio " " \fIPORT-MAP\fB " ]" .RB "[ " port-prio " " \fIPORT-MAP\fB " ]" .RB "[ " dscp-prio " " \fIDSCP-MAP\fB " ]" +.RB "[ " pcp-prio " " \fIPCP-MAP\fB " ]" .ti -8 .IR PRIO-LIST " := [ " PRIO-LIST " ] " PRIO
@@ -55,6 +57,12 @@ the DCB (Data Center Bridging) subsystem .ti -8 .IR DSCP-MAPPING " := { " DSCP " | " \fBall " }" \fB:\fIPRIO\fR +.ti -8 +.IR PCP-MAP " := [ " PCP-MAP " ] " PCP-MAPPING + +.ti -8 +.IR PCP-MAPPING " := " PCP\fB:\fIPRIO\fR + .ti -8 .IR ET " := { " \fB0x600\fR " .. " \fB0xffff\fR " }"
@@ -64,6 +72,9 @@ the DCB (Data Center Bridging) subsystem .ti -8 .IR DSCP " := { " \fB0\fR " .. " \fB63\fR " }" +.ti -8 +.IR PCP " := { " \fB0(nd/de)\fR " .. " \fB7(nd/de)\fR " }" + .ti -8 .IR PRIO " := { " \fB0\fR " .. " \fB7\fR " }"
@@ -182,6 +193,17 @@ command line option .B -N turns the show translation off. +.TP +.B pcp-prio \fIPCP-MAP +\fIPCP-MAP\fR uses the array parameter syntax, see +.BR dcb (8) +for details. Keys are PCP/DEI. Values are priorities assigned to traffic with +matching PCP/DEI. PCP/DEI values are written as a combination of numeric- and +symbolic values, to accommodate for both. PCP always in numerical form e.g +0 .. 7 and DEI in symbolic form e.g 'de' (drop-eligible), indicating that the +DEI bit is 1 or 'nd' (not-drop-eligible), indicating that the DEI bit is 0. +In combination 2de:1 translates to a mapping of PCP=2 and DEI=1 to priority 1. + .SH EXAMPLE & USAGE Prioritize traffic with DSCP 0 to priority 0, 24 to 3 and 48 to 6:
@@ -221,6 +243,16 @@ Flush all DSCP rules: .br (nothing) +Add a rule to map traffic with PCP 1 and DEI 0 to priority 1 and PCP 2 and DEI 1 +to priority 2: + +.P +# dcb app add dev eth0 pcp-prio 1nd:1 2de:2 +.br +# dcb app show dev eth0 pcp-prio +.br +pcp-prio 1nd:1 2de:2 + .SH EXIT STATUS Exit status is 0 if command was successful or a positive integer upon failure.
Signature · 1 line
2.34.1
Re: [PATCH iproute2-next v3 1/2] dcb: add new pcp-prio parameter to dcb app
dcb/dcb_app.c static int dcb_app_print_key_dscp(__u16 protocol) · line 434
Quoted 10 lines · On Fri, 2 Dec 2022 10:22:34 +0100 Daniel Machon <[email protected]>…
dcb/dcb_app.c +10
-0+static int dcb_app_print_key_pcp (__u16 protocol) +{ +/* Print in numerical form, if protocol value is out-of-range */ +if (protocol >DCB_APP_PCP_MAX ) { +fprintf (stderr,"Unknown PCP key: %d\n" , protocol); +return print_uint (PRINT_ANY ,NULL ,"%d:" , protocol); + } + +return print_string (PRINT_ANY ,NULL ,"%s:" , pcp_names[protocol]); +}
This is not an application friendly way to produce JSON output. You need to put a key on each one, and value should not contain colon.
Re: [PATCH iproute2-next v3 1/2] dcb: add new pcp-prio parameter to dcb app
Quoted 5 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
On Fri, 2 Dec 2022 10:22:34 +0100
Daniel Machon <[email protected]> wrote:
Quoted 13 lines
dcb/dcb_app.c static int dcb_app_print_key_dscp(__u16 protocol) · line 434
Quoted 10 lines
dcb/dcb_app.c +10
-0+static int dcb_app_print_key_pcp (__u16 protocol) +{ +/* Print in numerical form, if protocol value is out-of-range */ +if (protocol >DCB_APP_PCP_MAX ) { +fprintf (stderr,"Unknown PCP key: %d\n" , protocol); +return print_uint (PRINT_ANY ,NULL ,"%d:" , protocol); + } + +return print_string (PRINT_ANY ,NULL ,"%s:" , pcp_names[protocol]); +}This is not an application friendly way to produce JSON output. You need to put a key on each one, and value should not contain colon.
Hi Stephen,
Trying to understand your comment.
Are you talking about not producing any JSON output with the symbolic PCP values? eg. ["1de", 1] -> [8, 1]. So basically print with PRINT_FP in case of printing in JSON context?
/Daniel
Re: [PATCH iproute2-next v3 1/2] dcb: add new pcp-prio parameter to dcb app
Quoted 21 lines · On Sun, 4 Dec 2022 22:27:40 +0000 <[email protected]> wrote:
Quoted 5 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
On Fri, 2 Dec 2022 10:22:34 +0100
Daniel Machon <[email protected]> wrote:Quoted 13 lines
dcb/dcb_app.c static int dcb_app_print_key_dscp(__u16 protocol) · line 434
Quoted 10 lines
dcb/dcb_app.c +10
-0+static int dcb_app_print_key_pcp (__u16 protocol) +{ +/* Print in numerical form, if protocol value is out-of-range */ +if (protocol >DCB_APP_PCP_MAX ) { +fprintf (stderr,"Unknown PCP key: %d\n" , protocol); +return print_uint (PRINT_ANY ,NULL ,"%d:" , protocol); + } + +return print_string (PRINT_ANY ,NULL ,"%s:" , pcp_names[protocol]); +}This is not an application friendly way to produce JSON output. You need to put a key on each one, and value should not contain colon.
Hi Stephen,
Quoted 7 lines
Trying to understand your comment.
Are you talking about not producing any JSON output with the symbolic PCP values? eg. ["1de", 1] -> [8, 1]. So basically print with
PRINT_FPin case of printing in JSON context?/Daniel
What does output look like in json and non-json versions?
My concern that the json version would be awkward and have colons in it, but looks like it won't.
For the unknown key type is printing error necessary? Maybe just show it in numeric form.
Re: [PATCH iproute2-next v3 1/2] dcb: add new pcp-prio parameter to dcb app
Quoted 21 lines
Quoted 21 lines
Quoted 16 lines
dcb/dcb_app.c static int dcb_app_print_key_dscp(__u16 protocol) · line 434
Quoted 10 lines · On Fri, 2 Dec 2022 10:22:34 +0100 Daniel Machon <[email protected]>…
dcb/dcb_app.c +10
-0+static int dcb_app_print_key_pcp (__u16 protocol) +{ +/* Print in numerical form, if protocol value is out-of-range */ +if (protocol >DCB_APP_PCP_MAX ) { +fprintf (stderr,"Unknown PCP key: %d\n" , protocol); +return print_uint (PRINT_ANY ,NULL ,"%d:" , protocol); + } + +return print_string (PRINT_ANY ,NULL ,"%s:" , pcp_names[protocol]); +}This is not an application friendly way to produce JSON output. You need to put a key on each one, and value should not contain colon.
Hi Stephen,
Trying to understand your comment.
Quoted 7 lines
Quoted 5 lines
Are you talking about not producing any JSON output with the symbolic PCP values? eg. ["1de", 1] -> [8, 1]. So basically print with
PRINT_FPin case of printing in JSON context?/Daniel
What does output look like in json and non-json versions?
non-JSON: pcp-prio 1de:1
JSON : {"pcp_prio":[["1de",1]]}
Quoted 2 lines
My concern that the json version would be awkward and have colons in it, but looks like it won't.
Yeah, the "%s:" format is only used in non-JSON context, so we are good here.
Quoted 2 lines
For the unknown key type is printing error necessary? Maybe just show it in numeric form.
No not necessary, I'll get rid of it.
/ Daniel
Re: [PATCH iproute2-next v3 1/2] dcb: add new pcp-prio parameter to dcb app
Quoted 6 lines · On Mon, 5 Dec 2022 09:19:06 +0000 <[email protected]> wrote:
Quoted 6 lines
Quoted 6 lines
Trying to understand your comment.
Are you talking about not producing any JSON output with the symbolic PCP values? eg. ["1de", 1] -> [8, 1]. So basically print with
PRINT_FPin case of printing in JSON context?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
/Daniel
What does output look like in json and non-json versions?
non-JSON: pcp-prio 1de:1
JSON : {"pcp_prio":[["1de",1]]}
Would the JSON be better as:
{ "pcp_prio" :[ { "1de":1 } ] }It looks like the PCP values are both unique and used in a name/value manner.
Quoted 11 lines
Quoted 3 lines
My concern that the json version would be awkward and have colons in it, but looks like it won't.
Yeah, the "%s:" format is only used in non-JSON context, so we are good here.
Quoted 2 lines
For the unknown key type is printing error necessary? Maybe just show it in numeric form.
No not necessary, I'll get rid of it.
Re: [PATCH iproute2-next v3 1/2] dcb: add new pcp-prio parameter to dcb app
Quoted 13 lines
Quoted 10 lines · On Mon, 5 Dec 2022 09:19:06 +0000 <[email protected]> wrote:
Quoted 9 lines
Quoted 7 lines
Trying to understand your comment.
Are you talking about not producing any JSON output with the symbolic PCP values? eg. ["1de", 1] -> [8, 1]. So basically print with
PRINT_FPin case of printing in JSON context?/Daniel
What does output look like in json and non-json versions?
Quoted 7 lines
Quoted 2 lines
non-JSON: pcp-prio 1de:1
JSON : {"pcp_prio":[["1de",1]]}Would the JSON be better as:
{ "pcp_prio" :[ { "1de":1 } ] }It looks like the PCP values are both unique and used in a name/value manner.
In this case I think it would be best to stay consistent with the rest of the dcb app code. All priority mappings are printed using the dcb_app_print_filtered() (now also the pcp-prio), which creates an array, for whatever reason.
If you are OK with this, I will go ahead and create v4, with the print warning removed.
/Daniel
Quoted 13 lines
Quoted 12 lines
Quoted 4 lines
My concern that the json version would be awkward and have colons in it, but looks like it won't.
Yeah, the "%s:" format is only used in non-JSON context, so we are good here.
Quoted 2 lines
For the unknown key type is printing error necessary? Maybe just show it in numeric form.
No not necessary, I'll get rid of it.
Re: [PATCH iproute2-next v3 1/2] dcb: add new pcp-prio parameter to dcb app
Quoted 26 lines · On Mon, 5 Dec 2022 19:19:35 +0000 <[email protected]> wrote:
Quoted 13 lines
Quoted 10 lines · On Mon, 5 Dec 2022 09:19:06 +0000 <[email protected]> wrote:
Quoted 9 lines
Quoted 7 lines
Trying to understand your comment.
Are you talking about not producing any JSON output with the symbolic PCP values? eg. ["1de", 1] -> [8, 1]. So basically print with
PRINT_FPin case of printing in JSON context?/Daniel
What does output look like in json and non-json versions?
Quoted 7 lines
Quoted 2 lines
non-JSON: pcp-prio 1de:1
JSON : {"pcp_prio":[["1de",1]]}Would the JSON be better as:
{ "pcp_prio" :[ { "1de":1 } ] }It looks like the PCP values are both unique and used in a name/value manner.
In this case I think it would be best to stay consistent with the rest of the dcb app code. All priority mappings are printed using the
dcb_app_print_filtered()(now also the pcp-prio), which creates an array, for whatever reason.
Quoted 4 lines
If you are OK with this, I will go ahead and create v4, with the print warning removed.
/Daniel
I am ok with what ever you decide, just wanted to make sure you thought about it
Re: [PATCH iproute2-next v3 1/2] dcb: add new pcp-prio parameter to dcb app
In reply to [email protected]Quoted 17 lines · <[email protected]> writes:
Quoted 17 lines
Quoted 10 lines · On Mon, 5 Dec 2022 09:19:06 +0000 <[email protected]> wrote:
Quoted 7 lines
Quoted 5 lines
Trying to understand your comment.
Are you talking about not producing any JSON output with the symbolic PCP values? eg. ["1de", 1] -> [8, 1]. So basically print with
PRINT_FPin case of printing in JSON context?What does output look like in json and non-json versions?
non-JSON: pcp-prio 1de:1
JSON : {"pcp_prio":[["1de",1]]}Would the JSON be better as:
{ "pcp_prio" :[ { "1de":1 } ] }
Quoted 6 lines
Quoted 1 line
It looks like the PCP values are both unique and used in a name/value manner.
In this case I think it would be best to stay consistent with the rest of the dcb app code. All priority mappings are printed using the
dcb_app_print_filtered()(now also the pcp-prio), which creates an array, for whatever reason.
The reason is that APP mappings are not unique. It is OK to have rules for both 1de:1 and 1de:2. And 2de:1 and 2de:2 too, it's a full m:n relationship. A JSON dictionary would not work well for this purpose. (It's not technically forbidden to have duplicate keys in a JSON dictionary, just discouraged, i.e. SHOULD NOT rather than SHALL NOT, but e.g. jq then doesn't let you work with both entries.)
PATCH v3 2/2 dcb: add new subcommand for apptrust
In reply to Daniel MachonAdd new apptrust subcommand for the dcbnl apptrust extension object.
The apptrust command lets you specify a consecutive ordered list of trusted selectors, which can be used by drivers to determine which selectors are eligible (trusted) for packet prioritization, and in which order.
Selectors are sent in a new nested attribute:DCB_ATTR_IEEE_APP_TRUST_TABLE. The nest contains trusted selectors encapsulated in either DCB_ATTR_IEEE_APP or DCB_ATTR_DCB_APP attributes, for standard and non-standard selectors, respectively.
Example:
Trust selectors dscp and pcp, in that order
$ dcb apptrust set dev eth0 order dscp pcp
--- dcb/Makefile | 3 +- dcb/dcb.c | 4 +- dcb/dcb.h | 4 + dcb/dcb_apptrust.c | 307 ++++++++++++++++++++++++++++++++++++++++ man/man8/dcb-apptrust.8 | 109 ++++++++++++++ 5 files changed, 425 insertions(+), 2 deletions(-) create mode 100644 dcb/dcb_apptrust.c create mode 100644 man/man8/dcb-apptrust.8
dcb/Makefile +2 -1
@@ -7,7 +7,8 @@ DCBOBJ = dcb.o \ dcb_dcbx.o \ dcb_ets.o \ dcb_maxrate.o \ - dcb_pfc.o + dcb_pfc.o \ + dcb_apptrust.o TARGETS += dcb LDLIBS += -lm
dcb/dcb.c +3 -1
@@ -470,7 +470,7 @@ static void dcb_help(void)fprintf (stderr,"Usage: dcb [ OPTIONS ] OBJECT { COMMAND | help }\n" " dcb [ -f | --force ] { -b | --batch } filename [ -n | --netns ] netnsname\n" -"where OBJECT := { app | buffer | dcbx | ets | maxrate | pfc }\n" +"where OBJECT := { app | apptrust | buffer | dcbx | ets | maxrate | pfc }\n" " OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n" " | -N | --Numeric | -p | --pretty\n" " | -s | --statistics | -v | --verbose]\n" );
@@ -483,6 +483,8 @@ static int dcb_cmd(struct dcb *dcb, int argc, char **argv)return 0 ; }else if (matches (*argv,"app" ) ==0 ) {return dcb_cmd_app (dcb, argc -1 , argv +1 ); + }else if (strcmp (*argv,"apptrust" ) ==0 ) { +return dcb_cmd_apptrust (dcb, argc -1 , argv +1 ); }else if (matches (*argv,"buffer" ) ==0 ) {return dcb_cmd_buffer (dcb, argc -1 , argv +1 ); }else if (matches (*argv,"dcbx" ) ==0 ) {
dcb/dcb.h +4 -0
@@ -61,6 +61,10 @@ enum ieee_attrs_app dcb_app_attr_type_get(__u8 selector);bool dcb_app_attr_type_validate (enum ieee_attrs_app type);bool dcb_app_selector_validate (enum ieee_attrs_app type,__u8 selector); +/* dcb_apptrust.c */ + +int dcb_cmd_apptrust (struct dcb *dcb,int argc,char **argv); +/* dcb_buffer.c */ int dcb_cmd_buffer (struct dcb *dcb,int argc,char **argv);
dcb/dcb_apptrust.c new file +307 -0
307 lines not on this page · raw message
man/man8/dcb-apptrust.8 new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.34.1