DPDK
21.11.8
|
#include <rte_pci.h>
#include <rte_memory.h>
#include <rte_mempool.h>
#include <rte_ether.h>
#include <rte_kni_common.h>
Go to the source code of this file.
Data Structures | |
struct | rte_kni_ops |
struct | rte_kni_conf |
Functions | |
int | rte_kni_init (unsigned int max_kni_ifaces) |
struct rte_kni * | rte_kni_alloc (struct rte_mempool *pktmbuf_pool, const struct rte_kni_conf *conf, 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) |
struct rte_kni * | rte_kni_get (const char *name) |
const char * | rte_kni_get_name (const struct rte_kni *kni) |
int | rte_kni_register_handlers (struct rte_kni *kni, struct rte_kni_ops *ops) |
int | rte_kni_unregister_handlers (struct rte_kni *kni) |
__rte_experimental int | rte_kni_update_link (struct rte_kni *kni, unsigned int linkup) |
void | rte_kni_close (void) |
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 provides two APIs to burst receive packets from KNI interfaces, and burst transmit packets to KNI interfaces.
Definition in file rte_kni.h.
int rte_kni_init | ( | unsigned int | max_kni_ifaces | ) |
Initialize and preallocate KNI subsystem
This function is to be executed on the main lcore only, after EAL initialization and before any KNI interface is attempted to be allocated
max_kni_ifaces | The maximum number of KNI interfaces that can coexist concurrently |
struct rte_kni* rte_kni_alloc | ( | struct rte_mempool * | pktmbuf_pool, |
const struct rte_kni_conf * | conf, | ||
struct rte_kni_ops * | ops | ||
) |
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.
The rte_kni_alloc shall not be called before rte_kni_init() has been called. rte_kni_alloc is thread safe.
The mempool should have capacity of more than "2 x KNI_FIFO_COUNT_MAX" elements for each KNI interface allocated.
pktmbuf_pool | The mempool for allocating mbufs for packets. |
conf | The pointer to the configurations of the KNI device. |
ops | The pointer to the callbacks for the KNI kernel requests. |
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.
rte_kni_release is thread safe.
kni | The pointer to the context of an existent KNI interface. |
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.
kni | The pointer to the context of an existent KNI interface. |
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 allocating the mbufs for KNI interface alloc queue.
kni | The KNI interface context. |
mbufs | The array to store the pointers of mbufs. |
num | The maximum number per burst. |
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 the freeing of the mbufs in the free queue of KNI interface.
kni | The KNI interface context. |
mbufs | The array to store the pointers of mbufs. |
num | The maximum number per burst. |
struct rte_kni* rte_kni_get | ( | const char * | name | ) |
Get the KNI context of its name.
name | pointer to the KNI device name. |
const char* rte_kni_get_name | ( | const struct rte_kni * | kni | ) |
Get the name given to a KNI device
kni | The KNI instance to query |
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 primary process or secondary process.
kni | pointer to struct rte_kni. |
ops | pointer to struct rte_kni_ops. |
int rte_kni_unregister_handlers | ( | struct rte_kni * | kni | ) |
Unregister KNI request handling for a specified port.
kni | pointer to struct rte_kni. |
__rte_experimental int rte_kni_update_link | ( | struct rte_kni * | kni, |
unsigned int | linkup | ||
) |
Update link carrier state for KNI port.
Update the linkup/linkdown state of a KNI interface in the kernel.
kni | pointer to struct rte_kni. |
linkup | New link state: 0 for linkdown.
|
void rte_kni_close | ( | void | ) |
Close KNI device.