4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 * The KNI library provides the ability to create and destroy kernel NIC
42 * interfaces that may be used by the RTE application to receive/transmit
43 * packets from/to Linux kernel net interfaces.
45 * This library provide two APIs to burst receive packets from KNI interfaces,
46 * and burst transmit packets to KNI interfaces.
58 * Structure which has the function pointers for KNI interface.
61 /* Pointer to function of changing MTU */
62 int (*change_mtu)(uint8_t port_id, unsigned new_mtu);
64 /* Pointer to function of configuring network interface */
65 int (*config_network_if)(uint8_t port_id, uint8_t if_up);
69 * Create kni interface according to the port id. It will create a paired KNI
70 * interface in the kernel space for each NIC port. The KNI interface created
71 * in the kernel space is the net interface the traditional Linux application
77 * The mempool for allocting mbufs for packets.
79 * The mbuf size to store a packet.
82 * - The pointer to the context of a KNI interface.
83 * - NULL indicate error.
85 extern struct rte_kni *rte_kni_create(uint8_t port_id, unsigned mbuf_size,
86 struct rte_mempool *pktmbuf_pool, struct rte_kni_ops *ops);
89 * Release KNI interface according to the context. It will also release the
90 * paired KNI interface in kernel space. All processing on the specific KNI
91 * context need to be stopped before calling this interface.
94 * The pointer to the context of an existant KNI interface.
97 * - 0 indicates success.
98 * - negative value indicates failure.
100 extern int rte_kni_release(struct rte_kni *kni);
103 * It is used to handle the request mbufs sent from kernel space.
104 * Then analyzes it and calls the specific actions for the specific requests.
105 * Finally constructs the response mbuf and puts it back to the resp_q.
108 * The pointer to the context of an existant KNI interface.
112 * - negative value indicates failure.
114 extern int rte_kni_handle_request(struct rte_kni *kni);
117 * Retrieve a burst of packets from a KNI interface. The retrieved packets are
118 * stored in rte_mbuf structures whose pointers are supplied in the array of
119 * mbufs, and the maximum number is indicated by num. It handles the freeing of
120 * the mbufs in the free queue of KNI interface.
123 * The KNI interface context.
125 * The array to store the pointers of mbufs.
127 * The maximum number per burst.
130 * The actual number of packets retrieved.
132 extern unsigned rte_kni_rx_burst(struct rte_kni *kni,
133 struct rte_mbuf **mbufs, unsigned num);
136 * Send a burst of packets to a KNI interface. The packets to be sent out are
137 * stored in rte_mbuf structures whose pointers are supplied in the array of
138 * mbufs, and the maximum number is indicated by num. It handles allocating
139 * the mbufs for KNI interface alloc queue.
142 * The KNI interface context.
144 * The array to store the pointers of mbufs.
146 * The maximum number per burst.
149 * The actual number of packets sent.
151 extern unsigned rte_kni_tx_burst(struct rte_kni *kni,
152 struct rte_mbuf **mbufs, unsigned num);
155 * Get the port id from KNI interface.
158 * The KNI interface context.
161 * On success: The port id.
164 extern uint8_t rte_kni_get_port_id(struct rte_kni *kni);
167 * Get the KNI context of the specific port.
173 * On success: Pointer to KNI interface.
176 extern struct rte_kni * rte_kni_info_get(uint8_t port_id);
179 * Register KNI request handling for a specified port,and it can
180 * be called by master process or slave process.
183 * pointer to struct rte_kni.
185 * ponter to struct rte_kni_ops.
191 extern int rte_kni_register_handlers(struct rte_kni *kni,
192 struct rte_kni_ops *ops);
195 * Unregister KNI request handling for a specified port.
198 * pointer to struct rte_kni.
204 extern int rte_kni_unregister_handlers(struct rte_kni *kni);
210 #endif /* _RTE_KNI_H_ */