ethdev: fix possibly incorrect maximum queues
[dpdk.git] / lib / librte_kni / rte_kni.h
index 1a0b004..9899a17 100644 (file)
@@ -47,7 +47,8 @@
  */
 
 #include <rte_pci.h>
-#include <rte_mbuf.h>
+#include <rte_memory.h>
+#include <rte_mempool.h>
 
 #include <exec-env/rte_kni_common.h>
 
@@ -56,6 +57,7 @@ extern "C" {
 #endif
 
 struct rte_kni;
+struct rte_mbuf;
 
 /**
  * Structure which has the function pointers for KNI interface.
@@ -90,37 +92,31 @@ struct rte_kni_conf {
 };
 
 /**
- * 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.
+ * Initialize and preallocate KNI subsystem
  *
- * @param pktmbuf_pool
- *  The mempool for allocting mbufs for packets.
- * @param conf
- *  The pointer to the configurations of the KNI device.
- * @param ops
- *  The pointer to the callbacks for the KNI kernel requests.
+ * This function is to be executed on the MASTER lcore only, after EAL
+ * initialization and before any KNI interface is attempted to be
+ * allocated
  *
- * @return
- *  - The pointer to the context of a KNI interface.
- *  - NULL indicate error.
+ * @param max_kni_ifaces
+ *  The maximum number of KNI interfaces that can coexist concurrently
  */
-extern struct rte_kni *rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
-                                    const struct rte_kni_conf *conf,
-                                    struct rte_kni_ops *ops);
+void rte_kni_init(unsigned int max_kni_ifaces);
+
 
 /**
- * It create a KNI device for specific port.
+ * 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.
  *
- * Note: It is deprecated and just for backward compatibility.
+ * The rte_kni_alloc shall not be called before rte_kni_init() has been
+ * called. rte_kni_alloc is thread safe.
  *
- * @param port_id
- *  Port ID.
- * @param mbuf_size
- *  mbuf size.
  * @param pktmbuf_pool
  *  The mempool for allocting mbufs for packets.
+ * @param conf
+ *  The pointer to the configurations of the KNI device.
  * @param ops
  *  The pointer to the callbacks for the KNI kernel requests.
  *
@@ -128,17 +124,16 @@ extern struct rte_kni *rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
  *  - 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
  * 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.
+ *
  * @param kni
  *  The pointer to the context of an existent KNI interface.
  *
@@ -146,7 +141,7 @@ extern struct rte_kni *rte_kni_create(uint8_t port_id,
  *  - 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.
@@ -160,7 +155,7 @@ extern int rte_kni_release(struct rte_kni *kni);
  *  - 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
@@ -178,8 +173,8 @@ extern int rte_kni_handle_request(struct rte_kni *kni);
  * @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
@@ -197,23 +192,8 @@ extern unsigned rte_kni_rx_burst(struct rte_kni *kni,
  * @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.
@@ -225,22 +205,17 @@ extern uint8_t rte_kni_get_port_id(struct rte_kni *kni) \
  *  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
@@ -255,8 +230,7 @@ extern struct rte_kni *rte_kni_info_get(uint8_t port_id) \
  *  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.
@@ -268,21 +242,15 @@ extern int rte_kni_register_handlers(struct rte_kni *kni,
  *   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.
- *
- *  @param void
- *
- *  @return
- *   void
+ *  Close KNI device.
  */
-extern void rte_kni_close(void);
+void rte_kni_close(void);
 
 #ifdef __cplusplus
 }
 #endif
 
 #endif /* _RTE_KNI_H_ */
-