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 avl_tree_t ist_task_list; 365 } iscsit_sess_t; 366 367 /* Update iscsit_ils_name table whenever login states are modified */ 368 typedef enum { 369 ILS_UNDEFINED = 0, 370 ILS_LOGIN_INIT, 371 ILS_LOGIN_WAITING, /* Waiting for more login PDU's */ 372 ILS_LOGIN_PROCESSING, /* Processing login request */ 373 ILS_LOGIN_RESPONDING, /* Sending login response */ 374 ILS_LOGIN_RESPONDED, /* Sent login response (no trans. to FFP) */ 375 ILS_LOGIN_FFP, /* Sending last login PDU for final response */ 376 ILS_LOGIN_DONE, /* Last login PDU sent (so we can free it) */ 377 ILS_LOGIN_ERROR, /* Login error, login failed */ 378 /* Add new login states above ILS_MAX_STATE */ 379 ILS_MAX_STATE 380 } iscsit_login_state_t; 381 382 #ifdef ISCSIT_LOGIN_SM_STRINGS 383 /* An array of login state text values, for use in logging login progress */ 384 static const char *iscsit_ils_name[ILS_MAX_STATE+1] = { 385 "ILS_UNDEFINED", 386 "ILS_LOGIN_INIT", 387 "ILS_LOGIN_WAITING", 388 "ILS_LOGIN_PROCESSING", 389 "ILS_LOGIN_RESPONDING", 390 "ILS_LOGIN_RESPONDED", 391 "ILS_LOGIN_FFP", 392 "ILS_LOGIN_DONE", 393 "ILS_LOGIN_ERROR", 394 "ILS_MAX_STATE" 395 }; 396 #endif 397 398 /* Update iscsit_ile_name table whenever login events are modified */ 399 typedef enum { 400 ILE_UNDEFINED = 0, 401 ILE_LOGIN_RCV, 402 ILE_LOGIN_RESP_READY, 403 ILE_LOGIN_FFP, 404 ILE_LOGIN_RESP_COMPLETE, 405 ILE_LOGIN_ERROR, 406 ILE_LOGIN_CONN_ERROR, 407 /* Add new login events above ILE_MAX_EVENT */ 408 ILE_MAX_EVENT 409 } iscsit_login_event_t; 410 411 #ifdef ISCSIT_LOGIN_SM_STRINGS 412 /* An array of login event text values, for use in logging login events */ 413 static const char *iscsit_ile_name[ILE_MAX_EVENT+1] = { 414 "ILE_UNDEFINED", 415 "ILE_LOGIN_RCV", 416 "ILE_LOGIN_RESP_READY", 417 "ILE_LOGIN_FFP", 418 "ILE_LOGIN_RESP_COMPLETE", 419 "ILE_LOGIN_ERROR", 420 "ILE_LOGIN_CONN_ERROR", 421 "ILE_MAX_EVENT" 422 }; 423 #endif 424 425 typedef struct { 426 uint32_t op_initial_params_set:1, 427 op_discovery_session:1, 428 op_initial_r2t:1, 429 op_immed_data:1, 430 op_data_pdu_in_order:1, 431 op_data_sequence_in_order:1; 432 uint64_t op_max_connections; 433 uint64_t op_max_recv_data_segment_length; 434 uint64_t op_max_burst_length; 435 uint64_t op_first_burst_length; 436 uint64_t op_default_time_2_wait; 437 uint64_t op_default_time_2_retain; 438 uint64_t op_max_outstanding_r2t; 439 uint64_t op_error_recovery_level; 440 } iscsit_op_params_t; 441 442 typedef struct { 443 iscsit_login_state_t icl_login_state; 444 iscsit_login_state_t icl_login_last_state; 445 sm_audit_buf_t icl_state_audit; 446 boolean_t icl_busy; 447 boolean_t icl_login_complete; 448 kmutex_t icl_mutex; 449 uint32_t icl_login_itt; 450 uint8_t icl_login_csg; 451 uint8_t icl_login_nsg; 452 boolean_t icl_login_transit; 453 conn_auth_t icl_auth; 454 iscsit_auth_client_t icl_auth_client; 455 int icl_auth_pass; 456 list_t icl_login_events; 457 list_t icl_pdu_list; 458 uint16_t icl_tsih; 459 uint8_t icl_isid[ISCSI_ISID_LEN]; 460 uint32_t icl_cmdsn; 461 uint16_t icl_tpgt_tag; 462 char *icl_target_name; 463 char *icl_target_alias; 464 char *icl_initiator_name; 465 char *icl_login_resp_buf; 466 void *icl_login_resp_itb; /* mult-pdu idm buf */ 467 int icl_login_resp_len; /* For kmem_free */ 468 int icl_login_resp_valid_len; 469 uint8_t icl_login_resp_err_class; 470 uint8_t icl_login_resp_err_detail; 471 iscsi_login_rsp_hdr_t *icl_login_resp_tmpl; 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 uint32_t ict_keepalive_ttt; 493 struct iscsit_conn_s *ict_reinstate_conn; 494 uint32_t ict_reinstating:1, 495 ict_lost:1, 496 ict_destroyed:1; 497 /* 498 * Parameters for processing text commands 499 */ 500 char *ict_text_rsp_buf; 501 uint32_t ict_text_rsp_len; 502 uint32_t ict_text_rsp_valid_len; 503 uint32_t ict_text_rsp_off; 504 uint32_t ict_text_req_itt; /* from initiator */ 505 uint32_t ict_text_rsp_ttt; 506 } iscsit_conn_t; 507 508 #define ICT_FLAGS_DISCOVERY 0x00000001 509 510 typedef struct { 511 idm_buf_t *ibuf_idm_buf; 512 stmf_data_buf_t *ibuf_stmf_buf; 513 idm_pdu_t *ibuf_immed_data_pdu; 514 boolean_t ibuf_is_immed; 515 } iscsit_buf_t; 516 517 typedef struct { 518 scsi_task_t *it_stmf_task; 519 idm_task_t *it_idm_task; 520 iscsit_buf_t *it_immed_data; 521 iscsit_conn_t *it_ict; 522 kmutex_t it_mutex; 523 idm_pdu_t *it_tm_pdu; 524 uint32_t it_stmf_abort:1, 525 it_aborted:1, 526 it_active:1, 527 it_tm_task:1, 528 it_tm_responded:1; 529 uint32_t it_cmdsn; 530 uint32_t it_itt; 531 uint32_t it_ttt; 532 avl_node_t it_sess_ln; 533 } iscsit_task_t; 534 535 typedef struct iscsit_isns_cfg { 536 kmutex_t isns_mutex; 537 boolean_t isns_state; 538 list_t isns_svrs; 539 } iscsit_isns_cfg_t; 540 541 /* 542 * State values for the iscsit service 543 */ 544 typedef enum { 545 ISE_UNDEFINED = 0, 546 ISE_DETACHED, 547 ISE_DISABLED, 548 ISE_ENABLING, 549 ISE_ENABLED, 550 ISE_BUSY, 551 ISE_DISABLING 552 } iscsit_service_enabled_t; 553 554 555 typedef struct { 556 iscsit_service_enabled_t global_svc_state; 557 dev_info_t *global_dip; 558 ldi_ident_t global_li; 559 nvlist_t *global_props; 560 stmf_port_provider_t *global_pp; 561 stmf_dbuf_store_t *global_dbuf_store; 562 taskq_t *global_dispatch_taskq; 563 idm_refcnt_t global_refcnt; 564 avl_tree_t global_discovery_sessions; 565 avl_tree_t global_target_list; 566 list_t global_deleted_target_list; 567 avl_tree_t global_tpg_list; 568 avl_tree_t global_ini_list; 569 iscsit_tpg_t *global_default_tpg; 570 vmem_t *global_tsih_pool; 571 iscsit_isns_cfg_t global_isns_cfg; 572 iscsi_radius_props_t global_radius_server; 573 krwlock_t global_rwlock; 574 } iscsit_global_t; 575 576 extern iscsit_global_t iscsit_global; 577 578 void 579 iscsit_global_hold(); 580 581 void 582 iscsit_global_rele(); 583 584 void 585 iscsit_global_wait_ref(); 586 587 idm_status_t 588 iscsit_login_sm_init(iscsit_conn_t *ict); 589 590 void 591 iscsit_login_sm_fini(iscsit_conn_t *ict); 592 593 void 594 iscsit_login_sm_event(iscsit_conn_t *ic, iscsit_login_event_t event, 595 idm_pdu_t *pdu); 596 597 void 598 iscsit_login_sm_event_locked(iscsit_conn_t *ic, iscsit_login_event_t event, 599 idm_pdu_t *pdu); 600 601 void 602 iscsit_send_async_event(iscsit_conn_t *ict, uint8_t async_event); 603 604 void 605 iscsit_pdu_tx(idm_pdu_t *pdu); 606 607 void 608 iscsit_send_reject(iscsit_conn_t *ict, idm_pdu_t *rejected_pdu, uint8_t reason); 609 610 void 611 iscsit_text_cmd_fini(iscsit_conn_t *ict); 612 613 /* 614 * IDM conn ops 615 */ 616 617 idm_rx_pdu_cb_t iscsit_op_scsi_cmd; 618 idm_rx_pdu_cb_t iscsit_rx_pdu; 619 idm_rx_pdu_error_cb_t iscsit_rx_pdu_error; 620 idm_task_cb_t iscsit_task_aborted; 621 idm_client_notify_cb_t iscsit_client_notify; 622 idm_build_hdr_cb_t iscsit_build_hdr; 623 idm_keepalive_cb_t iscsit_keepalive; 624 625 /* 626 * lport entry points 627 */ 628 stmf_status_t 629 iscsit_xfer_scsi_data(scsi_task_t *task, stmf_data_buf_t *dbuf, 630 uint32_t ioflags); 631 632 stmf_status_t 633 iscsit_send_scsi_status(scsi_task_t *task, uint32_t ioflags); 634 635 void 636 iscsit_lport_task_free(scsi_task_t *task); 637 638 stmf_status_t 639 iscsit_abort(stmf_local_port_t *lport, int abort_cmd, void *arg, 640 uint32_t flags); 641 642 void 643 iscsit_ctl(stmf_local_port_t *lport, int cmd, void *arg); 644 645 /* 646 * Connection functions 647 */ 648 idm_status_t 649 iscsit_conn_reinstate(iscsit_conn_t *existing_ict, iscsit_conn_t *ict); 650 651 void 652 iscsit_conn_destroy_done(iscsit_conn_t *ict); 653 654 void 655 iscsit_conn_set_auth(iscsit_conn_t *ict); 656 657 void 658 iscsit_conn_hold(iscsit_conn_t *ict); 659 660 void 661 iscsit_conn_rele(iscsit_conn_t *ict); 662 663 /* 664 * Session functions 665 */ 666 int 667 iscsit_sess_avl_compare(const void *void_sess1, const void *void_sess2); 668 669 iscsit_sess_t * 670 iscsit_sess_create(iscsit_tgt_t *tgt, iscsit_conn_t *ict, 671 uint32_t cmdsn, uint8_t *isid, uint16_t tag, 672 char *initiator_name, char *target_name, 673 uint8_t *error_class, uint8_t *error_detail); 674 675 void 676 iscsit_sess_destroy(iscsit_sess_t *ist); 677 678 void 679 iscsit_sess_hold(iscsit_sess_t *ist); 680 681 void 682 iscsit_sess_rele(iscsit_sess_t *ist); 683 684 iscsit_conn_t * 685 iscsit_sess_lookup_conn(iscsit_sess_t *ist, uint16_t cid); 686 687 void 688 iscsit_sess_bind_conn(iscsit_sess_t *ist, iscsit_conn_t *ict); 689 690 void 691 iscsit_sess_unbind_conn(iscsit_sess_t *ist, iscsit_conn_t *ict); 692 693 void 694 iscsit_sess_close(iscsit_sess_t *ist); 695 696 iscsit_sess_t * 697 iscsit_sess_reinstate(iscsit_tgt_t *tgt, iscsit_sess_t *ist, iscsit_conn_t *ict, 698 uint8_t *error_class, uint8_t *error_detail); 699 700 void 701 iscsit_sess_sm_event(iscsit_sess_t *ist, iscsit_session_event_t event, 702 iscsit_conn_t *ict); 703 704 /* 705 * Target, TPGT, TPGT and portal functions 706 */ 707 708 void 709 iscsit_tgt_sm_event(iscsit_tgt_t *tgt, iscsit_tgt_event_t event); 710 711 void 712 tgt_sm_event_locked(iscsit_tgt_t *tgt, iscsit_tgt_event_t event); 713 714 it_cfg_status_t 715 iscsit_config_merge_tgt(it_config_t *cfg); 716 717 void 718 iscsit_config_destroy_tgts(list_t *tgt_del_list); 719 720 void 721 iscsit_config_destroy_tpgts(list_t *tpgt_del_list); 722 723 iscsit_tgt_t * 724 iscsit_tgt_lookup(char *target_name); 725 726 iscsit_tgt_t * 727 iscsit_tgt_lookup_locked(char *target_name); 728 729 int 730 iscsit_tgt_avl_compare(const void *void_tgt1, const void *void_tgt2); 731 732 int 733 iscsit_tpgt_avl_compare(const void *void_tpgt1, const void *void_tpgt2); 734 735 void 736 iscsit_tgt_hold(iscsit_tgt_t *tgt); 737 738 void 739 iscsit_tgt_rele(iscsit_tgt_t *tgt); 740 741 iscsit_tpgt_t * 742 iscsit_tgt_lookup_tpgt(iscsit_tgt_t *tgt, uint16_t tag); 743 744 void 745 iscsit_tpgt_hold(iscsit_tpgt_t *tpgt); 746 747 void 748 iscsit_tpgt_rele(iscsit_tpgt_t *tpgt); 749 750 iscsit_portal_t * 751 iscsit_tgt_lookup_portal(iscsit_tgt_t *tgt, struct sockaddr_storage *sa, 752 iscsit_tpgt_t **output_tpgt); 753 754 iscsit_sess_t * 755 iscsit_tgt_lookup_sess(iscsit_tgt_t *tgt, char *initiator_name, 756 uint8_t *isid, uint16_t tsih, uint16_t tag); 757 758 void 759 iscsit_tgt_bind_sess(iscsit_tgt_t *tgt, iscsit_sess_t *sess); 760 761 void 762 iscsit_tgt_unbind_sess(iscsit_tgt_t *tgt, iscsit_sess_t *sess); 763 764 it_cfg_status_t 765 iscsit_config_merge_tpg(it_config_t *cfg, list_t *tpg_del_list); 766 767 void 768 iscsit_config_destroy_tpgs(list_t *tpg_del_list); 769 770 iscsit_tpg_t * 771 iscsit_tpg_lookup(char *tpg_name); 772 773 int 774 iscsit_tpg_avl_compare(const void *void_tpg1, const void *void_tpg2); 775 776 void 777 iscsit_tpg_hold(iscsit_tpg_t *tpg); 778 779 void 780 iscsit_tpg_rele(iscsit_tpg_t *tpg); 781 782 iscsit_tpg_t * 783 iscsit_tpg_createdefault(); 784 785 void 786 iscsit_tpg_destroydefault(iscsit_tpg_t *tpg); 787 788 idm_status_t 789 iscsit_tpg_online(iscsit_tpg_t *tpg); 790 791 void 792 iscsit_tpg_offline(iscsit_tpg_t *tpg); 793 794 iscsit_portal_t * 795 iscsit_tpg_portal_lookup(iscsit_tpg_t *tpg, struct sockaddr_storage *sa); 796 797 void 798 iscsit_portal_hold(iscsit_portal_t *portal); 799 800 void 801 iscsit_portal_rele(iscsit_portal_t *portal); 802 803 it_cfg_status_t 804 iscsit_config_merge_ini(it_config_t *cfg); 805 806 int 807 iscsit_ini_avl_compare(const void *void_ini1, const void *void_ini2); 808 809 iscsit_ini_t * 810 iscsit_ini_lookup_locked(char *ini_name); 811 812 int 813 iscsit_portal_avl_compare(const void *void_portal1, const void *void_portal2); 814 815 int 816 iscsit_verify_chap_resp(iscsit_conn_login_t *lsm, 817 unsigned int chap_i, uchar_t *chap_c, unsigned int challenge_len, 818 uchar_t *chap_r, unsigned int resp_len); 819 820 #endif /* _ISCSIT_H_ */ 821