vhost: export numa node

Introduce a new API rte_vhost_get_numa_node() to get the numa node
from which the virtio_net struct is allocated.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
This commit is contained in:
Yuanhan Liu 2016-05-11 06:12:57 +08:00
parent adf97191b3
commit 586e390013
4 changed files with 49 additions and 9 deletions

View File

@ -230,7 +230,7 @@ new_device(struct virtio_net *dev)
struct vhost_queue *vq;
unsigned i;
#ifdef RTE_LIBRTE_VHOST_NUMA
int newnode, ret;
int newnode;
#endif
if (dev == NULL) {
@ -248,14 +248,9 @@ new_device(struct virtio_net *dev)
internal = eth_dev->data->dev_private;
#ifdef RTE_LIBRTE_VHOST_NUMA
ret = get_mempolicy(&newnode, NULL, 0, dev,
MPOL_F_NODE | MPOL_F_ADDR);
if (ret < 0) {
RTE_LOG(ERR, PMD, "Unknown numa node\n");
return -1;
}
eth_dev->data->numa_node = newnode;
newnode = rte_vhost_get_numa_node(dev->vid);
if (newnode >= 0)
eth_dev->data->numa_node = newnode;
#endif
for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {

View File

@ -20,3 +20,10 @@ DPDK_2.1 {
rte_vhost_driver_unregister;
} DPDK_2.0;
DPDK_16.07 {
global:
rte_vhost_get_numa_node;
} DPDK_2.1;

View File

@ -244,6 +244,18 @@ int rte_vhost_driver_callback_register(struct virtio_net_device_ops const * cons
/* Start vhost driver session blocking loop. */
int rte_vhost_driver_session_start(void);
/**
* Get the numa node from which the virtio net device's memory
* is allocated.
*
* @param vid
* virtio-net device ID
*
* @return
* The numa node, -1 on failure
*/
int rte_vhost_get_numa_node(int vid);
/**
* This function adds buffers to the virtio devices RX virtqueue. Buffers can
* be received from the physical port or from another virtual device. A packet

View File

@ -730,6 +730,32 @@ vhost_set_backend(int vid, struct vhost_vring_file *file)
return 0;
}
int
rte_vhost_get_numa_node(int vid)
{
#ifdef RTE_LIBRTE_VHOST_NUMA
struct virtio_net *dev = get_device(vid);
int numa_node;
int ret;
if (dev == NULL)
return -1;
ret = get_mempolicy(&numa_node, NULL, 0, dev,
MPOL_F_NODE | MPOL_F_ADDR);
if (ret < 0) {
RTE_LOG(ERR, VHOST_CONFIG,
"(%d) failed to query numa node: %d\n", vid, ret);
return -1;
}
return numa_node;
#else
RTE_SET_USED(vid);
return -1;
#endif
}
int rte_vhost_enable_guest_notification(struct virtio_net *dev,
uint16_t queue_id, int enable)
{