1 | /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ |
2 | /* Copyright (C) 2017-2018 Netronome Systems, Inc. */ |
3 | |
4 | #ifndef NFP_BPF_FW_H |
5 | #define NFP_BPF_FW_H 1 |
6 | |
7 | #include <linux/bitops.h> |
8 | #include <linux/types.h> |
9 | #include "../ccm.h" |
10 | |
11 | /* Kernel's enum bpf_reg_type is not uABI so people may change it breaking |
12 | * our FW ABI. In that case we will do translation in the driver. |
13 | */ |
14 | #define NFP_BPF_SCALAR_VALUE 1 |
15 | #define NFP_BPF_MAP_VALUE 4 |
16 | #define NFP_BPF_STACK 6 |
17 | #define NFP_BPF_PACKET_DATA 8 |
18 | |
19 | enum bpf_cap_tlv_type { |
20 | NFP_BPF_CAP_TYPE_FUNC = 1, |
21 | NFP_BPF_CAP_TYPE_ADJUST_HEAD = 2, |
22 | NFP_BPF_CAP_TYPE_MAPS = 3, |
23 | NFP_BPF_CAP_TYPE_RANDOM = 4, |
24 | NFP_BPF_CAP_TYPE_QUEUE_SELECT = 5, |
25 | NFP_BPF_CAP_TYPE_ADJUST_TAIL = 6, |
26 | NFP_BPF_CAP_TYPE_ABI_VERSION = 7, |
27 | NFP_BPF_CAP_TYPE_CMSG_MULTI_ENT = 8, |
28 | }; |
29 | |
30 | struct nfp_bpf_cap_tlv_func { |
31 | __le32 func_id; |
32 | __le32 func_addr; |
33 | }; |
34 | |
35 | struct nfp_bpf_cap_tlv_adjust_head { |
36 | __le32 flags; |
37 | __le32 off_min; |
38 | __le32 off_max; |
39 | __le32 guaranteed_sub; |
40 | __le32 guaranteed_add; |
41 | }; |
42 | |
43 | #define NFP_BPF_ADJUST_HEAD_NO_META BIT(0) |
44 | |
45 | struct nfp_bpf_cap_tlv_maps { |
46 | __le32 types; |
47 | __le32 max_maps; |
48 | __le32 max_elems; |
49 | __le32 max_key_sz; |
50 | __le32 max_val_sz; |
51 | __le32 max_elem_sz; |
52 | }; |
53 | |
54 | /* |
55 | * Types defined for map related control messages |
56 | */ |
57 | |
58 | /* BPF ABIv2 fixed-length control message fields */ |
59 | #define CMSG_MAP_KEY_LW 16 |
60 | #define CMSG_MAP_VALUE_LW 16 |
61 | |
62 | enum nfp_bpf_cmsg_status { |
63 | CMSG_RC_SUCCESS = 0, |
64 | CMSG_RC_ERR_MAP_FD = 1, |
65 | CMSG_RC_ERR_MAP_NOENT = 2, |
66 | CMSG_RC_ERR_MAP_ERR = 3, |
67 | CMSG_RC_ERR_MAP_PARSE = 4, |
68 | CMSG_RC_ERR_MAP_EXIST = 5, |
69 | CMSG_RC_ERR_MAP_NOMEM = 6, |
70 | CMSG_RC_ERR_MAP_E2BIG = 7, |
71 | }; |
72 | |
73 | struct cmsg_reply_map_simple { |
74 | struct nfp_ccm_hdr hdr; |
75 | __be32 rc; |
76 | }; |
77 | |
78 | struct cmsg_req_map_alloc_tbl { |
79 | struct nfp_ccm_hdr hdr; |
80 | __be32 key_size; /* in bytes */ |
81 | __be32 value_size; /* in bytes */ |
82 | __be32 max_entries; |
83 | __be32 map_type; |
84 | __be32 map_flags; /* reserved */ |
85 | }; |
86 | |
87 | struct cmsg_reply_map_alloc_tbl { |
88 | struct cmsg_reply_map_simple reply_hdr; |
89 | __be32 tid; |
90 | }; |
91 | |
92 | struct cmsg_req_map_free_tbl { |
93 | struct nfp_ccm_hdr hdr; |
94 | __be32 tid; |
95 | }; |
96 | |
97 | struct cmsg_reply_map_free_tbl { |
98 | struct cmsg_reply_map_simple reply_hdr; |
99 | __be32 count; |
100 | }; |
101 | |
102 | struct cmsg_req_map_op { |
103 | struct nfp_ccm_hdr hdr; |
104 | __be32 tid; |
105 | __be32 count; |
106 | __be32 flags; |
107 | u8 data[]; |
108 | }; |
109 | |
110 | struct cmsg_reply_map_op { |
111 | struct cmsg_reply_map_simple reply_hdr; |
112 | __be32 count; |
113 | __be32 resv; |
114 | u8 data[]; |
115 | }; |
116 | |
117 | struct cmsg_bpf_event { |
118 | struct nfp_ccm_hdr hdr; |
119 | __be32 cpu_id; |
120 | __be64 map_ptr; |
121 | __be32 data_size; |
122 | __be32 pkt_size; |
123 | u8 data[]; |
124 | }; |
125 | #endif |
126 | |