DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] net/cnxk: update meter bpf ID in rq
@ 2021-11-30  6:41 Rakesh Kudurumalla
  2021-11-30  6:41 ` [PATCH 2/2] common/cnxk: update meter algorithm in band profile Rakesh Kudurumalla
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Rakesh Kudurumalla @ 2021-11-30  6:41 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, Rakesh Kudurumalla

Patch updates configured meter bpf is in rq context
during meter creation

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
---
 drivers/net/cnxk/cn10k_rte_flow.c  |  9 ++++-----
 drivers/net/cnxk/cnxk_ethdev_mtr.c | 25 ++++++++++++++++++-------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/net/cnxk/cn10k_rte_flow.c b/drivers/net/cnxk/cn10k_rte_flow.c
index b830abe63e..402bb1c72f 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,
@@ -98,7 +98,7 @@ cn10k_rss_action_validate(struct rte_eth_dev *eth_dev,
 		return -EINVAL;
 	}
 
-	if (eth_dev->data->dev_conf.rxmode.mq_mode != RTE_ETH_MQ_RX_RSS) {
+	if (eth_dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) {
 		plt_err("multi-queue mode is disabled");
 		return -ENOTSUP;
 	}
@@ -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..a36fcb8aaf 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,20 +179,20 @@ 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 = &eth_dev->nix;
-	int rc;
-	int i;
+	uint32_t time_unit;
+	int rc, i;
 
 	RTE_SET_USED(dev);
 
 	if (!capa)
 		return -rte_mtr_error_set(error, EINVAL,
-				RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
-				"NULL input parameter");
+					  RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
+					  "NULL input parameter");
 
 	rc = roc_nix_bpf_count_get(nix, lvl_mask, count);
 	if (rc)
@@ -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",
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/2] common/cnxk: update meter algorithm in band profile
  2021-11-30  6:41 [PATCH 1/2] net/cnxk: update meter bpf ID in rq Rakesh Kudurumalla
@ 2021-11-30  6:41 ` Rakesh Kudurumalla
  2021-11-30  7:15   ` Sunil Kumar Kori
  2021-11-30  7:16 ` [PATCH 1/2] net/cnxk: update meter bpf ID in rq Sunil Kumar Kori
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Rakesh Kudurumalla @ 2021-11-30  6:41 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, Rakesh Kudurumalla

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 2/2] common/cnxk: update meter algorithm in band profile
  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
  0 siblings, 0 replies; 12+ messages in thread
From: Sunil Kumar Kori @ 2021-11-30  7:15 UTC (permalink / raw)
  To: Rakesh Kudurumalla, Nithin Kumar Dabilpuram,
	Kiran Kumar Kokkilagadda, Satha Koteswara Rao Kottidi
  Cc: dev, Rakesh Kudurumalla

