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