1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2017-2018 Netronome Systems, Inc. */
7 #include <linux/bitops.h>
8 #include <linux/types.h>
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.
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
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,
29 struct nfp_bpf_cap_tlv_func {
34 struct nfp_bpf_cap_tlv_adjust_head {
38 __le32 guaranteed_sub;
39 __le32 guaranteed_add;
42 #define NFP_BPF_ADJUST_HEAD_NO_META BIT(0)
44 struct nfp_bpf_cap_tlv_maps {
54 * Types defined for map related control messages
57 /* BPF ABIv2 fixed-length control message fields */
58 #define CMSG_MAP_KEY_LW 16
59 #define CMSG_MAP_VALUE_LW 16
61 enum nfp_bpf_cmsg_status {
63 CMSG_RC_ERR_MAP_FD = 1,
64 CMSG_RC_ERR_MAP_NOENT = 2,
65 CMSG_RC_ERR_MAP_ERR = 3,
66 CMSG_RC_ERR_MAP_PARSE = 4,
67 CMSG_RC_ERR_MAP_EXIST = 5,
68 CMSG_RC_ERR_MAP_NOMEM = 6,
69 CMSG_RC_ERR_MAP_E2BIG = 7,
72 struct cmsg_reply_map_simple {
73 struct nfp_ccm_hdr hdr;
77 struct cmsg_req_map_alloc_tbl {
78 struct nfp_ccm_hdr hdr;
79 __be32 key_size; /* in bytes */
80 __be32 value_size; /* in bytes */
83 __be32 map_flags; /* reserved */
86 struct cmsg_reply_map_alloc_tbl {
87 struct cmsg_reply_map_simple reply_hdr;
91 struct cmsg_req_map_free_tbl {
92 struct nfp_ccm_hdr hdr;
96 struct cmsg_reply_map_free_tbl {
97 struct cmsg_reply_map_simple reply_hdr;
101 struct cmsg_req_map_op {
102 struct nfp_ccm_hdr hdr;
109 struct cmsg_reply_map_op {
110 struct cmsg_reply_map_simple reply_hdr;
116 struct cmsg_bpf_event {
117 struct nfp_ccm_hdr hdr;