1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34#ifndef NFP_BPF_FW_H
35#define NFP_BPF_FW_H 1
36
37#include <linux/bitops.h>
38#include <linux/types.h>
39
40
41
42
43#define NFP_BPF_SCALAR_VALUE 1
44#define NFP_BPF_MAP_VALUE 4
45#define NFP_BPF_STACK 6
46#define NFP_BPF_PACKET_DATA 8
47
48enum bpf_cap_tlv_type {
49 NFP_BPF_CAP_TYPE_FUNC = 1,
50 NFP_BPF_CAP_TYPE_ADJUST_HEAD = 2,
51 NFP_BPF_CAP_TYPE_MAPS = 3,
52 NFP_BPF_CAP_TYPE_RANDOM = 4,
53 NFP_BPF_CAP_TYPE_QUEUE_SELECT = 5,
54 NFP_BPF_CAP_TYPE_ADJUST_TAIL = 6,
55};
56
57struct nfp_bpf_cap_tlv_func {
58 __le32 func_id;
59 __le32 func_addr;
60};
61
62struct nfp_bpf_cap_tlv_adjust_head {
63 __le32 flags;
64 __le32 off_min;
65 __le32 off_max;
66 __le32 guaranteed_sub;
67 __le32 guaranteed_add;
68};
69
70#define NFP_BPF_ADJUST_HEAD_NO_META BIT(0)
71
72struct nfp_bpf_cap_tlv_maps {
73 __le32 types;
74 __le32 max_maps;
75 __le32 max_elems;
76 __le32 max_key_sz;
77 __le32 max_val_sz;
78 __le32 max_elem_sz;
79};
80
81
82
83
84#define CMSG_MAP_ABI_VERSION 1
85
86enum nfp_bpf_cmsg_type {
87 CMSG_TYPE_MAP_ALLOC = 1,
88 CMSG_TYPE_MAP_FREE = 2,
89 CMSG_TYPE_MAP_LOOKUP = 3,
90 CMSG_TYPE_MAP_UPDATE = 4,
91 CMSG_TYPE_MAP_DELETE = 5,
92 CMSG_TYPE_MAP_GETNEXT = 6,
93 CMSG_TYPE_MAP_GETFIRST = 7,
94 CMSG_TYPE_BPF_EVENT = 8,
95 __CMSG_TYPE_MAP_MAX,
96};
97
98#define CMSG_TYPE_MAP_REPLY_BIT 7
99#define __CMSG_REPLY(req) (BIT(CMSG_TYPE_MAP_REPLY_BIT) | (req))
100
101#define CMSG_MAP_KEY_LW 16
102#define CMSG_MAP_VALUE_LW 16
103
104enum nfp_bpf_cmsg_status {
105 CMSG_RC_SUCCESS = 0,
106 CMSG_RC_ERR_MAP_FD = 1,
107 CMSG_RC_ERR_MAP_NOENT = 2,
108 CMSG_RC_ERR_MAP_ERR = 3,
109 CMSG_RC_ERR_MAP_PARSE = 4,
110 CMSG_RC_ERR_MAP_EXIST = 5,
111 CMSG_RC_ERR_MAP_NOMEM = 6,
112 CMSG_RC_ERR_MAP_E2BIG = 7,
113};
114
115struct cmsg_hdr {
116 u8 type;
117 u8 ver;
118 __be16 tag;
119};
120
121struct cmsg_reply_map_simple {
122 struct cmsg_hdr hdr;
123 __be32 rc;
124};
125
126struct cmsg_req_map_alloc_tbl {
127 struct cmsg_hdr hdr;
128 __be32 key_size;
129 __be32 value_size;
130 __be32 max_entries;
131 __be32 map_type;
132 __be32 map_flags;
133};
134
135struct cmsg_reply_map_alloc_tbl {
136 struct cmsg_reply_map_simple reply_hdr;
137 __be32 tid;
138};
139
140struct cmsg_req_map_free_tbl {
141 struct cmsg_hdr hdr;
142 __be32 tid;
143};
144
145struct cmsg_reply_map_free_tbl {
146 struct cmsg_reply_map_simple reply_hdr;
147 __be32 count;
148};
149
150struct cmsg_key_value_pair {
151 __be32 key[CMSG_MAP_KEY_LW];
152 __be32 value[CMSG_MAP_VALUE_LW];
153};
154
155struct cmsg_req_map_op {
156 struct cmsg_hdr hdr;
157 __be32 tid;
158 __be32 count;
159 __be32 flags;
160 struct cmsg_key_value_pair elem[0];
161};
162
163struct cmsg_reply_map_op {
164 struct cmsg_reply_map_simple reply_hdr;
165 __be32 count;
166 __be32 resv;
167 struct cmsg_key_value_pair elem[0];
168};
169
170struct cmsg_bpf_event {
171 struct cmsg_hdr hdr;
172 __be32 cpu_id;
173 __be64 map_ptr;
174 __be32 data_size;
175 __be32 pkt_size;
176 u8 data[0];
177};
178#endif
179