xref: /freebsd/sys/dev/qlnx/qlnxe/ecore_iscsi_api.h (revision c1d255d3)
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 #ifndef __EXTRACT__LINUX__IF__
35 typedef enum _ecore_status_t (*iscsi_event_cb_t)(void *context,
36 						 u8 fw_event_code,
37 						 void *fw_handle);
38 
39 struct ecore_iscsi_stats
40 {
41 	u64 iscsi_rx_bytes_cnt;
42 	u64 iscsi_rx_packet_cnt;
43 	u64 iscsi_rx_new_ooo_isle_events_cnt;
44 	u32 iscsi_cmdq_threshold_cnt;
45 	u32 iscsi_rq_threshold_cnt;
46 	u32 iscsi_immq_threshold_cnt;
47 
48 	u64 iscsi_rx_dropped_pdus_task_not_valid;
49 
50 	u64 iscsi_rx_data_pdu_cnt;
51 	u64 iscsi_rx_r2t_pdu_cnt;
52 	u64 iscsi_rx_total_pdu_cnt;
53 
54 	u64 iscsi_tx_go_to_slow_start_event_cnt;
55 	u64 iscsi_tx_fast_retransmit_event_cnt;
56 
57 	u64 iscsi_tx_data_pdu_cnt;
58 	u64 iscsi_tx_r2t_pdu_cnt;
59 	u64 iscsi_tx_total_pdu_cnt;
60 
61 	u64 iscsi_tx_bytes_cnt;
62 	u64 iscsi_tx_packet_cnt;
63 
64 	u64 iscsi_rx_tcp_payload_bytes_cnt;
65 	u64 iscsi_rx_tcp_pkt_cnt;
66 	u64 iscsi_rx_pure_ack_cnt;
67 
68 	u64 iscsi_rx_dup_ack_cnt;
69 
70 	u64 iscsi_tx_pure_ack_cnt;
71 	u64 iscsi_tx_delayed_ack_cnt;
72 
73 	u64 iscsi_tx_tcp_payload_bytes_cnt;
74 	u64 iscsi_tx_tcp_pkt_cnt;
75 };
76 
77 struct ecore_iscsi_tcp_stats
78 {
79 	u64 iscsi_tcp_tx_packets_cnt;
80 	u64 iscsi_tcp_tx_bytes_cnt;
81 	u64 iscsi_tcp_tx_rxmit_cnt;
82 	u64 iscsi_tcp_rx_packets_cnt;
83 	u64 iscsi_tcp_rx_bytes_cnt;
84 	u64 iscsi_tcp_rx_dup_ack_cnt;
85 	u32 iscsi_tcp_rx_chksum_err_cnt;
86 };
87 #endif
88 
89 #ifndef __EXTRACT__LINUX__C__
90 struct ecore_iscsi_conn {
91 	osal_list_entry_t	list_entry;
92 	bool			free_on_delete;
93 
94 	u16			conn_id;
95 	u32			icid;
96 	u32			fw_cid;
97 
98 	u8			layer_code;
99 	u8			offl_flags;
100 	u8			connect_mode;
101 	u32			initial_ack;
102 	dma_addr_t		sq_pbl_addr;
103 	struct ecore_chain	r2tq;
104 	struct ecore_chain	xhq;
105 	struct ecore_chain	uhq;
106 
107 	struct tcp_upload_params *tcp_upload_params_virt_addr;
108 	dma_addr_t		tcp_upload_params_phys_addr;
109 	struct iscsi_conn_stats_params *conn_stats_params_virt_addr;
110 	dma_addr_t		conn_stats_params_phys_addr;
111 	struct scsi_terminate_extra_params *queue_cnts_virt_addr;
112 	dma_addr_t		queue_cnts_phys_addr;
113 	dma_addr_t		syn_phy_addr;
114 
115 	u16			syn_ip_payload_length;
116 	u8			local_mac[6];
117 	u8			remote_mac[6];
118 	u16			vlan_id;
119 	u16			tcp_flags;
120 	u8			ip_version;
121 	u32			remote_ip[4];
122 	u32			local_ip[4];
123 	u8			ka_max_probe_cnt;
124 	u8			dup_ack_theshold;
125 	u32			rcv_next;
126 	u32			snd_una;
127 	u32			snd_next;
128 	u32			snd_max;
129 	u32			snd_wnd;
130 	u32			rcv_wnd;
131 	u32			snd_wl1;
132 	u32			cwnd;
133 	u32			ss_thresh;
134 	u16			srtt;
135 	u16			rtt_var;
136 	u32			ts_recent;
137 	u32			ts_recent_age;
138 	u32			total_rt;
139 	u32			ka_timeout_delta;
140 	u32			rt_timeout_delta;
141 	u8			dup_ack_cnt;
142 	u8			snd_wnd_probe_cnt;
143 	u8			ka_probe_cnt;
144 	u8			rt_cnt;
145 	u32			flow_label;
146 	u32			ka_timeout;
147 	u32			ka_interval;
148 	u32			max_rt_time;
149 	u32			initial_rcv_wnd;
150 	u8			ttl;
151 	u8			tos_or_tc;
152 	u16			remote_port;
153 	u16			local_port;
154 	u16			mss;
155 	u8			snd_wnd_scale;
156 	u8			rcv_wnd_scale;
157 	u16			da_timeout_value;
158 	u8			ack_frequency;
159 
160 	u8			update_flag;
161 #define	ECORE_ISCSI_CONN_HD_EN		0x01
162 #define	ECORE_ISCSI_CONN_DD_EN		0x02
163 #define	ECORE_ISCSI_CONN_INITIAL_R2T	0x04
164 #define	ECORE_ISCSI_CONN_IMMEDIATE_DATA	0x08
165 
166 	u8			default_cq;
167 	u32			max_seq_size;
168 	u32			max_recv_pdu_length;
169 	u32			max_send_pdu_length;
170 	u32			first_seq_length;
171 	u32			exp_stat_sn;
172 	u32			stat_sn;
173 	u16			physical_q0;
174 	u16			physical_q1;
175 	u8			abortive_dsconnect;
176 	u8			dif_on_immediate;
177 #define ECORE_ISCSI_CONN_DIF_ON_IMM_DIS		0
178 #define ECORE_ISCSI_CONN_DIF_ON_IMM_DEFAULT	1
179 #define ECORE_ISCSI_CONN_DIF_ON_IMM_LUN_MAPPER	2
180 
181 	dma_addr_t		lun_mapper_phys_addr;
182 	u32			initial_ref_tag;
183 	u16			application_tag;
184 	u16			application_tag_mask;
185 	u8			validate_guard;
186 	u8			validate_app_tag;
187 	u8			validate_ref_tag;
188 	u8			forward_guard;
189 	u8			forward_app_tag;
190 	u8			forward_ref_tag;
191 	u8			interval_size;		/* 0=512B, 1=4KB */
192 	u8			network_interface;	/* 0=None, 1=DIF */
193 	u8			host_interface;		/* 0=None, 1=DIF, 2=DIX */
194 	u8			ref_tag_mask;		/* mask for refernce tag handling */
195 	u8			forward_app_tag_with_mask;
196 	u8			forward_ref_tag_with_mask;
197 
198 	u8			ignore_app_tag;
199 	u8			initial_ref_tag_is_valid;
200 	u8			host_guard_type;	/* 0 = IP checksum, 1 = CRC */
201 	u8			protection_type;	/* 1/2/3 - Protection Type */
202 	u8			crc_seed;		/* 0=0x0000, 1=0xffff */
203 	u8			keep_ref_tag_const;
204 };
205 #endif
206 
207 /**
208  * @brief ecore_iscsi_acquire_connection - allocate resources,
209  *        provides connecion handle (CID)as out parameter.
210  *
211  * @param p_path
212  * @param p_conn  partially initialized incoming container of
213  *                iSCSI connection data
214  * @return enum _ecore_status_t
215  */
216 enum _ecore_status_t
217 ecore_iscsi_acquire_connection(struct ecore_hwfn *p_hwfn,
218 			       struct ecore_iscsi_conn *p_in_conn,
219 			       struct ecore_iscsi_conn **p_out_conn);
220 
221 /**
222  * @brief ecore_iscsi_setup_connection- initialize connection data.
223  *
224  * @param p_conn  container of iSCSI connection data
225  * @return enum _ecore_status_t
226  */
227 enum _ecore_status_t
228 ecore_iscsi_setup_connection(struct ecore_iscsi_conn *p_conn);
229 
230 void OSAL_IOMEM *ecore_iscsi_get_db_addr(struct ecore_hwfn *p_hwfn,
231 					 u32 cid);
232 
233 void OSAL_IOMEM *ecore_iscsi_get_global_cmdq_cons(struct ecore_hwfn *p_hwfn,
234 						  u8 relative_q_id);
235 
236 void OSAL_IOMEM *ecore_iscsi_get_primary_bdq_prod(struct ecore_hwfn *p_hwfn,
237 						  u8 bdq_id);
238 
239 void OSAL_IOMEM *ecore_iscsi_get_secondary_bdq_prod(struct ecore_hwfn *p_hwfn,
240 						    u8 bdq_id);
241 
242 /**
243  * @brief ecore_iscsi_offload_connection - offload previously
244  *        allocated iSCSI connection
245  *
246  * @param p_path
247  * @param p_conn  container of iSCSI connection data
248  *
249  * @return enum _ecore_status_t
250  */
251 enum _ecore_status_t
252 ecore_iscsi_offload_connection(struct ecore_hwfn *p_hwfn,
253 			       struct ecore_iscsi_conn *p_conn);
254 
255 /**
256  * @brief ecore_iscsi_release_connection - deletes connecton
257  *        resources (incliding container of iSCSI connection
258  *        data)
259  *
260  * @param p_path
261  * @param p_conn  container of iSCSI connection data
262  */
263 void ecore_iscsi_release_connection(struct ecore_hwfn *p_hwfn,
264 				    struct ecore_iscsi_conn *p_conn);
265 
266 /**
267  * @brief ecore_iscsi_terminate_connection - destroys previously
268  *        offloaded iSCSI connection
269  *
270  * @param p_path
271  * @param p_conn  container of iSCSI connection data
272  *
273  * @return enum _ecore_status_t
274  */
275 enum _ecore_status_t
276 ecore_iscsi_terminate_connection(struct ecore_hwfn *p_hwfn,
277 				 struct ecore_iscsi_conn *p_conn);
278 
279 /**
280  * @brief ecore_iscsi_update_connection - updates previously
281  *        offloaded iSCSI connection
282  *
283  *
284  * @param p_path
285  * @param p_conn  container of iSCSI connection data
286  *
287  * @return enum _ecore_status_t
288  */
289 enum _ecore_status_t
290 ecore_iscsi_update_connection(struct ecore_hwfn *p_hwfn,
291 			      struct ecore_iscsi_conn *p_conn);
292 
293 /**
294  * @brief ecore_iscsi_mac_update_connection - updates remote MAC for previously
295  *        offloaded iSCSI connection
296  *
297  *
298  * @param p_path
299  * @param p_conn  container of iSCSI connection data
300  *
301  * @return enum _ecore_status_t
302  */
303 enum _ecore_status_t
304 ecore_iscsi_update_remote_mac(struct ecore_hwfn *p_hwfn,
305 			      struct ecore_iscsi_conn *p_conn);
306 
307 /**
308  * @brief ecore_iscsi_get_tcp_stats - get and optionally reset TCP statistics
309  *        of offloaded iSCSI connection
310  *
311  *
312  * @param p_path
313  * @param p_conn  container of iSCSI connection data
314  * @param p_stats - buffer to place extracted stats
315  * @param reset - 1 - for reset stats (after extraction of accumulated
316  *                statistics in optionally provided buffer)
317  * @return enum _ecore_status_t
318  */
319 enum _ecore_status_t
320 ecore_iscsi_get_tcp_stats(struct ecore_hwfn *p_hwfn,
321 			  struct ecore_iscsi_conn *p_conn,
322 			  struct ecore_iscsi_tcp_stats *p_stats,
323 			  u8 reset);
324 
325 /**
326  * @brief ecore_iscsi_clear_connection_sq - clear SQ
327  *        offloaded iSCSI connection
328  *
329  *
330  * @param p_path
331  * @param p_conn  container of iSCSI connection data
332  *
333  * @return enum _ecore_status_t
334  */
335 enum _ecore_status_t
336 ecore_iscsi_clear_connection_sq(struct ecore_hwfn *p_hwfn,
337 				struct ecore_iscsi_conn *p_conn);
338 
339 /**
340  * @brief ecore_sp_iscsi_func_start
341  *
342  * This ramrod inits iSCSI functionality in FW
343  *
344  * @param p_path
345  * @param comp_mode
346  * @param comp_addr
347  *
348  * @return enum _ecore_status_t
349  */
350 enum _ecore_status_t
351 ecore_sp_iscsi_func_start(struct ecore_hwfn *p_hwfn,
352 			  enum spq_mode comp_mode,
353 			  struct ecore_spq_comp_cb *p_comp_addr,
354 			  void *async_event_context,
355 			  iscsi_event_cb_t async_event_cb);
356 
357 enum _ecore_status_t
358 ecore_sp_iscsi_func_stop(struct ecore_hwfn *p_hwfn,
359 			 enum spq_mode comp_mode,
360 			 struct ecore_spq_comp_cb *p_comp_addr);
361 
362 enum _ecore_status_t
363 ecore_iscsi_get_stats(struct ecore_hwfn *p_hwfn,
364 		      struct ecore_iscsi_stats *stats);
365 
366 #endif
367