X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Ffreebsd%2Feal_thread.c;h=1dce9b04f24ad7601292e5b1c2f955a0bcf79b5b;hb=5b38d8cd4663;hp=925737d34dfa360c29b429ef93d14535d95cc184;hpb=f2fc83b40f06da6a6b2476005279ba52d4ce3c44;p=dpdk.git diff --git a/lib/librte_eal/freebsd/eal_thread.c b/lib/librte_eal/freebsd/eal_thread.c index 925737d34d..1dce9b04f2 100644 --- a/lib/librte_eal/freebsd/eal_thread.c +++ b/lib/librte_eal/freebsd/eal_thread.c @@ -20,117 +20,91 @@ #include #include #include +#include #include "eal_private.h" #include "eal_thread.h" -RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY; -RTE_DEFINE_PER_LCORE(unsigned, _socket_id) = (unsigned)SOCKET_ID_ANY; -RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset); - /* - * Send a message to a slave lcore identified by slave_id to call a + * Send a message to a worker lcore identified by worker_id to call a * function f with argument arg. Once the execution is done, the * remote lcore switch in FINISHED state. */ int -rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id) +rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned worker_id) { int n; char c = 0; - int m2s = lcore_config[slave_id].pipe_master2slave[1]; - int s2m = lcore_config[slave_id].pipe_slave2master[0]; + int m2w = lcore_config[worker_id].pipe_main2worker[1]; + int w2m = lcore_config[worker_id].pipe_worker2main[0]; + int rc = -EBUSY; - if (lcore_config[slave_id].state != WAIT) - return -EBUSY; + if (lcore_config[worker_id].state != WAIT) + goto finish; - lcore_config[slave_id].f = f; - lcore_config[slave_id].arg = arg; + lcore_config[worker_id].f = f; + lcore_config[worker_id].arg = arg; /* send message */ n = 0; while (n == 0 || (n < 0 && errno == EINTR)) - n = write(m2s, &c, 1); + n = write(m2w, &c, 1); if (n < 0) rte_panic("cannot write on configuration pipe\n"); /* wait ack */ do { - n = read(s2m, &c, 1); + n = read(w2m, &c, 1); } while (n < 0 && errno == EINTR); if (n <= 0) rte_panic("cannot read on configuration pipe\n"); - return 0; -} - -/* set affinity for current thread */ -static int -eal_thread_set_affinity(void) -{ - unsigned lcore_id = rte_lcore_id(); - - /* acquire system unique id */ - rte_gettid(); - - /* update EAL thread core affinity */ - return rte_thread_set_affinity(&lcore_config[lcore_id].cpuset); -} - -void eal_thread_init_master(unsigned lcore_id) -{ - /* set the lcore ID in per-lcore memory area */ - RTE_PER_LCORE(_lcore_id) = lcore_id; - - /* set CPU affinity */ - if (eal_thread_set_affinity() < 0) - rte_panic("cannot set affinity\n"); + rc = 0; +finish: + rte_eal_trace_thread_remote_launch(f, arg, worker_id, rc); + return rc; } /* main loop of threads */ -__attribute__((noreturn)) void * +__rte_noreturn void * eal_thread_loop(__rte_unused void *arg) { char c; int n, ret; unsigned lcore_id; pthread_t thread_id; - int m2s, s2m; + int m2w, w2m; char cpuset[RTE_CPU_AFFINITY_STR_LEN]; thread_id = pthread_self(); /* retrieve our lcore_id from the configuration structure */ - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { if (thread_id == lcore_config[lcore_id].thread_id) break; } if (lcore_id == RTE_MAX_LCORE) rte_panic("cannot retrieve lcore id\n"); - m2s = lcore_config[lcore_id].pipe_master2slave[0]; - s2m = lcore_config[lcore_id].pipe_slave2master[1]; - - /* set the lcore ID in per-lcore memory area */ - RTE_PER_LCORE(_lcore_id) = lcore_id; + m2w = lcore_config[lcore_id].pipe_main2worker[0]; + w2m = lcore_config[lcore_id].pipe_worker2main[1]; - /* set CPU affinity */ - if (eal_thread_set_affinity() < 0) - rte_panic("cannot set affinity\n"); - - ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset)); + __rte_thread_init(lcore_id, &lcore_config[lcore_id].cpuset); + ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset)); RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n", lcore_id, thread_id, cpuset, ret == 0 ? "" : "..."); + rte_eal_trace_thread_lcore_ready(lcore_id, cpuset); + /* read on our pipe to get commands */ while (1) { void *fct_arg; /* wait command */ do { - n = read(m2s, &c, 1); + n = read(m2w, &c, 1); } while (n < 0 && errno == EINTR); if (n <= 0) @@ -141,7 +115,7 @@ eal_thread_loop(__rte_unused void *arg) /* send ack */ n = 0; while (n == 0 || (n < 0 && errno == EINTR)) - n = write(s2m, &c, 1); + n = write(w2m, &c, 1); if (n < 0) rte_panic("cannot write on configuration pipe\n"); @@ -175,3 +149,12 @@ int rte_thread_setname(pthread_t id, const char *name) pthread_set_name_np(id, name); return 0; } + +int rte_thread_getname(pthread_t id, char *name, size_t len) +{ + RTE_SET_USED(id); + RTE_SET_USED(name); + RTE_SET_USED(len); + + return -ENOTSUP; +}