1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 3*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 4*7c478bd9Sstevel@tonic-gate */ 5*7c478bd9Sstevel@tonic-gate /* 6*7c478bd9Sstevel@tonic-gate * Copyright (c) 1999,2000 Michael Smith 7*7c478bd9Sstevel@tonic-gate * Copyright (c) 2000 BSDi 8*7c478bd9Sstevel@tonic-gate * All rights reserved. 9*7c478bd9Sstevel@tonic-gate * 10*7c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 11*7c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions 12*7c478bd9Sstevel@tonic-gate * are met: 13*7c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 14*7c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 15*7c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 16*7c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 17*7c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 18*7c478bd9Sstevel@tonic-gate * 19*7c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20*7c478bd9Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21*7c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22*7c478bd9Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23*7c478bd9Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24*7c478bd9Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25*7c478bd9Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26*7c478bd9Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27*7c478bd9Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28*7c478bd9Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29*7c478bd9Sstevel@tonic-gate * SUCH DAMAGE. 30*7c478bd9Sstevel@tonic-gate * 31*7c478bd9Sstevel@tonic-gate * Copyright (c) 2002 Eric Moore 32*7c478bd9Sstevel@tonic-gate * Copyright (c) 2002 LSI Logic Corporation 33*7c478bd9Sstevel@tonic-gate * All rights reserved. 34*7c478bd9Sstevel@tonic-gate * 35*7c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 36*7c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions 37*7c478bd9Sstevel@tonic-gate * are met: 38*7c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 39*7c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 40*7c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 41*7c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 42*7c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 43*7c478bd9Sstevel@tonic-gate * 3. The party using or redistributing the source code and binary forms 44*7c478bd9Sstevel@tonic-gate * agrees to the disclaimer below and the terms and conditions set forth 45*7c478bd9Sstevel@tonic-gate * herein. 46*7c478bd9Sstevel@tonic-gate * 47*7c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 48*7c478bd9Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 49*7c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 50*7c478bd9Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 51*7c478bd9Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 52*7c478bd9Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 53*7c478bd9Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 54*7c478bd9Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 55*7c478bd9Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56*7c478bd9Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57*7c478bd9Sstevel@tonic-gate * SUCH DAMAGE. 58*7c478bd9Sstevel@tonic-gate */ 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate #ifndef _AMRVAR_H 61*7c478bd9Sstevel@tonic-gate #define _AMRVAR_H 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 66*7c478bd9Sstevel@tonic-gate extern "C" { 67*7c478bd9Sstevel@tonic-gate #endif 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate #define AMR_DEBUG 70*7c478bd9Sstevel@tonic-gate #ifdef AMR_DEBUG 71*7c478bd9Sstevel@tonic-gate #define AMRDB_PRINT(fmt) if (amr_debug_var) cmn_err fmt 72*7c478bd9Sstevel@tonic-gate #else 73*7c478bd9Sstevel@tonic-gate #define AMRDB_PRINT(fmt) 74*7c478bd9Sstevel@tonic-gate #endif 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate #define AMRDB_PANIC(fmt) cmn_err fmt 77*7c478bd9Sstevel@tonic-gate 78*7c478bd9Sstevel@tonic-gate #define AMR_PERIODIC_TIMEOUT 60 79*7c478bd9Sstevel@tonic-gate #define AMR_RETRYCOUNT 10000 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate /* for scsi commands */ 82*7c478bd9Sstevel@tonic-gate #ifndef SD_MODE_SENSE_PAGE3_CODE 83*7c478bd9Sstevel@tonic-gate #define SD_MODE_SENSE_PAGE3_CODE 0x03 84*7c478bd9Sstevel@tonic-gate #endif 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate #ifndef SD_MODE_SENSE_PAGE4_CODE 87*7c478bd9Sstevel@tonic-gate #define SD_MODE_SENSE_PAGE4_CODE 0x04 88*7c478bd9Sstevel@tonic-gate #endif 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate #ifndef SCMD_SYNCHRONIZE_CACHE 91*7c478bd9Sstevel@tonic-gate #define SCMD_SYNCHRONIZE_CACHE 0x35 92*7c478bd9Sstevel@tonic-gate #endif 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate #define AMR_DEFAULT_SECTORS 512 95*7c478bd9Sstevel@tonic-gate #define AMR_DEFAULT_HEADS 255 96*7c478bd9Sstevel@tonic-gate #define AMR_DEFAULT_CYLINDERS 63 97*7c478bd9Sstevel@tonic-gate #define AMR_DEFAULT_ROTATIONS 10000 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate #define AMR_INQ_ADDITIONAL_LEN 31 100*7c478bd9Sstevel@tonic-gate #define AMR_INQ_ANSI_VER 2 101*7c478bd9Sstevel@tonic-gate #define AMR_INQ_RESP_DATA_FORMAT 2 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate #define AMR_PRODUCT_INFO_SIZE \ 104*7c478bd9Sstevel@tonic-gate sizeof (((struct scsi_inquiry *)(NULL))->inq_pid) 105*7c478bd9Sstevel@tonic-gate #define AMR_FIRMWARE_VER_SIZE \ 106*7c478bd9Sstevel@tonic-gate sizeof (((struct scsi_inquiry *)(NULL))->inq_revision) 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate #define AMR_LAST_COOKIE_TAG 0xffffffff 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate /* 111*7c478bd9Sstevel@tonic-gate * Per-logical-drive datastructure 112*7c478bd9Sstevel@tonic-gate */ 113*7c478bd9Sstevel@tonic-gate struct amr_logdrive 114*7c478bd9Sstevel@tonic-gate { 115*7c478bd9Sstevel@tonic-gate uint32_t al_size; 116*7c478bd9Sstevel@tonic-gate uint8_t al_state; 117*7c478bd9Sstevel@tonic-gate uint8_t al_properties; 118*7c478bd9Sstevel@tonic-gate }; 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate /* 121*7c478bd9Sstevel@tonic-gate * Per-command control structure. 122*7c478bd9Sstevel@tonic-gate */ 123*7c478bd9Sstevel@tonic-gate struct amr_command 124*7c478bd9Sstevel@tonic-gate { 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate struct amr_command *ac_prev; 127*7c478bd9Sstevel@tonic-gate struct amr_command *ac_next; 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate struct amr_softs *ac_softs; 130*7c478bd9Sstevel@tonic-gate uint8_t ac_slot; 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate uint8_t ac_status; 133*7c478bd9Sstevel@tonic-gate uint32_t ac_flags; 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate struct buf *ac_buf; 136*7c478bd9Sstevel@tonic-gate uint32_t cmdlen; 137*7c478bd9Sstevel@tonic-gate struct scsi_pkt *pkt; 138*7c478bd9Sstevel@tonic-gate 139*7c478bd9Sstevel@tonic-gate void *ac_data; 140*7c478bd9Sstevel@tonic-gate size_t ac_length; 141*7c478bd9Sstevel@tonic-gate uint32_t ac_dataphys; 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t sg_dma_handle; 144*7c478bd9Sstevel@tonic-gate ddi_dma_cookie_t sg_dma_cookie; 145*7c478bd9Sstevel@tonic-gate uint_t sg_dma_cookien; 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t buffer_dma_handle; 148*7c478bd9Sstevel@tonic-gate ddi_dma_cookie_t buffer_dma_cookie; 149*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t buffer_acc_handle; 150*7c478bd9Sstevel@tonic-gate uint_t num_of_cookie; 151*7c478bd9Sstevel@tonic-gate uint_t num_of_win; 152*7c478bd9Sstevel@tonic-gate uint_t current_cookie; 153*7c478bd9Sstevel@tonic-gate uint_t current_win; 154*7c478bd9Sstevel@tonic-gate uint32_t data_transfered; 155*7c478bd9Sstevel@tonic-gate uint32_t transfer_size; 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate struct amr_mailbox mailbox; 158*7c478bd9Sstevel@tonic-gate struct amr_sgentry sgtable[AMR_NSEG]; 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate time_t ac_timestamp; 161*7c478bd9Sstevel@tonic-gate }; 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate /* 164*7c478bd9Sstevel@tonic-gate * ac_flags values in amr_command 165*7c478bd9Sstevel@tonic-gate */ 166*7c478bd9Sstevel@tonic-gate #define AMR_CMD_DATAIN (1<<0) 167*7c478bd9Sstevel@tonic-gate #define AMR_CMD_DATAOUT (1<<1) 168*7c478bd9Sstevel@tonic-gate #define AMR_CMD_CCB_DATAIN (1<<2) 169*7c478bd9Sstevel@tonic-gate #define AMR_CMD_CCB_DATAOUT (1<<3) 170*7c478bd9Sstevel@tonic-gate #define AMR_CMD_PRIORITY (1<<4) 171*7c478bd9Sstevel@tonic-gate #define AMR_CMD_MAPPED (1<<5) 172*7c478bd9Sstevel@tonic-gate #define AMR_CMD_SLEEP (1<<6) 173*7c478bd9Sstevel@tonic-gate #define AMR_CMD_BUSY (1<<7) 174*7c478bd9Sstevel@tonic-gate #define AMR_CMD_PKT_CONSISTENT (1<<8) 175*7c478bd9Sstevel@tonic-gate #define AMR_CMD_PKT_DMA_PARTIAL (1<<9) 176*7c478bd9Sstevel@tonic-gate #define AMR_CMD_GOT_SLOT (1<<10) 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate struct sg_item { 179*7c478bd9Sstevel@tonic-gate struct amr_sgentry *sg_table; 180*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t sg_handle; 181*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t sg_acc_handle; 182*7c478bd9Sstevel@tonic-gate uint32_t sg_phyaddr; 183*7c478bd9Sstevel@tonic-gate }; 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate struct product_info { 186*7c478bd9Sstevel@tonic-gate uint8_t pi_firmware_ver[AMR_FIRMWARE_VER_SIZE+1]; 187*7c478bd9Sstevel@tonic-gate uint8_t pi_product_name[AMR_PRODUCT_INFO_SIZE+1]; 188*7c478bd9Sstevel@tonic-gate }; 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate /* 191*7c478bd9Sstevel@tonic-gate * Per-controller-instance data 192*7c478bd9Sstevel@tonic-gate */ 193*7c478bd9Sstevel@tonic-gate struct amr_softs 194*7c478bd9Sstevel@tonic-gate { 195*7c478bd9Sstevel@tonic-gate /* bus attachments */ 196*7c478bd9Sstevel@tonic-gate dev_info_t *dev_info_p; 197*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t pciconfig_handle; 198*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t regsmap_handle; 199*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t iblock_cookiep; 200*7c478bd9Sstevel@tonic-gate 201*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t mbox_dma_handle; 202*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t mbox_acc_handle; 203*7c478bd9Sstevel@tonic-gate ddi_dma_cookie_t mbox_dma_cookie; 204*7c478bd9Sstevel@tonic-gate uint_t mbox_dma_cookien; 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate /* controller limits and features */ 207*7c478bd9Sstevel@tonic-gate uint8_t maxio; /* maximum number of I/O transactions */ 208*7c478bd9Sstevel@tonic-gate uint8_t maxdrives; /* max number of logical drives */ 209*7c478bd9Sstevel@tonic-gate uint8_t maxchan; /* count of SCSI channels */ 210*7c478bd9Sstevel@tonic-gate 211*7c478bd9Sstevel@tonic-gate uint8_t amr_nlogdrives; 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate /* connected logical drives */ 214*7c478bd9Sstevel@tonic-gate struct amr_logdrive logic_drive[AMR_MAXLD]; 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate /* product info of the card */ 217*7c478bd9Sstevel@tonic-gate struct product_info amr_product_info; 218*7c478bd9Sstevel@tonic-gate 219*7c478bd9Sstevel@tonic-gate /* controller state */ 220*7c478bd9Sstevel@tonic-gate uint32_t state; 221*7c478bd9Sstevel@tonic-gate 222*7c478bd9Sstevel@tonic-gate struct amr_mailbox *mailbox; 223*7c478bd9Sstevel@tonic-gate void *mbox; 224*7c478bd9Sstevel@tonic-gate uint32_t mbox_phyaddr; 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate /* per-controller poll command */ 227*7c478bd9Sstevel@tonic-gate kmutex_t cmd_mutex; 228*7c478bd9Sstevel@tonic-gate kcondvar_t cmd_cv; 229*7c478bd9Sstevel@tonic-gate 230*7c478bd9Sstevel@tonic-gate uint32_t amr_busyslots; 231*7c478bd9Sstevel@tonic-gate struct amr_command *busycmd[AMR_MAXCMD]; 232*7c478bd9Sstevel@tonic-gate struct sg_item sg_items[AMR_MAXCMD]; 233*7c478bd9Sstevel@tonic-gate uint32_t sg_max_count; 234*7c478bd9Sstevel@tonic-gate struct amr_command *waiting_q_head; 235*7c478bd9Sstevel@tonic-gate struct amr_command *waiting_q_tail; 236*7c478bd9Sstevel@tonic-gate kmutex_t queue_mutex; 237*7c478bd9Sstevel@tonic-gate 238*7c478bd9Sstevel@tonic-gate /* periodic status check */ 239*7c478bd9Sstevel@tonic-gate timeout_id_t timeout_t; 240*7c478bd9Sstevel@tonic-gate kmutex_t periodic_mutex; 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate scsi_hba_tran_t *hba_tran; 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate ddi_taskq_t *amr_taskq; 245*7c478bd9Sstevel@tonic-gate uint32_t amr_interrupts_counter; 246*7c478bd9Sstevel@tonic-gate }; 247*7c478bd9Sstevel@tonic-gate 248*7c478bd9Sstevel@tonic-gate /* 249*7c478bd9Sstevel@tonic-gate * state values in amr_softs 250*7c478bd9Sstevel@tonic-gate */ 251*7c478bd9Sstevel@tonic-gate #define AMR_STATE_OPEN (1<<0) 252*7c478bd9Sstevel@tonic-gate #define AMR_STATE_SUSPEND (1<<1) 253*7c478bd9Sstevel@tonic-gate #define AMR_STATE_CARD_DETECTED (1<<2) 254*7c478bd9Sstevel@tonic-gate #define AMR_STATE_BUS_MASTER_ENABLED (1<<3) 255*7c478bd9Sstevel@tonic-gate #define AMR_STATE_SOFT_STATE_SETUP (1<<4) 256*7c478bd9Sstevel@tonic-gate #define AMR_STATE_PCI_CONFIG_SETUP (1<<5) 257*7c478bd9Sstevel@tonic-gate #define AMR_STATE_PCI_MEM_MAPPED (1<<6) 258*7c478bd9Sstevel@tonic-gate #define AMR_STATE_KMUTEX_INITED (1<<7) 259*7c478bd9Sstevel@tonic-gate #define AMR_STATE_MAILBOX_SETUP (1<<8) 260*7c478bd9Sstevel@tonic-gate #define AMR_STATE_SG_TABLES_SETUP (1<<9) 261*7c478bd9Sstevel@tonic-gate #define AMR_STATE_INTR_SETUP (1<<10) 262*7c478bd9Sstevel@tonic-gate #define AMR_STATE_TASKQ_SETUP (1<<11) 263*7c478bd9Sstevel@tonic-gate #define AMR_STATE_TRAN_SETUP (1<<12) 264*7c478bd9Sstevel@tonic-gate #define AMR_STATE_TIMEOUT_ENABLED (1<<13) 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 267*7c478bd9Sstevel@tonic-gate } 268*7c478bd9Sstevel@tonic-gate #endif 269*7c478bd9Sstevel@tonic-gate 270*7c478bd9Sstevel@tonic-gate #endif /* _AMRVAR_H */ 271