From patchwork Thu Sep 21 13:19:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Bhansali X-Patchwork-Id: 131795 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2F04F42606; Thu, 21 Sep 2023 15:21:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA258402D2; Thu, 21 Sep 2023 15:21:18 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 36F28402C5 for ; Thu, 21 Sep 2023 15:21:16 +0200 (CEST) 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 38L7Porh001328 for ; Thu, 21 Sep 2023 06:21:15 -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=yEHhxUPZSYT35NabxhDB/wEBnJ3QhMR0NIVj96h0YkQ=; b=fw+A2CQc408hGLAGWFPdoRcxBVZO7BwEqjcDXCS84fMZLxJMdds68GXbZPY15I8gD7ph xocRav+ALnsjrpHy7Ox2j6OWF2KtCFTN5RBg/PEFu4Gfa1GhopDqu12QeVov69HOYyE8 2ONNWORbVJvmb6m3DYaNt9WM9LcBW93fMw+1snyR/ao9LLqLRQR7zAP3bFic2mAe9Xwk cLoWHu5rFqDOexk3HiEJY542Ku9Wpi+CQYsgK8Rgdual/8xhjjuXQhyUGLYvbk59pSeR P6/HheNtwr2jr9Fa2OdE5vAr+os96+Gl4hwnppNLvtZtHWmZFFSeeR0nD2ub/alCAhow BA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3t7u4de6xd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 21 Sep 2023 06:21:14 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 21 Sep 2023 06:20:00 -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, 21 Sep 2023 06:20:00 -0700 Received: from localhost.localdomain (unknown [10.28.36.158]) by maili.marvell.com (Postfix) with ESMTP id 396635B693B; Thu, 21 Sep 2023 06:19:57 -0700 (PDT) From: Rahul Bhansali To: , Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , Rahul Bhansali Subject: [PATCH v2] common/cnxk: reserve last LMT line for control ops Date: Thu, 21 Sep 2023 18:49:53 +0530 Message-ID: <20230921131953.1483157-1-rbhansali@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230920101222.767408-1-rbhansali@marvell.com> References: <20230920101222.767408-1-rbhansali@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Cjo0tR2ZAXF-wzq8xiRJTJ62EH46D7DR X-Proofpoint-GUID: Cjo0tR2ZAXF-wzq8xiRJTJ62EH46D7DR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-21_11,2023-09-21_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org As rte_eth_dev_configure() can be called from any EAL or non-EAL cores. And in case of non-EAL core, LMT address will not be a valid. So, reserving last LMT line 2047 for control path specific functionality. Signed-off-by: Rahul Bhansali --- v2 change: No change, sent as independent of series. drivers/common/cnxk/roc_dev.c | 5 +++++ drivers/common/cnxk/roc_nix_inl.c | 6 ++++-- drivers/common/cnxk/roc_platform.c | 25 +++++++++++++++++++++++++ drivers/common/cnxk/roc_platform.h | 5 +++++ drivers/common/cnxk/version.map | 2 ++ 5 files changed, 41 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c index 18d7981825..3815da078a 100644 --- a/drivers/common/cnxk/roc_dev.c +++ b/drivers/common/cnxk/roc_dev.c @@ -1369,6 +1369,11 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev) if (!dev_cache_line_size_valid()) return -EFAULT; + if (!roc_plt_lmt_validate()) { + plt_err("Failed to validate LMT line"); + return -EFAULT; + } + bar2 = (uintptr_t)pci_dev->mem_resource[2].addr; bar4 = (uintptr_t)pci_dev->mem_resource[4].addr; if (bar2 == 0 || bar4 == 0) { diff --git a/drivers/common/cnxk/roc_nix_inl.c b/drivers/common/cnxk/roc_nix_inl.c index 5cb1f11f53..750fd08355 100644 --- a/drivers/common/cnxk/roc_nix_inl.c +++ b/drivers/common/cnxk/roc_nix_inl.c @@ -779,8 +779,10 @@ nix_inl_eng_caps_get(struct nix *nix) hw_res->cn10k.compcode = CPT_COMP_NOT_DONE; - /* Use this lcore's LMT line as no one else is using it */ - ROC_LMT_BASE_ID_GET(lmt_base, lmt_id); + /* Use this reserved LMT line as no one else is using it */ + lmt_id = roc_plt_control_lmt_id_get(); + lmt_base += ((uint64_t)lmt_id << ROC_LMT_LINE_SIZE_LOG2); + memcpy((void *)lmt_base, &inst, sizeof(inst)); lmt_arg = ROC_CN10K_CPT_LMT_ARG | (uint64_t)lmt_id; diff --git a/drivers/common/cnxk/roc_platform.c b/drivers/common/cnxk/roc_platform.c index a8a83a3723..15cbb6d68f 100644 --- a/drivers/common/cnxk/roc_platform.c +++ b/drivers/common/cnxk/roc_platform.c @@ -21,6 +21,31 @@ roc_plt_init_cb_register(roc_plt_init_cb_t cb) return 0; } +uint16_t +roc_plt_control_lmt_id_get(void) +{ + uint32_t lcore_id = plt_lcore_id(); + if (lcore_id != LCORE_ID_ANY) + return lcore_id << ROC_LMT_LINES_PER_CORE_LOG2; + else + /* Return Last LMT ID to be use in control path functionality */ + return ROC_NUM_LMT_LINES - 1; +} + +uint16_t +roc_plt_lmt_validate(void) +{ + if (!roc_model_is_cn9k()) { + /* Last LMT line is reserved for control specific operation and can be + * use from any EAL or non EAL cores. + */ + if ((RTE_MAX_LCORE << ROC_LMT_LINES_PER_CORE_LOG2) > + (ROC_NUM_LMT_LINES - 1)) + return 0; + } + return 1; +} + int roc_plt_init(void) { diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h index dbc0858e18..6d52a14009 100644 --- a/drivers/common/cnxk/roc_platform.h +++ b/drivers/common/cnxk/roc_platform.h @@ -316,6 +316,11 @@ extern int cnxk_logtype_dpi; __rte_internal int roc_plt_init(void); +__rte_internal +uint16_t roc_plt_control_lmt_id_get(void); +__rte_internal +uint16_t roc_plt_lmt_validate(void); + /* Init callbacks */ typedef int (*roc_plt_init_cb_t)(void); int __roc_api roc_plt_init_cb_register(roc_plt_init_cb_t cb); diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index 38064919e4..4dce181437 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -464,6 +464,8 @@ INTERNAL { roc_ot_ipsec_outb_sa_init; roc_plt_init; roc_plt_init_cb_register; + roc_plt_lmt_validate; + roc_plt_control_lmt_id_get; roc_sso_dev_fini; roc_sso_dev_init; roc_sso_dump;