1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef __BFA_MSGQ_H__
20#define __BFA_MSGQ_H__
21
22#include "bfa_defs.h"
23#include "bfi.h"
24#include "bfa_ioc.h"
25#include "bfa_cs.h"
26
27#define BFA_MSGQ_FREE_CNT(_q) \
28 (((_q)->consumer_index - (_q)->producer_index - 1) & ((_q)->depth - 1))
29
30#define BFA_MSGQ_INDX_ADD(_q_indx, _qe_num, _q_depth) \
31 ((_q_indx) = (((_q_indx) + (_qe_num)) & ((_q_depth) - 1)))
32
33#define BFA_MSGQ_CMDQ_NUM_ENTRY 128
34#define BFA_MSGQ_CMDQ_SIZE \
35 (BFI_MSGQ_CMD_ENTRY_SIZE * BFA_MSGQ_CMDQ_NUM_ENTRY)
36
37#define BFA_MSGQ_RSPQ_NUM_ENTRY 128
38#define BFA_MSGQ_RSPQ_SIZE \
39 (BFI_MSGQ_RSP_ENTRY_SIZE * BFA_MSGQ_RSPQ_NUM_ENTRY)
40
41#define bfa_msgq_cmd_set(_cmd, _cbfn, _cbarg, _msg_size, _msg_hdr) \
42do { \
43 (_cmd)->cbfn = (_cbfn); \
44 (_cmd)->cbarg = (_cbarg); \
45 (_cmd)->msg_size = (_msg_size); \
46 (_cmd)->msg_hdr = (_msg_hdr); \
47} while (0)
48
49struct bfa_msgq;
50
51typedef void (*bfa_msgq_cmdcbfn_t)(void *cbarg, enum bfa_status status);
52
53struct bfa_msgq_cmd_entry {
54 struct list_head qe;
55 bfa_msgq_cmdcbfn_t cbfn;
56 void *cbarg;
57 size_t msg_size;
58 struct bfi_msgq_mhdr *msg_hdr;
59};
60
61enum bfa_msgq_cmdq_flags {
62 BFA_MSGQ_CMDQ_F_DB_UPDATE = 1,
63};
64
65struct bfa_msgq_cmdq {
66 bfa_fsm_t fsm;
67 enum bfa_msgq_cmdq_flags flags;
68
69 u16 producer_index;
70 u16 consumer_index;
71 u16 depth;
72 struct bfa_dma addr;
73 struct bfa_mbox_cmd dbell_mb;
74
75 u16 token;
76 int offset;
77 int bytes_to_copy;
78 struct bfa_mbox_cmd copy_mb;
79
80 struct list_head pending_q;
81
82 struct bfa_msgq *msgq;
83};
84
85enum bfa_msgq_rspq_flags {
86 BFA_MSGQ_RSPQ_F_DB_UPDATE = 1,
87};
88
89typedef void (*bfa_msgq_mcfunc_t)(void *cbarg, struct bfi_msgq_mhdr *mhdr);
90
91struct bfa_msgq_rspq {
92 bfa_fsm_t fsm;
93 enum bfa_msgq_rspq_flags flags;
94
95 u16 producer_index;
96 u16 consumer_index;
97 u16 depth;
98 struct bfa_dma addr;
99 struct bfa_mbox_cmd dbell_mb;
100
101 int nmclass;
102 struct {
103 bfa_msgq_mcfunc_t cbfn;
104 void *cbarg;
105 } rsphdlr[BFI_MC_MAX];
106
107 struct bfa_msgq *msgq;
108};
109
110struct bfa_msgq {
111 struct bfa_msgq_cmdq cmdq;
112 struct bfa_msgq_rspq rspq;
113
114 struct bfa_wc init_wc;
115 struct bfa_mbox_cmd init_mb;
116
117 struct bfa_ioc_notify ioc_notify;
118 struct bfa_ioc *ioc;
119};
120
121u32 bfa_msgq_meminfo(void);
122void bfa_msgq_memclaim(struct bfa_msgq *msgq, u8 *kva, u64 pa);
123void bfa_msgq_attach(struct bfa_msgq *msgq, struct bfa_ioc *ioc);
124void bfa_msgq_regisr(struct bfa_msgq *msgq, enum bfi_mclass mc,
125 bfa_msgq_mcfunc_t cbfn, void *cbarg);
126void bfa_msgq_cmd_post(struct bfa_msgq *msgq,
127 struct bfa_msgq_cmd_entry *cmd);
128void bfa_msgq_rsp_copy(struct bfa_msgq *msgq, u8 *buf, size_t buf_len);
129
130#endif
131