Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp503830rwd; Thu, 8 Jun 2023 04:03:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ48P1aqeRv1Hblav/cta80B38tSAz0IE3eSUPAxwJkqnl6P0OVsihfIAWzgT5nXMDpzfAWB X-Received: by 2002:a17:90a:4b4e:b0:259:acbd:c6ef with SMTP id o14-20020a17090a4b4e00b00259acbdc6efmr3726926pjl.16.1686222236148; Thu, 08 Jun 2023 04:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686222236; cv=none; d=google.com; s=arc-20160816; b=OXfuZnqCStMKVezBaRCBnBc34U3vkGcEd3lWcJ2nQYMX2qhRjyyTAhLXzE5ARLGp0K DXb0NAdqB5eImTdDnHpj3S97/ocbb+shRO6bET7OWnB836ifTurMG2ah2veAVJaGdRdY K6/e56cXRYXmZcs3xJ92jZXGvxIOslbOGpSAVdUE/iYNbYNj3IcSJKTcGXxrjeuzR4Ku mfBGfSs2NVRN7865TFv1ibZhf5iWnGpdMRSt+zA0gjCt1sclLRFbnMaPb5o/vZ4JkuEe k6/+xwVVS9KEYBw4Z+uNhivuD3QSE/IiVzLV99GqajsDtQgV4JZjq4a65vFxE1KVSJtz jazQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L2TeqzzSAJW3Y0ujjwLs+3OlJYXWv6M+88djxLDuzzk=; b=j7y4GUzFdaGMImqVtzUoRbBY1TUMdG7dwrO+QuBWfMbkYK3OKv+2AXmBpvAf3j1X0H 7xLuLyuToZgntcKdpD/dUywLT8fucQ/LAMZZxsYKWLbmLNSyZhNnUUq9R1nUjNU1/7Ba dSgp6r0Wc+t4D3+44gI3GYeaRq4nD7L/Rla0rCzfoGliNMgsGfSbzoefdpzuWZGKZOB+ Msv1VxAXcNMOXUyTa5emdfjzg0rBJnTpAbvPLYvLeOxwC8Kbmloa6NESFEBA9YI4BAYB jUCEkgm8SltP332r13/UJ7v9CEQjGz9qeYQMYURm8ytNWsp4G9//8ryG6JRCIHhfgvyL zPyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=b0nljOoX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo7-20020a17090b090700b00256c16039efsi874481pjb.163.2023.06.08.04.03.41; Thu, 08 Jun 2023 04:03:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=b0nljOoX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235569AbjFHKu2 (ORCPT + 99 others); Thu, 8 Jun 2023 06:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232116AbjFHKuX (ORCPT ); Thu, 8 Jun 2023 06:50:23 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE65A269A; Thu, 8 Jun 2023 03:50:22 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3587nH50023576; Thu, 8 Jun 2023 03:50:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=L2TeqzzSAJW3Y0ujjwLs+3OlJYXWv6M+88djxLDuzzk=; b=b0nljOoXhMD9NayzOdT2KlvF5u1a0ivMgpbneDuDdvw8cKag8fNYHIrFkWaC2YyU+JRO fMq7WryeKpaLAr4aeJEfC/OZHWyfXsxOiC7NwOOUcoMaJnARFZIGf4S+/zO1nxBeQvXG bAJ6zI+7/6kWRwt8h9XUslR+My3FciwEsp2iGd5kKb4LyyPW/59zgzo5j2OdA0ZQC/ux v4eibrsIIAOI+7qrGCfeufhewSAFJ14NCos3NvMjxrmHf9E3wC4dE+mbVq6O/1muk7wx sEIdWRm3lorXBSPKvQowVLCtam8R/DLJYG3yXooYyQjcktijf1wvb0bmmoTETRQKqdhc aQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3r329c2c30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 08 Jun 2023 03:50:16 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 8 Jun 2023 03:50:15 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 8 Jun 2023 03:50:15 -0700 Received: from #hyd1583.marvell.com (unknown [10.29.37.44]) by maili.marvell.com (Postfix) with ESMTP id DF6573F707F; Thu, 8 Jun 2023 03:50:12 -0700 (PDT) From: Naveen Mamindlapalli To: , , , , , , CC: Naveen Mamindlapalli Subject: [net-next PATCH 1/6] octeontx2-af: Add devlink option to adjust mcam high prio zone entries Date: Thu, 8 Jun 2023 16:20:02 +0530 Message-ID: <20230608105007.26924-2-naveenm@marvell.com> X-Mailer: git-send-email 2.39.0.198.ga38d39a4c5 In-Reply-To: <20230608105007.26924-1-naveenm@marvell.com> References: <20230608105007.26924-1-naveenm@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: gT39MCYMJMLnozTCBMUbCjhRItGLTfBo X-Proofpoint-ORIG-GUID: gT39MCYMJMLnozTCBMUbCjhRItGLTfBo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-08_07,2023-06-08_01,2023-05-22_02 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The NPC MCAM entries are currently divided into three priority zones in AF driver: high, mid, and low. The high priority zone and low priority zone take up 1/8th (each) of the available MCAM entries, and remaining going to the mid priority zone. The current allocation scheme may not meet certain requirements, such as when a requester needs more high priority zone entries than are reserved. This patch adds a devlink configurable option to increase the number of high priority zone entries that can be allocated by requester. The max number of entries that can be reserved for high priority usage is 100% of available MCAM entries. Usage: 1) Change high priority zone percentage to 75%: devlink -p dev param set pci/0002:01:00.0 name npc_mcam_high_zone_percent \ value 75 cmode runtime 2) Read high priority zone percentage: devlink -p dev param show pci/0002:01:00.0 name npc_mcam_high_zone_percent The devlink set configuration is only permitted when no MCAM entries are assigned, i.e., all MCAM entries are free, indicating that no PF/VF driver is loaded. So user must unload/unbind PF/VF driver/devices before modifying the high priority zone percentage. Signed-off-by: Naveen Mamindlapalli Signed-off-by: Sunil Goutham --- .../marvell/octeontx2/af/rvu_devlink.c | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c index bda1a6fa2ec4..64b8beaa7247 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c @@ -1438,6 +1438,7 @@ enum rvu_af_dl_param_id { RVU_AF_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, RVU_AF_DEVLINK_PARAM_ID_DWRR_MTU, RVU_AF_DEVLINK_PARAM_ID_NPC_EXACT_FEATURE_DISABLE, + RVU_AF_DEVLINK_PARAM_ID_NPC_MCAM_ZONE_PERCENT, }; static int rvu_af_npc_exact_feature_get(struct devlink *devlink, u32 id, @@ -1494,6 +1495,67 @@ static int rvu_af_npc_exact_feature_validate(struct devlink *devlink, u32 id, return -EFAULT; } +static int rvu_af_dl_npc_mcam_high_zone_percent_get(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct rvu_devlink *rvu_dl = devlink_priv(devlink); + struct rvu *rvu = rvu_dl->rvu; + struct npc_mcam *mcam; + u32 percent; + + mcam = &rvu->hw->mcam; + percent = (mcam->hprio_count * 100) / mcam->bmap_entries; + ctx->val.vu8 = (u8)percent; + + return 0; +} + +static int rvu_af_dl_npc_mcam_high_zone_percent_set(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct rvu_devlink *rvu_dl = devlink_priv(devlink); + struct rvu *rvu = rvu_dl->rvu; + struct npc_mcam *mcam; + u32 percent; + + percent = ctx->val.vu8; + mcam = &rvu->hw->mcam; + mcam->hprio_count = (mcam->bmap_entries * percent) / 100; + mcam->hprio_end = mcam->hprio_count; + mcam->lprio_count = (mcam->bmap_entries - mcam->hprio_count) / 2; + mcam->lprio_start = mcam->bmap_entries - mcam->lprio_count; + + return 0; +} + +static int rvu_af_dl_npc_mcam_high_zone_percent_validate(struct devlink *devlink, u32 id, + union devlink_param_value val, + struct netlink_ext_ack *extack) +{ + struct rvu_devlink *rvu_dl = devlink_priv(devlink); + struct rvu *rvu = rvu_dl->rvu; + struct npc_mcam *mcam; + + /* The percent of high prio zone must range from 12% to 100% of unreserved mcam space */ + if (val.vu8 < 12 || val.vu8 > 100) { + NL_SET_ERR_MSG_MOD(extack, + "mcam high zone percent must be between 12% to 100%"); + return -EINVAL; + } + + /* Do not allow user to modify the high priority zone entries while mcam entries + * have already been assigned. + */ + mcam = &rvu->hw->mcam; + if (mcam->bmap_fcnt < mcam->bmap_entries) { + NL_SET_ERR_MSG_MOD(extack, + "mcam entries have already been assigned, can't resize"); + return -EPERM; + } + + return 0; +} + static const struct devlink_param rvu_af_dl_params[] = { DEVLINK_PARAM_DRIVER(RVU_AF_DEVLINK_PARAM_ID_DWRR_MTU, "dwrr_mtu", DEVLINK_PARAM_TYPE_U32, @@ -1506,6 +1568,12 @@ static const struct devlink_param rvu_af_dl_params[] = { rvu_af_npc_exact_feature_get, rvu_af_npc_exact_feature_disable, rvu_af_npc_exact_feature_validate), + DEVLINK_PARAM_DRIVER(RVU_AF_DEVLINK_PARAM_ID_NPC_MCAM_ZONE_PERCENT, + "npc_mcam_high_zone_percent", DEVLINK_PARAM_TYPE_U8, + BIT(DEVLINK_PARAM_CMODE_RUNTIME), + 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 switch mode */ -- 2.39.0.198.ga38d39a4c5