Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: ISC
0002 /*
0003  * Copyright (c) 2014 Broadcom Corporation
0004  */
0005 #ifndef BRCMFMAC_COMMONRING_H
0006 #define BRCMFMAC_COMMONRING_H
0007 
0008 
0009 struct brcmf_commonring {
0010     u16 r_ptr;
0011     u16 w_ptr;
0012     u16 f_ptr;
0013     u16 depth;
0014     u16 item_len;
0015 
0016     void *buf_addr;
0017 
0018     int (*cr_ring_bell)(void *ctx);
0019     int (*cr_update_rptr)(void *ctx);
0020     int (*cr_update_wptr)(void *ctx);
0021     int (*cr_write_rptr)(void *ctx);
0022     int (*cr_write_wptr)(void *ctx);
0023 
0024     void *cr_ctx;
0025 
0026     spinlock_t lock;
0027     unsigned long flags;
0028     bool inited;
0029     bool was_full;
0030 
0031     atomic_t outstanding_tx;
0032 };
0033 
0034 
0035 void brcmf_commonring_register_cb(struct brcmf_commonring *commonring,
0036                   int (*cr_ring_bell)(void *ctx),
0037                   int (*cr_update_rptr)(void *ctx),
0038                   int (*cr_update_wptr)(void *ctx),
0039                   int (*cr_write_rptr)(void *ctx),
0040                   int (*cr_write_wptr)(void *ctx), void *ctx);
0041 void brcmf_commonring_config(struct brcmf_commonring *commonring, u16 depth,
0042                  u16 item_len, void *buf_addr);
0043 void brcmf_commonring_lock(struct brcmf_commonring *commonring);
0044 void brcmf_commonring_unlock(struct brcmf_commonring *commonring);
0045 bool brcmf_commonring_write_available(struct brcmf_commonring *commonring);
0046 void *brcmf_commonring_reserve_for_write(struct brcmf_commonring *commonring);
0047 void *
0048 brcmf_commonring_reserve_for_write_multiple(struct brcmf_commonring *commonring,
0049                         u16 n_items, u16 *alloced);
0050 int brcmf_commonring_write_complete(struct brcmf_commonring *commonring);
0051 void brcmf_commonring_write_cancel(struct brcmf_commonring *commonring,
0052                    u16 n_items);
0053 void *brcmf_commonring_get_read_ptr(struct brcmf_commonring *commonring,
0054                     u16 *n_items);
0055 int brcmf_commonring_read_complete(struct brcmf_commonring *commonring,
0056                    u16 n_items);
0057 
0058 #define brcmf_commonring_n_items(commonring) (commonring->depth)
0059 #define brcmf_commonring_len_item(commonring) (commonring->item_len)
0060 
0061 
0062 #endif /* BRCMFMAC_COMMONRING_H */