get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 27615,
    "url": "https://patches.dpdk.org/api/patches/27615/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1502800360-15782-5-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-5-git-send-email-harry.van.haaren@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1502800360-15782-5-git-send-email-harry.van.haaren@intel.com",
    "date": "2017-08-15T12:32:36",
    "name": "[dpdk-dev,4/8] service: rework service start stop to runstate",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "cb9941a8f89d82a82090345bffc044de6b2bad97",
    "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-5-git-send-email-harry.van.haaren@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/27615/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/27615/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 F337B9143;\n\tTue, 15 Aug 2017 14:33:07 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id 400387D47\n\tfor <dev@dpdk.org>; Tue, 15 Aug 2017 14:32:55 +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:54 -0700",
            "from silpixa00398672.ir.intel.com ([10.237.223.128])\n\tby fmsmga005.fm.intel.com with ESMTP; 15 Aug 2017 05:32:54 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.41,377,1498546800\"; d=\"scan'208\";a=\"139790193\"",
        "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:36 +0100",
        "Message-Id": "<1502800360-15782-5-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 4/8] service: rework service start stop to\n\trunstate",
        "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 API to move from two seperate start\nand stop functions, to a \"runstate\" API which allows setting\nthe runstate. The is_running API is replaced with an function\nto query the runstate. The runstate functions take a id value\nfor service. Unit tests and the eventdev sw pmd are updated.\n\nSigned-off-by: Harry van Haaren <harry.van.haaren@intel.com>\n---\n drivers/event/sw/sw_evdev.c                     |  3 +-\n lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  5 ++--\n lib/librte_eal/common/include/rte_service.h     | 37 +++++++++---------------\n lib/librte_eal/common/rte_service.c             | 38 ++++++++++---------------\n lib/librte_eal/linuxapp/eal/rte_eal_version.map |  5 ++--\n test/test/test_service_cores.c                  | 19 ++++++-------\n 6 files changed, 42 insertions(+), 65 deletions(-)",
    "diff": "diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c\nindex 819d3ef..fd2fb72 100644\n--- a/drivers/event/sw/sw_evdev.c\n+++ b/drivers/event/sw/sw_evdev.c\n@@ -617,8 +617,7 @@ sw_start(struct rte_eventdev *dev)\n \tstruct sw_evdev *sw = sw_pmd_priv(dev);\n \n \t/* check a service core is mapped to this service */\n-\tstruct rte_service_spec *s = rte_service_get_by_name(sw->service_name);\n-\tif (!rte_service_is_running(s))\n+\tif (!rte_service_runstate_get(sw->service_id))\n \t\tSW_LOG_ERR(\"Warning: No Service core enabled on service %s\\n\",\n \t\t\t\tsw->service_name);\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..f76d1ea 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,7 +216,6 @@ EXPERIMENTAL {\n \trte_service_get_by_id;\n \trte_service_get_by_name;\n \trte_service_get_count;\n-\trte_service_is_running;\n \trte_service_lcore_add;\n \trte_service_lcore_count;\n \trte_service_lcore_del;\n@@ -229,10 +228,10 @@ EXPERIMENTAL {\n \trte_service_probe_capability;\n \trte_service_register;\n \trte_service_reset;\n+\trte_service_runstate_get;\n+\trte_service_runstate_set;\n \trte_service_set_stats_enable;\n-\trte_service_start;\n \trte_service_start_with_defaults;\n-\trte_service_stop;\n \trte_service_unregister;\n \n } DPDK_17.08;\ndiff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h\nindex de69695..e133ca1 100644\n--- a/lib/librte_eal/common/include/rte_service.h\n+++ b/lib/librte_eal/common/include/rte_service.h\n@@ -192,40 +192,31 @@ int32_t rte_service_map_lcore_get(uint32_t service_id, uint32_t lcore);\n  * @warning\n  * @b EXPERIMENTAL: this API may change without prior notice\n  *\n- * Enable *service* to run.\n+ * Set the runstate of the service.\n  *\n- * This function switches on a service during runtime.\n- * @retval 0 The service was successfully started\n- */\n-int32_t rte_service_start(struct rte_service_spec *service);\n-\n-/**\n- * @warning\n- * @b EXPERIMENTAL: this API may change without prior notice\n+ * Each service is either running or stopped. Setting a non-zero runstate\n+ * enables the service to run, while setting runstate zero disables it.\n  *\n- * Disable *service*.\n+ * @param id The id of the service\n+ * @param runstate The run state to apply to the service\n  *\n- * Switch off a service, so it is not run until it is *rte_service_start* is\n- * called on it.\n- * @retval 0 Service successfully switched off\n+ * @retval 0 The service was successfully started\n+ * @retval -EINVAL Invalid service id\n  */\n-int32_t rte_service_stop(struct rte_service_spec *service);\n+int32_t rte_service_runstate_set(uint32_t id, uint32_t runstate);\n \n /**\n  * @warning\n  * @b EXPERIMENTAL: this API may change without prior notice\n  *\n- * Returns if *service* is currently running.\n- *\n- * This function returns true if the service has been started using\n- * *rte_service_start*, AND a service core is mapped to the service. This\n- * function can be used to ensure that the service will be run.\n+ * Get the runstate for the service with *id*. See *rte_service_runstate_set*\n+ * for details of runstates.\n  *\n- * @retval 1 Service is currently running, and has a service lcore mapped\n- * @retval 0 Service is currently stopped, or no service lcore is mapped\n- * @retval -EINVAL Invalid service pointer provided\n+ * @retval 1 Service is running\n+ * @retval 0 Service is stopped\n+ * @retval -EINVAL Invalid service id\n  */\n-int32_t rte_service_is_running(const struct rte_service_spec *service);\n+int32_t rte_service_runstate_get(uint32_t id);\n \n /**\n  * @warning\ndiff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c\nindex 0ee0c13..7e9bf4d 100644\n--- a/lib/librte_eal/common/rte_service.c\n+++ b/lib/librte_eal/common/rte_service.c\n@@ -230,18 +230,6 @@ rte_service_probe_capability(uint32_t id, uint32_t capability)\n }\n \n int32_t\n-rte_service_is_running(const struct rte_service_spec *spec)\n-{\n-\tconst struct rte_service_spec_impl *impl =\n-\t\t(const struct rte_service_spec_impl *)spec;\n-\tif (!impl)\n-\t\treturn -EINVAL;\n-\n-\treturn (impl->runstate == RUNSTATE_RUNNING) &&\n-\t\t(impl->num_mapped_cores > 0);\n-}\n-\n-int32_t\n rte_service_register(const struct rte_service_spec *spec, uint32_t *id_ptr)\n {\n \tuint32_t i;\n@@ -308,23 +296,27 @@ rte_service_unregister(struct rte_service_spec *spec)\n }\n \n int32_t\n-rte_service_start(struct rte_service_spec *service)\n+rte_service_runstate_set(uint32_t id, uint32_t runstate)\n {\n-\tstruct rte_service_spec_impl *s =\n-\t\t(struct rte_service_spec_impl *)service;\n-\ts->runstate = RUNSTATE_RUNNING;\n+\tstruct rte_service_spec_impl *s;\n+\tSERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL);\n+\n+\tif (runstate)\n+\t\ts->runstate = RUNSTATE_RUNNING;\n+\telse\n+\t\ts->runstate = RUNSTATE_STOPPED;\n+\n \trte_smp_wmb();\n \treturn 0;\n }\n \n int32_t\n-rte_service_stop(struct rte_service_spec *service)\n+rte_service_runstate_get(uint32_t id)\n {\n-\tstruct rte_service_spec_impl *s =\n-\t\t(struct rte_service_spec_impl *)service;\n-\ts->runstate = RUNSTATE_STOPPED;\n-\trte_smp_wmb();\n-\treturn 0;\n+\tstruct rte_service_spec_impl *s;\n+\tSERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL);\n+\n+\treturn (s->runstate == RUNSTATE_RUNNING) && (s->num_mapped_cores > 0);\n }\n \n static int32_t\n@@ -447,7 +439,7 @@ rte_service_start_with_defaults(void)\n \t\tif (lcore_iter >= lcore_count)\n \t\t\tlcore_iter = 0;\n \n-\t\tret = rte_service_start(s);\n+\t\tret = rte_service_runstate_set(i, 1);\n \t\tif (ret)\n \t\t\treturn -ENOEXEC;\n \t}\ndiff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\nindex 452ae1c..557b5e7 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,7 +221,6 @@ EXPERIMENTAL {\n \trte_service_get_by_id;\n \trte_service_get_by_name;\n \trte_service_get_count;\n-\trte_service_is_running;\n \trte_service_lcore_add;\n \trte_service_lcore_count;\n \trte_service_lcore_del;\n@@ -234,10 +233,10 @@ EXPERIMENTAL {\n \trte_service_probe_capability;\n \trte_service_register;\n \trte_service_reset;\n+\trte_service_runstate_get;\n+\trte_service_runstate_set;\n \trte_service_set_stats_enable;\n-\trte_service_start;\n \trte_service_start_with_defaults;\n-\trte_service_stop;\n \trte_service_unregister;\n \n } DPDK_17.08;\ndiff --git a/test/test/test_service_cores.c b/test/test/test_service_cores.c\nindex 72d774d..ba252c5 100644\n--- a/test/test/test_service_cores.c\n+++ b/test/test/test_service_cores.c\n@@ -274,7 +274,6 @@ static int\n service_start_stop(void)\n {\n \tconst uint32_t sid = 0;\n-\tstruct rte_service_spec *s = rte_service_get_by_id(0);\n \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@@ -283,19 +282,19 @@ service_start_stop(void)\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(s),\n+\tTEST_ASSERT_EQUAL(0, rte_service_runstate_get(sid),\n \t\t\t\"Error: Service should be stopped\");\n \n-\tTEST_ASSERT_EQUAL(0, rte_service_stop(s),\n+\tTEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0),\n \t\t\t\"Error: Service stopped returned non-zero\");\n \n-\tTEST_ASSERT_EQUAL(0, rte_service_is_running(s),\n+\tTEST_ASSERT_EQUAL(0, rte_service_runstate_get(sid),\n \t\t\t\"Error: Service is running - should be stopped\");\n \n-\tTEST_ASSERT_EQUAL(0, rte_service_start(s),\n+\tTEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 1),\n \t\t\t\"Error: Service start returned non-zero\");\n \n-\tTEST_ASSERT_EQUAL(1, rte_service_is_running(s),\n+\tTEST_ASSERT_EQUAL(1, rte_service_runstate_get(sid),\n \t\t\t\"Error: Service is not running\");\n \n \treturn unregister_all();\n@@ -474,9 +473,8 @@ service_threaded_test(int mt_safe)\n \tTEST_ASSERT_EQUAL(0, rte_service_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 \tconst uint32_t sid = 0;\n-\tTEST_ASSERT_EQUAL(0, rte_service_start(s),\n+\tTEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 1),\n \t\t\t\"Starting valid service failed\");\n \tTEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_1, 1),\n \t\t\t\"Failed to enable lcore 1 on mt safe service\");\n@@ -493,7 +491,7 @@ service_threaded_test(int mt_safe)\n \tTEST_ASSERT_EQUAL(1, test_params[1],\n \t\t\t\"MT Safe service not run by two cores concurrently\");\n \n-\tTEST_ASSERT_EQUAL(0, rte_service_stop(s),\n+\tTEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0),\n \t\t\t\"Failed to stop MT Safe service\");\n \n \tunregister_all();\n@@ -532,8 +530,7 @@ service_lcore_start_stop(void)\n {\n \t/* start service core and service, create mapping so tick() runs */\n \tconst uint32_t sid = 0;\n-\tstruct rte_service_spec *s = rte_service_get_by_id(0);\n-\tTEST_ASSERT_EQUAL(0, rte_service_start(s),\n+\tTEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 1),\n \t\t\t\"Starting valid service failed\");\n \tTEST_ASSERT_EQUAL(-EINVAL, rte_service_map_lcore_set(sid, slcore_id, 1),\n \t\t\t\"Enabling valid service on non-service core must fail\");\n",
    "prefixes": [
        "dpdk-dev",
        "4/8"
    ]
}