1189251Ssam// SPDX-License-Identifier: ISC 2189251Ssam/* 3189251Ssam * Copyright (c) 2014 Broadcom Corporation 4189251Ssam */ 5252726Srpaulo#ifndef BRCMFMAC_COMMONRING_H 6252726Srpaulo#define BRCMFMAC_COMMONRING_H 7189251Ssam 8189251Ssam 9189251Ssamstruct brcmf_commonring { 10189251Ssam u16 r_ptr; 11189251Ssam u16 w_ptr; 12189251Ssam u16 f_ptr; 13189251Ssam u16 depth; 14189251Ssam u16 item_len; 15189251Ssam 16189251Ssam void *buf_addr; 17189251Ssam 18189251Ssam int (*cr_ring_bell)(void *ctx); 19189251Ssam int (*cr_update_rptr)(void *ctx); 20189251Ssam int (*cr_update_wptr)(void *ctx); 21189251Ssam int (*cr_write_rptr)(void *ctx); 22189251Ssam int (*cr_write_wptr)(void *ctx); 23189251Ssam 24189251Ssam void *cr_ctx; 25189251Ssam 26189251Ssam spinlock_t lock; 27189251Ssam unsigned long flags; 28189251Ssam bool inited; 29189251Ssam bool was_full; 30189251Ssam 31189251Ssam atomic_t outstanding_tx; 32189251Ssam}; 33189251Ssam 34189251Ssam 35189251Ssamvoid brcmf_commonring_register_cb(struct brcmf_commonring *commonring, 36189251Ssam int (*cr_ring_bell)(void *ctx), 37189251Ssam int (*cr_update_rptr)(void *ctx), 38189251Ssam int (*cr_update_wptr)(void *ctx), 39189251Ssam int (*cr_write_rptr)(void *ctx), 40189251Ssam int (*cr_write_wptr)(void *ctx), void *ctx); 41189251Ssamvoid brcmf_commonring_config(struct brcmf_commonring *commonring, u16 depth, 42189251Ssam u16 item_len, void *buf_addr); 43189251Ssamvoid brcmf_commonring_lock(struct brcmf_commonring *commonring); 44189251Ssamvoid brcmf_commonring_unlock(struct brcmf_commonring *commonring); 45189251Ssambool brcmf_commonring_write_available(struct brcmf_commonring *commonring); 46189251Ssamvoid *brcmf_commonring_reserve_for_write(struct brcmf_commonring *commonring); 47189251Ssamvoid * 48189251Ssambrcmf_commonring_reserve_for_write_multiple(struct brcmf_commonring *commonring, 49189251Ssam u16 n_items, u16 *alloced); 50189251Ssamint brcmf_commonring_write_complete(struct brcmf_commonring *commonring); 51189251Ssamvoid brcmf_commonring_write_cancel(struct brcmf_commonring *commonring, 52189251Ssam u16 n_items); 53189251Ssamvoid *brcmf_commonring_get_read_ptr(struct brcmf_commonring *commonring, 54189251Ssam u16 *n_items); 55189251Ssamint brcmf_commonring_read_complete(struct brcmf_commonring *commonring, 56189251Ssam u16 n_items); 57189251Ssam 58189251Ssam#define brcmf_commonring_n_items(commonring) (commonring->depth) 59189251Ssam#define brcmf_commonring_len_item(commonring) (commonring->item_len) 60189251Ssam 61189251Ssam 62189251Ssam#endif /* BRCMFMAC_COMMONRING_H */ 63189251Ssam