ecore_iscsi_api.h revision 337519
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: stable/10/sys/dev/qlnx/qlnxe/ecore_iscsi_api.h 337519 2018-08-09 01:39:47Z davidcs $
28 *
29 */
30
31#ifndef __ECORE_ISCSI_API_H__
32#define __ECORE_ISCSI_API_H__
33
34#ifndef __EXTRACT__LINUX__IF__
35typedef enum _ecore_status_t (*iscsi_event_cb_t)(void *context,
36						 u8 fw_event_code,
37						 void *fw_handle);
38
39struct 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
77struct 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__
90struct 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 */
216enum _ecore_status_t
217ecore_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 */
227enum _ecore_status_t
228ecore_iscsi_setup_connection(struct ecore_iscsi_conn *p_conn);
229
230void OSAL_IOMEM *ecore_iscsi_get_db_addr(struct ecore_hwfn *p_hwfn,
231					 u32 cid);
232
233void OSAL_IOMEM *ecore_iscsi_get_global_cmdq_cons(struct ecore_hwfn *p_hwfn,
234						  u8 relative_q_id);
235
236void OSAL_IOMEM *ecore_iscsi_get_primary_bdq_prod(struct ecore_hwfn *p_hwfn,
237						  u8 bdq_id);
238
239void 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 */
251enum _ecore_status_t
252ecore_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 */
263void 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 */
275enum _ecore_status_t
276ecore_iscsi_terminate_connection(struct ecore_hwfn *p_hwfn,
277				 struct ecore_iscsi_conn *p_conn);
278
279
280/**
281 * @brief ecore_iscsi_update_connection - updates previously
282 *        offloaded iSCSI connection
283 *
284 *
285 * @param p_path
286 * @param p_conn  container of iSCSI connection data
287 *
288 * @return enum _ecore_status_t
289 */
290enum _ecore_status_t
291ecore_iscsi_update_connection(struct ecore_hwfn *p_hwfn,
292			      struct ecore_iscsi_conn *p_conn);
293
294/**
295 * @brief ecore_iscsi_mac_update_connection - updates remote MAC for previously
296 *        offloaded iSCSI connection
297 *
298 *
299 * @param p_path
300 * @param p_conn  container of iSCSI connection data
301 *
302 * @return enum _ecore_status_t
303 */
304enum _ecore_status_t
305ecore_iscsi_update_remote_mac(struct ecore_hwfn *p_hwfn,
306			      struct ecore_iscsi_conn *p_conn);
307
308/**
309 * @brief ecore_iscsi_get_tcp_stats - get and optionally reset TCP statistics
310 *        of offloaded iSCSI connection
311 *
312 *
313 * @param p_path
314 * @param p_conn  container of iSCSI connection data
315 * @param p_stats - buffer to place extracted stats
316 * @param reset - 1 - for reset stats (after extraction of accumulated
317 *                statistics in optionally provided buffer)
318 * @return enum _ecore_status_t
319 */
320enum _ecore_status_t
321ecore_iscsi_get_tcp_stats(struct ecore_hwfn *p_hwfn,
322			  struct ecore_iscsi_conn *p_conn,
323			  struct ecore_iscsi_tcp_stats *p_stats,
324			  u8 reset);
325
326/**
327 * @brief ecore_iscsi_clear_connection_sq - clear SQ
328 *        offloaded iSCSI connection
329 *
330 *
331 * @param p_path
332 * @param p_conn  container of iSCSI connection data
333 *
334 * @return enum _ecore_status_t
335 */
336enum _ecore_status_t
337ecore_iscsi_clear_connection_sq(struct ecore_hwfn *p_hwfn,
338				struct ecore_iscsi_conn *p_conn);
339
340/**
341 * @brief ecore_sp_iscsi_func_start
342 *
343 * This ramrod inits iSCSI functionality in FW
344 *
345 * @param p_path
346 * @param comp_mode
347 * @param comp_addr
348 *
349 * @return enum _ecore_status_t
350 */
351enum _ecore_status_t
352ecore_sp_iscsi_func_start(struct ecore_hwfn *p_hwfn,
353			  enum spq_mode comp_mode,
354			  struct ecore_spq_comp_cb *p_comp_addr,
355			  void *async_event_context,
356			  iscsi_event_cb_t async_event_cb);
357
358enum _ecore_status_t
359ecore_sp_iscsi_func_stop(struct ecore_hwfn *p_hwfn,
360			 enum spq_mode comp_mode,
361			 struct ecore_spq_comp_cb *p_comp_addr);
362
363enum _ecore_status_t
364ecore_iscsi_get_stats(struct ecore_hwfn *p_hwfn,
365		      struct ecore_iscsi_stats *stats);
366
367#endif
368