1 /* Copyright (c) 2014 Broadcom Corporation
3 * Permission to use, copy, modify, and/or distribute this software for any
4 * purpose with or without fee is hereby granted, provided that the above
5 * copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 #ifndef BRCMFMAC_COMMONRING_H
16 #define BRCMFMAC_COMMONRING_H
19 struct brcmf_commonring
{
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
);
41 atomic_t outstanding_tx
;
45 void 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
);
51 void brcmf_commonring_config(struct brcmf_commonring
*commonring
, u16 depth
,
52 u16 item_len
, void *buf_addr
);
53 void brcmf_commonring_lock(struct brcmf_commonring
*commonring
);
54 void brcmf_commonring_unlock(struct brcmf_commonring
*commonring
);
55 bool brcmf_commonring_write_available(struct brcmf_commonring
*commonring
);
56 void *brcmf_commonring_reserve_for_write(struct brcmf_commonring
*commonring
);
58 brcmf_commonring_reserve_for_write_multiple(struct brcmf_commonring
*commonring
,
59 u16 n_items
, u16
*alloced
);
60 int brcmf_commonring_write_complete(struct brcmf_commonring
*commonring
);
61 void brcmf_commonring_write_cancel(struct brcmf_commonring
*commonring
,
63 void *brcmf_commonring_get_read_ptr(struct brcmf_commonring
*commonring
,
65 int brcmf_commonring_read_complete(struct brcmf_commonring
*commonring
,
68 #define brcmf_commonring_n_items(commonring) (commonring->depth)
69 #define brcmf_commonring_len_item(commonring) (commonring->item_len)
72 #endif /* BRCMFMAC_COMMONRING_H */