1
2
3
4
5#ifndef BRCMFMAC_COMMONRING_H
6#define BRCMFMAC_COMMONRING_H
7
8
9struct brcmf_commonring {
10 u16 r_ptr;
11 u16 w_ptr;
12 u16 f_ptr;
13 u16 depth;
14 u16 item_len;
15
16 void *buf_addr;
17
18 int (*cr_ring_bell)(void *ctx);
19 int (*cr_update_rptr)(void *ctx);
20 int (*cr_update_wptr)(void *ctx);
21 int (*cr_write_rptr)(void *ctx);
22 int (*cr_write_wptr)(void *ctx);
23
24 void *cr_ctx;
25
26 spinlock_t lock;
27 unsigned long flags;
28 bool inited;
29 bool was_full;
30
31 atomic_t outstanding_tx;
32};
33
34
35void brcmf_commonring_register_cb(struct brcmf_commonring *commonring,
36 int (*cr_ring_bell)(void *ctx),
37 int (*cr_update_rptr)(void *ctx),
38 int (*cr_update_wptr)(void *ctx),
39 int (*cr_write_rptr)(void *ctx),
40 int (*cr_write_wptr)(void *ctx), void *ctx);
41void brcmf_commonring_config(struct brcmf_commonring *commonring, u16 depth,
42 u16 item_len, void *buf_addr);
43void brcmf_commonring_lock(struct brcmf_commonring *commonring);
44void brcmf_commonring_unlock(struct brcmf_commonring *commonring);
45bool brcmf_commonring_write_available(struct brcmf_commonring *commonring);
46void *brcmf_commonring_reserve_for_write(struct brcmf_commonring *commonring);
47void *
48brcmf_commonring_reserve_for_write_multiple(struct brcmf_commonring *commonring,
49 u16 n_items, u16 *alloced);
50int brcmf_commonring_write_complete(struct brcmf_commonring *commonring);
51void brcmf_commonring_write_cancel(struct brcmf_commonring *commonring,
52 u16 n_items);
53void *brcmf_commonring_get_read_ptr(struct brcmf_commonring *commonring,
54 u16 *n_items);
55int brcmf_commonring_read_complete(struct brcmf_commonring *commonring,
56 u16 n_items);
57
58#define brcmf_commonring_n_items(commonring) (commonring->depth)
59#define brcmf_commonring_len_item(commonring) (commonring->item_len)
60
61
62#endif
63