1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2016-2019 Netronome Systems, Inc. */
7 #include <linux/bitmap.h>
8 #include <linux/skbuff.h>
9 #include <linux/wait.h>
16 NFP_CCM_TYPE_BPF_MAP_ALLOC = 1,
17 NFP_CCM_TYPE_BPF_MAP_FREE = 2,
18 NFP_CCM_TYPE_BPF_MAP_LOOKUP = 3,
19 NFP_CCM_TYPE_BPF_MAP_UPDATE = 4,
20 NFP_CCM_TYPE_BPF_MAP_DELETE = 5,
21 NFP_CCM_TYPE_BPF_MAP_GETNEXT = 6,
22 NFP_CCM_TYPE_BPF_MAP_GETFIRST = 7,
23 NFP_CCM_TYPE_BPF_BPF_EVENT = 8,
27 #define NFP_CCM_ABI_VERSION 1
35 static inline u8 nfp_ccm_get_type(struct sk_buff *skb)
37 struct nfp_ccm_hdr *hdr;
39 hdr = (struct nfp_ccm_hdr *)skb->data;
44 static inline unsigned int nfp_ccm_get_tag(struct sk_buff *skb)
46 struct nfp_ccm_hdr *hdr;
48 hdr = (struct nfp_ccm_hdr *)skb->data;
50 return be16_to_cpu(hdr->tag);
56 * struct nfp_ccm - common control message handling
59 * @tag_allocator: bitmap of control message tags in use
60 * @tag_alloc_next: next tag bit to allocate
61 * @tag_alloc_last: next tag bit to be freed
63 * @replies: received cmsg replies waiting to be consumed
64 * @wq: work queue for waiting for cmsg replies
69 DECLARE_BITMAP(tag_allocator, U16_MAX + 1);
73 struct sk_buff_head replies;
74 struct wait_queue_head wq;
77 int nfp_ccm_init(struct nfp_ccm *ccm, struct nfp_app *app);
78 void nfp_ccm_clean(struct nfp_ccm *ccm);
79 void nfp_ccm_rx(struct nfp_ccm *ccm, struct sk_buff *skb);
81 nfp_ccm_communicate(struct nfp_ccm *ccm, struct sk_buff *skb,
82 enum nfp_ccm_type type, unsigned int reply_size);