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