get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 6186,
    "url": "https://patches.dpdk.org/api/patches/6186/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1436351693-2349-7-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": "<1436351693-2349-7-git-send-email-mukawa@igel.co.jp>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1436351693-2349-7-git-send-email-mukawa@igel.co.jp",
    "date": "2015-07-08T10:34:47",
    "name": "[dpdk-dev,v9,06/12] eal: Add pci_uio_alloc/free_resource()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "637088399aad4d56d1bd7759f206b4719f586777",
    "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/1436351693-2349-7-git-send-email-mukawa@igel.co.jp/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/6186/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/6186/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 3557BC2FC;\n\tWed,  8 Jul 2015 12:35:51 +0200 (CEST)",
            "from mail-pa0-f52.google.com (mail-pa0-f52.google.com\n\t[209.85.220.52]) by dpdk.org (Postfix) with ESMTP id 48066C2FC\n\tfor <dev@dpdk.org>; Wed,  8 Jul 2015 12:35:49 +0200 (CEST)",
            "by pabvl15 with SMTP id vl15so129600316pab.1\n\tfor <dev@dpdk.org>; Wed, 08 Jul 2015 03:35:48 -0700 (PDT)",
            "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby smtp.gmail.com with ESMTPSA id\n\txf2sm2043139pab.25.2015.07.08.03.35.46\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tWed, 08 Jul 2015 03:35:47 -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=IHxs3NoiyTaITNC9cyMImLi/GTHjOwCHL34ce3SJ8A4=;\n\tb=fH0n3PsbjFzXNM8Q8aFW4l9jT7Q6xbOb35TuSXw2jZR+6EyFWHhAl255v6r94JxGhk\n\tJ1zSaooyiK/fGbQnBwUnk7B0uL04SQVV+VJby7fjuZxjtPsztO0Q3+gGydW6BWerFzNw\n\tIqujkHZRYd5SSMJ5KslN/Y5xwvw0T5JO+DCRp2NWtBGU8DcyZLsZiUb8DPrblwoI7QkJ\n\t555A4rHqdyPVMLkcN9dT8CI1TpXAeR0ZTez1Dfl9O58m+aYdTUcRJU5NySiZDXezqTNb\n\tqt9zmn3NVXbN80a1Qx4J7ZRXibdMMI41cJAVLfvy0heqaW9zjjJ+BChygfkkEU8I2B18\n\tjkUA==",
        "X-Gm-Message-State": "ALoCoQlKMu86NAvmPAwLu6Byh4hWi3lMXqg286bOehrH8i/cyXzTLiIu3EFS6RqaOd563lbEp1tu",
        "X-Received": "by 10.68.197.102 with SMTP id it6mr19290850pbc.65.1436351748642; \n\tWed, 08 Jul 2015 03:35:48 -0700 (PDT)",
        "From": "Tetsuya Mukawa <mukawa@igel.co.jp>",
        "To": "dev@dpdk.org",
        "Date": "Wed,  8 Jul 2015 19:34:47 +0900",
        "Message-Id": "<1436351693-2349-7-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": "<1436351693-2349-1-git-send-email-mukawa@igel.co.jp>",
        "References": "<1435652668-3380-12-git-send-email-mukawa@igel.co.jp>\n\t<1436351693-2349-1-git-send-email-mukawa@igel.co.jp>",
        "Subject": "[dpdk-dev] [PATCH v9 06/12] eal: Add pci_uio_alloc/free_resource()",
        "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: \"Tetsuya.Mukawa\" <mukawa@igel.co.jp>\n\nThis patch adds new functions called pci_uio_alloc_resource() and\npci_uio_free_resource().\nThe functions hides how to prepare or free uio resource in linuxapp\nand bsdapp. With the function, pci_uio_map_resource() will be more\nabstracted.\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n lib/librte_eal/bsdapp/eal/eal_pci.c       | 83 ++++++++++++++++++---------\n lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 93 ++++++++++++++++++++-----------\n 2 files changed, 117 insertions(+), 59 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c\nindex fba67df..b4a2631 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_pci.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c\n@@ -188,28 +188,27 @@ pci_uio_map_secondary(struct rte_pci_device *dev)\n \treturn 1;\n }\n \n-/* map the PCI resource of a PCI device in virtual memory */\n+static void\n+pci_uio_free_resource(struct rte_pci_device *dev,\n+\t\tstruct mapped_pci_resource *uio_res)\n+{\n+\trte_free(uio_res);\n+\n+\tif (dev->intr_handle.fd) {\n+\t\tclose(dev->intr_handle.fd);\n+\t\tdev->intr_handle.fd = -1;\n+\t\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n+\t}\n+}\n+\n static int\n-pci_uio_map_resource(struct rte_pci_device *dev)\n+pci_uio_alloc_resource(struct rte_pci_device *dev,\n+\t\tstruct mapped_pci_resource **uio_res)\n {\n-\tint i, map_idx = 0;\n \tchar devname[PATH_MAX]; /* contains the /dev/uioX */\n-\tvoid *mapaddr;\n-\tuint64_t phaddr;\n-\tuint64_t offset;\n-\tuint64_t pagesz;\n-\tstruct rte_pci_addr *loc = &dev->addr;\n-\tstruct mapped_pci_resource *uio_res = NULL;\n-\tstruct mapped_pci_res_list *uio_res_list =\n-\t\t\tRTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);\n-\tstruct pci_map *maps;\n+\tstruct rte_pci_addr *loc;\n \n-\tdev->intr_handle.fd = -1;\n-\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n-\n-\t/* secondary processes - use already recorded details */\n-\tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n-\t\treturn pci_uio_map_secondary(dev);\n+\tloc = &dev->addr;\n \n \tsnprintf(devname, sizeof(devname), \"/dev/uio@pci:%u:%u:%u\",\n \t\t\tdev->addr.bus, dev->addr.devid, dev->addr.function);\n@@ -230,18 +229,53 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \tdev->intr_handle.type = RTE_INTR_HANDLE_UIO;\n \n \t/* allocate the mapping details for secondary processes*/\n-\tif ((uio_res = rte_zmalloc(\"UIO_RES\", sizeof (*uio_res), 0)) == NULL) {\n+\t*uio_res = rte_zmalloc(\"UIO_RES\", sizeof(**uio_res), 0);\n+\tif (*uio_res == NULL) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"%s(): cannot store uio mmap details\\n\", __func__);\n \t\tgoto error;\n \t}\n \n-\tsnprintf(uio_res->path, sizeof(uio_res->path), \"%s\", devname);\n-\tmemcpy(&uio_res->pci_addr, &dev->addr, sizeof(uio_res->pci_addr));\n+\tsnprintf((*uio_res)->path, sizeof((*uio_res)->path), \"%s\", devname);\n+\tmemcpy(&(*uio_res)->pci_addr, &dev->addr, sizeof((*uio_res)->pci_addr));\n \n+\treturn 0;\n+\n+error:\n+\tpci_uio_free_resource(dev, *uio_res);\n+\treturn -1;\n+}\n+\n+/* map the PCI resource of a PCI device in virtual memory */\n+static int\n+pci_uio_map_resource(struct rte_pci_device *dev)\n+{\n+\tint i, map_idx = 0, ret;\n+\tchar *devname;\n+\tvoid *mapaddr;\n+\tuint64_t phaddr;\n+\tuint64_t offset;\n+\tuint64_t pagesz;\n+\tstruct mapped_pci_resource *uio_res = NULL;\n+\tstruct mapped_pci_res_list *uio_res_list =\n+\t\tRTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);\n+\tstruct pci_map *maps;\n+\n+\tdev->intr_handle.fd = -1;\n+\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n+\n+\t/* secondary processes - use already recorded details */\n+\tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n+\t\treturn pci_uio_map_secondary(dev);\n+\n+\t/* allocate uio resource */\n+\tret = pci_uio_alloc_resource(dev, &uio_res);\n+\tif (ret)\n+\t\treturn ret;\n \n \t/* Map all BARs */\n \tpagesz = sysconf(_SC_PAGESIZE);\n+\tdevname = uio_res->path;\n \n \tmaps = uio_res->maps;\n \tfor (i = 0; i != PCI_MAX_RESOURCE; i++) {\n@@ -297,12 +331,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n error:\n \tfor (i = 0; i < map_idx; i++)\n \t\trte_free(maps[i].path);\n-\trte_free(uio_res);\n-\tif (dev->intr_handle.fd >= 0) {\n-\t\tclose(dev->intr_handle.fd);\n-\t\tdev->intr_handle.fd = -1;\n-\t\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n-\t}\n+\tpci_uio_free_resource(dev, uio_res);\n \treturn -1;\n }\n \ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\nindex f4e5dd1..986f431 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n@@ -253,30 +253,34 @@ pci_get_uio_dev(struct rte_pci_device *dev, char *dstbuf,\n \treturn uio_num;\n }\n \n-/* map the PCI resource of a PCI device in virtual memory */\n-int\n-pci_uio_map_resource(struct rte_pci_device *dev)\n+static void\n+pci_uio_free_resource(struct rte_pci_device *dev,\n+\t\tstruct mapped_pci_resource *uio_res)\n+{\n+\trte_free(uio_res);\n+\n+\tif (dev->intr_handle.uio_cfg_fd >= 0) {\n+\t\tclose(dev->intr_handle.uio_cfg_fd);\n+\t\tdev->intr_handle.uio_cfg_fd = -1;\n+\t}\n+\tif (dev->intr_handle.fd) {\n+\t\tclose(dev->intr_handle.fd);\n+\t\tdev->intr_handle.fd = -1;\n+\t\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n+\t}\n+}\n+\n+static int\n+pci_uio_alloc_resource(struct rte_pci_device *dev,\n+\t\tstruct mapped_pci_resource **uio_res)\n {\n-\tint i, map_idx = 0;\n \tchar dirname[PATH_MAX];\n \tchar cfgname[PATH_MAX];\n \tchar devname[PATH_MAX]; /* contains the /dev/uioX */\n-\tvoid *mapaddr;\n \tint uio_num;\n-\tuint64_t phaddr;\n-\tstruct rte_pci_addr *loc = &dev->addr;\n-\tstruct mapped_pci_resource *uio_res = NULL;\n-\tstruct mapped_pci_res_list *uio_res_list =\n-\t\t\tRTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);\n-\tstruct pci_map *maps;\n+\tstruct rte_pci_addr *loc;\n \n-\tdev->intr_handle.fd = -1;\n-\tdev->intr_handle.uio_cfg_fd = -1;\n-\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n-\n-\t/* secondary processes - use already recorded details */\n-\tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n-\t\treturn pci_uio_map_secondary(dev);\n+\tloc = &dev->addr;\n \n \t/* find uio resource */\n \tuio_num = pci_get_uio_dev(dev, dirname, sizeof(dirname));\n@@ -317,15 +321,49 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \t}\n \n \t/* allocate the mapping details for secondary processes*/\n-\tuio_res = rte_zmalloc(\"UIO_RES\", sizeof(*uio_res), 0);\n-\tif (uio_res == NULL) {\n+\t*uio_res = rte_zmalloc(\"UIO_RES\", sizeof(**uio_res), 0);\n+\tif (*uio_res == NULL) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"%s(): cannot store uio mmap details\\n\", __func__);\n \t\tgoto error;\n \t}\n \n-\tsnprintf(uio_res->path, sizeof(uio_res->path), \"%s\", devname);\n-\tmemcpy(&uio_res->pci_addr, &dev->addr, sizeof(uio_res->pci_addr));\n+\tsnprintf((*uio_res)->path, sizeof((*uio_res)->path), \"%s\", devname);\n+\tmemcpy(&(*uio_res)->pci_addr, &dev->addr, sizeof((*uio_res)->pci_addr));\n+\n+\treturn 0;\n+\n+error:\n+\tpci_uio_free_resource(dev, *uio_res);\n+\treturn -1;\n+}\n+\n+/* map the PCI resource of a PCI device in virtual memory */\n+int\n+pci_uio_map_resource(struct rte_pci_device *dev)\n+{\n+\tint i, map_idx = 0, ret;\n+\tchar devname[PATH_MAX]; /* contains the /dev/uioX */\n+\tvoid *mapaddr;\n+\tuint64_t phaddr;\n+\tstruct rte_pci_addr *loc = &dev->addr;\n+\tstruct mapped_pci_resource *uio_res = NULL;\n+\tstruct mapped_pci_res_list *uio_res_list =\n+\t\tRTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);\n+\tstruct pci_map *maps;\n+\n+\tdev->intr_handle.fd = -1;\n+\tdev->intr_handle.uio_cfg_fd = -1;\n+\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n+\n+\t/* secondary processes - use already recorded details */\n+\tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n+\t\treturn pci_uio_map_secondary(dev);\n+\n+\t/* allocate uio resource */\n+\tret = pci_uio_alloc_resource(dev, &uio_res);\n+\tif (ret)\n+\t\treturn ret;\n \n \t/* Map all BARs */\n \tmaps = uio_res->maps;\n@@ -399,16 +437,7 @@ error:\n \t\t\t\t(size_t)uio_res->maps[i].size);\n \t\trte_free(maps[i].path);\n \t}\n-\trte_free(uio_res);\n-\tif (dev->intr_handle.uio_cfg_fd >= 0) {\n-\t\tclose(dev->intr_handle.uio_cfg_fd);\n-\t\tdev->intr_handle.uio_cfg_fd = -1;\n-\t}\n-\tif (dev->intr_handle.fd >= 0) {\n-\t\tclose(dev->intr_handle.fd);\n-\t\tdev->intr_handle.fd = -1;\n-\t\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n-\t}\n+\tpci_uio_free_resource(dev, uio_res);\n \treturn -1;\n }\n \n",
    "prefixes": [
        "dpdk-dev",
        "v9",
        "06/12"
    ]
}