>-----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>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/2] net/cnxk: update meter bpf ID in rq
  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:16 ` Sunil Kumar Kori
  2022-01-10  8:45   ` Jerin Jacob
  2022-01-11 12:46 ` Ferruh Yigit
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Sunil Kumar Kori @ 2021-11-30  7:16 UTC (permalink / raw)
  To: Rakesh Kudurumalla, Nithin Kumar Dabilpuram,
	Kiran Kumar Kokkilagadda, Satha Koteswara Rao Kottidi
  Cc: dev, Rakesh Kudurumalla

>-----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 1/2] net/cnxk: update meter bpf ID in rq
>
>Patch updates configured meter bpf is in rq context during meter creation
>
>Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
>---
> drivers/net/cnxk/cn10k_rte_flow.c  |  9 ++++-----
>drivers/net/cnxk/cnxk_ethdev_mtr.c | 25 ++++++++++++++++++-------
> 2 files changed, 22 insertions(+), 12 deletions(-)
>
>diff --git a/drivers/net/cnxk/cn10k_rte_flow.c
>b/drivers/net/cnxk/cn10k_rte_flow.c
>index b830abe63e..402bb1c72f 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,
>@@ -98,7 +98,7 @@ cn10k_rss_action_validate(struct rte_eth_dev *eth_dev,
> 		return -EINVAL;
> 	}
>
>-	if (eth_dev->data->dev_conf.rxmode.mq_mode !=
>RTE_ETH_MQ_RX_RSS) {
>+	if (eth_dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) {
> 		plt_err("multi-queue mode is disabled");
> 		return -ENOTSUP;
> 	}
>@@ -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..a36fcb8aaf 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,20 +179,20
>@@ 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 = &eth_dev->nix;
>-	int rc;
>-	int i;
>+	uint32_t time_unit;
>+	int rc, i;
>
> 	RTE_SET_USED(dev);
>
> 	if (!capa)
> 		return -rte_mtr_error_set(error, EINVAL,
>-				RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
>-				"NULL input parameter");
>+
>RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
>+					  "NULL input parameter");
>
> 	rc = roc_nix_bpf_count_get(nix, lvl_mask, count);
> 	if (rc)
>@@ -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",
>--
>2.25.1

Acked-by: Sunil Kumar Kori <skori@mavell.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] net/cnxk: update meter bpf ID in rq
  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
  0 siblings, 0 replies; 12+ messages in thread
From: Jerin Jacob @ 2022-01-10  8:45 UTC (permalink / raw)
  To: Sunil Kumar Kori, Ferruh Yigit, Andrew Rybchenko
  Cc: Rakesh Kudurumalla, Nithin Kumar Dabilpuram,
	Kiran Kumar Kokkilagadda, Satha Koteswara Rao Kottidi, dev

On Tue, Nov 30, 2021 at 12:47 PM Sunil Kumar Kori <skori@marvell.com> wrote:
>
> >-----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 1/2] net/cnxk: update meter bpf ID in rq
> >
> >Patch updates configured meter bpf is in rq context during meter creation
> >
> >Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>

Series applied to dpdk-next-net-mrvl/for-next-net. Thanks.


> >---
> > drivers/net/cnxk/cn10k_rte_flow.c  |  9 ++++-----
> >drivers/net/cnxk/cnxk_ethdev_mtr.c | 25 ++++++++++++++++++-------
> > 2 files changed, 22 insertions(+), 12 deletions(-)
> >
> >diff --git a/drivers/net/cnxk/cn10k_rte_flow.c
> >b/drivers/net/cnxk/cn10k_rte_flow.c
> >index b830abe63e..402bb1c72f 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,
> >@@ -98,7 +98,7 @@ cn10k_rss_action_validate(struct rte_eth_dev *eth_dev,
> >               return -EINVAL;
> >       }
> >
> >-      if (eth_dev->data->dev_conf.rxmode.mq_mode !=
> >RTE_ETH_MQ_RX_RSS) {
> >+      if (eth_dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) {
> >               plt_err("multi-queue mode is disabled");
> >               return -ENOTSUP;
> >       }
> >@@ -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..a36fcb8aaf 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,20 +179,20
> >@@ 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 = &eth_dev->nix;
> >-      int rc;
> >-      int i;
> >+      uint32_t time_unit;
> >+      int rc, i;
> >
> >       RTE_SET_USED(dev);
> >
> >       if (!capa)
> >               return -rte_mtr_error_set(error, EINVAL,
> >-                              RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
> >-                              "NULL input parameter");
> >+
> >RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
> >+                                        "NULL input parameter");
> >
> >       rc = roc_nix_bpf_count_get(nix, lvl_mask, count);
> >       if (rc)
> >@@ -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",
> >--
> >2.25.1
>
> Acked-by: Sunil Kumar Kori <skori@mavell.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] net/cnxk: update meter bpf ID in rq
  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:16 ` [PATCH 1/2] net/cnxk: update meter bpf ID in rq Sunil Kumar Kori
