From patchwork Mon Jan 25 01:20:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Zhang X-Patchwork-Id: 87165 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CF308A0A0B; Mon, 25 Jan 2021 02:20:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A531B140DD3; Mon, 25 Jan 2021 02:20:33 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 3ECEF140DD2 for ; Mon, 25 Jan 2021 02:20:32 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from lizh@nvidia.com) with SMTP; 25 Jan 2021 03:20:26 +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 10P1KQ9p024995; Mon, 25 Jan 2021 03:20:26 +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 Date: Mon, 25 Jan 2021 03:20:23 +0200 Message-Id: <20210125012023.1769769-2-lizh@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210125012023.1769769-1-lizh@nvidia.com> References: <20210125010235.1768333-2-lizh@nvidia.com> <20210125012023.1769769-1-lizh@nvidia.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] [RFC, v2]: adds support PPS(packet per second) on meter 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" Currently the flow Meter algorithms in rte_flow only supports bytes per second(BPS). Such as Single Rate Three Color Marker (srTCM rfc2697) This RFC adds the packet per second definition in Meter algorithms structure, to support the rte_mtr APIs with type srTCM pps mode. The below structure will be extended: rte_mtr_algorithm rte_mtr_meter_profile Signed-off-by: Li Zhang Acked-By: Morten Brørup --- lib/librte_ethdev/rte_mtr.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/librte_ethdev/rte_mtr.h b/lib/librte_ethdev/rte_mtr.h index 916a09c5c3..3e88904faf 100644 --- a/lib/librte_ethdev/rte_mtr.h +++ b/lib/librte_ethdev/rte_mtr.h @@ -119,6 +119,9 @@ enum rte_mtr_algorithm { /** Two Rate Three Color Marker (trTCM) - IETF RFC 4115. */ RTE_MTR_TRTCM_RFC4115, + + /** Single Rate Three Color Marker (srTCM) in Packet per second mode */ + RTE_MTR_SRTCM_PPS, }; /** @@ -171,6 +174,18 @@ struct rte_mtr_meter_profile { /** Excess Burst Size (EBS) (bytes). */ uint64_t ebs; } trtcm_rfc4115; + + /** Items only valid when *alg* is set to srTCM - PPS. */ + struct { + /** Committed Information Rate (CIR)(packets/second). */ + uint64_t cir; + + /** Committed Burst Size (CBS) (bytes). */ + uint64_t cbs; + + /** Excess Burst Size (EBS) (bytes). */ + uint64_t ebs; + } srtcm_pps; }; }; @@ -317,6 +332,13 @@ struct rte_mtr_capabilities { */ uint32_t meter_trtcm_rfc4115_n_max; + /** Maximum number of MTR objects that can have their meter configured + * to run the srTCM packet per second algorithm. The value of 0 + * indicates this metering algorithm is not supported. + * The maximum value is *n_max*. + */ + uint32_t meter_srtcm_pps_n_max; + /** Maximum traffic rate that can be metered by a single MTR object. For * srTCM RFC 2697, this is the maximum CIR rate. For trTCM RFC 2698, * this is the maximum PIR rate. For trTCM RFC 4115, this is the maximum @@ -342,6 +364,12 @@ struct rte_mtr_capabilities { */ int color_aware_trtcm_rfc4115_supported; + /** + * When non-zero, it indicates that color aware mode is supported for + * the srTCM packet per second metering algorithm. + */ + int color_aware_srtcm_pps_supported; + /** When non-zero, it indicates that the policer packet recolor actions * are supported. * @see enum rte_mtr_policer_action From patchwork Mon Mar 1 09:53:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhang X-Patchwork-Id: 88309 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3CF9BA055D; Mon, 1 Mar 2021 10:54:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3ED23406B4; Mon, 1 Mar 2021 10:53:59 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 58A3C4014E for ; Mon, 1 Mar 2021 10:53:58 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from lizh@nvidia.com) with SMTP; 1 Mar 2021 11:53:55 +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 1219rtBK006667; Mon, 1 Mar 2021 11:53:55 +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:53:50 +0200 Message-Id: <20210301095350.183502-5-lizh@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210301095350.183502-1-lizh@nvidia.com> References: <20210125012023.1769769-2-lizh@nvidia.com> <20210301095350.183502-1-lizh@nvidia.com> MIME-Version: 1.0 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 ~~~~~~~~~~~~~~~~~~~~~~~~~