1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 1996, 1999-2000, 2002 Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate * Use is subject to license terms. 26*0Sstevel@tonic-gate */ 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate #ifndef _SYS_DADA_DADA_PKT_H 29*0Sstevel@tonic-gate #define _SYS_DADA_DADA_PKT_H 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate #include <sys/dada/dada_types.h> 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #ifdef __cplusplus 36*0Sstevel@tonic-gate extern "C" { 37*0Sstevel@tonic-gate #endif 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * DCD pkt definition. 42*0Sstevel@tonic-gate * 43*0Sstevel@tonic-gate * This structure defined the packet which is allocated by a library 44*0Sstevel@tonic-gate * function and handed to a target driver. The target driver fills 45*0Sstevel@tonic-gate * in some information, and passes it to the library for transport 46*0Sstevel@tonic-gate * to an addressed DCD devices. The host adapter found by the library 47*0Sstevel@tonic-gate * fills in some other information as the command is processed. When 48*0Sstevel@tonic-gate * the command completes (or can be taken no further) the function 49*0Sstevel@tonic-gate * specified in the pkt is called with a pointer to the packet as 50*0Sstevel@tonic-gate * argument. For fields within the packet, the target driver can 51*0Sstevel@tonic-gate * determine the success or failure of the command. 52*0Sstevel@tonic-gate */ 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate struct dcd_pkt { 56*0Sstevel@tonic-gate uchar_t *pkt_cdbp; /* pointer to command block */ 57*0Sstevel@tonic-gate uchar_t *pkt_scbp; /* ptr to status block */ 58*0Sstevel@tonic-gate int pkt_flags; /* Pkt flags */ 59*0Sstevel@tonic-gate int pkt_time; /* Completion timeout */ 60*0Sstevel@tonic-gate int pkt_scblen; /* Scb length */ 61*0Sstevel@tonic-gate int pkt_cdblen; /* Length of cdb */ 62*0Sstevel@tonic-gate uint_t pkt_state; /* State of command */ 63*0Sstevel@tonic-gate uint_t pkt_statistics; /* Statistics */ 64*0Sstevel@tonic-gate uint_t pkt_reason; /* reason or error stat */ 65*0Sstevel@tonic-gate uint_t pkt_secleft; /* remaining sectors */ 66*0Sstevel@tonic-gate void (*pkt_comp)(); /* Pkt Completion routine */ 67*0Sstevel@tonic-gate ssize_t pkt_resid; /* bytes not transfered */ 68*0Sstevel@tonic-gate daddr32_t pkt_startsec; /* Starting sector */ 69*0Sstevel@tonic-gate ataopaque_t pkt_private; /* Target drivers priV data */ 70*0Sstevel@tonic-gate ataopaque_t pkt_ha_private; /* HBA private data */ 71*0Sstevel@tonic-gate ataopaque_t pkt_passthru; /* pass through command ptr */ 72*0Sstevel@tonic-gate struct dcd_address pkt_address; /* destination address */ 73*0Sstevel@tonic-gate uint_t version_no; /* Version Number of this */ 74*0Sstevel@tonic-gate ushort_t reserved[2]; /* Reserved for future */ 75*0Sstevel@tonic-gate }; 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate /* 78*0Sstevel@tonic-gate * definition for the pkt_flags field. 79*0Sstevel@tonic-gate */ 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate /* 82*0Sstevel@tonic-gate * Following defines are generic. 83*0Sstevel@tonic-gate */ 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate #define FLAG_NOINTR 0x0001 /* Run command with no cmd completion */ 86*0Sstevel@tonic-gate /* callback; command has been complted */ 87*0Sstevel@tonic-gate /* up return from dcd_transport(9F) */ 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate #define FLAG_NODICON 0x0002 /* Even is overlap is possible donot do it */ 90*0Sstevel@tonic-gate #define FLAG_NOPARITY 0x0008 /* Run command without parity checking */ 91*0Sstevel@tonic-gate #define FLAG_FORCENOINTR\ 92*0Sstevel@tonic-gate 0x0010 /* Force command with to run in polled mode */ 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate #define FLAG_IMMEDIATE_CB\ 95*0Sstevel@tonic-gate 0x0800 /* Immediate callback on command completion */ 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate /* 99*0Sstevel@tonic-gate * The following flags are they needed ??? 100*0Sstevel@tonic-gate */ 101*0Sstevel@tonic-gate #define FLAG_SILENT 0x00010000 102*0Sstevel@tonic-gate #define FLAG_DIAGNOSE 0x00020000 103*0Sstevel@tonic-gate #define FLAG_ISOLATE 0x00040000 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate /* 107*0Sstevel@tonic-gate * Definitions for pkt_reason field. 108*0Sstevel@tonic-gate */ 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate /* 111*0Sstevel@tonic-gate * Following defines are generic. 112*0Sstevel@tonic-gate */ 113*0Sstevel@tonic-gate #define CMD_CMPLT 0 /* no transport errors - normal completion */ 114*0Sstevel@tonic-gate #define CMD_INCOMPLETE 1 /* transport stopped with not normal state */ 115*0Sstevel@tonic-gate #define CMD_DMA_DERR 2 /* dama direction error occurred */ 116*0Sstevel@tonic-gate #define CMD_TRAN_ERR 3 /* Unspecified transport error */ 117*0Sstevel@tonic-gate #define CMD_RESET 4 /* Target completed hard reset sequence */ 118*0Sstevel@tonic-gate #define CMD_ABORTED 5 /* Command transport aborted on request */ 119*0Sstevel@tonic-gate #define CMD_TIMEOUT 6 /* Command timedout */ 120*0Sstevel@tonic-gate #define CMD_DATA_OVR 7 /* Data Overrun */ 121*0Sstevel@tonic-gate #define CMD_CMD_OVR 8 /* Command Overrun - Not used */ 122*0Sstevel@tonic-gate #define CMD_STS_OVR 9 /* Status Overrun - Not used */ 123*0Sstevel@tonic-gate #define CMD_FATAL 10 /* There is a fatal error */ 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate /* 127*0Sstevel@tonic-gate * definitions for pkt_state field. 128*0Sstevel@tonic-gate */ 129*0Sstevel@tonic-gate #define STATE_SENT_CMD 0x04 /* Command successsully sent */ 130*0Sstevel@tonic-gate #define STATE_XFERRED_DATA 0x08 /* Data Transfer took place */ 131*0Sstevel@tonic-gate #define STATE_GOT_STATUS 0x10 /* Status got */ 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate /* 135*0Sstevel@tonic-gate * Definitions for pkt_statistics field 136*0Sstevel@tonic-gate */ 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate /* 139*0Sstevel@tonic-gate * Following defines are generic. 140*0Sstevel@tonic-gate */ 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate #define STAT_ATA_BUS_RESET 0x08 /* TBD */ 143*0Sstevel@tonic-gate #define STAT_ATA_DEV_RESET 0x10 /* TBD */ 144*0Sstevel@tonic-gate #define STAT_ATA_ABORTED 0x20 /* Command was aborted */ 145*0Sstevel@tonic-gate #define STAT_ATA_TERMINATED 0x80 /* Command was terminated */ 146*0Sstevel@tonic-gate #define STAT_ATA_TIMEOUT 0x40 /* Command experienced a timeout */ 147*0Sstevel@tonic-gate 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate /* 150*0Sstevel@tonic-gate * Following filds are appropriate depending on feature used. 151*0Sstevel@tonic-gate */ 152*0Sstevel@tonic-gate #define STAT_ATA_DISCON 0x01 /* Command is doing overlap processing */ 153*0Sstevel@tonic-gate #define STAT_ATA_SYNC 0x02 /* May be used for DMA transfers */ 154*0Sstevel@tonic-gate #define STAT_ATA_PERR 0x04 /* Command experienced a parity error */ 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate /* 158*0Sstevel@tonic-gate * Definitions for what dcd_transport returns 159*0Sstevel@tonic-gate */ 160*0Sstevel@tonic-gate #define TRAN_ACCEPT 1 161*0Sstevel@tonic-gate #define TRAN_BUSY 0 162*0Sstevel@tonic-gate #define TRAN_BADPKT -1 163*0Sstevel@tonic-gate #define TRAN_FATAL_ERROR -2 /* The hba cannot accept any pkt */ 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate #ifdef _KERNEL 167*0Sstevel@tonic-gate /* 168*0Sstevel@tonic-gate * Kernel function declarations 169*0Sstevel@tonic-gate */ 170*0Sstevel@tonic-gate 171*0Sstevel@tonic-gate #define ata_pkt_transport dcd_transport 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gate #ifdef __STDC__ 174*0Sstevel@tonic-gate extern int dcd_transport(struct dcd_pkt *); 175*0Sstevel@tonic-gate #else /* __STDC__ */ 176*0Sstevel@tonic-gate extern int dcd_transport(); 177*0Sstevel@tonic-gate #endif /* __STDC__ */ 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate #define DCD_POLL_TIMEOUT 60 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate #endif /* _KERNEL */ 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gate #ifdef __cplusplus 184*0Sstevel@tonic-gate } 185*0Sstevel@tonic-gate #endif 186*0Sstevel@tonic-gate 187*0Sstevel@tonic-gate #endif /* _SYS_DADA_DADA_PKT_H */ 188