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