1
2
3
4
5
6#ifndef _RTE_KNI_COMMON_H_
7#define _RTE_KNI_COMMON_H_
8
9#ifdef __KERNEL__
10#include <linux/if.h>
11#include <asm/barrier.h>
12#define RTE_STD_C11
13#else
14#include <rte_common.h>
15#include <rte_config.h>
16#endif
17
18
19
20
21#define RTE_KNI_NAMESIZE 16
22
23#define RTE_CACHE_LINE_MIN_SIZE 64
24
25
26
27
28enum rte_kni_req_id {
29 RTE_KNI_REQ_UNKNOWN = 0,
30 RTE_KNI_REQ_CHANGE_MTU,
31 RTE_KNI_REQ_CFG_NETWORK_IF,
32 RTE_KNI_REQ_CHANGE_MAC_ADDR,
33 RTE_KNI_REQ_CHANGE_PROMISC,
34 RTE_KNI_REQ_CHANGE_ALLMULTI,
35 RTE_KNI_REQ_MAX,
36};
37
38
39
40
41struct rte_kni_request {
42 uint32_t req_id;
43 RTE_STD_C11
44 union {
45 uint32_t new_mtu;
46 uint8_t if_up;
47 uint8_t mac_addr[6];
48 uint8_t promiscusity;
49 uint8_t allmulti;
50 };
51 int32_t async : 1;
52 int32_t result;
53} __attribute__((__packed__));
54
55
56
57
58
59
60struct rte_kni_fifo {
61#ifdef RTE_USE_C11_MEM_MODEL
62 unsigned write;
63 unsigned read;
64#else
65 volatile unsigned write;
66 volatile unsigned read;
67#endif
68 unsigned len;
69 unsigned elem_size;
70 void *volatile buffer[];
71};
72
73
74
75
76
77struct rte_kni_mbuf {
78 void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
79 uint64_t buf_iova;
80 uint16_t data_off;
81 char pad1[2];
82 uint16_t nb_segs;
83 char pad4[2];
84 uint64_t ol_flags;
85 char pad2[4];
86 uint32_t pkt_len;
87 uint16_t data_len;
88 char pad3[14];
89 void *pool;
90
91
92 __attribute__((__aligned__(RTE_CACHE_LINE_MIN_SIZE)))
93 void *next;
94};
95
96
97
98
99
100struct rte_kni_device_info {
101 char name[RTE_KNI_NAMESIZE];
102
103 phys_addr_t tx_phys;
104 phys_addr_t rx_phys;
105 phys_addr_t alloc_phys;
106 phys_addr_t free_phys;
107
108
109 phys_addr_t req_phys;
110 phys_addr_t resp_phys;
111 phys_addr_t sync_phys;
112 void * sync_va;
113
114
115 void * mbuf_va;
116 phys_addr_t mbuf_phys;
117
118 uint16_t group_id;
119 uint32_t core_id;
120
121 __extension__
122 uint8_t force_bind : 1;
123
124
125 unsigned mbuf_size;
126 unsigned int mtu;
127 unsigned int min_mtu;
128 unsigned int max_mtu;
129 uint8_t mac_addr[6];
130 uint8_t iova_mode;
131};
132
133#define KNI_DEVICE "kni"
134
135#define RTE_KNI_IOCTL_TEST _IOWR(0, 1, int)
136#define RTE_KNI_IOCTL_CREATE _IOWR(0, 2, struct rte_kni_device_info)
137#define RTE_KNI_IOCTL_RELEASE _IOWR(0, 3, struct rte_kni_device_info)
138
139#endif
140