xref: /dpdk/kernel/linux/kni/kni_dev.h (revision ca926852)
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 	struct net_device_stats stats;
43 	int status;
44 	uint16_t group_id;           /* Group ID of a group of KNI devices */
45 	uint32_t core_id;            /* Core ID to bind */
46 	char name[RTE_KNI_NAMESIZE]; /* Network device name */
47 	struct task_struct *pthread;
48 
49 	/* wait queue for req/resp */
50 	wait_queue_head_t wq;
51 	struct mutex sync_lock;
52 
53 	/* kni device */
54 	struct net_device *net_dev;
55 
56 	/* queue for packets to be sent out */
57 	void *tx_q;
58 
59 	/* queue for the packets received */
60 	void *rx_q;
61 
62 	/* queue for the allocated mbufs those can be used to save sk buffs */
63 	void *alloc_q;
64 
65 	/* free queue for the mbufs to be freed */
66 	void *free_q;
67 
68 	/* request queue */
69 	void *req_q;
70 
71 	/* response queue */
72 	void *resp_q;
73 
74 	void *sync_kva;
75 	void *sync_va;
76 
77 	void *mbuf_kva;
78 	void *mbuf_va;
79 
80 	/* mbuf size */
81 	uint32_t mbuf_size;
82 
83 	/* synchro for request processing */
84 	unsigned long synchro;
85 
86 	/* buffers */
87 	void *pa[MBUF_BURST_SZ];
88 	void *va[MBUF_BURST_SZ];
89 	void *alloc_pa[MBUF_BURST_SZ];
90 	void *alloc_va[MBUF_BURST_SZ];
91 };
92 
93 void kni_net_release_fifo_phy(struct kni_dev *kni);
94 void kni_net_rx(struct kni_dev *kni);
95 void kni_net_init(struct net_device *dev);
96 void kni_net_config_lo_mode(char *lo_str);
97 void kni_net_poll_resp(struct kni_dev *kni);
98 
99 #endif
100