app/testpmd: metering and policing CLI clean up
PATCH 1/3 app/testpmd: metering and policing CLI clean up
This patch updates the metering and policing CLIs as follows:
- change name of set port meter CLI to create port meter and add meter enable option, dscp table entries arguments, action mask, policer actions and previous meter color option as an input color
- set the right metering algorithm in add meter profile CLIs related to srtcm(rfc2697) and trtcm(rfc2698,rfc4115)
- change clear flag type from uint32_t to string in show meter stats CLI
--- app/test-pmd/cmdline.c | 12 +- app/test-pmd/cmdline_mtr.c | 329 ++++++++++++++++++++++++++++++++------------- app/test-pmd/cmdline_mtr.h | 2 +- 3 files changed, 248 insertions(+), 95 deletions(-)
app/test-pmd/cmdline.c +8 -4
@@ -698,7 +698,7 @@ static void cmd_help_long_parsed(void *parsed_result,"set port (port_id) queue-region flush (on|off)\n" " flush all queue region related configuration\n\n" -"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (color_aware)\n" +"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" " meter profile add - srtcm rfc 2697\n\n" "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
@@ -710,7 +710,10 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter profile (port_id) (profile_id)\n" " meter profile delete\n\n" -"set port meter (port_id) (mtr_id) (profile_id) (g_action) (y_action) (r_action) (stats_mask) (shared)\n" +"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" +"(g_action) (y_action) (r_action) (stats_mask) (shared)\n" +"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" +"(dscp_tbl_entry63)]\n" " meter create\n\n" "del port meter (port_id) (mtr_id)\n"
@@ -719,7 +722,8 @@ static void cmd_help_long_parsed(void *parsed_result,"set port meter profile (port_id) (mtr_id) (profile_id)\n" " meter update meter profile\n\n" -"set port meter policer action (port_id) (mtr_id) (color) (action)\n" +"set port meter policer action (port_id) (mtr_id) (action_mask)\n" +"(action0) [(action1) (action2)]\n" " meter update policer action\n\n" "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
@@ -15688,7 +15692,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, - (cmdline_parse_inst_t *)&cmd_set_port_meter, + (cmdline_parse_inst_t *)&cmd_create_port_meter, (cmdline_parse_inst_t *)&cmd_del_port_meter, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
app/test-pmd/cmdline_mtr.c +239 -90
497 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +1 -1
@@ -39,7 +39,7 @@ extern cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm;extern cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm;extern cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115;extern cmdline_parse_inst_t cmd_del_port_meter_profile; -extern cmdline_parse_inst_t cmd_set_port_meter; +extern cmdline_parse_inst_t cmd_create_port_meter;extern cmdline_parse_inst_t cmd_del_port_meter;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_policer_action;
Signature · 1 line
2.9.3
PATCH 2/3 app/testpmd: add CLI for metering and policing API
Add following CLIs to testpmd application;
- show port metering and policing capabilities.
- enable/disable meter of the MTR object.
- update the MTR object dscp table entries.
--- app/test-pmd/cmdline.c | 17 +++ app/test-pmd/cmdline_mtr.c | 325 +++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/cmdline_mtr.h | 4 + 3 files changed, 346 insertions(+)
app/test-pmd/cmdline.c +17 -0
@@ -698,6 +698,9 @@ static void cmd_help_long_parsed(void *parsed_result,"set port (port_id) queue-region flush (on|off)\n" " flush all queue region related configuration\n\n" +"show port meter cap (port_id) \n" +" Show port meter capability information\n\n" +"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" " meter profile add - srtcm rfc 2697\n\n"
@@ -716,12 +719,22 @@ static void cmd_help_long_parsed(void *parsed_result,"(dscp_tbl_entry63)]\n" " meter create\n\n" +"enable port meter (port_id) (mtr_id)\n" +" meter enable\n\n" + +"disable port meter (port_id) (mtr_id)\n" +" meter disable\n\n" +"del port meter (port_id) (mtr_id)\n" " meter delete\n\n" "set port meter profile (port_id) (mtr_id) (profile_id)\n" " meter update meter profile\n\n" +"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" +"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" +" update meter dscp table entries\n\n" +"set port meter policer action (port_id) (mtr_id) (action_mask)\n" "(action0) [(action1) (action2)]\n" " meter update policer action\n\n"
@@ -15689,12 +15702,16 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_hash_input_set, (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, (cmdline_parse_inst_t *)&cmd_flow, + (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, (cmdline_parse_inst_t *)&cmd_create_port_meter, + (cmdline_parse_inst_t *)&cmd_enable_port_meter, + (cmdline_parse_inst_t *)&cmd_disable_port_meter, (cmdline_parse_inst_t *)&cmd_del_port_meter, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, + (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
app/test-pmd/cmdline_mtr.c +325 -0
343 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +4 -0
@@ -35,13 +35,17 @@#define _CMDLINE_MTR_H_/* Traffic Metering and Policing */ +extern cmdline_parse_inst_t cmd_show_port_meter_cap;extern cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm;extern cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm;extern cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115;extern cmdline_parse_inst_t cmd_del_port_meter_profile;extern cmdline_parse_inst_t cmd_create_port_meter; +extern cmdline_parse_inst_t cmd_enable_port_meter; +extern cmdline_parse_inst_t cmd_disable_port_meter;extern cmdline_parse_inst_t cmd_del_port_meter;extern cmdline_parse_inst_t cmd_set_port_meter_profile; +extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;extern cmdline_parse_inst_t cmd_set_port_meter_policer_action;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats;
Signature · 1 line
2.9.3
PATCH 3/3 doc: add description of traffic metering and policing funcs in testpmd
In reply to Jasvinder Singh--- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 173 ++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+)
doc/guides/testpmd_app_ug/testpmd_funcs.rst +173 -0
@@ -2068,6 +2068,179 @@ For example, to set the high bit in the register from the example above:: testpmd> write regbit 0 0xEE00 31 1 port 0 PCI register at offset 0xEE00: 0x8000000A (2147483658) +Traffic Metering and Policing +----------------------------- + +The following section shows functions for configuring traffic metering and +policing on the ethernet device through the use of generic ethdev API. + +show port traffic management capability +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Show traffic metering and policing capability of the port:: + + testpmd> show port meter cap (port_id) + +add port meter profile (srTCM rfc2967) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Add meter profile (srTCM rfc2697) to the ethernet device:: + + testpmd> add port meter profile srtcm_rfc2697 (port_id) (profile_id) \ + (cir) (cbs) (ebs) + +where: + +* ``profile_id``: ID for the meter profile. +* ``cir``: Committed Information Rate (CIR) (bytes/second). +* ``cbs``: Committed Burst Size (CBS) (bytes). +* ``ebs``: Excess Burst Size (EBS) (bytes). + +add port meter profile (trTCM rfc2968) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Add meter profile (srTCM rfc2698) to the ethernet device:: + + testpmd> add port meter profile trtcm_rfc2698 (port_id) (profile_id) \ + (cir) (pir) (cbs) (pbs) + +where: + +* ``profile_id``: ID for the meter profile. +* ``cir``: Committed information rate (bytes/second). +* ``pir``: Peak information rate (bytes/second). +* ``cbs``: Committed burst size (bytes). +* ``pbs``: Peak burst size (bytes). + +add port meter profile (trTCM rfc4115) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Add meter profile (trTCM rfc4115) to the ethernet device:: + + testpmd> add port meter profile trtcm_rfc4115 (port_id) (profile_id) \ + (cir) (eir) (cbs) (ebs) + +where: + +* ``profile_id``: ID for the meter profile. +* ``cir``: Committed information rate (bytes/second). +* ``eir``: Excess information rate (bytes/second). +* ``cbs``: Committed burst size (bytes). +* ``ebs``: Excess burst size (bytes). + +delete port meter profile +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Delete meter profile from the ethernet device:: + + testpmd> del port meter profile (port_id) (profile_id) + +create port meter +~~~~~~~~~~~~~~~~~ + +Create new meter object for the ethernet device:: + + testpmd> create port meter (port_id) (mtr_id) (profile_id) \ + (meter_enable) (g_action) (y_action) (r_action) (stats_mask) (shared) \ + (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\ + (dscp_tbl_entry63)] + +where: + +* ``mtr_id``: meter object ID. +* ``profile_id``: ID for the meter profile. +* ``meter_enable``: When this parameter has a non-zero value, the meter object + gets enabled at the time of creation, otherwise remains disabled. +* ``g_action``: Policer action for the packet with green color. +* ``y_action``: Policer action for the packet with yellow color. +* ``r_action``: Policer action for the packet with red color. +* ``stats_mask``: Mask of statistics counter types to be enabled for the + meter object. +* ``shared``: When this parameter has a non-zero value, the meter object is + shared by multiple flows. Otherwise, meter object is used by single flow. +* ``use_pre_meter_color``: When this parameter has a non-zero value, the + input color for the current meter object is determined by the latest meter + object in the same flow. Otherwise, the current meter object uses the + *dscp_table* to determine the input color. +* ``dscp_tbl_entryx``: DSCP table entry x providing meter providing input + color, 0 <= x <= 63. + +enable port meter +~~~~~~~~~~~~~~~~~ + +Enable meter for the ethernet device:: + + testpmd> enable port meter (port_id) (mtr_id) + +disable port meter +~~~~~~~~~~~~~~~~~~ + +Disable meter for the ethernet device:: + + testpmd> disable port meter (port_id) (mtr_id) + +delete port meter +~~~~~~~~~~~~~~~~~ + +Delete meter for the ethernet device:: + + testpmd> del port meter (port_id) (mtr_id) + +Set port meter profile +~~~~~~~~~~~~~~~~~~~~~~ + +Set meter profile for the ethernet device:: + + testpmd> set port meter profile (port_id) (mtr_id) (profile_id) + +set port meter dscp table +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Set meter dscp table for the ethernet device:: + + testpmd> set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0) \ + (dscp_tbl_entry1)...(dscp_tbl_entry63)] + +set port meter policer action +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Set meter policer action for the ethernet device:: + + testpmd> set port meter policer action (port_id) (mtr_id) (action_mask) \ + (action0) [(action1) (action1)] + +where: + +* ``action_mask``: Bit mask indicating which policer actions need to be + updated. One or more policer actions can be updated in a single function + invocation. To update the policer action associated with color C, bit + (1 << C) needs to be set in *action_mask* and element at position C + in the *actions* array needs to be valid. +* ``actionx``: Policer action for the color x, + RTE_MTR_GREEN <= x < RTE_MTR_COLORS + +set port meter stats mask +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Set meter stats mask for the ethernet device:: + + testpmd> set port meter stats mask (port_id) (mtr_id) (stats_mask) + +where: + +* ``stats_mask``: Bit mask indicating statistics counter types to be enabled. + +show port meter stats +~~~~~~~~~~~~~~~~~~~~~ + +Show meter stats of the ethernet device:: + + testpmd> show port meter stats (port_id) (mtr_id) (clear) + +where: + +* ``clear``: Flag that indicates whether the statistics counters should + be cleared (i.e. set to zero) immediately after they have been read or not. Traffic Management ------------------
Signature · 1 line
2.9.3
Re: [PATCH 3/3] doc: add description of traffic metering and policing funcs in testpmd
Quoted 1 line · Jasvinder Singh
Signed-off-by Jasvinder Singh <[email protected]>
Re: [PATCH 3/3] doc: add description of traffic metering and policing funcs in testpmd
In reply to Jasvinder SinghQuoted 11 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Monday, November 20, 2017 4:39 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Wu, Jingjing <[email protected]>; Mcnamara, John <[email protected]>
Subject: [PATCH 3/3] doc: add description of traffic metering and policing funcs in testpmd
Quoted 1 line
Signed-off-by Jasvinder Singh <[email protected]>
Re: [PATCH 3/3] doc: add description of traffic metering and policing funcs in testpmd
In reply to Jasvinder SinghNote, there is a devtools/check-git-log.sh warning on the commit subject. Maybe use something like this instead, if you update the patchset, or the maintainer can fix inline:
doc: add metering and policing funcs to testpmd docs
Quoted 18 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Tuesday, November 21, 2017 12:39 AM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Wu, Jingjing <[email protected]>; Mcnamara, John <[email protected]>
Subject: [PATCH 1/3] app/testpmd: metering and policing CLI clean upThis patch updates the metering and policing CLIs as follows:
- change name of set port meter CLI to create port meter and add meter enable option, dscp table entries arguments, action mask, policer actions and previous meter color option as an input color
- set the right metering algorithm in add meter profile CLIs related to srtcm(rfc2697) andtrtcm(rfc2698,rfc4115)
- change clear flag type fromuint32_tto string in show meter stats CLI
Quoted 1 line
Signed-off-by Jasvinder Singh <[email protected]>
With minor comment:
Quoted 20 lines
app/test-pmd/cmdline_mtr.c +20
-0+static int +parse_dscp_table_entries (char *str,enum rte_mtr_color *dscp_table) +{ +char *token; +int i =0 ; + + token =strtok_r (str,PARSE_DELIMITER , &str); +if (token ==NULL ) +return 0 ; + +/* Allocate memory for dscp table */ + dscp_table = (enum rte_mtr_color *)malloc (MAX_DSCP_TABLE_ENTRIES * +sizeof (enum rte_mtr_color )); + +while (1 ) { +if (strcmp (token,"G" ) ==0 || +strcmp (token,"g" ) ==0 ) + dscp_table[i++] =RTE_MTR_GREEN ; +else if (strcmp (token,"Y" ) ==0 || +strcmp (token,"y" ) ==0 )
app/test-pmd/cmdline_mtr.c print_err_msg(struct rte_mtr_error *error) · line 134
Quoted 10 lines
app/test-pmd/cmdline_mtr.c +10
-0+ dscp_table[i++] =RTE_MTR_YELLOW ; + else if (strcmp(token, "R") == 0 || + strcmp(token, "r") == 0) + dscp_table[i++] = RTE_MTR_RED; + else { + free(dscp_table); + return -1; + } + if (i == MAX_DSCP_TABLE_ENTRIES) + break;
Is that meaning the size dscp table must be 64, can it be less than 64?
Thanks
Jingjing
Re: [PATCH 2/3] app/testpmd: add CLI for metering and policing API
In reply to Jasvinder SinghQuoted 10 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Tuesday, November 21, 2017 12:39 AM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Wu, Jingjing <[email protected]>; Mcnamara, John <[email protected]>
Subject: [PATCH 2/3] app/testpmd: add CLI for metering and policing API
Quoted 6 lines
Add following CLIs to testpmd application;
- show port metering and policing capabilities.
- enable/disable meter of the MTR object.
- update the MTR object dscp table entries.Signed-off-by Jasvinder Singh <[email protected]>
Quoted 57 lines
-----Original Message-----
From: Wu, Jingjing
Sent: Sunday, January 7, 2018 2:25 PM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Mcnamara, John <[email protected]>
Subject: RE: [PATCH 1/3] app/testpmd: metering and policing CLI clean upQuoted 17 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Tuesday, November 21, 2017 12:39 AM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Wu, Jingjing <[email protected]>; Mcnamara, John <[email protected]>
Subject: [PATCH 1/3] app/testpmd: metering and policing CLI clean upThis patch updates the metering and policing CLIs as follows:
- change name of set port meter CLI to create port meter and add meter enable option, dscp table entries arguments, action mask, policer actions and previous meter color option as an input color
- set the right metering algorithm in add meter profile CLIs related to srtcm(rfc2697) andtrtcm(rfc2698,rfc4115)
- change clear flag type fromuint32_tto string in show meter stats CLIQuoted 1 line
Signed-off-by Jasvinder Singh <[email protected]>Acked-by Jingjing Wu <[email protected]>With minor comment:
app/test-pmd/cmdline_mtr.c print_err_msg(struct rte_mtr_error *error)
Quoted 11 lines
app/test-pmd/cmdline_mtr.c +11
-0+static int +parse_dscp_table_entries (char *str,enum rte_mtr_color *dscp_table) { +char *token; +int i =0 ; + + token =strtok_r (str,PARSE_DELIMITER , &str); +if (token ==NULL ) +return 0 ; + +/* Allocate memory for dscp table */ + dscp_table = (enum rte_mtr_color*)malloc(MAX_DSCP_TABLE_ENTRIES *
Quoted 11 lines
app/test-pmd/cmdline_mtr.c +11
-0+ sizeof(enum rte_mtr_color)); + +while (1 ) { +if (strcmp (token,"G" ) ==0 || +strcmp (token,"g" ) ==0 ) + dscp_table[i++] =RTE_MTR_GREEN ; +else if (strcmp (token,"Y" ) ==0 || +strcmp (token,"y" ) ==0 ) + dscp_table[i++] =RTE_MTR_YELLOW ; +else if (strcmp (token,"R" ) ==0 || +strcmp (token,"r" ) ==0 )
Quoted 8 lines
app/test-pmd/cmdline_mtr.c print_err_msg(struct rte_mtr_error *error) · line 134
Quoted 7 lines
app/test-pmd/cmdline_mtr.c +7
-0+ dscp_table[i++] =RTE_MTR_RED ; + else { +free (dscp_table); +return -1 ; + } +if (i ==MAX_DSCP_TABLE_ENTRIES ) +break ;Is that meaning the size dscp table must be 64, can it be less than 64?
The DSCP field is represented by 6 bits in the byte long TOS field of the IP header. Therefore, DSCP table should be have 64 entries for the packets classification.
Quoted 2 lines
Thanks
Jingjing
Quoted 10 lines
Quoted 9 lines
This patch updates the metering and policing CLIs as follows:
- change name of set port meter CLI to create port meter and add meter enable option, dscp table entries arguments, action mask, policer actions and previous meter color option as an input color
- set the right metering algorithm in add meter profile CLIs related to srtcm(rfc2697) andtrtcm(rfc2698,rfc4115)
- change clear flag type fromuint32_tto string in show meter stats CLISigned-off-by Jasvinder Singh <[email protected]>Acked-by Jingjing Wu <[email protected]>
Series applied, thanks