2 * Copyright (c) 2017-2018 Cavium, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __ECORE_SPQ_H__
32 #define __ECORE_SPQ_H__
34 #include "ecore_hsi_common.h"
35 #include "ecore_status.h"
36 #include "ecore_hsi_eth.h"
37 #include "ecore_hsi_fcoe.h"
38 #include "tcp_common.h"
39 #include "ecore_hsi_iscsi.h"
40 #include "ecore_hsi_roce.h"
41 #include "ecore_hsi_iwarp.h"
42 #include "ecore_chain.h"
43 #include "ecore_sp_api.h"
47 struct pf_start_ramrod_data pf_start;
48 struct pf_update_ramrod_data pf_update;
49 struct rl_update_ramrod_data rl_update;
50 struct rx_queue_start_ramrod_data rx_queue_start;
51 struct rx_queue_update_ramrod_data rx_queue_update;
52 struct rx_queue_stop_ramrod_data rx_queue_stop;
53 struct tx_queue_start_ramrod_data tx_queue_start;
54 struct tx_queue_stop_ramrod_data tx_queue_stop;
55 struct vport_start_ramrod_data vport_start;
56 struct vport_stop_ramrod_data vport_stop;
57 struct rx_update_gft_filter_data rx_update_gft;
58 struct vport_update_ramrod_data vport_update;
59 struct core_rx_start_ramrod_data core_rx_queue_start;
60 struct core_rx_stop_ramrod_data core_rx_queue_stop;
61 struct core_tx_start_ramrod_data core_tx_queue_start;
62 struct core_tx_stop_ramrod_data core_tx_queue_stop;
63 struct vport_filter_update_ramrod_data vport_filter_update;
65 struct rdma_init_func_ramrod_data rdma_init_func;
66 struct rdma_close_func_ramrod_data rdma_close_func;
67 struct rdma_register_tid_ramrod_data rdma_register_tid;
68 struct rdma_deregister_tid_ramrod_data rdma_deregister_tid;
69 struct roce_create_qp_resp_ramrod_data roce_create_qp_resp;
70 struct roce_create_qp_req_ramrod_data roce_create_qp_req;
71 struct roce_modify_qp_resp_ramrod_data roce_modify_qp_resp;
72 struct roce_modify_qp_req_ramrod_data roce_modify_qp_req;
73 struct roce_query_qp_resp_ramrod_data roce_query_qp_resp;
74 struct roce_query_qp_req_ramrod_data roce_query_qp_req;
75 struct roce_destroy_qp_resp_ramrod_data roce_destroy_qp_resp;
76 struct roce_destroy_qp_req_ramrod_data roce_destroy_qp_req;
77 struct roce_init_func_ramrod_data roce_init_func;
79 struct rdma_create_cq_ramrod_data rdma_create_cq;
80 struct rdma_resize_cq_ramrod_data rdma_resize_cq;
81 struct rdma_destroy_cq_ramrod_data rdma_destroy_cq;
82 struct rdma_srq_create_ramrod_data rdma_create_srq;
83 struct rdma_srq_destroy_ramrod_data rdma_destroy_srq;
84 struct rdma_srq_modify_ramrod_data rdma_modify_srq;
86 struct iwarp_create_qp_ramrod_data iwarp_create_qp;
87 struct iwarp_tcp_offload_ramrod_data iwarp_tcp_offload;
88 struct iwarp_mpa_offload_ramrod_data iwarp_mpa_offload;
89 struct iwarp_modify_qp_ramrod_data iwarp_modify_qp;
90 struct iwarp_query_qp_ramrod_data iwarp_query_qp;
91 struct iwarp_init_func_ramrod_data iwarp_init_func;
93 struct fcoe_init_ramrod_params fcoe_init;
94 struct fcoe_conn_offload_ramrod_params fcoe_conn_ofld;
95 struct fcoe_conn_terminate_ramrod_params fcoe_conn_terminate;
96 struct fcoe_stat_ramrod_params fcoe_stat;
98 struct iscsi_slow_path_hdr iscsi_empty;
99 struct iscsi_init_ramrod_params iscsi_init;
100 struct iscsi_spe_func_dstry iscsi_destroy;
101 struct iscsi_spe_conn_offload iscsi_conn_offload;
102 struct iscsi_conn_update_ramrod_params iscsi_conn_update;
103 struct iscsi_spe_conn_mac_update iscsi_conn_mac_update;
104 struct iscsi_spe_conn_termination iscsi_conn_terminate;
105 struct iscsi_spe_conn_statistics iscsi_conn_statistics;
107 struct vf_start_ramrod_data vf_start;
108 struct vf_stop_ramrod_data vf_stop;
111 #define EQ_MAX_CREDIT 0xffffffff
114 ECORE_SPQ_PRIORITY_NORMAL,
115 ECORE_SPQ_PRIORITY_HIGH,
118 union ecore_spq_req_comp {
119 struct ecore_spq_comp_cb cb;
123 /* SPQ_MODE_EBLOCK */
124 struct ecore_spq_comp_done {
129 struct ecore_spq_entry {
130 osal_list_entry_t list;
134 /* HSI slow path element */
135 struct slow_path_element elem;
137 union ramrod_data ramrod;
139 enum spq_priority priority;
141 /* pending queue for this entry */
144 enum spq_mode comp_mode;
145 struct ecore_spq_comp_cb comp_cb;
146 struct ecore_spq_comp_done comp_done; /* SPQ_MODE_EBLOCK */
150 struct ecore_chain chain;
151 u8 eq_sb_index; /* index within the SB */
152 __le16 *p_fw_cons; /* ptr to index value */
156 struct ecore_chain chain;
159 typedef enum _ecore_status_t
160 (*ecore_spq_async_comp_cb)(struct ecore_hwfn *p_hwfn,
163 union event_ring_data *data,
167 ecore_spq_register_async_cb(struct ecore_hwfn *p_hwfn,
168 enum protocol_type protocol_id,
169 ecore_spq_async_comp_cb cb);
172 ecore_spq_unregister_async_cb(struct ecore_hwfn *p_hwfn,
173 enum protocol_type protocol_id);
176 osal_spinlock_t lock;
178 osal_list_t unlimited_pending;
180 osal_list_t completion_pending;
181 osal_list_t free_pool;
183 struct ecore_chain chain;
185 /* allocated dma-able memory for spq entries (+ramrod data) */
187 struct ecore_spq_entry *p_virt;
189 /* Bitmap for handling out-of-order completions */
190 #define SPQ_RING_SIZE \
191 (CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element))
192 #define SPQ_COMP_BMAP_SIZE (SPQ_RING_SIZE / (sizeof(unsigned long) * 8 /* BITS_PER_LONG */))
193 unsigned long p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
195 #define SPQ_COMP_BMAP_SET_BIT(p_spq, idx) \
197 OSAL_SET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap); \
199 #define SPQ_COMP_BMAP_CLEAR_BIT(p_spq, idx) \
201 OSAL_CLEAR_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap); \
203 #define SPQ_COMP_BMAP_TEST_BIT(p_spq, idx) \
204 (OSAL_TEST_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
207 u32 unlimited_pending_count;
216 struct core_db_data db_data;
217 ecore_spq_async_comp_cb async_comp_cb[MAX_PROTOCOL_TYPE];
224 * @brief ecore_spq_post - Posts a Slow hwfn request to FW, or lacking that
225 * Pends it to the future list.
230 * @return enum _ecore_status_t
232 enum _ecore_status_t ecore_spq_post(struct ecore_hwfn *p_hwfn,
233 struct ecore_spq_entry *p_ent,
237 * @brief ecore_spq_allocate - Alloocates & initializes the SPQ and EQ.
241 * @return enum _ecore_status_t
243 enum _ecore_status_t ecore_spq_alloc(struct ecore_hwfn *p_hwfn);
246 * @brief ecore_spq_setup - Reset the SPQ to its start state.
250 void ecore_spq_setup(struct ecore_hwfn *p_hwfn);
253 * @brief ecore_spq_deallocate - Deallocates the given SPQ struct.
257 void ecore_spq_free(struct ecore_hwfn *p_hwfn);
260 * @brief ecore_spq_get_entry - Obtain an entrry from the spq
268 * @return enum _ecore_status_t
271 ecore_spq_get_entry(struct ecore_hwfn *p_hwfn,
272 struct ecore_spq_entry **pp_ent);
275 * @brief ecore_spq_return_entry - Return an entry to spq free
281 void ecore_spq_return_entry(struct ecore_hwfn *p_hwfn,
282 struct ecore_spq_entry *p_ent);
284 * @brief ecore_eq_allocate - Allocates & initializes an EQ struct
287 * @param num_elem number of elements in the eq
289 * @return enum _ecore_status_t
291 enum _ecore_status_t ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem);
294 * @brief ecore_eq_setup - Reset the EQ to its start state.
298 void ecore_eq_setup(struct ecore_hwfn *p_hwfn);
301 * @brief ecore_eq_free - deallocates the given EQ struct.
305 void ecore_eq_free(struct ecore_hwfn *p_hwfn);
308 * @brief ecore_eq_prod_update - update the FW with default EQ producer
313 void ecore_eq_prod_update(struct ecore_hwfn *p_hwfn,
317 * @brief ecore_eq_completion - Completes currently pending EQ elements
322 * @return enum _ecore_status_t
324 enum _ecore_status_t ecore_eq_completion(struct ecore_hwfn *p_hwfn,
328 * @brief ecore_spq_completion - Completes a single event
331 * @param echo - echo value from cookie (used for determining completion)
332 * @param p_data - data from cookie (used in callback function if applicable)
334 * @return enum _ecore_status_t
336 enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
339 union event_ring_data *p_data);
342 * @brief ecore_spq_get_cid - Given p_hwfn, return cid for the hwfn's SPQ
346 * @return u32 - SPQ CID
348 u32 ecore_spq_get_cid(struct ecore_hwfn *p_hwfn);
351 * @brief ecore_consq_alloc - Allocates & initializes an ConsQ struct
355 * @return enum _ecore_status_t
357 enum _ecore_status_t ecore_consq_alloc(struct ecore_hwfn *p_hwfn);
360 * @brief ecore_consq_setup - Reset the ConsQ to its start state.
364 void ecore_consq_setup(struct ecore_hwfn *p_hwfn);
367 * @brief ecore_consq_free - deallocates the given ConsQ struct.
371 void ecore_consq_free(struct ecore_hwfn *p_hwfn);
372 enum _ecore_status_t ecore_spq_pend_post(struct ecore_hwfn *p_hwfn);
373 #endif /* __ECORE_SPQ_H__ */