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