Lines Matching defs:ccm
6 #include "ccm.h"
14 static bool nfp_ccm_all_tags_busy(struct nfp_ccm *ccm)
18 used_tags = ccm->tag_alloc_next - ccm->tag_alloc_last;
23 static int nfp_ccm_alloc_tag(struct nfp_ccm *ccm)
29 if (unlikely(nfp_ccm_all_tags_busy(ccm))) {
30 ccm_warn(ccm->app, "all FW request contexts busy!\n");
34 WARN_ON(__test_and_set_bit(ccm->tag_alloc_next, ccm->tag_allocator));
35 return ccm->tag_alloc_next++;
38 static void nfp_ccm_free_tag(struct nfp_ccm *ccm, u16 tag)
40 WARN_ON(!__test_and_clear_bit(tag, ccm->tag_allocator));
42 while (!test_bit(ccm->tag_alloc_last, ccm->tag_allocator) &&
43 ccm->tag_alloc_last != ccm->tag_alloc_next)
44 ccm->tag_alloc_last++;
47 static struct sk_buff *__nfp_ccm_reply(struct nfp_ccm *ccm, u16 tag)
52 skb_queue_walk(&ccm->replies, skb) {
55 nfp_ccm_free_tag(ccm, tag);
56 __skb_unlink(skb, &ccm->replies);
65 nfp_ccm_reply(struct nfp_ccm *ccm, struct nfp_app *app, u16 tag)
70 skb = __nfp_ccm_reply(ccm, tag);
77 nfp_ccm_reply_drop_tag(struct nfp_ccm *ccm, struct nfp_app *app, u16 tag)
82 skb = __nfp_ccm_reply(ccm, tag);
84 nfp_ccm_free_tag(ccm, tag);
91 nfp_ccm_wait_reply(struct nfp_ccm *ccm, struct nfp_app *app,
99 skb = nfp_ccm_reply(ccm, app, tag);
104 err = wait_event_interruptible_timeout(ccm->wq,
105 skb = nfp_ccm_reply(ccm, app,
112 skb = nfp_ccm_reply_drop_tag(ccm, app, tag);
128 nfp_ccm_communicate(struct nfp_ccm *ccm, struct sk_buff *skb,
131 struct nfp_app *app = ccm->app;
136 tag = nfp_ccm_alloc_tag(ccm);
152 skb = nfp_ccm_wait_reply(ccm, app, type, tag);
175 void nfp_ccm_rx(struct nfp_ccm *ccm, struct sk_buff *skb)
177 struct nfp_app *app = ccm->app;
188 if (unlikely(!test_bit(tag, ccm->tag_allocator))) {
194 __skb_queue_tail(&ccm->replies, skb);
195 wake_up_interruptible_all(&ccm->wq);
206 int nfp_ccm_init(struct nfp_ccm *ccm, struct nfp_app *app)
208 ccm->app = app;
209 skb_queue_head_init(&ccm->replies);
210 init_waitqueue_head(&ccm->wq);
214 void nfp_ccm_clean(struct nfp_ccm *ccm)
216 WARN_ON(!skb_queue_empty(&ccm->replies));