Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2370/?format=api
https://patches.dpdk.org/api/patches/2370/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1421664027-17971-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": "<1421664027-17971-6-git-send-email-mukawa@igel.co.jp>", "list_archive_url": "https://inbox.dpdk.org/dev/1421664027-17971-6-git-send-email-mukawa@igel.co.jp", "date": "2015-01-19T10:40:21", "name": "[dpdk-dev,v4,05/11] ethdev: Add functions that will be used by port hotplug functions", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "86d0575b226825d456a383d91e144e8095fbef92", "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/1421664027-17971-6-git-send-email-mukawa@igel.co.jp/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/2370/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/2370/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 A4D435AC3;\n\tMon, 19 Jan 2015 11:41:27 +0100 (CET)", "from mail-pd0-f171.google.com (mail-pd0-f171.google.com\n\t[209.85.192.171]) by dpdk.org (Postfix) with ESMTP id A4D9B5A9C\n\tfor <dev@dpdk.org>; Mon, 19 Jan 2015 11:41:17 +0100 (CET)", "by mail-pd0-f171.google.com with SMTP id fp1so14534380pdb.2\n\tfor <dev@dpdk.org>; Mon, 19 Jan 2015 02:41:17 -0800 (PST)", "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\ta13sm11337588pdm.44.2015.01.19.02.41.15\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tMon, 19 Jan 2015 02:41:16 -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=8YbLLQeUJO8gjcA3bphWNlWS948VfEI1CgfZM6Bwdvw=;\n\tb=JNr9ZY4/BINa7DgaaSErPE/2wEoOeihpqbg4a+0EiAO6Inqnw7s5Nj33Wc3z6CS/Dx\n\tYvWNvj0szDn50osXHNOQgamIgVEV5IOSrxZVSMuPPzs5JhhaLRi9MXvr13UmnQwtq1jn\n\twEtmQeJ1NT+nO/ZexMbBqoiCGil/s4MWSgHBnbh8vUziHND3H0cCbdd21/bCQCdsudcJ\n\tZCpK2C2uBOuTqePBO9ZcTfnqOx7/HVBViJKQy2XfgMIYEzr34o/zADyg9UK696yybIR/\n\tLqiil4um0Tuuq18lLabZda2F1QO8ThyXngzHlB7JZcaEES6+FJ01PfGqqDV25Tv+2MBv\n\twF2Q==", "X-Gm-Message-State": "ALoCoQm4WlvfNzjC7/RmCP7HIqNwlOfnOA5DpGfkd6qsPheSm+94aThVqKXVxJuj7RwD4mTVgS8a", "X-Received": "by 10.68.227.72 with SMTP id ry8mr42549007pbc.101.1421664076984; \n\tMon, 19 Jan 2015 02:41:16 -0800 (PST)", "From": "Tetsuya Mukawa <mukawa@igel.co.jp>", "To": "dev@dpdk.org", "Date": "Mon, 19 Jan 2015 19:40:21 +0900", "Message-Id": "<1421664027-17971-6-git-send-email-mukawa@igel.co.jp>", "X-Mailer": "git-send-email 1.9.1", "In-Reply-To": "<1421664027-17971-1-git-send-email-mukawa@igel.co.jp>", "References": "<1418106629-22227-2-git-send-email-mukawa@igel.co.j>\n\t<1421664027-17971-1-git-send-email-mukawa@igel.co.jp>", "Subject": "[dpdk-dev] [PATCH v4 05/11] ethdev: Add functions that will be used\n\tby port hotplug functions", "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 patch adds following functions.\n\n- rte_eth_dev_save()\n The function is used for saving current rte_eth_dev structures.\n- rte_eth_dev_get_changed_port()\n The function receives the rte_eth_dev structures, then compare\n these with current values to know which port is actually\n attached or detached.\n- rte_eth_dev_get_addr_by_port()\n The function returns a pci address of a ethdev specified by port\n identifier.\n- rte_eth_dev_get_port_by_addr()\n The function returns a port identifier of a ethdev specified by\n pci address.\n- rte_eth_dev_get_name_by_port()\n The function returns a unique identifier name of a ethdev\n specified by port identifier.\n- Add rte_eth_dev_check_detachable()\n The function returns whether a PMD supports detach function.\n\nAlso the patch changes scope of rte_eth_dev_allocated() to global.\nThis function will be called by virtual PMDs to support port hotplug.\nSo change scope of the function to global.\n\nv4:\n- Add paramerter checking.\nv3:\n- Fix if-condition bug while comparing pci addresses.\n- Add error checking codes.\nReported-by: Mark Enright <menrigh@brocade.com>\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n lib/librte_ether/rte_ethdev.c | 102 +++++++++++++++++++++++++++++++++++++++++-\n lib/librte_ether/rte_ethdev.h | 80 +++++++++++++++++++++++++++++++++\n 2 files changed, 181 insertions(+), 1 deletion(-)", "diff": "diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c\nindex e5145b7..e572ef4 100644\n--- a/lib/librte_ether/rte_ethdev.c\n+++ b/lib/librte_ether/rte_ethdev.c\n@@ -206,7 +206,7 @@ rte_eth_dev_data_alloc(void)\n \t\t\t\tRTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));\n }\n \n-static struct rte_eth_dev *\n+struct rte_eth_dev *\n rte_eth_dev_allocated(const char *name)\n {\n \tunsigned i;\n@@ -422,6 +422,106 @@ rte_eth_dev_count(void)\n \treturn (nb_ports);\n }\n \n+void\n+rte_eth_dev_save(struct rte_eth_dev *devs)\n+{\n+\tif (devs == NULL)\n+\t\treturn;\n+\n+\t/* save current rte_eth_devices */\n+\tmemcpy(devs, rte_eth_devices,\n+\t\t\tsizeof(struct rte_eth_dev) * RTE_MAX_ETHPORTS);\n+}\n+\n+int\n+rte_eth_dev_get_changed_port(struct rte_eth_dev *devs, uint8_t *port_id)\n+{\n+\tif ((devs == NULL) || (port_id == NULL))\n+\t\treturn -1;\n+\n+\t/* check which port was attached or detached */\n+\tfor (*port_id = 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++, devs++) {\n+\t\tif (rte_eth_devices[*port_id].attached ^ devs->attached)\n+\t\t\treturn 0;\n+\t}\n+\treturn 1;\n+}\n+\n+int\n+rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)\n+{\n+\tif (rte_eth_dev_validate_port(port_id) == DEV_INVALID) {\n+\t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (addr == NULL) {\n+\t\tPMD_DEBUG_TRACE(\"Null pointer is specified\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t*addr = rte_eth_devices[port_id].pci_dev->addr;\n+\treturn 0;\n+}\n+\n+int\n+rte_eth_dev_get_port_by_addr(struct rte_pci_addr *addr, uint8_t *port_id)\n+{\n+\tstruct rte_pci_addr *tmp;\n+\n+\tif ((addr == NULL) || (port_id == NULL)) {\n+\t\tPMD_DEBUG_TRACE(\"Null pointer is specified\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tfor (*port_id = 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++) {\n+\t\tif (!rte_eth_devices[*port_id].attached)\n+\t\t\tcontinue;\n+\t\tif (!rte_eth_devices[*port_id].pci_dev)\n+\t\t\tcontinue;\n+\t\ttmp = &rte_eth_devices[*port_id].pci_dev->addr;\n+\t\tif (eal_compare_pci_addr(tmp, addr) == 0)\n+\t\t\treturn 0;\n+\t}\n+\treturn -1;\n+}\n+\n+int\n+rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)\n+{\n+\tchar *tmp;\n+\n+\tif (rte_eth_dev_validate_port(port_id) == DEV_INVALID) {\n+\t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (name == NULL) {\n+\t\tPMD_DEBUG_TRACE(\"Null pointer is specified\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* shouldn't check 'rte_eth_devices[i].data',\n+\t * because it might be overwritten by VDEV PMD */\n+\ttmp = rte_eth_dev_data[port_id].name;\n+\tstrncpy(name, tmp, strlen(tmp) + 1);\n+\treturn 0;\n+}\n+\n+int\n+rte_eth_dev_check_detachable(uint8_t port_id)\n+{\n+\tuint32_t drv_flags;\n+\n+\tif (port_id >= RTE_MAX_ETHPORTS) {\n+\t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tdrv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags;\n+\treturn !(drv_flags & RTE_PCI_DRV_DETACHABLE);\n+}\n+\n static int\n rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)\n {\ndiff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h\nindex 2a8ff26..c0b98dc 100644\n--- a/lib/librte_ether/rte_ethdev.h\n+++ b/lib/librte_ether/rte_ethdev.h\n@@ -1642,6 +1642,86 @@ extern struct rte_eth_dev rte_eth_devices[];\n extern uint8_t rte_eth_dev_count(void);\n \n /**\n+ * Function for internal use by port hotplug functions.\n+ * Copies current ethdev structures to the specified pointer.\n+ *\n+ * @param\tdevs\tThe pointer to the ethdev structures\n+ */\n+extern void rte_eth_dev_save(struct rte_eth_dev *devs);\n+\n+/**\n+ * Function for internal use by port hotplug functions.\n+ * Compare the specified ethdev structures with currents. Then\n+ * if there is a port which status is changed, fill the specified pointer\n+ * with the port id of that port.\n+ * @param\tdevs\tThe pointer to the ethdev structures\n+ * @param\tport_id\tThe pointer to the port id\n+ * @return\n+ * - 0 on success, negative on error\n+ */\n+extern int rte_eth_dev_get_changed_port(\n+\t\tstruct rte_eth_dev *devs, uint8_t *port_id);\n+\n+/**\n+ * Function for internal use by port hotplug functions.\n+ * Returns a pci address of a ethdev specified by port identifier.\n+ * @param\tport_id\n+ * The port identifier of the Ethernet device\n+ * @param\taddr\n+ * The pointer to the pci address\n+ * @return\n+ * - 0 on success, negative on error\n+ */\n+extern int rte_eth_dev_get_addr_by_port(\n+\t\tuint8_t port_id, struct rte_pci_addr *addr);\n+\n+/**\n+ * Function for internal use by port hotplug functions.\n+ * Returns a port identifier of a ethdev specified by pci address.\n+ * @param\taddr\n+ * The pointer to the pci address of the Ethernet device.\n+ * @param\tport_id\n+ * The pointer to the port identifier\n+ * @return\n+ * - 0 on success, negative on error\n+ */\n+extern int rte_eth_dev_get_port_by_addr(\n+\t\tstruct rte_pci_addr *addr, uint8_t *port_id);\n+\n+/**\n+ * Function for internal use by port hotplug functions.\n+ * Returns a unique identifier name of a ethdev specified by port identifier.\n+ * @param\tport_id\n+ * The port identifier.\n+ * @param\tname\n+ * The pointer to the Unique identifier name for each Ethernet device\n+ * @return\n+ * - 0 on success, negative on error\n+ */\n+extern int rte_eth_dev_get_name_by_port(uint8_t port_id, char *name);\n+\n+/**\n+ * Function for internal use by port hotplug functions.\n+ * Check whether or not, a PMD that is handling the ethdev specified by port\n+ * identifier can support detach function.\n+ * @param\tport_id\n+ * The port identifier\n+ * @return\n+ * - 0 on supporting detach function, negative on not supporting\n+ */\n+extern int rte_eth_dev_check_detachable(uint8_t port_id);\n+\n+/**\n+ * Function for internal use by port hotplug functions.\n+ * Returns a ethdev slot specified by the unique identifier name.\n+ * @param\tname\n+ * The pointer to the Unique identifier name for each Ethernet device\n+ * @return\n+ * - The pointer to the ethdev slot, on success. NULL on error\n+ */\n+extern struct rte_eth_dev *rte_eth_dev_allocated(const char *name);\n+\n+/**\n * Function for internal use by dummy drivers primarily, e.g. ring-based\n * driver.\n * Allocates a new ethdev slot for an ethernet device and returns the pointer\n", "prefixes": [ "dpdk-dev", "v4", "05/11" ] }{ "id": 2370, "url": "