@ 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:28 ` [PATCH v3 1/2] net/cnxk: update meter bpf ID in Receive Queue Rakesh Kudurumalla
  4 siblings, 1 reply; 12+ messages in thread
From: Ferruh Yigit @ 2022-01-11 12:46 UTC (permalink / raw)
  To: Rakesh Kudurumalla, Nithin Dabilpuram, Kiran Kumar K,
	Sunil Kumar Kori, Satha Rao
  Cc: dev

On 11/30/2021 6:41 AM, Rakesh Kudurumalla wrote:
> Patch updates configured meter bpf is in rq context
> during meter creation

RQ is receive queue, right? Can you please use the long version for clarification?

> 
> Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> ---
>   drivers/net/cnxk/cn10k_rte_flow.c  |  9 ++++-----
>   drivers/net/cnxk/cnxk_ethdev_mtr.c | 25 ++++++++++++++++++-------
>   2 files changed, 22 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/cnxk/cn10k_rte_flow.c b/drivers/net/cnxk/cn10k_rte_flow.c
> index b830abe63e..402bb1c72f 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,
> @@ -98,7 +98,7 @@ cn10k_rss_action_validate(struct rte_eth_dev *eth_dev,
>   		return -EINVAL;
>   	}
>   
> -	if (eth_dev->data->dev_conf.rxmode.mq_mode != RTE_ETH_MQ_RX_RSS) {
> +	if (eth_dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) {

This change seems unintended. Please keep the original value.



<...>

>   	if (!capa)
>   		return -rte_mtr_error_set(error, EINVAL,
> -				RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
> -				"NULL input parameter");
> +					  RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
> +					  "NULL input parameter");
>   

Previous indentation looks more consistent with DPDK coding guide.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [EXT] Re: [PATCH 1/2] net/cnxk: update meter bpf ID in rq
  2022-01-11 12:46 ` Ferruh Yigit
@ 2022-01-13  8:21   ` Rakesh Kudurumalla
  0 siblings, 0 replies; 12+ messages in thread
From: Rakesh Kudurumalla @ 2022-01-13  8:21 UTC (permalink / raw)
  To: Ferruh Yigit, Nithin Kumar Dabilpuram, Kiran Kumar Kokkilagadda,
	Sunil Kumar Kori, Satha Koteswara Rao Kottidi
  Cc: dev



> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Tuesday, January 11, 2022 6:16 PM
> To: Rakesh Kudurumalla <rkudurumalla@marvell.com>; 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
> Subject: [EXT] Re: [PATCH 1/2] net/cnxk: update meter bpf ID in rq
> 
> External Email
> 
> ----------------------------------------------------------------------
> On 11/30/2021 6:41 AM, Rakesh Kudurumalla wrote:
> > Patch updates configured meter bpf is in rq context during meter
> > creation
> 
> RQ is receive queue, right? Can you please use the long version for
> clarification?
Yes RQ is receive queue. Sure will use long version
> 
> >
> > Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> > ---
> >   drivers/net/cnxk/cn10k_rte_flow.c  |  9 ++++-----
> >   drivers/net/cnxk/cnxk_ethdev_mtr.c | 25 ++++++++++++++++++-------
> >   2 files changed, 22 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/net/cnxk/cn10k_rte_flow.c
> > b/drivers/net/cnxk/cn10k_rte_flow.c
> > index b830abe63e..402bb1c72f 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,
> > @@ -98,7 +98,7 @@ cn10k_rss_action_validate(struct rte_eth_dev
> *eth_dev,
> >   		return -EINVAL;
> >   	}
> >
> > -	if (eth_dev->data->dev_conf.rxmode.mq_mode !=
> RTE_ETH_MQ_RX_RSS) {
> > +	if (eth_dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS)
> {
> 
> This change seems unintended. Please keep the original value.
Will keep original value
> 
> 
> 
> <...>
> 
> >   	if (!capa)
> >   		return -rte_mtr_error_set(error, EINVAL,
> > -				RTE_MTR_ERROR_TYPE_MTR_PARAMS,
> NULL,
> > -				"NULL input parameter");
> > +
> RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
> > +					  "NULL input parameter");
> >
> 
> Previous indentation looks more consistent with DPDK coding guide.
Will update to pervious indentation

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/2] net/cnxk: update meter bpf ID in Recevie Queue
  2021-11-30  6:41 [PATCH 1/2] net/cnxk: update meter bpf ID in rq Rakesh Kudurumalla
                   ` (2 preceding siblings ...)
  2022-01-11 12:46 ` Ferruh Yigit
@ 2022-01-13 12:20 ` 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
  4 siblings, 1 reply; 12+ messages in thread
