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 B7B1B42C5D for ; Thu, 8 Jun 2023 10:08:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AFE94410F2; Thu, 8 Jun 2023 10:08:32 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id CFB0840042; Thu, 8 Jun 2023 10:08:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686211711; x=1717747711; h=from:to:cc:subject:date:message-id; bh=dT+g4eGK1ArjzpBZ3bL431XlKnHPufBz+TKaebUt918=; b=NguOxL6niL9IOUIYiaOEoSU3LcwZFJ6j2DARnk3Q5jpm9kQwO61kbOJb +v8itM4HpcQPhDud0mTSJk4p6qB2kE+0ivr0yDy4Wuij8GNckcMXjAVwu 8y11Gq/v683mur7CqmYCwVCIZ3aCR+YkW9Sg/F39CeCBHp+posEvcTRZs cG5rzAXNDCiI7bXTLivnQJfPMZ+ZVmY0QcJPSySS15yLWf/0PoCywUToy kOcsBUTbxsC/uMx8lWr+D1ZPZnORthmzrfzqM4MbZL+GGtTWlq2Q335/n vmmC/K/WuWIt+5U3uTYtdDwhkHmxLnIMqz69+QvQwBjurNrbHLthSOFE5 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10734"; a="346859561" X-IronPort-AV: E=Sophos;i="6.00,226,1681196400"; d="scan'208";a="346859561" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 01:08:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10734"; a="822509233" X-IronPort-AV: E=Sophos;i="6.00,226,1681196400"; d="scan'208";a="822509233" Received: from npg-dpdk-virtio-xiachenbo-nw.sh.intel.com ([10.67.119.79]) by fmsmga002.fm.intel.com with ESMTP; 08 Jun 2023 01:08:27 -0700 From: Chenbo Xia To: dev@dpdk.org Cc: david.marchand@redhat.com, thomas@monjalon.net, alialnu@nvidia.com, probb@iol.unh.edu, miao.li@intel.com, stable@dpdk.org, Yahui Cao , Sunil Kumar Kori Subject: [PATCH] bus/pci: fix missing MMIO APIs in Windows Date: Thu, 8 Jun 2023 15:43:05 +0800 Message-Id: <20230608074305.38061-1-chenbo.xia@intel.com> X-Mailer: git-send-email 2.17.1 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 MMIO read and write APIs were defined in PCI bus. But the corresponding implementations are not done in windows. This patch fixes this. Bugzilla ID: 1245 Fixes: 095cf6e68b28 ("bus/pci: introduce MMIO read/write") Cc: stable@dpdk.org Signed-off-by: Chenbo Xia --- drivers/bus/pci/windows/pci.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c index df5221d913..45a12bcb52 100644 --- a/drivers/bus/pci/windows/pci.c +++ b/drivers/bus/pci/windows/pci.c @@ -88,6 +88,30 @@ rte_pci_write_config(const struct rte_pci_device *dev __rte_unused, return 0; } +/* Read PCI MMIO space. */ +int +rte_pci_mmio_read(const struct rte_pci_device *dev, int bar, + void *buf, size_t len, off_t offset) +{ + if (bar >= PCI_MAX_RESOURCE || dev->mem_resource[bar].addr == NULL || + (uint64_t)offset + len > dev->mem_resource[bar].len) + return -1; + memcpy(buf, (uint8_t *)dev->mem_resource[bar].addr + offset, len); + return len; +} + +/* Write PCI MMIO space. */ +int +rte_pci_mmio_write(const struct rte_pci_device *dev, int bar, + const void *buf, size_t len, off_t offset) +{ + if (bar >= PCI_MAX_RESOURCE || dev->mem_resource[bar].addr == NULL || + (uint64_t)offset + len > dev->mem_resource[bar].len) + return -1; + memcpy((uint8_t *)dev->mem_resource[bar].addr + offset, buf, len); + return len; +} + enum rte_iova_mode pci_device_iova_mode(const struct rte_pci_driver *pdrv __rte_unused, const struct rte_pci_device *pdev __rte_unused) -- 2.17.1