diff options
-rw-r--r-- | lib/netdev-dpdk.h | 2 | ||||
-rw-r--r-- | lib/netdev-odp.c | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h index c24d6da33..d298f3a74 100644 --- a/lib/netdev-dpdk.h +++ b/lib/netdev-dpdk.h @@ -51,11 +51,13 @@ free_dpdk_buf(struct dpif_packet *buf OVS_UNUSED) /* Nothing */ } +#ifndef ODP_NETDEV static inline int pmd_thread_setaffinity_cpu(int cpu OVS_UNUSED) { return 0; } +#endif /*#ifndef ODP_NETDEV */ static inline void thread_set_nonpmd(void) diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c index c78940484..c33788e5c 100644 --- a/lib/netdev-odp.c +++ b/lib/netdev-odp.c @@ -679,3 +679,23 @@ netdev_odp_register(void) ovsthread_once_done(&once); } } + +int +pmd_thread_setaffinity_cpu(int cpu) +{ + cpu_set_t cpuset; + int err; + + CPU_ZERO(&cpuset); + CPU_SET(cpu, &cpuset); + err = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (err) { + VLOG_ERR("Thread affinity error %d",err); + return err; + } + /* lcore_id 0 is reseved for use by non pmd threads. */ + ovs_assert(cpu); + + return 0; +} + |