Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/4651/?format=api
http://patches.dpdk.org/api/patches/4651/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1431041135-6289-2-git-send-email-stephen@networkplumber.org/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1431041135-6289-2-git-send-email-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/1431041135-6289-2-git-send-email-stephen@networkplumber.org", "date": "2015-05-07T23:25:32", "name": "[dpdk-dev,1/4] pci: allow access to PCI config space", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "94e1d0792f19a243000eab68ac861a1abca98348", "submitter": { "id": 27, "url": "http://patches.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1431041135-6289-2-git-send-email-stephen@networkplumber.org/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/4651/comments/", "check": "pending", "checks": "http://patches.dpdk.org/api/patches/4651/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id DD7B35A0F;\n\tFri, 8 May 2015 01:25:36 +0200 (CEST)", "from mail-pa0-f46.google.com (mail-pa0-f46.google.com\n\t[209.85.220.46]) by dpdk.org (Postfix) with ESMTP id EC569376E\n\tfor <dev@dpdk.org>; Fri, 8 May 2015 01:25:34 +0200 (CEST)", "by pabtp1 with SMTP id tp1so52780286pab.2\n\tfor <dev@dpdk.org>; Thu, 07 May 2015 16:25:34 -0700 (PDT)", "from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net.\n\t[50.53.82.155]) by mx.google.com with ESMTPSA id\n\tki3sm3203006pdb.74.2015.05.07.16.25.33\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tThu, 07 May 2015 16:25:33 -0700 (PDT)" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=rKpBPrYZGq9ffPSsx0tW0amhcz9nIPEJZDXZLvV61eg=;\n\tb=Dxmk7OFFtf+cMCmU/RPkSmcKxOCszWDI3+AJ95rDVEtDfZHaCIevja5OYVvVF6T86o\n\tgyGVFJaM1NKmt80xfy3ueNbnws2jCXOPMBJSFLKhNoUYmBJ5KRUGhfzqI2wfoRSt15is\n\t0CQgAAIeiRCjcreOdvhCJZIuXnvdV/PP/m18FEe6YftpepMAklwfNB8+rnFcv1TotK2f\n\tJtPgCCBJJHQqqxF23ggy3hM/WSaqYMkVuhdXGezW+sdvQnNHu5I/8M6/MVDD6ezqEowe\n\tn/RJMQfSmEzy49Q7aSz5Qta6scq6RdwM7PE5D4DsCOc9I4QiikXseo9SEkGF3H3ARY98\n\tioYA==", "X-Gm-Message-State": "ALoCoQnxxggjim9dbDpaJpNoGV+o/1E8UlE/9gzJBNgb5T440ySz98t1ZQRFvneRuquEZOgutkAZ", "X-Received": "by 10.68.137.7 with SMTP id qe7mr1750924pbb.40.1431041134303;\n\tThu, 07 May 2015 16:25:34 -0700 (PDT)", "From": "Stephen Hemminger <stephen@networkplumber.org>", "To": "dev@dpdk.org", "Date": "Thu, 7 May 2015 16:25:32 -0700", "Message-Id": "<1431041135-6289-2-git-send-email-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.1.4", "In-Reply-To": "<1431041135-6289-1-git-send-email-stephen@networkplumber.org>", "References": "<1431041135-6289-1-git-send-email-stephen@networkplumber.org>", "Cc": "Stephen Hemminger <shemming@brocade.com>", "Subject": "[dpdk-dev] [PATCH 1/4] pci: allow access to PCI config space", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "From: Stephen Hemminger <shemming@brocade.com>\n\nSome drivers need ability to access PCI config (for example for power\nmanagement). This adds an abstraction to do this; only implemented\non Linux, but should be possible on BSD.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n lib/librte_eal/common/include/rte_pci.h | 28 +++++++++++++++\n lib/librte_eal/linuxapp/eal/eal_pci.c | 48 +++++++++++++++++++++++++\n lib/librte_eal/linuxapp/eal/eal_pci_init.h | 11 ++++++\n lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 14 ++++++++\n lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 16 +++++++++\n lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++\n 6 files changed, 119 insertions(+)", "diff": "diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h\nindex 223d3cd..cea982a 100644\n--- a/lib/librte_eal/common/include/rte_pci.h\n+++ b/lib/librte_eal/common/include/rte_pci.h\n@@ -393,6 +393,34 @@ void rte_eal_pci_register(struct rte_pci_driver *driver);\n */\n void rte_eal_pci_unregister(struct rte_pci_driver *driver);\n \n+/**\n+ * Read PCI config space.\n+ *\n+ * @param device\n+ * A pointer to a rte_pci_device structure describing the device\n+ * to use\n+ * @param buf\n+ * A data buffer where the bytes should be read into\n+ * @param size\n+ * The length of the data buffer.\n+ */\n+int rte_eal_pci_read_config(const struct rte_pci_device *device,\n+\t\t\t void *buf, size_t len, off_t offset);\n+\n+/**\n+ * Write PCI config space.\n+ *\n+ * @param device\n+ * A pointer to a rte_pci_device structure describing the device\n+ * to use\n+ * @param buf\n+ * A data buffer containing the bytes should be written\n+ * @param size\n+ * The length of the data buffer.\n+ */\n+int rte_eal_pci_write_config(const struct rte_pci_device *device,\n+\t\t\t const void *buf, size_t len, off_t offset);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c\nindex d2adc66..6d79a08 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c\n@@ -756,6 +756,54 @@ rte_eal_pci_close_one_driver(struct rte_pci_driver *dr __rte_unused,\n }\n #endif /* RTE_LIBRTE_EAL_HOTPLUG */\n \n+/* Read PCI config space. */\n+int rte_eal_pci_read_config(const struct rte_pci_device *device,\n+\t\t\t void *buf, size_t len, off_t offset)\n+{\n+\tconst struct rte_intr_handle *intr_handle = &device->intr_handle;\n+\n+\tswitch (intr_handle->type) {\n+\tcase RTE_INTR_HANDLE_UIO:\n+\t\treturn pci_uio_read_config(intr_handle, buf, len, offset);\n+\n+#ifdef VFIO_PRESENT\n+\tcase RTE_INTR_HANDLE_VFIO_MSIX:\n+\tcase RTE_INTR_HANDLE_VFIO_MSI:\n+\tcase RTE_INTR_HANDLE_VFIO_LEGACY:\n+\t\treturn pci_vfio_read_config(intr_handle, buf, len, offset);\n+#endif\n+\tdefault:\n+\t\tRTE_LOG(ERR, EAL,\n+\t\t\t\"Unknown handle type of fd %d\\n\",\n+\t\t\t\t\tintr_handle->fd);\n+\t\treturn -1;\n+\t}\n+}\n+\n+/* Write PCI config space. */\n+int rte_eal_pci_write_config(const struct rte_pci_device *device,\n+\t\t\t const void *buf, size_t len, off_t offset)\n+{\n+\tconst struct rte_intr_handle *intr_handle = &device->intr_handle;\n+\n+\tswitch (intr_handle->type) {\n+\tcase RTE_INTR_HANDLE_UIO:\n+\t\treturn pci_uio_write_config(intr_handle, buf, len, offset);\n+\n+#ifdef VFIO_PRESENT\n+\tcase RTE_INTR_HANDLE_VFIO_MSIX:\n+\tcase RTE_INTR_HANDLE_VFIO_MSI:\n+\tcase RTE_INTR_HANDLE_VFIO_LEGACY:\n+\t\treturn pci_vfio_write_config(intr_handle, buf, len, offset);\n+#endif\n+\tdefault:\n+\t\tRTE_LOG(ERR, EAL,\n+\t\t\t\"Unknown handle type of fd %d\\n\",\n+\t\t\t\t\tintr_handle->fd);\n+\t\treturn -1;\n+\t}\n+}\n+\n /* Init the PCI EAL subsystem */\n int\n rte_eal_pci_init(void)\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_init.h b/lib/librte_eal/linuxapp/eal/eal_pci_init.h\nindex aa7b755..c28e5b0 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_init.h\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_init.h\n@@ -68,6 +68,11 @@ void *pci_find_max_end_va(void);\n void *pci_map_resource(void *requested_addr, int fd, off_t offset,\n \t size_t size, int additional_flags);\n \n+int pci_uio_read_config(const struct rte_intr_handle *intr_handle,\n+\t\t\tvoid *buf, size_t len, off_t offs);\n+int pci_uio_write_config(const struct rte_intr_handle *intr_handle,\n+\t\t\t const void *buf, size_t len, off_t offs);\n+\n /* map IGB_UIO resource prototype */\n int pci_uio_map_resource(struct rte_pci_device *dev);\n \n@@ -86,6 +91,12 @@ int pci_vfio_enable(void);\n int pci_vfio_is_enabled(void);\n int pci_vfio_mp_sync_setup(void);\n \n+/* access config space */\n+int pci_vfio_read_config(const struct rte_intr_handle *intr_handle,\n+\t\t\t void *buf, size_t len, off_t offs);\n+int pci_vfio_write_config(const struct rte_intr_handle *intr_handle,\n+\t\t\t const void *buf, size_t len, off_t offs);\n+\n /* map VFIO resource prototype */\n int pci_vfio_map_resource(struct rte_pci_device *dev);\n int pci_vfio_get_group_fd(int iommu_group_fd);\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\nindex 2d1c69b..bbc59ed 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n@@ -58,6 +58,20 @@ EAL_REGISTER_TAILQ(rte_uio_tailq)\n \n #define OFF_MAX ((uint64_t)(off_t)-1)\n \n+int\n+pci_uio_read_config(const struct rte_intr_handle *intr_handle,\n+\t\t void *buf, size_t len, off_t offset)\n+{\n+\treturn pread(intr_handle->uio_cfg_fd, buf, len, offset);\n+}\n+\n+int\n+pci_uio_write_config(const struct rte_intr_handle *intr_handle,\n+\t\t const void *buf, size_t len, off_t offset)\n+{\n+\treturn pwrite(intr_handle->uio_cfg_fd, buf, len, offset);\n+}\n+\n static int\n pci_uio_set_bus_master(int dev_fd)\n {\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\nindex aea1fb1..092a369 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\n@@ -77,6 +77,22 @@ EAL_REGISTER_TAILQ(rte_vfio_tailq)\n /* per-process VFIO config */\n static struct vfio_config vfio_cfg;\n \n+int\n+pci_vfio_read_config(const struct rte_intr_handle *intr_handle,\n+\t\t void *buf, size_t len, off_t offs)\n+{\n+\treturn pread64(intr_handle->vfio_dev_fd, buf, len,\n+\t VFIO_GET_REGION_ADDR(VFIO_PCI_CONFIG_REGION_INDEX) + offs);\n+}\n+\n+int\n+pci_vfio_write_config(const struct rte_intr_handle *intr_handle,\n+\t\t const void *buf, size_t len, off_t offs)\n+{\n+\treturn pwrite64(intr_handle->vfio_dev_fd, buf, len,\n+\t VFIO_GET_REGION_ADDR(VFIO_PCI_CONFIG_REGION_INDEX) + offs);\n+}\n+\n /* get PCI BAR number where MSI-X interrupts are */\n static int\n pci_vfio_get_msix_bar(int fd, int *msix_bar, uint32_t *msix_table_offset,\ndiff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\nindex 7e850a9..494aae0 100644\n--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n@@ -42,9 +42,11 @@ DPDK_2.0 {\n \trte_eal_pci_dump;\n \trte_eal_pci_probe;\n \trte_eal_pci_probe_one;\n+\trte_eal_pci_read_config;\n \trte_eal_pci_register;\n \trte_eal_pci_scan;\n \trte_eal_pci_unregister;\n+\trte_eal_pci_write_config;\n \trte_eal_process_type;\n \trte_eal_remote_launch;\n \trte_eal_tailq_lookup;\n", "prefixes": [ "dpdk-dev", "1/4" ] }{ "id": 4651, "url": "