17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*602ca9eaScth * Common Development and Distribution License (the "License"). 6*602ca9eaScth * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*602ca9eaScth * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*602ca9eaScth * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate #ifndef _SYS_SCSI_ADAPTERS_FASCMD_H 267c478bd9Sstevel@tonic-gate #define _SYS_SCSI_ADAPTERS_FASCMD_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <sys/note.h> 317c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 327c478bd9Sstevel@tonic-gate #include <sys/scsi/scsi_types.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * The transport layer deals with things in terms of the following structure. 407c478bd9Sstevel@tonic-gate * Note that the target driver's view of things is the scsi_pkt that is 417c478bd9Sstevel@tonic-gate * enfolded as the first element of the following structure. 427c478bd9Sstevel@tonic-gate * 437c478bd9Sstevel@tonic-gate * the preferred the cdb size is 12. fas is a scsi2 HBA driver and 447c478bd9Sstevel@tonic-gate * rarely needs 16 byte cdb's 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * preferred pkt_private length in 64-bit quantities 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate #ifdef _LP64 517c478bd9Sstevel@tonic-gate #define PKT_PRIV_SIZE 2 527c478bd9Sstevel@tonic-gate #define PKT_PRIV_LEN 16 /* in bytes */ 537c478bd9Sstevel@tonic-gate #else /* _ILP32 */ 547c478bd9Sstevel@tonic-gate #define PKT_PRIV_SIZE 1 557c478bd9Sstevel@tonic-gate #define PKT_PRIV_LEN 8 /* in bytes */ 567c478bd9Sstevel@tonic-gate #endif 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #define PKT2CMD(pkt) ((struct fas_cmd *)(pkt)->pkt_ha_private) 607c478bd9Sstevel@tonic-gate #define CMD2PKT(sp) ((sp)->cmd_pkt) 617c478bd9Sstevel@tonic-gate 62*602ca9eaScth #define EXTCMD_SIZE (sizeof (struct fas_cmd) + scsi_pkt_size()) 63*602ca9eaScth #define EXTCMDS_STATUS_SIZE (sizeof (struct scsi_arq_status)) 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate struct fas_cmd { 667c478bd9Sstevel@tonic-gate struct scsi_pkt *cmd_pkt; /* the generic packet itself */ 677c478bd9Sstevel@tonic-gate struct fas_cmd *cmd_forw; /* ready fifo que link */ 687c478bd9Sstevel@tonic-gate uchar_t *cmd_cdbp; /* active command pointer */ 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate uint32_t cmd_data_count; /* aggregate data count */ 717c478bd9Sstevel@tonic-gate uint32_t cmd_cur_addr; /* current dma address */ 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate ushort_t cmd_qfull_retries; 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate ushort_t cmd_nwin; /* number of windows */ 767c478bd9Sstevel@tonic-gate ushort_t cmd_cur_win; /* current window */ 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate ushort_t cmd_saved_win; /* saved window */ 797c478bd9Sstevel@tonic-gate uint32_t cmd_saved_data_count; /* saved aggr. count */ 807c478bd9Sstevel@tonic-gate uint32_t cmd_saved_cur_addr; /* saved virt address */ 817c478bd9Sstevel@tonic-gate int cmd_pkt_flags; /* copy of pkt_flags */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate ddi_dma_handle_t cmd_dmahandle; /* dma handle */ 847c478bd9Sstevel@tonic-gate ddi_dma_cookie_t cmd_dmacookie; /* current dma cookie */ 857c478bd9Sstevel@tonic-gate uint32_t cmd_dmacount; /* total xfer count */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate uchar_t cmd_cdb[CDB_SIZE]; /* 12 byte cdb */ 887c478bd9Sstevel@tonic-gate uint_t cmd_flags; /* private flags */ 897c478bd9Sstevel@tonic-gate struct scsi_arq_status cmd_scb; 907c478bd9Sstevel@tonic-gate uint_t cmd_scblen; /* length of scb */ 917c478bd9Sstevel@tonic-gate uchar_t cmd_slot; 927c478bd9Sstevel@tonic-gate uchar_t cmd_age; /* cmd age (tagged queing) */ 937c478bd9Sstevel@tonic-gate uint_t cmd_cdblen; /* length of cdb */ 947c478bd9Sstevel@tonic-gate uint64_t cmd_pkt_private[PKT_PRIV_SIZE]; 957c478bd9Sstevel@tonic-gate uint_t cmd_privlen; /* length of tgt private */ 967c478bd9Sstevel@tonic-gate uchar_t cmd_tag[2]; /* command tag */ 977c478bd9Sstevel@tonic-gate uchar_t cmd_actual_cdblen; /* length of cdb */ 987c478bd9Sstevel@tonic-gate }; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per pkt", fas_cmd)) 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* 1037c478bd9Sstevel@tonic-gate * private data for arq pkt 1047c478bd9Sstevel@tonic-gate */ 1057c478bd9Sstevel@tonic-gate struct arq_private_data { 1067c478bd9Sstevel@tonic-gate struct buf *arq_save_bp; 1077c478bd9Sstevel@tonic-gate struct fas_cmd *arq_save_sp; 1087c478bd9Sstevel@tonic-gate }; 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* 1117c478bd9Sstevel@tonic-gate * A note about the cmd_cdb && cmd_scb structures: 1127c478bd9Sstevel@tonic-gate * 1137c478bd9Sstevel@tonic-gate * If the command allocation requested exceeds the size of CDB_SIZE, 1147c478bd9Sstevel@tonic-gate * the cdb will be allocated outside this structure (via kmem_zalloc) 1157c478bd9Sstevel@tonic-gate * The same applies to cmd_scb. 1167c478bd9Sstevel@tonic-gate */ 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate /* 1197c478bd9Sstevel@tonic-gate * These are the defined flags for this structure. 1207c478bd9Sstevel@tonic-gate */ 1217c478bd9Sstevel@tonic-gate #define CFLAG_CMDDISC 0x0001 /* cmd currently disconnected */ 1227c478bd9Sstevel@tonic-gate #define CFLAG_WATCH 0x0002 /* watchdog time for this command */ 1237c478bd9Sstevel@tonic-gate #define CFLAG_FINISHED 0x0004 /* command completed */ 1247c478bd9Sstevel@tonic-gate #define CFLAG_CHKSEG 0x0008 /* check cmd_data within seg */ 1257c478bd9Sstevel@tonic-gate #define CFLAG_COMPLETED 0x0010 /* completion routine called */ 1267c478bd9Sstevel@tonic-gate #define CFLAG_PREPARED 0x0020 /* pkt has been init'ed */ 1277c478bd9Sstevel@tonic-gate #define CFLAG_IN_TRANSPORT 0x0040 /* in use by host adapter driver */ 1287c478bd9Sstevel@tonic-gate #define CFLAG_RESTORE_PTRS 0x0080 /* implicit restore ptr on reconnect */ 1297c478bd9Sstevel@tonic-gate #define CFLAG_TRANFLAG 0x00ff /* covers transport part of flags */ 1307c478bd9Sstevel@tonic-gate #define CFLAG_CMDPROXY 0x000100 /* cmd is a 'proxy' command */ 1317c478bd9Sstevel@tonic-gate #define CFLAG_CMDARQ 0x000200 /* cmd is a 'rqsense' command */ 1327c478bd9Sstevel@tonic-gate #define CFLAG_DMAVALID 0x000400 /* dma mapping valid */ 1337c478bd9Sstevel@tonic-gate #define CFLAG_DMASEND 0x000800 /* data is going 'out' */ 1347c478bd9Sstevel@tonic-gate #define CFLAG_CMDIOPB 0x001000 /* this is an 'iopb' packet */ 1357c478bd9Sstevel@tonic-gate #define CFLAG_CDBEXTERN 0x002000 /* cdb kmem_alloc'd */ 1367c478bd9Sstevel@tonic-gate #define CFLAG_SCBEXTERN 0x004000 /* scb kmem_alloc'd */ 1377c478bd9Sstevel@tonic-gate #define CFLAG_FREE 0x008000 /* packet is on free list */ 1387c478bd9Sstevel@tonic-gate #define CFLAG_PRIVEXTERN 0x020000 /* target private kmem_alloc'd */ 1397c478bd9Sstevel@tonic-gate #define CFLAG_DMA_PARTIAL 0x040000 /* partial xfer OK */ 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1427c478bd9Sstevel@tonic-gate } 1437c478bd9Sstevel@tonic-gate #endif 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate #endif /* _SYS_SCSI_ADAPTERS_FASCMD_H */ 146