17836SJohn.Forte@Sun.COM /* 27836SJohn.Forte@Sun.COM * CDDL HEADER START 37836SJohn.Forte@Sun.COM * 47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 77836SJohn.Forte@Sun.COM * 87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 117836SJohn.Forte@Sun.COM * and limitations under the License. 127836SJohn.Forte@Sun.COM * 137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 187836SJohn.Forte@Sun.COM * 197836SJohn.Forte@Sun.COM * CDDL HEADER END 207836SJohn.Forte@Sun.COM */ 217836SJohn.Forte@Sun.COM /* 2212625SJohn.Forte@Sun.COM * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 237836SJohn.Forte@Sun.COM */ 247836SJohn.Forte@Sun.COM #ifndef _STMF_IMPL_H 257836SJohn.Forte@Sun.COM #define _STMF_IMPL_H 267836SJohn.Forte@Sun.COM 277836SJohn.Forte@Sun.COM #include <sys/stmf_defines.h> 287836SJohn.Forte@Sun.COM #include <sys/stmf_ioctl.h> 297836SJohn.Forte@Sun.COM 307836SJohn.Forte@Sun.COM #ifdef __cplusplus 317836SJohn.Forte@Sun.COM extern "C" { 327836SJohn.Forte@Sun.COM #endif 337836SJohn.Forte@Sun.COM 347836SJohn.Forte@Sun.COM typedef uint32_t stmf_event_handle_t; 357836SJohn.Forte@Sun.COM #define STMF_MAX_NUM_EVENTS (sizeof (stmf_event_handle_t) * 8) 367836SJohn.Forte@Sun.COM #define STMF_EVENT_ADD(h, e) (atomic_or_32(&(h), \ 377836SJohn.Forte@Sun.COM ((uint32_t)1) << (e))) 387836SJohn.Forte@Sun.COM #define STMF_EVENT_REMOVE(h, e) (atomic_and_32(&(h), \ 397836SJohn.Forte@Sun.COM ~(((uint32_t)1) << (e)))) 407836SJohn.Forte@Sun.COM #define STMF_EVENT_ENABLED(h, e) (((h) & ((uint32_t)1) << (e)) != 0) 417836SJohn.Forte@Sun.COM #define STMF_EVENT_CLEAR_ALL(h) ((h) = 0) 427836SJohn.Forte@Sun.COM #define STMF_EVENT_ALLOC_HANDLE(h) ((h) = 0) 437836SJohn.Forte@Sun.COM #define STMF_EVENT_FREE_HANDLE(h) ((h) = 0) 447836SJohn.Forte@Sun.COM 459435STim.Szeto@Sun.COM #define STMF_TGT_NAME_LEN 256 469435STim.Szeto@Sun.COM #define STMF_GUID_INPUT 32 479435STim.Szeto@Sun.COM 489435STim.Szeto@Sun.COM #define STMF_UPDATE_KSTAT_IO(kip, dbuf) \ 499435STim.Szeto@Sun.COM if (dbuf->db_flags & DB_DIRECTION_TO_RPORT) { \ 509435STim.Szeto@Sun.COM kip->reads++; \ 519435STim.Szeto@Sun.COM kip->nread += dbuf->db_data_size; \ 529435STim.Szeto@Sun.COM } else { \ 539435STim.Szeto@Sun.COM kip->writes++; \ 549435STim.Szeto@Sun.COM kip->nwritten += dbuf->db_data_size; \ 559435STim.Szeto@Sun.COM } 569435STim.Szeto@Sun.COM 577836SJohn.Forte@Sun.COM struct stmf_i_scsi_task; 587836SJohn.Forte@Sun.COM struct stmf_itl_data; 597836SJohn.Forte@Sun.COM 607836SJohn.Forte@Sun.COM typedef struct stmf_i_lu_provider { 617836SJohn.Forte@Sun.COM stmf_lu_provider_t *ilp_lp; 627836SJohn.Forte@Sun.COM uint32_t ilp_alloc_size; 637836SJohn.Forte@Sun.COM uint32_t ilp_nlus; /* # LUNs being exported */ 647836SJohn.Forte@Sun.COM uint32_t ilp_cb_in_progress:1, 657836SJohn.Forte@Sun.COM ilp_rsvd:31; 667836SJohn.Forte@Sun.COM struct stmf_i_lu_provider *ilp_next; 677836SJohn.Forte@Sun.COM struct stmf_pp_data *ilp_ppd; 687836SJohn.Forte@Sun.COM } stmf_i_lu_provider_t; 697836SJohn.Forte@Sun.COM 707836SJohn.Forte@Sun.COM typedef struct stmf_i_lu { 717836SJohn.Forte@Sun.COM stmf_lu_t *ilu_lu; 727836SJohn.Forte@Sun.COM uint32_t ilu_alloc_size; 737836SJohn.Forte@Sun.COM uint32_t ilu_flags; 747836SJohn.Forte@Sun.COM uint32_t ilu_ref_cnt; 757836SJohn.Forte@Sun.COM uint8_t ilu_state; 767836SJohn.Forte@Sun.COM uint8_t ilu_prev_state; 7710725SJohn.Forte@Sun.COM uint8_t ilu_access; 7810725SJohn.Forte@Sun.COM uint8_t ilu_alua; 797836SJohn.Forte@Sun.COM stmf_event_handle_t ilu_event_hdl; 807836SJohn.Forte@Sun.COM struct stmf_i_lu *ilu_next; 817836SJohn.Forte@Sun.COM struct stmf_i_lu *ilu_prev; 827836SJohn.Forte@Sun.COM char *ilu_alias; 839435STim.Szeto@Sun.COM char ilu_ascii_hex_guid[STMF_GUID_INPUT + 1]; 847836SJohn.Forte@Sun.COM kmutex_t ilu_task_lock; 857836SJohn.Forte@Sun.COM uint32_t ilu_task_cntr1; 867836SJohn.Forte@Sun.COM uint32_t ilu_task_cntr2; 877836SJohn.Forte@Sun.COM uint32_t *ilu_cur_task_cntr; 887836SJohn.Forte@Sun.COM uint32_t ilu_ntasks; /* # of tasks in the ilu_task list */ 897836SJohn.Forte@Sun.COM uint32_t ilu_ntasks_free; /* # of tasks that are free */ 907836SJohn.Forte@Sun.COM uint32_t ilu_ntasks_min_free; /* # minimal free tasks */ 9110725SJohn.Forte@Sun.COM uint32_t rsvd1; 9210725SJohn.Forte@Sun.COM uint32_t ilu_proxy_registered; 9310725SJohn.Forte@Sun.COM uint64_t ilu_reg_msgid; 947836SJohn.Forte@Sun.COM struct stmf_i_scsi_task *ilu_tasks; 957836SJohn.Forte@Sun.COM struct stmf_i_scsi_task *ilu_free_tasks; 967836SJohn.Forte@Sun.COM struct stmf_itl_data *ilu_itl_list; 979435STim.Szeto@Sun.COM kstat_t *ilu_kstat_info; 989435STim.Szeto@Sun.COM kstat_t *ilu_kstat_io; 999435STim.Szeto@Sun.COM kmutex_t ilu_kstat_lock; 1007836SJohn.Forte@Sun.COM 1017836SJohn.Forte@Sun.COM /* point to the luid entry in stmf_state.stmf_luid_list */ 1027836SJohn.Forte@Sun.COM void *ilu_luid; 1037836SJohn.Forte@Sun.COM } stmf_i_lu_t; 1047836SJohn.Forte@Sun.COM 1057836SJohn.Forte@Sun.COM /* 1067836SJohn.Forte@Sun.COM * ilu_flags 1077836SJohn.Forte@Sun.COM */ 1087836SJohn.Forte@Sun.COM #define ILU_STALL_DEREGISTER 0x0001 1097836SJohn.Forte@Sun.COM #define ILU_RESET_ACTIVE 0x0002 1107836SJohn.Forte@Sun.COM 1117836SJohn.Forte@Sun.COM typedef struct stmf_i_port_provider { 1127836SJohn.Forte@Sun.COM stmf_port_provider_t *ipp_pp; 1137836SJohn.Forte@Sun.COM uint32_t ipp_alloc_size; 1147836SJohn.Forte@Sun.COM uint32_t ipp_npps; 1157836SJohn.Forte@Sun.COM uint32_t ipp_cb_in_progress:1, 1167836SJohn.Forte@Sun.COM ipp_rsvd:31; 1177836SJohn.Forte@Sun.COM struct stmf_i_port_provider *ipp_next; 1187836SJohn.Forte@Sun.COM struct stmf_pp_data *ipp_ppd; 1197836SJohn.Forte@Sun.COM } stmf_i_port_provider_t; 1207836SJohn.Forte@Sun.COM 12111773STim.Szeto@Sun.COM #define MAX_ILPORT 0x10000 12211773STim.Szeto@Sun.COM 1237836SJohn.Forte@Sun.COM typedef struct stmf_i_local_port { 1247836SJohn.Forte@Sun.COM stmf_local_port_t *ilport_lport; 1257836SJohn.Forte@Sun.COM uint32_t ilport_alloc_size; 1267836SJohn.Forte@Sun.COM uint32_t ilport_nsessions; 1277836SJohn.Forte@Sun.COM struct stmf_i_scsi_session *ilport_ss_list; 1287836SJohn.Forte@Sun.COM krwlock_t ilport_lock; 1297836SJohn.Forte@Sun.COM struct stmf_i_local_port *ilport_next; 1307836SJohn.Forte@Sun.COM struct stmf_i_local_port *ilport_prev; 1317836SJohn.Forte@Sun.COM uint8_t ilport_state; 1327836SJohn.Forte@Sun.COM uint8_t ilport_prev_state; 13310725SJohn.Forte@Sun.COM uint8_t ilport_standby; 13410725SJohn.Forte@Sun.COM uint8_t ilport_alua; 1357836SJohn.Forte@Sun.COM uint16_t ilport_rtpid; /* relative tpid */ 13610725SJohn.Forte@Sun.COM uint16_t ilport_proxy_registered; 13710725SJohn.Forte@Sun.COM uint64_t ilport_reg_msgid; 13810725SJohn.Forte@Sun.COM uint8_t ilport_no_standby_lu; 13912625SJohn.Forte@Sun.COM uint32_t ilport_unexpected_comp; 1407836SJohn.Forte@Sun.COM stmf_event_handle_t ilport_event_hdl; 1417836SJohn.Forte@Sun.COM clock_t ilport_last_online_clock; 1427836SJohn.Forte@Sun.COM clock_t ilport_avg_interval; 1437836SJohn.Forte@Sun.COM uint32_t ilport_online_times; 1447836SJohn.Forte@Sun.COM uint32_t ilport_flags; 1459435STim.Szeto@Sun.COM kstat_t *ilport_kstat_info; 1469435STim.Szeto@Sun.COM kstat_t *ilport_kstat_io; 1479435STim.Szeto@Sun.COM kmutex_t ilport_kstat_lock; 1489435STim.Szeto@Sun.COM char ilport_kstat_tgt_name[STMF_TGT_NAME_LEN]; 1497836SJohn.Forte@Sun.COM /* which target group this port belongs to in stmf_state.stmf_tg_list */ 1507836SJohn.Forte@Sun.COM void *ilport_tg; 15111773STim.Szeto@Sun.COM id_t ilport_instance; 1527836SJohn.Forte@Sun.COM /* XXX Need something to track all the remote ports also */ 1537836SJohn.Forte@Sun.COM } stmf_i_local_port_t; 1547836SJohn.Forte@Sun.COM 1557836SJohn.Forte@Sun.COM #define STMF_AVG_ONLINE_INTERVAL (30 * drv_usectohz(1000000)) 1567836SJohn.Forte@Sun.COM 15711773STim.Szeto@Sun.COM #define MAX_IRPORT 0x10000 15811773STim.Szeto@Sun.COM 15911773STim.Szeto@Sun.COM typedef struct stmf_i_remote_port { 16011773STim.Szeto@Sun.COM struct scsi_devid_desc *irport_id; 16111773STim.Szeto@Sun.COM kmutex_t irport_mutex; 16211773STim.Szeto@Sun.COM int irport_refcnt; 16311773STim.Szeto@Sun.COM id_t irport_instance; 16411773STim.Szeto@Sun.COM avl_node_t irport_ln; 16511773STim.Szeto@Sun.COM } stmf_i_remote_port_t; 16611773STim.Szeto@Sun.COM 16711773STim.Szeto@Sun.COM typedef struct stmf_i_itl_kstat { 16811773STim.Szeto@Sun.COM char iitl_kstat_nm[KSTAT_STRLEN]; 16911773STim.Szeto@Sun.COM char iitl_kstat_lport[STMF_TGT_NAME_LEN]; 17011773STim.Szeto@Sun.COM char iitl_kstat_guid[STMF_GUID_INPUT + 1]; 17111773STim.Szeto@Sun.COM char *iitl_kstat_strbuf; 17211773STim.Szeto@Sun.COM int iitl_kstat_strbuflen; 17311773STim.Szeto@Sun.COM kstat_t *iitl_kstat_info; 17411773STim.Szeto@Sun.COM kstat_t *iitl_kstat_taskq; 17511773STim.Szeto@Sun.COM kstat_t *iitl_kstat_lu_xfer; 17611773STim.Szeto@Sun.COM kstat_t *iitl_kstat_lport_xfer; 17711773STim.Szeto@Sun.COM avl_node_t iitl_kstat_ln; 17811773STim.Szeto@Sun.COM } stmf_i_itl_kstat_t; 17911773STim.Szeto@Sun.COM 1807836SJohn.Forte@Sun.COM /* 1817836SJohn.Forte@Sun.COM * ilport flags 1827836SJohn.Forte@Sun.COM */ 1837836SJohn.Forte@Sun.COM #define ILPORT_FORCED_OFFLINE 0x01 1847836SJohn.Forte@Sun.COM #define ILPORT_SS_GOT_INITIAL_LUNS 0x02 1857836SJohn.Forte@Sun.COM 1867836SJohn.Forte@Sun.COM typedef struct stmf_i_scsi_session { 1877836SJohn.Forte@Sun.COM stmf_scsi_session_t *iss_ss; 1887836SJohn.Forte@Sun.COM uint32_t iss_alloc_size; 1897836SJohn.Forte@Sun.COM uint32_t iss_flags; 19011773STim.Szeto@Sun.COM stmf_i_remote_port_t *iss_irport; 1917836SJohn.Forte@Sun.COM struct stmf_i_scsi_session *iss_next; 1927836SJohn.Forte@Sun.COM /* 1937836SJohn.Forte@Sun.COM * Ideally we should maintain 2 maps. One would indicate a new map 1947836SJohn.Forte@Sun.COM * which will become available only upon receipt of a REPORT LUN 1957836SJohn.Forte@Sun.COM * cmd. 1967836SJohn.Forte@Sun.COM */ 1977836SJohn.Forte@Sun.COM struct stmf_lun_map *iss_sm; 1987836SJohn.Forte@Sun.COM /* 1997836SJohn.Forte@Sun.COM * which host group the host of this session belongs to in 2007836SJohn.Forte@Sun.COM * stmf_state.stmf_hg_list 2017836SJohn.Forte@Sun.COM */ 2027836SJohn.Forte@Sun.COM void *iss_hg; 2037836SJohn.Forte@Sun.COM krwlock_t *iss_lockp; 2047836SJohn.Forte@Sun.COM time_t iss_creation_time; 2057836SJohn.Forte@Sun.COM } stmf_i_scsi_session_t; 2067836SJohn.Forte@Sun.COM 2077836SJohn.Forte@Sun.COM /* 2087836SJohn.Forte@Sun.COM * iss flags 2097836SJohn.Forte@Sun.COM */ 2107836SJohn.Forte@Sun.COM #define ISS_LUN_INVENTORY_CHANGED 0x0001 2117836SJohn.Forte@Sun.COM #define ISS_RESET_ACTIVE 0x0002 2127836SJohn.Forte@Sun.COM #define ISS_BEING_CREATED 0x0004 2137836SJohn.Forte@Sun.COM #define ISS_GOT_INITIAL_LUNS 0x0008 2147836SJohn.Forte@Sun.COM #define ISS_EVENT_ACTIVE 0x0010 215*12750SNattuvetty.Bhavyan@Sun.COM #define ISS_NULL_TPTID 0x0020 2167836SJohn.Forte@Sun.COM 2177836SJohn.Forte@Sun.COM #define ITASK_MAX_NCMDS 14 2187836SJohn.Forte@Sun.COM #define ITASK_DEFAULT_POLL_TIMEOUT 0 21912625SJohn.Forte@Sun.COM 22012625SJohn.Forte@Sun.COM #define ITASK_TASK_AUDIT_DEPTH 32 /* Must be a power of 2 */ 22112625SJohn.Forte@Sun.COM 22212625SJohn.Forte@Sun.COM typedef enum { 22312625SJohn.Forte@Sun.COM TE_UNDEFINED, 22412625SJohn.Forte@Sun.COM TE_TASK_START, 22512625SJohn.Forte@Sun.COM TE_XFER_START, 22612625SJohn.Forte@Sun.COM TE_XFER_DONE, 22712625SJohn.Forte@Sun.COM TE_SEND_STATUS, 22812625SJohn.Forte@Sun.COM TE_SEND_STATUS_DONE, 22912625SJohn.Forte@Sun.COM TE_TASK_FREE, 23012625SJohn.Forte@Sun.COM TE_TASK_ABORT, 23112625SJohn.Forte@Sun.COM TE_TASK_LPORT_ABORTED, 23212625SJohn.Forte@Sun.COM TE_TASK_LU_ABORTED, 23312625SJohn.Forte@Sun.COM TE_PROCESS_CMD 23412625SJohn.Forte@Sun.COM } task_audit_event_t; 23512625SJohn.Forte@Sun.COM 23612625SJohn.Forte@Sun.COM #define CMD_OR_IOF_NA 0xffffffff 23712625SJohn.Forte@Sun.COM 23812625SJohn.Forte@Sun.COM typedef struct stmf_task_audit_rec { 23912625SJohn.Forte@Sun.COM task_audit_event_t ta_event; 24012625SJohn.Forte@Sun.COM uint32_t ta_cmd_or_iof; 24112625SJohn.Forte@Sun.COM uint32_t ta_itask_flags; 24212625SJohn.Forte@Sun.COM stmf_data_buf_t *ta_dbuf; 24312625SJohn.Forte@Sun.COM timespec_t ta_timestamp; 24412625SJohn.Forte@Sun.COM } stmf_task_audit_rec_t; 24512625SJohn.Forte@Sun.COM 2467836SJohn.Forte@Sun.COM struct stmf_worker; 2477836SJohn.Forte@Sun.COM typedef struct stmf_i_scsi_task { 2487836SJohn.Forte@Sun.COM scsi_task_t *itask_task; 2497836SJohn.Forte@Sun.COM uint32_t itask_alloc_size; 2507836SJohn.Forte@Sun.COM uint32_t itask_flags; 25110725SJohn.Forte@Sun.COM uint64_t itask_proxy_msg_id; 25210725SJohn.Forte@Sun.COM stmf_data_buf_t *itask_proxy_dbuf; 2537836SJohn.Forte@Sun.COM struct stmf_worker *itask_worker; 2547836SJohn.Forte@Sun.COM uint32_t *itask_ilu_task_cntr; 2557836SJohn.Forte@Sun.COM struct stmf_i_scsi_task *itask_worker_next; 2567836SJohn.Forte@Sun.COM struct stmf_i_scsi_task *itask_lu_next; 2577836SJohn.Forte@Sun.COM struct stmf_i_scsi_task *itask_lu_prev; 2587836SJohn.Forte@Sun.COM struct stmf_i_scsi_task *itask_lu_free_next; 2597836SJohn.Forte@Sun.COM struct stmf_i_scsi_task *itask_abort_next; 2607836SJohn.Forte@Sun.COM struct stmf_itl_data *itask_itl_datap; 2617836SJohn.Forte@Sun.COM clock_t itask_start_time; /* abort and normal */ 2627836SJohn.Forte@Sun.COM /* For now we only support 4 parallel buffers. Should be enough. */ 2637836SJohn.Forte@Sun.COM stmf_data_buf_t *itask_dbufs[4]; 2647836SJohn.Forte@Sun.COM clock_t itask_poll_timeout; 2657836SJohn.Forte@Sun.COM uint8_t itask_cmd_stack[ITASK_MAX_NCMDS]; 2667836SJohn.Forte@Sun.COM uint8_t itask_ncmds; 2677836SJohn.Forte@Sun.COM uint8_t itask_allocated_buf_map; 2687836SJohn.Forte@Sun.COM uint16_t itask_cdb_buf_size; 26911773STim.Szeto@Sun.COM 27011773STim.Szeto@Sun.COM /* Task profile data */ 27111773STim.Szeto@Sun.COM hrtime_t itask_start_timestamp; 27211773STim.Szeto@Sun.COM hrtime_t itask_done_timestamp; 27311773STim.Szeto@Sun.COM hrtime_t itask_waitq_enter_timestamp; 27411773STim.Szeto@Sun.COM hrtime_t itask_waitq_time; 27511773STim.Szeto@Sun.COM hrtime_t itask_lu_read_time; 27611773STim.Szeto@Sun.COM hrtime_t itask_lu_write_time; 27711773STim.Szeto@Sun.COM hrtime_t itask_lport_read_time; 27811773STim.Szeto@Sun.COM hrtime_t itask_lport_write_time; 27911773STim.Szeto@Sun.COM uint64_t itask_read_xfer; 28011773STim.Szeto@Sun.COM uint64_t itask_write_xfer; 28112625SJohn.Forte@Sun.COM kmutex_t itask_audit_mutex; 28212625SJohn.Forte@Sun.COM uint8_t itask_audit_index; 28312625SJohn.Forte@Sun.COM stmf_task_audit_rec_t itask_audit_records[ITASK_TASK_AUDIT_DEPTH]; 2847836SJohn.Forte@Sun.COM } stmf_i_scsi_task_t; 2857836SJohn.Forte@Sun.COM 2867836SJohn.Forte@Sun.COM #define ITASK_DEFAULT_ABORT_TIMEOUT 5 2877836SJohn.Forte@Sun.COM 2887836SJohn.Forte@Sun.COM /* 2897836SJohn.Forte@Sun.COM * itask_flags 2907836SJohn.Forte@Sun.COM */ 2917836SJohn.Forte@Sun.COM #define ITASK_IN_FREE_LIST 0x0001 2927836SJohn.Forte@Sun.COM #define ITASK_IN_TRANSITION 0x0002 2937836SJohn.Forte@Sun.COM #define ITASK_IN_WORKER_QUEUE 0x0004 2947836SJohn.Forte@Sun.COM #define ITASK_BEING_ABORTED 0x0008 2957836SJohn.Forte@Sun.COM #define ITASK_BEING_COMPLETED 0x0010 2967836SJohn.Forte@Sun.COM #define ITASK_KNOWN_TO_TGT_PORT 0x0020 2977836SJohn.Forte@Sun.COM #define ITASK_KNOWN_TO_LU 0x0040 2987836SJohn.Forte@Sun.COM #define ITASK_LU_ABORT_CALLED 0x0080 2997836SJohn.Forte@Sun.COM #define ITASK_TGT_PORT_ABORT_CALLED 0x0100 3007836SJohn.Forte@Sun.COM #define ITASK_DEFAULT_HANDLING 0x0200 3017836SJohn.Forte@Sun.COM #define ITASK_CAUSING_LU_RESET 0x0400 3027836SJohn.Forte@Sun.COM #define ITASK_CAUSING_TARGET_RESET 0x0800 30310421STim.Szeto@Sun.COM #define ITASK_KSTAT_IN_RUNQ 0x1000 30410725SJohn.Forte@Sun.COM #define ITASK_PROXY_TASK 0x2000 3057836SJohn.Forte@Sun.COM 3067836SJohn.Forte@Sun.COM /* 3077836SJohn.Forte@Sun.COM * itask cmds. 3087836SJohn.Forte@Sun.COM */ 3097836SJohn.Forte@Sun.COM #define ITASK_CMD_MASK 0x1F 3107836SJohn.Forte@Sun.COM #define ITASK_CMD_BUF_NDX(cmd) (((uint8_t)(cmd)) >> 5) 3117836SJohn.Forte@Sun.COM #define ITASK_CMD_NEW_TASK 0x1 3127836SJohn.Forte@Sun.COM #define ITASK_CMD_DATA_XFER_DONE 0x2 3137836SJohn.Forte@Sun.COM #define ITASK_CMD_STATUS_DONE 0x3 3147836SJohn.Forte@Sun.COM #define ITASK_CMD_ABORT 0x4 3157836SJohn.Forte@Sun.COM #define ITASK_CMD_SEND_STATUS 0x5 3167836SJohn.Forte@Sun.COM #define ITASK_CMD_POLL 0x10 3177836SJohn.Forte@Sun.COM #define ITASK_CMD_POLL_LU (ITASK_CMD_POLL | 1) 3187836SJohn.Forte@Sun.COM #define ITASK_CMD_POLL_LPORT (ITASK_CMD_POLL | 2) 3197836SJohn.Forte@Sun.COM 3207836SJohn.Forte@Sun.COM /* 3217836SJohn.Forte@Sun.COM * struct maintained on a per itl basis when the lu registers ITL handle. 3227836SJohn.Forte@Sun.COM */ 3237836SJohn.Forte@Sun.COM typedef struct stmf_itl_data { 3247836SJohn.Forte@Sun.COM uint32_t itl_counter; 3257836SJohn.Forte@Sun.COM uint8_t itl_flags; 3267836SJohn.Forte@Sun.COM uint8_t itl_hdlrm_reason; 3277836SJohn.Forte@Sun.COM uint16_t itl_lun; 32811773STim.Szeto@Sun.COM char *itl_kstat_strbuf; 32911773STim.Szeto@Sun.COM int itl_kstat_strbuflen; 33011773STim.Szeto@Sun.COM kstat_t *itl_kstat_info; 33111773STim.Szeto@Sun.COM kstat_t *itl_kstat_taskq; 33211773STim.Szeto@Sun.COM kstat_t *itl_kstat_lu_xfer; 33311773STim.Szeto@Sun.COM kstat_t *itl_kstat_lport_xfer; 3347836SJohn.Forte@Sun.COM void *itl_handle; 33511773STim.Szeto@Sun.COM struct stmf_i_lu *itl_ilu; 3367836SJohn.Forte@Sun.COM struct stmf_i_scsi_session *itl_session; 3377836SJohn.Forte@Sun.COM struct stmf_itl_data *itl_next; 3387836SJohn.Forte@Sun.COM } stmf_itl_data_t; 3397836SJohn.Forte@Sun.COM 3407836SJohn.Forte@Sun.COM /* 3417836SJohn.Forte@Sun.COM * itl flags 3427836SJohn.Forte@Sun.COM */ 3437836SJohn.Forte@Sun.COM #define STMF_ITL_BEING_TERMINATED 0x01 3447836SJohn.Forte@Sun.COM 3457836SJohn.Forte@Sun.COM /* 3467836SJohn.Forte@Sun.COM * data structures to maintain provider private data. 3477836SJohn.Forte@Sun.COM */ 3487836SJohn.Forte@Sun.COM typedef struct stmf_pp_data { 3497836SJohn.Forte@Sun.COM struct stmf_pp_data *ppd_next; 3507836SJohn.Forte@Sun.COM void *ppd_provider; 3517836SJohn.Forte@Sun.COM nvlist_t *ppd_nv; 3527836SJohn.Forte@Sun.COM uint32_t ppd_lu_provider:1, 3537836SJohn.Forte@Sun.COM ppd_port_provider:1, 3547836SJohn.Forte@Sun.COM ppd_rsvd:30; 3557836SJohn.Forte@Sun.COM uint32_t ppd_alloc_size; 3569585STim.Szeto@Sun.COM uint64_t ppd_token; 3577836SJohn.Forte@Sun.COM char ppd_name[8]; 3587836SJohn.Forte@Sun.COM } stmf_pp_data_t; 3597836SJohn.Forte@Sun.COM 3607836SJohn.Forte@Sun.COM typedef struct stmf_worker { 3617836SJohn.Forte@Sun.COM kthread_t *worker_tid; 3627836SJohn.Forte@Sun.COM stmf_i_scsi_task_t *worker_task_head; 3637836SJohn.Forte@Sun.COM stmf_i_scsi_task_t *worker_task_tail; 3647836SJohn.Forte@Sun.COM stmf_i_scsi_task_t *worker_wait_head; 3657836SJohn.Forte@Sun.COM stmf_i_scsi_task_t *worker_wait_tail; 3667836SJohn.Forte@Sun.COM kmutex_t worker_lock; 3677836SJohn.Forte@Sun.COM kcondvar_t worker_cv; 3687836SJohn.Forte@Sun.COM uint32_t worker_flags; 3697836SJohn.Forte@Sun.COM uint32_t worker_queue_depth; /* ntasks cur queued */ 3707836SJohn.Forte@Sun.COM uint32_t worker_max_qdepth_pu; /* maxqd / unit time */ 3717836SJohn.Forte@Sun.COM uint32_t worker_max_sys_qdepth_pu; /* for all workers */ 3727836SJohn.Forte@Sun.COM uint32_t worker_ref_count; /* # IOs referencing */ 37311773STim.Szeto@Sun.COM hrtime_t worker_signal_timestamp; 3747836SJohn.Forte@Sun.COM } stmf_worker_t; 3757836SJohn.Forte@Sun.COM 3767836SJohn.Forte@Sun.COM /* 3777836SJohn.Forte@Sun.COM * worker flags 3787836SJohn.Forte@Sun.COM */ 3797836SJohn.Forte@Sun.COM #define STMF_WORKER_STARTED 1 3807836SJohn.Forte@Sun.COM #define STMF_WORKER_ACTIVE 2 3817836SJohn.Forte@Sun.COM #define STMF_WORKER_TERMINATE 4 3827836SJohn.Forte@Sun.COM 3837836SJohn.Forte@Sun.COM /* 3847836SJohn.Forte@Sun.COM * data struct for managing transfers. 3857836SJohn.Forte@Sun.COM */ 3867836SJohn.Forte@Sun.COM typedef struct stmf_xfer_data { 3877836SJohn.Forte@Sun.COM uint32_t alloc_size; /* Including this struct */ 3887836SJohn.Forte@Sun.COM uint32_t size_done; 3897836SJohn.Forte@Sun.COM uint32_t size_left; 3907836SJohn.Forte@Sun.COM uint8_t buf[4]; 3917836SJohn.Forte@Sun.COM } stmf_xfer_data_t; 3927836SJohn.Forte@Sun.COM 3937836SJohn.Forte@Sun.COM /* 3947836SJohn.Forte@Sun.COM * Define frequently used macros 3957836SJohn.Forte@Sun.COM */ 3967836SJohn.Forte@Sun.COM #define TASK_TO_ITASK(x_task) \ 3977836SJohn.Forte@Sun.COM ((stmf_i_scsi_task_t *)(x_task)->task_stmf_private) 3987836SJohn.Forte@Sun.COM 3997836SJohn.Forte@Sun.COM void stmf_dlun_init(); 4007836SJohn.Forte@Sun.COM stmf_status_t stmf_dlun_fini(); 4017836SJohn.Forte@Sun.COM void stmf_worker_init(); 4027836SJohn.Forte@Sun.COM stmf_status_t stmf_worker_fini(); 4037836SJohn.Forte@Sun.COM void stmf_task_free(scsi_task_t *task); 4047836SJohn.Forte@Sun.COM void stmf_do_task_abort(scsi_task_t *task); 4057836SJohn.Forte@Sun.COM void stmf_do_itl_dereg(stmf_lu_t *lu, stmf_itl_data_t *itl, 4067836SJohn.Forte@Sun.COM uint8_t hdlrm_reason); 4077836SJohn.Forte@Sun.COM void stmf_generate_lu_event(stmf_i_lu_t *ilu, int eventid, 4087836SJohn.Forte@Sun.COM void *arg, uint32_t flags); 4097836SJohn.Forte@Sun.COM void stmf_generate_lport_event(stmf_i_local_port_t *ilport, int eventid, 4107836SJohn.Forte@Sun.COM void *arg, uint32_t flags); 4117836SJohn.Forte@Sun.COM 4127836SJohn.Forte@Sun.COM #ifdef __cplusplus 4137836SJohn.Forte@Sun.COM } 4147836SJohn.Forte@Sun.COM #endif 4157836SJohn.Forte@Sun.COM 4167836SJohn.Forte@Sun.COM #endif /* _STMF_IMPL_H */ 417