1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 #ifndef _ISCSIT_H_ 26 #define _ISCSIT_H_ 27 28 #include <sys/iscsit/iscsi_if.h> 29 #include <iscsit_authclient.h> 30 #include <sys/iscsit/iscsit_common.h> 31 32 /* 33 * For some reason iscsi_protocol.h lists the max version as "0x02" and the 34 * min version as "0x00". RFC3720 clearly states that the current version 35 * number is 0x00 so that is what we will use. 36 */ 37 #define ISCSIT_MIN_VERSION 0x00 38 #define ISCSIT_MAX_VERSION 0x00 39 #define ISCSIT_MAX_CONNECTIONS 1 /* No MC/S support */ 40 #define ISCSIT_MAX_RECV_DATA_SEGMENT_LENGTH (32*1024) 41 #define ISCSIT_MAX_BURST_LENGTH (512*1024) 42 #define ISCSIT_MAX_FIRST_BURST_LENGTH ISCSI_DEFAULT_FIRST_BURST_LENGTH 43 #define ISCSIT_MAX_TIME2WAIT ISCSI_DEFAULT_TIME_TO_WAIT 44 #define ISCSIT_MAX_TIME2RETAIN ISCSI_DEFAULT_TIME_TO_RETAIN 45 #define ISCSIT_MAX_OUTSTANDING_R2T ISCSI_DEFAULT_MAX_OUT_R2T 46 #define ISCSIT_MAX_ERROR_RECOVERY_LEVEL 0 47 48 #define ISCSIT_DEFAULT_TPG "iscsit-default-tpg" 49 #define ISCSIT_DEFAULT_TPGT 1 50 51 #define ISCSI_MAX_TSIH 0xffff 52 #define ISCSI_UNSPEC_TSIH 0 53 54 /* Max targets per system */ 55 #define ISCSIT_MAX_TARGETS 1024 56 57 /* Time in seconds to wait between calls to stmf_deregister_local_port */ 58 #define TGT_DEREG_RETRY_SECONDS 1 59 60 #define ISCSIT_GLOBAL_LOCK(rw) rw_enter(&iscsit_global.global_rwlock, (rw)) 61 #define ISCSIT_GLOBAL_UNLOCK() rw_exit(&iscsit_global.global_rwlock) 62 63 /* 64 * Used for serial number arithmetic (RFC 1982) 65 */ 66 #define ISCSIT_SNA32_CHECK 0x80000000 67 68 typedef struct { 69 char tpg_name[MAX_TPG_NAMELEN]; 70 kmutex_t tpg_mutex; 71 idm_refcnt_t tpg_refcnt; 72 int tpg_online; 73 avl_tree_t tpg_portal_list; 74 avl_node_t tpg_global_ln; 75 list_node_t tpg_delete_ln; 76 } iscsit_tpg_t; 77 78 #define IS_DEFAULT_TPGT(TPGT) \ 79 (((TPGT) != NULL) && \ 80 ((TPGT)->tpgt_tpg == iscsit_global.global_default_tpg)) 81 82 typedef struct { 83 iscsit_tpg_t *tpgt_tpg; 84 idm_refcnt_t tpgt_refcnt; 85 avl_node_t tpgt_tgt_ln; 86 list_node_t tpgt_delete_ln; 87 uint16_t tpgt_tag; 88 boolean_t tpgt_needs_tpg_offline; 89 } iscsit_tpgt_t; 90 91 typedef struct { 92 struct sockaddr_storage portal_addr; 93 int portal_online; 94 idm_refcnt_t portal_refcnt; 95 avl_node_t portal_tpg_ln; 96 iscsit_tpg_t *portal_tpg; 97 idm_svc_t *portal_svc; 98 boolean_t portal_default; 99 void *portal_isns; 100 } iscsit_portal_t; 101 102 103 /* Target states and events, update iscsit_ts_name table whenever modified */ 104 typedef enum { 105 TS_UNDEFINED = 0, 106 TS_CREATED, 107 TS_ONLINING, 108 TS_ONLINE, 109 TS_STMF_ONLINE, 110 TS_DELETING_NEED_OFFLINE, 111 TS_OFFLINING, 112 TS_OFFLINE, 113 TS_STMF_OFFLINE, 114 TS_DELETING_STMF_DEREG, 115 TS_DELETING_STMF_DEREG_FAIL, 116 TS_DELETING, 117 TS_MAX_STATE 118 } iscsit_tgt_state_t; 119 120 #ifdef ISCSIT_TGT_SM_STRINGS 121 static const char *iscsit_ts_name[TS_MAX_STATE+1] = { 122 "TS_UNDEFINED", 123 "TS_CREATED", 124 "TS_ONLINING", 125 "TS_ONLINE", 126 "TS_STMF_ONLINE", 127 "TS_DELETING_NEED_OFFLINE", 128 "TS_OFFLINING", 129 "TS_OFFLINE", 130 "TS_STMF_OFFLINE", 131 "TS_DELETING_STMF_DEREG", 132 "TS_DELETING_STMF_DEREG_FAIL", 133 "TS_DELETING", 134 "TS_MAX_STATE" 135 }; 136 #endif 137 138 typedef enum { 139 TE_UNDEFINED = 0, 140 TE_STMF_ONLINE_REQ, 141 TE_ONLINE_SUCCESS, 142 TE_ONLINE_FAIL, 143 TE_STMF_ONLINE_COMPLETE_ACK, 144 TE_STMF_OFFLINE_REQ, 145 TE_OFFLINE_COMPLETE, 146 TE_STMF_OFFLINE_COMPLETE_ACK, 147 TE_DELETE, 148 TE_STMF_DEREG_SUCCESS, 149 TE_STMF_DEREG_FAIL, 150 TE_STMF_DEREG_RETRY, 151 TE_WAIT_REF_COMPLETE, 152 TE_MAX_EVENT 153 } iscsit_tgt_event_t; 154 155 #ifdef ISCSIT_TGT_SM_STRINGS 156 static const char *iscsit_te_name[TE_MAX_EVENT+1] = { 157 "TE_UNDEFINED", 158 "TE_STMF_ONLINE_REQ", 159 "TE_ONLINE_SUCCESS", 160 "TE_ONLINE_FAIL", 161 "TE_STMF_ONLINE_COMPLETE_ACK", 162 "TE_STMF_OFFLINE_REQ", 163 "TE_OFFLINE_COMPLETE", 164 "TE_STMF_OFFLINE_COMPLETE_ACK", 165 "TE_DELETE", 166 "TE_STMF_DEREG_SUCCESS", 167 "TE_STMF_DEREG_FAIL", 168 "TE_STMF_DEREG_RETRY", 169 "TE_WAIT_REF_COMPLETE", 170 "TE_MAX_EVENT" 171 }; 172 #endif 173 174 typedef struct { 175 char *target_name; 176 nvlist_t *target_props; 177 kmutex_t target_mutex; 178 idm_refcnt_t target_refcnt; 179 idm_refcnt_t target_sess_refcnt; 180 avl_tree_t target_tpgt_list; 181 avl_tree_t target_sess_list; 182 avl_node_t target_global_ln; 183 avl_node_t target_global_deleted_ln; 184 /* STMF lport == iSCSI target */ 185 scsi_devid_desc_t *target_devid; 186 stmf_local_port_t *target_stmf_lport; 187 uint8_t target_stmf_lport_registered; 188 189 /* Target state */ 190 boolean_t target_sm_busy; 191 boolean_t target_deleting; 192 iscsit_tgt_state_t target_state; 193 iscsit_tgt_state_t target_last_state; 194 sm_audit_buf_t target_state_audit; 195 list_t target_events; 196 uint64_t target_generation; 197 } iscsit_tgt_t; 198 199 typedef struct { 200 char ini_name[MAX_ISCSI_NODENAMELEN]; 201 nvlist_t *ini_props; 202 avl_node_t ini_global_ln; 203 } iscsit_ini_t; 204 205 /* 206 * iSCSI Auth Information 207 */ 208 typedef struct conn_auth { 209 char ca_tgt_chapuser[iscsitAuthStringMaxLength]; 210 uint8_t ca_tgt_chapsecret[iscsitAuthStringMaxLength]; 211 int ca_tgt_chapsecretlen; 212 213 char ca_ini_chapuser[iscsitAuthStringMaxLength]; 214 uint8_t ca_ini_chapsecret[iscsitAuthStringMaxLength]; 215 int ca_ini_chapsecretlen; 216 217 /* RADIUS authentication information */ 218 boolean_t ca_use_radius; 219 struct sockaddr_storage ca_radius_server; 220 uint8_t ca_radius_secret[iscsitAuthStringMaxLength]; 221 int ca_radius_secretlen; 222 223 /* authentication method list */ 224 iscsit_auth_method_t ca_method_valid_list[iscsitAuthMethodMaxCount]; 225 226 /* Target alias */ 227 char ca_tgt_alias[MAX_ISCSI_NODENAMELEN]; 228 } conn_auth_t; 229 230 /* 231 * We have three state machines (so far) between the IDM connection state 232 * machine, the session state machine, and the login state machine. All 233 * of these states have some concept of "full feature mode". It's going 234 * to be obnoxious if we use a mixture of these "ffp" representations 235 * since it will be difficult to ensure the three state machines 236 * transition at exactly the same time. We should drive decisions that 237 * depend on FFP from the IDM state machine which is actually snooping 238 * the iSCSI PDU's and will always transition at the correct time. 239 * 240 * A consequence of this approach is that there is a window just after 241 * login completes where we may get a SCSI request but the session 242 * or login state machine has not quite transitioned to "FFP". Whether 243 * this is a problem depends on how we use those state machines. This 244 * is what we should use them for: 245 * 246 * IDM Connection state machine - Decisions related to command processing 247 * including whether a connection is in FFP 248 * 249 * Session state machine - Summarize the state of all available connections 250 * for the purposes of ERL1, ERL2 and MC/S. A session in LOGGED_IN state 251 * should always have at least one FFP connection but there may be a brief 252 * window where a session in ACTIVE might have one or more FFP connections 253 * even though ACTIVE is not strictly an FFP state according to the RFC. 254 * 255 * Login state machine -- drive the login process, collect negotiated 256 * parameters. Another side effect of this approach is that we may get 257 * the "notify ffp" callback from the IDM connection state machine before 258 * the login state machine has actually transitioned to FFP state. 259 */ 260 261 struct iscsit_conn_s; 262 263 /* Update iscsit_ss_name table whenever session states are modified */ 264 typedef enum { 265 SS_UNDEFINED = 0, 266 SS_Q1_FREE, 267 SS_Q2_ACTIVE, 268 SS_Q3_LOGGED_IN, 269 SS_Q4_FAILED, 270 SS_Q5_CONTINUE, 271 SS_Q6_DONE, 272 SS_Q7_ERROR, 273 /* Add new session states above SS_MAX_STATE */ 274 SS_MAX_STATE 275 } iscsit_session_state_t; 276 277 #ifdef ISCSIT_SESS_SM_STRINGS 278 /* An array of state text values, for use in logging state transitions */ 279 static const char *iscsit_ss_name[SS_MAX_STATE+1] = { 280 "SS_UNDEFINED", 281 "SS_Q1_FREE", 282 "SS_Q2_ACTIVE", 283 "SS_Q3_LOGGED_IN", 284 "SS_Q4_FAILED", 285 "SS_Q5_CONTINUE", 286 "SS_Q6_DONE", 287 "SS_Q7_ERROR", 288 "SS_MAX_STATE" 289 }; 290 #endif 291 292 /* Update iscsit_se_name table whenever session events are modified */ 293 typedef enum { 294 SE_UNDEFINED = 0, 295 SE_CONN_IN_LOGIN, /* From login state machine */ 296 SE_CONN_LOGGED_IN, /* FFP enabled client notification */ 297 SE_CONN_FFP_FAIL, /* FFP disabled client notification */ 298 SE_CONN_FFP_DISABLE, /* FFP disabled client notification */ 299 SE_CONN_FAIL, /* Conn destroy client notification */ 300 SE_SESSION_CLOSE, /* FFP disabled client notification */ 301 SE_SESSION_REINSTATE, /* From login state machine */ 302 SE_SESSION_TIMEOUT, /* Internal */ 303 SE_SESSION_CONTINUE, /* From login state machine */ 304 SE_SESSION_CONTINUE_FAIL, /* From login state machine? */ 305 /* Add new events above SE_MAX_EVENT */ 306 SE_MAX_EVENT 307 } iscsit_session_event_t; 308 309 #ifdef ISCSIT_SESS_SM_STRINGS 310 /* An array of event text values, for use in logging events */ 311 static const char *iscsit_se_name[SE_MAX_EVENT+1] = { 312 "SE_UNDEFINED", 313 "SE_CONN_IN_LOGIN", 314 "SE_CONN_LOGGED_IN", 315 "SE_CONN_FFP_FAIL", 316 "SE_CONN_FFP_DISABLE", 317 "SE_CONN_FAIL", 318 "SE_SESSION_CLOSE", 319 "SE_SESSION_REINSTATE", 320 "SE_SESSION_TIMEOUT", 321 "SE_SESSION_CONTINUE", 322 "SE_SESSION_CONTINUE_FAIL", 323 "SE_MAX_EVENT" 324 }; 325 #endif 326 327 /* 328 * Set in ist_tgt after iscsit_tgt_unbind_sess to differentiate an unbound 329 * session from a discovery session. 330 */ 331 #define SESS_UNBOUND_FROM_TGT -1 332 333 typedef struct { 334 stmf_scsi_session_t *ist_stmf_sess; 335 stmf_local_port_t *ist_lport; 336 iscsit_tgt_t *ist_tgt; 337 idm_refcnt_t ist_refcnt; 338 kmem_cache_t *ist_task_cache; 339 krwlock_t ist_sn_rwlock; 340 kmutex_t ist_mutex; 341 kcondvar_t ist_cv; 342 iscsit_session_state_t ist_state; 343 iscsit_session_state_t ist_last_state; 344 sm_audit_buf_t ist_state_audit; 345 boolean_t ist_sm_busy; 346 boolean_t ist_sm_complete; 347 boolean_t ist_admin_close; 348 list_t ist_events; 349 int ist_conn_count; 350 int ist_ffp_conn_count; 351 struct iscsit_conn_s *ist_failed_conn; 352 timeout_id_t ist_state_timeout; 353 list_t ist_conn_list; 354 avl_node_t ist_tgt_ln; 355 char *ist_initiator_name; 356 char *ist_initiator_alias; 357 char *ist_target_name; 358 char *ist_target_alias; 359 uint8_t ist_isid[ISCSI_ISID_LEN]; 360 uint16_t ist_tsih; 361 uint16_t ist_tpgt_tag; 362 uint32_t ist_expcmdsn; 363 uint32_t ist_maxcmdsn; 364 } iscsit_sess_t; 365 366 /* Update iscsit_ils_name table whenever login states are modified */ 367 typedef enum { 368 ILS_UNDEFINED = 0, 369 ILS_LOGIN_INIT, 370 ILS_LOGIN_WAITING, /* Waiting for more login PDU's */ 371 ILS_LOGIN_PROCESSING, /* Processing login request */ 372 ILS_LOGIN_RESPONDING, /* Sending login response */ 373 ILS_LOGIN_RESPONDED, /* Sent login response (no trans. to FFP) */ 374 ILS_LOGIN_FFP, /* Sending last login PDU for final response */ 375 ILS_LOGIN_DONE, /* Last login PDU sent (so we can free it) */ 376 ILS_LOGIN_ERROR, /* Login error, login failed */ 377 /* Add new login states above ILS_MAX_STATE */ 378 ILS_MAX_STATE 379 } iscsit_login_state_t; 380 381 #ifdef ISCSIT_LOGIN_SM_STRINGS 382 /* An array of login state text values, for use in logging login progress */ 383 static const char *iscsit_ils_name[ILS_MAX_STATE+1] = { 384 "ILS_UNDEFINED", 385 "ILS_LOGIN_INIT", 386 "ILS_LOGIN_WAITING", 387 "ILS_LOGIN_PROCESSING", 388 "ILS_LOGIN_RESPONDING", 389 "ILS_LOGIN_RESPONDED", 390 "ILS_LOGIN_FFP", 391 "ILS_LOGIN_DONE", 392 "ILS_LOGIN_ERROR", 393 "ILS_MAX_STATE" 394 }; 395 #endif 396 397 /* Update iscsit_ile_name table whenever login events are modified */ 398 typedef enum { 399 ILE_UNDEFINED = 0, 400 ILE_LOGIN_RCV, 401 ILE_LOGIN_RESP_READY, 402 ILE_LOGIN_FFP, 403 ILE_LOGIN_RESP_COMPLETE, 404 ILE_LOGIN_ERROR, 405 ILE_LOGIN_CONN_ERROR, 406 /* Add new login events above ILE_MAX_EVENT */ 407 ILE_MAX_EVENT 408 } iscsit_login_event_t; 409 410 #ifdef ISCSIT_LOGIN_SM_STRINGS 411 /* An array of login event text values, for use in logging login events */ 412 static const char *iscsit_ile_name[ILE_MAX_EVENT+1] = { 413 "ILE_UNDEFINED", 414 "ILE_LOGIN_RCV", 415 "ILE_LOGIN_RESP_READY", 416 "ILE_LOGIN_FFP", 417 "ILE_LOGIN_RESP_COMPLETE", 418 "ILE_LOGIN_ERROR", 419 "ILE_LOGIN_CONN_ERROR", 420 "ILE_MAX_EVENT" 421 }; 422 #endif 423 424 typedef struct { 425 uint32_t op_initial_params_set:1, 426 op_discovery_session:1, 427 op_initial_r2t:1, 428 op_immed_data:1, 429 op_data_pdu_in_order:1, 430 op_data_sequence_in_order:1; 431 uint64_t op_max_connections; 432 uint64_t op_max_recv_data_segment_length; 433 uint64_t op_max_burst_length; 434 uint64_t op_first_burst_length; 435 uint64_t op_default_time_2_wait; 436 uint64_t op_default_time_2_retain; 437 uint64_t op_max_outstanding_r2t; 438 uint64_t op_error_recovery_level; 439 } iscsit_op_params_t; 440 441 typedef struct { 442 iscsit_login_state_t icl_login_state; 443 iscsit_login_state_t icl_login_last_state; 444 sm_audit_buf_t icl_state_audit; 445 boolean_t icl_busy; 446 boolean_t icl_login_complete; 447 kmutex_t icl_mutex; 448 uint32_t icl_login_itt; 449 uint8_t icl_login_csg; 450 uint8_t icl_login_nsg; 451 boolean_t icl_login_transit; 452 conn_auth_t icl_auth; 453 iscsit_auth_client_t icl_auth_client; 454 int icl_auth_pass; 455 list_t icl_login_events; 456 list_t icl_pdu_list; 457 uint16_t icl_tsih; 458 uint8_t icl_isid[ISCSI_ISID_LEN]; 459 uint32_t icl_cmdsn; 460 uint16_t icl_tpgt_tag; 461 char *icl_target_name; 462 char *icl_target_alias; 463 char *icl_initiator_name; 464 char *icl_login_resp_buf; 465 void *icl_login_resp_itb; /* mult-pdu idm buf */ 466 int icl_login_resp_len; /* For kmem_free */ 467 int icl_login_resp_valid_len; 468 uint8_t icl_login_resp_err_class; 469 uint8_t icl_login_resp_err_detail; 470 iscsi_login_rsp_hdr_t *icl_login_resp_tmpl; 471 idm_pdu_t *icl_login_resp; 472 nvlist_t *icl_request_nvlist; 473 nvlist_t *icl_response_nvlist; 474 nvlist_t *icl_negotiated_values; 475 } iscsit_conn_login_t; 476 477 #define SET_LOGIN_ERROR(SLE_ICT, SLE_CLASS, SLE_DETAIL) \ 478 (SLE_ICT)->ict_login_sm.icl_login_resp_err_class = (SLE_CLASS); \ 479 (SLE_ICT)->ict_login_sm.icl_login_resp_err_detail = (SLE_DETAIL); 480 481 typedef struct iscsit_conn_s { 482 idm_conn_t *ict_ic; 483 iscsit_sess_t *ict_sess; 484 kmutex_t ict_mutex; 485 idm_refcnt_t ict_refcnt; 486 idm_refcnt_t ict_dispatch_refcnt; 487 list_node_t ict_sess_ln; 488 iscsit_conn_login_t ict_login_sm; 489 iscsit_op_params_t ict_op; 490 uint16_t ict_cid; 491 uint32_t ict_statsn; 492 struct iscsit_conn_s *ict_reinstate_conn; 493 uint32_t ict_reinstating:1, 494 ict_lost:1, 495 ict_destroyed:1; 496 } iscsit_conn_t; 497 498 #define ICT_FLAGS_DISCOVERY 0x00000001 499 500 typedef struct { 501 idm_buf_t *ibuf_idm_buf; 502 stmf_data_buf_t *ibuf_stmf_buf; 503 idm_pdu_t *ibuf_immed_data_pdu; 504 boolean_t ibuf_is_immed; 505 } iscsit_buf_t; 506 507 typedef struct { 508 scsi_task_t *it_stmf_task; 509 idm_task_t *it_idm_task; 510 iscsit_buf_t *it_immed_data; 511 iscsit_conn_t *it_ict; 512 kmutex_t it_mutex; 513 idm_pdu_t *it_tm_pdu; 514 uint32_t it_stmf_abort:1, 515 it_aborted:1, 516 it_tm_task:1, 517 it_tm_responded:1; 518 uint32_t it_cmdsn; 519 uint32_t it_itt; 520 uint32_t it_ttt; 521 } iscsit_task_t; 522 523 typedef struct iscsit_isns_cfg { 524 kmutex_t isns_mutex; 525 boolean_t isns_state; 526 list_t isns_svrs; 527 } iscsit_isns_cfg_t; 528 529 /* 530 * State values for the iscsit service 531 */ 532 typedef enum { 533 ISE_UNDEFINED = 0, 534 ISE_DETACHED, 535 ISE_DISABLED, 536 ISE_ENABLING, 537 ISE_ENABLED, 538 ISE_BUSY, 539 ISE_DISABLING 540 } iscsit_service_enabled_t; 541 542 543 typedef struct { 544 iscsit_service_enabled_t global_svc_state; 545 dev_info_t *global_dip; 546 ldi_ident_t global_li; 547 nvlist_t *global_props; 548 stmf_port_provider_t *global_pp; 549 stmf_dbuf_store_t *global_dbuf_store; 550 taskq_t *global_dispatch_taskq; 551 idm_refcnt_t global_refcnt; 552 avl_tree_t global_discovery_sessions; 553 avl_tree_t global_target_list; 554 list_t global_deleted_target_list; 555 avl_tree_t global_tpg_list; 556 avl_tree_t global_ini_list; 557 iscsit_tpg_t *global_default_tpg; 558 vmem_t *global_tsih_pool; 559 iscsit_isns_cfg_t global_isns_cfg; 560 iscsi_radius_props_t global_radius_server; 561 krwlock_t global_rwlock; 562 } iscsit_global_t; 563 564 extern iscsit_global_t iscsit_global; 565 566 void 567 iscsit_global_hold(); 568 569 void 570 iscsit_global_rele(); 571 572 void 573 iscsit_global_wait_ref(); 574 575 idm_status_t 576 iscsit_login_sm_init(iscsit_conn_t *ict); 577 578 void 579 iscsit_login_sm_fini(iscsit_conn_t *ict); 580 581 void 582 iscsit_login_sm_event(iscsit_conn_t *ic, iscsit_login_event_t event, 583 idm_pdu_t *pdu); 584 585 void 586 iscsit_login_sm_event_locked(iscsit_conn_t *ic, iscsit_login_event_t event, 587 idm_pdu_t *pdu); 588 589 void 590 iscsit_send_async_event(iscsit_conn_t *ict, uint8_t async_event); 591 592 void 593 iscsit_pdu_tx(idm_pdu_t *pdu); 594 595 /* 596 * IDM conn ops 597 */ 598 599 idm_rx_pdu_cb_t iscsit_op_scsi_cmd; 600 idm_rx_pdu_cb_t iscsit_rx_pdu; 601 idm_rx_pdu_error_cb_t iscsit_rx_pdu_error; 602 idm_task_cb_t iscsit_task_aborted; 603 idm_client_notify_cb_t iscsit_client_notify; 604 idm_build_hdr_cb_t iscsit_build_hdr; 605 606 /* 607 * lport entry points 608 */ 609 stmf_status_t 610 iscsit_xfer_scsi_data(scsi_task_t *task, stmf_data_buf_t *dbuf, 611 uint32_t ioflags); 612 613 stmf_status_t 614 iscsit_send_scsi_status(scsi_task_t *task, uint32_t ioflags); 615 616 void 617 iscsit_lport_task_free(scsi_task_t *task); 618 619 stmf_status_t 620 iscsit_abort(stmf_local_port_t *lport, int abort_cmd, void *arg, 621 uint32_t flags); 622 623 void 624 iscsit_ctl(stmf_local_port_t *lport, int cmd, void *arg); 625 626 /* 627 * Connection functions 628 */ 629 idm_status_t 630 iscsit_conn_reinstate(iscsit_conn_t *existing_ict, iscsit_conn_t *ict); 631 632 void 633 iscsit_conn_destroy_done(iscsit_conn_t *ict); 634 635 void 636 iscsit_conn_set_auth(iscsit_conn_t *ict); 637 638 void 639 iscsit_conn_hold(iscsit_conn_t *ict); 640 641 void 642 iscsit_conn_rele(iscsit_conn_t *ict); 643 644 /* 645 * Session functions 646 */ 647 int 648 iscsit_sess_avl_compare(const void *void_sess1, const void *void_sess2); 649 650 iscsit_sess_t * 651 iscsit_sess_create(iscsit_tgt_t *tgt, iscsit_conn_t *ict, 652 uint32_t cmdsn, uint8_t *isid, uint16_t tag, 653 char *initiator_name, char *target_name, 654 uint8_t *error_class, uint8_t *error_detail); 655 656 void 657 iscsit_sess_destroy(iscsit_sess_t *ist); 658 659 void 660 iscsit_sess_hold(iscsit_sess_t *ist); 661 662 void 663 iscsit_sess_rele(iscsit_sess_t *ist); 664 665 iscsit_conn_t * 666 iscsit_sess_lookup_conn(iscsit_sess_t *ist, uint16_t cid); 667 668 void 669 iscsit_sess_bind_conn(iscsit_sess_t *ist, iscsit_conn_t *ict); 670 671 void 672 iscsit_sess_unbind_conn(iscsit_sess_t *ist, iscsit_conn_t *ict); 673 674 void 675 iscsit_sess_close(iscsit_sess_t *ist); 676 677 iscsit_sess_t * 678 iscsit_sess_reinstate(iscsit_tgt_t *tgt, iscsit_sess_t *ist, iscsit_conn_t *ict, 679 uint8_t *error_class, uint8_t *error_detail); 680 681 void 682 iscsit_sess_sm_event(iscsit_sess_t *ist, iscsit_session_event_t event, 683 iscsit_conn_t *ict); 684 685 /* 686 * Target, TPGT, TPGT and portal functions 687 */ 688 689 void 690 iscsit_tgt_sm_event(iscsit_tgt_t *tgt, iscsit_tgt_event_t event); 691 692 void 693 tgt_sm_event_locked(iscsit_tgt_t *tgt, iscsit_tgt_event_t event); 694 695 it_cfg_status_t 696 iscsit_config_merge_tgt(it_config_t *cfg); 697 698 void 699 iscsit_config_destroy_tgts(list_t *tgt_del_list); 700 701 void 702 iscsit_config_destroy_tpgts(list_t *tpgt_del_list); 703 704 iscsit_tgt_t * 705 iscsit_tgt_lookup(char *target_name); 706 707 iscsit_tgt_t * 708 iscsit_tgt_lookup_locked(char *target_name); 709 710 int 711 iscsit_tgt_avl_compare(const void *void_tgt1, const void *void_tgt2); 712 713 int 714 iscsit_tpgt_avl_compare(const void *void_tpgt1, const void *void_tpgt2); 715 716 void 717 iscsit_tgt_hold(iscsit_tgt_t *tgt); 718 719 void 720 iscsit_tgt_rele(iscsit_tgt_t *tgt); 721 722 iscsit_tpgt_t * 723 iscsit_tgt_lookup_tpgt(iscsit_tgt_t *tgt, uint16_t tag); 724 725 void 726 iscsit_tpgt_hold(iscsit_tpgt_t *tpgt); 727 728 void 729 iscsit_tpgt_rele(iscsit_tpgt_t *tpgt); 730 731 iscsit_portal_t * 732 iscsit_tgt_lookup_portal(iscsit_tgt_t *tgt, struct sockaddr_storage *sa, 733 iscsit_tpgt_t **output_tpgt); 734 735 iscsit_sess_t * 736 iscsit_tgt_lookup_sess(iscsit_tgt_t *tgt, char *initiator_name, 737 uint8_t *isid, uint16_t tsih, uint16_t tag); 738 739 void 740 iscsit_tgt_bind_sess(iscsit_tgt_t *tgt, iscsit_sess_t *sess); 741 742 void 743 iscsit_tgt_unbind_sess(iscsit_tgt_t *tgt, iscsit_sess_t *sess); 744 745 it_cfg_status_t 746 iscsit_config_merge_tpg(it_config_t *cfg, list_t *tpg_del_list); 747 748 void 749 iscsit_config_destroy_tpgs(list_t *tpg_del_list); 750 751 iscsit_tpg_t * 752 iscsit_tpg_lookup(char *tpg_name); 753 754 int 755 iscsit_tpg_avl_compare(const void *void_tpg1, const void *void_tpg2); 756 757 void 758 iscsit_tpg_hold(iscsit_tpg_t *tpg); 759 760 void 761 iscsit_tpg_rele(iscsit_tpg_t *tpg); 762 763 iscsit_tpg_t * 764 iscsit_tpg_createdefault(); 765 766 void 767 iscsit_tpg_destroydefault(iscsit_tpg_t *tpg); 768 769 idm_status_t 770 iscsit_tpg_online(iscsit_tpg_t *tpg); 771 772 void 773 iscsit_tpg_offline(iscsit_tpg_t *tpg); 774 775 iscsit_portal_t * 776 iscsit_tpg_portal_lookup(iscsit_tpg_t *tpg, struct sockaddr_storage *sa); 777 778 void 779 iscsit_portal_hold(iscsit_portal_t *portal); 780 781 void 782 iscsit_portal_rele(iscsit_portal_t *portal); 783 784 it_cfg_status_t 785 iscsit_config_merge_ini(it_config_t *cfg); 786 787 int 788 iscsit_ini_avl_compare(const void *void_ini1, const void *void_ini2); 789 790 iscsit_ini_t * 791 iscsit_ini_lookup_locked(char *ini_name); 792 793 int 794 iscsit_portal_avl_compare(const void *void_portal1, const void *void_portal2); 795 796 int 797 iscsit_verify_chap_resp(iscsit_conn_login_t *lsm, 798 unsigned int chap_i, uchar_t *chap_c, unsigned int challenge_len, 799 uchar_t *chap_r, unsigned int resp_len); 800 801 #endif /* _ISCSIT_H_ */ 802