80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * This file and its contents are supplied under the terms of the
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Common Development and Distribution License ("CDDL"), version 1.0.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * You may only use this file in accordance with the terms of version
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 1.0 of the CDDL.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * A full copy of the text of the CDDL should have accompanied this
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * source. A copy of the CDDL is also available via the Internet at
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * http://www.illumos.org/license/CDDL.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#ifndef _CPQARY3_H
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define _CPQARY3_H
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/types.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/pci.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/param.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/errno.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/conf.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/map.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/modctl.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/kmem.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/cmn_err.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/stat.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/scsi/scsi.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/devops.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/ddi.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/sunddi.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <cpqary3_ciss.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <cpqary3_bd.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#ifdef __cplusplus
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiextern "C" {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#endif
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Ioctl Commands
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_IOCTL_CMD ('c' << 4)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_IOCTL_DRIVER_INFO CPQARY3_IOCTL_CMD | 0x01
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_IOCTL_CTLR_INFO CPQARY3_IOCTL_CMD | 0x02
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_IOCTL_BMIC_PASS CPQARY3_IOCTL_CMD | 0x04
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_IOCTL_SCSI_PASS CPQARY3_IOCTL_CMD | 0x08
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* Driver Revision : Used in Ioctl */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_MINOR_REV_NO 00
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_MAJOR_REV_NO 01
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_REV_DATE 05
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_REV_MONTH 04
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_REV_YEAR 2001
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* Some Useful definations */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_FAILURE 0
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_SUCCESS 1
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_SENT 2
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_SUBMITTED 3
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_NO_SIG 4
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_TRUE 1
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_FALSE 0
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CTLR_SCSI_ID 7
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_LD_FAILED 1
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Defines for cleanup in cpqary3_attach and cpqary3_detach.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_HBA_TRAN_ALLOC_DONE 0x0001
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_HBA_TRAN_ATTACH_DONE 0x0002
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_CTLR_CONFIG_DONE 0x0004
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_INTR_HDLR_SET 0x0008
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_CREATE_MINOR_NODE 0x0010
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_SOFTSTATE_ALLOC_DONE 0x0020
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_MUTEX_INIT_DONE 0x0040
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_TICK_TMOUT_REGD 0x0080
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_MEM_MAPPED 0x0100
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_SW_INTR_HDLR_SET 0x0200
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_SW_MUTEX_INIT_DONE 0x0400
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_NOE_INIT_DONE 0x0800
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_CLEAN_ALL 0x0FFF
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_TICKTMOUT_VALUE 180000000 /* 180 seconds */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Defines for Maximum and Default Settings.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define MAX_LOGDRV 64 /* Max supported Logical Drivers */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define MAX_CTLRS 8 /* Max supported Controllers */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define MAX_TAPE 28
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * NOTE: When changing the below two entries, Max SG count in cpqary3_ciss.h
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * should also be changed.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define MAX_PERF_SG_CNT 64 /* Maximum S/G in performant mode */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_SG_CNT 30 /* minimum S/G in simple mode */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_PERF_SG_CNT 31 /* minimum S/G for performant mode */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_MAX_TGT (MAX_LOGDRV + MAX_TAPE + 1)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * SCSI Capabilities Related IDs
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_CAP_DISCON_ENABLED 0x01
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_CAP_SYNC_ENABLED 0x02
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_CAP_WIDE_XFER_ENABLED 0x04
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_CAP_ARQ_ENABLED 0x08
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_CAP_TAG_QING_ENABLED 0x10
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_CAP_TAG_QING_SUPP 0x20
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_CAP_UNTAG_DRV_QING_ENABLED 0x40
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Defines for HBA
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CAP_NOT_DEFINED -1
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CAP_CHG_NOT_ALLOWED 0
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CAP_CHG_SUCCESS 1
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Macros for Data Access
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* SCSI Addr to Per Controller */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define SA2CTLR(saddr) ((cpqary3_t *)((saddr)->a_hba_tran->tran_hba_private))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define SA2TGT(sa) (sa)->a_target /* SCSI Addr to Target ID */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define SD2TGT(sd) (sd)->sd_address.a_target /* SCSI Dev to Target ID */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define SD2LUN(sd) (sd)->sd_address.a_lun /* SCSI Dev to Lun */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define SD2SA(sd) ((sd)->sd_address) /* SCSI Dev to SCSI Addr */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* SCSI Dev to Per Controller */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define SD2CTLR(sd) \
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ((cpqary3_t *)sd->sd_address.a_hba_tran->tran_hba_private)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define PKT2PVTPKT(sp) ((cpqary3_pkt_t *)((sp)->pkt_ha_private))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define PVTPKT2MEM(p) ((cpqary3_cmdpvt_t *)p->memp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define MEM2CMD(m) ((CommandList_t *)m->cmdlist_memaddr)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define SP2CMD(sp) MEM2CMD(PVTPKT2MEM(PKT2PVTPKT(sp)))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CTLR2MEMLISTP(ctlr) ((cpqary3_cmdmemlist_t *)ctlr->cmdmemlistp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define MEM2PVTPKT(m) ((cpqary3_pkt_t *)m->pvt_pkt)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define MEM2DRVPVT(m) ((cpqary3_private_t *)m->driverdata)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define TAG2MEM(ctlr, tag) \
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ((cpqary3_cmdpvt_t *)(CTLR2MEMLISTP(ctlr)->pool[tag]))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* MACROS */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_MIN(x, y) (x < y ? x : y)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_SWAP(val) ((val >> 8) | ((val & 0xff) << 8))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define RETURN_VOID_IF_NULL(x) if (NULL == x) return
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define RETURN_NULL_IF_NULL(x) if (NULL == x) return (NULL)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define RETURN_FAILURE_IF_NULL(x) if (NULL == x) return (CPQARY3_FAILURE)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Macros for memory allocation/deallocations
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define MEM_ZALLOC(x) kmem_zalloc(x, KM_NOSLEEP)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define MEM_SFREE(x, y) if (x) kmem_free((void*)x, y)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Convenient macros for reading/writing Configuration table registers
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define DDI_GET8(ctlr, regp) \
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_get8((ctlr)->ct_handle, (uint8_t *)(regp))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define DDI_PUT8(ctlr, regp, value) \
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_put8((ctlr)->ct_handle, (uint8_t *)(regp), (value))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define DDI_GET16(ctlr, regp) \
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_get16((ctlr)->ct_handle, (uint16_t *)(regp))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define DDI_PUT16(ctlr, regp, value) \
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_put16((ctlr)->ct_handle, (uint16_t *)(regp), (value))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define DDI_GET32(ctlr, regp) \
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_get32((ctlr)->ct_handle, (uint32_t *)(regp))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define DDI_PUT32(ctlr, regp, value) \
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_put32((ctlr)->ct_handle, (uint32_t *)(regp), (value))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* PERF */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define DDI_PUT32_CP(ctlr, regp, value) \
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_put32((ctlr)->cp_handle, (uint32_t *)(regp), (value))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* PERF */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_BUFFER_ERROR_CLEAR 0x0 /* to be used with bioerror */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_DMA_NO_CALLBACK 0x0 /* to be used with DMA calls */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_DMA_ALLOC_HANDLE_DONE 0x01
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_DMA_ALLOC_MEM_DONE 0x02
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_DMA_BIND_ADDR_DONE 0x04
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_FREE_PHYCTG_MEM 0x07
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_SYNCCMD_SEND_WAITSIG (0x0001)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Include the driver specific relevant header files here.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include "cpqary3_ciss.h"
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include "cpqary3_q_mem.h"
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include "cpqary3_noe.h"
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include "cpqary3_scsi.h"
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include "cpqary3_ioctl.h"
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Per Target Structure
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskitypedef struct cpqary3_target {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t logical_id : 30; /* at most 64 : 63 drives + 1 CTLR */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t type : 2; /* NONE, CTLR, LOGICAL DRIVE, TAPE */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski PhysDevAddr_t PhysID;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski union {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t id;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t bus;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } scsi; /* To support tapes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t heads;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t sectors;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } drive; /* Logical drives */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } properties;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t ctlr_flags;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dev_info_t *tgt_dip;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_attr_t dma_attrs;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski} cpqary3_tgt_t;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Values for the type field in the Per Target Structure (above)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_TARGET_NONE 0 /* No Device */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_TARGET_CTLR 1 /* Controller */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_TARGET_LOG_VOL 2 /* Logical Volume */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CPQARY3_TARGET_TAPE 3 /* SCSI Device - Tape */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Index into PCI Configuration Registers for Base Address Registers(BAR)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Currently, only index for BAR 0 and BAR 1 are defined
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INDEX_PCI_BASE0 1 /* offset 0x10 */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INDEX_PCI_BASE1 2 /* offset 0x14 */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* Offset Values for IO interface from BAR 0 */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INBOUND_DOORBELL 0x20
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define OUTBOUND_LIST_STATUS 0x30
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define OUTBOUND_INTERRUPT_MASK 0x34
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INBOUND_QUEUE 0x40
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define OUTBOUND_QUEUE 0x44
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* Offset Values for IO interface from BAR 1 */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CONFIGURATION_TABLE 0x00
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INTR_DISABLE_5300_MASK 0x00000008l
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INTR_DISABLE_5I_MASK 0x00000004l
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define OUTBOUND_LIST_5300_EXISTS 0x00000008l
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define OUTBOUND_LIST_5I_EXISTS 0x00000004l
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INTR_PERF_MASK 0x00000001l
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INTR_PERF_LOCKUP_MASK 0x00000004l
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INTR_E200_PERF_MASK 0x00000004l
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INTR_SIMPLE_MASK 0x00000008l
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INTR_SIMPLE_LOCKUP_MASK 0x0000000cl
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INTR_SIMPLE_5I_MASK 0x00000004l
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define INTR_SIMPLE_5I_LOCKUP_MASK 0x0000000cl
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskitypedef struct cpqary3_per_controller CTLR;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Per Controller Structure
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskitypedef struct cpqary3_per_controller {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* System Dependent Entities */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t bus;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t dev : 5;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t fun : 3;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t instance;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dev_info_t *dip;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Controller Specific Information */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int8_t hba_name[38];
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ulong_t num_of_targets;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t heartbeat;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t board_id;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_bd_t *bddef;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Condition Variables used */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski kcondvar_t cv_immediate_wait;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski kcondvar_t cv_noe_wait;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski kcondvar_t cv_flushcache_wait;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski kcondvar_t cv_abort_wait;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski kcondvar_t cv_ioctl_wait; /* Variable for ioctls */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * CPQary3 driver related entities related to :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Hardware & Software Interrupts, Cookies & Mutex.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Timeout Handler
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Driver Transport Layer/Structure
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Database for the per-controller Command Memory Pool
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Target List for the per-controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t irq; /* h/w IRQ */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_iblock_cookie_t hw_iblock_cookie; /* cookie for h/w intr */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski kmutex_t hw_mutex; /* h/w mutex */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_iblock_cookie_t sw_iblock_cookie; /* cookie for s/w intr */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski kmutex_t sw_mutex; /* s/w mutex */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_softintr_t cpqary3_softintr_id; /* s/w intr identifier */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t swintr_flag;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski timeout_id_t tick_tmout_id; /* timeout identifier */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t cpqary3_tick_hdlr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_hba_tran_t *hba_tran; /* transport structure */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdmemlist_t *cmdmemlistp; /* database - Memory Pool */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_tgt_t *cpqary3_tgtp[CPQARY3_MAX_TGT];
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_drvr_replyq_t *drvr_replyq;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t (*check_ctlr_intr)(CTLR *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * PCI Configuration Registers
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x10 Primary I2O Memory BAR - for Host Interface
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x14 Primary DRAM 1 BAR - for Transport Configuration Table
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Host Interface Registers
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Offset from Primary I2O Memory BAR
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x20 Inbound Doorbell - for interrupting controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x30 Outbound List Status - for signalling status of Reply Q
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x34 Outbound Interrupt Mask - for masking Interrupts to host
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x40 Host Inbound Queue - Request Q
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x44 Host Outbound Queue - reply Q
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Offset from Primary DRAM 1 BAR
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x00 Configuration Table - for Controller Transport Layer
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t *idr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_acc_handle_t idr_handle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* LOCKUP CODE */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t *spr0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_acc_handle_t spr0_handle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* LOCKUP CODE */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t *odr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_acc_handle_t odr_handle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t *odr_cl;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_acc_handle_t odr_cl_handle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t *isr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_acc_handle_t isr_handle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t *imr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_acc_handle_t imr_handle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t *ipq;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_acc_handle_t ipq_handle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t *opq;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_acc_handle_t opq_handle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CfgTable_t *ct;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_acc_handle_t ct_handle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CfgTrans_Perf_t *cp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_acc_handle_t cp_handle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t legacy_mapping;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t noe_support;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t sg_cnt;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t ctlr_maxcmds;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t host_support;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t controller_lockup;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t lockup_logged;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t poll_flag;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski} cpqary3_t;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Private Structure for Self Issued Commands
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskitypedef struct cpqary3_driver_private {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski void *sg;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_phyctg_t *phyctgp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}cpqary3_private_t;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* cmd_flags */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CFLAG_DMASEND 0x01
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CFLAG_CMDIOPB 0x02
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#define CFLAG_DMAVALID 0x04
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Driver Private Packet
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskitypedef struct cpqary3_pkt {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct scsi_pkt *scsi_cmd_pkt;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_win_t prev_winp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_seg_t prev_segp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski clock_t cmd_start_time;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_cookie_t cmd_dmacookies[MAX_PERF_SG_CNT];
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t cmd_ncookies;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t cmd_cookie;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t cmd_cookiecnt;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t cmd_nwin;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t cmd_curwin;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski off_t cmd_dma_offset;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski size_t cmd_dma_len;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski size_t cmd_dmacount;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct buf *bf;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_handle_t cmd_dmahandle;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t bytes;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t cmd_flags;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t cdb_len;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t scb_len;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvt_t *memp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski} cpqary3_pkt_t;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#pragma pack(1)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskitypedef struct cpqary3_ioctlresp {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Driver Revision */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct cpqary3_revision {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t minor; /* Version */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t major;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t mm; /* Revision Date */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t dd;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint16_t yyyy;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } cpqary3_drvrev;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* HBA Info */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct cpqary3_ctlr {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t num_of_tgts; /* No of Logical Drive */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint8_t *name;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } cpqary3_ctlr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski} cpqary3_ioctlresp_t;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskitypedef struct cpqary3_ioctlreq {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_ioctlresp_t *cpqary3_ioctlrespp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski} cpqary3_ioctlreq_t;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#pragma pack()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* Driver function definitions */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_init_hbatran(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_read_conf_file(dev_info_t *, cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_tick_hdlr(void *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_flush_cache(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_intr_onoff(cpqary3_t *, uint8_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_lockup_intr_onoff(cpqary3_t *, uint8_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint8_t cpqary3_disable_NOE_command(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint8_t cpqary3_send_NOE_command(cpqary3_t *, cpqary3_cmdpvt_t *, uint8_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint16_t cpqary3_init_ctlr_resource(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint32_t cpqary3_hw_isr(caddr_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint32_t cpqary3_sw_isr(caddr_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint32_t cpqary3_ioctl_driver_info(uintptr_t, int);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint32_t cpqary3_ioctl_ctlr_info(uintptr_t, cpqary3_t *, int);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint32_t cpqary3_ioctl_bmic_pass(uintptr_t, cpqary3_t *, int);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint32_t cpqary3_ioctl_scsi_pass(uintptr_t, cpqary3_t *, int);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint8_t cpqary3_probe4targets(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_cmdlist_release(cpqary3_cmdpvt_t *, uint8_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint32_t cpqary3_submit(cpqary3_t *, uint32_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_free_phyctgs_mem(cpqary3_phyctg_t *, uint8_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicaddr_t cpqary3_alloc_phyctgs_mem(cpqary3_t *, size_t, uint32_t *,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_phyctg_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_cmdpvt_t *cpqary3_cmdlist_occupy(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_synccmd_complete(cpqary3_cmdpvt_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_NOE_handler(cpqary3_cmdpvt_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint8_t cpqary3_retrieve(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_synccmd_cleanup(cpqary3_cmdpvt_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint cpqary3_target_geometry(struct scsi_address *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint8_t cpqary3_send_abortcmd(cpqary3_t *, uint16_t, CommandList_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_memfini(cpqary3_t *, uint8_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint8_t cpqary3_init_ctlr(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint16_t cpqary3_meminit(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_noe_complete(cpqary3_cmdpvt_t *cpqary3_cmdpvtp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_cmdpvt_t *cpqary3_synccmd_alloc(cpqary3_t *, size_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_synccmd_free(cpqary3_t *, cpqary3_cmdpvt_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint cpqary3_synccmd_send(cpqary3_t *, cpqary3_cmdpvt_t *, clock_t, int);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint8_t cpqary3_poll_retrieve(cpqary3_t *cpqary3p, uint32_t poll_tag);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint8_t cpqary3_build_cmdlist(cpqary3_cmdpvt_t *cpqary3_cmdpvtp, uint32_t tid);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#ifdef __cplusplus
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#endif
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#endif /* _CPQARY3_H */