]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/lib/librte_eal/linux/eal/include/rte_kni_common.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_eal / linux / eal / include / rte_kni_common.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR LGPL-2.1) */
2 /*
3 * Copyright(c) 2007-2014 Intel Corporation.
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 * KNI name is part of memzone name.
20 */
21 #define RTE_KNI_NAMESIZE 32
22
23 #define RTE_CACHE_LINE_MIN_SIZE 64
24
25 /*
26 * Request id.
27 */
28 enum 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_MAX,
35 };
36
37 /*
38 * Structure for KNI request.
39 */
40 struct rte_kni_request {
41 uint32_t req_id; /**< Request id */
42 RTE_STD_C11
43 union {
44 uint32_t new_mtu; /**< New MTU */
45 uint8_t if_up; /**< 1: interface up, 0: interface down */
46 uint8_t mac_addr[6]; /**< MAC address for interface */
47 uint8_t promiscusity;/**< 1: promisc mode enable, 0: disable */
48 };
49 int32_t result; /**< Result for processing request */
50 } __attribute__((__packed__));
51
52 /*
53 * Fifo struct mapped in a shared memory. It describes a circular buffer FIFO
54 * Write and read should wrap around. Fifo is empty when write == read
55 * Writing should never overwrite the read position
56 */
57 struct rte_kni_fifo {
58 #ifdef RTE_USE_C11_MEM_MODEL
59 unsigned write; /**< Next position to be written*/
60 unsigned read; /**< Next position to be read */
61 #else
62 volatile unsigned write; /**< Next position to be written*/
63 volatile unsigned read; /**< Next position to be read */
64 #endif
65 unsigned len; /**< Circular buffer length */
66 unsigned elem_size; /**< Pointer size - for 32/64 bit OS */
67 void *volatile buffer[]; /**< The buffer contains mbuf pointers */
68 };
69
70 /*
71 * The kernel image of the rte_mbuf struct, with only the relevant fields.
72 * Padding is necessary to assure the offsets of these fields
73 */
74 struct rte_kni_mbuf {
75 void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
76 uint64_t buf_physaddr;
77 uint16_t data_off; /**< Start address of data in segment buffer. */
78 char pad1[2];
79 uint16_t nb_segs; /**< Number of segments. */
80 char pad4[2];
81 uint64_t ol_flags; /**< Offload features. */
82 char pad2[4];
83 uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */
84 uint16_t data_len; /**< Amount of data in segment buffer. */
85
86 /* fields on second cache line */
87 char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_MIN_SIZE)));
88 void *pool;
89 void *next;
90 };
91
92 /*
93 * Struct used to create a KNI device. Passed to the kernel in IOCTL call
94 */
95
96 struct rte_kni_device_info {
97 char name[RTE_KNI_NAMESIZE]; /**< Network device name for KNI */
98
99 phys_addr_t tx_phys;
100 phys_addr_t rx_phys;
101 phys_addr_t alloc_phys;
102 phys_addr_t free_phys;
103
104 /* Used by Ethtool */
105 phys_addr_t req_phys;
106 phys_addr_t resp_phys;
107 phys_addr_t sync_phys;
108 void * sync_va;
109
110 /* mbuf mempool */
111 void * mbuf_va;
112 phys_addr_t mbuf_phys;
113
114 /* PCI info */
115 uint16_t vendor_id; /**< Vendor ID or PCI_ANY_ID. */
116 uint16_t device_id; /**< Device ID or PCI_ANY_ID. */
117 uint8_t bus; /**< Device bus */
118 uint8_t devid; /**< Device ID */
119 uint8_t function; /**< Device function. */
120
121 uint16_t group_id; /**< Group ID */
122 uint32_t core_id; /**< core ID to bind for kernel thread */
123
124 __extension__
125 uint8_t force_bind : 1; /**< Flag for kernel thread binding */
126
127 /* mbuf size */
128 unsigned mbuf_size;
129 unsigned int mtu;
130 uint8_t mac_addr[6];
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 /* _RTE_KNI_COMMON_H_ */