2 * Copyright (C) 2017-2018 Netronome Systems, Inc.
4 * This software is dual licensed under the GNU General License Version 2,
5 * June 1991 as shown in the file COPYING in the top-level directory of this
6 * source tree or the BSD 2-Clause License provided below. You have the
7 * option to license this software under the complete terms of either license.
9 * The BSD 2-Clause License:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * 1. Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * 2. Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 #define NFP_BPF_FW_H 1
37 #include <linux/bitops.h>
38 #include <linux/types.h>
40 /* Kernel's enum bpf_reg_type is not uABI so people may change it breaking
41 * our FW ABI. In that case we will do translation in the driver.
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
48 enum 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,
57 struct nfp_bpf_cap_tlv_func {
62 struct nfp_bpf_cap_tlv_adjust_head {
66 __le32 guaranteed_sub;
67 __le32 guaranteed_add;
70 #define NFP_BPF_ADJUST_HEAD_NO_META BIT(0)
72 struct nfp_bpf_cap_tlv_maps {
82 * Types defined for map related control messages
84 #define CMSG_MAP_ABI_VERSION 1
86 enum 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,
98 #define CMSG_TYPE_MAP_REPLY_BIT 7
99 #define __CMSG_REPLY(req) (BIT(CMSG_TYPE_MAP_REPLY_BIT) | (req))
101 #define CMSG_MAP_KEY_LW 16
102 #define CMSG_MAP_VALUE_LW 16
104 enum nfp_bpf_cmsg_status {
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,
121 struct cmsg_reply_map_simple {
126 struct cmsg_req_map_alloc_tbl {
128 __be32 key_size; /* in bytes */
129 __be32 value_size; /* in bytes */
132 __be32 map_flags; /* reserved */
135 struct cmsg_reply_map_alloc_tbl {
136 struct cmsg_reply_map_simple reply_hdr;
140 struct cmsg_req_map_free_tbl {
145 struct cmsg_reply_map_free_tbl {
146 struct cmsg_reply_map_simple reply_hdr;
150 struct cmsg_key_value_pair {
151 __be32 key[CMSG_MAP_KEY_LW];
152 __be32 value[CMSG_MAP_VALUE_LW];
155 struct cmsg_req_map_op {
160 struct cmsg_key_value_pair elem[0];
163 struct cmsg_reply_map_op {
164 struct cmsg_reply_map_simple reply_hdr;
167 struct cmsg_key_value_pair elem[0];
170 struct cmsg_bpf_event {