From nobody Mon Nov 25 08:01:26 2024 Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19199200BB9; Tue, 29 Oct 2024 03:58:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730174288; cv=none; b=tSDkSCAe6qtVSnH5V9Q3ul+Rt8cesjQYw0dPIeDEtL++B7AyKkuuWZuW5Ok5hJzGYOyA5TUNMVUPdqV/oA890Kr93u0gBuKVNGK+tf75xHjRJQr8jVlUZHbt5a+nnu+qZBLcu+1EP5CF0gXjALozRVTD/49UbCc21T9ah6B9DnQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730174288; c=relaxed/simple; bh=KQaAXLazaBTSRyCewbienphQ9u+caovm/CiV0S/UdPs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kjYLlYL0v389ilQBZNgXCEYOxI+/epO/m8YiQ1Qfp5I4M5m01EbQNmUGemsQjEmCCBVlsRmAe94E82RLmazD6KHC0lLjdZFN/9Q/0cJR+2Pj/rpv/xVQKZOnSf1wflyjZ0ReZ1Q4COBB5RUeYC6E58XekHbp/GEdUeMX3aj7J9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=DDbBz/eE; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="DDbBz/eE" Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49T3QoVj020797; Mon, 28 Oct 2024 20:57:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=w TRsaO8u8nr9tQhOMRlxa0ZMu5A+IGmEI0vR43w4/hg=; b=DDbBz/eEHSna2LKq5 NMpsl8qVqgfRmx4M96gRYrkBEv8vSVFYAPWmOoH1IAed6vx/904nxcoNrMZ2IyEG 48pbp7H9wXklAbvCF7oEIJjUKwQJqt3KIzadzTMbbS56L19rGW4z3jlp//lEmUOt pANooVxn1TX9Cw1SWpravA3MrP/GQODo59nk8x/TiId/4zYq7SbTZN7PgIJ7NCil PAmsMRwBPrcjJjBVq1Di8nMP930MNptAjvHGorpyfvExSrtsP/enc2mHuann9LRe xFLjMujjiNgjYkH+uAhLORJt8wsBNL+Y0uTHglGxKa2yNAGakCgvCuguvn/mrVTh huuuA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42jqtcg2fx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Oct 2024 20:57:59 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 28 Oct 2024 20:57:58 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 28 Oct 2024 20:57:58 -0700 Received: from virtx40.. (unknown [10.28.34.196]) by maili.marvell.com (Postfix) with ESMTP id 124313F704D; Mon, 28 Oct 2024 20:57:53 -0700 (PDT) From: Linu Cherian To: , , , CC: , , , , , , , , , , Linu Cherian , "Simon Horman" Subject: [PATCH v4 net-next 1/3] octeontx2-af: Refactor few NPC mcam APIs Date: Tue, 29 Oct 2024 09:27:37 +0530 Message-ID: <20241029035739.1981839-2-lcherian@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029035739.1981839-1-lcherian@marvell.com> References: <20241029035739.1981839-1-lcherian@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: dSpHtYi6XwTYl0ttuvx_8xUe7BBi7tG2 X-Proofpoint-GUID: dSpHtYi6XwTYl0ttuvx_8xUe7BBi7tG2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 Content-Type: text/plain; charset="utf-8" Introduce lowlevel variant of rvu_mcam_remove/add_counter_from/to_rule for better code reuse, which assumes necessary locks are taken at higher level. These low level functions would be used for implementing default rule counter APIs in the subsequent patch. Signed-off-by: Linu Cherian Reviewed-by: Simon Horman --- Changelog from v3: Added Reviewed-by tag. .../net/ethernet/marvell/octeontx2/af/rvu.h | 6 +- .../ethernet/marvell/octeontx2/af/rvu_npc.c | 89 ++++++++++++++++--- .../marvell/octeontx2/af/rvu_npc_fs.c | 36 ++------ 3 files changed, 92 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/= ethernet/marvell/octeontx2/af/rvu.h index 5016ba82e142..d92a5f47a476 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h @@ -960,7 +960,11 @@ void rvu_npc_disable_default_entries(struct rvu *rvu, = u16 pcifunc, int nixlf); void rvu_npc_enable_default_entries(struct rvu *rvu, u16 pcifunc, int nixl= f); void rvu_npc_update_flowkey_alg_idx(struct rvu *rvu, u16 pcifunc, int nixl= f, int group, int alg_idx, int mcam_index); - +void __rvu_mcam_remove_counter_from_rule(struct rvu *rvu, u16 pcifunc, + struct rvu_npc_mcam_rule *rule); +void __rvu_mcam_add_counter_to_rule(struct rvu *rvu, u16 pcifunc, + struct rvu_npc_mcam_rule *rule, + struct npc_install_flow_rsp *rsp); void rvu_npc_get_mcam_entry_alloc_info(struct rvu *rvu, u16 pcifunc, int blkaddr, int *alloc_cnt, int *enable_cnt); diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_npc.c index 97722ce8c4cb..c4ef1e83cc46 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c @@ -2975,9 +2975,9 @@ int rvu_mbox_handler_npc_mcam_shift_entry(struct rvu = *rvu, return rc; } =20 -int rvu_mbox_handler_npc_mcam_alloc_counter(struct rvu *rvu, - struct npc_mcam_alloc_counter_req *req, - struct npc_mcam_alloc_counter_rsp *rsp) +static int __npc_mcam_alloc_counter(struct rvu *rvu, + struct npc_mcam_alloc_counter_req *req, + struct npc_mcam_alloc_counter_rsp *rsp) { struct npc_mcam *mcam =3D &rvu->hw->mcam; u16 pcifunc =3D req->hdr.pcifunc; @@ -2998,11 +2998,9 @@ int rvu_mbox_handler_npc_mcam_alloc_counter(struct r= vu *rvu, if (!req->contig && req->count > NPC_MAX_NONCONTIG_COUNTERS) return NPC_MCAM_INVALID_REQ; =20 - mutex_lock(&mcam->lock); =20 /* Check if unused counters are available or not */ if (!rvu_rsrc_free_count(&mcam->counters)) { - mutex_unlock(&mcam->lock); return NPC_MCAM_ALLOC_FAILED; } =20 @@ -3035,12 +3033,27 @@ int rvu_mbox_handler_npc_mcam_alloc_counter(struct = rvu *rvu, } } =20 - mutex_unlock(&mcam->lock); return 0; } =20 -int rvu_mbox_handler_npc_mcam_free_counter(struct rvu *rvu, - struct npc_mcam_oper_counter_req *req, struct msg_rsp *rsp) +int rvu_mbox_handler_npc_mcam_alloc_counter(struct rvu *rvu, + struct npc_mcam_alloc_counter_req *req, + struct npc_mcam_alloc_counter_rsp *rsp) +{ + struct npc_mcam *mcam =3D &rvu->hw->mcam; + int err; + + mutex_lock(&mcam->lock); + + err =3D __npc_mcam_alloc_counter(rvu, req, rsp); + + mutex_unlock(&mcam->lock); + return err; +} + +static int __npc_mcam_free_counter(struct rvu *rvu, + struct npc_mcam_oper_counter_req *req, + struct msg_rsp *rsp) { struct npc_mcam *mcam =3D &rvu->hw->mcam; u16 index, entry =3D 0; @@ -3050,10 +3063,8 @@ int rvu_mbox_handler_npc_mcam_free_counter(struct rv= u *rvu, if (blkaddr < 0) return NPC_MCAM_INVALID_REQ; =20 - mutex_lock(&mcam->lock); err =3D npc_mcam_verify_counter(mcam, req->hdr.pcifunc, req->cntr); if (err) { - mutex_unlock(&mcam->lock); return err; } =20 @@ -3077,10 +3088,66 @@ int rvu_mbox_handler_npc_mcam_free_counter(struct r= vu *rvu, index, req->cntr); } =20 - mutex_unlock(&mcam->lock); return 0; } =20 +int rvu_mbox_handler_npc_mcam_free_counter(struct rvu *rvu, + struct npc_mcam_oper_counter_req *req, struct msg_rsp *rsp) +{ + struct npc_mcam *mcam =3D &rvu->hw->mcam; + int err; + + mutex_lock(&mcam->lock); + + err =3D __npc_mcam_free_counter(rvu, req, rsp); + + mutex_unlock(&mcam->lock); + + return err; +} + +void __rvu_mcam_remove_counter_from_rule(struct rvu *rvu, u16 pcifunc, + struct rvu_npc_mcam_rule *rule) +{ + struct npc_mcam_oper_counter_req free_req =3D { 0 }; + struct msg_rsp free_rsp; + + if (!rule->has_cntr) + return; + + free_req.hdr.pcifunc =3D pcifunc; + free_req.cntr =3D rule->cntr; + + __npc_mcam_free_counter(rvu, &free_req, &free_rsp); + rule->has_cntr =3D false; +} + +void __rvu_mcam_add_counter_to_rule(struct rvu *rvu, u16 pcifunc, + struct rvu_npc_mcam_rule *rule, + struct npc_install_flow_rsp *rsp) +{ + struct npc_mcam_alloc_counter_req cntr_req =3D { 0 }; + struct npc_mcam_alloc_counter_rsp cntr_rsp =3D { 0 }; + int err; + + cntr_req.hdr.pcifunc =3D pcifunc; + cntr_req.contig =3D true; + cntr_req.count =3D 1; + + /* we try to allocate a counter to track the stats of this + * rule. If counter could not be allocated then proceed + * without counter because counters are limited than entries. + */ + err =3D __npc_mcam_alloc_counter(rvu, &cntr_req, &cntr_rsp); + if (!err && cntr_rsp.count) { + rule->cntr =3D cntr_rsp.cntr; + rule->has_cntr =3D true; + rsp->counter =3D rule->cntr; + } else { + rsp->counter =3D err; + } +} + int rvu_mbox_handler_npc_mcam_unmap_counter(struct rvu *rvu, struct npc_mcam_unmap_counter_req *req, struct msg_rsp *rsp) { diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c b/drive= rs/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c index 150635de2bd5..7a1c18b1486d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c @@ -1081,44 +1081,26 @@ static void rvu_mcam_add_rule(struct npc_mcam *mcam, static void rvu_mcam_remove_counter_from_rule(struct rvu *rvu, u16 pcifunc, struct rvu_npc_mcam_rule *rule) { - struct npc_mcam_oper_counter_req free_req =3D { 0 }; - struct msg_rsp free_rsp; + struct npc_mcam *mcam =3D &rvu->hw->mcam; =20 - if (!rule->has_cntr) - return; + mutex_lock(&mcam->lock); =20 - free_req.hdr.pcifunc =3D pcifunc; - free_req.cntr =3D rule->cntr; + __rvu_mcam_remove_counter_from_rule(rvu, pcifunc, rule); =20 - rvu_mbox_handler_npc_mcam_free_counter(rvu, &free_req, &free_rsp); - rule->has_cntr =3D false; + mutex_unlock(&mcam->lock); } =20 static void rvu_mcam_add_counter_to_rule(struct rvu *rvu, u16 pcifunc, struct rvu_npc_mcam_rule *rule, struct npc_install_flow_rsp *rsp) { - struct npc_mcam_alloc_counter_req cntr_req =3D { 0 }; - struct npc_mcam_alloc_counter_rsp cntr_rsp =3D { 0 }; - int err; + struct npc_mcam *mcam =3D &rvu->hw->mcam; =20 - cntr_req.hdr.pcifunc =3D pcifunc; - cntr_req.contig =3D true; - cntr_req.count =3D 1; + mutex_lock(&mcam->lock); =20 - /* we try to allocate a counter to track the stats of this - * rule. If counter could not be allocated then proceed - * without counter because counters are limited than entries. - */ - err =3D rvu_mbox_handler_npc_mcam_alloc_counter(rvu, &cntr_req, - &cntr_rsp); - if (!err && cntr_rsp.count) { - rule->cntr =3D cntr_rsp.cntr; - rule->has_cntr =3D true; - rsp->counter =3D rule->cntr; - } else { - rsp->counter =3D err; - } + __rvu_mcam_add_counter_to_rule(rvu, pcifunc, rule, rsp); + + mutex_unlock(&mcam->lock); } =20 static int npc_mcast_update_action_index(struct rvu *rvu, struct npc_insta= ll_flow_req *req, --=20 2.34.1 From nobody Mon Nov 25 08:01:26 2024 Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6DC2200CB6; Tue, 29 Oct 2024 03:58:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730174292; cv=none; b=q2ehX9VNLXicPThmPj5PIqu2n+Y4VF+uPzuIzJ9xjqVrB26M3x/1bpNIFcbRisO/7CxaPvbyKd/a0RavrC3s2eC8IVsjTvvF2rOe37IiLgyFB/8HSxz/egGTtkYAc1mSldL1A7e+LLgYZ1vNl9n148paJM9Tk2jR5QHBt8V+xyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730174292; c=relaxed/simple; bh=C5LDk1/+vJE76Y2p6FVY3qu4lKh4jkaZn6bJVMwO4vw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nfRWjjtDtPXrzYcrcR1JFTJeu873+vg4w7C7IioKL41NP7r4SH7/ym4sAi5ZAwySm/rddwz4BgP6rnGktRQEkl4qG6WsZ52qCCadPPM5KBF9osgfu6EXZVv8gu9UGCgnk6O9JqclvzBfSrSItySRXKBgEDTnt/OqEHoh0SFLimw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=dIyk/Vr3; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="dIyk/Vr3" Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49T3RoBd022013; Mon, 28 Oct 2024 20:58:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=g SJISprJl/otmxTFP3ot0RiGqvnCXQgEtRDqi7k32S8=; b=dIyk/Vr3FrjSlISVE UcW60N65r0ClA+Q9yetbbqDR3dBjs/DamudWf2LlMLlduJnNGWwcsmvQDWCZZXzW 3OsLnOp920+dDowsB6ZUk/ySDHHYIo3ZZqT62EweTPGF2CBXrifjpTzBZ8Ewo2Po 8GvBJpPvJgmeXZIhvfyBQm7Tha0IwFAAg1CGd2Z0upq4Cs734K3Jo+o9Y1HbEcIh 6ttSqgw5Lqay6QwhIqGah0GClqFotgyPFGbaaOoFuVYGlk1IM3Y3A8Tqx25uZOJh vdfumeiVhHGY226THnUL9YGiTZe6kW8u/wYrasoWUKsm7BY0MWF5ad1z8l+jnHVD nM3wA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42jqtcg2g6-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Oct 2024 20:58:03 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 28 Oct 2024 20:58:02 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 28 Oct 2024 20:58:02 -0700 Received: from virtx40.. (unknown [10.28.34.196]) by maili.marvell.com (Postfix) with ESMTP id D20773F704D; Mon, 28 Oct 2024 20:57:58 -0700 (PDT) From: Linu Cherian To: , , , CC: , , , , , , , , , , Linu Cherian Subject: [PATCH v4 net-next 2/3] octeontx2-af: Knobs for NPC default rule counters Date: Tue, 29 Oct 2024 09:27:38 +0530 Message-ID: <20241029035739.1981839-3-lcherian@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029035739.1981839-1-lcherian@marvell.com> References: <20241029035739.1981839-1-lcherian@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: ZbqU_RWzePeygnFiPWe5O-WLIok4K-e1 X-Proofpoint-GUID: ZbqU_RWzePeygnFiPWe5O-WLIok4K-e1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 Content-Type: text/plain; charset="utf-8" Add devlink knobs to enable/disable counters on NPC default rule entries. Sample command to enable default rule counters: devlink dev param set name npc_def_rule_cntr value true cmode runtime Sample command to read the counter: cat /sys/kernel/debug/cn10k/npc/mcam_rules Signed-off-by: Linu Cherian Reviewed-by: Simon Horman --- Changelog from v3: No changes. .../net/ethernet/marvell/octeontx2/af/rvu.h | 2 + .../marvell/octeontx2/af/rvu_devlink.c | 32 +++++++++++++ .../ethernet/marvell/octeontx2/af/rvu_npc.c | 45 +++++++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/= ethernet/marvell/octeontx2/af/rvu.h index d92a5f47a476..e8c6a6fe9bd5 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h @@ -525,6 +525,7 @@ struct rvu { struct mutex alias_lock; /* Serialize bar2 alias access */ int vfs; /* Number of VFs attached to RVU */ u16 vf_devid; /* VF devices id */ + bool def_rule_cntr_en; int nix_blkaddr[MAX_NIX_BLKS]; =20 /* Mbox */ @@ -989,6 +990,7 @@ void npc_set_mcam_action(struct rvu *rvu, struct npc_mc= am *mcam, void npc_read_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam, int blkaddr, u16 src, struct mcam_entry *entry, u8 *intf, u8 *ena); +int npc_config_cntr_default_entries(struct rvu *rvu, bool enable); bool is_cgx_config_permitted(struct rvu *rvu, u16 pcifunc); bool is_mac_feature_supported(struct rvu *rvu, int pf, int feature); u32 rvu_cgx_get_fifolen(struct rvu *rvu); diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c b/driv= ers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c index 7498ab429963..9c26e19a860b 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c @@ -1238,6 +1238,7 @@ enum rvu_af_dl_param_id { RVU_AF_DEVLINK_PARAM_ID_DWRR_MTU, RVU_AF_DEVLINK_PARAM_ID_NPC_MCAM_ZONE_PERCENT, RVU_AF_DEVLINK_PARAM_ID_NPC_EXACT_FEATURE_DISABLE, + RVU_AF_DEVLINK_PARAM_ID_NPC_DEF_RULE_CNTR_ENABLE, RVU_AF_DEVLINK_PARAM_ID_NIX_MAXLF, }; =20 @@ -1358,6 +1359,32 @@ static int rvu_af_dl_npc_mcam_high_zone_percent_vali= date(struct devlink *devlink return 0; } =20 +static int rvu_af_dl_npc_def_rule_cntr_get(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct rvu_devlink *rvu_dl =3D devlink_priv(devlink); + struct rvu *rvu =3D rvu_dl->rvu; + + ctx->val.vbool =3D rvu->def_rule_cntr_en; + + return 0; +} + +static int rvu_af_dl_npc_def_rule_cntr_set(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx, + struct netlink_ext_ack *extack) +{ + struct rvu_devlink *rvu_dl =3D devlink_priv(devlink); + struct rvu *rvu =3D rvu_dl->rvu; + int err; + + err =3D npc_config_cntr_default_entries(rvu, ctx->val.vbool); + if (!err) + rvu->def_rule_cntr_en =3D ctx->val.vbool; + + return err; +} + static int rvu_af_dl_nix_maxlf_get(struct devlink *devlink, u32 id, struct devlink_param_gset_ctx *ctx) { @@ -1444,6 +1471,11 @@ static const struct devlink_param rvu_af_dl_params[]= =3D { rvu_af_dl_npc_mcam_high_zone_percent_get, rvu_af_dl_npc_mcam_high_zone_percent_set, rvu_af_dl_npc_mcam_high_zone_percent_validate), + DEVLINK_PARAM_DRIVER(RVU_AF_DEVLINK_PARAM_ID_NPC_DEF_RULE_CNTR_ENABLE, + "npc_def_rule_cntr", DEVLINK_PARAM_TYPE_BOOL, + BIT(DEVLINK_PARAM_CMODE_RUNTIME), + rvu_af_dl_npc_def_rule_cntr_get, + rvu_af_dl_npc_def_rule_cntr_set, NULL), DEVLINK_PARAM_DRIVER(RVU_AF_DEVLINK_PARAM_ID_NIX_MAXLF, "nix_maxlf", DEVLINK_PARAM_TYPE_U16, BIT(DEVLINK_PARAM_CMODE_RUNTIME), diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/= net/ethernet/marvell/octeontx2/af/rvu_npc.c index c4ef1e83cc46..9e39c3149a4f 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c @@ -2691,6 +2691,51 @@ void npc_mcam_rsrcs_reserve(struct rvu *rvu, int blk= addr, int entry_idx) npc_mcam_set_bit(mcam, entry_idx); } =20 +int npc_config_cntr_default_entries(struct rvu *rvu, bool enable) +{ + struct npc_install_flow_rsp rsp =3D { 0 }; + struct npc_mcam *mcam =3D &rvu->hw->mcam; + struct rvu_npc_mcam_rule *rule; + int blkaddr; + + blkaddr =3D rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0); + if (blkaddr < 0) + return -EINVAL; + + mutex_lock(&mcam->lock); + list_for_each_entry(rule, &mcam->mcam_rules, list) { + if (!is_mcam_entry_enabled(rvu, mcam, blkaddr, rule->entry)) + continue; + if (!rule->default_rule) + continue; + if (enable && !rule->has_cntr) { /* Alloc and map new counter */ + __rvu_mcam_add_counter_to_rule(rvu, rule->owner, + rule, &rsp); + if (rsp.counter < 0) { + dev_err(rvu->dev, "%s: Err to allocate cntr for default rule (err=3D%d= )\n", + __func__, rsp.counter); + break; + } + npc_map_mcam_entry_and_cntr(rvu, mcam, blkaddr, + rule->entry, rsp.counter); + } + + if (enable && rule->has_cntr) /* Reset counter before use */ { + rvu_write64(rvu, blkaddr, + NPC_AF_MATCH_STATX(rule->cntr), 0x0); + continue; + } + + if (!enable && rule->has_cntr) /* Free and unmap counter */ { + __rvu_mcam_remove_counter_from_rule(rvu, rule->owner, + rule); + } + } + mutex_unlock(&mcam->lock); + + return 0; +} + int rvu_mbox_handler_npc_mcam_alloc_entry(struct rvu *rvu, struct npc_mcam_alloc_entry_req *req, struct npc_mcam_alloc_entry_rsp *rsp) --=20 2.34.1 From nobody Mon Nov 25 08:01:26 2024 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05F662010E0; Tue, 29 Oct 2024 03:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730174296; cv=none; b=Y7pUX+i7FKQmTeBMjZAY5tU9ru8vtJhyM2lCWDywwOiEXxK0WIFd9rHO6hzjoAyf2klpIr5heNo8iUH7pJSkzjy1H/HuXWVnUx0vKZNuc7qpgs5k4i3M27aDuCeSjlia7n7y3PpTgyF0vgYbY9EaLo7IeT/Nj+mK9t0/VoHJYS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730174296; c=relaxed/simple; bh=F2u3cl2SjWcs3OjghOgsxJYL8VpiRf/JhfUKtn4kDwQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ixoaW8PHqZyV1+vEMUozBxx/PtE+21srN3g5gMHeThVXR98HWM15PSnikxp/w9Zstp2lM9MDnkthck2BIjHU4rzi0/CTpa1JQ5JoHZ9zZywU72JN+O6MFn6lERz3s1dlrHdYtkKF7HbqJWSDDT+V8aEj5/W69MZc1n30/OBzz30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=AITu+Rjp; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="AITu+Rjp" Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49T0ABte014722; Mon, 28 Oct 2024 20:58:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=/ sDZ1ethO15plh1blqFEQBc1mrttvUCmt9BDT2Yu4Rs=; b=AITu+RjpGFvVvxSAg djOXHk2QWpOILA2opgcg4Sx/Ar2PwtzDgrjDK81oMKKJp+78apCWIy5SZ6BQ9HAF ZCC1o0H4wG69/xKIXW7hvjmU22XyRuUJXkR/6WT6Vj2+J7wj2DG6br4uU2HNj8k0 8oYe7VqMSOPChGAp4g7bdUNdLebl1TPnIFqK6YJpXR119frU7Xn90Vhc3buSsvdP Hxff5dxcFLL372azL8WDpbGofoguGWWfKVFKAg0jO+JQ68KPcX9+ml2MdkeuhXRX dLLIsCRbchdBXnJ9wVVbWBQszcoFYikj+0ObPva22wh+0XHBU7jXaJ9/+ascmf++ F07/g== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42jmx40ggd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Oct 2024 20:58:08 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 28 Oct 2024 20:58:07 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 28 Oct 2024 20:58:07 -0700 Received: from virtx40.. (unknown [10.28.34.196]) by maili.marvell.com (Postfix) with ESMTP id 64A163F7054; Mon, 28 Oct 2024 20:58:03 -0700 (PDT) From: Linu Cherian To: , , , CC: , , , , , , , , , , Linu Cherian Subject: [PATCH v4 net-next 3/3] devlink: Add documenation for OcteonTx2 AF Date: Tue, 29 Oct 2024 09:27:39 +0530 Message-ID: <20241029035739.1981839-4-lcherian@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029035739.1981839-1-lcherian@marvell.com> References: <20241029035739.1981839-1-lcherian@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: I-XO5X8Xjcx0pKkDNmzNJ-VE3Ac3rchC X-Proofpoint-GUID: I-XO5X8Xjcx0pKkDNmzNJ-VE3Ac3rchC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Type: text/plain; charset="utf-8" Add documenation for the following devlink params - npc_mcam_high_zone_percent - npc_def_rule_cntr - nix_maxlf Signed-off-by: Linu Cherian Reviewed-by: Simon Horman --- Changelog from v3: Newly added patch Documentation/networking/devlink/octeontx2.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/networking/devlink/octeontx2.rst b/Documentation= /networking/devlink/octeontx2.rst index d33a90dd44bf..7808ab361692 100644 --- a/Documentation/networking/devlink/octeontx2.rst +++ b/Documentation/networking/devlink/octeontx2.rst @@ -40,6 +40,21 @@ The ``octeontx2 AF`` driver implements the following dri= ver-specific parameters. - runtime - Use to set the quantum which hardware uses for scheduling among tra= nsmit queues. Hardware uses weighted DWRR algorithm to schedule among all transmi= t queues. + * - ``npc_mcam_high_zone_percent`` + - u8 + - runtime + - Use to set the number of high priority zone entries in NPC MCAM tha= t can be allocated + by a user, out of the three priority zone categories high, mid and = low. + * - ``npc_def_rule_cntr`` + - bool + - runtime + - Use to enable or disable hit counters for the default rules in NPC = MCAM. + * - ``nix_maxlf`` + - u16 + - runtime + - Use to set the maximum number of LFs in NIX hardware block. This wo= uld be useful + to increase the availability of default resources allocated to enab= led LFs like + MCAM entries for example. =20 The ``octeontx2 PF`` driver implements the following driver-specific param= eters. =20 --=20 2.34.1