get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 27686,
    "url": "https://patches.dpdk.org/api/patches/27686/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1503320296-51122-4-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": "<1503320296-51122-4-git-send-email-harry.van.haaren@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1503320296-51122-4-git-send-email-harry.van.haaren@intel.com",
    "date": "2017-08-21T12:58:04",
    "name": "[dpdk-dev,v2,03/15] service: rework register to return service id",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "e1d6d4b082332092b7b5a848ff949c97618faf43",
    "submitter": {
        "id": 317,
        "url": "https://patches.dpdk.org/api/people/317/?format=api",
        "name": "Van Haaren, Harry",
        "email": "harry.van.haaren@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1503320296-51122-4-git-send-email-harry.van.haaren@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/27686/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/27686/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 588B97D3B;\n\tMon, 21 Aug 2017 14:58:32 +0200 (CEST)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby dpdk.org (Postfix) with ESMTP id D93617D12\n\tfor <dev@dpdk.org>; Mon, 21 Aug 2017 14:58:29 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga105.fm.intel.com with ESMTP; 21 Aug 2017 05:58:29 -0700",
            "from silpixa00398672.ir.intel.com ([10.237.223.128])\n\tby fmsmga002.fm.intel.com with ESMTP; 21 Aug 2017 05:58:28 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.41,409,1498546800\"; d=\"scan'208\";\n\ta=\"1208383273\"",
        "From": "Harry van Haaren <harry.van.haaren@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Harry van Haaren <harry.van.haaren@intel.com>",
        "Date": "Mon, 21 Aug 2017 13:58:04 +0100",
        "Message-Id": "<1503320296-51122-4-git-send-email-harry.van.haaren@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1503320296-51122-1-git-send-email-harry.van.haaren@intel.com>",
        "References": "<1502800360-15782-1-git-send-email-harry.van.haaren@intel.com>\n\t<1503320296-51122-1-git-send-email-harry.van.haaren@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 03/15] service: rework register to return\n\tservice id",
        "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 register function to accept\nan extra parameter. The parameter is a uint32_t *, which when\nprovided will be set to the integer service_id that the newly\nregistered service is represented by.\n\nThis is useful for services that wish to validate settings at\na later point in time - they need to know their own service id.\n\nThis commit updates the eventdev sw pmd, as well as unit tests\nto use the new register API.\n\nSigned-off-by: Harry van Haaren <harry.van.haaren@intel.com>\n\n---\n\nv2:\n- Rename rte_service_register to rte_service_component_register\n  This makes it clearer which APIs apply to components vs services.\n---\n drivers/event/sw/sw_evdev.c                        |  4 +--\n drivers/event/sw/sw_evdev.h                        |  1 +\n lib/librte_eal/bsdapp/eal/rte_eal_version.map      |  2 +-\n .../common/include/rte_service_component.h         |  6 +++-\n lib/librte_eal/common/rte_service.c                |  6 +++-\n lib/librte_eal/linuxapp/eal/rte_eal_version.map    |  2 +-\n test/test/test_service_cores.c                     | 36 ++++++++++++----------\n 7 files changed, 35 insertions(+), 22 deletions(-)",
    "diff": "diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c\nindex 9c534b7..9cc63a0 100644\n--- a/drivers/event/sw/sw_evdev.c\n+++ b/drivers/event/sw/sw_evdev.c\n@@ -620,7 +620,7 @@ sw_start(struct rte_eventdev *dev)\n \tstruct rte_service_spec *s = rte_service_get_by_name(sw->service_name);\n \tif (!rte_service_is_running(s))\n \t\tSW_LOG_ERR(\"Warning: No Service core enabled on service %s\\n\",\n-\t\t\t\ts->name);\n+\t\t\t\tsw->service_name);\n \n \t/* check all ports are set up */\n \tfor (i = 0; i < sw->port_count; i++)\n@@ -855,7 +855,7 @@ sw_probe(struct rte_vdev_device *vdev)\n \tservice.callback = sw_sched_service_func;\n \tservice.callback_userdata = (void *)dev;\n \n-\tint32_t ret = rte_service_register(&service);\n+\tint32_t ret = rte_service_component_register(&service, &sw->service_id);\n \tif (ret) {\n \t\tSW_LOG_ERR(\"service register() failed\");\n \t\treturn -ENOEXEC;\ndiff --git a/drivers/event/sw/sw_evdev.h b/drivers/event/sw/sw_evdev.h\nindex 71de3c1..e0dec91 100644\n--- a/drivers/event/sw/sw_evdev.h\n+++ b/drivers/event/sw/sw_evdev.h\n@@ -278,6 +278,7 @@ struct sw_evdev {\n \tuint16_t xstats_count_per_qid[RTE_EVENT_MAX_QUEUES_PER_DEV];\n \tuint16_t xstats_offset_for_qid[RTE_EVENT_MAX_QUEUES_PER_DEV];\n \n+\tuint32_t service_id;\n \tchar service_name[SW_PMD_NAME_MAX];\n };\n \ndiff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map\nindex f626a6f..2b1089d 100644\n--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map\n+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map\n@@ -212,6 +212,7 @@ EXPERIMENTAL {\n \trte_eal_devargs_remove;\n \trte_eal_hotplug_add;\n \trte_eal_hotplug_remove;\n+\trte_service_component_register;\n \trte_service_dump;\n \trte_service_get_by_id;\n \trte_service_get_by_name;\n@@ -227,7 +228,6 @@ EXPERIMENTAL {\n \trte_service_map_lcore_get;\n \trte_service_map_lcore_set;\n \trte_service_probe_capability;\n-\trte_service_register;\n \trte_service_reset;\n \trte_service_set_stats_enable;\n \trte_service_start;\ndiff --git a/lib/librte_eal/common/include/rte_service_component.h b/lib/librte_eal/common/include/rte_service_component.h\nindex 7a946a1..6ef3ee4 100644\n--- a/lib/librte_eal/common/include/rte_service_component.h\n+++ b/lib/librte_eal/common/include/rte_service_component.h\n@@ -89,11 +89,15 @@ struct rte_service_spec {\n  * *rte_service_set_coremask*.\n  *\n  * @param spec The specification of the service to register\n+ * @param[out] service_id A pointer to a uint32_t, which will be filled in\n+ *             during registration of the service. It is set to the integers\n+ *             service number given to the service. This parameter may be NULL.\n  * @retval 0 Successfully registered the service.\n  *         -EINVAL Attempted to register an invalid service (eg, no callback\n  *         set)\n  */\n-int32_t rte_service_register(const struct rte_service_spec *spec);\n+int32_t rte_service_component_register(const struct rte_service_spec *spec,\n+\t\t\t\t       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 c5a8d0d..152eafe 100644\n--- a/lib/librte_eal/common/rte_service.c\n+++ b/lib/librte_eal/common/rte_service.c\n@@ -242,7 +242,8 @@ rte_service_is_running(const struct rte_service_spec *spec)\n }\n \n int32_t\n-rte_service_register(const struct rte_service_spec *spec)\n+rte_service_component_register(const struct rte_service_spec *spec,\n+\t\t\t       uint32_t *id_ptr)\n {\n \tuint32_t i;\n \tint32_t free_slot = -1;\n@@ -267,6 +268,9 @@ rte_service_register(const struct rte_service_spec *spec)\n \trte_smp_wmb();\n \trte_service_count++;\n \n+\tif (id_ptr)\n+\t\t*id_ptr = free_slot;\n+\n \treturn 0;\n }\n \ndiff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\nindex 452ae1c..336e40e 100644\n--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n@@ -217,6 +217,7 @@ EXPERIMENTAL {\n \trte_eal_devargs_remove;\n \trte_eal_hotplug_add;\n \trte_eal_hotplug_remove;\n+\trte_service_component_register;\n \trte_service_dump;\n \trte_service_get_by_id;\n \trte_service_get_by_name;\n@@ -232,7 +233,6 @@ EXPERIMENTAL {\n \trte_service_map_lcore_get;\n \trte_service_map_lcore_set;\n \trte_service_probe_capability;\n-\trte_service_register;\n \trte_service_reset;\n \trte_service_set_stats_enable;\n \trte_service_start;\ndiff --git a/test/test/test_service_cores.c b/test/test/test_service_cores.c\nindex fd63efd..7767fa2 100644\n--- a/test/test/test_service_cores.c\n+++ b/test/test/test_service_cores.c\n@@ -160,15 +160,17 @@ dummy_register(void)\n \tstruct rte_service_spec service;\n \tmemset(&service, 0, sizeof(struct rte_service_spec));\n \n-\tTEST_ASSERT_EQUAL(-EINVAL, rte_service_register(&service),\n+\tTEST_ASSERT_EQUAL(-EINVAL,\n+\t\t\trte_service_component_register(&service, NULL),\n \t\t\t\"Invalid callback\");\n \tservice.callback = dummy_cb;\n \n-\tTEST_ASSERT_EQUAL(-EINVAL, rte_service_register(&service),\n+\tTEST_ASSERT_EQUAL(-EINVAL,\n+\t\t\trte_service_component_register(&service, NULL),\n \t\t\t\"Invalid name\");\n \tsnprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);\n \n-\tTEST_ASSERT_EQUAL(0, rte_service_register(&service),\n+\tTEST_ASSERT_EQUAL(0, rte_service_component_register(&service, NULL),\n \t\t\t\"Failed to register valid service\");\n \n \treturn TEST_SUCCESS;\n@@ -187,13 +189,15 @@ service_get_by_name(void)\n \t/* register service */\n \tstruct rte_service_spec service;\n \tmemset(&service, 0, sizeof(struct rte_service_spec));\n-\tTEST_ASSERT_EQUAL(-EINVAL, rte_service_register(&service),\n+\tTEST_ASSERT_EQUAL(-EINVAL,\n+\t\t\trte_service_component_register(&service, NULL),\n \t\t\t\"Invalid callback\");\n \tservice.callback = dummy_cb;\n-\tTEST_ASSERT_EQUAL(-EINVAL, rte_service_register(&service),\n+\tTEST_ASSERT_EQUAL(-EINVAL,\n+\t\t\trte_service_component_register(&service, NULL),\n \t\t\t\"Invalid name\");\n \tsnprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);\n-\tTEST_ASSERT_EQUAL(0, rte_service_register(&service),\n+\tTEST_ASSERT_EQUAL(0, rte_service_component_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@@ -221,7 +225,7 @@ service_probe_capability(void)\n \tservice.callback = dummy_cb;\n \tsnprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);\n \tservice.capabilities |= RTE_SERVICE_CAP_MT_SAFE;\n-\tTEST_ASSERT_EQUAL(0, rte_service_register(&service),\n+\tTEST_ASSERT_EQUAL(0, rte_service_component_register(&service, NULL),\n \t\t\t\"Register of MT SAFE service failed\");\n \n \t/* verify flag is enabled */\n@@ -235,7 +239,7 @@ service_probe_capability(void)\n \tmemset(&service, 0, sizeof(struct rte_service_spec));\n \tservice.callback = dummy_cb;\n \tsnprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);\n-\tTEST_ASSERT_EQUAL(0, rte_service_register(&service),\n+\tTEST_ASSERT_EQUAL(0, rte_service_component_register(&service, NULL),\n \t\t\t\"Register of non-MT safe service failed\");\n \n \t/* verify flag is enabled */\n@@ -274,28 +278,28 @@ static int\n service_start_stop(void)\n {\n \tconst uint32_t sid = 0;\n-\tstruct rte_service_spec *service = rte_service_get_by_id(0);\n+\tstruct rte_service_spec *s = rte_service_get_by_id(0);\n \n-\t/* is_running() returns if service is running and slcore is mapped */\n+\t/* runstate_get() returns if service is running and slcore is mapped */\n \tTEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id),\n \t\t\t\"Service core add did not return zero\");\n \tint ret = rte_service_map_lcore_set(sid, slcore_id, 1);\n \tTEST_ASSERT_EQUAL(0, ret,\n \t\t\t\"Enabling service core, expected 0 got %d\", ret);\n \n-\tTEST_ASSERT_EQUAL(0, rte_service_is_running(service),\n+\tTEST_ASSERT_EQUAL(0, rte_service_is_running(s),\n \t\t\t\"Error: Service should be stopped\");\n \n-\tTEST_ASSERT_EQUAL(0, rte_service_stop(service),\n+\tTEST_ASSERT_EQUAL(0, rte_service_stop(s),\n \t\t\t\"Error: Service stopped returned non-zero\");\n \n-\tTEST_ASSERT_EQUAL(0, rte_service_is_running(service),\n+\tTEST_ASSERT_EQUAL(0, rte_service_is_running(s),\n \t\t\t\"Error: Service is running - should be stopped\");\n \n-\tTEST_ASSERT_EQUAL(0, rte_service_start(service),\n+\tTEST_ASSERT_EQUAL(0, rte_service_start(s),\n \t\t\t\"Error: Service start returned non-zero\");\n \n-\tTEST_ASSERT_EQUAL(1, rte_service_is_running(service),\n+\tTEST_ASSERT_EQUAL(1, rte_service_is_running(s),\n \t\t\t\"Error: Service is not running\");\n \n \treturn unregister_all();\n@@ -471,7 +475,7 @@ service_threaded_test(int mt_safe)\n \t\tservice.callback = dummy_mt_unsafe_cb;\n \t}\n \n-\tTEST_ASSERT_EQUAL(0, rte_service_register(&service),\n+\tTEST_ASSERT_EQUAL(0, rte_service_component_register(&service, NULL),\n \t\t\t\"Register of MT SAFE service failed\");\n \n \tstruct rte_service_spec *s = rte_service_get_by_id(0);\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "03/15"
    ]
}