get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 5897,
    "url": "https://patches.dpdk.org/api/patches/5897/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1435546610-4533-2-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": "<1435546610-4533-2-git-send-email-mukawa@igel.co.jp>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1435546610-4533-2-git-send-email-mukawa@igel.co.jp",
    "date": "2015-06-29T02:56:43",
    "name": "[dpdk-dev,v3,1/8] eal: Add pci_uio_alloc_uio_resource()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "fe486033c56046746983f1c84726c2cce6751905",
    "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/1435546610-4533-2-git-send-email-mukawa@igel.co.jp/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/5897/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/5897/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 ABDA2C5D6;\n\tMon, 29 Jun 2015 04:57:32 +0200 (CEST)",
            "from mail-pa0-f47.google.com (mail-pa0-f47.google.com\n\t[209.85.220.47]) by dpdk.org (Postfix) with ESMTP id ABE20C5D4\n\tfor <dev@dpdk.org>; Mon, 29 Jun 2015 04:57:30 +0200 (CEST)",
            "by paceq1 with SMTP id eq1so97274262pac.3\n\tfor <dev@dpdk.org>; Sun, 28 Jun 2015 19:57:29 -0700 (PDT)",
            "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\tbi4sm40303927pbc.56.2015.06.28.19.57.27\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tSun, 28 Jun 2015 19:57:28 -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=UvWAfCIlWLc4VM6g/6rlmKaRqHX7IwOQdSmcHvPqE+E=;\n\tb=TsB8Xss0YDkMDAAv58xWTllPpEOsgTvx0pKaShX05VYoYY8l7nlqalNjwopQDtKVKU\n\tz0shoJwbma00hmBp/rZXx9lNkqmrs6COvAS6wrNdV2+hfimapax11SntBpI8uyD/8VPp\n\tsrktpBxL8pO3mgYUITPtSceVQDeqkoGxE8jf8K1TplfGTBu0m9BGAzIpAyJGSkehFGuh\n\tX9/IZyeoTfA0o2AeTKbRzonaLbPetjxzrg5c/Hq+G0DnE3ufZR36W2mWjixUs8niOTO6\n\tDQOiBQj0He3e44txRerg5LlsDQrbT0rebINChSY5ci3aSJGytg+dKJm9C902BtUUCU0I\n\tJx0Q==",
        "X-Gm-Message-State": "ALoCoQmUx+VETowLUrWzBy9Mh96yIC9riInAvfES9a2sIQWxg2IP0pOv6sqgG2AuaC/DVQSSossO",
        "X-Received": "by 10.68.104.97 with SMTP id gd1mr26836573pbb.15.1435546649825; \n\tSun, 28 Jun 2015 19:57:29 -0700 (PDT)",
        "From": "Tetsuya Mukawa <mukawa@igel.co.jp>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 29 Jun 2015 11:56:43 +0900",
        "Message-Id": "<1435546610-4533-2-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": "<1435546610-4533-1-git-send-email-mukawa@igel.co.jp>",
        "References": "<1432016513-8456-5-git-send-email-mukawa@igel.co.jp>\n\t<1435546610-4533-1-git-send-email-mukawa@igel.co.jp>",
        "Subject": "[dpdk-dev] [PATCH v3 1/8] eal: Add pci_uio_alloc_uio_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 a new function called pci_uio_alloc_uio_resource().\nThe function hides how to prepare uio resource in linuxapp and bsdapp.\nWith the function, pci_uio_map_resource() will be more abstracted.\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n lib/librte_eal/bsdapp/eal/eal_pci.c       | 70 +++++++++++++++++++---------\n lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 77 ++++++++++++++++++++++---------\n 2 files changed, 104 insertions(+), 43 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c\nindex 06c564f..2d9f3a5 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_pci.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c\n@@ -189,28 +189,17 @@ 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 int\n-pci_uio_map_resource(struct rte_pci_device *dev)\n+pci_uio_alloc_uio_resource(struct rte_pci_device *dev,\n+\t\tstruct mapped_pci_resource **uio_res)\n {\n-\tint i, map_idx;\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;\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+\tif ((dev == NULL) || (uio_res == NULL))\n+\t\treturn -1;\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@@ -231,18 +220,56 @@ 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 close_fd;\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+close_fd:\n+\tclose(dev->intr_handle.fd);\n+\tdev->intr_handle.fd = -1;\n+\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n+\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, 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_uio_resource(dev, &uio_res);\n+\tif ((ret != 0) || (uio_res == NULL))\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, map_idx = 0; i != PCI_MAX_RESOURCE; i++) {\n@@ -300,7 +327,8 @@ free_uio_res:\n \tfor (i = 0; i < map_idx; i++)\n \t\trte_free(maps[i].path);\n \trte_free(uio_res);\n-close_fd:\n+\n+\t/* close fd opened by pci_uio_alloc_uio_resource() */\n \tclose(dev->intr_handle.fd);\n \tdev->intr_handle.fd = -1;\n \tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\nindex 19620fe..9e0b617 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n@@ -254,30 +254,20 @@ 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 int\n+pci_uio_alloc_uio_resource(struct rte_pci_device *dev,\n+\t\tstruct mapped_pci_resource **uio_res)\n {\n-\tint i, map_idx;\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;\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+\tif ((dev == NULL) || (uio_res == NULL))\n+\t\treturn -1;\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@@ -318,15 +308,57 @@ 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 close_fd;\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+close_fd:\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+\n+\tclose(dev->intr_handle.fd);\n+\tdev->intr_handle.fd = -1;\n+\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n+\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, 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_uio_resource(dev, &uio_res);\n+\tif ((ret != 0) || (uio_res == NULL))\n+\t\treturn ret;\n \n \t/* Map all BARs */\n \tmaps = uio_res->maps;\n@@ -401,7 +433,8 @@ free_uio_res:\n \t\trte_free(maps[i].path);\n \t}\n \trte_free(uio_res);\n-close_fd:\n+\n+\t/* close fd opened by pci_uio_alloc_uio_resource() */\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",
    "prefixes": [
        "dpdk-dev",
        "v3",
        "1/8"
    ]
}