get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 3983,
    "url": "https://patches.dpdk.org/api/patches/3983/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1426155474-1596-8-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": "<1426155474-1596-8-git-send-email-mukawa@igel.co.jp>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1426155474-1596-8-git-send-email-mukawa@igel.co.jp",
    "date": "2015-03-12T10:17:46",
    "name": "[dpdk-dev,v2,07/15] eal: Fix interface of pci_map_resource() of bsdapp",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f2183cd40c270f0dac7ef61856ad1175453f9e22",
    "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/1426155474-1596-8-git-send-email-mukawa@igel.co.jp/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/3983/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/3983/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 3CB649AB4;\n\tThu, 12 Mar 2015 11:18:35 +0100 (CET)",
            "from mail-pd0-f175.google.com (mail-pd0-f175.google.com\n\t[209.85.192.175]) by dpdk.org (Postfix) with ESMTP id 975BA594E\n\tfor <dev@dpdk.org>; Thu, 12 Mar 2015 11:18:31 +0100 (CET)",
            "by pdjy10 with SMTP id y10so18974135pdj.8\n\tfor <dev@dpdk.org>; Thu, 12 Mar 2015 03:18:30 -0700 (PDT)",
            "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\tz4sm10080331pdi.90.2015.03.12.03.18.29\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tThu, 12 Mar 2015 03:18:30 -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=qb2NOU6FkYj9AqC9cjchDMOJ+cvAmee2CkyrKVpTpBY=;\n\tb=PR0BFCD6fdUEqa66DjYOAiZSpP1dxK9ytE+0tIddTFsSsitcdcwjcpIl7mLabtQubu\n\tLII8GeYD4LDyaCzFLeCsge6h/j+8soSYh6RCahjBop3+GgcmBlFyQ1DS7IdZ4XvTv7Xz\n\t/tKpv6PgWBL1XrSKBOXZixL3WUkqBnPd3SX/t9Pd8f0z3TgGhqvPc2dsdbCDXlXPGwS3\n\tnb1acbbrgGtoR7z1O/d1V1fDGjX2EtDbFV9onCShsnxdSHnxxo7mAaeIhFWNW1u5Kr1s\n\t3FbTaZVz0B8Mhy2tvlfnes59J2NltjfuvoMK/m43c26Sm7VkaffaOdMbNynxeA6Et8+q\n\tPZug==",
        "X-Gm-Message-State": "ALoCoQlYVhSh4RVJIzeTcPfoeHeZrXu3fjJoKGHHgraUU7jqD1Fy3ZuoHcgyrOLxOgXL3n+HXNUY",
        "X-Received": "by 10.70.90.110 with SMTP id bv14mr82190508pdb.8.1426155510869; \n\tThu, 12 Mar 2015 03:18:30 -0700 (PDT)",
        "From": "Tetsuya Mukawa <mukawa@igel.co.jp>",
        "To": "dev@dpdk.org",
        "Date": "Thu, 12 Mar 2015 19:17:46 +0900",
        "Message-Id": "<1426155474-1596-8-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1426155474-1596-1-git-send-email-mukawa@igel.co.jp>",
        "References": "<1425438703-18895-1-git-send-email-mukawa@igel.co.jp>\n\t<1426155474-1596-1-git-send-email-mukawa@igel.co.jp>",
        "Subject": "[dpdk-dev] [PATCH v2 07/15] eal: Fix interface of\n\tpci_map_resource() of bsdapp",
        "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": "The function is implemented in both linuxapp and bsdapp, but interface\nis different. The patch fixes the function of bsdapp to do same as\nlinuxapp. After applying it, file descriptor should be opened and\nclosed out of pci_map_resource().\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n lib/librte_eal/bsdapp/eal/eal_pci.c       | 117 +++++++++++++++++++-----------\n lib/librte_eal/linuxapp/eal/eal_pci_uio.c |   5 +-\n 2 files changed, 78 insertions(+), 44 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c\nindex bd0f8cd..c92c624 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_pci.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c\n@@ -100,7 +100,7 @@ struct mapped_pci_resource {\n \n \tstruct rte_pci_addr pci_addr;\n \tchar path[PATH_MAX];\n-\tsize_t nb_maps;\n+\tint nb_maps;\n \tstruct pci_map maps[PCI_MAX_RESOURCE];\n };\n \n@@ -122,48 +122,31 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)\n \n /* map a particular resource from a file */\n static void *\n-pci_map_resource(void *requested_addr, const char *devname, off_t offset,\n-\t\t size_t size)\n+pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,\n+\t\t int additional_flags)\n {\n-\tint fd;\n \tvoid *mapaddr;\n \n-\t/*\n-\t * open devname, to mmap it\n-\t */\n-\tfd = open(devname, O_RDWR);\n-\tif (fd < 0) {\n-\t\tRTE_LOG(ERR, EAL, \"Cannot open %s: %s\\n\",\n-\t\t\tdevname, strerror(errno));\n-\t\tgoto fail;\n-\t}\n-\n \t/* Map the PCI memory resource of device */\n \tmapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,\n-\t\t\tMAP_SHARED, fd, offset);\n-\tclose(fd);\n-\tif (mapaddr == MAP_FAILED ||\n-\t    (requested_addr != NULL && mapaddr != requested_addr)) {\n+\t\t\tMAP_SHARED | additional_flags, fd, offset);\n+\tif (mapaddr == MAP_FAILED) {\n \t\tRTE_LOG(ERR, EAL,\n-\t\t\t\"%s(): cannot mmap(%s(%d), %p, 0x%lx, 0x%lx):\"\n-\t\t\t\" %s (%p)\\n\", __func__, devname, fd, requested_addr,\n+\t\t\t\"%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\\n\",\n+\t\t\t__func__, fd, requested_addr,\n \t\t\t(unsigned long)size, (unsigned long)offset,\n \t\t\tstrerror(errno), mapaddr);\n-\t\tgoto fail;\n+\t} else {\n+\t\tRTE_LOG(DEBUG, EAL, \"  PCI memory mapped at %p\\n\", mapaddr);\n \t}\n \n-\tRTE_LOG(DEBUG, EAL, \"  PCI memory mapped at %p\\n\", mapaddr);\n-\n \treturn mapaddr;\n-\n-fail:\n-\treturn NULL;\n }\n \n static int\n pci_uio_map_secondary(struct rte_pci_device *dev)\n {\n-\tsize_t i;\n+\tint i, fd;\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@@ -171,19 +154,42 @@ pci_uio_map_secondary(struct rte_pci_device *dev)\n \tTAILQ_FOREACH(uio_res, uio_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-\t\t\tif (pci_map_resource(uio_res->maps[i].addr,\n-\t\t\t\t\t     uio_res->path,\n-\t\t\t\t\t     (off_t)uio_res->maps[i].offset,\n-\t\t\t\t\t     (size_t)uio_res->maps[i].size)\n-\t\t\t    != uio_res->maps[i].addr) {\n-\t\t\t\tRTE_LOG(ERR, EAL,\n-\t\t\t\t\t\"Cannot mmap device resource\\n\");\n+\t\t\t/*\n+\t\t\t * open devname, to mmap it\n+\t\t\t */\n+\t\t\tfd = open(uio_res->maps[i].path, O_RDWR);\n+\t\t\tif (fd < 0) {\n+\t\t\t\tRTE_LOG(ERR, EAL, \"Cannot open %s: %s\\n\",\n+\t\t\t\t\tuio_res->maps[i].path, strerror(errno));\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\n+\t\t\tvoid *mapaddr = pci_map_resource(uio_res->maps[i].addr,\n+\t\t\t\t\tfd, (off_t)uio_res->maps[i].offset,\n+\t\t\t\t\t(size_t)uio_res->maps[i].size, 0);\n+\t\t\tif (mapaddr != uio_res->maps[i].addr) {\n+\t\t\t\tif (mapaddr == MAP_FAILED)\n+\t\t\t\t\tRTE_LOG(ERR, EAL,\n+\t\t\t\t\t\t\"Cannot mmap device resource \"\n+\t\t\t\t\t\t\"file %s: %s\\n\",\n+\t\t\t\t\t\tuio_res->maps[i].path,\n+\t\t\t\t\t\tstrerror(errno));\n+\t\t\t\telse\n+\t\t\t\t\tRTE_LOG(ERR, EAL,\n+\t\t\t\t\t\t\"Cannot mmap device resource \"\n+\t\t\t\t\t\t\"file %s to address: %p\\n\",\n+\t\t\t\t\t\tuio_res->maps[i].path,\n+\t\t\t\t\t\tuio_res->maps[i].addr);\n+\n+\t\t\t\tclose(fd);\n \t\t\t\treturn -1;\n \t\t\t}\n+\t\t\t/* fd is not needed in slave process, close it */\n+\t\t\tclose(fd);\n \t\t}\n \t\treturn 0;\n \t}\n@@ -251,25 +257,44 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \n \tmaps = uio_res->maps;\n \tfor (i = 0, map_idx = 0; i != PCI_MAX_RESOURCE; i++) {\n+\t\tint fd;\n \n \t\t/* skip empty BAR */\n \t\tphaddr = dev->mem_resource[i].phys_addr;\n \t\tif (phaddr == 0)\n \t\t\tcontinue;\n \n+\t\t/* allocate memory to keep path */\n+\t\tmaps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, 0);\n+\t\tif (maps[map_idx].path == NULL) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Cannot allocate memory for \"\n+\t\t\t\t\t\"path: %s\\n\", strerror(errno));\n+\t\t\tgoto fail0;\n+\t\t}\n+\n+\t\t/*\n+\t\t * open resource file, to mmap it\n+\t\t */\n+\t\tfd = open(devname, O_RDWR);\n+\t\tif (fd < 0) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Cannot open %s: %s\\n\",\n+\t\t\t\t\tdevname, strerror(errno));\n+\t\t\tgoto fail0;\n+\t\t}\n+\n \t\t/* if matching map is found, then use it */\n \t\toffset = i * pagesz;\n-\t\tmaps[map_idx].offset = offset;\n+\t\tmapaddr = pci_map_resource(NULL, fd, (off_t)offset,\n+\t\t\t\t\t(size_t)dev->mem_resource[i].len, 0);\n+\t\tclose(fd);\n+\t\tif (mapaddr == NULL)\n+\t\t\tgoto fail1;\n+\n \t\tmaps[map_idx].phaddr = dev->mem_resource[i].phys_addr;\n \t\tmaps[map_idx].size = dev->mem_resource[i].len;\n-\t\tmapaddr = pci_map_resource(NULL, devname, (off_t)offset,\n-\t\t\t\t\t(size_t)maps[map_idx].size);\n-\t\tif ((maps[map_idx].addr != NULL) || (mapaddr == NULL)) {\n-\t\t\trte_free(uio_res);\n-\t\t\treturn -1;\n-\t\t}\n-\n \t\tmaps[map_idx].addr = mapaddr;\n+\t\tmaps[map_idx].offset = offset;\n+\t\tstrcpy(maps[map_idx].path, devname);\n \t\tmap_idx++;\n \t\tdev->mem_resource[i].addr = mapaddr;\n \t}\n@@ -279,6 +304,12 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \tTAILQ_INSERT_TAIL(uio_res_list, uio_res, next);\n \n \treturn 0;\n+\n+fail1:\n+\trte_free(maps[map_idx].path);\n+fail0:\n+\trte_free(uio_res);\n+\treturn -1;\n }\n \n /* Scan one pci sysfs entry, and fill the devices list from it. */\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\nindex 2741c62..f100c1a 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n@@ -351,8 +351,11 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \n \t\t/* allocate memory to keep path */\n \t\tmaps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, 0);\n-\t\tif (maps[map_idx].path == NULL)\n+\t\tif (maps[map_idx].path == NULL) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Cannot allocate memory for \"\n+\t\t\t\t\t\"path: %s\\n\", strerror(errno));\n \t\t\tgoto fail0;\n+\t\t}\n \n \t\t/*\n \t\t * open resource file, to mmap it\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "07/15"
    ]
}