get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/116297/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 116297,
    "url": "http://patches.dpdk.org/api/patches/116297/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220914075841.51555-27-david.marchand@redhat.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": "<20220914075841.51555-27-david.marchand@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220914075841.51555-27-david.marchand@redhat.com",
    "date": "2022-09-14T07:58:40",
    "name": "[v6,26/27] bus/pci: fill bus specific information",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "dec85524c5a62ac06c0fcd20ba9de1ca77c25f91",
    "submitter": {
        "id": 1173,
        "url": "http://patches.dpdk.org/api/people/1173/?format=api",
        "name": "David Marchand",
        "email": "david.marchand@redhat.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20220914075841.51555-27-david.marchand@redhat.com/mbox/",
    "series": [
        {
            "id": 24657,
            "url": "http://patches.dpdk.org/api/series/24657/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=24657",
            "date": "2022-09-14T07:58:14",
            "name": "Bus and device cleanup for 22.11",
            "version": 6,
            "mbox": "http://patches.dpdk.org/series/24657/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/116297/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/116297/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 E7761A0032;\n\tWed, 14 Sep 2022 10:02:24 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 3C91142BBC;\n\tWed, 14 Sep 2022 10:01:09 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by mails.dpdk.org (Postfix) with ESMTP id 26DA742B9C\n for <dev@dpdk.org>; Wed, 14 Sep 2022 10:01:08 +0200 (CEST)",
            "from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com\n [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-164-APOCRqttOhauEbbkWWldWg-1; Wed, 14 Sep 2022 04:01:04 -0400",
            "from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com\n [10.11.54.9])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D03FF1C20AE9;\n Wed, 14 Sep 2022 08:01:03 +0000 (UTC)",
            "from localhost.localdomain (unknown [10.40.194.61])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 0FE5E49BB60;\n Wed, 14 Sep 2022 08:01:02 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1663142467;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=52MToWw5+t4HYMbFmUoCfDNsOz6HGHU+L8QrvoL5d+I=;\n b=El/4jOnDP1UBD2/j3QLTaPjnlfc4sSAhCTBhQ6xZ/oLnCXz/jFDyb3glkpZumDCWgLn+lk\n tt62Bn1yQx8M4spfYGWL8EZ12K1RSkunUZgPsYZ8s2oCXnECHd4pLxnrKQH0Rqa0cv4UKL\n ghIzUjLi+l/1vkD3bbskVZhO4UzU6HU=",
        "X-MC-Unique": "APOCRqttOhauEbbkWWldWg-1",
        "From": "David Marchand <david.marchand@redhat.com>",
        "To": "dev@dpdk.org",
        "Cc": "thomas@monjalon.net,\n\tbruce.richardson@intel.com",
        "Subject": "[PATCH v6 26/27] bus/pci: fill bus specific information",
        "Date": "Wed, 14 Sep 2022 09:58:40 +0200",
        "Message-Id": "<20220914075841.51555-27-david.marchand@redhat.com>",
        "In-Reply-To": "<20220914075841.51555-1-david.marchand@redhat.com>",
        "References": "<20220628144643.1213026-1-david.marchand@redhat.com>\n <20220914075841.51555-1-david.marchand@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.1 on 10.11.54.9",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "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": "For diagnostic, it may be useful to provide the PCI vendor and device\nid.\n\nSigned-off-by: David Marchand <david.marchand@redhat.com>\nAcked-by: Bruce Richardson <bruce.richardson@intel.com>\n---\nChanges since v5:\n- fixed Windows build issue (bis...),\n\nChanges since v4:\n- fixed Windows build issue (missing asprintf implementation),\n\n---\n drivers/bus/pci/bsd/pci.c        |  8 +++---\n drivers/bus/pci/bus_pci_driver.h |  1 +\n drivers/bus/pci/linux/pci.c      | 24 ++++++++--------\n drivers/bus/pci/pci_common.c     | 49 ++++++++++++++++++++++++++++++--\n drivers/bus/pci/private.h        | 10 +++++--\n drivers/bus/pci/windows/pci.c    |  6 ++--\n 6 files changed, 75 insertions(+), 23 deletions(-)",
    "diff": "diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c\nindex bc560a2a56..844d145fed 100644\n--- a/drivers/bus/pci/bsd/pci.c\n+++ b/drivers/bus/pci/bsd/pci.c\n@@ -248,7 +248,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)\n \t/* FreeBSD has no NUMA support (yet) */\n \tdev->device.numa_node = 0;\n \n-\tpci_name_set(dev);\n+\tpci_common_set(dev);\n \n \t/* FreeBSD has only one pass through driver */\n \tdev->kdrv = RTE_PCI_KDRV_NIC_UIO;\n@@ -299,11 +299,11 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)\n \t\t\t} else { /* already registered */\n \t\t\t\tdev2->kdrv = dev->kdrv;\n \t\t\t\tdev2->max_vfs = dev->max_vfs;\n-\t\t\t\tpci_name_set(dev2);\n+\t\t\t\tpci_common_set(dev2);\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\tfree(dev);\n+\t\t\t\tpci_free(dev);\n \t\t\t}\n \t\t\treturn 0;\n \t\t}\n@@ -313,7 +313,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)\n \treturn 0;\n \n skipdev:\n-\tfree(dev);\n+\tpci_free(dev);\n \treturn 0;\n }\n \ndiff --git a/drivers/bus/pci/bus_pci_driver.h b/drivers/bus/pci/bus_pci_driver.h\nindex 0f2f9b5101..be32263a82 100644\n--- a/drivers/bus/pci/bus_pci_driver.h\n+++ b/drivers/bus/pci/bus_pci_driver.h\n@@ -43,6 +43,7 @@ struct rte_pci_device {\n \tuint16_t max_vfs;                   /**< sriov enable if not zero */\n \tenum rte_pci_kernel_driver kdrv;    /**< Kernel driver passthrough */\n \tchar name[PCI_PRI_STR_SIZE+1];      /**< PCI location (ASCII) */\n+\tchar *bus_info;                     /**< PCI bus specific info */\n \tstruct rte_intr_handle *vfio_req_intr_handle;\n \t\t\t\t/**< Handler of VFIO request interrupt */\n };\ndiff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c\nindex fa5d5e131d..c8703d52f3 100644\n--- a/drivers/bus/pci/linux/pci.c\n+++ b/drivers/bus/pci/linux/pci.c\n@@ -226,7 +226,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \t/* get vendor id */\n \tsnprintf(filename, sizeof(filename), \"%s/vendor\", dirname);\n \tif (eal_parse_sysfs_value(filename, &tmp) < 0) {\n-\t\tfree(dev);\n+\t\tpci_free(dev);\n \t\treturn -1;\n \t}\n \tdev->id.vendor_id = (uint16_t)tmp;\n@@ -234,7 +234,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\tfree(dev);\n+\t\tpci_free(dev);\n \t\treturn -1;\n \t}\n \tdev->id.device_id = (uint16_t)tmp;\n@@ -243,7 +243,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\tfree(dev);\n+\t\tpci_free(dev);\n \t\treturn -1;\n \t}\n \tdev->id.subsystem_vendor_id = (uint16_t)tmp;\n@@ -252,7 +252,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\tfree(dev);\n+\t\tpci_free(dev);\n \t\treturn -1;\n \t}\n \tdev->id.subsystem_device_id = (uint16_t)tmp;\n@@ -261,7 +261,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\tfree(dev);\n+\t\tpci_free(dev);\n \t\treturn -1;\n \t}\n \t/* the least 24 bits are valid: class, subclass, program interface */\n@@ -295,13 +295,13 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \t\tdev->device.numa_node = 0;\n \t}\n \n-\tpci_name_set(dev);\n+\tpci_common_set(dev);\n \n \t/* parse resources */\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\tfree(dev);\n+\t\tpci_free(dev);\n \t\treturn -1;\n \t}\n \n@@ -310,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\tfree(dev);\n+\t\tpci_free(dev);\n \t\treturn -1;\n \t}\n \n@@ -324,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\tfree(dev);\n+\t\tpci_free(dev);\n \t\treturn 0;\n \t}\n \t/* device is valid, add in list (sorted) */\n@@ -346,7 +346,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \t\t\t\t\tdev2->kdrv = dev->kdrv;\n \t\t\t\t\tdev2->max_vfs = dev->max_vfs;\n \t\t\t\t\tdev2->id = dev->id;\n-\t\t\t\t\tpci_name_set(dev2);\n+\t\t\t\t\tpci_common_set(dev2);\n \t\t\t\t\tmemmove(dev2->mem_resource,\n \t\t\t\t\t\tdev->mem_resource,\n \t\t\t\t\t\tsizeof(dev->mem_resource));\n@@ -376,10 +376,10 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)\n \t\t\t\t\telse if (dev2->device.devargs !=\n \t\t\t\t\t\t dev->device.devargs) {\n \t\t\t\t\t\trte_devargs_remove(dev2->device.devargs);\n-\t\t\t\t\t\tpci_name_set(dev2);\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\tfree(dev);\n+\t\t\t\tpci_free(dev);\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 c26aacd364..5ea72bcf23 100644\n--- a/drivers/bus/pci/pci_common.c\n+++ b/drivers/bus/pci/pci_common.c\n@@ -44,6 +44,38 @@ const char *rte_pci_get_sysfs_path(void)\n \treturn path;\n }\n \n+#ifdef RTE_EXEC_ENV_WINDOWS\n+#define asprintf pci_asprintf\n+\n+static int\n+__rte_format_printf(2, 3)\n+pci_asprintf(char **buffer, const char *format, ...)\n+{\n+\tint size, ret;\n+\tva_list arg;\n+\n+\tva_start(arg, format);\n+\tsize = vsnprintf(NULL, 0, format, arg);\n+\tva_end(arg);\n+\tif (size < 0)\n+\t\treturn -1;\n+\tsize++;\n+\n+\t*buffer = malloc(size);\n+\tif (*buffer == NULL)\n+\t\treturn -1;\n+\n+\tva_start(arg, format);\n+\tret = vsnprintf(*buffer, size, format, arg);\n+\tva_end(arg);\n+\tif (ret != size - 1) {\n+\t\tfree(*buffer);\n+\t\treturn -1;\n+\t}\n+\treturn ret;\n+}\n+#endif /* RTE_EXEC_ENV_WINDOWS */\n+\n static struct rte_devargs *\n pci_devargs_lookup(const struct rte_pci_addr *pci_addr)\n {\n@@ -59,7 +91,7 @@ pci_devargs_lookup(const struct rte_pci_addr *pci_addr)\n }\n \n void\n-pci_name_set(struct rte_pci_device *dev)\n+pci_common_set(struct rte_pci_device *dev)\n {\n \tstruct rte_devargs *devargs;\n \n@@ -80,6 +112,19 @@ pci_name_set(struct rte_pci_device *dev)\n \telse\n \t\t/* Otherwise, it uses the internal, canonical form. */\n \t\tdev->device.name = dev->name;\n+\n+\tif (asprintf(&dev->bus_info, \"vendor_id=%\"PRIx16\", device_id=%\"PRIx16,\n+\t\t\tdev->id.vendor_id, dev->id.device_id) != -1)\n+\t\tdev->device.bus_info = dev->bus_info;\n+}\n+\n+void\n+pci_free(struct rte_pci_device *dev)\n+{\n+\tif (dev == NULL)\n+\t\treturn;\n+\tfree(dev->bus_info);\n+\tfree(dev);\n }\n \n /* map a particular resource from a file */\n@@ -604,7 +649,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\tfree(pdev);\n+\t\tpci_free(pdev);\n \t}\n \treturn ret;\n }\ndiff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h\nindex fddf49251d..c8161a1074 100644\n--- a/drivers/bus/pci/private.h\n+++ b/drivers/bus/pci/private.h\n@@ -44,10 +44,16 @@ struct rte_pci_device;\n int rte_pci_scan(void);\n \n /**\n- * Find the name of a PCI device.\n+ * Set common internal information for a PCI device.\n  */\n void\n-pci_name_set(struct rte_pci_device *dev);\n+pci_common_set(struct rte_pci_device *dev);\n+\n+/**\n+ * Free a PCI device.\n+ */\n+void\n+pci_free(struct rte_pci_device *dev);\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 f013b743b3..3f7a8b9432 100644\n--- a/drivers/bus/pci/windows/pci.c\n+++ b/drivers/bus/pci/windows/pci.c\n@@ -382,7 +382,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)\n \tdev->id = pci_id;\n \tdev->max_vfs = 0; /* TODO: get max_vfs */\n \n-\tpci_name_set(dev);\n+\tpci_common_set(dev);\n \n \tset_kernel_driver_type(device_info_data, dev);\n \n@@ -410,7 +410,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\tfree(dev);\n+\t\t\t\tpci_free(dev);\n \t\t\t}\n \t\t\treturn 0;\n \t\t}\n@@ -419,7 +419,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)\n \n \treturn 0;\n end:\n-\tfree(dev);\n+\tpci_free(dev);\n \treturn ret;\n }\n \n",
    "prefixes": [
        "v6",
        "26/27"
    ]
}