10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*6640Scth * Common Development and Distribution License (the "License"). 6*6640Scth * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*6640Scth * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_1394_TARGETS_SCSA1394_CMD_H 270Sstevel@tonic-gate #define _SYS_1394_TARGETS_SCSA1394_CMD_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate /* 320Sstevel@tonic-gate * scsa1394 command 330Sstevel@tonic-gate */ 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <sys/scsi/scsi_types.h> 360Sstevel@tonic-gate #include <sys/1394/targets/scsa1394/sbp2.h> 370Sstevel@tonic-gate #include <sys/note.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #ifdef __cplusplus 400Sstevel@tonic-gate extern "C" { 410Sstevel@tonic-gate #endif 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* preferred pkt_private length in 64-bit quantities */ 440Sstevel@tonic-gate #ifdef _LP64 450Sstevel@tonic-gate #define SCSA1394_CMD_PRIV_SIZE 2 460Sstevel@tonic-gate #else /* _ILP32 */ 470Sstevel@tonic-gate #define SCSA1394_CMD_PRIV_SIZE 1 480Sstevel@tonic-gate #endif 490Sstevel@tonic-gate #define SCSA1394_CMD_PRIV_LEN (SCSA1394_CMD_PRIV_SIZE * sizeof (uint64_t)) 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* entry describing a page table segment */ 520Sstevel@tonic-gate typedef struct scsa1394_cmd_seg { 530Sstevel@tonic-gate size_t ss_len; 540Sstevel@tonic-gate uint64_t ss_daddr; 550Sstevel@tonic-gate uint64_t ss_baddr; 560Sstevel@tonic-gate t1394_addr_handle_t ss_addr_hdl; 570Sstevel@tonic-gate } scsa1394_cmd_seg_t; 580Sstevel@tonic-gate 590Sstevel@tonic-gate /* command packet structure */ 600Sstevel@tonic-gate typedef struct scsa1394_cmd { 610Sstevel@tonic-gate sbp2_task_t sc_task; /* corresponding SBP-2 task */ 620Sstevel@tonic-gate struct scsa1394_lun *sc_lun; /* lun it belongs to */ 630Sstevel@tonic-gate int sc_state; /* command state */ 640Sstevel@tonic-gate int sc_flags; /* command flags */ 650Sstevel@tonic-gate struct buf *sc_bp; /* data buffer */ 660Sstevel@tonic-gate struct scsi_pkt *sc_pkt; /* corresponding scsi pkt */ 670Sstevel@tonic-gate size_t sc_cdb_len; 680Sstevel@tonic-gate size_t sc_cdb_actual_len; 690Sstevel@tonic-gate size_t sc_scb_len; 700Sstevel@tonic-gate size_t sc_priv_len; 710Sstevel@tonic-gate uchar_t sc_cdb[SCSI_CDB_SIZE]; 720Sstevel@tonic-gate uchar_t sc_pkt_cdb[SCSI_CDB_SIZE]; 730Sstevel@tonic-gate struct scsi_arq_status sc_scb; 740Sstevel@tonic-gate uint64_t sc_priv[SCSA1394_CMD_PRIV_SIZE]; 750Sstevel@tonic-gate clock_t sc_start_time; 760Sstevel@tonic-gate int sc_timeout; 770Sstevel@tonic-gate 780Sstevel@tonic-gate /* DMA: command ORB */ 790Sstevel@tonic-gate ddi_dma_handle_t sc_orb_dma_hdl; 800Sstevel@tonic-gate ddi_acc_handle_t sc_orb_acc_hdl; 810Sstevel@tonic-gate ddi_dma_cookie_t sc_orb_dmac; 820Sstevel@tonic-gate t1394_addr_handle_t sc_orb_addr_hdl; 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* DMA: data buffer */ 850Sstevel@tonic-gate ddi_dma_handle_t sc_buf_dma_hdl; 860Sstevel@tonic-gate uint_t sc_buf_nsegs; /* # of segments/cookies */ 870Sstevel@tonic-gate uint_t sc_buf_nsegs_alloc; /* # of entries allocated */ 880Sstevel@tonic-gate scsa1394_cmd_seg_t *sc_buf_seg; /* segment array */ 890Sstevel@tonic-gate scsa1394_cmd_seg_t sc_buf_seg_mem; /* backstore for one segment */ 900Sstevel@tonic-gate uint_t sc_nwin; /* # windows */ 910Sstevel@tonic-gate uint_t sc_curwin; /* current window */ 920Sstevel@tonic-gate off_t sc_win_offset; /* current window offset */ 930Sstevel@tonic-gate size_t sc_win_len; /* current window length */ 940Sstevel@tonic-gate size_t sc_xfer_bytes; /* current xfer byte count */ 950Sstevel@tonic-gate size_t sc_xfer_blks; /* current xfer blk count */ 960Sstevel@tonic-gate 970Sstevel@tonic-gate /* DMA: page table */ 980Sstevel@tonic-gate ddi_dma_handle_t sc_pt_dma_hdl; 990Sstevel@tonic-gate ddi_acc_handle_t sc_pt_acc_hdl; 1000Sstevel@tonic-gate ddi_dma_cookie_t sc_pt_dmac; 1010Sstevel@tonic-gate caddr_t sc_pt_kaddr; 1020Sstevel@tonic-gate uint64_t sc_pt_baddr; 1030Sstevel@tonic-gate t1394_addr_handle_t sc_pt_addr_hdl; 1040Sstevel@tonic-gate size_t sc_pt_ent_alloc; /* # allocated entries */ 1050Sstevel@tonic-gate int sc_pt_cmd_size; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate /* for symbios mode only */ 1080Sstevel@tonic-gate int sc_lba; /* start LBA */ 1090Sstevel@tonic-gate int sc_blk_size; /* xfer block size */ 1100Sstevel@tonic-gate size_t sc_total_blks; /* total xfer blocks */ 1110Sstevel@tonic-gate size_t sc_resid_blks; /* blocks left */ 1120Sstevel@tonic-gate 113*6640Scth struct scsi_pkt sc_scsi_pkt; /* must be last */ 114*6640Scth /* embedded SCSI packet */ 115*6640Scth /* ... scsi_pkt_size() */ 1160Sstevel@tonic-gate } scsa1394_cmd_t; 117*6640Scth #define SCSA1394_CMD_SIZE (sizeof (struct scsa1394_cmd) - \ 118*6640Scth sizeof (struct scsi_pkt) + scsi_pkt_size()) 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per task", { scsa1394_cmd scsa1394_cmd_seg 1210Sstevel@tonic-gate scsi_pkt scsi_inquiry scsi_extended_sense scsi_cdb scsi_arq_status })) 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate #define PKT2CMD(pktp) ((scsa1394_cmd_t *)((pktp)->pkt_ha_private)) 1240Sstevel@tonic-gate #define CMD2PKT(cmdp) ((struct scsi_pkt *)((cmdp)->sc_pkt)) 1250Sstevel@tonic-gate #define TASK2CMD(task) ((scsa1394_cmd_t *)(task)->ts_drv_priv) 1260Sstevel@tonic-gate #define CMD2TASK(cmdp) ((sbp2_task_t *)&(cmdp)->sc_task) 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate /* state */ 1290Sstevel@tonic-gate enum { 1300Sstevel@tonic-gate SCSA1394_CMD_INIT, 1310Sstevel@tonic-gate SCSA1394_CMD_START, 1320Sstevel@tonic-gate SCSA1394_CMD_STATUS 1330Sstevel@tonic-gate }; 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate /* flags */ 1360Sstevel@tonic-gate enum { 1370Sstevel@tonic-gate SCSA1394_CMD_CDB_EXT = 0x0001, 1380Sstevel@tonic-gate SCSA1394_CMD_PRIV_EXT = 0x0002, 1390Sstevel@tonic-gate SCSA1394_CMD_SCB_EXT = 0x0004, 1400Sstevel@tonic-gate SCSA1394_CMD_EXT = (SCSA1394_CMD_CDB_EXT | 1410Sstevel@tonic-gate SCSA1394_CMD_PRIV_EXT | 1420Sstevel@tonic-gate SCSA1394_CMD_SCB_EXT), 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate SCSA1394_CMD_DMA_CDB_VALID = 0x0008, 1450Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_BIND_VALID = 0x0010, 1460Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_PT_VALID = 0x0020, 1470Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_ADDR_VALID = 0x0040, 1480Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_VALID = (SCSA1394_CMD_DMA_BUF_BIND_VALID | 1490Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_ADDR_VALID | 1500Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_PT_VALID), 1510Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_MAPIN = 0x0080, 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate SCSA1394_CMD_READ = 0x0100, 1540Sstevel@tonic-gate SCSA1394_CMD_WRITE = 0x0200, 1550Sstevel@tonic-gate SCSA1394_CMD_RDWR = (SCSA1394_CMD_READ | 1560Sstevel@tonic-gate SCSA1394_CMD_WRITE), 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate SCSA1394_CMD_SYMBIOS_BREAKUP = 0x400 1590Sstevel@tonic-gate }; 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate #ifdef __cplusplus 1620Sstevel@tonic-gate } 1630Sstevel@tonic-gate #endif 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate #endif /* _SYS_1394_TARGETS_SCSA1394_CMD_H */ 166