1fcf3ce44SJohn Forte /* 2fcf3ce44SJohn Forte * CDDL HEADER START 3fcf3ce44SJohn Forte * 4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the 5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License"). 6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License. 7fcf3ce44SJohn Forte * 8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing. 10fcf3ce44SJohn Forte * See the License for the specific language governing permissions 11fcf3ce44SJohn Forte * and limitations under the License. 12fcf3ce44SJohn Forte * 13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each 14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the 16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying 17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner] 18fcf3ce44SJohn Forte * 19fcf3ce44SJohn Forte * CDDL HEADER END 20fcf3ce44SJohn Forte */ 21fcf3ce44SJohn Forte /* 22d42c7aecSReed * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23fcf3ce44SJohn Forte * Use is subject to license terms. 24fcf3ce44SJohn Forte */ 25fcf3ce44SJohn Forte 26fcf3ce44SJohn Forte #ifndef _FCPVAR_H 27fcf3ce44SJohn Forte #define _FCPVAR_H 28fcf3ce44SJohn Forte 29fcf3ce44SJohn Forte 30fcf3ce44SJohn Forte 31fcf3ce44SJohn Forte #ifdef __cplusplus 32fcf3ce44SJohn Forte extern "C" { 33fcf3ce44SJohn Forte #endif 34fcf3ce44SJohn Forte 35fcf3ce44SJohn Forte #include <sys/types.h> 36fcf3ce44SJohn Forte 37fcf3ce44SJohn Forte /* 38fcf3ce44SJohn Forte * Maximum number of times FCP will re-issue a REPORTS_LUNS command if the 39fcf3ce44SJohn Forte * device couldn't return all of them in the submitted buffer. 40fcf3ce44SJohn Forte */ 41fcf3ce44SJohn Forte #define FCP_MAX_REPORTLUNS_ATTEMPTS 2 42fcf3ce44SJohn Forte /* 43fcf3ce44SJohn Forte * Maximum number of LUNs supported. This limit is enforced to accommodate 44fcf3ce44SJohn Forte * certain HBAs. 45fcf3ce44SJohn Forte */ 46fcf3ce44SJohn Forte #define FCP_MAX_LUNS_SUPPORTED 65535 47fcf3ce44SJohn Forte 48fcf3ce44SJohn Forte /* 49fcf3ce44SJohn Forte * Stuff to be defined in fc_ulpif.h FIXIT 50fcf3ce44SJohn Forte */ 51fcf3ce44SJohn Forte #define PORT_DEVICE_CREATE 0x40 52fcf3ce44SJohn Forte #define SCMD_REPORT_LUN 0xa0 /* SCSI cmd to report on LUNs */ 53fcf3ce44SJohn Forte #define SCMD_INQUIRY_LWWN_SIZE 32 /* Max WWN size */ 54fcf3ce44SJohn Forte #define SCMD_INQUIRY_PAGE83 0xF0 /* Internal opcode for page 0x83 */ 55fcf3ce44SJohn Forte #define FC4_SCSI_FCP 0x08 /* our (SCSI) FC4 type number */ 56fcf3ce44SJohn Forte 57fcf3ce44SJohn Forte #define FCP_QUEUE_DELAY (4) 58fcf3ce44SJohn Forte #define FCP_FAILED_DELAY 20 59fcf3ce44SJohn Forte #define FCP_RESET_DELAY 3 /* target reset delay of 3 secs */ 60fcf3ce44SJohn Forte #define FCP_OFFLINE_DELAY 20 /* 20 seconds is 2*RA_TOV_els */ 61fcf3ce44SJohn Forte 62fcf3ce44SJohn Forte /* 63fcf3ce44SJohn Forte * Highest possible timeout value to indicate 64fcf3ce44SJohn Forte * the watch thread to return the I/O 65fcf3ce44SJohn Forte */ 66fcf3ce44SJohn Forte #define FCP_INVALID_TIMEOUT (0xFFFFFFFF) 67fcf3ce44SJohn Forte 68fcf3ce44SJohn Forte /* 69fcf3ce44SJohn Forte * The max inquiry page 83 size as expected in the code today 70fcf3ce44SJohn Forte * is 0xf0 bytes. Defining a constant to make it easy incase 71fcf3ce44SJohn Forte * this needs to be changed at a later time. 72fcf3ce44SJohn Forte */ 73fcf3ce44SJohn Forte #define SCMD_MAX_INQUIRY_PAGE83_SIZE 0xF0 74fcf3ce44SJohn Forte /* 75fcf3ce44SJohn Forte * Events generated for Target drivers; "SUNW,sf:" prefix 76fcf3ce44SJohn Forte * is a legacy fcal stuff hardcoded into ssd via the use of 77fcf3ce44SJohn Forte * FCAL_INSERT_EVENT defined in an fcal header file; We 78fcf3ce44SJohn Forte * just need to continue to use this. 79fcf3ce44SJohn Forte */ 80fcf3ce44SJohn Forte #define FCAL_INSERT_EVENT "SUNW,sf:DEVICE-INSERTION.1" 81fcf3ce44SJohn Forte #define FCAL_REMOVE_EVENT "SUNW,sf:DEVICE-REMOVAL.1" 82fcf3ce44SJohn Forte 83fcf3ce44SJohn Forte /* 84fcf3ce44SJohn Forte * for debug trace 85fcf3ce44SJohn Forte */ 86fcf3ce44SJohn Forte #define FCP_STACK_DEPTH 14 87fcf3ce44SJohn Forte 88fcf3ce44SJohn Forte 89fcf3ce44SJohn Forte /* 90fcf3ce44SJohn Forte * All the stuff above needs to move intp appropriate header files. 91fcf3ce44SJohn Forte */ 92fcf3ce44SJohn Forte 93fcf3ce44SJohn Forte #define FCP_NUM_HASH 128 94fcf3ce44SJohn Forte 95fcf3ce44SJohn Forte #define FCP_HASH(x) ((x[0] + x[1] + x[2] + x[3] +\ 96fcf3ce44SJohn Forte x[4] + x[5] + x[6] + x[7]) & \ 97fcf3ce44SJohn Forte (FCP_NUM_HASH-1)) 98fcf3ce44SJohn Forte 99fcf3ce44SJohn Forte #define FCP_STATEC_MASK (FC_STATE_OFFLINE | FC_STATE_ONLINE |\ 100fcf3ce44SJohn Forte FC_STATE_LOOP | FC_STATE_NAMESERVICE |\ 101fcf3ce44SJohn Forte FC_STATE_RESET |\ 102fcf3ce44SJohn Forte FC_STATE_RESET_REQUESTED |\ 103fcf3ce44SJohn Forte FC_STATE_LIP | FC_STATE_DEVICE_CHANGE) 104fcf3ce44SJohn Forte 105fcf3ce44SJohn Forte #define PKT_PRIV_SIZE 2 106fcf3ce44SJohn Forte 107fcf3ce44SJohn Forte #ifdef KSTATS_CODE 108fcf3ce44SJohn Forte /* 109fcf3ce44SJohn Forte * fcp_stats : Statistics provided for fcp. 110fcf3ce44SJohn Forte */ 111fcf3ce44SJohn Forte struct fcp_stats { 112d42c7aecSReed uint_t version; /* version of this struct */ 113d42c7aecSReed uint_t lip_count; /* lips forced by fcp */ 114d42c7aecSReed uint_t link_reset_count; /* lip failures, ie, no ONLINE */ 115fcf3ce44SJohn Forte /* response after forcing lip */ 116d42c7aecSReed uint_t ncmds; /* outstanding commands */ 117d42c7aecSReed uint_t throttle_limit; /* current throttle limit */ 118fcf3ce44SJohn Forte char drvr_name[MAXNAMELEN]; /* Name of driver, NULL term. */ 119fcf3ce44SJohn Forte }; 120fcf3ce44SJohn Forte #endif 121fcf3ce44SJohn Forte 122fcf3ce44SJohn Forte /* 123fcf3ce44SJohn Forte * Structure fcp_port 124fcf3ce44SJohn Forte * -------------------- 125fcf3ce44SJohn Forte * 126fcf3ce44SJohn Forte * This structure is the FCP representation of an N_Port on a local FC HBA card. 127fcf3ce44SJohn Forte * This is the master structure off of which all the others will be hanging at 128fcf3ce44SJohn Forte * some point and is the Solaris per-instance soft-state structure. 129fcf3ce44SJohn Forte */ 130fcf3ce44SJohn Forte struct fcp_port { 131fcf3ce44SJohn Forte /* 132fcf3ce44SJohn Forte * This mutex protects the access to this structure (or most of its 133fcf3ce44SJohn Forte * fields). 134fcf3ce44SJohn Forte */ 135fcf3ce44SJohn Forte kmutex_t port_mutex; 136fcf3ce44SJohn Forte /* 137fcf3ce44SJohn Forte * This is the link to the next fcp_port structure in the global 138fcf3ce44SJohn Forte * list. The head of the global list is fcp_port_head and is 139fcf3ce44SJohn Forte * defined in fcp.c. This field is NULL for the last element of 140fcf3ce44SJohn Forte * the global list. 141fcf3ce44SJohn Forte */ 142fcf3ce44SJohn Forte struct fcp_port *port_next; 143fcf3ce44SJohn Forte /* 144fcf3ce44SJohn Forte * This field points to the head of a list of internal requests that 145fcf3ce44SJohn Forte * will be retried later. Examples of internal requests are: 146fcf3ce44SJohn Forte * 'Send a PRLI ELS', 'Send a PRLO ELS', 'Send a PLOGI ELS' or 147fcf3ce44SJohn Forte * 'Send an Inquiry command'. If the submission of the request to the 148fcf3ce44SJohn Forte * fp/fctl module failed (for a set of specific reasons) and the 149d42c7aecSReed * request can be resubmitted later, it is queued here. The watchdog 150fcf3ce44SJohn Forte * timer (fcp_watch()) will walk this queue and resubmit the requests. 151fcf3ce44SJohn Forte */ 152fcf3ce44SJohn Forte struct fcp_ipkt *port_ipkt_list; 153fcf3ce44SJohn Forte /* 154fcf3ce44SJohn Forte * This seems to be used as a temporary device counter during a 155fcf3ce44SJohn Forte * discovery process (or reconfiguration as some comments put it). 156fcf3ce44SJohn Forte * It seems to be initialized in fcp_statec_callback() with the 157fcf3ce44SJohn Forte * number of devices that fp/fctl saw after the line came up and 158fcf3ce44SJohn Forte * is supposed to reached zero when the reconfiguration process is 159fcf3ce44SJohn Forte * over. 160fcf3ce44SJohn Forte */ 161fcf3ce44SJohn Forte int port_tmp_cnt; 162fcf3ce44SJohn Forte /* 163d42c7aecSReed * This is supposed to indicate the state of this port. It is a 164fcf3ce44SJohn Forte * bitmap which means several bits can be set simultaneously. The list 165fcf3ce44SJohn Forte * of the different bits and their meaning is given further down in 166fcf3ce44SJohn Forte * this file. 167fcf3ce44SJohn Forte */ 168fcf3ce44SJohn Forte uint32_t port_state; 169fcf3ce44SJohn Forte /* 170fcf3ce44SJohn Forte * This field is initialized at the very end of the function 171fcf3ce44SJohn Forte * fcp_handle_port_attach() if the attachment of the port was 172d42c7aecSReed * successful. It is set to the value stored in lbolt64 at the 173fcf3ce44SJohn Forte * time of the attachment. This value is only used in the function 174fcf3ce44SJohn Forte * fcp_scsi_bus_config(). It is used to determine the value of the 175fcf3ce44SJohn Forte * parameter timeout when ndi_busop_bus_config() and cv_wait() are 176fcf3ce44SJohn Forte * called. It actually serves to figure out how long the enumeration 177fcf3ce44SJohn Forte * can be delayed (the max value being FCP_INIT_WAIT_TIMEOUT). 178fcf3ce44SJohn Forte */ 179fcf3ce44SJohn Forte int64_t port_attach_time; 180fcf3ce44SJohn Forte /* 181fcf3ce44SJohn Forte * This field contains the topology of the SAN the port is connected 182fcf3ce44SJohn Forte * to. 183fcf3ce44SJohn Forte */ 184fcf3ce44SJohn Forte uint32_t port_topology; 185fcf3ce44SJohn Forte /* 186fcf3ce44SJohn Forte * This field contains the local port ID. It is provided by fp/fctl 187fcf3ce44SJohn Forte * when calling fcp_statec_callback() and fcp_port_attach(). This 188fcf3ce44SJohn Forte * value is used to build Fibre Channel headers (like for PLOGI or 189fcf3ce44SJohn Forte * PRLI). 190fcf3ce44SJohn Forte */ 191fcf3ce44SJohn Forte uint32_t port_id; 192fcf3ce44SJohn Forte /* 193fcf3ce44SJohn Forte * This field keeps track of the physical port state (fcp_port being 194fcf3ce44SJohn Forte * more like the FCP software port state). The information stored here 195fcf3ce44SJohn Forte * is provided by fp/fctl except in two instances: in 196fcf3ce44SJohn Forte * fcp_handle_port_attach() and fcp_handle_port_resume(). The values 197fcf3ce44SJohn Forte * this field can take are defined in fctl.h. 198fcf3ce44SJohn Forte */ 199fcf3ce44SJohn Forte uint32_t port_phys_state; 200fcf3ce44SJohn Forte /* 201fcf3ce44SJohn Forte * This field points to the first element of a list of fcp_reset_elem 202d42c7aecSReed * structures. Those structures are created when the target driver 203fcf3ce44SJohn Forte * calls fcp_reset_target(). The target or the LUN specified by the 204d42c7aecSReed * target driver is reset by sending a Task Management command. After 205fcf3ce44SJohn Forte * the response has been received, a fcp_reset_elem structure is 206fcf3ce44SJohn Forte * queued here and will remain queued for FCP_RESET_DELAY. While 207fcf3ce44SJohn Forte * the fcp_reset_elem structure is in this queue the LUNs of 208fcf3ce44SJohn Forte * the target to reset or the LUN to reset is set to LUN_BUSY state. 209fcf3ce44SJohn Forte * In fcp_watch() the timeout is tested. If the timout has expired, 210fcf3ce44SJohn Forte * the fcp_reset_elem structure is unqueued and freed, and all the 211fcf3ce44SJohn Forte * active commands for the target or LUNs are aborted. 212fcf3ce44SJohn Forte */ 213fcf3ce44SJohn Forte struct fcp_reset_elem *port_reset_list; 214fcf3ce44SJohn Forte /* 215fcf3ce44SJohn Forte * This points to the first element of a list of fcp_tgt_elem 216d42c7aecSReed * structures. This list is a list of targets to offline. The list 217fcf3ce44SJohn Forte * is walked in fcp_watch(). After the target is offlined the 218fcf3ce44SJohn Forte * structure fcp_tgt_elem is freed. 219fcf3ce44SJohn Forte */ 220fcf3ce44SJohn Forte struct fcp_tgt_elem *port_offline_tgts; 221fcf3ce44SJohn Forte /* 222fcf3ce44SJohn Forte * This points to the first element of a list of fcp_lun_elem 223d42c7aecSReed * structures. This list is a list of LUNs to offline. The list 224fcf3ce44SJohn Forte * is walked in fcp_watch(). After the lun is offlined the 225fcf3ce44SJohn Forte * structure fcp_lun_elem is freed. 226fcf3ce44SJohn Forte */ 227fcf3ce44SJohn Forte struct fcp_lun_elem *port_offline_luns; 228fcf3ce44SJohn Forte /* 229fcf3ce44SJohn Forte * This field is a counter initialized to 1 when the port attaches. 230fcf3ce44SJohn Forte * It is incremented when the line goes from online to offline and 231d42c7aecSReed * vice versa. It is also incremented when the port detaches. The 232fcf3ce44SJohn Forte * value stored in this counter is used as a reference in time of the 233d42c7aecSReed * link state. For example, when the line comes up internal requests 234fcf3ce44SJohn Forte * are generated (fcp_ipkt) such as PRLI and INQUIRY. Those requests 235fcf3ce44SJohn Forte * are tagged with the value contained in this field at the time the 236fcf3ce44SJohn Forte * request is built. When the callback for the request is called, the 237fcf3ce44SJohn Forte * current value of port_link_cnt is checked against the one set in 238fcf3ce44SJohn Forte * the internal request structure. If they don't match, it means the 239fcf3ce44SJohn Forte * the request is not relevant anymore to the current line state and 240fcf3ce44SJohn Forte * must be discarded (in between a request is issued and the callback 241fcf3ce44SJohn Forte * routine is called the line may have bounced). This is the way FCP 242fcf3ce44SJohn Forte * identifies the requests that were hanging out when the state of the 243fcf3ce44SJohn Forte * line changed. 244fcf3ce44SJohn Forte */ 245fcf3ce44SJohn Forte uint32_t port_link_cnt; 246fcf3ce44SJohn Forte /* 247fcf3ce44SJohn Forte * This field, as its name suggests, specifies a deadline for the 248fcf3ce44SJohn Forte * overall discovery process. It is initialized in three cases: 249fcf3ce44SJohn Forte * 250fcf3ce44SJohn Forte * 1) When the line goes from the offline state to the online state. 251fcf3ce44SJohn Forte * 2) When the FP/FCTL called fcp_statec_callback() indicating that 252fcf3ce44SJohn Forte * a notification was received from the fabric indicating that a new 253fcf3ce44SJohn Forte * port showed up or that one disappeared. 254fcf3ce44SJohn Forte * 3) In the fcp_create_on_demand() function (called because of an 255fcf3ce44SJohn Forte * ioctl). 256fcf3ce44SJohn Forte * 257fcf3ce44SJohn Forte * In all instances it is set to: 258fcf3ce44SJohn Forte * 259fcf3ce44SJohn Forte * fcp_watchdog_time + FCP_ICMD_DEADLINE 260fcf3ce44SJohn Forte * 261fcf3ce44SJohn Forte * In all those instances a discovery process is started or extended 262d42c7aecSReed * (2). The value stored in port_deadline is only checked in one 263fcf3ce44SJohn Forte * function: fcp_is_retryable(). That function checks if an 264fcf3ce44SJohn Forte * internal command (fcp_ipkt) is retryable or not. Usually 265fcf3ce44SJohn Forte * there's a counter that limits the number of times a command is 266fcf3ce44SJohn Forte * retried (Max value is FCP_MAX_RETRIES). However, even if the 267fcf3ce44SJohn Forte * counter hasn't exceeded that value, the command will not be retried 268fcf3ce44SJohn Forte * past the deadline. This means that the discovery process has to 269fcf3ce44SJohn Forte * be finished before port_deadline. In other words, an internal 270fcf3ce44SJohn Forte * command retry capability is limited numerically and in time. 271fcf3ce44SJohn Forte */ 272fcf3ce44SJohn Forte int port_deadline; 273fcf3ce44SJohn Forte /* 274fcf3ce44SJohn Forte * This is the Node WWN of the local port. It is initialized 275fcf3ce44SJohn Forte * during the port attachment. 276fcf3ce44SJohn Forte */ 277fcf3ce44SJohn Forte la_wwn_t port_nwwn; 278fcf3ce44SJohn Forte /* 279fcf3ce44SJohn Forte * This is the Port WWN of the local port. It is initialized during 280fcf3ce44SJohn Forte * the port attachment. 281fcf3ce44SJohn Forte */ 282fcf3ce44SJohn Forte la_wwn_t port_pwwn; 283fcf3ce44SJohn Forte /* 284fcf3ce44SJohn Forte * This is the fp/fctl port handle. 285fcf3ce44SJohn Forte */ 286fcf3ce44SJohn Forte opaque_t *port_fp_handle; 287fcf3ce44SJohn Forte /* 288fcf3ce44SJohn Forte * The following 4 fields handle the queue of fcp_pkt outstanding for 289fcf3ce44SJohn Forte * this port. 290fcf3ce44SJohn Forte * 291fcf3ce44SJohn Forte * port_pkt_mutex Protects the access to the queue 292fcf3ce44SJohn Forte * port_pkt_head Points to the head of the queue 293fcf3ce44SJohn Forte * port_pkt_tail Points to the tail of the queue 294fcf3ce44SJohn Forte * port_npkts Number of commands outstanding (used only when 295fcf3ce44SJohn Forte * DEBUG is defined). 296fcf3ce44SJohn Forte */ 297fcf3ce44SJohn Forte kmutex_t port_pkt_mutex; 298fcf3ce44SJohn Forte uint32_t port_npkts; 299fcf3ce44SJohn Forte struct fcp_pkt *port_pkt_head; 300fcf3ce44SJohn Forte struct fcp_pkt *port_pkt_tail; 301fcf3ce44SJohn Forte /* 302fcf3ce44SJohn Forte * This field is the counter of allocated and currently active 303fcf3ce44SJohn Forte * fcp_ipkt. 304fcf3ce44SJohn Forte */ 305fcf3ce44SJohn Forte int port_ipkt_cnt; 306fcf3ce44SJohn Forte /* 307fcf3ce44SJohn Forte * Port instance provided by FP/FCTL. It is actually deduced using 308fcf3ce44SJohn Forte * ddi_get_instance() in fcp_port_attach(). 309fcf3ce44SJohn Forte */ 310fcf3ce44SJohn Forte uint32_t port_instance; 311fcf3ce44SJohn Forte /* 312fcf3ce44SJohn Forte * Maximum number of exchanges the underlying physical FibreChannel 313fcf3ce44SJohn Forte * port can handle. This field is initialized during the port 314fcf3ce44SJohn Forte * attachment but is never used. 315fcf3ce44SJohn Forte */ 316fcf3ce44SJohn Forte uint32_t port_max_exch; 317fcf3ce44SJohn Forte /* 318fcf3ce44SJohn Forte * This port stores the behavior expected of the underlying FCA driver 319fcf3ce44SJohn Forte * when a port reset occurs. The values stored here are defined in the 320fcf3ce44SJohn Forte * file fc_types.h. 321fcf3ce44SJohn Forte */ 322fcf3ce44SJohn Forte fc_reset_action_t port_reset_action; 323fcf3ce44SJohn Forte /* 324fcf3ce44SJohn Forte * This port stores the DMA behavior of the underlying FCA driver. It 325fcf3ce44SJohn Forte * is checked only once in fcp_prepare_pkt() and, as the comment 326fcf3ce44SJohn Forte * suggests, to work around an issue with an Intel PCI bridge. 327fcf3ce44SJohn Forte */ 328fcf3ce44SJohn Forte fc_dma_behavior_t port_cmds_dma_flags; 329fcf3ce44SJohn Forte /* 330fcf3ce44SJohn Forte * The value stored here indicates if the underlying FCA driver 331fcf3ce44SJohn Forte * supports DMA transfers with non SCSI data (Ex: PRLI request). 332fcf3ce44SJohn Forte */ 333fcf3ce44SJohn Forte fc_fcp_dma_t port_fcp_dma; 334fcf3ce44SJohn Forte /* 335fcf3ce44SJohn Forte * This field contains the size of the private space required by the 336fcf3ce44SJohn Forte * underlying FCA driver in a FibreChannel packet (fc_packet_t). 337fcf3ce44SJohn Forte */ 338fcf3ce44SJohn Forte uint32_t port_priv_pkt_len; 339fcf3ce44SJohn Forte /* 340d42c7aecSReed * This field contains the port's modlink info. It is provided by 341fcf3ce44SJohn Forte * FP/FCTL during the port attachment. 342fcf3ce44SJohn Forte */ 343fcf3ce44SJohn Forte struct modlinkage port_fp_modlinkage; 344fcf3ce44SJohn Forte /* 345fcf3ce44SJohn Forte * DMA attributes for data packets, commands and responses. 346fcf3ce44SJohn Forte */ 347fcf3ce44SJohn Forte ddi_dma_attr_t port_data_dma_attr; 348fcf3ce44SJohn Forte ddi_dma_attr_t port_cmd_dma_attr; 349fcf3ce44SJohn Forte ddi_dma_attr_t port_resp_dma_attr; 350fcf3ce44SJohn Forte ddi_device_acc_attr_t port_dma_acc_attr; 351fcf3ce44SJohn Forte /* 352fcf3ce44SJohn Forte * Field containing the hba_tran structure registered with SCSA. 353fcf3ce44SJohn Forte */ 354d42c7aecSReed struct scsi_hba_tran *port_tran; 355fcf3ce44SJohn Forte /* 356fcf3ce44SJohn Forte * Device info structure provided by fp/fctl when the port attaches and 357fcf3ce44SJohn Forte * representing the local physical fibre channel port. 358fcf3ce44SJohn Forte */ 359fcf3ce44SJohn Forte dev_info_t *port_dip; 360fcf3ce44SJohn Forte /* 361fcf3ce44SJohn Forte * Head of the list of callback routines to call when a bus reset 362fcf3ce44SJohn Forte * occurs. This list is populated by the targets drivers by calling 363fcf3ce44SJohn Forte * fcp_scsi_reset_notify() (tran_reset_notify(9E)). 364fcf3ce44SJohn Forte */ 365fcf3ce44SJohn Forte struct scsi_reset_notify_entry *port_reset_notify_listf; 366fcf3ce44SJohn Forte /* 367fcf3ce44SJohn Forte * for framework event management 368fcf3ce44SJohn Forte */ 369fcf3ce44SJohn Forte ndi_event_definition_t *port_ndi_event_defs; 370fcf3ce44SJohn Forte ndi_event_hdl_t port_ndi_event_hdl; 371fcf3ce44SJohn Forte ndi_event_set_t port_ndi_events; 372fcf3ce44SJohn Forte /* 373d42c7aecSReed * hash lists of targets attached to this port. The hashing is based 374fcf3ce44SJohn Forte * on the WWN. 375fcf3ce44SJohn Forte */ 376fcf3ce44SJohn Forte struct fcp_tgt *port_tgt_hash_table[FCP_NUM_HASH]; 377fcf3ce44SJohn Forte /* 378fcf3ce44SJohn Forte * per-Port control flag. By default mpxio is enabled on ports unless 379fcf3ce44SJohn Forte * explicitly disabled through driver.conf. 380fcf3ce44SJohn Forte */ 381fcf3ce44SJohn Forte int port_mpxio; 382fcf3ce44SJohn Forte /* 383fcf3ce44SJohn Forte * Value used as a flag to determine if the throttling has been 384fcf3ce44SJohn Forte * set/initialized in the FCA driver. 385fcf3ce44SJohn Forte */ 386fcf3ce44SJohn Forte int port_notify; 387fcf3ce44SJohn Forte /* 388fcf3ce44SJohn Forte * This field contains a string initialized at attachment time and used 389fcf3ce44SJohn Forte * when calling the function the function fc_trace_debug() (through 390fcf3ce44SJohn Forte * the macro FCP_TRACE and FCP_DTRACE) to identify the port that 391fcf3ce44SJohn Forte * logged the message. 392fcf3ce44SJohn Forte */ 393fcf3ce44SJohn Forte char port_instbuf[24]; 394fcf3ce44SJohn Forte uchar_t port_boot_wwn[FC_WWN_SIZE]; 395fcf3ce44SJohn Forte 396fcf3ce44SJohn Forte #ifdef DEBUG 397fcf3ce44SJohn Forte /* 398fcf3ce44SJohn Forte * Use once in fcp_finish_init() when calling getpcstack(). 399fcf3ce44SJohn Forte */ 400fcf3ce44SJohn Forte int port_finish_depth; 401fcf3ce44SJohn Forte pc_t port_finish_stack[FCP_STACK_DEPTH]; 402fcf3ce44SJohn Forte #endif /* DEBUG */ 403fcf3ce44SJohn Forte /* 404fcf3ce44SJohn Forte * Condition variable used during the bus enumeration process. 405fcf3ce44SJohn Forte */ 406fcf3ce44SJohn Forte kcondvar_t port_config_cv; 407fcf3ce44SJohn Forte /* 408fcf3ce44SJohn Forte * Size (in bytes) required to hold the cookies of a scatter/gather 409fcf3ce44SJohn Forte * list. 410fcf3ce44SJohn Forte */ 411fcf3ce44SJohn Forte int port_dmacookie_sz; 412fcf3ce44SJohn Forte }; 413fcf3ce44SJohn Forte 414fcf3ce44SJohn Forte /* 415fcf3ce44SJohn Forte * We need to save the target change count values in a map tag so as 416fcf3ce44SJohn Forte * to uniquely identify the cause and handle it better as they change 417fcf3ce44SJohn Forte * counts are bound to change upon receiving more state changes. 418fcf3ce44SJohn Forte */ 419fcf3ce44SJohn Forte typedef int fcp_map_tag_t; 420fcf3ce44SJohn Forte 421fcf3ce44SJohn Forte /* 422fcf3ce44SJohn Forte * fcp_state definitions. 423fcf3ce44SJohn Forte */ 424fcf3ce44SJohn Forte #define FCP_STATE_INIT 0x0001 425fcf3ce44SJohn Forte #define FCP_STATE_OFFLINE 0x0002 426fcf3ce44SJohn Forte #define FCP_STATE_ONLINE 0x0004 427fcf3ce44SJohn Forte #define FCP_STATE_SUSPENDED 0x0008 428fcf3ce44SJohn Forte #define FCP_STATE_POWER_DOWN 0x0010 429fcf3ce44SJohn Forte #define FCP_STATE_ONLINING 0x0020 430fcf3ce44SJohn Forte #define FCP_STATE_DETACHING 0x0040 431fcf3ce44SJohn Forte #define FCP_STATE_IN_WATCHDOG 0x0080 432fcf3ce44SJohn Forte #define FCP_STATE_IN_MDI 0x0100 /* Not in S8/S9 */ 433fcf3ce44SJohn Forte #define FCP_STATE_NS_REG_FAILED 0x0200 /* Diff value from S8/S9 */ 434fcf3ce44SJohn Forte /* 435fcf3ce44SJohn Forte * FCP_STATE_IN_CB_DEVC indicates that we're handling a state change 436fcf3ce44SJohn Forte * notification that will be changing the state of devices. This is an 437fcf3ce44SJohn Forte * indication to fcp_scsi_start that the target's status might change. 438fcf3ce44SJohn Forte */ 439fcf3ce44SJohn Forte #define FCP_STATE_IN_CB_DEVC 0x0400 440fcf3ce44SJohn Forte 441fcf3ce44SJohn Forte #define FCP_MAX_DEVICES 127 442fcf3ce44SJohn Forte 443fcf3ce44SJohn Forte /* To remember that dip was allocated for a lun on this target. */ 444fcf3ce44SJohn Forte 445fcf3ce44SJohn Forte #define FCP_DEVICE_CREATED 0x1 446fcf3ce44SJohn Forte 447fcf3ce44SJohn Forte #define FCP_EVENT_TAG_INSERT 0 448fcf3ce44SJohn Forte #define FCP_EVENT_TAG_REMOVE 1 449fcf3ce44SJohn Forte 450fcf3ce44SJohn Forte /* 451fcf3ce44SJohn Forte * fcp_pkt: FCP packet 452fcf3ce44SJohn Forte * --------------------- 453fcf3ce44SJohn Forte * 454fcf3ce44SJohn Forte * This structure is the one initialized/created in the tran_init_pkt(9E). It 455fcf3ce44SJohn Forte * embeds the fc_packet structure eventually passed to fp/fctl as well as 456fcf3ce44SJohn Forte * the scsi_pkt returned by tran_init_pkt(9E) to the target driver. There is 457fcf3ce44SJohn Forte * a 1-to-1 correlation between the scsi_pkt, the fcp_pkt and the 458fcf3ce44SJohn Forte * fc_packet. 459fcf3ce44SJohn Forte * 460fcf3ce44SJohn Forte * This is what a fcp_pkt looks like after allocation: 461fcf3ce44SJohn Forte * 462d42c7aecSReed * +================================+ 463d42c7aecSReed * +---> | struct scsi_pkt | 464d42c7aecSReed * | | | 465d42c7aecSReed * | +--- | pkt_ha_private | 466d42c7aecSReed * | | | | 467d42c7aecSReed * | | +================================+ 468d42c7aecSReed * | | 469d42c7aecSReed * | | +================================+ 470d42c7aecSReed * | +--> | struct fcp_pkt | <---------+ 471d42c7aecSReed * +----- | cmd_pkt | | 472d42c7aecSReed * | cmd_fp_pkt | ---+ | 473d42c7aecSReed * +--------->| cmd_fcp_rsp[] | | | 474d42c7aecSReed * | +------->| cmd_fcp_cmd[] | | | 475d42c7aecSReed * | | |--------------------------------| | | 476d42c7aecSReed * | | | struct fc_packet | <--+ | 477d42c7aecSReed * | | | | | 478d42c7aecSReed * | | | pkt_ulp_private | ----------+ 479d42c7aecSReed * | | | pkt_fca_private | -----+ 480d42c7aecSReed * | | | pkt_data_cookie | ---+ | 481d42c7aecSReed * | | | pkt_cmdlen | | | 482d42c7aecSReed * | |(a) | pkt_rsplen | | | 483d42c7aecSReed * | +--------| .......... pkt_cmd ........... | ---|-|-------+ 484d42c7aecSReed * | (a) | pkt_cmd_cookie | ---|-|-----+ | 485d42c7aecSReed * +----------| .......... pkt_resp .......... | ---|-|---+ | | 486d42c7aecSReed * | pkt_resp_cookie | ---|-|-+ | | | 487d42c7aecSReed * | pkt_cmd_dma | | | | | | | 488d42c7aecSReed * | pkt_cmd_acc | | | | | | | 489d42c7aecSReed * +================================+ | | | | | | 490d42c7aecSReed * | dma_cookies | <--+ | | | | | 491d42c7aecSReed * | | | | | | | 492d42c7aecSReed * +================================+ | | | | | 493d42c7aecSReed * | fca_private | <----+ | | | | 494d42c7aecSReed * | | | | | | 495d42c7aecSReed * +================================+ | | | | 496d42c7aecSReed * | | | | 497d42c7aecSReed * | | | | 498d42c7aecSReed * +================================+ (b) | | | | 499d42c7aecSReed * | fcp_resp cookies | <------+ | | | 500d42c7aecSReed * | | | | | 501d42c7aecSReed * +================================+ | | | 502d42c7aecSReed * | | | 503d42c7aecSReed * +================================+ (b) | | | 504d42c7aecSReed * | fcp_resp | <--------+ | | 505d42c7aecSReed * | (DMA resources associated) | | | 506d42c7aecSReed * +================================+ | | 507d42c7aecSReed * | | 508d42c7aecSReed * | | 509d42c7aecSReed * | | 510d42c7aecSReed * +================================+ (b) | | 511d42c7aecSReed * | fcp_cmd cookies | <----------+ | 512d42c7aecSReed * | | | 513d42c7aecSReed * +================================+ | 514d42c7aecSReed * | 515d42c7aecSReed * +================================+ (b) | 516d42c7aecSReed * | fcp_cmd | <------------+ 517d42c7aecSReed * | (DMA resources associated) | 518d42c7aecSReed * +================================+ 519fcf3ce44SJohn Forte * 520fcf3ce44SJohn Forte * 521d42c7aecSReed * (a) The underlying FCA does NOT support DMA for this field 522d42c7aecSReed * (b) The underlying FCA supports DMA for this field 523fcf3ce44SJohn Forte */ 524fcf3ce44SJohn Forte struct fcp_pkt { 525fcf3ce44SJohn Forte /* 526fcf3ce44SJohn Forte * The two following fields are used to queue fcp_pkt in the double 527fcf3ce44SJohn Forte * link list of the lun structure. The packet is queued in 528fcf3ce44SJohn Forte * tran_init_pkt(9E) and unqueued in tran_destroy_pkt(9E). 529fcf3ce44SJohn Forte */ 530fcf3ce44SJohn Forte struct fcp_pkt *cmd_forw; 531fcf3ce44SJohn Forte struct fcp_pkt *cmd_back; 532fcf3ce44SJohn Forte /* 533fcf3ce44SJohn Forte * This field is used to queue the packet in the single link list of the 534fcf3ce44SJohn Forte * port structure. The port keeps a list of all the commands issued 535fcf3ce44SJohn Forte * through it and scans it, for example, when all of those commands 536fcf3ce44SJohn Forte * have to be aborted. 537fcf3ce44SJohn Forte */ 538fcf3ce44SJohn Forte struct fcp_pkt *cmd_next; 539fcf3ce44SJohn Forte /* 540fcf3ce44SJohn Forte * This field points back to the scsi_pkt. 541fcf3ce44SJohn Forte */ 542fcf3ce44SJohn Forte struct scsi_pkt *cmd_pkt; 543fcf3ce44SJohn Forte /* 544fcf3ce44SJohn Forte * This field points to the field cmd_fc_packet defined further in this 545fcf3ce44SJohn Forte * same structure. 546fcf3ce44SJohn Forte */ 547fcf3ce44SJohn Forte struct fc_packet *cmd_fp_pkt; 548fcf3ce44SJohn Forte /* 549fcf3ce44SJohn Forte * Structure where the FCP_CMD information unit is going to be built. 550fcf3ce44SJohn Forte */ 551fcf3ce44SJohn Forte fcp_cmd_t cmd_fcp_cmd; 552fcf3ce44SJohn Forte /* 553d42c7aecSReed * State of the packet. The values for the state seem to indicate 554fcf3ce44SJohn Forte * that it isn't a bitmap. However, in several instances the code 555fcf3ce44SJohn Forte * treats it as a bitmap doing a "&= ~FCP_PKT_ISSUED" to it 556fcf3ce44SJohn Forte * eventhough the value stored is always checked using "!=" and "==". 557fcf3ce44SJohn Forte */ 558fcf3ce44SJohn Forte uint_t cmd_state; 559fcf3ce44SJohn Forte /* 560fcf3ce44SJohn Forte * This field is a bitmap indicating if 561fcf3ce44SJohn Forte * the cmd is queued 562fcf3ce44SJohn Forte */ 563fcf3ce44SJohn Forte uint_t cmd_flags; 564fcf3ce44SJohn Forte /* Contains the number of bytes DMA mappped. */ 565fcf3ce44SJohn Forte uint_t cmd_dmacount; 566fcf3ce44SJohn Forte /* 567fcf3ce44SJohn Forte * Contains the timeout value for the packet. This is not a delay or 568fcf3ce44SJohn Forte * a delta but an absolute value. 569fcf3ce44SJohn Forte */ 570fcf3ce44SJohn Forte uint_t cmd_timeout; 571fcf3ce44SJohn Forte /* 572fcf3ce44SJohn Forte * This array is used to store the FCP_RSP information unit returned by 573fcf3ce44SJohn Forte * the device when the underlying FCA cannot DMA it in. 574fcf3ce44SJohn Forte */ 575fcf3ce44SJohn Forte char cmd_fcp_rsp[FCP_MAX_RSP_IU_SIZE]; 576fcf3ce44SJohn Forte /* 577fcf3ce44SJohn Forte * This is the fc_packet structure used to forward the request to 578fcf3ce44SJohn Forte * fp/fctl. 579fcf3ce44SJohn Forte */ 580fcf3ce44SJohn Forte struct fc_packet cmd_fc_packet; 581fcf3ce44SJohn Forte }; 582fcf3ce44SJohn Forte 583fcf3ce44SJohn Forte /* 584fcf3ce44SJohn Forte * fcp_ipkt : Packet for internal commands. 585fcf3ce44SJohn Forte * ------------------------------------------ 586fcf3ce44SJohn Forte * 587d42c7aecSReed * +================================+ 588d42c7aecSReed * | struct fcp_ipkt | <---------+ 589d42c7aecSReed * | (kmem_zalloc()) | | 590d42c7aecSReed * | ipkt_fpkt | ---+ | 591d42c7aecSReed * | | | | 592d42c7aecSReed * | ipkt_cmdlen = cmd_len | | | 593d42c7aecSReed * | | | | 594d42c7aecSReed * | | | | 595d42c7aecSReed * | | | | 596d42c7aecSReed * |--------------------------------| | | 597d42c7aecSReed * | struct fc_packet | <--+ | 598d42c7aecSReed * | | | 599d42c7aecSReed * | pkt_ulp_private | ----------+ 600d42c7aecSReed * | pkt_fca_private | -----+ 601d42c7aecSReed * | pkt_data_cookie | ---+ | 602d42c7aecSReed * | pkt_cmdlen | | | 603d42c7aecSReed * | pkt_rsplen | | | 604d42c7aecSReed * | pkt_cmd ...................... | ---|-|-------+ 605d42c7aecSReed * | pkt_cmd_cookie | ---|-|-----+ | 606d42c7aecSReed * | pkt_resp ..................... | ---|-|---+ | | 607d42c7aecSReed * | pkt_resp_cookie | ---|-|-+ | | | 608d42c7aecSReed * | pkt_cmd_dma | | | | | | | 609d42c7aecSReed * | pkt_cmd_acc | | | | | | | 610d42c7aecSReed * +================================+ | | | | | | 611d42c7aecSReed * | dma_cookies | <--+ | | | | | 612d42c7aecSReed * | | | | | | | 613d42c7aecSReed * | | | | | | | 614d42c7aecSReed * | | | | | | | 615d42c7aecSReed * +================================+ | | | | | 616d42c7aecSReed * | fca_private | <----+ | | | | 617d42c7aecSReed * | | | | | | 618d42c7aecSReed * | | | | | | 619d42c7aecSReed * | | | | | | 620d42c7aecSReed * +================================+ | | | | 621d42c7aecSReed * | | | | 622d42c7aecSReed * | | | | 623d42c7aecSReed * +================================+ (b) | | | | 624d42c7aecSReed * | fcp_resp cookies | <------+ | | | 625d42c7aecSReed * | | | | | 626d42c7aecSReed * +================================+ | | | 627d42c7aecSReed * | | | 628d42c7aecSReed * +================================+ (b) | | | 629d42c7aecSReed * | fcp_resp | <--------+ | | 630d42c7aecSReed * | (DMA resources associated) | | | 631d42c7aecSReed * +================================+ | | 632d42c7aecSReed * | | 633d42c7aecSReed * | | 634d42c7aecSReed * | | 635d42c7aecSReed * +================================+ (b) | | 636d42c7aecSReed * | fcp_cmd cookies | <----------+ | 637d42c7aecSReed * | | | 638d42c7aecSReed * +================================+ | 639d42c7aecSReed * | 640d42c7aecSReed * +================================+ (b) | 641d42c7aecSReed * | fcp_cmd | <------------+ 642d42c7aecSReed * | (DMA resources associated) | 643d42c7aecSReed * +================================+ 644fcf3ce44SJohn Forte * 645d42c7aecSReed * (a) The underlying FCA does NOT support DMA for this field 646d42c7aecSReed * (b) The underlying FCA supports DMA for this field 647fcf3ce44SJohn Forte */ 648fcf3ce44SJohn Forte struct fcp_ipkt { 649fcf3ce44SJohn Forte /* 650fcf3ce44SJohn Forte * Pointer to the port (fcp_port) in behalf of which this internal 651fcf3ce44SJohn Forte * packet was allocated. 652fcf3ce44SJohn Forte */ 653fcf3ce44SJohn Forte struct fcp_port *ipkt_port; 654fcf3ce44SJohn Forte /* 655fcf3ce44SJohn Forte * Pointer to the target (fcp_tgt) in behalf of which this internal 656fcf3ce44SJohn Forte * packet was allocated. 657fcf3ce44SJohn Forte */ 658fcf3ce44SJohn Forte struct fcp_tgt *ipkt_tgt; 659fcf3ce44SJohn Forte /* 660fcf3ce44SJohn Forte * Pointer to the lun (fcp_lun) in behalf of which this internal 661fcf3ce44SJohn Forte * packet was allocated. This field is only meaningful when the 662fcf3ce44SJohn Forte * internal packet has been allocated for a "scsi passthru" command or 663fcf3ce44SJohn Forte * for an internal SCSI command such as REPORT LUNs and INQUIRY. 664fcf3ce44SJohn Forte */ 665fcf3ce44SJohn Forte struct fcp_lun *ipkt_lun; 666fcf3ce44SJohn Forte /* 667fcf3ce44SJohn Forte * Fields used to queue the internal packet into the double linked list 668fcf3ce44SJohn Forte * of the FCP port (fcp_port). 669fcf3ce44SJohn Forte */ 670fcf3ce44SJohn Forte struct fcp_ipkt *ipkt_next; 671fcf3ce44SJohn Forte struct fcp_ipkt *ipkt_prev; 672fcf3ce44SJohn Forte /* 673fcf3ce44SJohn Forte * This field points to the field ipkt_fc_packet defined farther in 674fcf3ce44SJohn Forte * this same structure. 675fcf3ce44SJohn Forte */ 676fcf3ce44SJohn Forte struct fc_packet *ipkt_fpkt; 677fcf3ce44SJohn Forte /* 678fcf3ce44SJohn Forte * This is the timeout value for the internal packet. It seems to 679d42c7aecSReed * increase with the number of retries. It is initialized like this 680fcf3ce44SJohn Forte * in the code: 681fcf3ce44SJohn Forte * 682fcf3ce44SJohn Forte * icmd->ipkt_restart = fcp_watchdog_time + icmd->ipkt_retries++ 683fcf3ce44SJohn Forte * 684fcf3ce44SJohn Forte * First time ipkt_retries is zero. As it increases, the timeout 685fcf3ce44SJohn Forte * value for the internal packet also increases. 686fcf3ce44SJohn Forte */ 687fcf3ce44SJohn Forte uint32_t ipkt_restart; 688fcf3ce44SJohn Forte /* 689fcf3ce44SJohn Forte * Link state counter when the internal packet was built. 690fcf3ce44SJohn Forte */ 691fcf3ce44SJohn Forte uint32_t ipkt_link_cnt; 692fcf3ce44SJohn Forte int ipkt_cause; 693fcf3ce44SJohn Forte uint32_t ipkt_cmdlen; 694fcf3ce44SJohn Forte uint32_t ipkt_resplen; 695fcf3ce44SJohn Forte uint32_t ipkt_datalen; 696fcf3ce44SJohn Forte /* 697fcf3ce44SJohn Forte * Counter of the times an internal packet has been retried. Its 698fcf3ce44SJohn Forte * value is checked against FCP_MAX_RETRIES. 699fcf3ce44SJohn Forte */ 700fcf3ce44SJohn Forte uint32_t ipkt_retries; 701fcf3ce44SJohn Forte uint32_t ipkt_change_cnt; 702fcf3ce44SJohn Forte int ipkt_nodma; 703fcf3ce44SJohn Forte /* 704fcf3ce44SJohn Forte * Semaphore used to wait for completion on. 705fcf3ce44SJohn Forte */ 706fcf3ce44SJohn Forte ksema_t ipkt_sema; 707fcf3ce44SJohn Forte /* 708fcf3ce44SJohn Forte * Opcode indicating what internal command the packet contains (PLOGI, 709fcf3ce44SJohn Forte * PRLI, INQUIRY...). 710fcf3ce44SJohn Forte */ 711fcf3ce44SJohn Forte uchar_t ipkt_opcode; 712fcf3ce44SJohn Forte /* 713fcf3ce44SJohn Forte * FC packet. 714fcf3ce44SJohn Forte */ 715fcf3ce44SJohn Forte struct fc_packet ipkt_fc_packet; 716fcf3ce44SJohn Forte }; 717fcf3ce44SJohn Forte 718fcf3ce44SJohn Forte /* 719fcf3ce44SJohn Forte * cmd_state definitions 720fcf3ce44SJohn Forte */ 721fcf3ce44SJohn Forte #define FCP_PKT_IDLE 0x1 722fcf3ce44SJohn Forte #define FCP_PKT_ISSUED 0x2 723fcf3ce44SJohn Forte #define FCP_PKT_ABORTING 0x3 724fcf3ce44SJohn Forte 725fcf3ce44SJohn Forte /* 726fcf3ce44SJohn Forte * These are the defined cmd_flags for this structure. 727fcf3ce44SJohn Forte */ 728fcf3ce44SJohn Forte #define CFLAG_IN_QUEUE 0x2000 /* command in fcp queue */ 729fcf3ce44SJohn Forte 730fcf3ce44SJohn Forte /* 731fcf3ce44SJohn Forte * Target structure 732fcf3ce44SJohn Forte * ---------------- 733fcf3ce44SJohn Forte * 734fcf3ce44SJohn Forte * This structure holds the information relative to a SCSI target. This 735fcf3ce44SJohn Forte * structure doesn't represent the object registered with the OS (NDI or 736fcf3ce44SJohn Forte * MPxIO...). 737fcf3ce44SJohn Forte */ 738fcf3ce44SJohn Forte struct fcp_tgt { 739fcf3ce44SJohn Forte /* 740fcf3ce44SJohn Forte * This field is used to queue the target structure in one of the 741fcf3ce44SJohn Forte * buckets of the fcp_port target hash table port_tgt_hash_table[]. 742fcf3ce44SJohn Forte */ 743fcf3ce44SJohn Forte struct fcp_tgt *tgt_next; 744fcf3ce44SJohn Forte /* Points to the fcp_port the target belongs to. */ 745fcf3ce44SJohn Forte struct fcp_port *tgt_port; 746fcf3ce44SJohn Forte /* 747fcf3ce44SJohn Forte * This field is a bitmap indicating the state of the target. Several 748fcf3ce44SJohn Forte * bits can be set simultaneously. 749fcf3ce44SJohn Forte */ 750fcf3ce44SJohn Forte uint32_t tgt_state; 751fcf3ce44SJohn Forte /* 752fcf3ce44SJohn Forte * State controlling if the LUNs attached to this target will be 753fcf3ce44SJohn Forte * automatically onlined or not. 754fcf3ce44SJohn Forte */ 755fcf3ce44SJohn Forte uint32_t tgt_node_state; 756fcf3ce44SJohn Forte /* 757fcf3ce44SJohn Forte * Mutex protecting this structure. 758fcf3ce44SJohn Forte */ 759fcf3ce44SJohn Forte kmutex_t tgt_mutex; 760fcf3ce44SJohn Forte /* 761fcf3ce44SJohn Forte * List of LUNs (single link list). 762fcf3ce44SJohn Forte */ 763fcf3ce44SJohn Forte struct fcp_lun *tgt_lun; 764fcf3ce44SJohn Forte opaque_t tgt_fca_dev; 765fcf3ce44SJohn Forte /* 766fcf3ce44SJohn Forte * Number of LUNs in this target. 767fcf3ce44SJohn Forte */ 768fcf3ce44SJohn Forte uint_t tgt_lun_cnt; 769fcf3ce44SJohn Forte /* 770fcf3ce44SJohn Forte * Counter of LUNs to probe. It is used during the discovery 771fcf3ce44SJohn Forte * process. Starts with the number of LUNs returned by REPORT_LUN 772fcf3ce44SJohn Forte * and is decremented until it reaches zero. 773fcf3ce44SJohn Forte */ 774fcf3ce44SJohn Forte uint_t tgt_tmp_cnt; 775fcf3ce44SJohn Forte /* 776fcf3ce44SJohn Forte * fp/fctl handle for the "port_device". 777fcf3ce44SJohn Forte */ 778fcf3ce44SJohn Forte opaque_t tgt_pd_handle; 779fcf3ce44SJohn Forte /* 780fcf3ce44SJohn Forte * Node World Wide Name. 781fcf3ce44SJohn Forte */ 782fcf3ce44SJohn Forte la_wwn_t tgt_node_wwn; 783fcf3ce44SJohn Forte /* 784fcf3ce44SJohn Forte * Port World Wide Name. 785fcf3ce44SJohn Forte */ 786fcf3ce44SJohn Forte la_wwn_t tgt_port_wwn; 787fcf3ce44SJohn Forte /* 788fcf3ce44SJohn Forte * Fibre Channel Port ID. 789fcf3ce44SJohn Forte */ 790fcf3ce44SJohn Forte uint32_t tgt_d_id; 791fcf3ce44SJohn Forte /* 792fcf3ce44SJohn Forte * Fibre Channel Port ID. Uses bit fields to represent it. 793fcf3ce44SJohn Forte */ 794fcf3ce44SJohn Forte uint32_t tgt_hard_addr; 795fcf3ce44SJohn Forte /* 796fcf3ce44SJohn Forte * Becomes 1 when the LUNs are created. 797fcf3ce44SJohn Forte */ 798fcf3ce44SJohn Forte uchar_t tgt_device_created; 799fcf3ce44SJohn Forte /* 800fcf3ce44SJohn Forte * Counter of how many REPORT_LUN commands were sent. It is used to 801fcf3ce44SJohn Forte * allow the REPORT_LUN command to be sent twice in case the buffer 802fcf3ce44SJohn Forte * allocated the first time wasn't big enough. 803fcf3ce44SJohn Forte */ 804fcf3ce44SJohn Forte uchar_t tgt_report_lun_cnt; 805fcf3ce44SJohn Forte /* 806fcf3ce44SJohn Forte * This field is incremented each time the field tgt_state is updated. 807fcf3ce44SJohn Forte * Its use is similar to the use of the field port_link_cnt in the 808d42c7aecSReed * fcp_port structure. The internal packets are, for example, tagged 809fcf3ce44SJohn Forte * with the value stored here. 810fcf3ce44SJohn Forte */ 811fcf3ce44SJohn Forte uint32_t tgt_change_cnt; 812fcf3ce44SJohn Forte /* 813fcf3ce44SJohn Forte * This field contains the cause of the last change in state. 814fcf3ce44SJohn Forte */ 815fcf3ce44SJohn Forte int tgt_statec_cause; 816fcf3ce44SJohn Forte /* 817fcf3ce44SJohn Forte * The following two fields indicate whether the remote port is an 818fcf3ce44SJohn Forte * FCP initiator or an FCP target. They are treated as booleans. 819fcf3ce44SJohn Forte */ 820fcf3ce44SJohn Forte uchar_t tgt_icap; /* Initiator */ 821fcf3ce44SJohn Forte uchar_t tgt_tcap; /* Target */ 822fcf3ce44SJohn Forte #ifdef DEBUG 823fcf3ce44SJohn Forte /* 824fcf3ce44SJohn Forte * Updated in fcp_call_finish_init_held() when DEBUG is defined 825fcf3ce44SJohn Forte */ 826fcf3ce44SJohn Forte int tgt_tmp_cnt_depth; 827fcf3ce44SJohn Forte pc_t tgt_tmp_cnt_stack[FCP_STACK_DEPTH]; 828fcf3ce44SJohn Forte #endif /* DEBUG */ 829fcf3ce44SJohn Forte /* 830fcf3ce44SJohn Forte * This field holds the timer id of the timer started when a LUN 831fcf3ce44SJohn Forte * reconfiguration is needed for the target. The reconfiguration 832fcf3ce44SJohn Forte * is done in the timeout function. 833fcf3ce44SJohn Forte */ 834fcf3ce44SJohn Forte timeout_id_t tgt_tid; 835fcf3ce44SJohn Forte int tgt_done; 836fcf3ce44SJohn Forte /* 837fcf3ce44SJohn Forte * Bitmap used to trace the discovery process. 838fcf3ce44SJohn Forte */ 839fcf3ce44SJohn Forte uint32_t tgt_trace; 840fcf3ce44SJohn Forte /* 841fcf3ce44SJohn Forte * This field is used when the code is sorting out which devices 842fcf3ce44SJohn Forte * were known which ones are new and which ones went away. 843fcf3ce44SJohn Forte */ 844fcf3ce44SJohn Forte uint32_t tgt_aux_state; 845fcf3ce44SJohn Forte /* 846fcf3ce44SJohn Forte * Number of internal packets allocated in behalf of the target. 847fcf3ce44SJohn Forte */ 848fcf3ce44SJohn Forte int tgt_ipkt_cnt; 849fcf3ce44SJohn Forte /* 850fcf3ce44SJohn Forte * used to detect user unconfig when auto configuration is enabled. 851fcf3ce44SJohn Forte */ 852fcf3ce44SJohn Forte uint32_t tgt_manual_config_only; 853fcf3ce44SJohn Forte }; 854fcf3ce44SJohn Forte 855fcf3ce44SJohn Forte /* 856fcf3ce44SJohn Forte * Target States 857fcf3ce44SJohn Forte */ 858fcf3ce44SJohn Forte #define FCP_TGT_INIT 0x01 859fcf3ce44SJohn Forte #define FCP_TGT_BUSY 0x02 860fcf3ce44SJohn Forte #define FCP_TGT_MARK 0x04 861fcf3ce44SJohn Forte #define FCP_TGT_OFFLINE 0x08 862fcf3ce44SJohn Forte #define FCP_TGT_ORPHAN 0x80 863fcf3ce44SJohn Forte #define FCP_TGT_ILLREQ 0x10 864fcf3ce44SJohn Forte 865fcf3ce44SJohn Forte /* 866fcf3ce44SJohn Forte * Target Aux Stat 867fcf3ce44SJohn Forte */ 868fcf3ce44SJohn Forte #define FCP_TGT_TAGGED 0x01 869fcf3ce44SJohn Forte 870fcf3ce44SJohn Forte /* 871fcf3ce44SJohn Forte * Target discovery tracing 872fcf3ce44SJohn Forte */ 873fcf3ce44SJohn Forte #define FCP_TGT_TRACE_1 0x00000001 874fcf3ce44SJohn Forte #define FCP_TGT_TRACE_2 0x00000002 875fcf3ce44SJohn Forte #define FCP_TGT_TRACE_3 0x00000004 876fcf3ce44SJohn Forte #define FCP_TGT_TRACE_4 0x00000008 877fcf3ce44SJohn Forte #define FCP_TGT_TRACE_5 0x00000010 878fcf3ce44SJohn Forte #define FCP_TGT_TRACE_6 0x00000020 879fcf3ce44SJohn Forte #define FCP_TGT_TRACE_7 0x00000040 880fcf3ce44SJohn Forte #define FCP_TGT_TRACE_8 0x00000080 881fcf3ce44SJohn Forte #define FCP_TGT_TRACE_9 0x00000100 882fcf3ce44SJohn Forte #define FCP_TGT_TRACE_10 0x00000200 883fcf3ce44SJohn Forte #define FCP_TGT_TRACE_11 0x00000400 884fcf3ce44SJohn Forte #define FCP_TGT_TRACE_12 0x00000800 885fcf3ce44SJohn Forte #define FCP_TGT_TRACE_13 0x00001000 886fcf3ce44SJohn Forte #define FCP_TGT_TRACE_14 0x00002000 887fcf3ce44SJohn Forte #define FCP_TGT_TRACE_15 0x00004000 888fcf3ce44SJohn Forte #define FCP_TGT_TRACE_16 0x00008000 889fcf3ce44SJohn Forte #define FCP_TGT_TRACE_17 0x00010000 890fcf3ce44SJohn Forte #define FCP_TGT_TRACE_18 0x00020000 891fcf3ce44SJohn Forte #define FCP_TGT_TRACE_19 0x00040000 892fcf3ce44SJohn Forte #define FCP_TGT_TRACE_20 0x00080000 893fcf3ce44SJohn Forte #define FCP_TGT_TRACE_21 0x00100000 894fcf3ce44SJohn Forte #define FCP_TGT_TRACE_22 0x00200000 895fcf3ce44SJohn Forte #define FCP_TGT_TRACE_23 0x00400000 896fcf3ce44SJohn Forte #define FCP_TGT_TRACE_24 0x00800000 897fcf3ce44SJohn Forte #define FCP_TGT_TRACE_25 0x01000000 898fcf3ce44SJohn Forte #define FCP_TGT_TRACE_26 0x02000000 899fcf3ce44SJohn Forte #define FCP_TGT_TRACE_27 0x04000000 900fcf3ce44SJohn Forte #define FCP_TGT_TRACE_28 0x08000000 901fcf3ce44SJohn Forte #define FCP_TGT_TRACE_29 0x10000000 902fcf3ce44SJohn Forte 903fcf3ce44SJohn Forte #ifndef __lock_lint 904fcf3ce44SJohn Forte 905fcf3ce44SJohn Forte #define FCP_TGT_TRACE(ptgt, tcount, bit) {\ 906fcf3ce44SJohn Forte if (ptgt) {\ 907fcf3ce44SJohn Forte if (ptgt->tgt_change_cnt == tcount) {\ 908fcf3ce44SJohn Forte ptgt->tgt_trace |= bit;\ 909fcf3ce44SJohn Forte }\ 910fcf3ce44SJohn Forte }\ 911fcf3ce44SJohn Forte } 912fcf3ce44SJohn Forte 913fcf3ce44SJohn Forte #else /* __lock_lint */ 914fcf3ce44SJohn Forte 915fcf3ce44SJohn Forte #define FCP_TGT_TRACE(ptgt, tcount, bit) 916fcf3ce44SJohn Forte 917fcf3ce44SJohn Forte #endif /* __lock_lint */ 918fcf3ce44SJohn Forte 919fcf3ce44SJohn Forte 920fcf3ce44SJohn Forte /* 921fcf3ce44SJohn Forte * state change cause 922fcf3ce44SJohn Forte */ 923fcf3ce44SJohn Forte #define FCP_CAUSE_TGT_CHANGE 0x01 924fcf3ce44SJohn Forte #define FCP_CAUSE_LINK_CHANGE 0x02 925fcf3ce44SJohn Forte #define FCP_CAUSE_LINK_DOWN 0x04 926fcf3ce44SJohn Forte #define FCP_CAUSE_USER_CREATE 0x08 927fcf3ce44SJohn Forte 928fcf3ce44SJohn Forte 929fcf3ce44SJohn Forte /* 930fcf3ce44SJohn Forte * Target node states (applicable to LUNs behind the target) 931fcf3ce44SJohn Forte */ 932fcf3ce44SJohn Forte #define FCP_TGT_NODE_NONE 0x00 /* No node exists */ 933fcf3ce44SJohn Forte #define FCP_TGT_NODE_ON_DEMAND 0x01 /* create only upon request */ 934fcf3ce44SJohn Forte #define FCP_TGT_NODE_PRESENT 0x02 /* Node exists; rediscover it */ 935fcf3ce44SJohn Forte 936fcf3ce44SJohn Forte 937fcf3ce44SJohn Forte #define FCP_NO_CHANGE 0x1 938fcf3ce44SJohn Forte #define FCP_LINK_CHANGE 0x2 939fcf3ce44SJohn Forte #define FCP_DEV_CHANGE 0x3 940fcf3ce44SJohn Forte 941fcf3ce44SJohn Forte 942fcf3ce44SJohn Forte /* hotplug event struct */ 943fcf3ce44SJohn Forte struct fcp_hp_event { 944fcf3ce44SJohn Forte int (*callback)(); 945fcf3ce44SJohn Forte void *arg; 946fcf3ce44SJohn Forte }; 947fcf3ce44SJohn Forte 948fcf3ce44SJohn Forte /* 949fcf3ce44SJohn Forte * We talk to both NDI and MDI framework to enumerate our child devices. 950fcf3ce44SJohn Forte * We internally define a generic child handle and assign either dev_info 951fcf3ce44SJohn Forte * or mdi_pathinfo handle depending on the device. 952fcf3ce44SJohn Forte */ 953fcf3ce44SJohn Forte typedef void *child_info_t; 954fcf3ce44SJohn Forte 955fcf3ce44SJohn Forte #define CIP(child) ((child_info_t *)(child)) 956fcf3ce44SJohn Forte #define DIP(child) ((dev_info_t *)(child)) 957fcf3ce44SJohn Forte #define PIP(child) ((mdi_pathinfo_t *)(child)) 958fcf3ce44SJohn Forte 959fcf3ce44SJohn Forte /* 960fcf3ce44SJohn Forte * LUN structure 961fcf3ce44SJohn Forte * ------------- 962fcf3ce44SJohn Forte * 963d42c7aecSReed * This structure holds the information relative to a SCSI LUN. This 964fcf3ce44SJohn Forte * structure is the one representing the object registered with the OS (NDI 965fcf3ce44SJohn Forte * or MPxIO...). 966fcf3ce44SJohn Forte */ 967fcf3ce44SJohn Forte struct fcp_lun { 968fcf3ce44SJohn Forte /* 969fcf3ce44SJohn Forte * Mutex protecting the access to this structure. 970fcf3ce44SJohn Forte */ 971fcf3ce44SJohn Forte kmutex_t lun_mutex; 972fcf3ce44SJohn Forte /* 973d42c7aecSReed * Logical unit number. It is a SCSI3 format. 974fcf3ce44SJohn Forte */ 975fcf3ce44SJohn Forte fcp_ent_addr_t lun_addr; 976fcf3ce44SJohn Forte /* 977fcf3ce44SJohn Forte * The two following fields are respectively the head and tail of a 978fcf3ce44SJohn Forte * double link list of fcp_packets. It is populated in 979fcf3ce44SJohn Forte * tran_init_pkt(9E) (fcp_scsi_init_pkt) and emptied in 980fcf3ce44SJohn Forte * tran_destroy_pkt(9E) (fcp_scsi_destroy_pkt). 981fcf3ce44SJohn Forte */ 982fcf3ce44SJohn Forte struct fcp_pkt *lun_pkt_head; 983fcf3ce44SJohn Forte struct fcp_pkt *lun_pkt_tail; 984fcf3ce44SJohn Forte /* 985d42c7aecSReed * This field is treated like a union. It may contain the dev_info_t 986fcf3ce44SJohn Forte * or the mdi_pathinfo_t depending on how the device associated with 987fcf3ce44SJohn Forte * this LUN was registered. 988fcf3ce44SJohn Forte */ 989fcf3ce44SJohn Forte child_info_t *lun_cip; 990fcf3ce44SJohn Forte /* 991fcf3ce44SJohn Forte * Online/Offline event count. 992fcf3ce44SJohn Forte */ 993fcf3ce44SJohn Forte int lun_event_count; 994fcf3ce44SJohn Forte /* 995fcf3ce44SJohn Forte * Back pointer to the target the LUN belongs to. 996fcf3ce44SJohn Forte */ 997fcf3ce44SJohn Forte struct fcp_tgt *lun_tgt; 998fcf3ce44SJohn Forte /* 999fcf3ce44SJohn Forte * Bit map reflecting the state of the LUN. 1000fcf3ce44SJohn Forte */ 1001fcf3ce44SJohn Forte uint_t lun_state; 1002fcf3ce44SJohn Forte /* 1003fcf3ce44SJohn Forte * LUN type (disk, tape...). The value stored here is taken from the 1004fcf3ce44SJohn Forte * inquiry data. 1005fcf3ce44SJohn Forte */ 1006fcf3ce44SJohn Forte uchar_t lun_type; 1007fcf3ce44SJohn Forte /* 1008fcf3ce44SJohn Forte * This field is incremented each time fcp_scsi_tgt_init() 1009fcf3ce44SJohn Forte * (tran_tgt_init(9E)) is called and decremented each time 1010fcf3ce44SJohn Forte * fcp_scsi_tgt_free() (tran_tgt_free(9E)) is called. The 1011fcf3ce44SJohn Forte * incrementation and decrementation will also have an effect on 1012fcf3ce44SJohn Forte * lun_state bit FCP_SCSI_LUN_TGT_INIT. 1013fcf3ce44SJohn Forte */ 1014fcf3ce44SJohn Forte uchar_t lun_tgt_count; 1015fcf3ce44SJohn Forte /* 1016fcf3ce44SJohn Forte * LUN number as it is returned by REPORT_LUNS. 1017fcf3ce44SJohn Forte */ 1018fcf3ce44SJohn Forte uint16_t lun_num; 1019fcf3ce44SJohn Forte /* 1020fcf3ce44SJohn Forte * Pointer to the next LUN. 1021fcf3ce44SJohn Forte */ 1022fcf3ce44SJohn Forte struct fcp_lun *lun_next; 1023fcf3ce44SJohn Forte /* 1024*63251bc7SReed * lun level association with scsi_device 1025fcf3ce44SJohn Forte */ 1026*63251bc7SReed struct scsi_device *lun_sd; 1027fcf3ce44SJohn Forte /* 1028fcf3ce44SJohn Forte * per-Lun control flag. A value of '1' means the LUN is managed by 1029fcf3ce44SJohn Forte * mpxio. A value of '0' means the LUN has been physically enumerated 1030fcf3ce44SJohn Forte * as a child of corresponding port driver node. 1031fcf3ce44SJohn Forte */ 1032fcf3ce44SJohn Forte int lun_mpxio; 1033fcf3ce44SJohn Forte /* 1034fcf3ce44SJohn Forte * Length of the GUID. 1035fcf3ce44SJohn Forte */ 1036fcf3ce44SJohn Forte size_t lun_guid_size; 1037fcf3ce44SJohn Forte /* 1038fcf3ce44SJohn Forte * Pointer to a buffer that contains the GUID. 1039fcf3ce44SJohn Forte */ 1040fcf3ce44SJohn Forte char *lun_guid; 1041fcf3ce44SJohn Forte /* 1042fcf3ce44SJohn Forte * Pointer to a buffer that contains the old GUID. 1043fcf3ce44SJohn Forte */ 1044fcf3ce44SJohn Forte char *lun_old_guid; 1045fcf3ce44SJohn Forte /* 1046fcf3ce44SJohn Forte * Length of the old GUID 1047fcf3ce44SJohn Forte */ 1048fcf3ce44SJohn Forte size_t lun_old_guid_size; 1049fcf3ce44SJohn Forte /* 1050fcf3ce44SJohn Forte * Bitmap used to track the LUN discovery process. 1051fcf3ce44SJohn Forte */ 1052fcf3ce44SJohn Forte uint32_t lun_trace; 1053fcf3ce44SJohn Forte /* 1054fcf3ce44SJohn Forte * Bitmap representing the SCSI capabilities. 1055fcf3ce44SJohn Forte */ 1056fcf3ce44SJohn Forte uchar_t lun_cap; 1057fcf3ce44SJohn Forte /* 1058fcf3ce44SJohn Forte * LUN inquiry data (as returned by the INQUIRY command). 1059fcf3ce44SJohn Forte */ 1060fcf3ce44SJohn Forte struct scsi_inquiry lun_inq; 1061fcf3ce44SJohn Forte }; 1062fcf3ce44SJohn Forte 1063fcf3ce44SJohn Forte 1064fcf3ce44SJohn Forte /* 1065fcf3ce44SJohn Forte * Lun discovery tracing 1066fcf3ce44SJohn Forte */ 1067fcf3ce44SJohn Forte #define FCP_LUN_TRACE_1 0x0000001 1068fcf3ce44SJohn Forte #define FCP_LUN_TRACE_2 0x0000002 1069fcf3ce44SJohn Forte #define FCP_LUN_TRACE_3 0x0000004 1070fcf3ce44SJohn Forte #define FCP_LUN_TRACE_4 0x0000008 1071fcf3ce44SJohn Forte #define FCP_LUN_TRACE_5 0x0000010 1072fcf3ce44SJohn Forte #define FCP_LUN_TRACE_6 0x0000020 1073fcf3ce44SJohn Forte #define FCP_LUN_TRACE_7 0x0000040 1074fcf3ce44SJohn Forte #define FCP_LUN_TRACE_8 0x0000080 1075fcf3ce44SJohn Forte #define FCP_LUN_TRACE_9 0x0000100 1076fcf3ce44SJohn Forte #define FCP_LUN_TRACE_10 0x0000200 1077fcf3ce44SJohn Forte #define FCP_LUN_TRACE_11 0x0000400 1078fcf3ce44SJohn Forte #define FCP_LUN_TRACE_12 0x0000800 1079fcf3ce44SJohn Forte #define FCP_LUN_TRACE_13 0x0001000 1080fcf3ce44SJohn Forte #define FCP_LUN_TRACE_14 0x0002000 1081fcf3ce44SJohn Forte #define FCP_LUN_TRACE_15 0x0004000 1082fcf3ce44SJohn Forte #define FCP_LUN_TRACE_16 0x0008000 1083fcf3ce44SJohn Forte #define FCP_LUN_TRACE_17 0x0010000 1084fcf3ce44SJohn Forte #define FCP_LUN_TRACE_18 0x0020000 1085fcf3ce44SJohn Forte #define FCP_LUN_TRACE_19 0x0040000 1086fcf3ce44SJohn Forte #define FCP_LUN_TRACE_20 0x0080000 1087fcf3ce44SJohn Forte #define FCP_LUN_TRACE_21 0x0100000 1088fcf3ce44SJohn Forte #define FCP_LUN_TRACE_22 0x0200000 1089fcf3ce44SJohn Forte #define FCP_LUN_TRACE_23 0x0400000 1090fcf3ce44SJohn Forte #define FCP_LUN_TRACE_24 0x0800000 1091fcf3ce44SJohn Forte #define FCP_LUN_TRACE_25 0x1000000 1092fcf3ce44SJohn Forte #define FCP_LUN_TRACE_26 0x2000000 1093fcf3ce44SJohn Forte #define FCP_LUN_TRACE_27 0x4000000 1094fcf3ce44SJohn Forte #define FCP_LUN_TRACE_28 0x8000000 1095fcf3ce44SJohn Forte 1096fcf3ce44SJohn Forte 1097fcf3ce44SJohn Forte #define FCP_LUN_TRACE(plun, bit) {\ 1098fcf3ce44SJohn Forte if (plun && plun->lun_tgt) {\ 1099fcf3ce44SJohn Forte mutex_enter(&plun->lun_tgt->tgt_mutex);\ 1100fcf3ce44SJohn Forte plun->lun_trace |= bit;\ 1101fcf3ce44SJohn Forte mutex_exit(&plun->lun_tgt->tgt_mutex);\ 1102fcf3ce44SJohn Forte }\ 1103fcf3ce44SJohn Forte } 1104fcf3ce44SJohn Forte 1105fcf3ce44SJohn Forte #define FCP_LUN_CAP_RESET 0x01 1106fcf3ce44SJohn Forte 1107fcf3ce44SJohn Forte /* 1108fcf3ce44SJohn Forte * Lun State -- these have the same values as the target states so 1109fcf3ce44SJohn Forte * that they can be interchanged (in cases where the same state occurs 1110fcf3ce44SJohn Forte * for both targets and luns) 1111fcf3ce44SJohn Forte */ 1112fcf3ce44SJohn Forte 1113fcf3ce44SJohn Forte #define FCP_LUN_INIT FCP_TGT_INIT 1114fcf3ce44SJohn Forte #define FCP_LUN_BUSY FCP_TGT_BUSY 1115fcf3ce44SJohn Forte #define FCP_LUN_MARK FCP_TGT_MARK 1116fcf3ce44SJohn Forte #define FCP_LUN_OFFLINE FCP_TGT_OFFLINE 1117fcf3ce44SJohn Forte #define FCP_SCSI_LUN_TGT_INIT 0x20 /* target/LUNs all inited */ 1118fcf3ce44SJohn Forte #define FCP_LUN_DISAPPEARED 0x40 1119fcf3ce44SJohn Forte /* 1120fcf3ce44SJohn Forte * Use the below flag with caution as it is can cause a delay in 1121fcf3ce44SJohn Forte * fcp_scsi_start() which is in the normal I/O performance path 1122fcf3ce44SJohn Forte */ 1123fcf3ce44SJohn Forte #define FCP_LUN_ONLINING 0x80 1124fcf3ce44SJohn Forte /* 1125fcf3ce44SJohn Forte * Set the below flag when the DTYPE or GUID of a LUN changes during discovery 1126fcf3ce44SJohn Forte */ 1127fcf3ce44SJohn Forte #define FCP_LUN_CHANGED 0x100 1128fcf3ce44SJohn Forte /* 1129fcf3ce44SJohn Forte * This flag is used specifically for the special lun: lun 0. 1130fcf3ce44SJohn Forte */ 1131fcf3ce44SJohn Forte #define FCP_LUN_DEVICE_NOT_CONNECTED 0x200 1132fcf3ce44SJohn Forte 1133fcf3ce44SJohn Forte /* 1134fcf3ce44SJohn Forte * Report Lun Format 1135fcf3ce44SJohn Forte */ 1136fcf3ce44SJohn Forte struct fcp_reportlun_resp { 1137fcf3ce44SJohn Forte uint32_t num_lun; /* num LUNs * 8 */ 1138fcf3ce44SJohn Forte uint32_t reserved; 1139fcf3ce44SJohn Forte longlong_t lun_string[1]; 1140fcf3ce44SJohn Forte }; 1141fcf3ce44SJohn Forte 1142fcf3ce44SJohn Forte /* 1143fcf3ce44SJohn Forte * This structure actually represents a request executed by the hot plug task. 1144fcf3ce44SJohn Forte */ 1145fcf3ce44SJohn Forte struct fcp_hp_elem { 1146fcf3ce44SJohn Forte /* 1147fcf3ce44SJohn Forte * FCP port concerned by the request. 1148fcf3ce44SJohn Forte */ 1149fcf3ce44SJohn Forte struct fcp_port *port; 1150fcf3ce44SJohn Forte /* 1151fcf3ce44SJohn Forte * LUN concerned by the request. 1152fcf3ce44SJohn Forte */ 1153fcf3ce44SJohn Forte struct fcp_lun *lun; 1154fcf3ce44SJohn Forte /* 1155fcf3ce44SJohn Forte * dev_info_t or mdi_pathinfo_t pointer. 1156fcf3ce44SJohn Forte */ 1157fcf3ce44SJohn Forte child_info_t *cip; 1158d42c7aecSReed /* 1159d42c7aecSReed * lun_mpxio when the event is submitted 1160d42c7aecSReed */ 1161d42c7aecSReed int old_lun_mpxio; 1162fcf3ce44SJohn Forte /* 1163fcf3ce44SJohn Forte * What to do (offline, online...). 1164fcf3ce44SJohn Forte */ 1165d42c7aecSReed int what; 1166fcf3ce44SJohn Forte /* 1167fcf3ce44SJohn Forte * FLags used when calling NDI fucntions. 1168fcf3ce44SJohn Forte */ 1169d42c7aecSReed int flags; 1170fcf3ce44SJohn Forte /* 1171fcf3ce44SJohn Forte * Link state change count when the structure was created. 1172fcf3ce44SJohn Forte */ 1173fcf3ce44SJohn Forte int link_cnt; 1174fcf3ce44SJohn Forte /* 1175fcf3ce44SJohn Forte * Target state change count when the structure was created. 1176fcf3ce44SJohn Forte */ 1177fcf3ce44SJohn Forte int tgt_cnt; 1178fcf3ce44SJohn Forte /* 1179fcf3ce44SJohn Forte * Online/Offline count when this event was queued. 1180fcf3ce44SJohn Forte */ 1181fcf3ce44SJohn Forte int event_cnt; 1182fcf3ce44SJohn Forte /* 1183fcf3ce44SJohn Forte * This is the flag protected by the mutex and condition variable 1184fcf3ce44SJohn Forte * defined further in this structure. It is the flag indicating 1185fcf3ce44SJohn Forte * that the hot plug task is done with the treatment of the structure. 1186fcf3ce44SJohn Forte */ 1187fcf3ce44SJohn Forte int wait; 1188fcf3ce44SJohn Forte /* 1189fcf3ce44SJohn Forte * This is where the result of the request is returned when the sender 1190fcf3ce44SJohn Forte * waits for the completion. 1191fcf3ce44SJohn Forte */ 1192fcf3ce44SJohn Forte int result; 1193fcf3ce44SJohn Forte /* 1194fcf3ce44SJohn Forte * Condition variable used when wait is true. 1195fcf3ce44SJohn Forte */ 1196fcf3ce44SJohn Forte kcondvar_t cv; 1197fcf3ce44SJohn Forte /* 1198fcf3ce44SJohn Forte * Mutex used in conjunction with the previous condition variable. 1199fcf3ce44SJohn Forte */ 1200fcf3ce44SJohn Forte kmutex_t mutex; 1201fcf3ce44SJohn Forte }; 1202fcf3ce44SJohn Forte 1203fcf3ce44SJohn Forte 1204fcf3ce44SJohn Forte struct fcp_reset_elem { 1205fcf3ce44SJohn Forte struct fcp_reset_elem *next; 1206fcf3ce44SJohn Forte struct fcp_tgt *tgt; 1207fcf3ce44SJohn Forte struct fcp_lun *lun; 1208fcf3ce44SJohn Forte clock_t timeout; 1209fcf3ce44SJohn Forte uint_t tgt_cnt; 1210fcf3ce44SJohn Forte }; 1211fcf3ce44SJohn Forte 1212fcf3ce44SJohn Forte /* 1213fcf3ce44SJohn Forte * This structure is used to offline targets. It is queued in the FCP port 1214fcf3ce44SJohn Forte * structure single linked list port_offline_tgts and walked by the watchdog 1215fcf3ce44SJohn Forte * timer. 1216fcf3ce44SJohn Forte */ 1217fcf3ce44SJohn Forte struct fcp_tgt_elem { 1218fcf3ce44SJohn Forte /* 1219fcf3ce44SJohn Forte * Points to the next element of the list. 1220fcf3ce44SJohn Forte */ 1221fcf3ce44SJohn Forte struct fcp_tgt_elem *next; 1222fcf3ce44SJohn Forte /* 1223fcf3ce44SJohn Forte * Points to the target to offline. 1224fcf3ce44SJohn Forte */ 1225fcf3ce44SJohn Forte struct fcp_tgt *ptgt; 1226fcf3ce44SJohn Forte /* 1227fcf3ce44SJohn Forte * Absolute time after which the target must be offlined. 1228fcf3ce44SJohn Forte */ 1229fcf3ce44SJohn Forte int time; 1230fcf3ce44SJohn Forte /* 1231fcf3ce44SJohn Forte * Link state change count when the structure was created. 1232fcf3ce44SJohn Forte */ 1233fcf3ce44SJohn Forte int link_cnt; 1234fcf3ce44SJohn Forte /* 1235fcf3ce44SJohn Forte * Target state change count when the structure was created. 1236fcf3ce44SJohn Forte */ 1237fcf3ce44SJohn Forte int tgt_cnt; 1238fcf3ce44SJohn Forte /* 1239fcf3ce44SJohn Forte * Flags providing information for the offline (when calling mdi or 1240fcf3ce44SJohn Forte * ndi). 1241fcf3ce44SJohn Forte */ 1242fcf3ce44SJohn Forte int flags; 1243fcf3ce44SJohn Forte }; 1244fcf3ce44SJohn Forte 1245fcf3ce44SJohn Forte /* 1246fcf3ce44SJohn Forte * This structure is used to offline LUNs. It is queued in the FCP port 1247fcf3ce44SJohn Forte * structure single linked list port_offline_luns and walked by the watchdog 1248fcf3ce44SJohn Forte * timer. 1249fcf3ce44SJohn Forte */ 1250fcf3ce44SJohn Forte struct fcp_lun_elem { 1251fcf3ce44SJohn Forte /* 1252fcf3ce44SJohn Forte * Points to the next element of the list. 1253fcf3ce44SJohn Forte */ 1254fcf3ce44SJohn Forte struct fcp_lun_elem *next; 1255fcf3ce44SJohn Forte /* 1256fcf3ce44SJohn Forte * Points to the LUN to offline. 1257fcf3ce44SJohn Forte */ 1258fcf3ce44SJohn Forte struct fcp_lun *plun; 1259fcf3ce44SJohn Forte /* 1260fcf3ce44SJohn Forte * Absolute time after which the LUN must be offlined. 1261fcf3ce44SJohn Forte */ 1262fcf3ce44SJohn Forte int time; 1263fcf3ce44SJohn Forte /* 1264fcf3ce44SJohn Forte * Link state change count when the structure was created. 1265fcf3ce44SJohn Forte */ 1266fcf3ce44SJohn Forte int link_cnt; 1267fcf3ce44SJohn Forte /* 1268fcf3ce44SJohn Forte * Target state change count when the structure was created. 1269fcf3ce44SJohn Forte */ 1270fcf3ce44SJohn Forte int tgt_cnt; 1271fcf3ce44SJohn Forte /* 1272fcf3ce44SJohn Forte * Flags providing information for the offline (when calling mdi or 1273fcf3ce44SJohn Forte * ndi). 1274fcf3ce44SJohn Forte */ 1275fcf3ce44SJohn Forte int flags; 1276fcf3ce44SJohn Forte }; 1277fcf3ce44SJohn Forte 1278fcf3ce44SJohn Forte /* 1279fcf3ce44SJohn Forte * LUN masking 1280fcf3ce44SJohn Forte */ 1281fcf3ce44SJohn Forte typedef struct fcp_black_list_entry { 1282fcf3ce44SJohn Forte /* 1283fcf3ce44SJohn Forte * Points to the next element of the list. 1284fcf3ce44SJohn Forte */ 1285fcf3ce44SJohn Forte struct fcp_black_list_entry *next; 1286fcf3ce44SJohn Forte /* 1287fcf3ce44SJohn Forte * Port WWN of the target. 1288fcf3ce44SJohn Forte */ 1289fcf3ce44SJohn Forte la_wwn_t wwn; 1290fcf3ce44SJohn Forte /* 1291fcf3ce44SJohn Forte * LUN number which need to be masked. 1292fcf3ce44SJohn Forte */ 1293fcf3ce44SJohn Forte uint32_t lun; 1294fcf3ce44SJohn Forte /* 1295fcf3ce44SJohn Forte * Counter of access times. 1296fcf3ce44SJohn Forte */ 1297fcf3ce44SJohn Forte int masked; 1298fcf3ce44SJohn Forte } fcp_black_list_entry_t; 1299fcf3ce44SJohn Forte 130053a7b6b6SChris Horne #define ADDR2FCP(ap) ((struct fcp_port *) \ 130153a7b6b6SChris Horne ((ap)->a_hba_tran->tran_hba_private)) 130253a7b6b6SChris Horne #define ADDR2LUN(ap) ((struct fcp_lun *) \ 130353a7b6b6SChris Horne scsi_device_hba_private_get(scsi_address_device(ap))) 1304fcf3ce44SJohn Forte #define CMD2PKT(cmd) ((cmd)->cmd_pkt) 130553a7b6b6SChris Horne #define PKT2CMD(pkt) ((struct fcp_pkt *)((pkt)->pkt_ha_private)) 1306fcf3ce44SJohn Forte 1307fcf3ce44SJohn Forte /* 1308fcf3ce44SJohn Forte * timeout values 1309fcf3ce44SJohn Forte */ 1310d42c7aecSReed #define FCP_ELS_TIMEOUT 20 /* 20 seconds */ 1311fcf3ce44SJohn Forte #define FCP_SCSI_CMD_TIMEOUT 25 /* 30 seconds */ 1312fcf3ce44SJohn Forte #define FCP_POLL_TIMEOUT 60 /* 60 seconds */ 1313fcf3ce44SJohn Forte #define FCP_TIMEOUT_DELTA 2 /* 2 seconds */ 1314fcf3ce44SJohn Forte #define FCP_ICMD_DEADLINE 120 /* 60 seconds */ 1315fcf3ce44SJohn Forte #define FCP_MAX_RETRIES 4 1316fcf3ce44SJohn Forte 1317fcf3ce44SJohn Forte 1318fcf3ce44SJohn Forte #if !defined(__lint) 1319fcf3ce44SJohn Forte _NOTE(MUTEX_PROTECTS_DATA(fcp_port::port_mutex, 1320fcf3ce44SJohn Forte fcp_port::port_state fcp_tgt::tgt_change_cnt 1321fcf3ce44SJohn Forte fcp_port::fcp_next fcp_port::port_tgt_hash_table 1322fcf3ce44SJohn Forte fcp_port::port_link_cnt fcp_port::port_reset_list 1323fcf3ce44SJohn Forte fcp_port::port_tmp_cnt fcp_port::port_ipkt_list 1324fcf3ce44SJohn Forte fcp_tgt::tgt_next)) 1325fcf3ce44SJohn Forte 1326fcf3ce44SJohn Forte _NOTE(MUTEX_PROTECTS_DATA(fcp_port::port_pkt_mutex, 1327fcf3ce44SJohn Forte fcp_port::port_pkt_head fcp_port::port_pkt_tail 1328fcf3ce44SJohn Forte fcp_port::port_npkts)) 1329fcf3ce44SJohn Forte 1330fcf3ce44SJohn Forte _NOTE(MUTEX_PROTECTS_DATA(fcp_tgt::tgt_mutex, 1331d42c7aecSReed fcp_tgt::tgt_state fcp_tgt::tgt_device_created 1332fcf3ce44SJohn Forte fcp_tgt::tgt_icap fcp_tgt::tgt_tcap 1333fcf3ce44SJohn Forte fcp_tgt::tgt_tid fcp_tgt::tgt_pd_handle fcp_tgt::tgt_tmp_cnt 1334fcf3ce44SJohn Forte fcp_tgt::tgt_statec_cause fcp_lun::lun_next fcp_lun::lun_state)) 1335fcf3ce44SJohn Forte 1336fcf3ce44SJohn Forte _NOTE(LOCK_ORDER(fcp_port::fcp_mutex fcp_tgt::tgt_mutex)) 1337fcf3ce44SJohn Forte _NOTE(LOCK_ORDER(fcp_tgt::tgt_mutex fcp_lun::lun_mutex)) 1338fcf3ce44SJohn Forte 1339fcf3ce44SJohn Forte _NOTE(MUTEX_PROTECTS_DATA(fcp_lun::lun_mutex, 1340fcf3ce44SJohn Forte fcp_lun::lun_pkt_head fcp_lun::lun_pkt_tail 1341fcf3ce44SJohn Forte fcp_lun::lun_cip fcp_lun::lun_mpxio)) 1342fcf3ce44SJohn Forte 1343fcf3ce44SJohn Forte _NOTE(DATA_READABLE_WITHOUT_LOCK( fcp_tgt::tgt_state)) 1344fcf3ce44SJohn Forte _NOTE(DATA_READABLE_WITHOUT_LOCK( fcp_tgt::tgt_pd_handle)) 1345fcf3ce44SJohn Forte 1346fcf3ce44SJohn Forte _NOTE(DATA_READABLE_WITHOUT_LOCK(fcp_tgt::tgt_tid)) 1347fcf3ce44SJohn Forte 1348fcf3ce44SJohn Forte 1349fcf3ce44SJohn Forte _NOTE(SCHEME_PROTECTS_DATA("Safe Data", 1350fcf3ce44SJohn Forte fcp_port::port_dma_acc_attr 1351fcf3ce44SJohn Forte fcp_port::port_fcp_dma fcp_port::fcp_tran 1352fcf3ce44SJohn Forte fcp_port::port_ndi_events fcp_port::port_ndi_event_defs 1353fcf3ce44SJohn Forte fcp_port::port_pkt_cache fcp_port::port_dip fcp_port::port_phys_state 1354fcf3ce44SJohn Forte fcp_port::port_reset_action fcp_port::port_cmds_dma_flags 1355fcf3ce44SJohn Forte fcp_port::port_fp_handle fcp_port::port_instance 1356fcf3ce44SJohn Forte fcp_port::port_fp_modlinkage fcp_port::port_max_exch 1357fcf3ce44SJohn Forte fcp_port::port_priv_pkt_len fcp_port::port_id 1358fcf3ce44SJohn Forte fcp_port::port_topology fcp_port::port_deadline fcp_port::port_mpxio 1359fcf3ce44SJohn Forte fcp_tgt::tgt_d_id fcp_tgt::tgt_hard_addr fcp_tgt::tgt_lun_cnt 1360fcf3ce44SJohn Forte fcp_tgt::tgt_port fcp_lun::lun_num fcp_lun::lun_tgt 1361fcf3ce44SJohn Forte fcp_lun::lun_type 1362fcf3ce44SJohn Forte fcp_lun::lun_guid_size fcp_lun::lun_guid 1363fcf3ce44SJohn Forte fcp_hp_elem::lun fcp_hp_elem::flags fcp_hp_elem::cip 1364fcf3ce44SJohn Forte fcp_hp_elem::what fcp_hp_elem::tgt_cnt fcp_hp_elem::tgt_cnt 1365fcf3ce44SJohn Forte fcp_hp_elem::link_cnt fcp_reset_elem fcp_pkt fcp_ipkt 1366fcf3ce44SJohn Forte scsi_pkt scsi_arq_status scsi_device scsi_hba_tran scsi_cdb)) 1367d42c7aecSReed #endif /* __lint */ 1368fcf3ce44SJohn Forte 1369fcf3ce44SJohn Forte #define FCP_CP_IN(s, d, handle, len) (ddi_rep_get8((handle), \ 1370fcf3ce44SJohn Forte (uint8_t *)(d), (uint8_t *)(s), \ 1371fcf3ce44SJohn Forte (len), DDI_DEV_AUTOINCR)) 1372fcf3ce44SJohn Forte 1373fcf3ce44SJohn Forte #define FCP_CP_OUT(s, d, handle, len) (ddi_rep_put8((handle), \ 1374fcf3ce44SJohn Forte (uint8_t *)(s), (uint8_t *)(d), \ 1375fcf3ce44SJohn Forte (len), DDI_DEV_AUTOINCR)) 1376fcf3ce44SJohn Forte 1377fcf3ce44SJohn Forte #define FCP_ONLINE 0x1 1378fcf3ce44SJohn Forte #define FCP_OFFLINE 0x2 1379fcf3ce44SJohn Forte #define FCP_MPXIO_PATH_CLEAR_BUSY 0x3 1380fcf3ce44SJohn Forte #define FCP_MPXIO_PATH_SET_BUSY 0x4 1381fcf3ce44SJohn Forte 1382fcf3ce44SJohn Forte #define FCP_IDLE 0x00 1383fcf3ce44SJohn Forte #define FCP_OPEN 0x01 1384fcf3ce44SJohn Forte #define FCP_EXCL 0x02 1385fcf3ce44SJohn Forte #define FCP_BUSY 0x04 1386fcf3ce44SJohn Forte 1387fcf3ce44SJohn Forte #define LFA(x) (x & 0xFFFF00) 1388fcf3ce44SJohn Forte #define FCP_SET 1 1389fcf3ce44SJohn Forte #define FCP_RESET 0 1390fcf3ce44SJohn Forte 1391fcf3ce44SJohn Forte /* init() and attach() wait timeout values (in usecs) */ 1392fcf3ce44SJohn Forte #define FCP_INIT_WAIT_TIMEOUT 60000000 /* 60 seconds */ 1393fcf3ce44SJohn Forte #define FCP_ATTACH_WAIT_TIMEOUT 10000000 /* 10 seconds */ 1394fcf3ce44SJohn Forte 1395fcf3ce44SJohn Forte #ifdef TRUE 1396fcf3ce44SJohn Forte #undef TRUE 1397fcf3ce44SJohn Forte #endif 1398fcf3ce44SJohn Forte #define TRUE 1 1399fcf3ce44SJohn Forte 1400fcf3ce44SJohn Forte #ifdef FALSE 1401fcf3ce44SJohn Forte #undef FALSE 1402fcf3ce44SJohn Forte #endif 1403fcf3ce44SJohn Forte #define FALSE 0 1404fcf3ce44SJohn Forte 1405fcf3ce44SJohn Forte #define UNDEFINED -1 1406fcf3ce44SJohn Forte 1407fcf3ce44SJohn Forte /* for softstate */ 1408fcf3ce44SJohn Forte #define FCP_INIT_ITEMS 5 1409fcf3ce44SJohn Forte 1410fcf3ce44SJohn Forte #ifdef __cplusplus 1411fcf3ce44SJohn Forte } 1412fcf3ce44SJohn Forte #endif 1413fcf3ce44SJohn Forte 1414fcf3ce44SJohn Forte #endif /* _FCPVAR_H */ 1415