DPDK  16.07.2
Data Structures | Functions
rte_virtio_net.h File Reference
#include <stdint.h>
#include <linux/vhost.h>
#include <linux/virtio_ring.h>
#include <linux/virtio_net.h>
#include <sys/eventfd.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <rte_memory.h>
#include <rte_mempool.h>
#include <rte_ether.h>

Go to the source code of this file.

Data Structures

struct  virtio_net_device_ops

Functions

int rte_vhost_feature_disable (uint64_t feature_mask)
int rte_vhost_feature_enable (uint64_t feature_mask)
int rte_vhost_driver_register (const char *path, uint64_t flags)
int rte_vhost_get_numa_node (int vid)
uint32_t rte_vhost_get_queue_num (int vid)
int rte_vhost_get_ifname (int vid, char *buf, size_t len)
uint16_t rte_vhost_avail_entries (int vid, uint16_t queue_id)
uint16_t rte_vhost_enqueue_burst (int vid, uint16_t queue_id, struct rte_mbuf **pkts, uint16_t count)
uint16_t rte_vhost_dequeue_burst (int vid, uint16_t queue_id, struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count)

Detailed Description

Interface to vhost net

Definition in file rte_virtio_net.h.

Function Documentation

int rte_vhost_feature_disable ( uint64_t  feature_mask)

Disable features in feature_mask. Returns 0 on success.

Examples:
tep_termination/main.c, and vhost/main.c.
int rte_vhost_feature_enable ( uint64_t  feature_mask)

Enable features in feature_mask. Returns 0 on success.

Examples:
vhost/main.c.
int rte_vhost_driver_register ( const char *  path,
uint64_t  flags 
)

Register vhost driver. path could be different for multiple instance support.

Examples:
tep_termination/main.c, and vhost/main.c.
int rte_vhost_get_numa_node ( int  vid)

Get the numa node from which the virtio net device's memory is allocated.

Parameters
vidvirtio-net device ID
Returns
The numa node, -1 on failure
uint32_t rte_vhost_get_queue_num ( int  vid)

Get the number of queues the device supports.

Parameters
vidvirtio-net device ID
Returns
The number of queues, 0 on failure
int rte_vhost_get_ifname ( int  vid,
char *  buf,
size_t  len 
)

Get the virtio net device's ifname. For vhost-cuse, ifname is the path of the char device. For vhost-user, ifname is the vhost-user socket file path.

Parameters
vidvirtio-net device ID
bufThe buffer to stored the queried ifname
lenThe length of buf
Returns
0 on success, -1 on failure
uint16_t rte_vhost_avail_entries ( int  vid,
uint16_t  queue_id 
)

Get how many avail entries are left in the queue

Parameters
vidvirtio-net device ID
queue_idvirtio queue index
Returns
num of avail entires left
Examples:
tep_termination/main.c, and vhost/main.c.
uint16_t rte_vhost_enqueue_burst ( int  vid,
uint16_t  queue_id,
struct rte_mbuf **  pkts,
uint16_t  count 
)

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 count is returned to indicate the number of packets that were succesfully added to the RX queue.

Parameters
vidvirtio-net device ID
queue_idvirtio queue index in mq case
pktsarray to contain packets to be enqueued
countpackets num to be enqueued
Returns
num of packets enqueued
Examples:
tep_termination/vxlan_setup.c, and vhost/main.c.
uint16_t rte_vhost_dequeue_burst ( int  vid,
uint16_t  queue_id,
struct rte_mempool mbuf_pool,
struct rte_mbuf **  pkts,
uint16_t  count 
)

This function gets guest buffers from the virtio device TX virtqueue, construct host mbufs, copies guest buffer content to host mbufs and store them in pkts to be processed.

Parameters
vidvirtio-net device
queue_idvirtio queue index in mq case
mbuf_poolmbuf_pool where host mbuf is allocated.
pktsarray to contain packets to be dequeued
countpackets num to be dequeued
Returns
num of packets dequeued
Examples:
tep_termination/main.c, and vhost/main.c.