From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id A7F2D7D0F for ; Mon, 21 Aug 2017 14:58:29 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.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";a="1208383268" Received: from silpixa00398672.ir.intel.com ([10.237.223.128]) by fmsmga002.fm.intel.com with ESMTP; 21 Aug 2017 05:58:26 -0700 From: Harry van Haaren To: dev@dpdk.org Cc: Harry van Haaren Date: Mon, 21 Aug 2017 13:58:03 +0100 Message-Id: <1503320296-51122-3-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> <1503320296-51122-1-git-send-email-harry.van.haaren@intel.com> Subject: [dpdk-dev] [PATCH v2 02/15] service: rework lcore to service map functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 12:58:30 -0000 This commit updates the APIs exposed to map service cores and services. The previous APIs required a pointer to a service, and used two separate functions for enable and disable. The new API uses an integer ID for the service and has a parameter for map or unmap. Unit tests are updated and passing, and the map file is updated to the new function names. Signed-off-by: Harry van Haaren --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 5 ++- lib/librte_eal/common/include/rte_service.h | 43 +++++++++---------------- lib/librte_eal/common/rte_service.c | 31 ++++++++---------- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 5 ++- test/test/test_service_cores.c | 27 +++++++++------- 5 files changed, 48 insertions(+), 63 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index aac6fd7..f626a6f 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -212,13 +212,10 @@ EXPERIMENTAL { rte_eal_devargs_remove; rte_eal_hotplug_add; rte_eal_hotplug_remove; - rte_service_disable_on_lcore; rte_service_dump; - rte_service_enable_on_lcore; rte_service_get_by_id; rte_service_get_by_name; rte_service_get_count; - rte_service_get_enabled_on_lcore; rte_service_is_running; rte_service_lcore_add; rte_service_lcore_count; @@ -227,6 +224,8 @@ EXPERIMENTAL { rte_service_lcore_reset_all; rte_service_lcore_start; rte_service_lcore_stop; + rte_service_map_lcore_get; + rte_service_map_lcore_set; rte_service_probe_capability; rte_service_register; rte_service_reset; diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h index bed1a61..de69695 100644 --- a/lib/librte_eal/common/include/rte_service.h +++ b/lib/librte_eal/common/include/rte_service.h @@ -152,10 +152,10 @@ int32_t rte_service_probe_capability(uint32_t id, uint32_t capability); * @warning * @b EXPERIMENTAL: this API may change without prior notice * - * Enable a core to run a service. + * Map or unmap a lcore to a service. * - * Each core can be added or removed from running specific services. This - * functions adds *lcore* to the set of cores that will run *service*. + * Each core can be added or removed from running a specific service. This + * function enables or disables *lcore* to run *service_id*. * * If multiple cores are enabled on a service, an atomic is used to ensure that * only one cores runs the service at a time. The exception to this is when @@ -163,43 +163,30 @@ int32_t rte_service_probe_capability(uint32_t id, uint32_t capability); * called RTE_SERVICE_CAP_MT_SAFE. With the multi-thread safe capability set, * the service function can be run on multiple threads at the same time. * - * @retval 0 lcore added successfully - * @retval -EINVAL An invalid service or lcore was provided. - */ -int32_t rte_service_enable_on_lcore(struct rte_service_spec *service, - uint32_t lcore); - -/** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice - * - * Disable a core to run a service. + * @param service_id the service to apply the lcore to + * @param lcore The lcore that will be mapped to service + * @param enable Zero to unmap or disable the core, non-zero to enable * - * Each core can be added or removed from running specific services. This - * functions removes *lcore* to the set of cores that will run *service*. - * - * @retval 0 Lcore removed successfully + * @retval 0 lcore map updated successfully * @retval -EINVAL An invalid service or lcore was provided. */ -int32_t rte_service_disable_on_lcore(struct rte_service_spec *service, - uint32_t lcore); +int32_t rte_service_map_lcore_set(uint32_t service_id, uint32_t lcore, + uint32_t enable); /** * @warning * @b EXPERIMENTAL: this API may change without prior notice * - * Return if an lcore is enabled for the service. + * Retrieve the mapping of an lcore to a service. * - * This function allows the application to query if *lcore* is currently set to - * run *service*. + * @param service_id the service to apply the lcore to + * @param lcore The lcore that will be mapped to service * - * @retval 1 Lcore enabled on this lcore - * @retval 0 Lcore disabled on this lcore + * @retval 1 lcore is mapped to service + * @retval 0 lcore is not mapped to service * @retval -EINVAL An invalid service or lcore was provided. */ -int32_t rte_service_get_enabled_on_lcore(struct rte_service_spec *service, - uint32_t lcore); - +int32_t rte_service_map_lcore_get(uint32_t service_id, uint32_t lcore); /** * @warning diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index c969406..c5a8d0d 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -436,7 +436,7 @@ rte_service_start_with_defaults(void) * should multiplex to a single core, or 1:1 if there are the * same amount of services as service-cores */ - ret = rte_service_enable_on_lcore(s, ids[lcore_iter]); + ret = rte_service_map_lcore_set(i, ids[lcore_iter], 1); if (ret) return -ENODEV; @@ -492,28 +492,25 @@ service_update(struct rte_service_spec *service, uint32_t lcore, return 0; } -int32_t rte_service_get_enabled_on_lcore(struct rte_service_spec *service, - uint32_t lcore) -{ - uint32_t enabled; - int ret = service_update(service, lcore, 0, &enabled); - if (ret == 0) - return enabled; - return -EINVAL; -} - int32_t -rte_service_enable_on_lcore(struct rte_service_spec *service, uint32_t lcore) +rte_service_map_lcore_set(uint32_t id, uint32_t lcore, uint32_t enabled) { - uint32_t on = 1; - return service_update(service, lcore, &on, 0); + struct rte_service_spec_impl *s; + SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL); + uint32_t on = enabled > 0; + return service_update(&s->spec, lcore, &on, 0); } int32_t -rte_service_disable_on_lcore(struct rte_service_spec *service, uint32_t lcore) +rte_service_map_lcore_get(uint32_t id, uint32_t lcore) { - uint32_t off = 0; - return service_update(service, lcore, &off, 0); + struct rte_service_spec_impl *s; + SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL); + uint32_t enabled; + int ret = service_update(&s->spec, lcore, 0, &enabled); + if (ret == 0) + return enabled; + return ret; } int32_t rte_service_lcore_reset_all(void) diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 3a8f154..452ae1c 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -217,13 +217,10 @@ EXPERIMENTAL { rte_eal_devargs_remove; rte_eal_hotplug_add; rte_eal_hotplug_remove; - rte_service_disable_on_lcore; rte_service_dump; - rte_service_enable_on_lcore; rte_service_get_by_id; rte_service_get_by_name; rte_service_get_count; - rte_service_get_enabled_on_lcore; rte_service_is_running; rte_service_lcore_add; rte_service_lcore_count; @@ -232,6 +229,8 @@ EXPERIMENTAL { rte_service_lcore_reset_all; rte_service_lcore_start; rte_service_lcore_stop; + rte_service_map_lcore_get; + rte_service_map_lcore_set; rte_service_probe_capability; rte_service_register; rte_service_reset; diff --git a/test/test/test_service_cores.c b/test/test/test_service_cores.c index 940bc62..fd63efd 100644 --- a/test/test/test_service_cores.c +++ b/test/test/test_service_cores.c @@ -273,12 +273,13 @@ service_dump(void) static int service_start_stop(void) { + const uint32_t sid = 0; struct rte_service_spec *service = rte_service_get_by_id(0); /* is_running() returns if service is running and slcore is mapped */ TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id), "Service core add did not return zero"); - int ret = rte_service_enable_on_lcore(service, slcore_id); + int ret = rte_service_map_lcore_set(sid, slcore_id, 1); TEST_ASSERT_EQUAL(0, ret, "Enabling service core, expected 0 got %d", ret); @@ -313,12 +314,12 @@ service_remote_launch_func(void *arg) static int service_lcore_en_dis_able(void) { - struct rte_service_spec *s = rte_service_get_by_id(0); + const uint32_t sid = 0; /* expected failure cases */ - TEST_ASSERT_EQUAL(-EINVAL, rte_service_enable_on_lcore(s, 100000), + TEST_ASSERT_EQUAL(-EINVAL, rte_service_map_lcore_set(sid, 100000, 1), "Enable on invalid core did not fail"); - TEST_ASSERT_EQUAL(-EINVAL, rte_service_disable_on_lcore(s, 100000), + TEST_ASSERT_EQUAL(-EINVAL, rte_service_map_lcore_set(sid, 100000, 0), "Disable on invalid core did not fail"); /* add service core to allow enabling */ @@ -326,15 +327,15 @@ service_lcore_en_dis_able(void) "Add service core failed when not in use before"); /* valid enable */ - TEST_ASSERT_EQUAL(0, rte_service_enable_on_lcore(s, slcore_id), + TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_id, 1), "Enabling valid service and core failed"); - TEST_ASSERT_EQUAL(1, rte_service_get_enabled_on_lcore(s, slcore_id), + TEST_ASSERT_EQUAL(1, rte_service_map_lcore_get(sid, slcore_id), "Enabled core returned not-enabled"); /* valid disable */ - TEST_ASSERT_EQUAL(0, rte_service_disable_on_lcore(s, slcore_id), + TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_id, 0), "Disabling valid service and lcore failed"); - TEST_ASSERT_EQUAL(0, rte_service_get_enabled_on_lcore(s, slcore_id), + TEST_ASSERT_EQUAL(0, rte_service_map_lcore_get(sid, slcore_id), "Disabled core returned enabled"); /* call remote_launch to verify that app can launch ex-service lcore */ @@ -474,11 +475,12 @@ service_threaded_test(int mt_safe) "Register of MT SAFE service failed"); struct rte_service_spec *s = rte_service_get_by_id(0); + const uint32_t sid = 0; TEST_ASSERT_EQUAL(0, rte_service_start(s), "Starting valid service failed"); - TEST_ASSERT_EQUAL(0, rte_service_enable_on_lcore(s, slcore_1), + TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_1, 1), "Failed to enable lcore 1 on mt safe service"); - TEST_ASSERT_EQUAL(0, rte_service_enable_on_lcore(s, slcore_2), + TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_2, 1), "Failed to enable lcore 2 on mt safe service"); rte_service_lcore_start(slcore_1); rte_service_lcore_start(slcore_2); @@ -529,10 +531,11 @@ static int service_lcore_start_stop(void) { /* start service core and service, create mapping so tick() runs */ + const uint32_t sid = 0; struct rte_service_spec *s = rte_service_get_by_id(0); TEST_ASSERT_EQUAL(0, rte_service_start(s), "Starting valid service failed"); - TEST_ASSERT_EQUAL(-EINVAL, rte_service_enable_on_lcore(s, slcore_id), + TEST_ASSERT_EQUAL(-EINVAL, rte_service_map_lcore_set(sid, slcore_id, 1), "Enabling valid service on non-service core must fail"); /* core start */ @@ -540,7 +543,7 @@ service_lcore_start_stop(void) "Service core start without add should return EINVAL"); TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id), "Service core add did not return zero"); - TEST_ASSERT_EQUAL(0, rte_service_enable_on_lcore(s, slcore_id), + TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_id, 1), "Enabling valid service on valid core failed"); TEST_ASSERT_EQUAL(0, rte_service_lcore_start(slcore_id), "Service core start after add failed"); -- 2.7.4