get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 3688,
    "url": "https://patches.dpdk.org/api/patches/3688/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1424837093-5661-6-git-send-email-mukawa@igel.co.jp/",
    "project": {
        "id": 1,
        "url": "https://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": "<1424837093-5661-6-git-send-email-mukawa@igel.co.jp>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1424837093-5661-6-git-send-email-mukawa@igel.co.jp",
    "date": "2015-02-25T04:04:43",
    "name": "[dpdk-dev,v14,05/13] eal/pci: Consolidate pci address comparison APIs",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "50a71b5d4276e219f99e915682b00a0be83e026a",
    "submitter": {
        "id": 64,
        "url": "https://patches.dpdk.org/api/people/64/?format=api",
        "name": "Tetsuya Mukawa",
        "email": "mukawa@igel.co.jp"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1424837093-5661-6-git-send-email-mukawa@igel.co.jp/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/3688/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/3688/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 B6A619AEE;\n\tWed, 25 Feb 2015 05:05:44 +0100 (CET)",
            "from mail-pd0-f174.google.com (mail-pd0-f174.google.com\n\t[209.85.192.174]) by dpdk.org (Postfix) with ESMTP id 5AF2B9AEC\n\tfor <dev@dpdk.org>; Wed, 25 Feb 2015 05:05:28 +0100 (CET)",
            "by pdbfl12 with SMTP id fl12so1892800pdb.2\n\tfor <dev@dpdk.org>; Tue, 24 Feb 2015 20:05:27 -0800 (PST)",
            "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\ty7sm3140021pdp.92.2015.02.24.20.05.25\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tTue, 24 Feb 2015 20:05:26 -0800 (PST)"
        ],
        "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=Dwr1tBuVmEu46v4ElCB85yLa3TaPQU5qqbRNRA6W9cQ=;\n\tb=JmOe1a+TdML3+FfjTsApjqRB4fLjaH1nq7MEugxLD6vcxvRhIbH9xW7WKjRvMJJSOq\n\tVN7x799bTte3dtX7XVPYo+smbEsJx/0BPgFSOiSnvY0z2NZ6bIdM+yMiRDrO8avapy7i\n\tP8DlwJo9TFXtBupXs/9WzjCCAT5JJyc0SnOEuXfMDNGJJjbd13qWsJvcgswnnRRCbeap\n\twUaA0mIyFUvviS3L6qrzBGdc7mQDjFzGR6RFbRxfvueyApzX8WsX2UIJVJQhNf7Ft4HD\n\tG/1nUIdILtyPfdlleaLw4+GC67LpboXxB5W0MmLuQeBPH2QPuyTTi5sfYYqdUWVTMrqW\n\tNZ+w==",
        "X-Gm-Message-State": "ALoCoQnv6dq/KYcTZ9NpPc7Vm/YSyrs1Er2gpUv6pmam5Wan3tlpCjp9M7LjWF3J6FTHHfFcGzrG",
        "X-Received": "by 10.70.37.202 with SMTP id a10mr2083030pdk.108.1424837127780; \n\tTue, 24 Feb 2015 20:05:27 -0800 (PST)",
        "From": "Tetsuya Mukawa <mukawa@igel.co.jp>",
        "To": "dev@dpdk.org",
        "Date": "Wed, 25 Feb 2015 13:04:43 +0900",
        "Message-Id": "<1424837093-5661-6-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1424837093-5661-1-git-send-email-mukawa@igel.co.jp>",
        "References": "<1424060073-23484-2-git-send-email-mukawa@igel.co.jp>\n\t<1424837093-5661-1-git-send-email-mukawa@igel.co.jp>",
        "Subject": "[dpdk-dev] [PATCH v14 05/13] eal/pci: Consolidate pci address\n\tcomparison APIs",
        "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": "This patch replaces pci_addr_comparison() and memcmp() of pci addresses by\nrte_eal_compare_pci_addr().\n\nTo compare PCI addresses, rte_eal_compare_pci_addr() doesn't use memcmp().\nThis is because sizeof(struct rte_pci_addr) returns 6, but actually\nthis structure is like below.\n\nstruct rte_pci_addr {\n        uint16_t domain;                /**< Device domain */\n        uint8_t bus;                    /**< Device bus */\n        uint8_t devid;                  /**< Device ID */\n        uint8_t function;               /**< Device function. */\n};\n\nIf the structure is dynamically allocated in a function without bzero,\nlast 1 byte may have value. As a result, memcmp may not work.\nTo avoid such a case, rte_eal_compare_pci_addr() compare following values.\n\n        dev_addr = (addr->domain << 24) | (addr->bus << 16) |\n                                (addr->devid << 8) | addr->function;\n\nv9:\n- eal_compare_pci_addr() is replaced by rte_eal_compare_pci_addr().\n- Fix commit log.\n  (Thanks to Thomas Monjalon)\nv8:\n- Fix pci_scan_one() to update sysfs values.\n  (Thanks to Qiu, Michael and Iremonger, Bernard)\nv5:\n- Fix pci_scan_one to handle pt_driver correctly.\nv4:\n- Fix calculation method of eal_compare_pci_addr().\n- Add parameter checking.\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n lib/librte_eal/bsdapp/eal/eal_pci.c       | 29 ++++++++++++--------------\n lib/librte_eal/common/eal_common_pci.c    |  2 +-\n lib/librte_eal/common/include/rte_pci.h   | 34 +++++++++++++++++++++++++++++++\n lib/librte_eal/linuxapp/eal/eal_pci.c     | 30 +++++++++++++--------------\n lib/librte_eal/linuxapp/eal/eal_pci_uio.c |  2 +-\n 5 files changed, 63 insertions(+), 34 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c\nindex 74ecce7..9193f80 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_pci.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c\n@@ -270,20 +270,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \treturn (0);\n }\n \n-/* Compare two PCI device addresses. */\n-static int\n-pci_addr_comparison(struct rte_pci_addr *addr, struct rte_pci_addr *addr2)\n-{\n-\tuint64_t dev_addr = (addr->domain << 24) + (addr->bus << 16) + (addr->devid << 8) + addr->function;\n-\tuint64_t dev_addr2 = (addr2->domain << 24) + (addr2->bus << 16) + (addr2->devid << 8) + addr2->function;\n-\n-\tif (dev_addr > dev_addr2)\n-\t\treturn 1;\n-\telse\n-\t\treturn 0;\n-}\n-\n-\n /* Scan one pci sysfs entry, and fill the devices list from it. */\n static int\n pci_scan_one(int dev_pci_fd, struct pci_conf *conf)\n@@ -356,13 +342,24 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)\n \t}\n \telse {\n \t\tstruct rte_pci_device *dev2 = NULL;\n+\t\tint ret;\n \n \t\tTAILQ_FOREACH(dev2, &pci_device_list, next) {\n-\t\t\tif (pci_addr_comparison(&dev->addr, &dev2->addr))\n+\t\t\tret = rte_eal_compare_pci_addr(&dev->addr, &dev2->addr);\n+\t\t\tif (ret > 0)\n \t\t\t\tcontinue;\n-\t\t\telse {\n+\t\t\telse if (ret < 0) {\n \t\t\t\tTAILQ_INSERT_BEFORE(dev2, dev, next);\n \t\t\t\treturn 0;\n+\t\t\t} else { /* already registered */\n+\t\t\t\t/* update pt_driver */\n+\t\t\t\tdev2->pt_driver = dev->pt_driver;\n+\t\t\t\tdev2->max_vfs = dev->max_vfs;\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\treturn 0;\n \t\t\t}\n \t\t}\n \t\tTAILQ_INSERT_TAIL(&pci_device_list, dev, next);\ndiff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c\nindex f3c7f71..bf2793f 100644\n--- a/lib/librte_eal/common/eal_common_pci.c\n+++ b/lib/librte_eal/common/eal_common_pci.c\n@@ -93,7 +93,7 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)\n \t\tif (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI &&\n \t\t\tdevargs->type != RTE_DEVTYPE_WHITELISTED_PCI)\n \t\t\tcontinue;\n-\t\tif (!memcmp(&dev->addr, &devargs->pci.addr, sizeof(dev->addr)))\n+\t\tif (!rte_eal_compare_pci_addr(&dev->addr, &devargs->pci.addr))\n \t\t\treturn devargs;\n \t}\n \treturn NULL;\ndiff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h\nindex 255a77b..dcf9c81 100644\n--- a/lib/librte_eal/common/include/rte_pci.h\n+++ b/lib/librte_eal/common/include/rte_pci.h\n@@ -272,6 +272,40 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)\n }\n #undef GET_PCIADDR_FIELD\n \n+/* Compare two PCI device addresses. */\n+/**\n+ * Utility function to compare two PCI device addresses.\n+ *\n+ * @param addr\n+ *\tThe PCI Bus-Device-Function address to compare\n+ * @param addr2\n+ *\tThe PCI Bus-Device-Function address to compare\n+ * @return\n+ *\t0 on equal PCI address.\n+ *\tPositive on addr is greater than addr2.\n+ *\tNegative on addr is less than addr2, or error.\n+ */\n+static inline int\n+rte_eal_compare_pci_addr(struct rte_pci_addr *addr, struct rte_pci_addr *addr2)\n+{\n+\tuint64_t dev_addr, dev_addr2;\n+\n+\tif ((addr == NULL) || (addr2 == NULL))\n+\t\treturn -1;\n+\n+\tdev_addr = (addr->domain << 24) | (addr->bus << 16) |\n+\t\t\t\t(addr->devid << 8) | addr->function;\n+\tdev_addr2 = (addr2->domain << 24) | (addr2->bus << 16) |\n+\t\t\t\t(addr2->devid << 8) | addr2->function;\n+\n+\tif (dev_addr > dev_addr2)\n+\t\treturn 1;\n+\telse if (dev_addr < dev_addr2)\n+\t\treturn -1;\n+\telse\n+\t\treturn 0;\n+}\n+\n /**\n  * Probe the PCI bus for registered drivers.\n  *\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c\nindex 3291c68..06bfc1a 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c\n@@ -41,6 +41,7 @@\n #include <rte_eal_memconfig.h>\n #include <rte_malloc.h>\n #include <rte_devargs.h>\n+#include <rte_memcpy.h>\n \n #include \"rte_pci_dev_ids.h\"\n #include \"eal_filesystem.h\"\n@@ -228,20 +229,6 @@ error:\n \treturn -1;\n }\n \n-/* Compare two PCI device addresses. */\n-static int\n-pci_addr_comparison(struct rte_pci_addr *addr, struct rte_pci_addr *addr2)\n-{\n-\tuint64_t dev_addr = (addr->domain << 24) + (addr->bus << 16) + (addr->devid << 8) + addr->function;\n-\tuint64_t dev_addr2 = (addr2->domain << 24) + (addr2->bus << 16) + (addr2->devid << 8) + addr2->function;\n-\n-\tif (dev_addr > dev_addr2)\n-\t\treturn 1;\n-\telse\n-\t\treturn 0;\n-}\n-\n-\n /* Scan one pci sysfs entry, and fill the devices list from it. */\n static int\n pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,\n@@ -359,13 +346,24 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,\n \t}\n \telse {\n \t\tstruct rte_pci_device *dev2 = NULL;\n+\t\tint ret;\n \n \t\tTAILQ_FOREACH(dev2, &pci_device_list, next) {\n-\t\t\tif (pci_addr_comparison(&dev->addr, &dev2->addr))\n+\t\t\tret = rte_eal_compare_pci_addr(&dev->addr, &dev2->addr);\n+\t\t\tif (ret > 0)\n \t\t\t\tcontinue;\n-\t\t\telse {\n+\t\t\telse if (ret < 0) {\n \t\t\t\tTAILQ_INSERT_BEFORE(dev2, dev, next);\n \t\t\t\treturn 0;\n+\t\t\t} else { /* already registered */\n+\t\t\t\t/* update pt_driver */\n+\t\t\t\tdev2->pt_driver = dev->pt_driver;\n+\t\t\t\tdev2->max_vfs = dev->max_vfs;\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\treturn 0;\n \t\t\t}\n \t\t}\n \t\tTAILQ_INSERT_TAIL(&pci_device_list, dev, next);\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\nindex 0a95376..c5e0cf3 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n@@ -91,7 +91,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)\n \tTAILQ_FOREACH(uio_res, pci_res_list, next) {\n \n \t\t/* skip this element if it doesn't match our PCI address */\n-\t\tif (memcmp(&uio_res->pci_addr, &dev->addr, sizeof(dev->addr)))\n+\t\tif (rte_eal_compare_pci_addr(&uio_res->pci_addr, &dev->addr))\n \t\t\tcontinue;\n \n \t\tfor (i = 0; i != uio_res->nb_maps; i++) {\n",
    "prefixes": [
        "dpdk-dev",
        "v14",
        "05/13"
    ]
}