-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
*/
#ifndef _RTE_KNI_H_
* 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,
+ * This library provides two APIs to burst receive packets from KNI interfaces,
* and burst transmit packets to KNI interfaces.
*/
#include <rte_pci.h>
#include <rte_memory.h>
#include <rte_mempool.h>
+#include <rte_ether.h>
-#include <exec-env/rte_kni_common.h>
+#include <rte_kni_common.h>
#ifdef __cplusplus
extern "C" {
* Structure which has the function pointers for KNI interface.
*/
struct rte_kni_ops {
- uint8_t port_id; /* Port ID */
+ uint16_t port_id; /* Port ID */
/* Pointer to function of changing MTU */
- int (*change_mtu)(uint8_t port_id, unsigned new_mtu);
+ int (*change_mtu)(uint16_t port_id, unsigned int new_mtu);
/* Pointer to function of configuring network interface */
- int (*config_network_if)(uint8_t port_id, uint8_t if_up);
+ int (*config_network_if)(uint16_t port_id, uint8_t if_up);
+
+ /* Pointer to function of configuring mac address */
+ int (*config_mac_address)(uint16_t port_id, uint8_t mac_addr[]);
+
+ /* Pointer to function of configuring promiscuous mode */
+ int (*config_promiscusity)(uint16_t port_id, uint8_t to_on);
+
+ /* Pointer to function of configuring allmulticast mode */
+ int (*config_allmulticast)(uint16_t port_id, uint8_t to_on);
};
/**
uint32_t core_id; /* Core ID to bind kernel thread on */
uint16_t group_id; /* Group ID */
unsigned mbuf_size; /* mbuf size */
- struct rte_pci_addr addr;
- struct rte_pci_id id;
+ struct rte_pci_addr addr; /* depreciated */
+ struct rte_pci_id id; /* depreciated */
+ __extension__
uint8_t force_bind : 1; /* Flag to bind kernel thread */
+ uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; /* MAC address assigned to KNI */
+ uint16_t mtu;
};
/**
*
* @param max_kni_ifaces
* The maximum number of KNI interfaces that can coexist concurrently
+ *
+ * @return
+ * - 0 indicates success.
+ * - negative value indicates failure.
*/
-extern void rte_kni_init(unsigned int max_kni_ifaces);
+int rte_kni_init(unsigned int max_kni_ifaces);
/**
* 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.
+ *
* @param pktmbuf_pool
- * The mempool for allocting mbufs for packets.
+ * The mempool for allocating mbufs for packets.
* @param conf
* The pointer to the configurations of the KNI device.
* @param ops
* - The pointer to the context of a KNI interface.
* - NULL indicate error.
*/
-extern struct rte_kni *rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
- const struct rte_kni_conf *conf,
- struct rte_kni_ops *ops);
-
-/**
- * It create a KNI device for specific port.
- *
- * Note: It is deprecated and just for backward compatibility.
- *
- * @param port_id
- * Port ID.
- * @param mbuf_size
- * mbuf size.
- * @param pktmbuf_pool
- * The mempool for allocting mbufs for packets.
- * @param ops
- * The pointer to the callbacks for the KNI kernel requests.
- *
- * @return
- * - The pointer to the context of a KNI interface.
- * - NULL indicate error.
- */
-extern struct rte_kni *rte_kni_create(uint8_t port_id,
- unsigned mbuf_size,
- struct rte_mempool *pktmbuf_pool,
- struct rte_kni_ops *ops) \
- __attribute__ ((deprecated));
+struct rte_kni *rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
+ const struct rte_kni_conf *conf, struct rte_kni_ops *ops);
/**
* Release KNI interface according to the context. It will also release the
* - 0 indicates success.
* - negative value indicates failure.
*/
-extern int rte_kni_release(struct rte_kni *kni);
+int rte_kni_release(struct rte_kni *kni);
/**
* It is used to handle the request mbufs sent from kernel space.
* - 0
* - negative value indicates failure.
*/
-extern int rte_kni_handle_request(struct rte_kni *kni);
+int rte_kni_handle_request(struct rte_kni *kni);
/**
* 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.
+ * mbufs, and the maximum number is indicated by num. It handles allocating
+ * the mbufs for KNI interface alloc queue.
*
* @param kni
* The KNI interface context.
* @return
* The actual number of packets retrieved.
*/
-extern unsigned rte_kni_rx_burst(struct rte_kni *kni,
- struct rte_mbuf **mbufs, unsigned num);
+unsigned rte_kni_rx_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.
+ * mbufs, and the maximum number is indicated by num. It handles the freeing of
+ * the mbufs in the free queue of KNI interface.
*
* @param kni
* The KNI interface context.
* @return
* The actual number of packets sent.
*/
-extern unsigned rte_kni_tx_burst(struct rte_kni *kni,
- struct rte_mbuf **mbufs, unsigned num);
-
-/**
- * Get the port id from KNI interface.
- *
- * Note: It is deprecated and just for backward compatibility.
- *
- * @param kni
- * The KNI interface context.
- *
- * @return
- * On success: The port id.
- * On failure: ~0x0
- */
-extern uint8_t rte_kni_get_port_id(struct rte_kni *kni) \
- __attribute__ ((deprecated));
+unsigned rte_kni_tx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs,
+ unsigned num);
/**
* Get the KNI context of its name.
* On success: Pointer to KNI interface.
* On failure: NULL.
*/
-extern struct rte_kni *rte_kni_get(const char *name);
+struct rte_kni *rte_kni_get(const char *name);
/**
- * Get the KNI context of the specific port.
- *
- * Note: It is deprecated and just for backward compatibility.
- *
- * @param port_id
- * the port id.
+ * Get the name given to a KNI device
*
+ * @param kni
+ * The KNI instance to query
* @return
- * On success: Pointer to KNI interface.
- * On failure: NULL
+ * The pointer to the KNI name
*/
-extern struct rte_kni *rte_kni_info_get(uint8_t port_id) \
- __attribute__ ((deprecated));
+const char *rte_kni_get_name(const struct rte_kni *kni);
/**
* Register KNI request handling for a specified port,and it can
* @param kni
* pointer to struct rte_kni.
* @param ops
- * ponter to struct rte_kni_ops.
+ * pointer to struct rte_kni_ops.
*
* @return
* On success: 0
* On failure: -1
*/
-extern int rte_kni_register_handlers(struct rte_kni *kni,
- struct rte_kni_ops *ops);
+int rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops);
/**
* Unregister KNI request handling for a specified port.
* On success: 0
* On failure: -1
*/
-extern int rte_kni_unregister_handlers(struct rte_kni *kni);
+int rte_kni_unregister_handlers(struct rte_kni *kni);
/**
- * close KNI device.
+ * Update link carrier state for KNI port.
*
- * @param void
+ * Update the linkup/linkdown state of a KNI interface in the kernel.
*
- * @return
- * void
+ * @param kni
+ * pointer to struct rte_kni.
+ * @param linkup
+ * New link state:
+ * 0 for linkdown.
+ * > 0 for linkup.
+ *
+ * @return
+ * On failure: -1
+ * Previous link state == linkdown: 0
+ * Previous link state == linkup: 1
+ */
+__rte_experimental
+int
+rte_kni_update_link(struct rte_kni *kni, unsigned int linkup);
+
+/**
+ * Close KNI device.
*/
-extern void rte_kni_close(void);
+void rte_kni_close(void);
#ifdef __cplusplus
}