From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7798142B3B for ; Thu, 18 May 2023 12:05:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7161C42BFE; Thu, 18 May 2023 12:05:12 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 7EE7B4014F; Thu, 18 May 2023 12:05:09 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34I965dY024724; Thu, 18 May 2023 03:05:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=tbLOhV/v0mEb87KMV9H4GEXcWlxvXp9+reHL2eiCXGg=; b=j/eTttVhqhOJm9xvCt755ErzowTOEOANQaYebdej1uaIh9WHMZag7rZofo5lN0lq/Lg9 FgDkNz2obZcdRI74lR28fv4C/d2rBdIijCaSDeT4jmg/jIeKYr7Qxy2tghuypuXWO2Dg qeW94A7aP7oQ7Pw7c3X/Dtk8GmH/zlMmMD+T8BJRFpalV1eOBAsDjoWpyacSJ2ILaUtZ U/p1awtDRLXcVrR8Ub/4Hea7WyfJ1XCYcwP6ixSgbnHfzcx2MV8YNyxFf7ML9Uuzmjq9 JeSMVQGNRdhYkj4COM8VSUnbi7bqW+a7t72iD/OYs/FBiFyZU17/7fISUYuN2jQu+CRt jQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3qmyexbkcx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 18 May 2023 03:05:08 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 May 2023 03:04:57 -0700 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.48 via Frontend Transport; Thu, 18 May 2023 03:04:57 -0700 Received: from satheeshpaullabpc.. (unknown [10.28.34.33]) by maili.marvell.com (Postfix) with ESMTP id BFB8A3F708F; Thu, 18 May 2023 03:04:55 -0700 (PDT) From: To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , Satheesh Paul , Subject: [dpdk-dev] [PATCH 1/2] common/cnxk: fix setting channel mask for SDP interfaces Date: Thu, 18 May 2023 15:34:51 +0530 Message-ID: <20230518100452.2190793-1-psatheesh@marvell.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: WQX2JIngjT2iG_tEJdBL2290ZIZSQ3eM X-Proofpoint-ORIG-GUID: WQX2JIngjT2iG_tEJdBL2290ZIZSQ3eM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_07,2023-05-17_02,2023-02-09_01 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Satheesh Paul 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 Reviewed-by: Kiran Kumar K --- 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