1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_FC4_FC_TRANSPORT_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_FC4_FC_TRANSPORT_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #include <sys/fc4/fc.h> 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate /* 37*7c478bd9Sstevel@tonic-gate * fc_devdata_t definitions 38*7c478bd9Sstevel@tonic-gate * 39*7c478bd9Sstevel@tonic-gate * See fc.h for TYPE field definitions 40*7c478bd9Sstevel@tonic-gate */ 41*7c478bd9Sstevel@tonic-gate typedef int fc_devdata_t; 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate /* 44*7c478bd9Sstevel@tonic-gate * fc_ioclass_t definitions. 45*7c478bd9Sstevel@tonic-gate */ 46*7c478bd9Sstevel@tonic-gate typedef enum { 47*7c478bd9Sstevel@tonic-gate FC_CLASS_OUTBOUND, 48*7c478bd9Sstevel@tonic-gate FC_CLASS_INBOUND, 49*7c478bd9Sstevel@tonic-gate FC_CLASS_SIMPLE, 50*7c478bd9Sstevel@tonic-gate FC_CLASS_IO_WRITE, 51*7c478bd9Sstevel@tonic-gate FC_CLASS_IO_READ, 52*7c478bd9Sstevel@tonic-gate FC_CLASS_OFFLINE, 53*7c478bd9Sstevel@tonic-gate FC_CLASS_UNSOLICITED 54*7c478bd9Sstevel@tonic-gate } fc_ioclass_t; 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate /* 57*7c478bd9Sstevel@tonic-gate * This data structure is used by a Fiber Channel Adaptor driver client to 58*7c478bd9Sstevel@tonic-gate * request a Fiber Channel transaction. 59*7c478bd9Sstevel@tonic-gate */ 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate typedef struct fc_packet { 62*7c478bd9Sstevel@tonic-gate /* 63*7c478bd9Sstevel@tonic-gate * identifies which FC device 64*7c478bd9Sstevel@tonic-gate * 65*7c478bd9Sstevel@tonic-gate * In our case it is a pointer to the 66*7c478bd9Sstevel@tonic-gate * port_status structure. This structure 67*7c478bd9Sstevel@tonic-gate * contains the physical port (0 or 1). 68*7c478bd9Sstevel@tonic-gate */ 69*7c478bd9Sstevel@tonic-gate void *fc_pkt_cookie; /* identifies which FC device */ 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate void (*fc_pkt_comp)(struct fc_packet *); 72*7c478bd9Sstevel@tonic-gate void *fc_pkt_private; 73*7c478bd9Sstevel@tonic-gate int32_t fc_pkt_flags; /* flags */ 74*7c478bd9Sstevel@tonic-gate int32_t fc_pkt_timeout; /* Max time to complete */ 75*7c478bd9Sstevel@tonic-gate fc_ioclass_t fc_pkt_io_class; /* fc io class */ 76*7c478bd9Sstevel@tonic-gate fc_devdata_t fc_pkt_io_devdata; /* FC IO Device Data. */ 77*7c478bd9Sstevel@tonic-gate fc_dataseg_t *fc_pkt_cmd; /* Outbound packet */ 78*7c478bd9Sstevel@tonic-gate fc_dataseg_t *fc_pkt_rsp; /* Inbound Packet */ 79*7c478bd9Sstevel@tonic-gate fc_dataseg_t **fc_pkt_datap; /* List of Data Packets */ 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate /* 82*7c478bd9Sstevel@tonic-gate * SOC status from soc status field in Response que. 83*7c478bd9Sstevel@tonic-gate */ 84*7c478bd9Sstevel@tonic-gate unsigned int fc_pkt_status; /* SOC Status when complete */ 85*7c478bd9Sstevel@tonic-gate int fc_pkt_statistics; /* not used */ 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate fc_frame_header_t *fc_frame_cmd, /* used for command */ 88*7c478bd9Sstevel@tonic-gate *fc_frame_resp; /* used for response */ 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate struct fc_packet *fc_pkt_next, /* Chain of FC packet reqs. */ 91*7c478bd9Sstevel@tonic-gate *fc_pkt_prev; 92*7c478bd9Sstevel@tonic-gate } fc_packet_t; 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate /* 95*7c478bd9Sstevel@tonic-gate * Fibre channel packet flags 96*7c478bd9Sstevel@tonic-gate */ 97*7c478bd9Sstevel@tonic-gate #define FCFLAG_NOINTR 1 /* run this command without intr */ 98*7c478bd9Sstevel@tonic-gate #define FCFLAG_COMPLETE 2 /* command has completed */ 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate /* 101*7c478bd9Sstevel@tonic-gate * fc_transport() return values 102*7c478bd9Sstevel@tonic-gate */ 103*7c478bd9Sstevel@tonic-gate enum { 104*7c478bd9Sstevel@tonic-gate FC_TRANSPORT_SUCCESS, /* success */ 105*7c478bd9Sstevel@tonic-gate FC_TRANSPORT_FAILURE, /* failure */ 106*7c478bd9Sstevel@tonic-gate FC_TRANSPORT_TIMEOUT, /* timeout while polling */ 107*7c478bd9Sstevel@tonic-gate FC_TRANSPORT_QFULL, /* queue full */ 108*7c478bd9Sstevel@tonic-gate FC_TRANSPORT_UNAVAIL /* temp. unavailable, e.g., offline */ 109*7c478bd9Sstevel@tonic-gate }; 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate /* 113*7c478bd9Sstevel@tonic-gate * pkt_status return values 114*7c478bd9Sstevel@tonic-gate */ 115*7c478bd9Sstevel@tonic-gate #define FC_STATUS_OK 0 116*7c478bd9Sstevel@tonic-gate #define FC_STATUS_P_RJT 2 117*7c478bd9Sstevel@tonic-gate #define FC_STATUS_F_RJT 3 118*7c478bd9Sstevel@tonic-gate #define FC_STATUS_P_BSY 4 119*7c478bd9Sstevel@tonic-gate #define FC_STATUS_F_BSY 5 120*7c478bd9Sstevel@tonic-gate #define FC_STATUS_ERR_OFFLINE 0x11 121*7c478bd9Sstevel@tonic-gate #define FC_STATUS_TIMEOUT 0x12 122*7c478bd9Sstevel@tonic-gate #define FC_STATUS_ERR_OVERRUN 0x13 123*7c478bd9Sstevel@tonic-gate #define FC_STATUS_UNKNOWN_CQ_TYPE 0x20 124*7c478bd9Sstevel@tonic-gate #define FC_STATUS_BAD_SEG_CNT 0x21 125*7c478bd9Sstevel@tonic-gate #define FC_STATUS_MAX_XCHG_EXCEEDED 0x22 126*7c478bd9Sstevel@tonic-gate #define FC_STATUS_BAD_XID 0x23 127*7c478bd9Sstevel@tonic-gate #define FC_STATUS_XCHG_BUSY 0x24 128*7c478bd9Sstevel@tonic-gate #define FC_STATUS_BAD_POOL_ID 0x25 129*7c478bd9Sstevel@tonic-gate #define FC_STATUS_INSUFFICIENT_CQES 0x26 130*7c478bd9Sstevel@tonic-gate #define FC_STATUS_ALLOC_FAIL 0x27 131*7c478bd9Sstevel@tonic-gate #define FC_STATUS_BAD_SID 0x28 132*7c478bd9Sstevel@tonic-gate #define FC_STATUS_NO_SEQ_INIT 0x29 133*7c478bd9Sstevel@tonic-gate #define FC_STATUS_ERROR 0x80 134*7c478bd9Sstevel@tonic-gate #define FC_STATUS_ONLINE_TIMEOUT 0x81 135*7c478bd9Sstevel@tonic-gate /* 136*7c478bd9Sstevel@tonic-gate * additional pseudo-status codes for login 137*7c478bd9Sstevel@tonic-gate */ 138*7c478bd9Sstevel@tonic-gate #define FC_STATUS_LOGIN_TIMEOUT 0x80000001u 139*7c478bd9Sstevel@tonic-gate #define FC_STATUS_CQFULL 0x80000002u 140*7c478bd9Sstevel@tonic-gate #define FC_STATUS_TRANSFAIL 0x80000003u 141*7c478bd9Sstevel@tonic-gate #define FC_STATUS_RESETFAIL 0x80000004u 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate /* 144*7c478bd9Sstevel@tonic-gate * fc_uc_register() return values 145*7c478bd9Sstevel@tonic-gate */ 146*7c478bd9Sstevel@tonic-gate typedef void * fc_uc_cookie_t; 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate /* 149*7c478bd9Sstevel@tonic-gate * fc_transport() iotype parameter 150*7c478bd9Sstevel@tonic-gate */ 151*7c478bd9Sstevel@tonic-gate typedef enum { 152*7c478bd9Sstevel@tonic-gate FC_TYPE_UNCATEGORIZED, 153*7c478bd9Sstevel@tonic-gate FC_TYPE_DATA, 154*7c478bd9Sstevel@tonic-gate FC_TYPE_UNSOL_CONTROL, 155*7c478bd9Sstevel@tonic-gate FC_TYPE_SOLICITED_CONTROL, 156*7c478bd9Sstevel@tonic-gate FC_TYPE_UNSOL_DATA, 157*7c478bd9Sstevel@tonic-gate FC_TYPE_XFER_RDY, 158*7c478bd9Sstevel@tonic-gate FC_TYPE_COMMAND, 159*7c478bd9Sstevel@tonic-gate FC_TYPE_RESPONSE 160*7c478bd9Sstevel@tonic-gate } fc_iotype_t; 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate /* 164*7c478bd9Sstevel@tonic-gate * fc_transport() sleep parameter 165*7c478bd9Sstevel@tonic-gate */ 166*7c478bd9Sstevel@tonic-gate typedef enum { 167*7c478bd9Sstevel@tonic-gate FC_SLEEP, /* sleep on queue full */ 168*7c478bd9Sstevel@tonic-gate FC_NOSLEEP /* do not sleep on queue full */ 169*7c478bd9Sstevel@tonic-gate } fc_sleep_t; 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate 172*7c478bd9Sstevel@tonic-gate /* 173*7c478bd9Sstevel@tonic-gate * State changes related to the N-port interface communicated from below 174*7c478bd9Sstevel@tonic-gate */ 175*7c478bd9Sstevel@tonic-gate typedef enum { 176*7c478bd9Sstevel@tonic-gate FC_STATE_ONLINE, /* port has gone online */ 177*7c478bd9Sstevel@tonic-gate FC_STATE_OFFLINE, /* port has gone offline */ 178*7c478bd9Sstevel@tonic-gate FC_STATE_RESET /* port reset, all cmds lost */ 179*7c478bd9Sstevel@tonic-gate } fc_statec_t; 180*7c478bd9Sstevel@tonic-gate 181*7c478bd9Sstevel@tonic-gate typedef void * fc_statec_cookie_t; 182*7c478bd9Sstevel@tonic-gate 183*7c478bd9Sstevel@tonic-gate /* 184*7c478bd9Sstevel@tonic-gate * This structure is allocated by Fiber Channel Adaptor at INITCHILD time, 185*7c478bd9Sstevel@tonic-gate * and is communicated to the child by ddi_set_driver_private(). 186*7c478bd9Sstevel@tonic-gate * It defines the vectors by which the child obtains soc 187*7c478bd9Sstevel@tonic-gate * driver services, and all other information the child 188*7c478bd9Sstevel@tonic-gate * may need about its parent. 189*7c478bd9Sstevel@tonic-gate */ 190*7c478bd9Sstevel@tonic-gate 191*7c478bd9Sstevel@tonic-gate typedef struct fc_transport { 192*7c478bd9Sstevel@tonic-gate void *fc_cookie; /* Which FC dev. */ 193*7c478bd9Sstevel@tonic-gate ddi_dma_lim_t *fc_dmalimp; /* FC ddi_dma_lim_t ptr. */ 194*7c478bd9Sstevel@tonic-gate ddi_dma_attr_t *fc_dma_attrp; /* FC ddi_dma_attr_t ptr. */ 195*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t fc_iblock; /* iblock for mutexes */ 196*7c478bd9Sstevel@tonic-gate kmutex_t fc_mtx; /* Locks for transport */ 197*7c478bd9Sstevel@tonic-gate kcondvar_t fc_cv; 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate /* 200*7c478bd9Sstevel@tonic-gate * Transport a command across the interface. 201*7c478bd9Sstevel@tonic-gate */ 202*7c478bd9Sstevel@tonic-gate int (*fc_transport)( 203*7c478bd9Sstevel@tonic-gate struct fc_packet *fc, 204*7c478bd9Sstevel@tonic-gate fc_sleep_t sleep); 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate /* 207*7c478bd9Sstevel@tonic-gate * Reset the transport. 208*7c478bd9Sstevel@tonic-gate */ 209*7c478bd9Sstevel@tonic-gate int (*fc_reset)( 210*7c478bd9Sstevel@tonic-gate struct fc_packet *fc); 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate /* 213*7c478bd9Sstevel@tonic-gate * Allocate an fc_packet structure. 214*7c478bd9Sstevel@tonic-gate */ 215*7c478bd9Sstevel@tonic-gate fc_packet_t *(*fc_pkt_alloc)( 216*7c478bd9Sstevel@tonic-gate void *cookie, 217*7c478bd9Sstevel@tonic-gate fc_sleep_t sleep); 218*7c478bd9Sstevel@tonic-gate 219*7c478bd9Sstevel@tonic-gate /* 220*7c478bd9Sstevel@tonic-gate * Free an fc_packet structure. 221*7c478bd9Sstevel@tonic-gate */ 222*7c478bd9Sstevel@tonic-gate void (*fc_pkt_free)( 223*7c478bd9Sstevel@tonic-gate void *cookie, 224*7c478bd9Sstevel@tonic-gate struct fc_packet *pkt); 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate /* 227*7c478bd9Sstevel@tonic-gate * Register a routine to handle state changes on the interface 228*7c478bd9Sstevel@tonic-gate * 229*7c478bd9Sstevel@tonic-gate * The arg parameter, along with an fc_statec_t parameter, will 230*7c478bd9Sstevel@tonic-gate * be passed to the callback routine on all state changes 231*7c478bd9Sstevel@tonic-gate * after initialization. 232*7c478bd9Sstevel@tonic-gate */ 233*7c478bd9Sstevel@tonic-gate fc_statec_cookie_t 234*7c478bd9Sstevel@tonic-gate (*fc_statec_register)( 235*7c478bd9Sstevel@tonic-gate void *cookie, 236*7c478bd9Sstevel@tonic-gate void (*callback)(void *, fc_statec_t), 237*7c478bd9Sstevel@tonic-gate void *arg); 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate /* 240*7c478bd9Sstevel@tonic-gate * Unregister a routine to handle state changes 241*7c478bd9Sstevel@tonic-gate */ 242*7c478bd9Sstevel@tonic-gate void (*fc_statec_unregister)( 243*7c478bd9Sstevel@tonic-gate void *cookie, 244*7c478bd9Sstevel@tonic-gate fc_statec_cookie_t statec_cookie); 245*7c478bd9Sstevel@tonic-gate 246*7c478bd9Sstevel@tonic-gate /* 247*7c478bd9Sstevel@tonic-gate * Run the interface in polling mode. This allows interface 248*7c478bd9Sstevel@tonic-gate * state changes, etc. to be processed when system interrupts 249*7c478bd9Sstevel@tonic-gate * are disabled. This is used mostly for error recovery. 250*7c478bd9Sstevel@tonic-gate * Too bad Fibre Channel doesn't have a common error policy for 251*7c478bd9Sstevel@tonic-gate * all protocols so that we could do error recovery at 252*7c478bd9Sstevel@tonic-gate * the lowest level instead of having kludges like this... 253*7c478bd9Sstevel@tonic-gate */ 254*7c478bd9Sstevel@tonic-gate void (*fc_interface_poll)( 255*7c478bd9Sstevel@tonic-gate void *cookie); 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate /* 258*7c478bd9Sstevel@tonic-gate * Unsolicited Command Interface 259*7c478bd9Sstevel@tonic-gate * 260*7c478bd9Sstevel@tonic-gate * This interface operates with the presumption that the 261*7c478bd9Sstevel@tonic-gate * higher level driver (child) will process unsolicited 262*7c478bd9Sstevel@tonic-gate * commands that pertain to its protocol such as FCP or FCIP. 263*7c478bd9Sstevel@tonic-gate */ 264*7c478bd9Sstevel@tonic-gate 265*7c478bd9Sstevel@tonic-gate /* 266*7c478bd9Sstevel@tonic-gate * Register a callback to be called in the event of an 267*7c478bd9Sstevel@tonic-gate * unsolicited command received by the soc for this child. 268*7c478bd9Sstevel@tonic-gate * No information is passed regarding the event, just that 269*7c478bd9Sstevel@tonic-gate * one occurred. The arg parameter to passed to the 270*7c478bd9Sstevel@tonic-gate * callback function as its parameter. 271*7c478bd9Sstevel@tonic-gate */ 272*7c478bd9Sstevel@tonic-gate fc_uc_cookie_t 273*7c478bd9Sstevel@tonic-gate (*fc_uc_register)( 274*7c478bd9Sstevel@tonic-gate void *cookie, 275*7c478bd9Sstevel@tonic-gate fc_devdata_t devdata, 276*7c478bd9Sstevel@tonic-gate void (*callback)(void *), 277*7c478bd9Sstevel@tonic-gate void *arg); 278*7c478bd9Sstevel@tonic-gate 279*7c478bd9Sstevel@tonic-gate /* 280*7c478bd9Sstevel@tonic-gate * Unregister a callback routine 281*7c478bd9Sstevel@tonic-gate */ 282*7c478bd9Sstevel@tonic-gate void (*fc_uc_unregister)( 283*7c478bd9Sstevel@tonic-gate void *cookie, 284*7c478bd9Sstevel@tonic-gate fc_uc_cookie_t uc_cookie); 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate /* 287*7c478bd9Sstevel@tonic-gate * Return information about the unsolicited command 288*7c478bd9Sstevel@tonic-gate * event in pkt. The pkt must be a fully allocated 289*7c478bd9Sstevel@tonic-gate * fc_packet structure, with a valid cmd dataseg 290*7c478bd9Sstevel@tonic-gate * pointer, in which the received cmd payload will 291*7c478bd9Sstevel@tonic-gate * be placed. The length of the allocated dataseg should 292*7c478bd9Sstevel@tonic-gate * be greater than or equal to the length of the received 293*7c478bd9Sstevel@tonic-gate * command payload, otherwise the entire command cannot 294*7c478bd9Sstevel@tonic-gate * be copied into the data segment. This function 295*7c478bd9Sstevel@tonic-gate * returns -1 in the event of an error, or the 296*7c478bd9Sstevel@tonic-gate * actual length of the received command payload. 297*7c478bd9Sstevel@tonic-gate */ 298*7c478bd9Sstevel@tonic-gate int (*fc_uc_get_pkt)( 299*7c478bd9Sstevel@tonic-gate void *cookie, 300*7c478bd9Sstevel@tonic-gate struct fc_packet *pkt); 301*7c478bd9Sstevel@tonic-gate 302*7c478bd9Sstevel@tonic-gate } fc_transport_t; 303*7c478bd9Sstevel@tonic-gate 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 306*7c478bd9Sstevel@tonic-gate } 307*7c478bd9Sstevel@tonic-gate #endif 308*7c478bd9Sstevel@tonic-gate 309*7c478bd9Sstevel@tonic-gate #endif /* !_SYS_FC4_FC_TRANSPORT_H */ 310