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]
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"
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
118 ECORE_SPQ_PRIORITY_NORMAL
,
119 ECORE_SPQ_PRIORITY_HIGH
,
122 union ecore_spq_req_comp
{
123 struct ecore_spq_comp_cb cb
;
127 /* SPQ_MODE_EBLOCK */
128 struct ecore_spq_comp_done
{
133 struct ecore_spq_entry
{
134 osal_list_entry_t list
;
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 */
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 */
154 struct ecore_chain chain
;
155 u8 eq_sb_index
; /* index within the SB */
156 __le16
*p_fw_cons
; /* ptr to index value */
160 struct ecore_chain chain
;
164 osal_spinlock_t lock
;
166 osal_list_t unlimited_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) */
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
];
183 #define SPQ_COMP_BMAP_SET_BIT(p_spq, idx) \
185 OSAL_SET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap); \
187 #define SPQ_COMP_BMAP_CLEAR_BIT(p_spq, idx) \
189 OSAL_CLEAR_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap); \
191 #define SPQ_COMP_BMAP_TEST_BIT(p_spq, idx) \
192 (OSAL_TEST_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
195 u32 unlimited_pending_count
;
208 * @brief ecore_spq_post - Posts a Slow hwfn request to FW, or lacking that
209 * Pends it to the future list.
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
,
221 * @brief ecore_spq_allocate - Alloocates & initializes the SPQ and EQ.
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.
234 void ecore_spq_setup(struct ecore_hwfn
*p_hwfn
);
237 * @brief ecore_spq_deallocate - Deallocates the given SPQ struct.
241 void ecore_spq_free(struct ecore_hwfn
*p_hwfn
);
244 * @brief ecore_spq_get_entry - Obtain an entrry from the spq
252 * @return 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
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
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.
282 void ecore_eq_setup(struct ecore_hwfn
*p_hwfn
);
285 * @brief ecore_eq_free - deallocates the given EQ struct.
289 void ecore_eq_free(struct ecore_hwfn
*p_hwfn
);
292 * @brief ecore_eq_prod_update - update the FW with default EQ producer
297 void ecore_eq_prod_update(struct ecore_hwfn
*p_hwfn
,
301 * @brief ecore_eq_completion - Completes currently pending EQ elements
306 * @return enum _ecore_status_t
308 enum _ecore_status_t
ecore_eq_completion(struct ecore_hwfn
*p_hwfn
,
312 * @brief ecore_spq_completion - Completes a single event
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
,
323 union event_ring_data
*p_data
);
326 * @brief ecore_spq_get_cid - Given p_hwfn, return cid for the hwfn's SPQ
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
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.
348 void ecore_consq_setup(struct ecore_hwfn
*p_hwfn
);
351 * @brief ecore_consq_free - deallocates the given ConsQ struct.
355 void ecore_consq_free(struct ecore_hwfn
*p_hwfn
);
357 #endif /* __ECORE_SPQ_H__ */