1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright(c) 2010-2014 Intel Corporation. 4 */ 5 6 #ifndef _KNI_DEV_H_ 7 #define _KNI_DEV_H_ 8 9 #ifdef pr_fmt 10 #undef pr_fmt 11 #endif 12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 13 14 #define KNI_VERSION "1.0" 15 16 #include "compat.h" 17 18 #include <linux/if.h> 19 #include <linux/wait.h> 20 #ifdef HAVE_SIGNAL_FUNCTIONS_OWN_HEADER 21 #include <linux/sched/signal.h> 22 #else 23 #include <linux/sched.h> 24 #endif 25 #include <linux/netdevice.h> 26 #include <linux/spinlock.h> 27 #include <linux/list.h> 28 29 #include <rte_kni_common.h> 30 #define KNI_KTHREAD_RESCHEDULE_INTERVAL 5 /* us */ 31 32 #define MBUF_BURST_SZ 32 33 34 /* Default carrier state for created KNI network interfaces */ 35 extern uint32_t dflt_carrier; 36 37 /** 38 * A structure describing the private information for a kni device. 39 */ 40 struct kni_dev { 41 /* kni list */ 42 struct list_head list; 43 44 uint32_t core_id; /* Core ID to bind */ 45 char name[RTE_KNI_NAMESIZE]; /* Network device name */ 46 struct task_struct *pthread; 47 48 /* wait queue for req/resp */ 49 wait_queue_head_t wq; 50 struct mutex sync_lock; 51 52 /* kni device */ 53 struct net_device *net_dev; 54 55 /* queue for packets to be sent out */ 56 struct rte_kni_fifo *tx_q; 57 58 /* queue for the packets received */ 59 struct rte_kni_fifo *rx_q; 60 61 /* queue for the allocated mbufs those can be used to save sk buffs */ 62 struct rte_kni_fifo *alloc_q; 63 64 /* free queue for the mbufs to be freed */ 65 struct rte_kni_fifo *free_q; 66 67 /* request queue */ 68 struct rte_kni_fifo *req_q; 69 70 /* response queue */ 71 struct rte_kni_fifo *resp_q; 72 73 void *sync_kva; 74 void *sync_va; 75 76 void *mbuf_kva; 77 void *mbuf_va; 78 79 /* mbuf size */ 80 uint32_t mbuf_size; 81 82 /* buffers */ 83 void *pa[MBUF_BURST_SZ]; 84 void *va[MBUF_BURST_SZ]; 85 void *alloc_pa[MBUF_BURST_SZ]; 86 void *alloc_va[MBUF_BURST_SZ]; 87 }; 88 89 void kni_net_release_fifo_phy(struct kni_dev *kni); 90 void kni_net_rx(struct kni_dev *kni); 91 void kni_net_init(struct net_device *dev); 92 void kni_net_config_lo_mode(char *lo_str); 93 void kni_net_poll_resp(struct kni_dev *kni); 94 95 #endif 96