app/testpmd: add commands traffic metering and policing

Add CLI commands to exercise the ethdev Traffic Metering and Policing
(MTR) API.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Reviewed-by: Jingjing Wu <jingjing.wu@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
This commit is contained in:
Cristian Dumitrescu 2017-10-13 13:22:18 +01:00
parent 5bf4bebb09
commit 30ffb4e67e
5 changed files with 1133 additions and 0 deletions

View File

@ -48,6 +48,7 @@ SRCS-y := testpmd.c
SRCS-y += parameters.c
SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline.c
SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_flow.c
SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_mtr.c
SRCS-y += config.c
SRCS-y += iofwd.c
SRCS-y += macfwd.c

View File

@ -99,6 +99,7 @@
#include <rte_pmd_bnxt.h>
#endif
#include "testpmd.h"
#include "cmdline_mtr.h"
static struct cmdline *testpmd_cl;
@ -234,6 +235,8 @@ static void cmd_help_long_parsed(void *parsed_result,
"show port (port_id) pctype mapping\n"
" Get flow ptype to pctype mapping on a port\n\n"
"show port meter stats (port_id) (meter_id) (clear)\n"
" Get meter stats on a port\n\n"
);
}
@ -675,6 +678,33 @@ 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"
" meter profile add - srtcm rfc 2697\n\n"
"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
" meter profile add - trtcm rfc 2698\n\n"
"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
" meter profile add - trtcm rfc 4115\n\n"
"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"
" meter create\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 policer action (port_id) (mtr_id) (color) (action)\n"
" meter update policer action\n\n"
"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
" meter update stats\n\n"
"show port (port_id) queue-region\n"
" show all queue region related configuration info\n\n"
@ -15540,6 +15570,15 @@ 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_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_del_port_meter,
(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
(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,
(cmdline_parse_inst_t *)&cmd_mcast_addr,
(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,

View File

@ -198,6 +198,8 @@ enum index {
ACTION_VF,
ACTION_VF_ORIGINAL,
ACTION_VF_ID,
ACTION_METER,
ACTION_METER_ID,
};
/** Size of pattern[] field in struct rte_flow_item_raw. */
@ -614,6 +616,7 @@ static const enum index next_action[] = {
ACTION_RSS,
ACTION_PF,
ACTION_VF,
ACTION_METER,
ZERO,
};
@ -648,6 +651,12 @@ static const enum index action_vf[] = {
ZERO,
};
static const enum index action_meter[] = {
ACTION_METER_ID,
ACTION_NEXT,
ZERO,
};
static int parse_init(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
@ -1606,6 +1615,21 @@ static const struct token token_list[] = {
.args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
.call = parse_vc_conf,
},
[ACTION_METER] = {
.name = "meter",
.help = "meter the directed packets at given id",
.priv = PRIV_ACTION(METER,
sizeof(struct rte_flow_action_meter)),
.next = NEXT(action_meter),
.call = parse_vc,
},
[ACTION_METER_ID] = {
.name = "mtr_id",
.help = "meter id to use",
.next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
.args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
.call = parse_vc_conf,
},
};
/** Remove and return last entry from argument stack. */

1020
app/test-pmd/cmdline_mtr.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2017 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _CMDLINE_MTR_H_
#define _CMDLINE_MTR_H_
/* Traffic Metering and Policing */
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_del_port_meter;
extern cmdline_parse_inst_t cmd_set_port_meter_profile;
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;
#endif /* _CMDLINE_MTR_H_ */