From 00fdf53c7076d1bd0045439e73f0144d613eb09c Mon Sep 17 00:00:00 2001 From: Chenmin Sun Date: Mon, 17 Feb 2020 02:19:15 +0800 Subject: gtpu: offload RX flow ip4 gtpu cli/api (using flow infra) to create flows and enable them on different hardware (currently tested with ice) to offload a gtpu tunnel onto hw: set flow-offload gtpu hw TwentyFiveGigabitEthernet3/0/0 rx gtpu_tunnel0 to remove offload: set flow-offload gtpu hw TwentyFiveGigabitEthernet3/0/0 rx gtpu_tunnel0 del TODO:ipv6 handling Type: feature Signed-off-by: Chenmin Sun Change-Id: I8e356feeb0b16cfeadc1bbbe92f773aa2916e715 --- src/plugins/gtpu/gtpu_test.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'src/plugins/gtpu/gtpu_test.c') diff --git a/src/plugins/gtpu/gtpu_test.c b/src/plugins/gtpu/gtpu_test.c index 55c5363becc..c780bd77d85 100644 --- a/src/plugins/gtpu/gtpu_test.c +++ b/src/plugins/gtpu/gtpu_test.c @@ -107,6 +107,12 @@ api_unformat_sw_if_index (unformat_input_t * input, va_list * args) return 1; } +static uword +api_unformat_hw_if_index (unformat_input_t * input, va_list * args) +{ + return 0; +} + static int api_sw_interface_set_gtpu_bypass (vat_main_t * vam) { @@ -173,6 +179,58 @@ static uword unformat_gtpu_decap_next return 1; } +static int +api_gtpu_offload_rx (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_gtpu_offload_rx_t *mp; + u32 rx_sw_if_index = ~0; + u32 hw_if_index = ~0; + int is_add = 1; + int ret; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam, &hw_if_index)) + ; + else + if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam, &rx_sw_if_index)) + ; + else + if (unformat (line_input, "del")) + { + is_add = 0; + continue; + } + else + { + errmsg ("parse error '%U'", format_unformat_error, line_input); + return -99; + } + } + + if (rx_sw_if_index == ~0) + { + errmsg ("missing rx interface"); + return -99; + } + + if (hw_if_index == ~0) + { + errmsg ("missing hw interface"); + return -99; + } + + M (GTPU_OFFLOAD_RX, mp); + mp->hw_if_index = ntohl (hw_if_index); + mp->sw_if_index = ntohl (rx_sw_if_index); + mp->enable = is_add; + + S (mp); + W (ret); + return ret; +} + static int api_gtpu_add_del_tunnel (vat_main_t * vam) { -- cgit 1.2.3-korg