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