lib/librte_meter: add RFC4115 trTCM meter support
cover lib/librte_meter: add RFC4115 trTCM meter support
This patch adds support for RFC4115 trTCM meters.
Eelco Chaudron (3):
lib/librte_meter: add RFC4115 trTCM meter support test/test_meter: update meter test to include RFC4115 meters lib/librte_meter: update abi to include new rfc4115 function
lib/librte_meter/Makefile | 2 lib/librte_meter/meson.build | 2 lib/librte_meter/rte_meter.c | 40 ++++++ lib/librte_meter/rte_meter.h | 193 +++++++++++++++++++++++++++-- lib/librte_meter/rte_meter_version.map | 9 + test/test/test_meter.c | 212 ++++++++++++++++++++++++++++++++ 6 files changed, 440 insertions(+), 18 deletions(-)
PATCH 1/3 lib/librte_meter: add RFC4115 trTCM meter support
This patch adds support for RFC4115 trTCM meters.
--- lib/librte_meter/rte_meter.c | 40 +++++++++ lib/librte_meter/rte_meter.h | 193 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 217 insertions(+), 16 deletions(-)
lib/librte_meter/rte_meter.c +40 -0
@@ -110,3 +110,43 @@ rte_meter_trtcm_config(struct rte_meter_trtcm *m,return 0 ; } + +int +rte_meter_trtcm_rfc4115_profile_config (struct rte_meter_trtcm_profile *p, +struct rte_meter_trtcm_params *params) +{ +uint64_t hz =rte_get_tsc_hz (); + +/* Check input parameters */ +if ((p ==NULL ) || + (params ==NULL ) || + (params->cir !=0 && params->cbs ==0 ) || + (params->eir !=0 && params->ebs ==0 )) +return -EINVAL ; + +/* Initialize trTCM run-time structure */ + p->cbs = params->cbs; + p->ebs = params->ebs; +rte_meter_get_tb_params (hz, params->cir, &p->cir_period, + &p->cir_bytes_per_period); +rte_meter_get_tb_params (hz, params->eir, &p->eir_period, + &p->eir_bytes_per_period); + +return 0 ; +} + +int +rte_meter_trtcm_rfc4115_config (struct rte_meter_trtcm *m, +struct rte_meter_trtcm_profile *p) +{ +/* Check input parameters */ +if ((m ==NULL ) || (p ==NULL )) +return -EINVAL ; + +/* Initialize trTCM run-time structure */ + m->time_tc = m->time_te =rte_get_tsc_cycles (); + m->tc = p->cbs; + m->te = p->ebs; + +return 0 ; +}
lib/librte_meter/rte_meter.h +177 -16
249 lines not on this page · raw message
PATCH 2/3 test/test_meter: update meter test to include RFC4115 meters
In reply to Eelco ChaudronAdd test cases for RFC4115 meters
--- test/test/test_meter.c | 212 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+)
test/test/test_meter.c +212 -0
@@ -32,8 +32,10 @@#define TM_TEST_TRTCM_CIR_DF 46000000#define TM_TEST_TRTCM_PIR_DF 69000000 +#define TM_TEST_TRTCM_EIR_DF 69000000#define TM_TEST_TRTCM_CBS_DF 2048#define TM_TEST_TRTCM_PBS_DF 4096 +#define TM_TEST_TRTCM_EBS_DF 4096static struct rte_meter_srtcm_params sparams = {.cir =TM_TEST_SRTCM_CIR_DF ,
@@ -46,6 +48,12 @@ static struct rte_meter_trtcm_params tparams= .cbs = TM_TEST_TRTCM_CBS_DF, .pbs = TM_TEST_TRTCM_PBS_DF,}; +static struct rte_meter_trtcm_params rfc4115params = + {.cir =TM_TEST_TRTCM_CIR_DF , + .eir =TM_TEST_TRTCM_EIR_DF , + .cbs =TM_TEST_TRTCM_CBS_DF , + .ebs =TM_TEST_TRTCM_EBS_DF ,}; +/** * functional test for rte_meter_srtcm_config */
@@ -148,6 +156,45 @@ tm_test_trtcm_config(void)return 0 ; } +/** +* functional test for rte_meter_trtcm_rfc4115_config +*/ +static inline int +tm_test_trtcm_rfc4115_config (void ) +{ +struct rte_meter_trtcm_profile tp; +struct rte_meter_trtcm_params rfc4115params1; +#define TRTCM_RFC4115_CFG_MSG "trtcm_rfc4115_config" + +/* invalid parameter test */ +if (rte_meter_trtcm_rfc4115_profile_config (NULL ,NULL ) ==0 ) +melog (TRTCM_RFC4115_CFG_MSG ); +if (rte_meter_trtcm_rfc4115_profile_config (&tp,NULL ) ==0 ) +melog (TRTCM_RFC4115_CFG_MSG ); +if (rte_meter_trtcm_rfc4115_profile_config (NULL , &rfc4115params) ==0 ) +melog (TRTCM_RFC4115_CFG_MSG ); + +/* +* cbs and pbs should be none-zero if cir and eir are none-zero +* respectively +*/ + rfc4115params1 = rfc4115params; + rfc4115params1.cbs =0 ; +if (rte_meter_trtcm_profile_config (&tp, &rfc4115params1) ==0 ) +melog (TRTCM_RFC4115_CFG_MSG ); + + rfc4115params1 = rfc4115params; + rfc4115params1.pbs =0 ; +if (rte_meter_trtcm_profile_config (&tp, &rfc4115params1) ==0 ) +melog (TRTCM_RFC4115_CFG_MSG ); + +/* usual parameter, should be successful */ +if (rte_meter_trtcm_profile_config (&tp, &rfc4115params) !=0 ) +melog (TRTCM_RFC4115_CFG_MSG ); + +return 0 ; +} +/** * functional test for rte_meter_srtcm_color_blind_check */
@@ -265,6 +312,65 @@ tm_test_trtcm_color_blind_check(void)return 0 ; } +/** +* functional test for rte_meter_trtcm_rfc4115_color_blind_check +*/ +static inline int +tm_test_trtcm_rfc4115_color_blind_check (void ) +{ +#define TRTCM_RFC4115_BLIND_CHECK_MSG "trtcm_rfc4115_blind_check" + +uint64_t time; +struct rte_meter_trtcm_profile tp; +struct rte_meter_trtcm tm; +uint64_t hz =rte_get_tsc_hz (); + +/* Test green */ +if (rte_meter_trtcm_rfc4115_profile_config (&tp, &rfc4115params) !=0 ) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG ); +if (rte_meter_trtcm_rfc4115_config (&tm, &tp) !=0 ) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG ); + time =rte_get_tsc_cycles () + hz; +if (rte_meter_trtcm_rfc4115_color_blind_check ( + &tm, &tp, time,TM_TEST_TRTCM_CBS_DF -1 ) + != e_RTE_METER_GREEN) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG " GREEN" ); + +/* Test yellow */ +if (rte_meter_trtcm_rfc4115_profile_config (&tp, &rfc4115params) !=0 ) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG ); +if (rte_meter_trtcm_rfc4115_config (&tm, &tp) !=0 ) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG ); + time =rte_get_tsc_cycles () + hz; +if (rte_meter_trtcm_rfc4115_color_blind_check ( + &tm, &tp, time,TM_TEST_TRTCM_CBS_DF +1 ) + != e_RTE_METER_YELLOW) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG " YELLOW" ); + +if (rte_meter_trtcm_rfc4115_profile_config (&tp, &rfc4115params) !=0 ) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG ); +if (rte_meter_trtcm_rfc4115_config (&tm, &tp) !=0 ) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG ); + time =rte_get_tsc_cycles () + hz; +if (rte_meter_trtcm_rfc4115_color_blind_check ( + &tm, &tp, time,TM_TEST_TRTCM_EBS_DF -1 ) + != e_RTE_METER_YELLOW) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG " YELLOW" ); + +/* Test red */ +if (rte_meter_trtcm_rfc4115_profile_config (&tp, &rfc4115params) !=0 ) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG ); +if (rte_meter_trtcm_rfc4115_config (&tm, &tp) !=0 ) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG ); + time =rte_get_tsc_cycles () + hz; +if (rte_meter_trtcm_rfc4115_color_blind_check ( + &tm, &tp, time,TM_TEST_TRTCM_EBS_DF +1 ) + != e_RTE_METER_RED) +melog (TRTCM_RFC4115_BLIND_CHECK_MSG " RED" ); + +return 0 ; +} +/** * @in[4] : the flags packets carries.
@@ -473,6 +579,103 @@ tm_test_trtcm_color_aware_check(void)return 0 ; } +/** +* @in[4] : the flags packets carries. +* @in[4] : the flags function expect to return. +* It will do blind check at the time of 1 second from beginning. +* At the time, it will use packets length of cbs -1, cbs + 1, +* ebs -1 and ebs +1 with flag in[0], in[1], in[2] and in[3] to do +* aware check, expect flag out[0], out[1], out[2] and out[3] +*/ +static inline int +tm_test_trtcm_rfc4115_aware_check +(enum rte_meter_color in[4 ],enum rte_meter_color out[4 ]) +{ +#define TRTCM_RFC4115_AWARE_CHECK_MSG "trtcm_rfc4115_aware_check" +struct rte_meter_trtcm_profile tp; +struct rte_meter_trtcm tm; +uint64_t time; +uint64_t hz =rte_get_tsc_hz (); + +if (rte_meter_trtcm_rfc4115_profile_config (&tp, &rfc4115params) !=0 ) +melog (TRTCM_AWARE_CHECK_MSG ); +if (rte_meter_trtcm_rfc4115_config (&tm, &tp) !=0 ) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG ); + time =rte_get_tsc_cycles () + hz; +if (rte_meter_trtcm_rfc4115_color_aware_check ( + &tm, &tp, time,TM_TEST_TRTCM_CBS_DF -1 , in[0 ]) != out[0 ]) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG " %u:%u" , in[0 ], out[0 ]); + +if (rte_meter_trtcm_rfc4115_profile_config (&tp, &rfc4115params) !=0 ) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG ); +if (rte_meter_trtcm_rfc4115_config (&tm, &tp) !=0 ) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG ); + time =rte_get_tsc_cycles () + hz; +if (rte_meter_trtcm_rfc4115_color_aware_check ( + &tm, &tp, time,TM_TEST_TRTCM_CBS_DF +1 , in[1 ]) != out[1 ]) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG " %u:%u" , in[1 ], out[1 ]); + +if (rte_meter_trtcm_rfc4115_profile_config (&tp, &rfc4115params) !=0 ) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG ); +if (rte_meter_trtcm_rfc4115_config (&tm, &tp) !=0 ) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG ); + time =rte_get_tsc_cycles () + hz; +if (rte_meter_trtcm_rfc4115_color_aware_check ( + &tm, &tp, time,TM_TEST_TRTCM_EBS_DF -1 , in[2 ]) != out[2 ]) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG " %u:%u" , in[2 ], out[2 ]); + +if (rte_meter_trtcm_rfc4115_profile_config (&tp, &rfc4115params) !=0 ) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG ); +if (rte_meter_trtcm_rfc4115_config (&tm, &tp) !=0 ) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG ); + time =rte_get_tsc_cycles () + hz; +if (rte_meter_trtcm_rfc4115_color_aware_check ( + &tm, &tp, time,TM_TEST_TRTCM_EBS_DF +1 , in[3 ]) != out[3 ]) +melog (TRTCM_RFC4115_AWARE_CHECK_MSG " %u:%u" , in[3 ], out[3 ]); + +return 0 ; +} + +/** +* functional test for rte_meter_trtcm_rfc4115_color_aware_check +*/ +static inline int +tm_test_trtcm_rfc4115_color_aware_check (void ) +{ +enum rte_meter_color in[4 ], out[4 ]; +/** +* test 4 points that will produce green, yellow, yellow, red flag +* if using blind check +*/ + +/* previouly have a green, test points should keep unchanged */ + in[0 ] = in[1 ] = in[2 ] = in[3 ] = e_RTE_METER_GREEN; + out[0 ] = e_RTE_METER_GREEN; + out[1 ] = e_RTE_METER_YELLOW; + out[2 ] = e_RTE_METER_YELLOW; + out[3 ] = e_RTE_METER_RED; +if (tm_test_trtcm_rfc4115_aware_check (in, out) !=0 ) +return -1 ; + + in[0 ] = in[1 ] = in[2 ] = in[3 ] = e_RTE_METER_YELLOW; + out[0 ] = e_RTE_METER_YELLOW; + out[1 ] = e_RTE_METER_YELLOW; + out[2 ] = e_RTE_METER_YELLOW; + out[3 ] = e_RTE_METER_RED; +if (tm_test_trtcm_rfc4115_aware_check (in, out) !=0 ) +return -1 ; + + in[0 ] = in[1 ] = in[2 ] = in[3 ] = e_RTE_METER_RED; + out[0 ] = e_RTE_METER_RED; + out[1 ] = e_RTE_METER_RED; + out[2 ] = e_RTE_METER_RED; + out[3 ] = e_RTE_METER_RED; +if (tm_test_trtcm_rfc4115_aware_check (in, out) !=0 ) +return -1 ; + +return 0 ; +} +/** * test main entrance for library meter */
@@ -485,18 +688,27 @@ test_meter(void)if (tm_test_trtcm_config () !=0 )return -1 ; +if (tm_test_trtcm_rfc4115_config () !=0 ) +return -1 ; +if (tm_test_srtcm_color_blind_check () !=0 )return -1 ;if (tm_test_trtcm_color_blind_check () !=0 )return -1 ; +if (tm_test_trtcm_rfc4115_color_blind_check () !=0 ) +return -1 ; +if (tm_test_srtcm_color_aware_check () !=0 )return -1 ;if (tm_test_trtcm_color_aware_check () !=0 )return -1 ; +if (tm_test_trtcm_rfc4115_color_aware_check () !=0 ) +return -1 ; +return 0 ; }
PATCH 3/3 lib/librte_meter: update abi to include new rfc4115 function
In reply to Eelco ChaudronUpdate the ABI to include the new RFC4115 meter functions
--- lib/librte_meter/Makefile | 2 +- lib/librte_meter/meson.build | 2 +- lib/librte_meter/rte_meter_version.map | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-)
lib/librte_meter/Makefile +1 -1
@@ -16,7 +16,7 @@ LDLIBS += -lrte_eal EXPORT_MAP := rte_meter_version.map -LIBABIVER := 2 +LIBABIVER := 3 # # all source are stored in SRCS-y
lib/librte_meter/meson.build +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -version = 2 +version = 3 sources = files('rte_meter.c') headers = files('rte_meter.h')
lib/librte_meter/rte_meter_version.map +9 -0
@@ -17,3 +17,12 @@ DPDK_18.08 { rte_meter_srtcm_profile_config; rte_meter_trtcm_profile_config; }; + +EXPERIMENTAL { + global: + + rte_meter_trtcm_rfc4115_color_aware_check; + rte_meter_trtcm_rfc4115_color_blind_check; + rte_meter_trtcm_rfc4115_config; + rte_meter_trtcm_rfc4115_profile_config; +};
A message that is not in the archive (sent off-list or not yet received): CAJFAV8zUyBqEovvaChs3TO+Ah15T3davXPPkpDzzE2-fMQGD2g@mail.gmail.com
Re: [PATCH 3/3] lib/librte_meter: update abi to include new rfc4115 function
Quoted 22 lines · David Marchand
Hello Eelco,
Quoted 18 lines · Eelco Chaudron
Update the ABI to include the new RFC4115 meter functions
--- lib/librte_meter/Makefile | 2 +- lib/librte_meter/meson.build | 2 +- lib/librte_meter/rte_meter_version.map | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-)lib/librte_meter/Makefile +1
-1@@ -16,7 +16,7 @@ LDLIBS += -lrte_eal EXPORT_MAP := rte_meter_version.map -LIBABIVER := 2 +LIBABIVER := 3
Quoted 6 lines
lib/librte_meter/Makefile LDLIBS += -lrte_eal · line 22
Quoted 3 lines
lib/librte_meter/Makefile +0
-0# # all source are stored in SRCS-yAs far as I understood the policy around the EXPERIMENTAL section, you don't need to bump the library version.
Thought I would add the new function as none experimental, i.e. next version, but checkpatch did not allow me to do this.
Tried to find info on what the right process was, as these functions are just another meter implementation using similar existing APIs. If anyone has any background on this please point me to it.
I changed the library version as an existing data structure changed (which in theory should not change the location of the data), but the ABI check popped warnings so I decided to increase the version.
Quoted 2 lines
+ you should squash this into the first patch.
I’ll do this on the next version.
Thanks,
Eelco
Re: [PATCH 3/3] lib/librte_meter: update abi to include new rfc4115 function
28/11/2018 10:27, Eelco Chaudron:
Quoted 11 lines · David Marchand
Quoted 9 lines
lib/librte_meter/Makefile LDLIBS += -lrte_eal · line 19
Quoted 4 lines · Eelco Chaudron
lib/librte_meter/Makefile +1
-1-LIBABIVER := 2 +LIBABIVER := 3As far as I understood the policy around the EXPERIMENTAL section, you don't need to bump the library version.
Quoted 6 lines
Thought I would add the new function as none experimental, i.e. next version, but checkpatch did not allow me to do this.
Tried to find info on what the right process was, as these functions are just another meter implementation using similar existing APIs. If anyone has any background on this please point me to it.
It is documented here:
http://doc.dpdk.org/guides/contributing/versioning.html
The case for "similar API" is not handled specifically so far. So you need to introduce it as experimental.
Quoted 3 lines
I changed the library version as an existing data structure changed (which in theory should not change the location of the data), but the ABI check popped warnings so I decided to increase the version.
It deserves to analyze why the ABI check raises a warning. If it really needs to bump the ABI version, you should justify it in the commit message, and explain what changed in the ABI section of the release notes, plus update the version in the release notes.
Re: [PATCH 3/3] lib/librte_meter: update abi to include new rfc4115 function
Quoted 19 lines · Thomas Monjalon
28/11/2018 10:27, Eelco Chaudron:
Quoted 11 lines · David Marchand
Quoted 9 lines
lib/librte_meter/Makefile LDLIBS += -lrte_eal · line 19
Quoted 4 lines · Eelco Chaudron
lib/librte_meter/Makefile +1
-1-LIBABIVER := 2 +LIBABIVER := 3As far as I understood the policy around the EXPERIMENTAL section, you don't need to bump the library version.
Quoted 6 lines
Thought I would add the new function as none experimental, i.e. next version, but checkpatch did not allow me to do this.
Tried to find info on what the right process was, as these functions are just another meter implementation using similar existing APIs. If anyone has any background on this please point me to it.
Quoted 5 lines
It is documented here:
http://doc.dpdk.org/guides/contributing/versioning.htmlThe case for "similar API" is not handled specifically so far. So you need to introduce it as experimental.
Thanks for the clarification, will update the APIs with __rte_experimental in the next iteration.
Quoted 8 lines
Quoted 3 lines
I changed the library version as an existing data structure changed (which in theory should not change the location of the data), but the ABI check popped warnings so I decided to increase the version.
It deserves to analyze why the ABI check raises a warning. If it really needs to bump the ABI version, you should justify it in the commit message, and explain what changed in the ABI section of the release notes, plus update the version in the release notes.
Will look at it more closely and update it for the next iteration.
Re: [PATCH 3/3] lib/librte_meter: update abi to include new rfc4115 function
28/11/2018 13:40, Eelco Chaudron:
Quoted 25 lines · Thomas Monjalon
Quoted 23 lines
28/11/2018 10:27, Eelco Chaudron:
Quoted 20 lines · David Marchand
Quoted 10 lines
lib/librte_meter/Makefile LDLIBS += -lrte_eal · line 19
Quoted 4 lines · Eelco Chaudron
lib/librte_meter/Makefile +1
-1-LIBABIVER := 2 +LIBABIVER := 3As far as I understood the policy around the EXPERIMENTAL section, you
don't need to bump the library version.Thought I would add the new function as none experimental, i.e. next version, but checkpatch did not allow me to do this.
Tried to find info on what the right process was, as these functions are
just another meter implementation using similar existing APIs. If anyone
has any background on this please point me to it.
Quoted 8 lines
Quoted 5 lines
It is documented here:
http://doc.dpdk.org/guides/contributing/versioning.htmlThe case for "similar API" is not handled specifically so far. So you need to introduce it as experimental.
Thanks for the clarification, will update the APIs with
__rte_experimentalin the next iteration.
You should also add this on top of the doxygen comment:
* @warning
* @b EXPERIMENTAL: this API may change without prior notice
Re: [PATCH 3/3] lib/librte_meter: update abi to include new rfc4115 function
Quoted 32 lines · Thomas Monjalon
28/11/2018 13:40, Eelco Chaudron:
Quoted 31 lines · Thomas Monjalon
Quoted 28 lines
28/11/2018 10:27, Eelco Chaudron:
Quoted 12 lines · David Marchand
Quoted 10 lines
lib/librte_meter/Makefile LDLIBS += -lrte_eal · line 19
Quoted 4 lines · Eelco Chaudron
lib/librte_meter/Makefile +1
-1-LIBABIVER := 2 +LIBABIVER := 3As far as I understood the policy around the EXPERIMENTAL section, you
don't need to bump the library version.Quoted 8 lines
Thought I would add the new function as none experimental, i.e. next version, but checkpatch did not allow me to do this.
Tried to find info on what the right process was, as these functions are
just another meter implementation using similar existing APIs. If anyone
has any background on this please point me to it.It is documented here:
http://doc.dpdk.org/guides/contributing/versioning.htmlThe case for "similar API" is not handled specifically so far. So you need to introduce it as experimental.
Quoted 7 lines
Quoted 2 lines
Thanks for the clarification, will update the APIs with
__rte_experimentalin the next iteration.You should also add this on top of the doxygen comment:
* @warning
* @b EXPERIMENTAL: this API may change without prior notice
Thanks, done!