patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] common/cnxk: fix setting channel mask for SDP interfaces
@ 2023-05-18 10:04 psatheesh
  2023-05-18 10:04 ` [dpdk-dev] [PATCH 2/2] common/cnxk: fix uninitialized pointer read psatheesh
  0 siblings, 1 reply; 3+ messages in thread
From: psatheesh @ 2023-05-18 10:04 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, Satheesh Paul, stable

From: Satheesh Paul <psatheesh@marvell.com>

Channel mask for SDP interfaces are by default set to
a constant value. Fix this by setting mask calculated
from the channel base and channel count configured in
NIX LF.

Fixes: f13756633330 ("common/cnxk: support setting channel mask for SDP interfaces")
Cc: stable@dpdk.org

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>
---
 drivers/common/cnxk/roc_npc.c | 40 ++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c
index ba75207955..d556b4c3a5 100644
--- a/drivers/common/cnxk/roc_npc.c
+++ b/drivers/common/cnxk/roc_npc.c
@@ -1388,12 +1388,39 @@ npc_inline_dev_ipsec_action_free(struct npc *npc, struct roc_npc_flow *flow)
 	return 1;
 }
 
+static void
+roc_npc_sdp_channel_get(struct roc_npc *roc_npc, uint16_t *chan_base, uint16_t *chan_mask)
+{
+	struct roc_nix *roc_nix = roc_npc->roc_nix;
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	uint16_t num_chan, range, num_bits = 0;
+	uint16_t mask = 0;
+
+	*chan_base = nix->rx_chan_base;
+	num_chan = nix->rx_chan_cnt - 1;
+	if (num_chan) {
+		range = *chan_base ^ (*chan_base + num_chan);
+		num_bits = (sizeof(uint32_t) * 8) - __builtin_clz(range) - 1;
+		/* Set mask for (15 - numbits) MSB bits */
+		*chan_mask = (uint16_t)~GENMASK(num_bits, 0);
+	} else {
+		*chan_mask = (uint16_t)GENMASK(15, 0);
+	}
+
+	mask = (uint16_t)GENMASK(num_bits, 0);
+	if (mask > num_chan + 1)
+		plt_warn(
+			"npc: SDP channel base:%x, channel count:%x. channel mask:%x covers more than channel count",
+			*chan_base, nix->rx_chan_cnt, *chan_mask);
+}
+
 struct roc_npc_flow *
 roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		    const struct roc_npc_item_info pattern[],
 		    const struct roc_npc_action actions[], int *errcode)
 {
 	struct npc *npc = roc_npc_to_npc_priv(roc_npc);
+	uint16_t sdp_chan_base = 0, sdp_chan_mask = 0;
 	struct roc_npc_flow *flow, *flow_iter;
 	struct npc_parse_state parse_state;
 	struct npc_flow_list *list;
@@ -1406,16 +1433,9 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 			npc->sdp_channel = roc_npc->sdp_channel;
 			npc->sdp_channel_mask = roc_npc->sdp_channel_mask;
 		} else {
-			/* By default set the channel and mask to cover
-			 * the whole SDP channel range.
-			 */
-			if (roc_model_is_cn10k()) {
-				npc->sdp_channel = (uint16_t)CN10K_SDP_CH_START;
-				npc->sdp_channel_mask = (uint16_t)CN10K_SDP_CH_MASK;
-			} else {
-				npc->sdp_channel = (uint16_t)NIX_CHAN_SDP_CH_START;
-				npc->sdp_channel_mask = (uint16_t)NIX_CHAN_SDP_CH_START;
-			}
+			roc_npc_sdp_channel_get(roc_npc, &sdp_chan_base, &sdp_chan_mask);
+			npc->sdp_channel = sdp_chan_base;
+			npc->sdp_channel_mask = sdp_chan_mask;
 		}
 	}
 
-- 
2.39.2


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

* [dpdk-dev] [PATCH 2/2] common/cnxk: fix uninitialized pointer read
  2023-05-18 10:04 [dpdk-dev] [PATCH 1/2] common/cnxk: fix setting channel mask for SDP interfaces psatheesh
@ 2023-05-18 10:04 ` psatheesh
  2023-05-22 13:55   ` Jerin Jacob
  0 siblings, 1 reply; 3+ messages in thread
From: psatheesh @ 2023-05-18 10:04 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, Satheesh Paul, stable

From: Satheesh Paul <psatheesh@marvell.com>

Fix uninitialized pointer read reported in coverity scan.

Coverity issue: 375811
Fixes: 84d2ea9d4fb3 ("common/cnxk: support custom pre L2 header parsing as raw")
Cc: stable@dpdk.org

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>
---
 drivers/common/cnxk/roc_npc_parse.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c
index f746b9cb6d..571fdb36fc 100644
--- a/drivers/common/cnxk/roc_npc_parse.c
+++ b/drivers/common/cnxk/roc_npc_parse.c
@@ -97,6 +97,7 @@ npc_parse_pre_l2(struct npc_parse_state *pst)
 		(const struct roc_npc_flow_item_raw *)pst->pattern->mask, &info,
 		raw_spec_buf, raw_mask_buf);
 
+	info.def_mask = NULL;
 	info.hw_mask = &hw_mask;
 	npc_get_hw_supp_mask(pst, &info, lid, lt);
 
-- 
2.39.2


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

* Re: [dpdk-dev] [PATCH 2/2] common/cnxk: fix uninitialized pointer read
  2023-05-18 10:04 ` [dpdk-dev] [PATCH 2/2] common/cnxk: fix uninitialized pointer read psatheesh
@ 2023-05-22 13:55   ` Jerin Jacob
  0 siblings, 0 replies; 3+ messages in thread
From: Jerin Jacob @ 2023-05-22 13:55 UTC (permalink / raw)
  To: psatheesh
  Cc: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	dev, stable

On Thu, May 18, 2023 at 3:35 PM <psatheesh@marvell.com> wrote:
>
> From: Satheesh Paul <psatheesh@marvell.com>
>
> Fix uninitialized pointer read reported in coverity scan.
>
> Coverity issue: 375811
> Fixes: 84d2ea9d4fb3 ("common/cnxk: support custom pre L2 header parsing as raw")
> Cc: stable@dpdk.org
>
> Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
> Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>

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


> ---
>  drivers/common/cnxk/roc_npc_parse.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c
> index f746b9cb6d..571fdb36fc 100644
> --- a/drivers/common/cnxk/roc_npc_parse.c
> +++ b/drivers/common/cnxk/roc_npc_parse.c
> @@ -97,6 +97,7 @@ npc_parse_pre_l2(struct npc_parse_state *pst)
>                 (const struct roc_npc_flow_item_raw *)pst->pattern->mask, &info,
>                 raw_spec_buf, raw_mask_buf);
>
> +       info.def_mask = NULL;
>         info.hw_mask = &hw_mask;
>         npc_get_hw_supp_mask(pst, &info, lid, lt);
>
> --
> 2.39.2
>

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

end of thread, other threads:[~2023-05-22 13:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-18 10:04 [dpdk-dev] [PATCH 1/2] common/cnxk: fix setting channel mask for SDP interfaces psatheesh
2023-05-18 10:04 ` [dpdk-dev] [PATCH 2/2] common/cnxk: fix uninitialized pointer read psatheesh
2023-05-22 13:55   ` 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).