1 /* SPDX-License-Identifier: (BSD-3-Clause OR LGPL-2.1) */
3 * Copyright(c) 2007-2014 Intel Corporation.
6 #ifndef _RTE_KNI_COMMON_H_
7 #define _RTE_KNI_COMMON_H_
11 #include <asm/barrier.h>
14 #include <rte_common.h>
15 #include <rte_config.h>
19 * KNI name is part of memzone name. Must not exceed IFNAMSIZ.
21 #define RTE_KNI_NAMESIZE 16
23 #define RTE_CACHE_LINE_MIN_SIZE 64
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,
39 * Structure for KNI request.
41 struct rte_kni_request {
42 uint32_t req_id; /**< Request id */
45 uint32_t new_mtu; /**< New MTU */
46 uint8_t if_up; /**< 1: interface up, 0: interface down */
47 uint8_t mac_addr[6]; /**< MAC address for interface */
48 uint8_t promiscusity;/**< 1: promisc mode enable, 0: disable */
49 uint8_t allmulti; /**< 1: all-multicast mode enable, 0: disable */
51 int32_t async : 1; /**< 1: request is asynchronous */
52 int32_t result; /**< Result for processing request */
53 } __attribute__((__packed__));
56 * Fifo struct mapped in a shared memory. It describes a circular buffer FIFO
57 * Write and read should wrap around. Fifo is empty when write == read
58 * Writing should never overwrite the read position
61 #ifdef RTE_USE_C11_MEM_MODEL
62 unsigned write; /**< Next position to be written*/
63 unsigned read; /**< Next position to be read */
65 volatile unsigned write; /**< Next position to be written*/
66 volatile unsigned read; /**< Next position to be read */
68 unsigned len; /**< Circular buffer length */
69 unsigned elem_size; /**< Pointer size - for 32/64 bit OS */
70 void *volatile buffer[]; /**< The buffer contains mbuf pointers */
74 * The kernel image of the rte_mbuf struct, with only the relevant fields.
75 * Padding is necessary to assure the offsets of these fields
78 void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
80 uint16_t data_off; /**< Start address of data in segment buffer. */
82 uint16_t nb_segs; /**< Number of segments. */
84 uint64_t ol_flags; /**< Offload features. */
86 uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */
87 uint16_t data_len; /**< Amount of data in segment buffer. */
91 /* fields on second cache line */
92 __attribute__((__aligned__(RTE_CACHE_LINE_MIN_SIZE)))
93 void *next; /**< Physical address of next mbuf in kernel. */
97 * Struct used to create a KNI device. Passed to the kernel in IOCTL call
100 struct rte_kni_device_info {
101 char name[RTE_KNI_NAMESIZE]; /**< Network device name for KNI */
105 phys_addr_t alloc_phys;
106 phys_addr_t free_phys;
108 /* Used by Ethtool */
109 phys_addr_t req_phys;
110 phys_addr_t resp_phys;
111 phys_addr_t sync_phys;
116 phys_addr_t mbuf_phys;
118 uint16_t group_id; /**< Group ID */
119 uint32_t core_id; /**< core ID to bind for kernel thread */
122 uint8_t force_bind : 1; /**< Flag for kernel thread binding */
127 unsigned int min_mtu;
128 unsigned int max_mtu;
133 #define KNI_DEVICE "kni"
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)
139 #endif /* _RTE_KNI_COMMON_H_ */