21e4b0d92368cb014a17f53721dce4af165910d0
[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         int status;
43         uint16_t group_id;           /* Group ID of a group of KNI devices */
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         void *tx_q;
57
58         /* queue for the packets received */
59         void *rx_q;
60
61         /* queue for the allocated mbufs those can be used to save sk buffs */
62         void *alloc_q;
63
64         /* free queue for the mbufs to be freed */
65         void *free_q;
66
67         /* request queue */
68         void *req_q;
69
70         /* response queue */
71         void *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         /* synchro for request processing */
83         unsigned long synchro;
84
85         /* buffers */
86         void *pa[MBUF_BURST_SZ];
87         void *va[MBUF_BURST_SZ];
88         void *alloc_pa[MBUF_BURST_SZ];
89         void *alloc_va[MBUF_BURST_SZ];
90 };
91
92 void kni_net_release_fifo_phy(struct kni_dev *kni);
93 void kni_net_rx(struct kni_dev *kni);
94 void kni_net_init(struct net_device *dev);
95 void kni_net_config_lo_mode(char *lo_str);
96 void kni_net_poll_resp(struct kni_dev *kni);
97
98 #endif