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 /* 22fcf3ce44SJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23fcf3ce44SJohn Forte * Use is subject to license terms. 24fcf3ce44SJohn Forte */ 25fcf3ce44SJohn Forte 26*d3351b34SJohn Levon /* 27*d3351b34SJohn Levon * Copyright 2019 Joyent, Inc. 28*d3351b34SJohn Levon */ 29*d3351b34SJohn Levon 30fcf3ce44SJohn Forte #ifndef _FP_H 31fcf3ce44SJohn Forte #define _FP_H 32fcf3ce44SJohn Forte 33fcf3ce44SJohn Forte 34fcf3ce44SJohn Forte #include <sys/note.h> 35fcf3ce44SJohn Forte 36fcf3ce44SJohn Forte #ifdef __cplusplus 37fcf3ce44SJohn Forte extern "C" { 38fcf3ce44SJohn Forte #endif 39fcf3ce44SJohn Forte 40fcf3ce44SJohn Forte /* 41fcf3ce44SJohn Forte * Debugging, Error reporting, and tracing 42fcf3ce44SJohn Forte */ 43fcf3ce44SJohn Forte #define FP_LOG_SIZE 1024 * 1024 44fcf3ce44SJohn Forte 45fcf3ce44SJohn Forte #define FP_LEVEL_1 0x00001 /* attach/detach PM CPR */ 46fcf3ce44SJohn Forte #define FP_LEVEL_2 0x00002 /* startup */ 47fcf3ce44SJohn Forte #define FP_LEVEL_3 0x00004 /* state change, discovery */ 48fcf3ce44SJohn Forte #define FP_LEVEL_4 0x00008 /* statec/devc to ULPs */ 49fcf3ce44SJohn Forte #define FP_LEVEL_5 0x00010 /* FCA UB callbacks */ 50fcf3ce44SJohn Forte #define FP_LEVEL_6 0x00020 /* Name Server */ 51fcf3ce44SJohn Forte #define FP_LEVEL_7 0x00040 /* RSCN */ 52fcf3ce44SJohn Forte #define FP_LEVEL_8 0x00080 /* I/O tracing */ 53fcf3ce44SJohn Forte #define FP_LEVEL_9 0x00100 /* Failure messages */ 54fcf3ce44SJohn Forte 55fcf3ce44SJohn Forte 56fcf3ce44SJohn Forte /* 57fcf3ce44SJohn Forte * Log contents to system messages file 58fcf3ce44SJohn Forte */ 59fcf3ce44SJohn Forte #define FP_MSG_LEVEL_1 (FP_LEVEL_1 | FC_TRACE_LOG_MSG) 60fcf3ce44SJohn Forte #define FP_MSG_LEVEL_2 (FP_LEVEL_2 | FC_TRACE_LOG_MSG) 61fcf3ce44SJohn Forte #define FP_MSG_LEVEL_3 (FP_LEVEL_3 | FC_TRACE_LOG_MSG) 62fcf3ce44SJohn Forte #define FP_MSG_LEVEL_4 (FP_LEVEL_4 | FC_TRACE_LOG_MSG) 63fcf3ce44SJohn Forte #define FP_MSG_LEVEL_5 (FP_LEVEL_5 | FC_TRACE_LOG_MSG) 64fcf3ce44SJohn Forte #define FP_MSG_LEVEL_6 (FP_LEVEL_6 | FC_TRACE_LOG_MSG) 65fcf3ce44SJohn Forte #define FP_MSG_LEVEL_7 (FP_LEVEL_7 | FC_TRACE_LOG_MSG) 66fcf3ce44SJohn Forte #define FP_MSG_LEVEL_8 (FP_LEVEL_8 | FC_TRACE_LOG_MSG) 67fcf3ce44SJohn Forte #define FP_MSG_LEVEL_9 (FP_LEVEL_9 | FC_TRACE_LOG_MSG) 68fcf3ce44SJohn Forte 69fcf3ce44SJohn Forte 70fcf3ce44SJohn Forte /* 71fcf3ce44SJohn Forte * Log contents to trace buffer 72fcf3ce44SJohn Forte */ 73fcf3ce44SJohn Forte #define FP_BUF_LEVEL_1 (FP_LEVEL_1 | FC_TRACE_LOG_BUF) 74fcf3ce44SJohn Forte #define FP_BUF_LEVEL_2 (FP_LEVEL_2 | FC_TRACE_LOG_BUF) 75fcf3ce44SJohn Forte #define FP_BUF_LEVEL_3 (FP_LEVEL_3 | FC_TRACE_LOG_BUF) 76fcf3ce44SJohn Forte #define FP_BUF_LEVEL_4 (FP_LEVEL_4 | FC_TRACE_LOG_BUF) 77fcf3ce44SJohn Forte #define FP_BUF_LEVEL_5 (FP_LEVEL_5 | FC_TRACE_LOG_BUF) 78fcf3ce44SJohn Forte #define FP_BUF_LEVEL_6 (FP_LEVEL_6 | FC_TRACE_LOG_BUF) 79fcf3ce44SJohn Forte #define FP_BUF_LEVEL_7 (FP_LEVEL_7 | FC_TRACE_LOG_BUF) 80fcf3ce44SJohn Forte #define FP_BUF_LEVEL_8 (FP_LEVEL_8 | FC_TRACE_LOG_BUF) 81fcf3ce44SJohn Forte #define FP_BUF_LEVEL_9 (FP_LEVEL_9 | FC_TRACE_LOG_BUF) 82fcf3ce44SJohn Forte 83fcf3ce44SJohn Forte 84fcf3ce44SJohn Forte /* 85fcf3ce44SJohn Forte * Log contents to both system messages file and trace buffer 86fcf3ce44SJohn Forte */ 87fcf3ce44SJohn Forte #define FP_MSG_BUF_LEVEL_1 (FP_LEVEL_1 | FC_TRACE_LOG_BUF |\ 88fcf3ce44SJohn Forte FC_TRACE_LOG_MSG) 89fcf3ce44SJohn Forte #define FP_MSG_BUF_LEVEL_2 (FP_LEVEL_2 | FC_TRACE_LOG_BUF |\ 90fcf3ce44SJohn Forte FC_TRACE_LOG_MSG) 91fcf3ce44SJohn Forte #define FP_MSG_BUF_LEVEL_3 (FP_LEVEL_3 | FC_TRACE_LOG_BUF |\ 92fcf3ce44SJohn Forte FC_TRACE_LOG_MSG) 93fcf3ce44SJohn Forte #define FP_MSG_BUF_LEVEL_4 (FP_LEVEL_4 | FC_TRACE_LOG_BUF |\ 94fcf3ce44SJohn Forte FC_TRACE_LOG_MSG) 95fcf3ce44SJohn Forte #define FP_MSG_BUF_LEVEL_5 (FP_LEVEL_5 | FC_TRACE_LOG_BUF |\ 96fcf3ce44SJohn Forte FC_TRACE_LOG_MSG) 97fcf3ce44SJohn Forte #define FP_MSG_BUF_LEVEL_6 (FP_LEVEL_6 | FC_TRACE_LOG_BUF |\ 98fcf3ce44SJohn Forte FC_TRACE_LOG_MSG) 99fcf3ce44SJohn Forte #define FP_MSG_BUF_LEVEL_7 (FP_LEVEL_7 | FC_TRACE_LOG_BUF |\ 100fcf3ce44SJohn Forte FC_TRACE_LOG_MSG) 101fcf3ce44SJohn Forte #define FP_MSG_BUF_LEVEL_8 (FP_LEVEL_8 | FC_TRACE_LOG_BUF |\ 102fcf3ce44SJohn Forte FC_TRACE_LOG_MSG) 103fcf3ce44SJohn Forte #define FP_MSG_BUF_LEVEL_9 (FP_LEVEL_9 | FC_TRACE_LOG_BUF |\ 104fcf3ce44SJohn Forte FC_TRACE_LOG_MSG) 105fcf3ce44SJohn Forte 106fcf3ce44SJohn Forte /* 107fcf3ce44SJohn Forte * Log contents to system messages file, console and trace buffer 108fcf3ce44SJohn Forte */ 109fcf3ce44SJohn Forte #define FP_MSG_BUF_CONSOLE_LEVEL_1 (FP_LEVEL_1 | FC_TRACE_LOG_BUF |\ 110fcf3ce44SJohn Forte FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE) 111fcf3ce44SJohn Forte #define FP_MSG_BUF_CONSOLE_LEVEL_2 (FP_LEVEL_2 | FC_TRACE_LOG_BUF |\ 112fcf3ce44SJohn Forte FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE) 113fcf3ce44SJohn Forte #define FP_MSG_BUF_CONSOLE_LEVEL_3 (FP_LEVEL_3 | FC_TRACE_LOG_BUF |\ 114fcf3ce44SJohn Forte FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE) 115fcf3ce44SJohn Forte #define FP_MSG_BUF_CONSOLE_LEVEL_4 (FP_LEVEL_4 | FC_TRACE_LOG_BUF |\ 116fcf3ce44SJohn Forte FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE) 117fcf3ce44SJohn Forte #define FP_MSG_BUF_CONSOLE_LEVEL_5 (FP_LEVEL_5 | FC_TRACE_LOG_BUF |\ 118fcf3ce44SJohn Forte FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE) 119fcf3ce44SJohn Forte #define FP_MSG_BUF_CONSOLE_LEVEL_6 (FP_LEVEL_6 | FC_TRACE_LOG_BUF |\ 120fcf3ce44SJohn Forte FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE) 121fcf3ce44SJohn Forte #define FP_MSG_BUF_CONSOLE_LEVEL_7 (FP_LEVEL_7 | FC_TRACE_LOG_BUF |\ 122fcf3ce44SJohn Forte FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE) 123fcf3ce44SJohn Forte #define FP_MSG_BUF_CONSOLE_LEVEL_8 (FP_LEVEL_8 | FC_TRACE_LOG_BUF |\ 124fcf3ce44SJohn Forte FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE) 125fcf3ce44SJohn Forte #define FP_MSG_BUF_CONSOLE_LEVEL_9 (FP_LEVEL_9 | FC_TRACE_LOG_BUF |\ 126fcf3ce44SJohn Forte FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE) 127fcf3ce44SJohn Forte #ifdef DEBUG 128fcf3ce44SJohn Forte 129fcf3ce44SJohn Forte #define FP_DTRACE fc_trace_debug 130fcf3ce44SJohn Forte 131fcf3ce44SJohn Forte #else 132fcf3ce44SJohn Forte 133*d3351b34SJohn Levon #define FP_DTRACE(...) (void)(0) 134fcf3ce44SJohn Forte 135fcf3ce44SJohn Forte #endif 136fcf3ce44SJohn Forte 137fcf3ce44SJohn Forte #define FP_TRACE fc_trace_debug 138fcf3ce44SJohn Forte 139fcf3ce44SJohn Forte 140fcf3ce44SJohn Forte #ifdef DEBUG 141fcf3ce44SJohn Forte 142fcf3ce44SJohn Forte #define FP_TRACE_DEFAULT (FC_TRACE_LOG_MASK | FP_LEVEL_1 |\ 143fcf3ce44SJohn Forte FP_LEVEL_2 | FP_LEVEL_3 |\ 144fcf3ce44SJohn Forte FP_LEVEL_4 | FP_LEVEL_5 |\ 145fcf3ce44SJohn Forte FP_LEVEL_6 | FP_LEVEL_7 | FP_LEVEL_9) 146fcf3ce44SJohn Forte 147fcf3ce44SJohn Forte #else 148fcf3ce44SJohn Forte 149fcf3ce44SJohn Forte #define FP_TRACE_DEFAULT (FC_TRACE_LOG_MASK | FP_LEVEL_1 |\ 150fcf3ce44SJohn Forte FP_LEVEL_2 | FP_LEVEL_3 |\ 151fcf3ce44SJohn Forte FP_LEVEL_4 | FP_LEVEL_5 |\ 152fcf3ce44SJohn Forte FP_LEVEL_6 | FP_LEVEL_7 | FP_LEVEL_9) 153fcf3ce44SJohn Forte #endif 154fcf3ce44SJohn Forte 155fcf3ce44SJohn Forte #define FP_THEAD(x, y, z) fp_logq, x->fp_ibuf, fp_trace, y, z 156fcf3ce44SJohn Forte 157fcf3ce44SJohn Forte #define FP_NHEAD1(x, y) FP_THEAD(port, FP_BUF_LEVEL_##x, y) 158fcf3ce44SJohn Forte 159fcf3ce44SJohn Forte #define FP_NHEAD2(x, y) FP_THEAD(port, FP_MSG_BUF_LEVEL_##x, y) 160fcf3ce44SJohn Forte 161fcf3ce44SJohn Forte #define FP_NHEAD3(x, y) FP_THEAD(port, FP_MSG_BUF_CONSOLE_LEVEL_##x, y) 162fcf3ce44SJohn Forte 163fcf3ce44SJohn Forte 164fcf3ce44SJohn Forte /* This is used in about a dozen or so places in fp.c */ 165fcf3ce44SJohn Forte #define FP_IS_PKT_ERROR(pkt) (((pkt)->pkt_state != FC_PKT_SUCCESS) ||\ 166fcf3ce44SJohn Forte ((pkt)->pkt_state == FC_PKT_SUCCESS &&\ 167fcf3ce44SJohn Forte (pkt)->pkt_resp_resid != 0)) 168fcf3ce44SJohn Forte 169fcf3ce44SJohn Forte 170fcf3ce44SJohn Forte /* 171fcf3ce44SJohn Forte * This is only used in fp_ns_init() and fp_fabric_online(). 172fcf3ce44SJohn Forte */ 173fcf3ce44SJohn Forte #define FP_MAX_DEVICES 255 174fcf3ce44SJohn Forte 175fcf3ce44SJohn Forte 176fcf3ce44SJohn Forte /* 177fcf3ce44SJohn Forte * Software restoration bit fields while doing (PM)SUSPEND/(PM)RESUME 178fcf3ce44SJohn Forte * Used with the fp_restore field in the fc_local_port_t struct. 179fcf3ce44SJohn Forte */ 180fcf3ce44SJohn Forte #define FP_RESTORE_WAIT_TIMEOUT 0x01 181fcf3ce44SJohn Forte #define FP_RESTORE_OFFLINE_TIMEOUT 0x02 182fcf3ce44SJohn Forte #define FP_ELS_TIMEOUT (20) 183fcf3ce44SJohn Forte #define FP_NS_TIMEOUT (120) 184fcf3ce44SJohn Forte #define FP_IS_F_PORT(p) ((p) & 0x1000) 185fcf3ce44SJohn Forte #define FP_RETRY_COUNT (5) 186fcf3ce44SJohn Forte #define FP_RETRY_DELAY (3) /* E_D_TOV + 1 second */ 187fcf3ce44SJohn Forte #define FP_OFFLINE_TICKER (90) /* seconds */ 188fcf3ce44SJohn Forte #define FP_DEFAULT_SID (0x000AE) /* Used once */ 189fcf3ce44SJohn Forte #define FP_DEFAULT_DID (0x000EA) /* Used once */ 190fcf3ce44SJohn Forte #define FP_PORT_IDENTIFIER_LEN (4) 191fcf3ce44SJohn Forte #define FP_UNSOL_BUF_COUNT (20) 192fcf3ce44SJohn Forte #define FP_UNSOL_BUF_SIZE (sizeof (la_els_logi_t)) 193fcf3ce44SJohn Forte #define FP_CMDWAIT_DELAY (240) /* Enough time for all cmds to complt */ 194fcf3ce44SJohn Forte 195fcf3ce44SJohn Forte 196fcf3ce44SJohn Forte /* 197fcf3ce44SJohn Forte * Values and macros used with fp_task and fp_last_task fields in 198fcf3ce44SJohn Forte * the fc_local_port_t struct. Also see fp_job_handler() for more info. 199fcf3ce44SJohn Forte */ 200fcf3ce44SJohn Forte #define FP_TASK_IDLE 0 201fcf3ce44SJohn Forte #define FP_TASK_PORT_STARTUP 1 202fcf3ce44SJohn Forte #define FP_TASK_OFFLINE 2 203fcf3ce44SJohn Forte #define FP_TASK_ONLINE 3 204fcf3ce44SJohn Forte #define FP_TASK_GETMAP 4 205fcf3ce44SJohn Forte 206fcf3ce44SJohn Forte 207fcf3ce44SJohn Forte /* 208fcf3ce44SJohn Forte * cmd_flags 209fcf3ce44SJohn Forte */ 210fcf3ce44SJohn Forte #define FP_CMD_CFLAG_UNDEFINED (-1) 211fcf3ce44SJohn Forte #define FP_CMD_PLOGI_DONT_CARE 0x00 212fcf3ce44SJohn Forte #define FP_CMD_PLOGI_RETAIN 0x01 /* Retain LOGIN */ 213fcf3ce44SJohn Forte #define FP_CMD_DELDEV_ON_ERROR 0x02 /* Remove device on error */ 214fcf3ce44SJohn Forte 215fcf3ce44SJohn Forte /* 216fcf3ce44SJohn Forte * cmd_dflags 217fcf3ce44SJohn Forte */ 218fcf3ce44SJohn Forte #define FP_CMD_VALID_DMA_MEM 0x01 219fcf3ce44SJohn Forte #define FP_CMD_VALID_DMA_BIND 0x02 220fcf3ce44SJohn Forte #define FP_RESP_VALID_DMA_MEM 0x04 221fcf3ce44SJohn Forte #define FP_RESP_VALID_DMA_BIND 0x08 222fcf3ce44SJohn Forte 223fcf3ce44SJohn Forte 224fcf3ce44SJohn Forte /* Values for fp_flag field in the fc_local_port_t struct */ 225fcf3ce44SJohn Forte #define FP_IDLE 0x00 226fcf3ce44SJohn Forte #define FP_OPEN 0x01 227fcf3ce44SJohn Forte #define FP_EXCL 0x02 228fcf3ce44SJohn Forte #define FP_EXCL_BUSY 0x04 /* Exclusive operation in progress */ 229fcf3ce44SJohn Forte 230fcf3ce44SJohn Forte 231fcf3ce44SJohn Forte /* message block/unblock'ing */ 232fcf3ce44SJohn Forte #define FP_WARNING_MESSAGES 0x01 233fcf3ce44SJohn Forte #define FP_FATAL_MESSAGES 0x02 234fcf3ce44SJohn Forte 235fcf3ce44SJohn Forte 236fcf3ce44SJohn Forte #define FP_IS_CLASS_1_OR_2(x) \ 237fcf3ce44SJohn Forte ((x) == FC_TRAN_CLASS1 || (x) == FC_TRAN_CLASS2) 238fcf3ce44SJohn Forte 239fcf3ce44SJohn Forte 240fcf3ce44SJohn Forte /* 241fcf3ce44SJohn Forte * Driver message control 242fcf3ce44SJohn Forte */ 243fcf3ce44SJohn Forte typedef enum fp_mesg_dest { 244fcf3ce44SJohn Forte FP_CONSOLE_ONLY, 245fcf3ce44SJohn Forte FP_LOG_ONLY, 246fcf3ce44SJohn Forte FP_LOG_AND_CONSOLE 247fcf3ce44SJohn Forte } fp_mesg_dest_t; 248fcf3ce44SJohn Forte 249fcf3ce44SJohn Forte typedef struct soft_attach { 250fcf3ce44SJohn Forte fc_attach_cmd_t att_cmd; 251fcf3ce44SJohn Forte struct fc_local_port *att_port; 252fcf3ce44SJohn Forte boolean_t att_need_pm_idle; 253fcf3ce44SJohn Forte } fp_soft_attach_t; 254fcf3ce44SJohn Forte 255fcf3ce44SJohn Forte typedef struct fp_cmd { 256fcf3ce44SJohn Forte uint16_t cmd_dflags; /* DMA flags */ 257fcf3ce44SJohn Forte ksema_t cmd_sema; 258fcf3ce44SJohn Forte int cmd_flags; /* cmd flags */ 259fcf3ce44SJohn Forte int cmd_retry_count; 260fcf3ce44SJohn Forte int cmd_retry_interval; /* milli secs */ 261fcf3ce44SJohn Forte fc_packet_t cmd_pkt; 262fcf3ce44SJohn Forte fc_local_port_t *cmd_port; 263fcf3ce44SJohn Forte opaque_t cmd_private; 264fcf3ce44SJohn Forte struct fp_cmd *cmd_next; 265fcf3ce44SJohn Forte fc_packet_t *cmd_ulp_pkt; 266fcf3ce44SJohn Forte job_request_t *cmd_job; 267fcf3ce44SJohn Forte int (*cmd_transport) (opaque_t fca_handle, fc_packet_t *); 268fcf3ce44SJohn Forte } fp_cmd_t; 269fcf3ce44SJohn Forte 270fcf3ce44SJohn Forte typedef struct fp_unsol_spec { 271fcf3ce44SJohn Forte fc_local_port_t *port; 272fcf3ce44SJohn Forte fc_unsol_buf_t *buf; 273fcf3ce44SJohn Forte } fp_unsol_spec_t; 274fcf3ce44SJohn Forte 275fcf3ce44SJohn Forte 276fcf3ce44SJohn Forte #if !defined(__lint) 277fcf3ce44SJohn Forte _NOTE(SCHEME_PROTECTS_DATA("unique per request", fp_cmd)) 278fcf3ce44SJohn Forte _NOTE(SCHEME_PROTECTS_DATA("unique per request", soft_attach)) 279fcf3ce44SJohn Forte _NOTE(SCHEME_PROTECTS_DATA("unique per request", fp_unsol_spec)) 280fcf3ce44SJohn Forte #endif /* __lint */ 281fcf3ce44SJohn Forte 282fcf3ce44SJohn Forte /* 283fcf3ce44SJohn Forte * Procedure templates. 284fcf3ce44SJohn Forte */ 285fcf3ce44SJohn Forte static int fp_attach(dev_info_t *dip, ddi_attach_cmd_t cmd); 286fcf3ce44SJohn Forte static int fp_detach(dev_info_t *dip, ddi_detach_cmd_t cmd); 287fcf3ce44SJohn Forte static int fp_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, 288fcf3ce44SJohn Forte void *arg, void **result); 289fcf3ce44SJohn Forte static int fp_power(dev_info_t *dip, int comp, int level); 290fcf3ce44SJohn Forte static int fp_open(dev_t *devp, int flag, int otype, cred_t *credp); 291fcf3ce44SJohn Forte static int fp_close(dev_t dev, int flag, int otype, cred_t *credp); 292fcf3ce44SJohn Forte static int fp_ioctl(dev_t dev, int cmd, intptr_t data, int mode, 293fcf3ce44SJohn Forte cred_t *credp, int *rval); 294fcf3ce44SJohn Forte static int fp_attach_handler(dev_info_t *dip); 295fcf3ce44SJohn Forte static int fp_resume_handler(dev_info_t *dip); 296fcf3ce44SJohn Forte static int fp_power_up(fc_local_port_t *port); 297fcf3ce44SJohn Forte static int fp_resume_all(fc_local_port_t *port, fc_attach_cmd_t cmd); 298fcf3ce44SJohn Forte static int fp_detach_handler(fc_local_port_t *port); 299fcf3ce44SJohn Forte static int fp_suspend_handler(fc_local_port_t *port); 300fcf3ce44SJohn Forte static int fp_power_down(fc_local_port_t *port); 301fcf3ce44SJohn Forte static void fp_suspend_all(fc_local_port_t *port); 302fcf3ce44SJohn Forte static int fp_cache_constructor(void *buf, void *cdarg, int kmflags); 303fcf3ce44SJohn Forte static void fp_cache_destructor(void *buf, void *cdarg); 304fcf3ce44SJohn Forte static fp_cmd_t *fp_alloc_pkt(fc_local_port_t *port, int cmd_len, 305fcf3ce44SJohn Forte int resp_len, int kmflags, fc_remote_port_t *pd); 306fcf3ce44SJohn Forte static void fp_free_pkt(fp_cmd_t *cmd); 307fcf3ce44SJohn Forte static void fp_free_dma(fp_cmd_t *cmd); 308fcf3ce44SJohn Forte static void fp_job_handler(fc_local_port_t *port); 309fcf3ce44SJohn Forte static int fp_port_startup(fc_local_port_t *port, job_request_t *job); 310fcf3ce44SJohn Forte static void fp_startup_done(opaque_t arg, uchar_t result); 311fcf3ce44SJohn Forte static void fp_ulp_port_attach(void *arg); 312fcf3ce44SJohn Forte static int fp_sendcmd(fc_local_port_t *port, fp_cmd_t *cmd, 313fcf3ce44SJohn Forte opaque_t fca_handle); 314fcf3ce44SJohn Forte static void fp_resendcmd(void *port_handle); 315fcf3ce44SJohn Forte static int fp_retry_cmd(fc_packet_t *pkt); 316fcf3ce44SJohn Forte static void fp_enque_cmd(fc_local_port_t *port, fp_cmd_t *cmd); 317fcf3ce44SJohn Forte static int fp_handle_reject(fc_packet_t *pkt); 318fcf3ce44SJohn Forte static uchar_t fp_get_nextclass(fc_local_port_t *port, uchar_t cur_class); 319fcf3ce44SJohn Forte static int fp_is_class_supported(uint32_t cos, uchar_t tran_class); 320fcf3ce44SJohn Forte static fp_cmd_t *fp_deque_cmd(fc_local_port_t *port); 321fcf3ce44SJohn Forte static void fp_jobwait(job_request_t *job); 322fcf3ce44SJohn Forte int fp_state_to_rval(uchar_t state); 323fcf3ce44SJohn Forte static void fp_iodone(fp_cmd_t *cmd); 324fcf3ce44SJohn Forte static void fp_jobdone(job_request_t *job); 325fcf3ce44SJohn Forte static void fp_port_shutdown(fc_local_port_t *port, job_request_t *job); 326fcf3ce44SJohn Forte static void fp_get_loopmap(fc_local_port_t *port, job_request_t *job); 327fcf3ce44SJohn Forte static void fp_loop_online(fc_local_port_t *port, job_request_t *job, 328fcf3ce44SJohn Forte int orphan); 329fcf3ce44SJohn Forte static int fp_get_lilpmap(fc_local_port_t *port, fc_lilpmap_t *lilp_map); 330fcf3ce44SJohn Forte static int fp_fabric_login(fc_local_port_t *port, uint32_t s_id, 331fcf3ce44SJohn Forte job_request_t *job, int flag, int sleep); 332fcf3ce44SJohn Forte static int fp_port_login(fc_local_port_t *port, uint32_t d_id, 333fcf3ce44SJohn Forte job_request_t *job, int cmd_flag, int sleep, fc_remote_port_t *pd, 334fcf3ce44SJohn Forte fc_packet_t *ulp_pkt); 335fcf3ce44SJohn Forte static void fp_register_login(ddi_acc_handle_t *handle, fc_remote_port_t *pd, 336fcf3ce44SJohn Forte la_els_logi_t *acc, uchar_t class); 337fcf3ce44SJohn Forte static void fp_remote_port_offline(fc_remote_port_t *pd); 338fcf3ce44SJohn Forte static void fp_unregister_login(fc_remote_port_t *pd); 339fcf3ce44SJohn Forte static void fp_port_offline(fc_local_port_t *port, int notify); 340fcf3ce44SJohn Forte static void fp_offline_timeout(void *port_handle); 341fcf3ce44SJohn Forte static void fp_els_init(fp_cmd_t *cmd, uint32_t s_id, uint32_t d_id, 342fcf3ce44SJohn Forte void (*comp) (), job_request_t *job); 343fcf3ce44SJohn Forte static void fp_xlogi_init(fc_local_port_t *port, fp_cmd_t *cmd, uint32_t s_id, 344fcf3ce44SJohn Forte uint32_t d_id, void (*intr) (), job_request_t *job, uchar_t ls_code); 345fcf3ce44SJohn Forte static void fp_logo_init(fc_remote_port_t *pd, fp_cmd_t *cmd, 346fcf3ce44SJohn Forte job_request_t *job); 347fcf3ce44SJohn Forte static void fp_adisc_init(fp_cmd_t *cmd, job_request_t *job); 348fcf3ce44SJohn Forte static int fp_ulp_statec_cb(fc_local_port_t *port, uint32_t state, 349fcf3ce44SJohn Forte fc_portmap_t *changelist, uint32_t listlen, uint32_t alloc_len, int sleep); 350fcf3ce44SJohn Forte static int fp_ulp_devc_cb(fc_local_port_t *port, fc_portmap_t *changelist, 351fcf3ce44SJohn Forte uint32_t listlen, uint32_t alloc_len, int sleep, int sync); 352fcf3ce44SJohn Forte static void fp_plogi_group(fc_local_port_t *port, job_request_t *job); 353fcf3ce44SJohn Forte static void fp_ns_init(fc_local_port_t *port, job_request_t *job, int sleep); 354fcf3ce44SJohn Forte static void fp_ns_fini(fc_local_port_t *port, job_request_t *job); 355fcf3ce44SJohn Forte static int fp_ns_reg(fc_local_port_t *port, fc_remote_port_t *pd, 356fcf3ce44SJohn Forte uint16_t cmd_code, job_request_t *job, int polled, int sleep); 357fcf3ce44SJohn Forte static int fp_common_intr(fc_packet_t *pkt, int iodone); 358fcf3ce44SJohn Forte static void fp_flogi_intr(fc_packet_t *pkt); 359fcf3ce44SJohn Forte static void fp_plogi_intr(fc_packet_t *pkt); 360fcf3ce44SJohn Forte static void fp_adisc_intr(fc_packet_t *pkt); 361fcf3ce44SJohn Forte static void fp_logo_intr(fc_packet_t *pkt); 362fcf3ce44SJohn Forte static void fp_rls_intr(fc_packet_t *pkt); 363fcf3ce44SJohn Forte static void fp_rnid_intr(fc_packet_t *pkt); 364fcf3ce44SJohn Forte static int fp_send_rnid(fc_local_port_t *port, intptr_t data, int mode, 365fcf3ce44SJohn Forte fcio_t *fcio, la_wwn_t *pwwn); 366fcf3ce44SJohn Forte static int fp_get_rnid(fc_local_port_t *port, intptr_t data, int mode, 367fcf3ce44SJohn Forte fcio_t *fcio); 368fcf3ce44SJohn Forte static int fp_set_rnid(fc_local_port_t *port, intptr_t data, int mode, 369fcf3ce44SJohn Forte fcio_t *fcio); 370fcf3ce44SJohn Forte static void fp_intr(fc_packet_t *pkt); 371fcf3ce44SJohn Forte static void fp_statec_cb(opaque_t port_handle, uint32_t state); 372fcf3ce44SJohn Forte static int fp_ns_scr(fc_local_port_t *port, job_request_t *job, 373fcf3ce44SJohn Forte uchar_t scr_func, int sleep); 374fcf3ce44SJohn Forte static int fp_ns_get_devcount(fc_local_port_t *port, job_request_t *job, 375fcf3ce44SJohn Forte int create, int sleep); 376fcf3ce44SJohn Forte static int fp_fciocmd(fc_local_port_t *port, intptr_t data, int mode, 377fcf3ce44SJohn Forte fcio_t *fcio); 378fcf3ce44SJohn Forte static int fp_copyout(void *from, void *to, size_t len, int mode); 379fcf3ce44SJohn Forte static int fp_fcio_copyout(fcio_t *fcio, intptr_t data, int mode); 380fcf3ce44SJohn Forte static void fp_p2p_online(fc_local_port_t *port, job_request_t *job); 381fcf3ce44SJohn Forte static int fp_fillout_p2pmap(fc_local_port_t *port, fcio_t *fcio, int mode); 382fcf3ce44SJohn Forte static void fp_fabric_online(fc_local_port_t *port, job_request_t *job); 383fcf3ce44SJohn Forte static int fp_fillout_loopmap(fc_local_port_t *port, fcio_t *fcio, int mode); 384fcf3ce44SJohn Forte static void fp_unsol_intr(fc_packet_t *pkt); 385fcf3ce44SJohn Forte static void fp_linit_intr(fc_packet_t *pkt); 386fcf3ce44SJohn Forte static void fp_unsol_cb(opaque_t port_handle, fc_unsol_buf_t *buf, 387fcf3ce44SJohn Forte uint32_t type); 388fcf3ce44SJohn Forte static void fp_handle_unsol_buf(fc_local_port_t *port, fc_unsol_buf_t *buf, 389fcf3ce44SJohn Forte job_request_t *job); 390fcf3ce44SJohn Forte static void fp_ba_rjt_init(fc_local_port_t *port, fp_cmd_t *cmd, 391fcf3ce44SJohn Forte fc_unsol_buf_t *buf, job_request_t *job); 392fcf3ce44SJohn Forte static void fp_els_rjt_init(fc_local_port_t *port, fp_cmd_t *cmd, 393fcf3ce44SJohn Forte fc_unsol_buf_t *buf, uchar_t action, uchar_t reason, job_request_t *job); 394fcf3ce44SJohn Forte static void fp_els_acc_init(fc_local_port_t *port, fp_cmd_t *cmd, 395fcf3ce44SJohn Forte fc_unsol_buf_t *buf, job_request_t *job); 396fcf3ce44SJohn Forte static void fp_handle_unsol_logo(fc_local_port_t *port, fc_unsol_buf_t *buf, 397fcf3ce44SJohn Forte fc_remote_port_t *pd, job_request_t *job); 398fcf3ce44SJohn Forte static void fp_handle_unsol_prlo(fc_local_port_t *port, fc_unsol_buf_t *buf, 399fcf3ce44SJohn Forte fc_remote_port_t *pd, job_request_t *job); 400fcf3ce44SJohn Forte static void fp_unsol_resp_init(fc_packet_t *pkt, fc_unsol_buf_t *buf, 401fcf3ce44SJohn Forte uchar_t r_ctl, uchar_t type); 402fcf3ce44SJohn Forte static void fp_i_handle_unsol_els(fc_local_port_t *port, fc_unsol_buf_t *buf); 403fcf3ce44SJohn Forte static void fp_handle_unsol_plogi(fc_local_port_t *port, fc_unsol_buf_t *buf, 404fcf3ce44SJohn Forte job_request_t *job, int sleep); 405fcf3ce44SJohn Forte static void fp_handle_unsol_flogi(fc_local_port_t *port, fc_unsol_buf_t *buf, 406fcf3ce44SJohn Forte job_request_t *job, int sleep); 407fcf3ce44SJohn Forte static void fp_login_acc_init(fc_local_port_t *port, fp_cmd_t *cmd, 408fcf3ce44SJohn Forte fc_unsol_buf_t *buf, job_request_t *job, int sleep); 409fcf3ce44SJohn Forte static void fp_handle_unsol_rscn(fc_local_port_t *port, fc_unsol_buf_t *buf, 410fcf3ce44SJohn Forte job_request_t *job, int sleep); 411fcf3ce44SJohn Forte static void fp_fillout_old_map_held(fc_portmap_t *map, fc_remote_port_t *pd, 412fcf3ce44SJohn Forte uchar_t flag); 413fcf3ce44SJohn Forte static void fp_fillout_old_map(fc_portmap_t *map, fc_remote_port_t *pd, 414fcf3ce44SJohn Forte uchar_t flag); 415fcf3ce44SJohn Forte static void fp_fillout_changed_map(fc_portmap_t *map, fc_remote_port_t *pd, 416fcf3ce44SJohn Forte uint32_t *new_did, la_wwn_t *new_pwwn); 417fcf3ce44SJohn Forte static void fp_fillout_new_nsmap(fc_local_port_t *port, 418fcf3ce44SJohn Forte ddi_acc_handle_t *handle, fc_portmap_t *port_map, ns_resp_gan_t *gan_resp, 419fcf3ce44SJohn Forte uint32_t d_id); 420fcf3ce44SJohn Forte static int fp_remote_lip(fc_local_port_t *port, la_wwn_t *pwwn, int sleep, 421fcf3ce44SJohn Forte job_request_t *job); 422fcf3ce44SJohn Forte static void fp_stuff_device_with_gan(ddi_acc_handle_t *handle, 423fcf3ce44SJohn Forte fc_remote_port_t *pd, ns_resp_gan_t *gan_resp); 424fcf3ce44SJohn Forte static int fp_ns_query(fc_local_port_t *port, fctl_ns_req_t *ns_cmd, 425fcf3ce44SJohn Forte job_request_t *job, int polled, int sleep); 426fcf3ce44SJohn Forte static void fp_ct_init(fc_local_port_t *port, fp_cmd_t *cmd, 427fcf3ce44SJohn Forte fctl_ns_req_t *ns_cmd, uint16_t cmd_code, caddr_t cmd_buf, 428fcf3ce44SJohn Forte uint16_t cmd_len, uint16_t resp_len, job_request_t *job); 429fcf3ce44SJohn Forte static void fp_ns_intr(fc_packet_t *pkt); 430fcf3ce44SJohn Forte static void fp_gan_handler(fc_packet_t *pkt, fctl_ns_req_t *ns_cmd); 431fcf3ce44SJohn Forte static void fp_ns_query_handler(fc_packet_t *pkt, fctl_ns_req_t *ns_cmd); 432fcf3ce44SJohn Forte static void fp_handle_unsol_adisc(fc_local_port_t *port, fc_unsol_buf_t *buf, 433fcf3ce44SJohn Forte fc_remote_port_t *pd, job_request_t *job); 434fcf3ce44SJohn Forte static void fp_adisc_acc_init(fc_local_port_t *port, fp_cmd_t *cmd, 435fcf3ce44SJohn Forte fc_unsol_buf_t *buf, job_request_t *job); 436fcf3ce44SJohn Forte static void fp_load_ulp_modules(dev_info_t *dip, fc_local_port_t *port); 437fcf3ce44SJohn Forte static int fp_logout(fc_local_port_t *port, fc_remote_port_t *pd, 438fcf3ce44SJohn Forte job_request_t *job); 439fcf3ce44SJohn Forte static void fp_attach_ulps(fc_local_port_t *port, fc_attach_cmd_t cmd); 440fcf3ce44SJohn Forte static int fp_ulp_notify(fc_local_port_t *port, uint32_t statec, int sleep); 441fcf3ce44SJohn Forte static int fp_ns_getmap(fc_local_port_t *port, job_request_t *job, 442fcf3ce44SJohn Forte fc_portmap_t **map, uint32_t *len, uint32_t sid); 443fcf3ce44SJohn Forte static fc_remote_port_t *fp_create_remote_port_by_ns(fc_local_port_t *port, 444fcf3ce44SJohn Forte uint32_t d_id, int sleep); 445fcf3ce44SJohn Forte static int fp_check_perms(uchar_t open_flag, uint16_t ioctl_cmd); 446fcf3ce44SJohn Forte static int fp_bind_callbacks(fc_local_port_t *port); 447fcf3ce44SJohn Forte static void fp_retrieve_caps(fc_local_port_t *port); 448fcf3ce44SJohn Forte static void fp_validate_area_domain(fc_local_port_t *port, uint32_t id, 449fcf3ce44SJohn Forte uint32_t mask, job_request_t *job, int sleep); 450fcf3ce44SJohn Forte static void fp_validate_rscn_page(fc_local_port_t *port, fc_affected_id_t *page, 451fcf3ce44SJohn Forte job_request_t *job, fctl_ns_req_t *ns_cmd, fc_portmap_t *listptr, 452fcf3ce44SJohn Forte int *listindex, int sleep); 453fcf3ce44SJohn Forte static int fp_ns_validate_device(fc_local_port_t *port, fc_remote_port_t *pd, 454fcf3ce44SJohn Forte job_request_t *job, int polled, int sleep); 455fcf3ce44SJohn Forte static int fp_validate_lilp_map(fc_lilpmap_t *lilp_map); 456fcf3ce44SJohn Forte static int fp_is_valid_alpa(uchar_t al_pa); 457fcf3ce44SJohn Forte static void fp_ulp_unsol_cb(void *arg); 458fcf3ce44SJohn Forte static void fp_printf(fc_local_port_t *port, int level, fp_mesg_dest_t dest, 459fcf3ce44SJohn Forte int fc_errno, fc_packet_t *pkt, const char *fmt, ...); 460fcf3ce44SJohn Forte static int fp_fcio_logout(fc_local_port_t *port, fcio_t *fcio, 461fcf3ce44SJohn Forte job_request_t *job); 462fcf3ce44SJohn Forte static int fp_fcio_login(fc_local_port_t *port, fcio_t *fcio, 463fcf3ce44SJohn Forte job_request_t *job); 464fcf3ce44SJohn Forte 465fcf3ce44SJohn Forte #ifdef __cplusplus 466fcf3ce44SJohn Forte } 467fcf3ce44SJohn Forte #endif 468fcf3ce44SJohn Forte 469fcf3ce44SJohn Forte #endif /* _FP_H */ 470