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