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