xref: /freebsd/sys/dev/qlnx/qlnxe/ecore_iscsi_api.h (revision 0e6acb26)
1 /*
2  * Copyright (c) 2017-2018 Cavium, Inc.
3  * All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
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.
14  *
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.
26  *
27  * $FreeBSD$
28  *
29  */
30 
31 #ifndef __ECORE_ISCSI_API_H__
32 #define __ECORE_ISCSI_API_H__
33 
34 typedef enum _ecore_status_t (*iscsi_event_cb_t)(void *context,
35 						 u8 fw_event_code,
36 						 void *fw_handle);
37 
38 struct ecore_iscsi_conn {
39 	osal_list_entry_t	list_entry;
40 	bool			free_on_delete;
41 
42 	u16			conn_id;
43 	u32			icid;
44 	u32			fw_cid;
45 
46 	u8			layer_code;
47 	u8			offl_flags;
48 	u8			connect_mode;
49 	u32			initial_ack;
50 	dma_addr_t		sq_pbl_addr;
51 	struct ecore_chain	r2tq;
52 	struct ecore_chain	xhq;
53 	struct ecore_chain	uhq;
54 
55 	struct tcp_upload_params *tcp_upload_params_virt_addr;
56 	dma_addr_t		tcp_upload_params_phys_addr;
57 	struct scsi_terminate_extra_params *queue_cnts_virt_addr;
58 	dma_addr_t		queue_cnts_phys_addr;
59 	dma_addr_t		syn_phy_addr;
60 
61 	u16			syn_ip_payload_length;
62 	u8			local_mac[6];
63 	u8			remote_mac[6];
64 	u16			vlan_id;
65 	u8			tcp_flags;
66 	u8			ip_version;
67 	u32			remote_ip[4];
68 	u32			local_ip[4];
69 	u8			ka_max_probe_cnt;
70 	u8			dup_ack_theshold;
71 	u32			rcv_next;
72 	u32			snd_una;
73 	u32			snd_next;
74 	u32			snd_max;
75 	u32			snd_wnd;
76 	u32			rcv_wnd;
77 	u32			snd_wl1;
78 	u32			cwnd;
79 	u32			ss_thresh;
80 	u16			srtt;
81 	u16			rtt_var;
82 	u32			ts_recent;
83 	u32			ts_recent_age;
84 	u32			total_rt;
85 	u32			ka_timeout_delta;
86 	u32			rt_timeout_delta;
87 	u8			dup_ack_cnt;
88 	u8			snd_wnd_probe_cnt;
89 	u8			ka_probe_cnt;
90 	u8			rt_cnt;
91 	u32			flow_label;
92 	u32			ka_timeout;
93 	u32			ka_interval;
94 	u32			max_rt_time;
95 	u32			initial_rcv_wnd;
96 	u8			ttl;
97 	u8			tos_or_tc;
98 	u16			remote_port;
99 	u16			local_port;
100 	u16			mss;
101 	u8			snd_wnd_scale;
102 	u8			rcv_wnd_scale;
103 	u16			da_timeout_value;
104 	u8			ack_frequency;
105 
106 	u8			update_flag;
107 #define	ECORE_ISCSI_CONN_HD_EN		0x01
108 #define	ECORE_ISCSI_CONN_DD_EN		0x02
109 #define	ECORE_ISCSI_CONN_INITIAL_R2T	0x04
110 #define	ECORE_ISCSI_CONN_IMMEDIATE_DATA	0x08
111 
112 	u8			default_cq;
113 	u32			max_seq_size;
114 	u32			max_recv_pdu_length;
115 	u32			max_send_pdu_length;
116 	u32			first_seq_length;
117 	u32			exp_stat_sn;
118 	u32			stat_sn;
119 	u16			physical_q0;
120 	u16			physical_q1;
121 	u8			abortive_dsconnect;
122 };
123 
124 struct ecore_iscsi_stats
125 {
126 	u64 iscsi_rx_bytes_cnt;
127 	u64 iscsi_rx_packet_cnt;
128 	u64 iscsi_rx_new_ooo_isle_events_cnt;
129 	u32 iscsi_cmdq_threshold_cnt;
130 	u32 iscsi_rq_threshold_cnt;
131 	u32 iscsi_immq_threshold_cnt;
132 
133 	u64 iscsi_rx_dropped_pdus_task_not_valid;
134 
135 	u64 iscsi_rx_data_pdu_cnt;
136 	u64 iscsi_rx_r2t_pdu_cnt;
137 	u64 iscsi_rx_total_pdu_cnt;
138 
139 	u64 iscsi_tx_go_to_slow_start_event_cnt;
140 	u64 iscsi_tx_fast_retransmit_event_cnt;
141 
142 	u64 iscsi_tx_data_pdu_cnt;
143 	u64 iscsi_tx_r2t_pdu_cnt;
144 	u64 iscsi_tx_total_pdu_cnt;
145 
146 	u64 iscsi_tx_bytes_cnt;
147 	u64 iscsi_tx_packet_cnt;
148 };
149 
150 /**
151  * @brief ecore_iscsi_acquire_connection - allocate resources,
152  *        provides connecion handle (CID)as out parameter.
153  *
154  * @param p_path
155  * @param p_conn  partially initialized incoming container of
156  *                iSCSI connection data
157  * @return enum _ecore_status_t
158  */
159 enum _ecore_status_t
160 ecore_iscsi_acquire_connection(struct ecore_hwfn *p_hwfn,
161 			       struct ecore_iscsi_conn *p_in_conn,
162 			       struct ecore_iscsi_conn **p_out_conn);
163 
164 void OSAL_IOMEM *ecore_iscsi_get_db_addr(struct ecore_hwfn *p_hwfn,
165 					 u32 cid);
166 
167 void OSAL_IOMEM *ecore_iscsi_get_global_cmdq_cons(struct ecore_hwfn *p_hwfn,
168 						  u8 relative_q_id);
169 
170 void OSAL_IOMEM *ecore_iscsi_get_primary_bdq_prod(struct ecore_hwfn *p_hwfn,
171 						  u8 bdq_id);
172 
173 void OSAL_IOMEM *ecore_iscsi_get_secondary_bdq_prod(struct ecore_hwfn *p_hwfn,
174 						    u8 bdq_id);
175 
176 /**
177  * @brief ecore_iscsi_offload_connection - offload previously
178  *        allocated iSCSI connection
179  *
180  * @param p_path
181  * @param p_conn  container of iSCSI connection data
182  *
183  * @return enum _ecore_status_t
184  */
185 enum _ecore_status_t
186 ecore_iscsi_offload_connection(struct ecore_hwfn *p_hwfn,
187 			       struct ecore_iscsi_conn *p_conn);
188 
189 /**
190  * @brief ecore_iscsi_release_connection - deletes connecton
191  *        resources (incliding container of iSCSI connection
192  *        data)
193  *
194  * @param p_path
195  * @param p_conn  container of iSCSI connection data
196  */
197 void ecore_iscsi_release_connection(struct ecore_hwfn *p_hwfn,
198 				    struct ecore_iscsi_conn *p_conn);
199 
200 /**
201  * @brief ecore_iscsi_terminate_connection - destroys previously
202  *        offloaded iSCSI connection
203  *
204  * @param p_path
205  * @param p_conn  container of iSCSI connection data
206  *
207  * @return enum _ecore_status_t
208  */
209 enum _ecore_status_t
210 ecore_iscsi_terminate_connection(struct ecore_hwfn *p_hwfn,
211 				 struct ecore_iscsi_conn *p_conn);
212 
213 
214 /**
215  * @brief ecore_iscsi_update_connection - updates previously
216  *        offloaded iSCSI connection
217  *
218  *
219  * @param p_path
220  * @param p_conn  container of iSCSI connection data
221  *
222  * @return enum _ecore_status_t
223  */
224 enum _ecore_status_t
225 ecore_iscsi_update_connection(struct ecore_hwfn *p_hwfn,
226 			      struct ecore_iscsi_conn *p_conn);
227 
228 /**
229  * @brief ecore_iscsi_mac_update_connection - updates remote MAC for previously
230  *        offloaded iSCSI connection
231  *
232  *
233  * @param p_path
234  * @param p_conn  container of iSCSI connection data
235  *
236  * @return enum _ecore_status_t
237  */
238 enum _ecore_status_t
239 ecore_iscsi_update_remote_mac(struct ecore_hwfn *p_hwfn,
240 			      struct ecore_iscsi_conn *p_conn);
241 
242 /**
243  * @brief ecore_iscsi_clear_connection_sq - clear SQ
244  *        offloaded iSCSI connection
245  *
246  *
247  * @param p_path
248  * @param p_conn  container of iSCSI connection data
249  *
250  * @return enum _ecore_status_t
251  */
252 enum _ecore_status_t
253 ecore_iscsi_clear_connection_sq(struct ecore_hwfn *p_hwfn,
254 				struct ecore_iscsi_conn *p_conn);
255 
256 /**
257  * @brief ecore_sp_iscsi_func_start
258  *
259  * This ramrod inits iSCSI functionality in FW
260  *
261  * @param p_path
262  * @param comp_mode
263  * @param comp_addr
264  *
265  * @return enum _ecore_status_t
266  */
267 enum _ecore_status_t
268 ecore_sp_iscsi_func_start(struct ecore_hwfn *p_hwfn,
269 			  enum spq_mode comp_mode,
270 			  struct ecore_spq_comp_cb *p_comp_addr,
271 			  void *async_event_context,
272 			  iscsi_event_cb_t async_event_cb);
273 
274 enum _ecore_status_t
275 ecore_sp_iscsi_func_stop(struct ecore_hwfn *p_hwfn,
276 			 enum spq_mode comp_mode,
277 			 struct ecore_spq_comp_cb *p_comp_addr);
278 
279 enum _ecore_status_t
280 ecore_iscsi_get_stats(struct ecore_hwfn *p_hwfn,
281 		      struct ecore_iscsi_stats *stats);
282 
283 #endif
284