9506 Want support for QLogic QL41000/45000 series devices
[unleashed.git] / usr / src / uts / common / io / qede / 579xx / drivers / ecore / ecore_spq.h
blobcf75647b5a7c321abc24fd230a3e002819e98ef7
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, v.1, (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2014-2017 Cavium, Inc.
24 * The contents of this file are subject to the terms of the Common Development
25 * and Distribution License, v.1, (the "License").
27 * You may not use this file except in compliance with the License.
29 * You can obtain a copy of the License at available
30 * at http://opensource.org/licenses/CDDL-1.0
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
36 #ifndef __ECORE_SPQ_H__
37 #define __ECORE_SPQ_H__
39 #include "ecore_hsi_common.h"
40 #include "ecore_status.h"
41 #include "ecore_hsi_eth.h"
42 #include "ecore_hsi_fcoe.h"
43 #include "tcp_common.h"
44 #include "ecore_hsi_iscsi.h"
45 #include "ecore_hsi_roce.h"
46 #include "ecore_hsi_iwarp.h"
47 #include "ecore_chain.h"
48 #include "ecore_sp_api.h"
50 union ramrod_data
52 struct pf_start_ramrod_data pf_start;
53 struct pf_update_ramrod_data pf_update;
54 struct rl_update_ramrod_data rl_update;
55 struct rx_queue_start_ramrod_data rx_queue_start;
56 struct rx_queue_update_ramrod_data rx_queue_update;
57 struct rx_queue_stop_ramrod_data rx_queue_stop;
58 struct tx_queue_start_ramrod_data tx_queue_start;
59 struct tx_queue_stop_ramrod_data tx_queue_stop;
60 struct vport_start_ramrod_data vport_start;
61 struct vport_stop_ramrod_data vport_stop;
62 struct rx_update_gft_filter_data rx_update_gft;
63 struct vport_update_ramrod_data vport_update;
64 struct core_rx_start_ramrod_data core_rx_queue_start;
65 struct core_rx_stop_ramrod_data core_rx_queue_stop;
66 struct core_tx_start_ramrod_data core_tx_queue_start;
67 struct core_tx_stop_ramrod_data core_tx_queue_stop;
68 struct vport_filter_update_ramrod_data vport_filter_update;
70 struct rdma_init_func_ramrod_data rdma_init_func;
71 struct rdma_close_func_ramrod_data rdma_close_func;
72 struct rdma_register_tid_ramrod_data rdma_register_tid;
73 struct rdma_deregister_tid_ramrod_data rdma_deregister_tid;
74 struct roce_create_qp_resp_ramrod_data roce_create_qp_resp;
75 struct roce_create_qp_req_ramrod_data roce_create_qp_req;
76 struct roce_modify_qp_resp_ramrod_data roce_modify_qp_resp;
77 struct roce_modify_qp_req_ramrod_data roce_modify_qp_req;
78 struct roce_query_qp_resp_ramrod_data roce_query_qp_resp;
79 struct roce_query_qp_req_ramrod_data roce_query_qp_req;
80 struct roce_destroy_qp_resp_ramrod_data roce_destroy_qp_resp;
81 struct roce_destroy_qp_req_ramrod_data roce_destroy_qp_req;
82 struct roce_init_func_ramrod_data roce_init_func;
84 struct rdma_create_cq_ramrod_data rdma_create_cq;
85 struct rdma_resize_cq_ramrod_data rdma_resize_cq;
86 struct rdma_destroy_cq_ramrod_data rdma_destroy_cq;
87 struct rdma_srq_create_ramrod_data rdma_create_srq;
88 struct rdma_srq_destroy_ramrod_data rdma_destroy_srq;
89 struct rdma_srq_modify_ramrod_data rdma_modify_srq;
91 struct iwarp_create_qp_ramrod_data iwarp_create_qp;
92 struct iwarp_tcp_offload_ramrod_data iwarp_tcp_offload;
93 struct iwarp_mpa_offload_ramrod_data iwarp_mpa_offload;
94 struct iwarp_modify_qp_ramrod_data iwarp_modify_qp;
95 struct iwarp_query_qp_ramrod_data iwarp_query_qp;
96 struct iwarp_init_func_ramrod_data iwarp_init_func;
98 struct fcoe_init_ramrod_params fcoe_init;
99 struct fcoe_conn_offload_ramrod_params fcoe_conn_ofld;
100 struct fcoe_conn_terminate_ramrod_params fcoe_conn_terminate;
101 struct fcoe_stat_ramrod_params fcoe_stat;
103 struct iscsi_slow_path_hdr iscsi_empty;
104 struct iscsi_init_ramrod_params iscsi_init;
105 struct iscsi_spe_func_dstry iscsi_destroy;
106 struct iscsi_spe_conn_offload iscsi_conn_offload;
107 struct iscsi_conn_update_ramrod_params iscsi_conn_update;
108 struct iscsi_spe_conn_mac_update iscsi_conn_mac_update;
109 struct iscsi_spe_conn_termination iscsi_conn_terminate;
111 struct vf_start_ramrod_data vf_start;
112 struct vf_stop_ramrod_data vf_stop;
115 #define EQ_MAX_CREDIT 0xffffffff
117 enum spq_priority {
118 ECORE_SPQ_PRIORITY_NORMAL,
119 ECORE_SPQ_PRIORITY_HIGH,
122 union ecore_spq_req_comp {
123 struct ecore_spq_comp_cb cb;
124 u64 *done_addr;
127 /* SPQ_MODE_EBLOCK */
128 struct ecore_spq_comp_done {
129 u64 done;
130 u8 fw_return_code;
133 struct ecore_spq_entry {
134 osal_list_entry_t list;
136 u8 flags;
138 /* HSI slow path element */
139 struct slow_path_element elem;
141 union ramrod_data ramrod;
143 enum spq_priority priority;
145 /* pending queue for this entry */
146 osal_list_t *queue;
148 enum spq_mode comp_mode;
149 struct ecore_spq_comp_cb comp_cb;
150 struct ecore_spq_comp_done comp_done; /* SPQ_MODE_EBLOCK */
153 struct ecore_eq {
154 struct ecore_chain chain;
155 u8 eq_sb_index; /* index within the SB */
156 __le16 *p_fw_cons; /* ptr to index value */
159 struct ecore_consq {
160 struct ecore_chain chain;
163 struct ecore_spq {
164 osal_spinlock_t lock;
166 osal_list_t unlimited_pending;
167 osal_list_t pending;
168 osal_list_t completion_pending;
169 osal_list_t free_pool;
171 struct ecore_chain chain;
173 /* allocated dma-able memory for spq entries (+ramrod data) */
174 dma_addr_t p_phys;
175 struct ecore_spq_entry *p_virt;
177 /* Bitmap for handling out-of-order completions */
178 #define SPQ_RING_SIZE \
179 (CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element))
180 #define SPQ_COMP_BMAP_SIZE (SPQ_RING_SIZE / (sizeof(unsigned long) * 8 /* BITS_PER_LONG */))
181 unsigned long p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
182 u8 comp_bitmap_idx;
183 #define SPQ_COMP_BMAP_SET_BIT(p_spq, idx) \
184 do { \
185 OSAL_SET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap); \
186 } while (0)
187 #define SPQ_COMP_BMAP_CLEAR_BIT(p_spq, idx) \
188 do { \
189 OSAL_CLEAR_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap); \
190 } while (0)
191 #define SPQ_COMP_BMAP_TEST_BIT(p_spq, idx) \
192 (OSAL_TEST_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
194 /* Statistics */
195 u32 unlimited_pending_count;
196 u32 normal_count;
197 u32 high_count;
198 u32 comp_sent_count;
199 u32 comp_count;
201 u32 cid;
204 struct ecore_port;
205 struct ecore_hwfn;
208 * @brief ecore_spq_post - Posts a Slow hwfn request to FW, or lacking that
209 * Pends it to the future list.
211 * @param p_hwfn
212 * @param p_req
214 * @return enum _ecore_status_t
216 enum _ecore_status_t ecore_spq_post(struct ecore_hwfn *p_hwfn,
217 struct ecore_spq_entry *p_ent,
218 u8 *fw_return_code);
221 * @brief ecore_spq_allocate - Alloocates & initializes the SPQ and EQ.
223 * @param p_hwfn
225 * @return enum _ecore_status_t
227 enum _ecore_status_t ecore_spq_alloc(struct ecore_hwfn *p_hwfn);
230 * @brief ecore_spq_setup - Reset the SPQ to its start state.
232 * @param p_hwfn
234 void ecore_spq_setup(struct ecore_hwfn *p_hwfn);
237 * @brief ecore_spq_deallocate - Deallocates the given SPQ struct.
239 * @param p_hwfn
241 void ecore_spq_free(struct ecore_hwfn *p_hwfn);
244 * @brief ecore_spq_get_entry - Obtain an entrry from the spq
245 * free pool list.
249 * @param p_hwfn
250 * @param pp_ent
252 * @return enum _ecore_status_t
254 enum _ecore_status_t
255 ecore_spq_get_entry(struct ecore_hwfn *p_hwfn,
256 struct ecore_spq_entry **pp_ent);
259 * @brief ecore_spq_return_entry - Return an entry to spq free
260 * pool list
262 * @param p_hwfn
263 * @param p_ent
265 void ecore_spq_return_entry(struct ecore_hwfn *p_hwfn,
266 struct ecore_spq_entry *p_ent);
268 * @brief ecore_eq_allocate - Allocates & initializes an EQ struct
270 * @param p_hwfn
271 * @param num_elem number of elements in the eq
273 * @return enum _ecore_status_t
275 enum _ecore_status_t ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem);
278 * @brief ecore_eq_setup - Reset the EQ to its start state.
280 * @param p_hwfn
282 void ecore_eq_setup(struct ecore_hwfn *p_hwfn);
285 * @brief ecore_eq_free - deallocates the given EQ struct.
287 * @param p_hwfn
289 void ecore_eq_free(struct ecore_hwfn *p_hwfn);
292 * @brief ecore_eq_prod_update - update the FW with default EQ producer
294 * @param p_hwfn
295 * @param prod
297 void ecore_eq_prod_update(struct ecore_hwfn *p_hwfn,
298 u16 prod);
301 * @brief ecore_eq_completion - Completes currently pending EQ elements
303 * @param p_hwfn
304 * @param cookie
306 * @return enum _ecore_status_t
308 enum _ecore_status_t ecore_eq_completion(struct ecore_hwfn *p_hwfn,
309 void *cookie);
312 * @brief ecore_spq_completion - Completes a single event
314 * @param p_hwfn
315 * @param echo - echo value from cookie (used for determining completion)
316 * @param p_data - data from cookie (used in callback function if applicable)
318 * @return enum _ecore_status_t
320 enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
321 __le16 echo,
322 u8 fw_return_code,
323 union event_ring_data *p_data);
326 * @brief ecore_spq_get_cid - Given p_hwfn, return cid for the hwfn's SPQ
328 * @param p_hwfn
330 * @return u32 - SPQ CID
332 u32 ecore_spq_get_cid(struct ecore_hwfn *p_hwfn);
335 * @brief ecore_consq_alloc - Allocates & initializes an ConsQ struct
337 * @param p_hwfn
339 * @return enum _ecore_status_t
341 enum _ecore_status_t ecore_consq_alloc(struct ecore_hwfn *p_hwfn);
344 * @brief ecore_consq_setup - Reset the ConsQ to its start state.
346 * @param p_hwfn
348 void ecore_consq_setup(struct ecore_hwfn *p_hwfn);
351 * @brief ecore_consq_free - deallocates the given ConsQ struct.
353 * @param p_hwfn
355 void ecore_consq_free(struct ecore_hwfn *p_hwfn);
357 #endif /* __ECORE_SPQ_H__ */