Show a patch.

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

{
    "id": 219,
    "url": "http://patches.dpdk.org/api/patches/219/",
    "web_url": "http://patches.dpdk.org/patch/219/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<20140825174429.2065320b@urahara>",
    "date": "2014-08-26T00:44:29",
    "name": "[dpdk-dev,RFC] PCI config access for drivers",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "1cc444be82b769da5a1362565712bef0f45a83dd",
    "submitter": {
        "id": 60,
        "url": "http://patches.dpdk.org/api/people/60/",
        "name": "Stephen Hemminger",
        "email": "shemming@brocade.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/patch/219/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/219/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/219/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<shemming@Brocade.com>",
        "MIME-Version": "1.0",
        "X-Mailman-Version": "2.1.15",
        "From": "Stephen Hemminger <shemming@brocade.com>",
        "X-List-Received-Date": "Tue, 26 Aug 2014 00:40:39 -0000",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"US-ASCII\"",
        "X-BeenThere": "dev@dpdk.org",
        "X-Proofpoint-Spam-Details": "rule=notspam policy=default score=3 spamscore=3\n\tsuspectscore=5 phishscore=0\n\tadultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx\n\tscancount=1\n\tengine=7.0.1-1402240000 definitions=main-1408260007",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Subject": "[dpdk-dev] [RFC] PCI config access for drivers",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "X-Mailman-Approved-At": "Tue, 26 Aug 2014 08:50:00 +0200",
        "Message-ID": "<20140825174429.2065320b@urahara>",
        "Precedence": "list",
        "Date": "Mon, 25 Aug 2014 17:44:29 -0700",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10432:5.12.52, 1.0.27,\n\t0.0.0000\n\tdefinitions=2014-08-26_01:2014-08-25, 2014-08-25,\n\t1970-01-01 signatures=0",
        "To": "\"dev@dpdk.org\" <dev@dpdk.org>",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "Received": [
            "from mx0b-000f0801.pphosted.com (mx0b-000f0801.pphosted.com\n\t[67.231.152.113]) by dpdk.org (Postfix) with ESMTP id 3BC6A3975\n\tfor <dev@dpdk.org>; Tue, 26 Aug 2014 02:40:39 +0200 (CEST)",
            "from pps.filterd (m0000700 [127.0.0.1])\n\tby mx0b-000f0801.pphosted.com (8.14.5/8.14.5) with SMTP id\n\ts7Q0bJdW008048 for <dev@dpdk.org>; Mon, 25 Aug 2014 17:44:32 -0700",
            "from hq1wp-exchub01.corp.brocade.com ([144.49.131.13])\n\tby mx0b-000f0801.pphosted.com with ESMTP id 1nyvsc3enf-1\n\t(version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT)\n\tfor <dev@dpdk.org>; Mon, 25 Aug 2014 17:44:32 -0700",
            "from HQ1WP-EXHUB01.corp.brocade.com (10.70.36.14) by\n\tHQ1WP-EXCHUB01.corp.brocade.com (10.70.36.99) with Microsoft SMTP\n\tServer (TLS) id 14.3.123.3; Mon, 25 Aug 2014 17:44:31 -0700",
            "from urahara (10.72.32.14) by imap.brocade.com (10.70.36.22) with\n\tMicrosoft SMTP Server (TLS) id 8.3.298.1;\n\tMon, 25 Aug 2014 17:44:30 -0700"
        ],
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Content-Transfer-Encoding": "7bit",
        "Organization": "Brocade"
    },
    "content": "Some drivers need ability to access PCI config (for example for power\nmanagement). This adds an abstraction to do this; only implemented\non Linux, but should be possible on BSD.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>",
    "diff": "--- a/lib/librte_eal/common/include/rte_pci.h\t2014-06-24 09:20:05.651993525 -0700\n+++ b/lib/librte_eal/common/include/rte_pci.h\t2014-06-24 09:25:42.150616572 -0700\n@@ -151,6 +151,7 @@ struct rte_pci_device {\n \tconst struct rte_pci_driver *driver;    /**< Associated driver */\n \tuint16_t max_vfs;                       /**< sriov enable if not zero */\n \tint numa_node;                          /**< NUMA node connection */\n+\tint config_fd;\t\t\t\t/**< PCI config access */\n \tstruct rte_devargs *devargs;            /**< Device user arguments */\n };\n \n@@ -298,6 +299,34 @@ void rte_eal_pci_register(struct rte_pci\n  */\n void rte_eal_pci_unregister(struct rte_pci_driver *driver);\n \n+/**\n+ * Read PCI config space.\n+ *\n+ * @param device\n+ *   A pointer to a rte_pci_device structure describing the device\n+ *   to use\n+ * @param buf\n+ *   A data buffer where the bytes should be read into\n+ * @param size\n+ *   The length of the data buffer.\n+ */\n+int rte_eal_pci_read_config(const struct rte_pci_device *device,\n+\t\t\t    void *buf, size_t len, off_t offset);\n+\n+/**\n+ * Write PCI config space.\n+ *\n+ * @param device\n+ *   A pointer to a rte_pci_device structure describing the device\n+ *   to use\n+ * @param buf\n+ *   A data buffer containing the bytes should be written\n+ * @param size\n+ *   The length of the data buffer.\n+ */\n+int rte_eal_pci_write_config(const struct rte_pci_device *device,\n+\t\t\t     const void *buf, size_t len, off_t offset);\n+\n #ifdef __cplusplus\n }\n #endif\n--- a/lib/librte_eal/linuxapp/eal/eal_pci.c\t2014-06-24 09:20:05.651993525 -0700\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c\t2014-06-24 09:20:05.651993525 -0700\n@@ -219,6 +219,7 @@ pci_scan_one(const char *dirname, uint16\n \tdev->addr.bus = bus;\n \tdev->addr.devid = devid;\n \tdev->addr.function = function;\n+\tdev->config_fd = -1;\n \n \t/* get vendor id */\n \tsnprintf(filename, sizeof(filename), \"%s/vendor\", dirname);\n@@ -578,6 +579,20 @@ rte_eal_pci_probe_one_driver(struct rte_\n \treturn 1;\n }\n \n+/* Read PCI config space. */\n+int rte_eal_pci_read_config(const struct rte_pci_device *device,\n+\t\t\t    void *buf, size_t len, off_t offset)\n+{\n+\treturn pread(device->config_fd, buf, len, offset);\n+}\n+\n+/* Write PCI config space. */\n+int rte_eal_pci_write_config(const struct rte_pci_device *device,\n+\t\t\t     const void *buf, size_t len, off_t offset)\n+{\n+\treturn pwrite(device->config_fd, buf, len, offset);\n+}\n+\n /* Init the PCI EAL subsystem */\n int\n rte_eal_pci_init(void)\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\t2014-06-24 08:35:31.832146544 -0700\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\t2014-06-24 09:37:44.892296443 -0700\n@@ -280,6 +280,7 @@ pci_uio_map_resource(struct rte_pci_devi\n \tint i, j;\n \tchar dirname[PATH_MAX];\n \tchar devname[PATH_MAX]; /* contains the /dev/uioX */\n+\tchar cfgname[PATH_MAX];\n \tvoid *mapaddr;\n \tint uio_num;\n \tuint64_t phaddr;\n@@ -326,11 +327,23 @@ pci_uio_map_resource(struct rte_pci_devi\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+\t/* Open fd for access to PCI config */\n+\tsnprintf(cfgname, sizeof(cfgname),\n+\t\t \"%s/device/config\", dirname);\n+\tdev->config_fd = open(cfgname, O_RDWR);\n+\tif (dev->config_fd < 0) {\n+\t\tRTE_LOG(ERR, EAL, \"%s(): cannot open %s: %s\\n\",\n+\t\t\t__func__, cfgname, strerror(errno));\n+\t\trte_free(uio_res);\n+\t\treturn -1;\n+\t}\n+\n \t/* collect info about device mappings */\n \tnb_maps = pci_uio_get_mappings(dirname, uio_res->maps,\n \t\t\t\t       RTE_DIM(uio_res->maps));\n \tif (nb_maps < 0) {\n \t\trte_free(uio_res);\n+\t\tclose(dev->config_fd);\n \t\treturn nb_maps;\n \t}\n \n@@ -379,6 +392,7 @@ pci_uio_map_resource(struct rte_pci_devi\n \n \t\t\tif (fail) {\n \t\t\t\trte_free(uio_res);\n+\t\t\t\tclose(dev->config_fd);\n \t\t\t\tclose(fd);\n \t\t\t\treturn -1;\n \t\t\t}\n",
    "prefixes": [
        "dpdk-dev",
        "RFC"
    ]
}