From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1D583A0561; Mon, 1 Mar 2021 10:40:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 650AB1CC4DB; Mon, 1 Mar 2021 10:40:18 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 715B21CC4DA for ; Mon, 1 Mar 2021 10:40:17 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from lizh@nvidia.com) with SMTP; 1 Mar 2021 11:40:11 +0200 Received: from nvidia.com (c-235-17-1-009.mtl.labs.mlnx [10.235.17.9]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 1219e4VR020473; Mon, 1 Mar 2021 11:40:11 +0200 From: Li Zhang To: dekelp@nvidia.com, orika@nvidia.com, viacheslavo@nvidia.com, matan@nvidia.com Cc: dev@dpdk.org, thomas@monjalon.net, rasland@nvidia.com, mb@smartsharesystems.com, ajit.khaparde@broadcom.com Date: Mon, 1 Mar 2021 11:40:00 +0200 Message-Id: <20210301094000.183002-5-lizh@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210301094000.183002-1-lizh@nvidia.com> References: <20210125012023.1769769-2-lizh@nvidia.com> <20210301094000.183002-1-lizh@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [RFC v3 4/4] app/testpmd: add meter pps mode cmd X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Support meter pps mode Signed-off-by: Li Zhang --- app/test-pmd/cmdline.c | 4 + app/test-pmd/cmdline_mtr.c | 105 ++++++++++++++++++++ app/test-pmd/cmdline_mtr.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 +++ 4 files changed, 125 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index d274a7cb8c..1a3fc644dc 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -698,6 +698,9 @@ static void cmd_help_long_parsed(void *parsed_result, "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" " meter profile add - trtcm rfc 4115\n\n" + "add port meter profile srtcmp (port_id) (profile_id) (cipr) (cpbs) (epbs)\n" + " meter profile add - srtcmp packet per second\n\n" + "del port meter profile (port_id) (profile_id)\n" " meter profile delete\n\n" @@ -17006,6 +17009,7 @@ cmdline_parse_ctx_t main_ctx[] = { (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_add_port_meter_profile_srtcmp, (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, diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c index 399ee56e07..3f62240a0d 100644 --- a/app/test-pmd/cmdline_mtr.c +++ b/app/test-pmd/cmdline_mtr.c @@ -295,6 +295,8 @@ static void cmd_show_port_meter_cap_parsed(void *parsed_result, cap.meter_trtcm_rfc2698_n_max); printf("cap.meter_trtcm_rfc4115_n_max %" PRIu32 "\n", cap.meter_trtcm_rfc4115_n_max); + printf("cap.meter_srtcmp_n_max %" PRIu32 "\n", + cap.meter_srtcmp_n_max); printf("cap.meter_rate_max %" PRIu64 "\n", cap.meter_rate_max); printf("cap.color_aware_srtcm_rfc2697_supported %" PRId32 "\n", cap.color_aware_srtcm_rfc2697_supported); @@ -302,6 +304,8 @@ static void cmd_show_port_meter_cap_parsed(void *parsed_result, cap.color_aware_trtcm_rfc2698_supported); printf("cap.color_aware_trtcm_rfc4115_supported %" PRId32 "\n", cap.color_aware_trtcm_rfc4115_supported); + printf("cap.color_aware_srtcmp_supported %" PRId32 "\n", + cap.color_aware_srtcmp_supported); printf("cap.policer_action_recolor_supported %" PRId32 "\n", cap.policer_action_recolor_supported); printf("cap.policer_action_drop_supported %" PRId32 "\n", @@ -644,6 +648,107 @@ cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115 = { }, }; +/* *** Add Port Meter Profile srtcmp *** */ +struct cmd_add_port_meter_profile_srtcmp_result { + cmdline_fixed_string_t add; + cmdline_fixed_string_t port; + cmdline_fixed_string_t meter; + cmdline_fixed_string_t profile; + cmdline_fixed_string_t srtcmp; + uint16_t port_id; + uint32_t profile_id; + uint64_t cir; + uint64_t cbs; + uint64_t ebs; +}; + +cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcmp_add = + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_meter_profile_srtcmp_result, add, "add"); +cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcmp_port = + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_meter_profile_srtcmp_result, + port, "port"); +cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcmp_meter = + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_meter_profile_srtcmp_result, + meter, "meter"); +cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcmp_profile = + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_meter_profile_srtcmp_result, + profile, "profile"); +cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcmp_srtcmp = + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_meter_profile_srtcmp_result, + srtcmp, "srtcmp"); +cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcmp_port_id = + TOKEN_NUM_INITIALIZER( + struct cmd_add_port_meter_profile_srtcmp_result, + port_id, RTE_UINT16); +cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcmp_profile_id = + TOKEN_NUM_INITIALIZER( + struct cmd_add_port_meter_profile_srtcmp_result, + profile_id, RTE_UINT32); +cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcmp_cir = + TOKEN_NUM_INITIALIZER( + struct cmd_add_port_meter_profile_srtcmp_result, + cir, RTE_UINT64); +cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcmp_cbs = + TOKEN_NUM_INITIALIZER( + struct cmd_add_port_meter_profile_srtcmp_result, + cbs, RTE_UINT64); +cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcmp_ebs = + TOKEN_NUM_INITIALIZER( + struct cmd_add_port_meter_profile_srtcmp_result, + ebs, RTE_UINT64); + +static void cmd_add_port_meter_profile_srtcmp_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_add_port_meter_profile_srtcmp_result *res = parsed_result; + struct rte_mtr_meter_profile mp; + struct rte_mtr_error error; + uint32_t profile_id = res->profile_id; + uint16_t port_id = res->port_id; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + + /* Private shaper profile params */ + memset(&mp, 0, sizeof(struct rte_mtr_meter_profile)); + mp.alg = RTE_MTR_SRTCMP; + mp.srtcmp.cir = res->cir; + mp.srtcmp.cbs = res->cbs; + mp.srtcmp.ebs = res->ebs; + + ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error); + if (ret != 0) { + print_err_msg(&error); + return; + } +} + +cmdline_parse_inst_t cmd_add_port_meter_profile_srtcmp = { + .f = cmd_add_port_meter_profile_srtcmp_parsed, + .data = NULL, + .help_str = "Add port meter profile srtcmp", + .tokens = { + (void *)&cmd_add_port_meter_profile_srtcmp_add, + (void *)&cmd_add_port_meter_profile_srtcmp_port, + (void *)&cmd_add_port_meter_profile_srtcmp_meter, + (void *)&cmd_add_port_meter_profile_srtcmp_profile, + (void *)&cmd_add_port_meter_profile_srtcmp_srtcmp, + (void *)&cmd_add_port_meter_profile_srtcmp_port_id, + (void *)&cmd_add_port_meter_profile_srtcmp_profile_id, + (void *)&cmd_add_port_meter_profile_srtcmp_cir, + (void *)&cmd_add_port_meter_profile_srtcmp_cbs, + (void *)&cmd_add_port_meter_profile_srtcmp_ebs, + NULL, + }, +}; + /* *** Delete Port Meter Profile *** */ struct cmd_del_port_meter_profile_result { cmdline_fixed_string_t del; diff --git a/app/test-pmd/cmdline_mtr.h b/app/test-pmd/cmdline_mtr.h index e69d6da023..01ef85e1e7 100644 --- a/app/test-pmd/cmdline_mtr.h +++ b/app/test-pmd/cmdline_mtr.h @@ -10,6 +10,7 @@ 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_add_port_meter_profile_srtcmp; 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; diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 37278d31d6..d11de05583 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2734,6 +2734,21 @@ where: * ``cbs``: Committed burst size (bytes). * ``ebs``: Excess burst size (bytes). +add port meter profile (srTcmp) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Add meter profile (srTcmp) to the ethernet device:: + + testpmd> add port meter profile srtcmp (port_id) (profile_id) \ + (cir) (cbs) (ebs) + +where: + +* ``profile_id``: ID for the meter profile. +* ``cpr``: Committed Information Rate (CIR) (packets/second). +* ``cbs``: Committed Burst Size (CBS) (packets). +* ``ebs``: Excess Burst Size (EBS) (packets). + delete port meter profile ~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.21.0