Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/127739/?format=api
http://patches.dpdk.org/api/patches/127739/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230531053743.129442-2-miao.li@intel.com/", "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": "<20230531053743.129442-2-miao.li@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20230531053743.129442-2-miao.li@intel.com", "date": "2023-05-31T05:37:39", "name": "[v4,1/4] bus/pci: introduce an internal representation of PCI device", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "d16fa131f591da021ad573e20726bb8ec8e86424", "submitter": { "id": 2220, "url": "http://patches.dpdk.org/api/people/2220/?format=api", "name": "Li, Miao", "email": "miao.li@intel.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230531053743.129442-2-miao.li@intel.com/mbox/", "series": [ { "id": 28263, "url": "http://patches.dpdk.org/api/series/28263/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=28263", "date": "2023-05-31T05:37:38", "name": "Support VFIO sparse mmap in PCI bus", "version": 4, "mbox": "http://patches.dpdk.org/series/28263/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/127739/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/127739/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "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])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 6A3BA42BEB;\n\tWed, 31 May 2023 07:38:02 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 00DC942B8B;\n\tWed, 31 May 2023 07:38:00 +0200 (CEST)", "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n by mails.dpdk.org (Postfix) with ESMTP id 48B33427E9\n for <dev@dpdk.org>; Wed, 31 May 2023 07:37:57 +0200 (CEST)", "from orsmga006.jf.intel.com ([10.7.209.51])\n by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 30 May 2023 22:37:56 -0700", "from dpdk-limiao-icelake.sh.intel.com ([10.67.111.26])\n by orsmga006.jf.intel.com with ESMTP; 30 May 2023 22:37:54 -0700" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1685511477; x=1717047477;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=b+hf+ebLi3z9+3jbj2JZqCysOXVE1xIzJ23YHdSCfN4=;\n b=ILVZirklyWFp5+ICDmf8ItT7cWu7nvMdFG3oP0/se/ZquDckUxKmZR90\n OUB/y4hgXKYtD6w0LV9FF7jRWuZqCO9orOzIqw/TG0ZtV5G3A5x+ppu/h\n wSpDKna9zIlSHCTFtOSfH76H607jl+Yj8MQdqugfSC4cs+VQ8yGgn4eha\n w41pMTTMauQjAansLftkHhh2sREnal7dhe0Jz9oX2tEm6ZdYrFIxfYniJ\n URGLQaDe2aZmFTkkiZlSfgporgz9Q/KA3TUvNoHhQC678q8yFZJdlmeaJ\n mY5SP1kgMirY8nhDSejZ+Hnpgf6dP9lJDumPl5SYkVJVtol3JzAR8heH0 A==;", "X-IronPort-AV": [ "E=McAfee;i=\"6600,9927,10726\"; a=\"335489273\"", "E=Sophos;i=\"6.00,205,1681196400\"; d=\"scan'208\";a=\"335489273\"", "E=McAfee;i=\"6600,9927,10726\"; a=\"684273518\"", "E=Sophos;i=\"6.00,205,1681196400\"; d=\"scan'208\";a=\"684273518\"" ], "X-ExtLoop1": "1", "From": "Miao Li <miao.li@intel.com>", "To": "dev@dpdk.org", "Cc": "skori@marvell.com, thomas@monjalon.net, david.marchand@redhat.com,\n ferruh.yigit@amd.com, chenbo.xia@intel.com, yahui.cao@intel.com", "Subject": "[PATCH v4 1/4] bus/pci: introduce an internal representation of PCI\n device", "Date": "Wed, 31 May 2023 05:37:39 +0000", "Message-Id": "<20230531053743.129442-2-miao.li@intel.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20230531053743.129442-1-miao.li@intel.com>", "References": "<20230525163116.682000-1-miao.li@intel.com>\n <20230531053743.129442-1-miao.li@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "From: Chenbo Xia <chenbo.xia@intel.com>\n\nThis patch introduces an internal representation of the PCI device\nwhich will be used to store the internal information that don't have\nto be exposed to drivers, e.g., the VFIO region sizes/offsets.\n\nIn this patch, the internal structure is simply a wrapper of the\nrte_pci_device structure. More fields will be added.\n\nSigned-off-by: Chenbo Xia <chenbo.xia@intel.com>\nAcked-by: Sunil Kumar Kori <skori@marvell.com>\nAcked-by: Yahui Cao <yahui.cao@intel.com>\n---\n drivers/bus/pci/bsd/pci.c | 13 ++++++++-----\n drivers/bus/pci/linux/pci.c | 28 ++++++++++++++++------------\n drivers/bus/pci/pci_common.c | 12 ++++++------\n drivers/bus/pci/private.h | 14 +++++++++++++-\n drivers/bus/pci/windows/pci.c | 14 +++++++++-----\n 5 files changed, 52 insertions(+), 29 deletions(-)", "diff": "diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c\nindex 7459d15c7e..a747eca58c 100644\n--- a/drivers/bus/pci/bsd/pci.c\n+++ b/drivers/bus/pci/bsd/pci.c\n@@ -208,16 +208,19 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,\n static int\n pci_scan_one(int dev_pci_fd, struct pci_conf *conf)\n {\n+\tstruct rte_pci_device_internal *pdev;\n \tstruct rte_pci_device *dev;\n \tstruct pci_bar_io bar;\n \tunsigned i, max;\n \n-\tdev = malloc(sizeof(*dev));\n-\tif (dev == NULL) {\n+\tpdev = malloc(sizeof(*pdev));\n+\tif (pdev == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot allocate memory for internal pci device\\n\");\n \t\treturn -1;\n \t}\n \n-\tmemset(dev, 0, sizeof(*dev));\n+\tmemset(pdev, 0, sizeof(*pdev));\n+\tdev = &pdev->device;\n \tdev->device.bus = &rte_pci_bus.bus;\n \n \tdev->addr.domain = conf->pc_sel.pc_domain;\n@@ -303,7 +306,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)\n \t\t\t\tmemmove(dev2->mem_resource,\n \t\t\t\t\tdev->mem_resource,\n \t\t\t\t\tsizeof(dev->mem_resource));\n-\t\t\t\tpci_free(dev);\n+\t\t\t\tpci_free(pdev);\n \t\t\t}\n \t\t\treturn 0;\n \t\t}\n@@ -313,7 +316,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)\n \treturn 0;\n \n skipdev:\n-\tpci_free(dev);\n+\tpci_free(pdev);\n \treturn 0;\n }\n \ndiff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c\nindex ebd1395502..4c2c5ba382 100644\n--- a/drivers/bus/pci/linux/pci.c\n+++ b/drivers/bus/pci/linux/pci.c\n@@ -211,22 +211,26 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n {\n \tchar filename[PATH_MAX];\n \tunsigned long tmp;\n+\tstruct rte_pci_device_internal *pdev;\n \tstruct rte_pci_device *dev;\n \tchar driver[PATH_MAX];\n \tint ret;\n \n-\tdev = malloc(sizeof(*dev));\n-\tif (dev == NULL)\n+\tpdev = malloc(sizeof(*pdev));\n+\tif (pdev == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot allocate memory for internal pci device\\n\");\n \t\treturn -1;\n+\t}\n \n-\tmemset(dev, 0, sizeof(*dev));\n+\tmemset(pdev, 0, sizeof(*pdev));\n+\tdev = &pdev->device;\n \tdev->device.bus = &rte_pci_bus.bus;\n \tdev->addr = *addr;\n \n \t/* get vendor id */\n \tsnprintf(filename, sizeof(filename), \"%s/vendor\", dirname);\n \tif (eal_parse_sysfs_value(filename, &tmp) < 0) {\n-\t\tpci_free(dev);\n+\t\tpci_free(pdev);\n \t\treturn -1;\n \t}\n \tdev->id.vendor_id = (uint16_t)tmp;\n@@ -234,7 +238,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \t/* get device id */\n \tsnprintf(filename, sizeof(filename), \"%s/device\", dirname);\n \tif (eal_parse_sysfs_value(filename, &tmp) < 0) {\n-\t\tpci_free(dev);\n+\t\tpci_free(pdev);\n \t\treturn -1;\n \t}\n \tdev->id.device_id = (uint16_t)tmp;\n@@ -243,7 +247,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \tsnprintf(filename, sizeof(filename), \"%s/subsystem_vendor\",\n \t\t dirname);\n \tif (eal_parse_sysfs_value(filename, &tmp) < 0) {\n-\t\tpci_free(dev);\n+\t\tpci_free(pdev);\n \t\treturn -1;\n \t}\n \tdev->id.subsystem_vendor_id = (uint16_t)tmp;\n@@ -252,7 +256,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \tsnprintf(filename, sizeof(filename), \"%s/subsystem_device\",\n \t\t dirname);\n \tif (eal_parse_sysfs_value(filename, &tmp) < 0) {\n-\t\tpci_free(dev);\n+\t\tpci_free(pdev);\n \t\treturn -1;\n \t}\n \tdev->id.subsystem_device_id = (uint16_t)tmp;\n@@ -261,7 +265,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \tsnprintf(filename, sizeof(filename), \"%s/class\",\n \t\t dirname);\n \tif (eal_parse_sysfs_value(filename, &tmp) < 0) {\n-\t\tpci_free(dev);\n+\t\tpci_free(pdev);\n \t\treturn -1;\n \t}\n \t/* the least 24 bits are valid: class, subclass, program interface */\n@@ -297,7 +301,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \tsnprintf(filename, sizeof(filename), \"%s/resource\", dirname);\n \tif (pci_parse_sysfs_resource(filename, dev) < 0) {\n \t\tRTE_LOG(ERR, EAL, \"%s(): cannot parse resource\\n\", __func__);\n-\t\tpci_free(dev);\n+\t\tpci_free(pdev);\n \t\treturn -1;\n \t}\n \n@@ -306,7 +310,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \tret = pci_get_kernel_driver_by_path(filename, driver, sizeof(driver));\n \tif (ret < 0) {\n \t\tRTE_LOG(ERR, EAL, \"Fail to get kernel driver\\n\");\n-\t\tpci_free(dev);\n+\t\tpci_free(pdev);\n \t\treturn -1;\n \t}\n \n@@ -320,7 +324,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \t\telse\n \t\t\tdev->kdrv = RTE_PCI_KDRV_UNKNOWN;\n \t} else {\n-\t\tpci_free(dev);\n+\t\tpci_free(pdev);\n \t\treturn 0;\n \t}\n \t/* device is valid, add in list (sorted) */\n@@ -375,7 +379,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \t\t\t\t\t\tpci_common_set(dev2);\n \t\t\t\t\t}\n \t\t\t\t}\n-\t\t\t\tpci_free(dev);\n+\t\t\t\tpci_free(pdev);\n \t\t\t}\n \t\t\treturn 0;\n \t\t}\ndiff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c\nindex e32a9d517a..52404ab0fe 100644\n--- a/drivers/bus/pci/pci_common.c\n+++ b/drivers/bus/pci/pci_common.c\n@@ -121,12 +121,12 @@ pci_common_set(struct rte_pci_device *dev)\n }\n \n void\n-pci_free(struct rte_pci_device *dev)\n+pci_free(struct rte_pci_device_internal *pdev)\n {\n-\tif (dev == NULL)\n+\tif (pdev == NULL)\n \t\treturn;\n-\tfree(dev->bus_info);\n-\tfree(dev);\n+\tfree(pdev->device.bus_info);\n+\tfree(pdev);\n }\n \n /* map a particular resource from a file */\n@@ -465,7 +465,7 @@ pci_cleanup(void)\n \t\trte_intr_instance_free(dev->vfio_req_intr_handle);\n \t\tdev->vfio_req_intr_handle = NULL;\n \n-\t\tpci_free(dev);\n+\t\tpci_free(RTE_PCI_DEVICE_INTERNAL(dev));\n \t}\n \n \treturn error;\n@@ -681,7 +681,7 @@ pci_unplug(struct rte_device *dev)\n \tif (ret == 0) {\n \t\trte_pci_remove_device(pdev);\n \t\trte_devargs_remove(dev->devargs);\n-\t\tpci_free(pdev);\n+\t\tpci_free(RTE_PCI_DEVICE_INTERNAL(pdev));\n \t}\n \treturn ret;\n }\ndiff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h\nindex c8161a1074..b564646e03 100644\n--- a/drivers/bus/pci/private.h\n+++ b/drivers/bus/pci/private.h\n@@ -13,6 +13,14 @@\n #include <rte_os_shim.h>\n #include <rte_pci.h>\n \n+/*\n+ * Convert struct rte_pci_device to struct rte_pci_device_internal\n+ */\n+#define RTE_PCI_DEVICE_INTERNAL(ptr) \\\n+\tcontainer_of(ptr, struct rte_pci_device_internal, device)\n+#define RTE_PCI_DEVICE_INTERNAL_CONST(ptr) \\\n+\tcontainer_of(ptr, const struct rte_pci_device_internal, device)\n+\n /**\n * Structure describing the PCI bus\n */\n@@ -34,6 +42,10 @@ extern struct rte_pci_bus rte_pci_bus;\n struct rte_pci_driver;\n struct rte_pci_device;\n \n+struct rte_pci_device_internal {\n+\tstruct rte_pci_device device;\n+};\n+\n /**\n * Scan the content of the PCI bus, and the devices in the devices\n * list\n@@ -53,7 +65,7 @@ pci_common_set(struct rte_pci_device *dev);\n * Free a PCI device.\n */\n void\n-pci_free(struct rte_pci_device *dev);\n+pci_free(struct rte_pci_device_internal *pdev);\n \n /**\n * Validate whether a device with given PCI address should be ignored or not.\ndiff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c\nindex 5cf05ce1a0..df5221d913 100644\n--- a/drivers/bus/pci/windows/pci.c\n+++ b/drivers/bus/pci/windows/pci.c\n@@ -336,6 +336,7 @@ set_kernel_driver_type(PSP_DEVINFO_DATA device_info_data,\n static int\n pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)\n {\n+\tstruct rte_pci_device_internal *pdev = NULL;\n \tstruct rte_pci_device *dev = NULL;\n \tint ret = -1;\n \tchar pci_device_info[REGSTR_VAL_MAX_HCID_LEN];\n@@ -370,11 +371,14 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)\n \t\tgoto end;\n \t}\n \n-\tdev = malloc(sizeof(*dev));\n-\tif (dev == NULL)\n+\tpdev = malloc(sizeof(*pdev));\n+\tif (pdev == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot allocate memory for internal pci device\\n\");\n \t\tgoto end;\n+\t}\n \n-\tmemset(dev, 0, sizeof(*dev));\n+\tmemset(pdev, 0, sizeof(*pdev));\n+\tdev = &pdev->device;\n \n \tdev->device.bus = &rte_pci_bus.bus;\n \tdev->addr = addr;\n@@ -409,7 +413,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)\n \t\t\t\tdev2->max_vfs = dev->max_vfs;\n \t\t\t\tmemmove(dev2->mem_resource, dev->mem_resource,\n \t\t\t\t\tsizeof(dev->mem_resource));\n-\t\t\t\tpci_free(dev);\n+\t\t\t\tpci_free(pdev);\n \t\t\t}\n \t\t\treturn 0;\n \t\t}\n@@ -418,7 +422,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)\n \n \treturn 0;\n end:\n-\tpci_free(dev);\n+\tpci_free(pdev);\n \treturn ret;\n }\n \n", "prefixes": [ "v4", "1/4" ] }{ "id": 127739, "url": "