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_ISCSI_API_H__
32 #define __ECORE_ISCSI_API_H__
34 #ifndef __EXTRACT__LINUX__IF__
35 typedef enum _ecore_status_t (*iscsi_event_cb_t)(void *context,
39 struct ecore_iscsi_stats
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;
48 u64 iscsi_rx_dropped_pdus_task_not_valid;
50 u64 iscsi_rx_data_pdu_cnt;
51 u64 iscsi_rx_r2t_pdu_cnt;
52 u64 iscsi_rx_total_pdu_cnt;
54 u64 iscsi_tx_go_to_slow_start_event_cnt;
55 u64 iscsi_tx_fast_retransmit_event_cnt;
57 u64 iscsi_tx_data_pdu_cnt;
58 u64 iscsi_tx_r2t_pdu_cnt;
59 u64 iscsi_tx_total_pdu_cnt;
61 u64 iscsi_tx_bytes_cnt;
62 u64 iscsi_tx_packet_cnt;
64 u64 iscsi_rx_tcp_payload_bytes_cnt;
65 u64 iscsi_rx_tcp_pkt_cnt;
66 u64 iscsi_rx_pure_ack_cnt;
68 u64 iscsi_rx_dup_ack_cnt;
70 u64 iscsi_tx_pure_ack_cnt;
71 u64 iscsi_tx_delayed_ack_cnt;
73 u64 iscsi_tx_tcp_payload_bytes_cnt;
74 u64 iscsi_tx_tcp_pkt_cnt;
77 struct ecore_iscsi_tcp_stats
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;
89 #ifndef __EXTRACT__LINUX__C__
90 struct ecore_iscsi_conn {
91 osal_list_entry_t list_entry;
102 dma_addr_t sq_pbl_addr;
103 struct ecore_chain r2tq;
104 struct ecore_chain xhq;
105 struct ecore_chain uhq;
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;
115 u16 syn_ip_payload_length;
139 u32 ka_timeout_delta;
140 u32 rt_timeout_delta;
142 u8 snd_wnd_probe_cnt;
157 u16 da_timeout_value;
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
168 u32 max_recv_pdu_length;
169 u32 max_send_pdu_length;
170 u32 first_seq_length;
175 u8 abortive_dsconnect;
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
181 dma_addr_t lun_mapper_phys_addr;
184 u16 application_tag_mask;
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;
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;
208 * @brief ecore_iscsi_acquire_connection - allocate resources,
209 * provides connecion handle (CID)as out parameter.
212 * @param p_conn partially initialized incoming container of
213 * iSCSI connection data
214 * @return 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);
222 * @brief ecore_iscsi_setup_connection- initialize connection data.
224 * @param p_conn container of iSCSI connection data
225 * @return enum _ecore_status_t
228 ecore_iscsi_setup_connection(struct ecore_iscsi_conn *p_conn);
230 void OSAL_IOMEM *ecore_iscsi_get_db_addr(struct ecore_hwfn *p_hwfn,
233 void OSAL_IOMEM *ecore_iscsi_get_global_cmdq_cons(struct ecore_hwfn *p_hwfn,
236 void OSAL_IOMEM *ecore_iscsi_get_primary_bdq_prod(struct ecore_hwfn *p_hwfn,
239 void OSAL_IOMEM *ecore_iscsi_get_secondary_bdq_prod(struct ecore_hwfn *p_hwfn,
243 * @brief ecore_iscsi_offload_connection - offload previously
244 * allocated iSCSI connection
247 * @param p_conn container of iSCSI connection data
249 * @return enum _ecore_status_t
252 ecore_iscsi_offload_connection(struct ecore_hwfn *p_hwfn,
253 struct ecore_iscsi_conn *p_conn);
256 * @brief ecore_iscsi_release_connection - deletes connecton
257 * resources (incliding container of iSCSI connection
261 * @param p_conn container of iSCSI connection data
263 void ecore_iscsi_release_connection(struct ecore_hwfn *p_hwfn,
264 struct ecore_iscsi_conn *p_conn);
267 * @brief ecore_iscsi_terminate_connection - destroys previously
268 * offloaded iSCSI connection
271 * @param p_conn container of iSCSI connection data
273 * @return enum _ecore_status_t
276 ecore_iscsi_terminate_connection(struct ecore_hwfn *p_hwfn,
277 struct ecore_iscsi_conn *p_conn);
280 * @brief ecore_iscsi_update_connection - updates previously
281 * offloaded iSCSI connection
285 * @param p_conn container of iSCSI connection data
287 * @return enum _ecore_status_t
290 ecore_iscsi_update_connection(struct ecore_hwfn *p_hwfn,
291 struct ecore_iscsi_conn *p_conn);
294 * @brief ecore_iscsi_mac_update_connection - updates remote MAC for previously
295 * offloaded iSCSI connection
299 * @param p_conn container of iSCSI connection data
301 * @return enum _ecore_status_t
304 ecore_iscsi_update_remote_mac(struct ecore_hwfn *p_hwfn,
305 struct ecore_iscsi_conn *p_conn);
308 * @brief ecore_iscsi_get_tcp_stats - get and optionally reset TCP statistics
309 * of offloaded iSCSI connection
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
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,
326 * @brief ecore_iscsi_clear_connection_sq - clear SQ
327 * offloaded iSCSI connection
331 * @param p_conn container of iSCSI connection data
333 * @return enum _ecore_status_t
336 ecore_iscsi_clear_connection_sq(struct ecore_hwfn *p_hwfn,
337 struct ecore_iscsi_conn *p_conn);
340 * @brief ecore_sp_iscsi_func_start
342 * This ramrod inits iSCSI functionality in FW
348 * @return 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);
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);
363 ecore_iscsi_get_stats(struct ecore_hwfn *p_hwfn,
364 struct ecore_iscsi_stats *stats);