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_
13 #include <rte_common.h>
14 #include <rte_config.h>
18 * KNI name is part of memzone name.
20 #define RTE_KNI_NAMESIZE 32
22 #define RTE_CACHE_LINE_MIN_SIZE 64
28 RTE_KNI_REQ_UNKNOWN
= 0,
29 RTE_KNI_REQ_CHANGE_MTU
,
30 RTE_KNI_REQ_CFG_NETWORK_IF
,
31 RTE_KNI_REQ_CHANGE_MAC_ADDR
,
32 RTE_KNI_REQ_CHANGE_PROMISC
,
37 * Structure for KNI request.
39 struct rte_kni_request
{
40 uint32_t req_id
; /**< Request id */
43 uint32_t new_mtu
; /**< New MTU */
44 uint8_t if_up
; /**< 1: interface up, 0: interface down */
45 uint8_t mac_addr
[6]; /**< MAC address for interface */
46 uint8_t promiscusity
;/**< 1: promisc mode enable, 0: disable */
48 int32_t result
; /**< Result for processing request */
49 } __attribute__((__packed__
));
52 * Fifo struct mapped in a shared memory. It describes a circular buffer FIFO
53 * Write and read should wrap around. Fifo is empty when write == read
54 * Writing should never overwrite the read position
57 volatile unsigned write
; /**< Next position to be written*/
58 volatile unsigned read
; /**< Next position to be read */
59 unsigned len
; /**< Circular buffer length */
60 unsigned elem_size
; /**< Pointer size - for 32/64 bit OS */
61 void *volatile buffer
[]; /**< The buffer contains mbuf pointers */
65 * The kernel image of the rte_mbuf struct, with only the relevant fields.
66 * Padding is necessary to assure the offsets of these fields
69 void *buf_addr
__attribute__((__aligned__(RTE_CACHE_LINE_SIZE
)));
70 uint64_t buf_physaddr
;
71 uint16_t data_off
; /**< Start address of data in segment buffer. */
73 uint16_t nb_segs
; /**< Number of segments. */
75 uint64_t ol_flags
; /**< Offload features. */
77 uint32_t pkt_len
; /**< Total pkt len: sum of all segment data_len. */
78 uint16_t data_len
; /**< Amount of data in segment buffer. */
80 /* fields on second cache line */
81 char pad3
[8] __attribute__((__aligned__(RTE_CACHE_LINE_MIN_SIZE
)));
87 * Struct used to create a KNI device. Passed to the kernel in IOCTL call
90 struct rte_kni_device_info
{
91 char name
[RTE_KNI_NAMESIZE
]; /**< Network device name for KNI */
95 phys_addr_t alloc_phys
;
96 phys_addr_t free_phys
;
100 phys_addr_t resp_phys
;
101 phys_addr_t sync_phys
;
106 phys_addr_t mbuf_phys
;
109 uint16_t vendor_id
; /**< Vendor ID or PCI_ANY_ID. */
110 uint16_t device_id
; /**< Device ID or PCI_ANY_ID. */
111 uint8_t bus
; /**< Device bus */
112 uint8_t devid
; /**< Device ID */
113 uint8_t function
; /**< Device function. */
115 uint16_t group_id
; /**< Group ID */
116 uint32_t core_id
; /**< core ID to bind for kernel thread */
119 uint8_t force_bind
: 1; /**< Flag for kernel thread binding */
127 #define KNI_DEVICE "kni"
129 #define RTE_KNI_IOCTL_TEST _IOWR(0, 1, int)
130 #define RTE_KNI_IOCTL_CREATE _IOWR(0, 2, struct rte_kni_device_info)
131 #define RTE_KNI_IOCTL_RELEASE _IOWR(0, 3, struct rte_kni_device_info)
133 #endif /* _RTE_KNI_COMMON_H_ */