From: Sunil Kumar Kori <skori@marvell.com>
To: Rakesh Kudurumalla <rkudurumalla@marvell.com>,
Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>,
Kiran Kumar Kokkilagadda <kirankumark@marvell.com>,
Satha Koteswara Rao Kottidi <skoteshwar@marvell.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
Rakesh Kudurumalla <rkudurumalla@marvell.com>
Subject: RE: [PATCH 2/2] common/cnxk: update meter algorithm in band profile
Date: Tue, 30 Nov 2021 07:15:31 +0000 [thread overview]
Message-ID: <CO6PR18MB3860931A9D9EEEEAFD917066B4679@CO6PR18MB3860.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20211130064147.1023321-2-rkudurumalla@marvell.com>
>-----Original Message-----
>From: Rakesh Kudurumalla <rkudurumalla@marvell.com>
>Sent: Tuesday, November 30, 2021 12:12 PM
>To: Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; Kiran Kumar
>Kokkilagadda <kirankumark@marvell.com>; Sunil Kumar Kori
><skori@marvell.com>; Satha Koteswara Rao Kottidi
><skoteshwar@marvell.com>
>Cc: dev@dpdk.org; Rakesh Kudurumalla <rkudurumalla@marvell.com>
>Subject: [PATCH 2/2] common/cnxk: update meter algorithm in band profile
>
>Patch updates meter algorithm in nix band profile structure
>
>Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
>---
> 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);
>--
>2.25.1
Acked-by: Sunil Kumar Kori <skori@mavell.com>
next prev parent reply other threads:[~2021-11-30 7:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-30 6:41 [PATCH 1/2] net/cnxk: update meter bpf ID in rq Rakesh Kudurumalla
2021-11-30 6:41 ` [PATCH 2/2] common/cnxk: update meter algorithm in band profile Rakesh Kudurumalla
2021-11-30 7:15 ` Sunil Kumar Kori [this message]
2021-11-30 7:16 ` [PATCH 1/2] net/cnxk: update meter bpf ID in rq Sunil Kumar Kori
2022-01-10 8:45 ` Jerin Jacob
2022-01-11 12:46 ` Ferruh Yigit
2022-01-13 8:21 ` [EXT] " Rakesh Kudurumalla
2022-01-13 12:20 ` [PATCH v2 1/2] net/cnxk: update meter bpf ID in Recevie Queue Rakesh Kudurumalla
2022-01-13 12:20 ` [PATCH v2 2/2] common/cnxk: update meter algorithm in band profile Rakesh Kudurumalla
2022-01-13 12:28 ` [PATCH v3 1/2] net/cnxk: update meter bpf ID in Receive Queue Rakesh Kudurumalla
2022-01-13 12:28 ` [PATCH v3 2/2] common/cnxk: update meter algorithm in band profile Rakesh Kudurumalla
2022-01-20 8:43 ` [PATCH v3 1/2] net/cnxk: update meter bpf ID in Receive Queue Jerin Jacob
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CO6PR18MB3860931A9D9EEEEAFD917066B4679@CO6PR18MB3860.namprd18.prod.outlook.com \
--to=skori@marvell.com \
--cc=dev@dpdk.org \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=rkudurumalla@marvell.com \
--cc=skoteshwar@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).