From patchwork Tue Nov 14 17:36:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdullah Sevincer X-Patchwork-Id: 134366 X-Patchwork-Delegate: thomas@monjalon.net 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 88CEB4332D; Tue, 14 Nov 2023 18:36:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 730D44028A; Tue, 14 Nov 2023 18:36:15 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id E2CEF4027B for ; Tue, 14 Nov 2023 18:36:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699983374; x=1731519374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wExmIDeH97IZ2kmn/5JnjIh2Hyac/jAA4U8Kyc4wFGM=; b=mt4eAvjlwskAu4OlPJrGYcmsHiGRQPhMcPINdH+v8vDBloDWY8EGbKX6 x1+SDmP+lea5aEZH+udac1apgLTwh4LR1AlDnbtpG7315K9FXiw0oZuu9 S/o+RPhopf2hgeoogcJvE4h960zQYgx/suCsPQlbqfolKDcmCjfBE3/xD 0zMnEEcBkVj/tZxv7NMeaSO5DJan5CiQDccNKOdNquMkKQ6WjRoAMYAqz e2T4Q1AfBvElGteKoCXwGkiSsYwbkb8ZNN1WxVPuLaaW0mLP2w3gwMfma 9mJcE9+RYuBPWqldrx6tBUf52k4CDMGf+Q9kANblRAfdq8SFwJ1INb8os A==; X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="457200214" X-IronPort-AV: E=Sophos;i="6.03,302,1694761200"; d="scan'208";a="457200214" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 09:36:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,302,1694761200"; d="scan'208";a="12496725" Received: from txanpdk02.an.intel.com ([10.123.117.76]) by orviesa001.jf.intel.com with ESMTP; 14 Nov 2023 09:36:12 -0800 From: Abdullah Sevincer To: dev@dpdk.org Cc: jerinj@marvell.com, mike.ximing.chen@intel.com, bruce.richardson@intel.com, thomas@monjalon.net, david.marchand@redhat.com, nipun.gupta@amd.com, chenbox@nvidia.com, Abdullah Sevincer Subject: [PATCH v2] bus/pci: revise support PASID control Date: Tue, 14 Nov 2023 11:36:09 -0600 Message-Id: <20231114173609.3590237-1-abdullah.sevincer@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231113172759.3529518-1-abdullah.sevincer@intel.com> References: <20231113172759.3529518-1-abdullah.sevincer@intel.com> MIME-Version: 1.0 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 This commit revises PASID control function to accept PASID offset to pasid *structure* instead of taking exact register for controlling the feature. PASID control function was introduced in earlier commit. Please see commit 5a6878335b81 ("event/dlb2: disable PASID") and commit 60ea19609aec ("bus/pci: add PASID control"). Signed-off-by: Abdullah Sevincer Reviewed-by: Chenbo Xia --- drivers/bus/pci/pci_common.c | 5 ++--- drivers/bus/pci/rte_bus_pci.h | 5 ++++- drivers/event/dlb2/pf/dlb2_main.c | 4 ++-- lib/pci/rte_pci.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index ba5e280d33..889a48d2af 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -943,9 +943,8 @@ rte_pci_pasid_set_state(const struct rte_pci_device *dev, off_t offset, bool enable) { uint16_t pasid = enable; - return rte_pci_write_config(dev, &pasid, sizeof(pasid), offset) < 0 - ? -1 - : 0; + return rte_pci_write_config(dev, &pasid, sizeof(pasid), + offset + RTE_PCI_PASID_CTRL) != sizeof(pasid) ? -1 : 0; } struct rte_pci_bus rte_pci_bus = { diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h index f07bf9b588..35d07d8294 100644 --- a/drivers/bus/pci/rte_bus_pci.h +++ b/drivers/bus/pci/rte_bus_pci.h @@ -161,9 +161,12 @@ int rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable); * @param dev * A pointer to a rte_pci_device structure. * @param offset - * Offset of the PASID external capability. + * Offset of the PASID external capability structure. * @param enable * Flag to enable or disable PASID. + * + * @return + * 0 on success, -1 on error in PCI config space read/write. */ __rte_internal int rte_pci_pasid_set_state(const struct rte_pci_device *dev, diff --git a/drivers/event/dlb2/pf/dlb2_main.c b/drivers/event/dlb2/pf/dlb2_main.c index 61a7b39eef..a95d3227a4 100644 --- a/drivers/event/dlb2/pf/dlb2_main.c +++ b/drivers/event/dlb2/pf/dlb2_main.c @@ -518,8 +518,8 @@ dlb2_pf_reset(struct dlb2_dev *dlb2_dev) /* Disable PASID if it is enabled by default, which * breaks the DLB if enabled. */ - off = DLB2_PCI_PASID_CAP_OFFSET + RTE_PCI_PASID_CTRL; - if (rte_pci_pasid_set_state(pdev, off, false)) { + off = DLB2_PCI_PASID_CAP_OFFSET; + if (rte_pci_pasid_set_state(pdev, off, false) < 0) { DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n", __func__, (int)off); return -1; diff --git a/lib/pci/rte_pci.h b/lib/pci/rte_pci.h index 0d2d8d8fed..c26fc77209 100644 --- a/lib/pci/rte_pci.h +++ b/lib/pci/rte_pci.h @@ -101,7 +101,7 @@ extern "C" { #define RTE_PCI_EXT_CAP_ID_ACS 0x0d /* Access Control Services */ #define RTE_PCI_EXT_CAP_ID_SRIOV 0x10 /* SR-IOV */ #define RTE_PCI_EXT_CAP_ID_PRI 0x13 /* Page Request Interface */ -#define RTE_PCI_EXT_CAP_ID_PASID 0x1B /* Process Address Space ID */ +#define RTE_PCI_EXT_CAP_ID_PASID 0x1b /* Process Address Space ID */ /* Advanced Error Reporting (RTE_PCI_EXT_CAP_ID_ERR) */ #define RTE_PCI_ERR_UNCOR_STATUS 0x04 /* Uncorrectable Error Status */