From: Rakesh Kudurumalla @ 2022-01-13 12:20 UTC (permalink / raw)
  To: jerinj, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, Rakesh Kudurumalla, Sunil Kumar Kori

Patch updates configured meter bpf is in recevie queue
context during meter creation

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
Acked-by: Sunil Kumar Kori <skori@mavell.com>
---
v2: Fix commit message
 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 = &eth_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",
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 2/2] common/cnxk: update meter algorithm in band profile
  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   ` Rakesh Kudurumalla
  0 siblings, 0 replies; 12+ messages in thread
From: Rakesh Kudurumalla @ 2022-01-13 12:20 UTC (permalink / raw)
  To: jerinj, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, Rakesh Kudurumalla, Sunil Kumar Kori

Patch updates meter algorithm in nix band profile
structure

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
Acked-by: Sunil Kumar Kori <skori@mavell.com>
---
v2: 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);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 1/2] net/cnxk: update meter bpf ID in Receive Queue
  2021-11-30  6:41 [PATCH 1/2] net/cnxk: update meter bpf ID in rq Rakesh Kudurumalla
                   ` (3 preceding siblings ...)
  2022-01-13 12:20 ` [PATCH v2 1/2] net/cnxk: update meter bpf ID in Recevie Queue Rakesh Kudurumalla
@ 2022-01-13 12:28 ` 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
  4 siblings, 2 replies; 12+ messages in thread
From: Rakesh Kudurumalla @ 2022-01-13 12:28 UTC (permalink / raw)
  To: jerinj, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, Rakesh Kudurumalla, Sunil Kumar Kori

Patch updates configured meter bpf is in receive queue
context during meter creation

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
Acked-by: Sunil Kumar Kori <skori@mavell.com>
---
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 = &eth_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",
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 2/2] common/cnxk: update meter algorithm in band profile
  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   ` Rakesh Kudurumalla
  2022-01-20  8:43   ` [PATCH v3 1/2] net/cnxk: update meter bpf ID in Receive Queue Jerin Jacob
  1 sibling, 0 replies; 12+ messages in thread
From: Rakesh Kudurumalla @ 2022-01-13 12:28 UTC (permalink / raw)
  To: jerinj, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, Rakesh Kudurumalla, Sunil Kumar Kori

Patch updates meter algorithm in nix band profile
structure

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
Acked-by: Sunil Kumar Kori <skori@mavell.com>
---
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);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 1/2] net/cnxk: update meter bpf ID in Receive Queue
  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   ` Jerin Jacob
  1 sibling, 0 replies; 12+ messages in thread
From: Jerin Jacob @ 2022-01-20  8:43 UTC (permalink / raw)
  To: Rakesh Kudurumalla, Ferruh Yigit
  Cc: Jerin Jacob, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori,
	Satha Rao, dpdk-dev, Sunil Kumar Kori

On Thu, Jan 13, 2022 at 5:58 PM Rakesh Kudurumalla
<rkudurumalla@marvell.com> wrote:
>
> Patch updates configured meter bpf is in receive queue
> context during meter creation
>
> Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> Acked-by: Sunil Kumar Kori <skori@mavell.com>

Series Acked-by: Jerin Jacob <jerinj@marvell.com>
Series applied to dpdk-next-net-mrvl/for-next-net with following git
log update. Thanks.

Author: Rakesh Kudurumalla <rkudurumalla@marvell.com>
Date:   Thu Jan 13 17:58:07 2022 +0530

    common/cnxk: update meter algorithm in band profile

    Update meter algorithm in NIX's band profile structure.

    Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
    Acked-by: Sunil Kumar Kori <skori@mavell.com>
    Acked-by: Jerin Jacob <jerinj@marvell.com>

Author: Rakesh Kudurumalla <rkudurumalla@marvell.com>
Date:   Thu Jan 13 17:58:06 2022 +0530

    net/cnxk: update meter BPF ID in Receive Queue

    Patch updates configured meter BPF(Bandwidth profile) ID is in
    receive queue context during meter creation.

    Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
    Acked-by: Sunil Kumar Kori <skori@mavell.com>
    Acked-by: Jerin Jacob <jerinj@marvell.com>

> ---
> 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 = &eth_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",
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-01-20  8:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).