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 u8 dif_on_immediate; 123 #define ECORE_ISCSI_CONN_DIF_ON_IMM_DIS 0 124 #define ECORE_ISCSI_CONN_DIF_ON_IMM_DEFAULT 1 125 #define ECORE_ISCSI_CONN_DIF_ON_IMM_LUN_MAPPER 2 126 127 dma_addr_t lun_mapper_phys_addr; 128 u32 initial_ref_tag; 129 u16 application_tag; 130 u16 application_tag_mask; 131 u8 validate_guard; 132 u8 validate_app_tag; 133 u8 validate_ref_tag; 134 u8 forward_guard; 135 u8 forward_app_tag; 136 u8 forward_ref_tag; 137 u8 interval_size; /* 0=512B, 1=4KB */ 138 u8 network_interface; /* 0=None, 1=DIF */ 139 u8 host_interface; /* 0=None, 1=DIF, 2=DIX */ 140 u8 ref_tag_mask; /* mask for refernce tag handling */ 141 u8 forward_app_tag_with_mask; 142 u8 forward_ref_tag_with_mask; 143 144 u8 ignore_app_tag; 145 u8 initial_ref_tag_is_valid; 146 u8 host_guard_type; /* 0 = IP checksum, 1 = CRC */ 147 u8 protection_type; /* 1/2/3 - Protection Type */ 148 u8 crc_seed; /* 0=0x0000, 1=0xffff */ 149 u8 keep_ref_tag_const; 150 }; 151 152 struct ecore_iscsi_stats 153 { 154 u64 iscsi_rx_bytes_cnt; 155 u64 iscsi_rx_packet_cnt; 156 u64 iscsi_rx_new_ooo_isle_events_cnt; 157 u32 iscsi_cmdq_threshold_cnt; 158 u32 iscsi_rq_threshold_cnt; 159 u32 iscsi_immq_threshold_cnt; 160 161 u64 iscsi_rx_dropped_pdus_task_not_valid; 162 163 u64 iscsi_rx_data_pdu_cnt; 164 u64 iscsi_rx_r2t_pdu_cnt; 165 u64 iscsi_rx_total_pdu_cnt; 166 167 u64 iscsi_tx_go_to_slow_start_event_cnt; 168 u64 iscsi_tx_fast_retransmit_event_cnt; 169 170 u64 iscsi_tx_data_pdu_cnt; 171 u64 iscsi_tx_r2t_pdu_cnt; 172 u64 iscsi_tx_total_pdu_cnt; 173 174 u64 iscsi_tx_bytes_cnt; 175 u64 iscsi_tx_packet_cnt; 176 }; 177 178 /** 179 * @brief ecore_iscsi_acquire_connection - allocate resources, 180 * provides connecion handle (CID)as out parameter. 181 * 182 * @param p_path 183 * @param p_conn partially initialized incoming container of 184 * iSCSI connection data 185 * @return enum _ecore_status_t 186 */ 187 enum _ecore_status_t 188 ecore_iscsi_acquire_connection(struct ecore_hwfn *p_hwfn, 189 struct ecore_iscsi_conn *p_in_conn, 190 struct ecore_iscsi_conn **p_out_conn); 191 192 void OSAL_IOMEM *ecore_iscsi_get_db_addr(struct ecore_hwfn *p_hwfn, 193 u32 cid); 194 195 void OSAL_IOMEM *ecore_iscsi_get_global_cmdq_cons(struct ecore_hwfn *p_hwfn, 196 u8 relative_q_id); 197 198 void OSAL_IOMEM *ecore_iscsi_get_primary_bdq_prod(struct ecore_hwfn *p_hwfn, 199 u8 bdq_id); 200 201 void OSAL_IOMEM *ecore_iscsi_get_secondary_bdq_prod(struct ecore_hwfn *p_hwfn, 202 u8 bdq_id); 203 204 /** 205 * @brief ecore_iscsi_offload_connection - offload previously 206 * allocated iSCSI connection 207 * 208 * @param p_path 209 * @param p_conn container of iSCSI connection data 210 * 211 * @return enum _ecore_status_t 212 */ 213 enum _ecore_status_t 214 ecore_iscsi_offload_connection(struct ecore_hwfn *p_hwfn, 215 struct ecore_iscsi_conn *p_conn); 216 217 /** 218 * @brief ecore_iscsi_release_connection - deletes connecton 219 * resources (incliding container of iSCSI connection 220 * data) 221 * 222 * @param p_path 223 * @param p_conn container of iSCSI connection data 224 */ 225 void ecore_iscsi_release_connection(struct ecore_hwfn *p_hwfn, 226 struct ecore_iscsi_conn *p_conn); 227 228 /** 229 * @brief ecore_iscsi_terminate_connection - destroys previously 230 * offloaded iSCSI connection 231 * 232 * @param p_path 233 * @param p_conn container of iSCSI connection data 234 * 235 * @return enum _ecore_status_t 236 */ 237 enum _ecore_status_t 238 ecore_iscsi_terminate_connection(struct ecore_hwfn *p_hwfn, 239 struct ecore_iscsi_conn *p_conn); 240 241 242 /** 243 * @brief ecore_iscsi_update_connection - updates previously 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_update_connection(struct ecore_hwfn *p_hwfn, 254 struct ecore_iscsi_conn *p_conn); 255 256 /** 257 * @brief ecore_iscsi_mac_update_connection - updates remote MAC for previously 258 * offloaded iSCSI connection 259 * 260 * 261 * @param p_path 262 * @param p_conn container of iSCSI connection data 263 * 264 * @return enum _ecore_status_t 265 */ 266 enum _ecore_status_t 267 ecore_iscsi_update_remote_mac(struct ecore_hwfn *p_hwfn, 268 struct ecore_iscsi_conn *p_conn); 269 270 /** 271 * @brief ecore_iscsi_clear_connection_sq - clear SQ 272 * offloaded iSCSI connection 273 * 274 * 275 * @param p_path 276 * @param p_conn container of iSCSI connection data 277 * 278 * @return enum _ecore_status_t 279 */ 280 enum _ecore_status_t 281 ecore_iscsi_clear_connection_sq(struct ecore_hwfn *p_hwfn, 282 struct ecore_iscsi_conn *p_conn); 283 284 /** 285 * @brief ecore_sp_iscsi_func_start 286 * 287 * This ramrod inits iSCSI functionality in FW 288 * 289 * @param p_path 290 * @param comp_mode 291 * @param comp_addr 292 * 293 * @return enum _ecore_status_t 294 */ 295 enum _ecore_status_t 296 ecore_sp_iscsi_func_start(struct ecore_hwfn *p_hwfn, 297 enum spq_mode comp_mode, 298 struct ecore_spq_comp_cb *p_comp_addr, 299 void *async_event_context, 300 iscsi_event_cb_t async_event_cb); 301 302 enum _ecore_status_t 303 ecore_sp_iscsi_func_stop(struct ecore_hwfn *p_hwfn, 304 enum spq_mode comp_mode, 305 struct ecore_spq_comp_cb *p_comp_addr); 306 307 enum _ecore_status_t 308 ecore_iscsi_get_stats(struct ecore_hwfn *p_hwfn, 309 struct ecore_iscsi_stats *stats); 310 311 #endif 312