Print this page
NEX-6018 Return of the walking dead idm_refcnt_wait_ref comstar threads
Reviewed by:  Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by:  Evan Layton <evan.layton@nexenta.com>
re #12375 rb4141 Create ALUA Support on NexentaStor; Failover causes loss of storage
re #7936 rb3706 Support for COMSTAR/OEM
re #8002 rb3706 Allow setting iSCSI vendor ID via stmf_sbd.conf
re #11454 rb3750 Fix inconsistent vid/pid in stmf
Re #6790 backspace should perform delete on console
VAAI (XXX ATS support for COMSTAR, YYY Block-copy support for COMSTAR)
   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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.

  23  * Copyright (c) 2013 by Delphix. All rights reserved.
  24  */

  25 #ifndef _STMF_H
  26 #define _STMF_H
  27 
  28 #include <sys/stmf_defines.h>
  29 
  30 #ifdef  __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 typedef enum stmf_struct_id {
  35         STMF_STRUCT_LU_PROVIDER = 1,
  36         STMF_STRUCT_PORT_PROVIDER,
  37         STMF_STRUCT_STMF_LOCAL_PORT,
  38         STMF_STRUCT_STMF_LU,
  39         STMF_STRUCT_SCSI_SESSION,
  40         STMF_STRUCT_SCSI_TASK,
  41         STMF_STRUCT_DATA_BUF,
  42         STMF_STRUCT_DBUF_STORE,
  43         STMF_MAX_STRUCT_IDS
  44 } stmf_struct_id_t;


 188 #define TM_CLEAR_TASK_SET       0x04
 189 #define TM_LUN_RESET            0x05
 190 #define TM_TARGET_WARM_RESET    0x06
 191 #define TM_TARGET_COLD_RESET    0x07
 192 #define TM_TASK_REASSIGN        0x08
 193 #define TM_TARGET_RESET         0x09
 194 #define TM_QUERY_TASK           0x0A
 195 
 196 /*
 197  * additional flags
 198  */
 199 #define TASK_AF_ENABLE_COMP_CONF        0x01
 200 #define TASK_AF_PORT_LOAD_HIGH          0x02
 201 #define TASK_AF_NO_EXPECTED_XFER_LENGTH 0x04
 202 /*
 203  * PP sets this flag if it can process dbufs created by the LU.
 204  */
 205 #define TASK_AF_ACCEPT_LU_DBUF          0x08
 206 
 207 /*





 208  * scsi_task_t extension identifiers
 209  */
 210 #define STMF_TASK_EXT_NONE              0
 211 
 212 /*
 213  * max_nbufs
 214  */
 215 #define STMF_BUFS_MAX           255
 216 
 217 /*
 218  * Task status ctrl
 219  */
 220 #define TASK_SCTRL_OVER         1
 221 #define TASK_SCTRL_UNDER        2
 222 
 223 /*
 224  * The flags used by I/O flow.
 225  */
 226 #define STMF_IOF_LU_DONE                0x0001
 227 #define STMF_IOF_LPORT_DONE             0x0002


 362 void stmf_free(void *struct_ptr);
 363 struct scsi_task *stmf_task_alloc(struct stmf_local_port *lport,
 364     struct stmf_scsi_session *ss, uint8_t *lun, uint16_t cdb_length,
 365     uint16_t ext_id);
 366 void stmf_post_task(scsi_task_t *task, stmf_data_buf_t *dbuf);
 367 stmf_data_buf_t *stmf_alloc_dbuf(scsi_task_t *task, uint32_t size,
 368     uint32_t *pminsize, uint32_t flags);
 369 void stmf_free_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf);
 370 stmf_status_t stmf_setup_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf,
 371     uint32_t flags);
 372 void stmf_teardown_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf);
 373 stmf_status_t stmf_xfer_data(scsi_task_t *task, stmf_data_buf_t *dbuf,
 374     uint32_t ioflags);
 375 stmf_status_t stmf_send_scsi_status(scsi_task_t *task, uint32_t ioflags);
 376 void stmf_data_xfer_done(scsi_task_t *task, stmf_data_buf_t *dbuf,
 377     uint32_t iof);
 378 void stmf_send_status_done(scsi_task_t *task, stmf_status_t s, uint32_t iof);
 379 void stmf_task_lu_done(scsi_task_t *task);
 380 void stmf_abort(int abort_cmd, scsi_task_t *task, stmf_status_t s, void *arg);
 381 void stmf_task_lu_aborted(scsi_task_t *task, stmf_status_t s, uint32_t iof);
 382 void stmf_task_lport_aborted(scsi_task_t *task, stmf_status_t s, uint32_t iof);

 383 stmf_status_t stmf_task_poll_lu(scsi_task_t *task, uint32_t timeout);
 384 stmf_status_t stmf_task_poll_lport(scsi_task_t *task, uint32_t timeout);
 385 stmf_status_t stmf_ctl(int cmd, void *obj, void *arg);
 386 stmf_status_t stmf_register_itl_handle(struct stmf_lu *lu, uint8_t *lun,
 387     struct stmf_scsi_session *ss, uint64_t session_id, void *itl_handle);
 388 stmf_status_t stmf_deregister_all_lu_itl_handles(struct stmf_lu *lu);
 389 stmf_status_t stmf_get_itl_handle(struct stmf_lu *lu, uint8_t *lun,
 390     struct stmf_scsi_session *ss, uint64_t session_id, void **itl_handle_retp);
 391 stmf_data_buf_t *stmf_handle_to_buf(scsi_task_t *task, uint8_t h);
 392 stmf_status_t stmf_lu_add_event(struct stmf_lu *lu, int eventid);
 393 stmf_status_t stmf_lu_remove_event(struct stmf_lu *lu, int eventid);
 394 stmf_status_t stmf_lport_add_event(struct stmf_local_port *lport, int eventid);
 395 stmf_status_t stmf_lport_remove_event(struct stmf_local_port *lport,
 396     int eventid);
 397 void stmf_wwn_to_devid_desc(struct scsi_devid_desc *sdid, uint8_t *wwn,
 398     uint8_t protocol_id);
 399 stmf_status_t stmf_scsilib_uniq_lu_id(uint32_t company_id,
 400     struct scsi_devid_desc *lu_id);
 401 stmf_status_t stmf_scsilib_uniq_lu_id2(uint32_t company_id, uint32_t host_id,
 402     struct scsi_devid_desc *lu_id);
 403 void stmf_scsilib_send_status(scsi_task_t *task, uint8_t st, uint32_t saa);
 404 uint32_t stmf_scsilib_prepare_vpd_page83(scsi_task_t *task, uint8_t *page,
 405                 uint32_t page_len, uint8_t byte0, uint32_t vpd_mask);
 406 uint16_t stmf_scsilib_get_lport_rtid(struct scsi_devid_desc *devid);
 407 struct scsi_devid_desc *stmf_scsilib_get_devid_desc(uint16_t rtpid);
 408 void stmf_scsilib_handle_report_tpgs(scsi_task_t *task, stmf_data_buf_t *dbuf);
 409 void stmf_scsilib_handle_task_mgmt(scsi_task_t *task);
 410 
 411 struct stmf_remote_port *stmf_scsilib_devid_to_remote_port(
 412     struct scsi_devid_desc *);
 413 boolean_t stmf_scsilib_tptid_validate(struct scsi_transport_id *,
 414     uint32_t, uint16_t *);
 415 boolean_t stmf_scsilib_tptid_compare(struct scsi_transport_id *,
 416     struct scsi_transport_id *);
 417 struct stmf_remote_port *stmf_remote_port_alloc(uint16_t);
 418 void stmf_remote_port_free(struct stmf_remote_port *);



 419 #ifdef  __cplusplus
 420 }
 421 #endif
 422 
 423 #endif  /* _STMF_H */
   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 /*
  23  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
  25  * Copyright (c) 2013 by Delphix. All rights reserved.
  26  */
  27 
  28 #ifndef _STMF_H
  29 #define _STMF_H
  30 
  31 #include <sys/stmf_defines.h>
  32 
  33 #ifdef  __cplusplus
  34 extern "C" {
  35 #endif
  36 
  37 typedef enum stmf_struct_id {
  38         STMF_STRUCT_LU_PROVIDER = 1,
  39         STMF_STRUCT_PORT_PROVIDER,
  40         STMF_STRUCT_STMF_LOCAL_PORT,
  41         STMF_STRUCT_STMF_LU,
  42         STMF_STRUCT_SCSI_SESSION,
  43         STMF_STRUCT_SCSI_TASK,
  44         STMF_STRUCT_DATA_BUF,
  45         STMF_STRUCT_DBUF_STORE,
  46         STMF_MAX_STRUCT_IDS
  47 } stmf_struct_id_t;


 191 #define TM_CLEAR_TASK_SET       0x04
 192 #define TM_LUN_RESET            0x05
 193 #define TM_TARGET_WARM_RESET    0x06
 194 #define TM_TARGET_COLD_RESET    0x07
 195 #define TM_TASK_REASSIGN        0x08
 196 #define TM_TARGET_RESET         0x09
 197 #define TM_QUERY_TASK           0x0A
 198 
 199 /*
 200  * additional flags
 201  */
 202 #define TASK_AF_ENABLE_COMP_CONF        0x01
 203 #define TASK_AF_PORT_LOAD_HIGH          0x02
 204 #define TASK_AF_NO_EXPECTED_XFER_LENGTH 0x04
 205 /*
 206  * PP sets this flag if it can process dbufs created by the LU.
 207  */
 208 #define TASK_AF_ACCEPT_LU_DBUF          0x08
 209 
 210 /*
 211  * Indicating a PPPT task
 212  */
 213 #define TASK_AF_PPPT_TASK               0x10
 214 
 215 /*
 216  * scsi_task_t extension identifiers
 217  */
 218 #define STMF_TASK_EXT_NONE              0
 219 
 220 /*
 221  * max_nbufs
 222  */
 223 #define STMF_BUFS_MAX           255
 224 
 225 /*
 226  * Task status ctrl
 227  */
 228 #define TASK_SCTRL_OVER         1
 229 #define TASK_SCTRL_UNDER        2
 230 
 231 /*
 232  * The flags used by I/O flow.
 233  */
 234 #define STMF_IOF_LU_DONE                0x0001
 235 #define STMF_IOF_LPORT_DONE             0x0002


 370 void stmf_free(void *struct_ptr);
 371 struct scsi_task *stmf_task_alloc(struct stmf_local_port *lport,
 372     struct stmf_scsi_session *ss, uint8_t *lun, uint16_t cdb_length,
 373     uint16_t ext_id);
 374 void stmf_post_task(scsi_task_t *task, stmf_data_buf_t *dbuf);
 375 stmf_data_buf_t *stmf_alloc_dbuf(scsi_task_t *task, uint32_t size,
 376     uint32_t *pminsize, uint32_t flags);
 377 void stmf_free_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf);
 378 stmf_status_t stmf_setup_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf,
 379     uint32_t flags);
 380 void stmf_teardown_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf);
 381 stmf_status_t stmf_xfer_data(scsi_task_t *task, stmf_data_buf_t *dbuf,
 382     uint32_t ioflags);
 383 stmf_status_t stmf_send_scsi_status(scsi_task_t *task, uint32_t ioflags);
 384 void stmf_data_xfer_done(scsi_task_t *task, stmf_data_buf_t *dbuf,
 385     uint32_t iof);
 386 void stmf_send_status_done(scsi_task_t *task, stmf_status_t s, uint32_t iof);
 387 void stmf_task_lu_done(scsi_task_t *task);
 388 void stmf_abort(int abort_cmd, scsi_task_t *task, stmf_status_t s, void *arg);
 389 void stmf_task_lu_aborted(scsi_task_t *task, stmf_status_t s, uint32_t iof);
 390 void stmf_task_lport_aborted_unlocked(scsi_task_t *task, stmf_status_t s,
 391     uint32_t iof);
 392 stmf_status_t stmf_task_poll_lu(scsi_task_t *task, uint32_t timeout);
 393 stmf_status_t stmf_task_poll_lport(scsi_task_t *task, uint32_t timeout);
 394 stmf_status_t stmf_ctl(int cmd, void *obj, void *arg);
 395 stmf_status_t stmf_register_itl_handle(struct stmf_lu *lu, uint8_t *lun,
 396     struct stmf_scsi_session *ss, uint64_t session_id, void *itl_handle);
 397 stmf_status_t stmf_deregister_all_lu_itl_handles(struct stmf_lu *lu);
 398 stmf_status_t stmf_get_itl_handle(struct stmf_lu *lu, uint8_t *lun,
 399     struct stmf_scsi_session *ss, uint64_t session_id, void **itl_handle_retp);
 400 stmf_data_buf_t *stmf_handle_to_buf(scsi_task_t *task, uint8_t h);
 401 stmf_status_t stmf_lu_add_event(struct stmf_lu *lu, int eventid);
 402 stmf_status_t stmf_lu_remove_event(struct stmf_lu *lu, int eventid);
 403 stmf_status_t stmf_lport_add_event(struct stmf_local_port *lport, int eventid);
 404 stmf_status_t stmf_lport_remove_event(struct stmf_local_port *lport,
 405     int eventid);
 406 void stmf_wwn_to_devid_desc(struct scsi_devid_desc *sdid, uint8_t *wwn,
 407     uint8_t protocol_id);
 408 stmf_status_t stmf_scsilib_uniq_lu_id(uint32_t company_id,
 409     struct scsi_devid_desc *lu_id);
 410 stmf_status_t stmf_scsilib_uniq_lu_id2(uint32_t company_id, uint32_t host_id,
 411     struct scsi_devid_desc *lu_id);
 412 void stmf_scsilib_send_status(scsi_task_t *task, uint8_t st, uint32_t saa);
 413 uint32_t stmf_scsilib_prepare_vpd_page83(scsi_task_t *task, uint8_t *page,
 414                 uint32_t page_len, uint8_t byte0, uint32_t vpd_mask);
 415 uint16_t stmf_scsilib_get_lport_rtid(struct scsi_devid_desc *devid);
 416 struct scsi_devid_desc *stmf_scsilib_get_devid_desc(uint16_t rtpid);
 417 void stmf_scsilib_handle_report_tpgs(scsi_task_t *task, stmf_data_buf_t *dbuf);
 418 void stmf_scsilib_handle_task_mgmt(scsi_task_t *task);
 419 
 420 struct stmf_remote_port *stmf_scsilib_devid_to_remote_port(
 421     struct scsi_devid_desc *);
 422 boolean_t stmf_scsilib_tptid_validate(struct scsi_transport_id *,
 423     uint32_t, uint16_t *);
 424 boolean_t stmf_scsilib_tptid_compare(struct scsi_transport_id *,
 425     struct scsi_transport_id *);
 426 struct stmf_remote_port *stmf_remote_port_alloc(uint16_t);
 427 void stmf_remote_port_free(struct stmf_remote_port *);
 428 struct stmf_lu *stmf_check_and_hold_lu(struct scsi_task *task, uint8_t *guid);
 429 void stmf_release_lu(struct stmf_lu *lu);
 430 int stmf_is_task_being_aborted(struct scsi_task *task);
 431 #ifdef  __cplusplus
 432 }
 433 #endif
 434 
 435 #endif  /* _STMF_H */