diff options
author | Dave Barach <dave@barachs.net> | 2019-04-03 11:20:06 -0400 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-04-11 01:19:56 +0000 |
commit | 7c91007e1e13b56a29236bd076891709eaa21754 (patch) | |
tree | e6d78635a3b53f6db4b0bfa563d98254c464da6f /src/plugins/nsim/nsim_test.c | |
parent | 10dc2eabd6e8a266405aef270a819794a3ddd333 (diff) |
Make the loss / delay sim available as an output feature
Add binary api and debug cli support.
Rewrite for speed: enqueue vlib_buffer_t's to the wheel, instead of
memcpy'ing data. Quad-loop the output feature / x-connect (interior)
node. Prefetch wheel entries in the input node.
Save packet-generator-based unit-test setup in extras/nsim.
Simple config example:
set nsim delay 20 ms bandwidth 1 gbit packet-size 1024
nsim output-feature enable-disable GigabitEthernet3/0/0
Change-Id: I852a32d4eb596e7e2aa1d9b30bf3b53525e39fd1
Signed-off-by: Dave Barach <dave@barachs.net>c
Diffstat (limited to 'src/plugins/nsim/nsim_test.c')
-rw-r--r-- | src/plugins/nsim/nsim_test.c | 62 |
1 files changed, 54 insertions, 8 deletions
diff --git a/src/plugins/nsim/nsim_test.c b/src/plugins/nsim/nsim_test.c index 7123703fd42..35f222eadf0 100644 --- a/src/plugins/nsim/nsim_test.c +++ b/src/plugins/nsim/nsim_test.c @@ -60,7 +60,8 @@ nsim_test_main_t nsim_test_main; #include <vlibapi/vat_helper_macros.h> #define foreach_standard_reply_retval_handler \ -_(nsim_enable_disable_reply) \ +_(nsim_cross_connect_enable_disable_reply) \ +_(nsim_output_feature_enable_disable_reply) \ _(nsim_configure_reply) #define _(n) \ @@ -83,19 +84,22 @@ foreach_standard_reply_retval_handler; * Table of message reply handlers, must include boilerplate handlers * we just generated */ -#define foreach_vpe_api_reply_msg \ -_(NSIM_ENABLE_DISABLE_REPLY, nsim_enable_disable_reply) \ +#define foreach_vpe_api_reply_msg \ +_(NSIM_CROSS_CONNECT_ENABLE_DISABLE_REPLY, \ +nsim_cross_connect_enable_disable_reply) \ +_(NSIM_OUTPUT_FEATURE_ENABLE_DISABLE_REPLY, \ +nsim_output_feature_enable_disable_reply) \ _(NSIM_CONFIGURE_REPLY, nsim_configure_reply) static int -api_nsim_enable_disable (vat_main_t * vam) +api_nsim_cross_connect_enable_disable (vat_main_t * vam) { unformat_input_t *i = vam->input; int enable_disable = 1; u32 sw_if_index0 = ~0; u32 sw_if_index1 = ~0; u32 tmp; - vl_api_nsim_enable_disable_t *mp; + vl_api_nsim_cross_connect_enable_disable_t *mp; int ret; /* Parse args required to build the message */ @@ -128,7 +132,7 @@ api_nsim_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M (NSIM_ENABLE_DISABLE, mp); + M (NSIM_CROSS_CONNECT_ENABLE_DISABLE, mp); mp->sw_if_index0 = ntohl (sw_if_index0); mp->sw_if_index1 = ntohl (sw_if_index1); mp->enable_disable = enable_disable; @@ -141,6 +145,47 @@ api_nsim_enable_disable (vat_main_t * vam) return ret; } +static int +api_nsim_output_feature_enable_disable (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + int enable_disable = 1; + u32 sw_if_index = ~0; + vl_api_nsim_output_feature_enable_disable_t *mp; + int ret; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (i, "disable")) + enable_disable = 0; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("missing interface name / explicit sw_if_index number \n"); + return -99; + } + + /* Construct the API message */ + M (NSIM_OUTPUT_FEATURE_ENABLE_DISABLE, mp); + mp->sw_if_index = ntohl (sw_if_index); + mp->enable_disable = enable_disable; + + /* send it... */ + S (mp); + + /* Wait for a reply... */ + W (ret); + return ret; +} + static uword unformat_delay (unformat_input_t * input, va_list * args) { @@ -229,9 +274,10 @@ api_nsim_configure (vat_main_t * vam) * and that the data plane plugin processes */ #define foreach_vpe_api_msg \ -_(nsim_enable_disable, \ +_(nsim_cross_connect_enable_disable, \ "[<intfc0> | sw_if_index <swif0>] [<intfc1> | sw_if_index <swif1>] [disable]") \ -_(nsim_configure, "delay <time> bandwidth <bw> [packet-size <nn>]" \ +_(nsim_output_feature_enable_disable,"[<intfc> | sw_if_index <nnn> [disable]") \ +_(nsim_configure, "delay <time> bandwidth <bw> [packet-size <nn>]" \ "[packets-per-drop <nnnn>]") static void |