get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 29586,
    "url": "https://patches.dpdk.org/api/patches/29586/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1507114491-144338-2-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": "<1507114491-144338-2-git-send-email-harry.van.haaren@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1507114491-144338-2-git-send-email-harry.van.haaren@intel.com",
    "date": "2017-10-04T10:54:49",
    "name": "[dpdk-dev,1/3] service: add attribute get function",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "5f46733b4f26de30d17d6be8404b7c12c67af5d9",
    "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/1507114491-144338-2-git-send-email-harry.van.haaren@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/29586/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/29586/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 91BD11B63E;\n\tWed,  4 Oct 2017 12:54:34 +0200 (CEST)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 410661B625\n\tfor <dev@dpdk.org>; Wed,  4 Oct 2017 12:54:31 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Oct 2017 03:54:29 -0700",
            "from silpixa00398672.ir.intel.com ([10.237.223.128])\n\tby fmsmga002.fm.intel.com with ESMTP; 04 Oct 2017 03:54:28 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.42,477,1500966000\"; d=\"scan'208\";\n\ta=\"1226897085\"",
        "From": "Harry van Haaren <harry.van.haaren@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Harry van Haaren <harry.van.haaren@intel.com>",
        "Date": "Wed,  4 Oct 2017 11:54:49 +0100",
        "Message-Id": "<1507114491-144338-2-git-send-email-harry.van.haaren@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1507114491-144338-1-git-send-email-harry.van.haaren@intel.com>",
        "References": "<1507114491-144338-1-git-send-email-harry.van.haaren@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 1/3] service: add attribute get function",
        "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 adds a new function to the service API to allow\nthe application to retrieve items about each individual service\nin the system. A unit test checks the return values of a variety\nof invalid and valid calls.\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     | 17 +++++++\n lib/librte_eal/common/rte_service.c             | 18 ++++++++\n lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +\n test/test/test_service_cores.c                  | 61 +++++++++++++++++++++++++\n 5 files changed, 98 insertions(+)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map\nindex 47a09ea..8c9c5f6 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_attr_get;\n \trte_service_component_register;\n \trte_service_component_unregister;\n \trte_service_component_runstate_set;\ndiff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h\nindex 21da739..9267a0e 100644\n--- a/lib/librte_eal/common/include/rte_service.h\n+++ b/lib/librte_eal/common/include/rte_service.h\n@@ -360,6 +360,23 @@ int32_t rte_service_lcore_count_services(uint32_t lcore);\n  */\n int32_t rte_service_dump(FILE *f, uint32_t id);\n \n+/**\n+ * Returns the number of cycles that this service has consumed\n+ */\n+#define RTE_SERVICE_ATTR_CYCLES 0\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * Get an attribute from a service.\n+ *\n+ * @retval 0 Success, the attribute value has been written to *attr_value*.\n+ *         -EINVAL Invalid id, attr_id or attr_value was NULL.\n+ */\n+int32_t rte_service_attr_get(uint32_t id, uint32_t attr_id,\n+\t\t\t     uint32_t *attr_value);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c\nindex e598e16..4935804 100644\n--- a/lib/librte_eal/common/rte_service.c\n+++ b/lib/librte_eal/common/rte_service.c\n@@ -644,6 +644,24 @@ rte_service_lcore_stop(uint32_t lcore)\n \treturn 0;\n }\n \n+int32_t\n+rte_service_attr_get(uint32_t id, uint32_t attr_id, uint32_t *attr_value)\n+{\n+\tstruct rte_service_spec_impl *s;\n+\tSERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL);\n+\n+\tif (!attr_value)\n+\t\treturn -EINVAL;\n+\n+\tswitch (attr_id) {\n+\tcase RTE_SERVICE_ATTR_CYCLES:\n+\t\t*attr_value = s->cycles_spent;\n+\t\treturn 0;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+}\n+\n static void\n rte_service_dump_one(FILE *f, struct rte_service_spec_impl *s,\n \t\t     uint64_t all_cycles, uint32_t reset)\ndiff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\nindex 8c08b8d..c2fad10 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_attr_get;\n \trte_service_component_register;\n \trte_service_component_unregister;\n \trte_service_component_runstate_set;\ndiff --git a/test/test/test_service_cores.c b/test/test/test_service_cores.c\nindex ee8313e..7d2e42d 100644\n--- a/test/test/test_service_cores.c\n+++ b/test/test/test_service_cores.c\n@@ -266,6 +266,66 @@ service_name(void)\n \treturn unregister_all();\n }\n \n+/* verify service attr get */\n+static int\n+service_attr_get(void)\n+{\n+\tstruct rte_service_spec service;\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+\tservice.capabilities |= RTE_SERVICE_CAP_MT_SAFE;\n+\tuint32_t id;\n+\tTEST_ASSERT_EQUAL(0, rte_service_component_register(&service, &id),\n+\t\t\t\"Register of  service failed\");\n+\trte_service_component_runstate_set(id, 1);\n+\tTEST_ASSERT_EQUAL(0, rte_service_runstate_set(id, 1),\n+\t\t\t\"Error: Service start returned non-zero\");\n+\trte_service_set_stats_enable(id, 1);\n+\n+\tuint32_t attr_id = UINT32_MAX;\n+\tuint32_t attr_value = 0xdead;\n+\t/* check error return values */\n+\tTEST_ASSERT_EQUAL(-EINVAL, rte_service_attr_get(id, attr_id,\n+\t\t\t\t\t\t\t&attr_value),\n+\t\t\t\"Invalid attr_id didn't return -EINVAL\");\n+\n+\tattr_id = RTE_SERVICE_ATTR_CYCLES;\n+\tTEST_ASSERT_EQUAL(-EINVAL, rte_service_attr_get(UINT32_MAX, attr_id,\n+\t\t\t\t\t\t\t&attr_value),\n+\t\t\t\"Invalid service id didn't return -EINVAL\");\n+\n+\tTEST_ASSERT_EQUAL(-EINVAL, rte_service_attr_get(id, attr_id, NULL),\n+\t\t\t\"Invalid attr_value pointer id didn't return -EINVAL\");\n+\n+\t/* check correct (zero) return value and correct value (zero) */\n+\tTEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_id, &attr_value),\n+\t\t\t\"Valid attr_get() call didn't return success\");\n+\tTEST_ASSERT_EQUAL(0, attr_value,\n+\t\t\t\"attr_get() call didn't set correct cycles (zero)\");\n+\n+\t/* Call service to increment cycle count */\n+\tTEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id),\n+\t\t\t\"Service core add did not return zero\");\n+\tTEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(id, slcore_id, 1),\n+\t\t\t\"Enabling valid service and core failed\");\n+\tTEST_ASSERT_EQUAL(0, rte_service_lcore_start(slcore_id),\n+\t\t\t\"Starting service core failed\");\n+\n+\t/* wait for the service lcore to run */\n+\trte_delay_ms(200);\n+\n+\tTEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_id, &attr_value),\n+\t\t\t\"Valid attr_get() call didn't return success\");\n+\tint cycles_gt_zero = attr_value > 0;\n+\tTEST_ASSERT_EQUAL(1, cycles_gt_zero,\n+\t\t\t\"attr_get() failed to get cycles (expected > zero)\");\n+\n+\trte_service_lcore_stop(slcore_id);\n+\n+\treturn unregister_all();\n+}\n+\n /* verify service dump */\n static int\n service_dump(void)\n@@ -606,6 +666,7 @@ static struct unit_test_suite service_tests  = {\n \t\tTEST_CASE_ST(dummy_register, NULL, service_name),\n \t\tTEST_CASE_ST(dummy_register, NULL, service_get_by_name),\n \t\tTEST_CASE_ST(dummy_register, NULL, service_dump),\n+\t\tTEST_CASE_ST(dummy_register, NULL, service_attr_get),\n \t\tTEST_CASE_ST(dummy_register, NULL, service_probe_capability),\n \t\tTEST_CASE_ST(dummy_register, NULL, service_start_stop),\n \t\tTEST_CASE_ST(dummy_register, NULL, service_lcore_add_del),\n",
    "prefixes": [
        "dpdk-dev",
        "1/3"
    ]
}