[ovs-dev] [dpdk patch 2/8] netdev-dpdk: Add function for getting the socket_id of netdev-dpdk.
Alex Wang
alexw at nicira.com
Tue Aug 12 04:56:37 UTC 2014
Signed-off-by: Alex Wang <alexw at nicira.com>
---
lib/netdev-dpdk.c | 14 ++++++++++++++
lib/netdev-dpdk.h | 8 ++++++++
2 files changed, 22 insertions(+)
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 6ee9803..7298334 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1442,6 +1442,20 @@ netdev_dpdk_register(void)
}
}
+/* Returns the 'socket_id' if 'netdev_' is class dpdk. Otherwise,
+ * return -1. */
+int
+netdev_dpdk_get_socket_id(const struct netdev *netdev_)
+{
+ if (is_dpdk_class(netdev_->netdev_class)) {
+ struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_);
+
+ return netdev->socket_id;
+ } else {
+ return -1;
+ }
+}
+
int
pmd_thread_setaffinity_cpu(int cpu)
{
diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h
index e4ba6fc..75f6a0b 100644
--- a/lib/netdev-dpdk.h
+++ b/lib/netdev-dpdk.h
@@ -4,6 +4,7 @@
#include <config.h>
struct dpif_packet;
+struct netdev;
#ifdef DPDK_NETDEV
@@ -22,6 +23,7 @@ struct dpif_packet;
int dpdk_init(int argc, char **argv);
void netdev_dpdk_register(void);
+int netdev_dpdk_get_socket_id(const struct netdev *);
void free_dpdk_buf(struct dpif_packet *);
int pmd_thread_setaffinity_cpu(int cpu);
void thread_set_nonpmd(void);
@@ -40,6 +42,12 @@ netdev_dpdk_register(void)
/* Nothing */
}
+static inline int
+netdev_dpdk_get_socket_id(const struct netdev *netdev_ OVS_UNUSED)
+{
+ return -1;
+}
+
static inline void
free_dpdk_buf(struct dpif_packet *buf OVS_UNUSED)
{
--
1.7.9.5
More information about the dev
mailing list