diff options
author | Zoltan Kiss <zoltan.kiss@linaro.org> | 2015-12-16 16:49:51 +0000 |
---|---|---|
committer | Zoltan Kiss <zoltan.kiss@linaro.org> | 2015-12-18 17:43:05 +0000 |
commit | 9eca3dd5deab6805b2d1989c71e09d37a431a47c (patch) | |
tree | 08219b12b90e70ff9972ed561515add1e7fde4f8 /platform/linux-dpdk | |
parent | 44ca0a666b77db5f863a2a9d27b33c74f30e6912 (diff) |
linux-dpdk: cpumask: go back to linux-generic cpumask implementation
The only reason for a separate one is because odp_cpumask_default_worker()
goes through the lcore list to get this data for us. But with the master
thread's affinity fixed there is no need for that, the linux-generic way of
using the thread affinity is good for linux-dpdk as well.
Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
Diffstat (limited to 'platform/linux-dpdk')
-rw-r--r-- | platform/linux-dpdk/Makefile.am | 3 | ||||
-rw-r--r-- | platform/linux-dpdk/odp_cpumask.c | 233 |
2 files changed, 2 insertions, 234 deletions
diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index 03c73215f..b4bd85e2f 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -112,7 +112,8 @@ __LIB__libodp_la_SOURCES = \ ../linux-generic/odp_barrier.c \ odp_buffer.c \ ../linux-generic/odp_cpu.c \ - odp_cpumask.c \ + ../linux-generic/odp_cpumask.c \ + ../linux-generic/odp_cpumask_task.c \ ../linux-generic/odp_crypto.c \ odp_errno.c \ ../linux-generic/odp_event.c \ diff --git a/platform/linux-dpdk/odp_cpumask.c b/platform/linux-dpdk/odp_cpumask.c deleted file mode 100644 index 98b51c727..000000000 --- a/platform/linux-dpdk/odp_cpumask.c +++ /dev/null @@ -1,233 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include <sched.h> -#include <pthread.h> - -#include <odp/cpumask.h> -#include <odp_debug_internal.h> - -#include <stdlib.h> -#include <string.h> - -#include <rte_lcore.h> - -void odp_cpumask_from_str(odp_cpumask_t *mask, const char *str_in) -{ - cpu_set_t cpuset; - const char *str = str_in; - const char *p; - int cpu = 0; - int len = strlen(str); - - CPU_ZERO(&cpuset); - odp_cpumask_zero(mask); - - /* Strip leading "0x"/"0X" if present and verify length */ - if ((len >= 2) && ((str[1] == 'x') || (str[1] == 'X'))) { - str += 2; - len -= 2; - } - if (!len) - return; - - /* Walk string from LSB setting cpu bits */ - for (p = str + len - 1; (len > 0) && (cpu < CPU_SETSIZE); p--, len--) { - char c = *p; - int value; - int idx; - - /* Convert hex nibble, abort when invalid value found */ - if ((c >= '0') && (c <= '9')) - value = c - '0'; - else if ((c >= 'A') && (c <= 'F')) - value = c - 'A' + 10; - else if ((c >= 'a') && (c <= 'f')) - value = c - 'a' + 10; - else - return; - - /* Walk converted nibble and set bits in mask */ - for (idx = 0; idx < 4; idx++, cpu++) - if (value & (1 << idx)) - CPU_SET(cpu, &cpuset); - } - - /* Copy the computed mask */ - memcpy(&mask->set, &cpuset, sizeof(cpuset)); -} - -int32_t odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, int32_t len) -{ - char *p = str; - int cpu = odp_cpumask_last(mask); - int nibbles; - int value; - - /* Handle bad string length, need at least 4 chars for "0x0" and - * terminating null char */ - if (len < 4) - return -1; /* Failure */ - - /* Handle no CPU found */ - if (cpu < 0) { - strcpy(str, "0x0"); - return strlen(str) + 1; /* Success */ - } - /* CPU was found and cpu >= 0 */ - - /* Compute number of nibbles in cpumask that have bits set */ - nibbles = (cpu / 4) + 1; - - /* Verify minimum space (account for "0x" and termination) */ - if (len < (3 + nibbles)) - return -1; /* Failure */ - - /* Prefix */ - *p++ = '0'; - *p++ = 'x'; - - /* - * Now we can scan the cpus down to zero and - * build the string one nibble at a time - */ - value = 0; - do { - /* Set bit to go into the current nibble */ - if (CPU_ISSET(cpu, &mask->set)) - value |= 1 << (cpu % 4); - - /* If we are on a nibble boundary flush value to string */ - if (0 == (cpu % 4)) { - if (value < 0xA) - *p++ = '0' + value; - else - *p++ = 'A' + value - 0xA; - value = 0; - } - } while (cpu--); - - /* Terminate the string */ - *p++ = 0; - return p - str; /* Success */ -} - -void odp_cpumask_zero(odp_cpumask_t *mask) -{ - CPU_ZERO(&mask->set); -} - -void odp_cpumask_set(odp_cpumask_t *mask, int cpu) -{ - CPU_SET(cpu, &mask->set); -} - -void odp_cpumask_setall(odp_cpumask_t *mask) -{ - int cpu; - - for (cpu = 0; cpu < CPU_SETSIZE; cpu++) - CPU_SET(cpu, &mask->set); -} - -void odp_cpumask_clr(odp_cpumask_t *mask, int cpu) -{ - CPU_CLR(cpu, &mask->set); -} - -int odp_cpumask_isset(const odp_cpumask_t *mask, int cpu) -{ - return CPU_ISSET(cpu, &mask->set); -} - -int odp_cpumask_count(const odp_cpumask_t *mask) -{ - return CPU_COUNT(&mask->set); -} - -void odp_cpumask_and(odp_cpumask_t *dest, const odp_cpumask_t *src1, - const odp_cpumask_t *src2) -{ - CPU_AND(&dest->set, &src1->set, &src2->set); -} - -void odp_cpumask_or(odp_cpumask_t *dest, const odp_cpumask_t *src1, - const odp_cpumask_t *src2) -{ - CPU_OR(&dest->set, &src1->set, &src2->set); -} - -void odp_cpumask_xor(odp_cpumask_t *dest, const odp_cpumask_t *src1, - const odp_cpumask_t *src2) -{ - CPU_XOR(&dest->set, &src1->set, &src2->set); -} - -int odp_cpumask_equal(const odp_cpumask_t *mask1, - const odp_cpumask_t *mask2) -{ - return CPU_EQUAL(&mask1->set, &mask2->set); -} - -void odp_cpumask_copy(odp_cpumask_t *dest, const odp_cpumask_t *src) -{ - memcpy(&dest->set, &src->set, sizeof(src->set)); -} - -int odp_cpumask_first(const odp_cpumask_t *mask) -{ - int cpu; - - for (cpu = 0; cpu < CPU_SETSIZE; cpu++) - if (odp_cpumask_isset(mask, cpu)) - return cpu; - return -1; -} - -int odp_cpumask_last(const odp_cpumask_t *mask) -{ - int cpu; - - for (cpu = CPU_SETSIZE - 1; cpu >= 0; cpu--) - if (odp_cpumask_isset(mask, cpu)) - return cpu; - return -1; -} - -int odp_cpumask_next(const odp_cpumask_t *mask, int cpu) -{ - for (cpu += 1; cpu < CPU_SETSIZE; cpu++) - if (odp_cpumask_isset(mask, cpu)) - return cpu; - return -1; -} - -int odp_cpumask_default_worker(odp_cpumask_t *mask, int num) -{ - int i, count = 0; - - odp_cpumask_zero(mask); - - RTE_LCORE_FOREACH_SLAVE(i) { - odp_cpumask_set(mask, i); - if (++count == num) - break; - } - - /* exclude master lcore */ - return count; -} - -int odp_cpumask_default_control(odp_cpumask_t *mask, int num ODP_UNUSED) -{ - odp_cpumask_zero(mask); - /* By default all control threads on CPU 0 */ - odp_cpumask_set(mask, 0); - return 1; -} |