summaryrefslogtreecommitdiff
path: root/service/src
diff options
context:
space:
mode:
author童宗振 <[email protected]>2024-09-19 11:14:34 +0000
committer童宗振 <[email protected]>2024-09-19 11:14:34 +0000
commit34732cc360c7e3f70c3bb58b5f2414cead6cea05 (patch)
treeae59b0a7d86896bb4700d168f6713290935f20dd /service/src
parent42c0570c2280d6823874358d29a78d7fc0ed2ec4 (diff)
Adjust the service core code
Diffstat (limited to 'service/src')
-rw-r--r--service/src/core.c83
1 files changed, 22 insertions, 61 deletions
diff --git a/service/src/core.c b/service/src/core.c
index 04d8917..96e2c82 100644
--- a/service/src/core.c
+++ b/service/src/core.c
@@ -737,7 +737,7 @@ void __setproctitle_init(int argc, char ** argv, char ** envp)
struct service_performance_monit
{
- unsigned int service_id;
+ uint32_t service_id;
uint64_t service_last_cycles;
uint64_t service_last_call_counts;
};
@@ -784,8 +784,7 @@ cJSON * service_monit_loop(struct sc_main * sc)
return j_root;
}
-static int __rte_service_register_helper(const struct rte_service_spec * spec, const cpu_set_t * cpu_set,
- unsigned int * out_service_id)
+static int service_register_helper(const struct rte_service_spec * spec, unsigned int * out_service_id)
{
int ret = 0;
uint32_t service_id = 0;
@@ -807,22 +806,6 @@ static int __rte_service_register_helper(const struct rte_service_spec * spec, c
return ret;
}
- // static_assert(RTE_MAX_LCORE <= CPU_SETSIZE, "RTE_MAX_LCORE must less than CPU_SETSIZE");
- for (unsigned int lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
- {
- if (!CPU_ISSET(lcore_id, cpu_set))
- continue;
-
- ret = rte_service_map_lcore_set(service_id, lcore_id, 1);
- if (ret < 0)
- {
- MR_ERROR("Failed at set lcore map for service %s: lcore_id = %d, ret = %d", spec->name, lcore_id, ret);
- return ret;
- }
-
- MR_INFO("Setup core %u for service %s...", lcore_id, spec->name);
- }
-
*out_service_id = service_id;
return 0;
}
@@ -1319,58 +1302,36 @@ int marsio_service_main(int argc, char * argv[])
.socket_id = 0,
};
- /* set eal all cores run as service cores */
- RTE_LCORE_FOREACH(lcore_id_iter)
- {
- ret = rte_service_lcore_add(lcore_id_iter);
- if (ret && ret != -EALREADY)
- {
- MR_ERROR("Failed at add core %u to service cores: ret = %d", lcore_id_iter, ret);
- goto quit;
- }
- }
-
-#if 0
- ret = __rte_service_register_helper(&sw_fwd_service_spec, &sc->cpu_set_io, &sw_info_sw_fwd.service_id);
- if (unlikely(ret < 0))
- {
- MR_ERROR("Failed at starting service %s", sw_fwd_service_spec.name);
- goto quit;
- }
-
- ret = __rte_service_register_helper(&sw_vlan_base_fwd_service_spec, &sc->cpu_set_io, &sw_info_sw_vlan_fwd.service_id);
- if(unlikely(ret < 0))
- {
- MR_ERROR("Failed at starting service %s", sw_vlan_base_fwd_service_spec.name);
- goto quit;
- }
-
- ret = __rte_service_register_helper(&smartoffload_spec, &sc->cpu_set_offload, &sw_info_smartoffload.service_id);
- if (unlikely(ret < 0))
- {
- MR_ERROR("Failed at starting service %s", smartoffload_spec.name);
- goto quit;
- }
-#endif
-
- ret = __rte_service_register_helper(&node_spec, &sc->cpu_set_io, &sw_info_node.service_id);
+ ret = service_register_helper(&node_spec, &sw_info_node.service_id);
if (unlikely(ret < 0))
{
MR_ERROR("Failed at starting service %s", node_spec.name);
goto quit;
}
- cpu_set_t cpu_set_service;
- CPU_ZERO(&cpu_set_service);
-
- CPU_OR(&cpu_set_service, &cpu_set_service, &sc->cpu_set_io);
- CPU_OR(&cpu_set_service, &cpu_set_service, &sc->cpu_set_offload);
-
for (unsigned int lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
{
- if (!CPU_ISSET(lcore_id, &cpu_set_service))
+ if (!CPU_ISSET(lcore_id, &sc->cpu_set_io))
continue;
+ ret = rte_service_lcore_add(lcore_id);
+ if (ret && ret != -EALREADY)
+ {
+ MR_ERROR("Failed at add core %u to service cores: ret = %d", lcore_id, ret);
+ goto quit;
+ }
+
+ ret = rte_service_map_lcore_set(sw_info_node.service_id, lcore_id, 1);
+ if (rte_service_map_lcore_get(sw_info_node.service_id, lcore_id) == 1)
+ {
+ MR_INFO("Setup core %u for service %s...", lcore_id, node_spec.name);
+ }
+ else
+ {
+ MR_ERROR("Failed at set lcore map for service %s: lcore_id = %d, ret = %d", node_spec.name, lcore_id, ret);
+ goto quit;
+ }
+
ret = rte_service_lcore_start(lcore_id);
if (ret && ret != -EALREADY)
{