get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 27618,
    "url": "https://patches.dpdk.org/api/patches/27618/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1502800360-15782-8-git-send-email-harry.van.haaren@intel.com/",
    "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": "<1502800360-15782-8-git-send-email-harry.van.haaren@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1502800360-15782-8-git-send-email-harry.van.haaren@intel.com",
    "date": "2017-08-15T12:32:39",
    "name": "[dpdk-dev,7/8] service: rework get by name function to use id",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "1e5d4b2041ea0be96a4ba84188140832f5ba780a",
    "submitter": {
        "id": 317,
        "url": "https://patches.dpdk.org/api/people/317/?format=api",
        "name": "Van Haaren, Harry",
        "email": "harry.van.haaren@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1502800360-15782-8-git-send-email-harry.van.haaren@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/27618/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/27618/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 D59389965;\n\tTue, 15 Aug 2017 14:33:12 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id 3FA907D10\n\tfor <dev@dpdk.org>; Tue, 15 Aug 2017 14:32:58 +0200 (CEST)",
            "from fmsmga005.fm.intel.com ([10.253.24.32])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t15 Aug 2017 05:32:57 -0700",
            "from silpixa00398672.ir.intel.com ([10.237.223.128])\n\tby fmsmga005.fm.intel.com with ESMTP; 15 Aug 2017 05:32:57 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.41,377,1498546800\"; d=\"scan'208\";a=\"139790205\"",
        "From": "Harry van Haaren <harry.van.haaren@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Harry van Haaren <harry.van.haaren@intel.com>",
        "Date": "Tue, 15 Aug 2017 13:32:39 +0100",
        "Message-Id": "<1502800360-15782-8-git-send-email-harry.van.haaren@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1502800360-15782-1-git-send-email-harry.van.haaren@intel.com>",
        "References": "<1502800360-15782-1-git-send-email-harry.van.haaren@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 7/8] service: rework get by name function to use\n\tid",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <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": "This commit reworks the service_get_by_name() function to\naccept an integer, and removes the service_get_by_id() function.\n\nAll functions now accept an integer argument representing the\nservice, so it is no longer required to expose the service_spec\npointers to the application.\n\nSigned-off-by: Harry van Haaren <harry.van.haaren@intel.com>\n---\n lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +\n lib/librte_eal/common/include/rte_service.h     | 45 ++++++++++---------------\n lib/librte_eal/common/rte_service.c             | 24 ++++---------\n lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +\n test/test/test_service_cores.c                  | 30 ++++++++++-------\n 5 files changed, 43 insertions(+), 58 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map\nindex f76d1ea..97113e2 100644\n--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map\n+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map\n@@ -216,6 +216,7 @@ EXPERIMENTAL {\n \trte_service_get_by_id;\n \trte_service_get_by_name;\n \trte_service_get_count;\n+\trte_service_get_name;\n \trte_service_lcore_add;\n \trte_service_lcore_count;\n \trte_service_lcore_del;\ndiff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h\nindex afa6c0bf..e06b075 100644\n--- a/lib/librte_eal/common/include/rte_service.h\n+++ b/lib/librte_eal/common/include/rte_service.h\n@@ -61,9 +61,6 @@ extern \"C\" {\n \n #include <rte_lcore.h>\n \n-/* forward declaration only. Definition in rte_service_private.h */\n-struct rte_service_spec;\n-\n #define RTE_SERVICE_NAME_MAX 32\n \n /* Capabilities of a service.\n@@ -89,40 +86,32 @@ struct rte_service_spec;\n  */\n uint32_t rte_service_get_count(void);\n \n-\n /**\n  * @warning\n  * @b EXPERIMENTAL: this API may change without prior notice\n  *\n- * Return the specification of a service by integer id.\n- *\n- * This function provides the specification of a service. This can be used by\n- * the application to understand what the service represents. The service\n- * must not be modified by the application directly, only passed to the various\n- * rte_service_* functions.\n- *\n- * @param id The integer id of the service to retrieve\n- * @retval non-zero A valid pointer to the service_spec\n- * @retval NULL Invalid *id* provided.\n- */\n-struct rte_service_spec *rte_service_get_by_id(uint32_t id);\n-\n-/**\n- * @warning\n- * @b EXPERIMENTAL: this API may change without prior notice\n+ * Return the id of a service by name.\n  *\n- * Return the specification of a service by name.\n+ * This function provides the id of the service using the service name as\n+ * lookup key. The service id is to be passed to other functions in the\n+ * rte_service_* API.\n  *\n- * This function provides the specification of a service using the service name\n- * as lookup key. This can be used by the application to understand what the\n- * service represents. The service must not be modified by the application\n- * directly, only passed to the various rte_service_* functions.\n+ * Example usage:\n+ * @code\n+ *      uint32_t service_id;\n+ *      int32_t ret = rte_service_get_by_name(\"service_X\", &service_id);\n+ *      if (ret) {\n+ *              // handle error\n+ *      }\n+ * @endcode\n  *\n  * @param name The name of the service to retrieve\n- * @retval non-zero A valid pointer to the service_spec\n- * @retval NULL Invalid *name* provided.\n+ * @param[out] service_id A pointer to a uint32_t, to be filled in with the id.\n+ * @retval 0 Success. The service id is provided in *service_id*.\n+ * @retval -EINVAL Null *service_id* pointer provided\n+ * @retval -ENODEV No such service registered\n  */\n-struct rte_service_spec *rte_service_get_by_name(const char *name);\n+int32_t rte_service_get_by_name(const char *name, uint32_t *service_id);\n \n /**\n  * @warning\ndiff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c\nindex 7299514..7a825b7 100644\n--- a/lib/librte_eal/common/rte_service.c\n+++ b/lib/librte_eal/common/rte_service.c\n@@ -185,29 +185,21 @@ rte_service_get_count(void)\n \treturn rte_service_count;\n }\n \n-struct rte_service_spec *\n-rte_service_get_by_id(uint32_t id)\n+int32_t rte_service_get_by_name(const char *name, uint32_t *service_id)\n {\n-\tstruct rte_service_spec *service = NULL;\n-\tif (id < rte_service_count)\n-\t\tservice = (struct rte_service_spec *)&rte_services[id];\n-\n-\treturn service;\n-}\n+\tif (!service_id)\n+\t\treturn -EINVAL;\n \n-struct rte_service_spec *rte_service_get_by_name(const char *name)\n-{\n-\tstruct rte_service_spec *service = NULL;\n \tint i;\n \tfor (i = 0; i < RTE_SERVICE_NUM_MAX; i++) {\n \t\tif (service_valid(i) &&\n \t\t\t\tstrcmp(name, rte_services[i].spec.name) == 0) {\n-\t\t\tservice = (struct rte_service_spec *)&rte_services[i];\n-\t\t\tbreak;\n+\t\t\t*service_id = i;\n+\t\t\treturn 0;\n \t\t}\n \t}\n \n-\treturn service;\n+\treturn -ENODEV;\n }\n \n const char *\n@@ -406,10 +398,6 @@ rte_service_start_with_defaults(void)\n \t\trte_service_lcore_start(ids[i]);\n \n \tfor (i = 0; i < count; i++) {\n-\t\tstruct rte_service_spec *s = rte_service_get_by_id(i);\n-\t\tif (!s)\n-\t\t\treturn -EINVAL;\n-\n \t\t/* do 1:1 core mapping here, with each service getting\n \t\t * assigned a single core by default. Adding multiple services\n \t\t * should multiplex to a single core, or 1:1 if there are the\ndiff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\nindex 557b5e7..d179fa5 100644\n--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n@@ -221,6 +221,7 @@ EXPERIMENTAL {\n \trte_service_get_by_id;\n \trte_service_get_by_name;\n \trte_service_get_count;\n+\trte_service_get_name;\n \trte_service_lcore_add;\n \trte_service_lcore_count;\n \trte_service_lcore_del;\ndiff --git a/test/test/test_service_cores.c b/test/test/test_service_cores.c\nindex 43ad027..ff8dcb1 100644\n--- a/test/test/test_service_cores.c\n+++ b/test/test/test_service_cores.c\n@@ -176,9 +176,13 @@ service_get_by_name(void)\n {\n \tunregister_all();\n \n-\t/* ensure with no services registered returns NULL */\n-\tTEST_ASSERT_EQUAL(0, rte_service_get_by_name(DUMMY_SERVICE_NAME),\n-\t\t\t\"Service get by name should return NULL\");\n+\tuint32_t sid;\n+\tTEST_ASSERT_EQUAL(-ENODEV,\n+\t\t\trte_service_get_by_name(DUMMY_SERVICE_NAME, &sid),\n+\t\t\t\"get by name with invalid name should return -ENODEV\");\n+\tTEST_ASSERT_EQUAL(-EINVAL,\n+\t\t\trte_service_get_by_name(DUMMY_SERVICE_NAME, 0x0),\n+\t\t\t\"get by name with NULL ptr should return -ENODEV\");\n \n \t/* register service */\n \tstruct rte_service_spec service;\n@@ -192,16 +196,19 @@ service_get_by_name(void)\n \tTEST_ASSERT_EQUAL(0, rte_service_register(&service, NULL),\n \t\t\t\"Failed to register valid service\");\n \n-\t/* ensure with dummy services registered returns same ptr as ID */\n-\tstruct rte_service_spec *s_by_id = rte_service_get_by_id(0);\n-\tTEST_ASSERT_EQUAL(s_by_id, rte_service_get_by_name(DUMMY_SERVICE_NAME),\n-\t\t\t\"Service get_by_name should equal get_by_id()\");\n+\t/* we unregistered all service, now registering 1, should be id 0 */\n+\tuint32_t service_id_as_expected = 0;\n+\tTEST_ASSERT_EQUAL(0, rte_service_get_by_name(DUMMY_SERVICE_NAME, &sid),\n+\t\t\t\"Service get_by_name should return 0 on valid inputs\");\n+\tTEST_ASSERT_EQUAL(service_id_as_expected, sid,\n+\t\t\t\"Service get_by_name should equal expected id\");\n \n \tunregister_all();\n \n \t/* ensure after unregister, get_by_name returns NULL */\n-\tTEST_ASSERT_EQUAL(0, rte_service_get_by_name(DUMMY_SERVICE_NAME),\n-\t\t\t\"get by name should return NULL after unregister\");\n+\tTEST_ASSERT_EQUAL(-ENODEV,\n+\t\t\trte_service_get_by_name(DUMMY_SERVICE_NAME, &sid),\n+\t\t\t\"get by name should return -ENODEV after unregister\");\n \n \treturn TEST_SUCCESS;\n }\n@@ -245,9 +252,8 @@ service_probe_capability(void)\n static int\n service_name(void)\n {\n-\tstruct rte_service_spec *service = rte_service_get_by_id(0);\n-\n-\tint equal = strcmp(service->name, DUMMY_SERVICE_NAME);\n+\tconst char *name = rte_service_get_name(0);\n+\tint equal = strcmp(name, DUMMY_SERVICE_NAME);\n \tTEST_ASSERT_EQUAL(0, equal, \"Error: Service name not correct\");\n \n \treturn unregister_all();\n",
    "prefixes": [
        "dpdk-dev",
        "7/8"
    ]
}