From patchwork Thu Jan 13 12:28:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Kudurumalla X-Patchwork-Id: 105785 X-Patchwork-Delegate: jerinj@marvell.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 265A4A0093; Thu, 13 Jan 2022 13:28:18 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 954074272D; Thu, 13 Jan 2022 13:28:17 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id C95B740150 for ; Thu, 13 Jan 2022 13:28:15 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20DA79EZ030480; Thu, 13 Jan 2022 04:28:14 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=dVX5O3+F/+vMAmwg//A0hudFPwGXTjBZSAG109my5MY=; b=bcjthehTpPTkWe4uyEW3kFwFT3BqAtn4gb2hOfKK/pxv8f+KmRrRWknj4xmTCXTnVXsH Iiy4Z8lSDG2Gak9cVSYUcOUsIAAD9vjVmIW9NqYhXhinUCCVC7dbqxofHvJLs4jXJ7Ln 1pzRiIZfvqgiv0sX8eoLK/rFWoHgowZP2GfnCYtdjBDYuVANGHtbmDZraByX2vu5jeZT rLcMfd41L01BO/8yiHVSfQmCCM7iqqQItubAiFtVXfn93CQvlie6YGT5o6lAA0vAKHjv Tz31Aas/9rwOAks2ah+YumJMAbBM0IS/x3Qdiu9HhsxUQuVMVWfP2zLDwbGpIM8uRdRt /A== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3djarn9wvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 04:28:14 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 13 Jan 2022 04:28:12 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 13 Jan 2022 04:28:12 -0800 Received: from localhost.localdomain (unknown [10.28.48.103]) by maili.marvell.com (Postfix) with ESMTP id 812E53F708E; Thu, 13 Jan 2022 04:28:10 -0800 (PST) From: Rakesh Kudurumalla To: , Nithin Dabilpuram , "Kiran Kumar K" , Sunil Kumar Kori , Satha Rao CC: , Rakesh Kudurumalla , "Sunil Kumar Kori" Subject: [PATCH v3 1/2] net/cnxk: update meter bpf ID in Receive Queue Date: Thu, 13 Jan 2022 17:58:06 +0530 Message-ID: <20220113122807.1570511-1-rkudurumalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211130064147.1023321-1-rkudurumalla@marvell.com> References: <20211130064147.1023321-1-rkudurumalla@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: sdDOP3DxFzcvqB0XoTydKKxHaEInLb9H X-Proofpoint-ORIG-GUID: sdDOP3DxFzcvqB0XoTydKKxHaEInLb9H X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-13_04,2022-01-13_01,2021-12-02_01 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 Patch updates configured meter bpf is in receive queue context during meter creation Signed-off-by: Rakesh Kudurumalla Acked-by: Sunil Kumar Kori --- v3: Fix commit message spelling drivers/net/cnxk/cn10k_rte_flow.c | 7 +++---- drivers/net/cnxk/cnxk_ethdev_mtr.c | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/net/cnxk/cn10k_rte_flow.c b/drivers/net/cnxk/cn10k_rte_flow.c index b830abe63e..529fb0e4b7 100644 --- a/drivers/net/cnxk/cn10k_rte_flow.c +++ b/drivers/net/cnxk/cn10k_rte_flow.c @@ -36,20 +36,20 @@ cn10k_mtr_configure(struct rte_eth_dev *eth_dev, for (i = 0; actions[i].type != RTE_FLOW_ACTION_TYPE_END; i++) { if (actions[i].type == RTE_FLOW_ACTION_TYPE_METER) { mtr_conf = (const struct rte_flow_action_meter - *)(actions->conf); + *)(actions[i].conf); mtr_id = mtr_conf->mtr_id; is_mtr_act = true; } if (actions[i].type == RTE_FLOW_ACTION_TYPE_QUEUE) { q_conf = (const struct rte_flow_action_queue - *)(actions->conf); + *)(actions[i].conf); if (is_mtr_act) nix_mtr_rq_update(eth_dev, mtr_id, 1, &q_conf->index); } if (actions[i].type == RTE_FLOW_ACTION_TYPE_RSS) { rss_conf = (const struct rte_flow_action_rss - *)(actions->conf); + *)(actions[i].conf); if (is_mtr_act) nix_mtr_rq_update(eth_dev, mtr_id, rss_conf->queue_num, @@ -171,7 +171,6 @@ cn10k_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, return NULL; } } - for (i = 0; actions[i].type != RTE_FLOW_ACTION_TYPE_END; i++) { if (actions[i].type == RTE_FLOW_ACTION_TYPE_METER) { mtr = (const struct rte_flow_action_meter *)actions[i] diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c index 39d8563826..cc783e5f86 100644 --- a/drivers/net/cnxk/cnxk_ethdev_mtr.c +++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c @@ -35,7 +35,6 @@ static struct rte_mtr_capabilities mtr_capa = { .chaining_n_mtrs_per_flow_max = NIX_MTR_COUNT_PER_FLOW, .chaining_use_prev_mtr_color_supported = true, .chaining_use_prev_mtr_color_enforced = true, - .meter_rate_max = NIX_BPF_RATE_MAX / 8, /* Bytes per second */ .color_aware_srtcm_rfc2697_supported = true, .color_aware_trtcm_rfc2698_supported = true, .color_aware_trtcm_rfc4115_supported = true, @@ -180,13 +179,13 @@ cnxk_nix_mtr_capabilities_get(struct rte_eth_dev *dev, struct rte_mtr_capabilities *capa, struct rte_mtr_error *error) { - struct cnxk_eth_dev *eth_dev = cnxk_eth_pmd_priv(dev); - uint16_t count[ROC_NIX_BPF_LEVEL_MAX] = {0}; uint8_t lvl_mask = ROC_NIX_BPF_LEVEL_F_LEAF | ROC_NIX_BPF_LEVEL_F_MID | ROC_NIX_BPF_LEVEL_F_TOP; + struct cnxk_eth_dev *eth_dev = cnxk_eth_pmd_priv(dev); + uint16_t count[ROC_NIX_BPF_LEVEL_MAX] = {0}; struct roc_nix *nix = ð_dev->nix; - int rc; - int i; + uint32_t time_unit; + int rc, i; RTE_SET_USED(dev); @@ -207,6 +206,15 @@ cnxk_nix_mtr_capabilities_get(struct rte_eth_dev *dev, mtr_capa.meter_trtcm_rfc4115_n_max = mtr_capa.n_max; mtr_capa.meter_policy_n_max = mtr_capa.n_max; + rc = roc_nix_bpf_timeunit_get(nix, &time_unit); + if (rc) + return rc; + + mtr_capa.meter_rate_max = + NIX_BPF_RATE(time_unit, NIX_BPF_MAX_RATE_EXPONENT, + NIX_BPF_MAX_RATE_MANTISSA, 0) / + 8; + *capa = mtr_capa; return 0; } @@ -304,6 +312,9 @@ cnxk_nix_mtr_policy_validate(struct rte_eth_dev *dev, if (action->type == RTE_FLOW_ACTION_TYPE_DROP) supported[i] = true; + if (action->type == RTE_FLOW_ACTION_TYPE_VOID) + supported[i] = true; + if (!supported[i]) { sprintf(message, "%s action is not valid", From patchwork Thu Jan 13 12:28:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Kudurumalla X-Patchwork-Id: 105786 X-Patchwork-Delegate: jerinj@marvell.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 2EFD6A0093; Thu, 13 Jan 2022 13:28:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC80B42739; Thu, 13 Jan 2022 13:28:24 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 81C7042730 for ; Thu, 13 Jan 2022 13:28:23 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20DABZMQ023932; Thu, 13 Jan 2022 04:28:21 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=NjJHMZuyDFBCbnUcQumM/V2BldGZxOKYxjz/CWQEXBQ=; b=NciXouCImarOOjRlgvkdh/Ul70vmT65E2GvnE0KMUJ3kKuoenYbDgeunUTp+th7U4akS lfksvdTKLhBYXebQ3/1cR0QaL8JLNlgt+GkucKubvUgKz0gbU0qUG9s+jxZxJCpCJSzK Eh7G0panRWK95s1dHuW9+Tkuv25aCQGHKtpAhBSGcapJgelWuShyH75lWYZbOnX16yEH OEjtuCfnNiE8r8cAsot03pkOTsZZjsQWl2wVbNIPswK7S+WchOq1xN231gr8GGoNQ5YU bf9XLzyZrHG0oSnaTrTKkol6Xa4bVdnff0JmaBm5EcroLLNzEDQ0vqZCNCQnOdup/QM3 0g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3djhd4rg8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 04:28:20 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 13 Jan 2022 04:28:18 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 13 Jan 2022 04:28:18 -0800 Received: from localhost.localdomain (unknown [10.28.48.103]) by maili.marvell.com (Postfix) with ESMTP id 17DEE3F7096; Thu, 13 Jan 2022 04:28:15 -0800 (PST) From: Rakesh Kudurumalla To: , Nithin Dabilpuram , "Kiran Kumar K" , Sunil Kumar Kori , Satha Rao CC: , Rakesh Kudurumalla , "Sunil Kumar Kori" Subject: [PATCH v3 2/2] common/cnxk: update meter algorithm in band profile Date: Thu, 13 Jan 2022 17:58:07 +0530 Message-ID: <20220113122807.1570511-2-rkudurumalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113122807.1570511-1-rkudurumalla@marvell.com> References: <20211130064147.1023321-1-rkudurumalla@marvell.com> <20220113122807.1570511-1-rkudurumalla@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: pOIaid2Boo5qd2yn_LhHYX_d5ztw3BQv X-Proofpoint-ORIG-GUID: pOIaid2Boo5qd2yn_LhHYX_d5ztw3BQv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-13_04,2022-01-13_01,2021-12-02_01 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 Patch updates meter algorithm in nix band profile structure Signed-off-by: Rakesh Kudurumalla Acked-by: Sunil Kumar Kori --- v3: series patch of 1/2 drivers/common/cnxk/hw/nix.h | 5 --- drivers/common/cnxk/roc_nix_bpf.c | 61 +++++++++---------------------- 2 files changed, 17 insertions(+), 49 deletions(-) diff --git a/drivers/common/cnxk/hw/nix.h b/drivers/common/cnxk/hw/nix.h index dd2ebecc6a..6931f1d1d2 100644 --- a/drivers/common/cnxk/hw/nix.h +++ b/drivers/common/cnxk/hw/nix.h @@ -2133,11 +2133,6 @@ struct nix_lso_format { ((NIX_BPF_RATE_CONST * ((256 + (mantissa)) << (exponent))) / \ (((1ull << (div_exp)) * 256 * policer_timeunit))) -/* Meter rate limits in Bits/Sec */ -#define NIX_BPF_RATE_MIN NIX_BPF_RATE(1000000000, 0, 0, 0) -#define NIX_BPF_RATE_MAX \ - NIX_BPF_RATE(1, NIX_BPF_MAX_RATE_EXPONENT, NIX_BPF_MAX_RATE_MANTISSA, 0) - #define NIX_BPF_DEFAULT_ADJUST_MANTISSA 511 #define NIX_BPF_DEFAULT_ADJUST_EXPONENT 0 diff --git a/drivers/common/cnxk/roc_nix_bpf.c b/drivers/common/cnxk/roc_nix_bpf.c index 6996a54be0..46ed91e87b 100644 --- a/drivers/common/cnxk/roc_nix_bpf.c +++ b/drivers/common/cnxk/roc_nix_bpf.c @@ -38,48 +38,23 @@ meter_rate_to_nix(uint64_t value, uint64_t *exponent_p, uint64_t *mantissa_p, uint64_t *div_exp_p, uint32_t timeunit_p) { uint64_t div_exp, exponent, mantissa; - uint32_t time_us = timeunit_p; + uint32_t time_ns = timeunit_p; /* Boundary checks */ - if (value < NIX_BPF_RATE_MIN || value > NIX_BPF_RATE_MAX) + if (value < NIX_BPF_RATE(time_ns, 0, 0, 0) || + value > NIX_BPF_RATE(time_ns, NIX_BPF_MAX_RATE_EXPONENT, + NIX_BPF_MAX_RATE_MANTISSA, 0)) return 0; - if (value <= NIX_BPF_RATE(time_us, 0, 0, 0)) { - /* Calculate rate div_exp and mantissa using - * the following formula: - * - * value = (2E6 * (256 + mantissa) - * / ((1 << div_exp) * 256)) - */ - div_exp = 0; - exponent = 0; - mantissa = NIX_BPF_MAX_RATE_MANTISSA; - - while (value < (NIX_BPF_RATE_CONST / (1 << div_exp))) - div_exp += 1; - - while (value < ((NIX_BPF_RATE_CONST * (256 + mantissa)) / - ((1 << div_exp) * 256))) - mantissa -= 1; - } else { - /* Calculate rate exponent and mantissa using - * the following formula: - * - * value = (2E6 * ((256 + mantissa) << exponent)) / 256 - * - */ - div_exp = 0; - exponent = NIX_BPF_MAX_RATE_EXPONENT; - mantissa = NIX_BPF_MAX_RATE_MANTISSA; - - while (value < (NIX_BPF_RATE_CONST * (1 << exponent))) - exponent -= 1; - - while (value < - ((NIX_BPF_RATE_CONST * ((256 + mantissa) << exponent)) / - 256)) - mantissa -= 1; - } + div_exp = 0; + exponent = NIX_BPF_MAX_RATE_EXPONENT; + mantissa = NIX_BPF_MAX_RATE_MANTISSA; + + while (value < (NIX_BPF_RATE(time_ns, exponent, 0, 0))) + exponent -= 1; + + while (value < (NIX_BPF_RATE(time_ns, exponent, mantissa, 0))) + mantissa -= 1; if (div_exp > NIX_BPF_MAX_RATE_DIV_EXP || exponent > NIX_BPF_MAX_RATE_EXPONENT || @@ -94,7 +69,7 @@ meter_rate_to_nix(uint64_t value, uint64_t *exponent_p, uint64_t *mantissa_p, *mantissa_p = mantissa; /* Calculate real rate value */ - return NIX_BPF_RATE(time_us, exponent, mantissa, div_exp); + return NIX_BPF_RATE(time_ns, exponent, mantissa, div_exp); } static inline uint64_t @@ -195,11 +170,7 @@ nix_precolor_conv_table_write(struct roc_nix *roc_nix, uint64_t val, int64_t *addr; addr = PLT_PTR_ADD(nix->base, off); - /* FIXME: Currently writing to this register throwing kernel dump. - * plt_write64(val, addr); - */ - PLT_SET_USED(val); - PLT_SET_USED(addr); + plt_write64(val, addr); } static uint8_t @@ -665,6 +636,7 @@ roc_nix_bpf_config(struct roc_nix *roc_nix, uint16_t id, aq->prof.lmode = cfg->lmode; aq->prof.icolor = cfg->icolor; + aq->prof.meter_algo = cfg->alg; aq->prof.pc_mode = cfg->pc_mode; aq->prof.tnl_ena = cfg->tnl_ena; aq->prof.gc_action = cfg->action[ROC_NIX_BPF_COLOR_GREEN]; @@ -673,6 +645,7 @@ roc_nix_bpf_config(struct roc_nix *roc_nix, uint16_t id, aq->prof_mask.lmode = ~(aq->prof_mask.lmode); aq->prof_mask.icolor = ~(aq->prof_mask.icolor); + aq->prof_mask.meter_algo = ~(aq->prof_mask.meter_algo); aq->prof_mask.pc_mode = ~(aq->prof_mask.pc_mode); aq->prof_mask.tnl_ena = ~(aq->prof_mask.tnl_ena); aq->prof_mask.gc_action = ~(aq->prof_mask.gc_action);