DPDK  1.7.1
Data Structures | Functions
rte_kni.h File Reference
#include <rte_pci.h>
#include <rte_mbuf.h>
#include <exec-env/rte_kni_common.h>

Data Structures

struct  rte_kni_ops
struct  rte_kni_conf

Functions

struct rte_kni * rte_kni_alloc (struct rte_mempool *pktmbuf_pool, const struct rte_kni_conf *conf, struct rte_kni_ops *ops)
struct rte_kni * rte_kni_create (uint8_t port_id, unsigned mbuf_size, struct rte_mempool *pktmbuf_pool, struct rte_kni_ops *ops)
int rte_kni_release (struct rte_kni *kni)
int rte_kni_handle_request (struct rte_kni *kni)
unsigned rte_kni_rx_burst (struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned num)
unsigned rte_kni_tx_burst (struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned num)
uint8_t rte_kni_get_port_id (struct rte_kni *kni)
struct rte_kni * rte_kni_get (const char *name)
struct rte_kni * rte_kni_info_get (uint8_t port_id)
int rte_kni_register_handlers (struct rte_kni *kni, struct rte_kni_ops *ops)
int rte_kni_unregister_handlers (struct rte_kni *kni)
void rte_kni_close (void)

Detailed Description

RTE KNI

The KNI library provides the ability to create and destroy kernel NIC interfaces that may be used by the RTE application to receive/transmit packets from/to Linux kernel net interfaces.

This library provide two APIs to burst receive packets from KNI interfaces, and burst transmit packets to KNI interfaces.

Function Documentation

struct rte_kni* rte_kni_alloc ( struct rte_mempool pktmbuf_pool,
const struct rte_kni_conf conf,
struct rte_kni_ops ops 
)
read

Allocate KNI interface according to the port id, mbuf size, mbuf pool, configurations and callbacks for kernel requests.The KNI interface created in the kernel space is the net interface the traditional Linux application talking to.

Parameters
pktmbuf_poolThe mempool for allocting mbufs for packets.
confThe pointer to the configurations of the KNI device.
opsThe pointer to the callbacks for the KNI kernel requests.
Returns
  • The pointer to the context of a KNI interface.
  • NULL indicate error.
void rte_kni_close ( void  )

close KNI device.

Parameters
void
Returns
void
struct rte_kni* rte_kni_create ( uint8_t  port_id,
unsigned  mbuf_size,
struct rte_mempool pktmbuf_pool,
struct rte_kni_ops ops 
)
read

It create a KNI device for specific port.

Note: It is deprecated and just for backward compatibility.

Parameters
port_idPort ID.
mbuf_sizembuf size.
pktmbuf_poolThe mempool for allocting mbufs for packets.
opsThe pointer to the callbacks for the KNI kernel requests.
Returns
  • The pointer to the context of a KNI interface.
  • NULL indicate error.
struct rte_kni* rte_kni_get ( const char *  name)
read

Get the KNI context of its name.

Parameters
namepointer to the KNI device name.
Returns
On success: Pointer to KNI interface. On failure: NULL.
uint8_t rte_kni_get_port_id ( struct rte_kni *  kni)

Get the port id from KNI interface.

Note: It is deprecated and just for backward compatibility.

Parameters
kniThe KNI interface context.
Returns
On success: The port id. On failure: ~0x0
int rte_kni_handle_request ( struct rte_kni *  kni)

It is used to handle the request mbufs sent from kernel space. Then analyzes it and calls the specific actions for the specific requests. Finally constructs the response mbuf and puts it back to the resp_q.

Parameters
kniThe pointer to the context of an existent KNI interface.
Returns
  • 0
  • negative value indicates failure.
struct rte_kni* rte_kni_info_get ( uint8_t  port_id)
read

Get the KNI context of the specific port.

Note: It is deprecated and just for backward compatibility.

Parameters
port_idthe port id.
Returns
On success: Pointer to KNI interface. On failure: NULL
int rte_kni_register_handlers ( struct rte_kni *  kni,
struct rte_kni_ops ops 
)

Register KNI request handling for a specified port,and it can be called by master process or slave process.

Parameters
knipointer to struct rte_kni.
opsponter to struct rte_kni_ops.
Returns
On success: 0 On failure: -1
int rte_kni_release ( struct rte_kni *  kni)

Release KNI interface according to the context. It will also release the paired KNI interface in kernel space. All processing on the specific KNI context need to be stopped before calling this interface.

Parameters
kniThe pointer to the context of an existent KNI interface.
Returns
  • 0 indicates success.
  • negative value indicates failure.
unsigned rte_kni_rx_burst ( struct rte_kni *  kni,
struct rte_mbuf **  mbufs,
unsigned  num 
)

Retrieve a burst of packets from a KNI interface. The retrieved packets are stored in rte_mbuf structures whose pointers are supplied in the array of mbufs, and the maximum number is indicated by num. It handles the freeing of the mbufs in the free queue of KNI interface.

Parameters
kniThe KNI interface context.
mbufsThe array to store the pointers of mbufs.
numThe maximum number per burst.
Returns
The actual number of packets retrieved.
unsigned rte_kni_tx_burst ( struct rte_kni *  kni,
struct rte_mbuf **  mbufs,
unsigned  num 
)

Send a burst of packets to a KNI interface. The packets to be sent out are stored in rte_mbuf structures whose pointers are supplied in the array of mbufs, and the maximum number is indicated by num. It handles allocating the mbufs for KNI interface alloc queue.

Parameters
kniThe KNI interface context.
mbufsThe array to store the pointers of mbufs.
numThe maximum number per burst.
Returns
The actual number of packets sent.
int rte_kni_unregister_handlers ( struct rte_kni *  kni)

Unregister KNI request handling for a specified port.

Parameters
knipointer to struct rte_kni.
Returns
On success: 0 On failure: -1