From patchwork Mon Mar 1 09:39:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhang X-Patchwork-Id: 88300 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 8A07AA0561; Mon, 1 Mar 2021 10:40:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1365F4067B; Mon, 1 Mar 2021 10:40:08 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 4DE434067B for ; Mon, 1 Mar 2021 10:40:07 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from lizh@nvidia.com) with SMTP; 1 Mar 2021 11:40:06 +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 1219e4VO020473; Mon, 1 Mar 2021 11:40:06 +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:39:57 +0200 Message-Id: <20210301094000.183002-2-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 Subject: [dpdk-dev] [RFC v3 1/4] ethdev: add meter PPS profile 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 meter algorithms only supports rate is bytes per second(BPS). Add this new meter srTCMp algorithm to support rate is packet per second. So that it can meter traffic by packet per second. The below structure will be extended: rte_mtr_algorithm rte_mtr_meter_profile Signed-off-by: Li Zhang --- .../traffic_metering_and_policing.rst | 3 +- doc/guides/rel_notes/release_20_11.rst | 5 +++ lib/librte_ethdev/rte_mtr.h | 32 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/doc/guides/prog_guide/traffic_metering_and_policing.rst b/doc/guides/prog_guide/traffic_metering_and_policing.rst index 90c781eb1d..4d2405d44a 100644 --- a/doc/guides/prog_guide/traffic_metering_and_policing.rst +++ b/doc/guides/prog_guide/traffic_metering_and_policing.rst @@ -17,7 +17,8 @@ The main features are: * Part of DPDK rte_ethdev API * Capability query API * Metering algorithms: RFC 2697 Single Rate Three Color Marker (srTCM), RFC 2698 - and RFC 4115 Two Rate Three Color Marker (trTCM) + and RFC 4115 Two Rate Three Color Marker (trTCM), + Single Rate Three Color Marker, Packet based (srTCMp). * Policer actions (per meter output color): recolor, drop * Statistics (per policer output color) diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst index 7405a9864f..de04886cc9 100644 --- a/doc/guides/rel_notes/release_20_11.rst +++ b/doc/guides/rel_notes/release_20_11.rst @@ -429,6 +429,11 @@ New Features can leverage IOAT DMA channels with vhost asynchronous APIs. See the :doc:`../sample_app_ug/vhost` for more details. +* **Added support for meter PPS profile.** + + Currently meter algorithms only supports bytes per second(BPS). + Add this new meter algorithm to support packet per second (PPS) mode. + So that it can meter traffic by packet per second. Removed Items ------------- diff --git a/lib/librte_ethdev/rte_mtr.h b/lib/librte_ethdev/rte_mtr.h index 916a09c5c3..f27a4b5354 100644 --- a/lib/librte_ethdev/rte_mtr.h +++ b/lib/librte_ethdev/rte_mtr.h @@ -119,6 +119,11 @@ enum rte_mtr_algorithm { /** Two Rate Three Color Marker (trTCM) - IETF RFC 4115. */ RTE_MTR_TRTCM_RFC4115, + + /** Single Rate Three Color Marker, Packet based (srTCMp). + * - - similar to IETF RFC 2697 but rate is packet per second. + */ + RTE_MTR_SRTCMP, }; /** @@ -171,6 +176,20 @@ struct rte_mtr_meter_profile { /** Excess Burst Size (EBS) (bytes). */ uint64_t ebs; } trtcm_rfc4115; + + /** Items only valid when *alg* is set to srTCMp. */ + struct { + /** Committed Information Rate (CIR) + * (packets/second). + */ + uint64_t cir; + + /** Committed Burst Size (CBS) (packets). */ + uint64_t cbs; + + /** Excess Burst Size (EBS) (packets). */ + uint64_t ebs; + } srtcmp; }; }; @@ -317,6 +336,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 srTCMp algorithm. The value of 0 + * indicates this metering algorithm is not supported. + * The maximum value is *n_max*. + */ + uint32_t meter_srtcmp_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 +368,12 @@ struct rte_mtr_capabilities { */ int color_aware_trtcm_rfc4115_supported; + /** + * When non-zero, it indicates that color aware mode is supported for + * the srTCMp metering algorithm. + */ + int color_aware_srtcmp_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:39:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhang X-Patchwork-Id: 88303 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 7E84FA0561; Mon, 1 Mar 2021 10:40:28 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 295821CC4D4; Mon, 1 Mar 2021 10:40:15 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 519301CC3B1 for ; Mon, 1 Mar 2021 10:40:12 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from lizh@nvidia.com) with SMTP; 1 Mar 2021 11:40:07 +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 1219e4VP020473; Mon, 1 Mar 2021 11:40:07 +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:39:58 +0200 Message-Id: <20210301094000.183002-3-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 Subject: [dpdk-dev] [RFC v3 2/4] common/mlx5: add meter mode definition in PRM file 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" Add meter mode definition in PRM file Signed-off-by: Li Zhang --- drivers/common/mlx5/mlx5_prm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index e3d4120849..609b1c3951 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -2177,6 +2177,13 @@ struct mlx5_ifc_flow_meter_parameters_bits { #define MLX5_IFC_FLOW_METER_PARAM_MASK UINT64_C(0x80FFFFFF) #define MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL 0x14BF00C8 +enum { + MLX5_METER_MODE_IP_LEN = 0x0, + MLX5_METER_MODE_L2_LEN = 0x1, + MLX5_METER_MODE_L2_IPG_LEN = 0x2, + MLX5_METER_MODE_PKT = 0x3, +}; + enum { MLX5_CQE_SIZE_64B = 0x0, MLX5_CQE_SIZE_128B = 0x1, @@ -2508,6 +2515,7 @@ struct mlx5_aso_mtr_dseg { #define ASO_DSEG_VALID_OFFSET 31 #define ASO_DSEG_BO_OFFSET 30 #define ASO_DSEG_SC_OFFSET 28 +#define ASO_DSEG_MTR_MODE 24 #define ASO_DSEG_CBS_EXP_OFFSET 24 #define ASO_DSEG_CBS_MAN_OFFSET 16 #define ASO_DSEG_CIR_EXP_MASK 0x1F From patchwork Mon Mar 1 09:39:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhang X-Patchwork-Id: 88302 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 6114EA0561; Mon, 1 Mar 2021 10:40:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CCA7E1CC3B6; Mon, 1 Mar 2021 10:40:13 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 51BE11CC3C7 for ; Mon, 1 Mar 2021 10:40:12 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from lizh@nvidia.com) with SMTP; 1 Mar 2021 11:40:09 +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 1219e4VQ020473; Mon, 1 Mar 2021 11:40:09 +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:39:59 +0200 Message-Id: <20210301094000.183002-4-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 Subject: [dpdk-dev] [RFC v3 3/4] net/mlx5: support meter PPS profile 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 meter algorithms only supports bytes per second(BPS). Such as Single Rate Three Color Marker (srTCM rfc2697) Add this new meter srTCMp algorithm to support rate is packet per second. So that it can meter traffic by packet per second (PPS). Signed-off-by: Li Zhang --- doc/guides/nics/mlx5.rst | 1 + drivers/net/mlx5/mlx5.h | 13 ++++-- drivers/net/mlx5/mlx5_flow_aso.c | 17 ++++--- drivers/net/mlx5/mlx5_flow_meter.c | 71 ++++++++++++++++++++++++------ 4 files changed, 79 insertions(+), 23 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index a390a4b53c..93f5c0e4d4 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -362,6 +362,7 @@ Limitations - Green color is not supported with drop action. - Yellow detection is not supported. - Red color must be with drop action. + - meter srTCMp algorithm is supported. Statistics ---------- diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 2790995dcc..16fa1b6c4d 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -742,8 +742,13 @@ struct mlx5_flow_meter_info { /**< Flow meter action. */ }; -/* RFC2697 parameter structure. */ -struct mlx5_flow_meter_srtcm_rfc2697_prm { +/* PPS(packets per second) map to BPS(Bytes per second). + * HW treat packet as 128bytes in PPS mode + */ +#define MLX5_MTRS_PPS_MAP_BPS_SHIFT 7 + +/* RFC2697/PPS parameter structure. */ +struct mlx5_flow_meter_srtcm_prm { rte_be32_t cbs_cir; /* * bit 24-28: cbs_exponent, bit 16-23 cbs_mantissa, @@ -763,8 +768,8 @@ struct mlx5_flow_meter_profile { uint32_t id; /**< Profile id. */ struct rte_mtr_meter_profile profile; /**< Profile detail. */ union { - struct mlx5_flow_meter_srtcm_rfc2697_prm srtcm_prm; - /**< srtcm_rfc2697 struct. */ + struct mlx5_flow_meter_srtcm_prm srtcm_prm; + /**< srtcm_rfc2697/srtcm_pps struct. */ }; uint32_t ref_cnt; /**< Use count. */ }; diff --git a/drivers/net/mlx5/mlx5_flow_aso.c b/drivers/net/mlx5/mlx5_flow_aso.c index c9280b1f9d..3f3ba7e8fa 100644 --- a/drivers/net/mlx5/mlx5_flow_aso.c +++ b/drivers/net/mlx5/mlx5_flow_aso.c @@ -244,7 +244,6 @@ mlx5_aso_mtr_init_sq(struct mlx5_aso_sq *sq) volatile struct mlx5_aso_wqe *restrict wqe; int i; int size = 1 << sq->log_desc_n; - uint32_t idx; /* All the next fields state should stay constant. */ for (i = 0, wqe = &sq->wqes[0]; i < size; ++i, ++wqe) { @@ -257,11 +256,6 @@ mlx5_aso_mtr_init_sq(struct mlx5_aso_sq *sq) (BYTEWISE_64BYTE << ASO_CSEG_DATA_MASK_MODE_OFFSET)); wqe->general_cseg.flags = RTE_BE32(MLX5_COMP_ALWAYS << MLX5_COMP_MODE_OFFSET); - for (idx = 0; idx < MLX5_ASO_METERS_PER_WQE; - idx++) - wqe->aso_dseg.mtrs[idx].v_bo_sc_bbog_mm = - RTE_BE32((1 << ASO_DSEG_VALID_OFFSET) | - (MLX5_FLOW_COLOR_GREEN << ASO_DSEG_SC_OFFSET)); } } @@ -744,6 +738,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq, { volatile struct mlx5_aso_wqe *wqe = NULL; struct mlx5_flow_meter_info *fm = NULL; + struct mlx5_flow_meter_profile *fmp; uint16_t size = 1 << sq->log_desc_n; uint16_t mask = size - 1; uint16_t res = size - (uint16_t)(sq->head - sq->tail); @@ -781,6 +776,16 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq, RTE_BE32(MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL); wqe->aso_dseg.mtrs[dseg_idx].ebs_eir = 0; } + fmp = fm->profile; + if (fmp->profile.alg == RTE_MTR_SRTCMP) + wqe->aso_dseg.mtrs[dseg_idx].v_bo_sc_bbog_mm = + RTE_BE32((1 << ASO_DSEG_VALID_OFFSET) | + (MLX5_FLOW_COLOR_GREEN << ASO_DSEG_SC_OFFSET) | + (MLX5_METER_MODE_PKT << ASO_DSEG_MTR_MODE)); + else + wqe->aso_dseg.mtrs[dseg_idx].v_bo_sc_bbog_mm = + RTE_BE32((1 << ASO_DSEG_VALID_OFFSET) | + (MLX5_FLOW_COLOR_GREEN << ASO_DSEG_SC_OFFSET)); sq->head++; sq->pi += 2;/* Each WQE contains 2 WQEBB's. */ rte_io_wmb(); diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 49f6229ae6..cf2fe8c173 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -33,7 +33,7 @@ mlx5_flow_meter_action_create(struct mlx5_priv *priv, #ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER struct mlx5dv_dr_flow_meter_attr mtr_init; uint32_t fmp[MLX5_ST_SZ_DW(flow_meter_parameters)]; - struct mlx5_flow_meter_srtcm_rfc2697_prm *srtcm = + struct mlx5_flow_meter_srtcm_prm *srtcm = &fm->profile->srtcm_prm; uint32_t cbs_cir = rte_be_to_cpu_32(srtcm->cbs_cir); uint32_t ebs_eir = rte_be_to_cpu_32(srtcm->ebs_eir); @@ -157,6 +157,32 @@ mlx5_flow_meter_profile_validate(struct rte_eth_dev *dev, "Invalid metering parameters."); } } + if (priv->sh->meter_aso_en && + profile->alg == RTE_MTR_SRTCMP) { + if (priv->config.hca_attr.qos.srtcm_sup) { + /* Verify support for flow meter parameters. */ + if (profile->srtcmp.cir > 0 && + (profile->srtcmp.cir << + MLX5_MTRS_PPS_MAP_BPS_SHIFT) + <= MLX5_SRTCM_CIR_MAX && + profile->srtcmp.cbs > 0 && + (profile->srtcmp.cbs << + MLX5_MTRS_PPS_MAP_BPS_SHIFT) + <= MLX5_SRTCM_CBS_MAX && + (profile->srtcmp.ebs << + MLX5_MTRS_PPS_MAP_BPS_SHIFT) + <= MLX5_SRTCM_EBS_MAX) + return 0; + else + return -rte_mtr_error_set + (error, ENOTSUP, + RTE_MTR_ERROR_TYPE_MTR_PARAMS, + NULL, + profile->srtcmp.ebs ? + "Metering value ebs must be 0." : + "Invalid metering parameters."); + } + } return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_PROFILE, NULL, "Metering algorithm not supported."); @@ -238,19 +264,35 @@ mlx5_flow_meter_xbs_man_exp_calc(uint64_t xbs, uint8_t *man, uint8_t *exp) */ static int mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp, - struct rte_mtr_error *error) + struct mlx5_priv *priv, struct rte_mtr_error *error) { - struct mlx5_flow_meter_srtcm_rfc2697_prm *srtcm = &fmp->srtcm_prm; + struct mlx5_flow_meter_srtcm_prm *srtcm = &fmp->srtcm_prm; uint8_t man, exp; uint32_t cbs_exp, cbs_man, cir_exp, cir_man; uint32_t ebs_exp, ebs_man; + uint64_t cir, cbs, ebs; - if (fmp->profile.alg != RTE_MTR_SRTCM_RFC2697) - return -rte_mtr_error_set(error, ENOTSUP, + if (fmp->profile.alg == RTE_MTR_SRTCM_RFC2697) { + cir = fmp->profile.srtcm_rfc2697.cir; + cbs = fmp->profile.srtcm_rfc2697.cbs; + ebs = fmp->profile.srtcm_rfc2697.ebs; + } else { + if (priv->sh->meter_aso_en && + fmp->profile.alg == RTE_MTR_SRTCMP) { + cir = fmp->profile.srtcmp.cir << + MLX5_MTRS_PPS_MAP_BPS_SHIFT; + cbs = fmp->profile.srtcmp.cbs << + MLX5_MTRS_PPS_MAP_BPS_SHIFT; + ebs = fmp->profile.srtcmp.ebs << + MLX5_MTRS_PPS_MAP_BPS_SHIFT; + } else { + return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_PROFILE, NULL, "Metering algorithm not supported."); + } + } /* cir = 8G * cir_mantissa * 1/(2^cir_exponent)) Bytes/Sec */ - mlx5_flow_meter_cir_man_exp_calc(fmp->profile.srtcm_rfc2697.cir, + mlx5_flow_meter_cir_man_exp_calc(cir, &man, &exp); /* Check if cir mantissa is too large. */ if (exp > ASO_DSEG_CIR_EXP_MASK) @@ -261,7 +303,7 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp, cir_man = man; cir_exp = exp; /* cbs = cbs_mantissa * 2^cbs_exponent */ - mlx5_flow_meter_xbs_man_exp_calc(fmp->profile.srtcm_rfc2697.cbs, + mlx5_flow_meter_xbs_man_exp_calc(cbs, &man, &exp); /* Check if cbs mantissa is too large. */ if (exp > ASO_DSEG_EXP_MASK) @@ -275,7 +317,7 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp, cbs_man << ASO_DSEG_CBS_MAN_OFFSET | cir_exp << ASO_DSEG_CIR_EXP_OFFSET | cir_man); - mlx5_flow_meter_xbs_man_exp_calc(fmp->profile.srtcm_rfc2697.ebs, + mlx5_flow_meter_xbs_man_exp_calc(ebs, &man, &exp); /* Check if ebs mantissa is too large. */ if (exp > ASO_DSEG_EXP_MASK) @@ -316,11 +358,14 @@ mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev, RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL, "Meter is not supported"); memset(cap, 0, sizeof(*cap)); - if (priv->sh->meter_aso_en) + if (priv->sh->meter_aso_en) { /* 2 meters per one ASO cache line. */ cap->n_max = 1 << (qattr->log_max_num_meter_aso + 1); - else + cap->meter_srtcmp_n_max = qattr->srtcm_sup ? cap->n_max : 0; + } else { cap->n_max = 1 << qattr->log_max_flow_meter; + cap->meter_srtcmp_n_max = 0; + } cap->n_shared_max = cap->n_max; cap->identical = 1; cap->shared_identical = 1; @@ -382,7 +427,7 @@ mlx5_flow_meter_profile_add(struct rte_eth_dev *dev, fmp->id = meter_profile_id; fmp->profile = *profile; /* Fill the flow meter parameters for the PRM. */ - ret = mlx5_flow_meter_param_fill(fmp, error); + ret = mlx5_flow_meter_param_fill(fmp, priv, error); if (ret) goto error; /* Add to list. */ @@ -539,7 +584,7 @@ mlx5_flow_meter_validate(struct mlx5_priv *priv, uint32_t meter_id, static int mlx5_flow_meter_action_modify(struct mlx5_priv *priv, struct mlx5_flow_meter_info *fm, - const struct mlx5_flow_meter_srtcm_rfc2697_prm *srtcm, + const struct mlx5_flow_meter_srtcm_prm *srtcm, uint64_t modify_bits, uint32_t active_state, uint32_t is_enable) { #ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER @@ -899,7 +944,7 @@ mlx5_flow_meter_modify_state(struct mlx5_priv *priv, uint32_t new_state, struct rte_mtr_error *error) { - static const struct mlx5_flow_meter_srtcm_rfc2697_prm srtcm = { + static const struct mlx5_flow_meter_srtcm_prm srtcm = { .cbs_cir = RTE_BE32(MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL), .ebs_eir = 0, }; From patchwork Mon Mar 1 09:40:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhang X-Patchwork-Id: 88304 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 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 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 ~~~~~~~~~~~~~~~~~~~~~~~~~