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. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_1394_TARGETS_SCSA1394_CMD_H 277c478bd9Sstevel@tonic-gate #define _SYS_1394_TARGETS_SCSA1394_CMD_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * scsa1394 command 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/scsi/scsi_types.h> 347c478bd9Sstevel@tonic-gate #include <sys/1394/targets/scsa1394/sbp2.h> 357c478bd9Sstevel@tonic-gate #include <sys/note.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* preferred pkt_private length in 64-bit quantities */ 427c478bd9Sstevel@tonic-gate #ifdef _LP64 437c478bd9Sstevel@tonic-gate #define SCSA1394_CMD_PRIV_SIZE 2 447c478bd9Sstevel@tonic-gate #else /* _ILP32 */ 457c478bd9Sstevel@tonic-gate #define SCSA1394_CMD_PRIV_SIZE 1 467c478bd9Sstevel@tonic-gate #endif 477c478bd9Sstevel@tonic-gate #define SCSA1394_CMD_PRIV_LEN (SCSA1394_CMD_PRIV_SIZE * sizeof (uint64_t)) 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* entry describing a page table segment */ 507c478bd9Sstevel@tonic-gate typedef struct scsa1394_cmd_seg { 517c478bd9Sstevel@tonic-gate size_t ss_len; 527c478bd9Sstevel@tonic-gate uint64_t ss_daddr; 537c478bd9Sstevel@tonic-gate uint64_t ss_baddr; 547c478bd9Sstevel@tonic-gate t1394_addr_handle_t ss_addr_hdl; 557c478bd9Sstevel@tonic-gate } scsa1394_cmd_seg_t; 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* command packet structure */ 587c478bd9Sstevel@tonic-gate typedef struct scsa1394_cmd { 597c478bd9Sstevel@tonic-gate sbp2_task_t sc_task; /* corresponding SBP-2 task */ 607c478bd9Sstevel@tonic-gate struct scsa1394_lun *sc_lun; /* lun it belongs to */ 617c478bd9Sstevel@tonic-gate int sc_state; /* command state */ 627c478bd9Sstevel@tonic-gate int sc_flags; /* command flags */ 637c478bd9Sstevel@tonic-gate struct buf *sc_bp; /* data buffer */ 647c478bd9Sstevel@tonic-gate struct scsi_pkt *sc_pkt; /* corresponding scsi pkt */ 657c478bd9Sstevel@tonic-gate size_t sc_cdb_len; 667c478bd9Sstevel@tonic-gate size_t sc_cdb_actual_len; 677c478bd9Sstevel@tonic-gate size_t sc_scb_len; 687c478bd9Sstevel@tonic-gate size_t sc_priv_len; 697c478bd9Sstevel@tonic-gate uchar_t sc_cdb[SCSI_CDB_SIZE]; 707c478bd9Sstevel@tonic-gate uchar_t sc_pkt_cdb[SCSI_CDB_SIZE]; 717c478bd9Sstevel@tonic-gate struct scsi_arq_status sc_scb; 727c478bd9Sstevel@tonic-gate uint64_t sc_priv[SCSA1394_CMD_PRIV_SIZE]; 737c478bd9Sstevel@tonic-gate clock_t sc_start_time; 747c478bd9Sstevel@tonic-gate int sc_timeout; 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* DMA: command ORB */ 777c478bd9Sstevel@tonic-gate ddi_dma_handle_t sc_orb_dma_hdl; 787c478bd9Sstevel@tonic-gate ddi_acc_handle_t sc_orb_acc_hdl; 797c478bd9Sstevel@tonic-gate ddi_dma_cookie_t sc_orb_dmac; 807c478bd9Sstevel@tonic-gate t1394_addr_handle_t sc_orb_addr_hdl; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* DMA: data buffer */ 837c478bd9Sstevel@tonic-gate ddi_dma_handle_t sc_buf_dma_hdl; 847c478bd9Sstevel@tonic-gate uint_t sc_buf_nsegs; /* # of segments/cookies */ 857c478bd9Sstevel@tonic-gate uint_t sc_buf_nsegs_alloc; /* # of entries allocated */ 867c478bd9Sstevel@tonic-gate scsa1394_cmd_seg_t *sc_buf_seg; /* segment array */ 877c478bd9Sstevel@tonic-gate scsa1394_cmd_seg_t sc_buf_seg_mem; /* backstore for one segment */ 887c478bd9Sstevel@tonic-gate uint_t sc_nwin; /* # windows */ 897c478bd9Sstevel@tonic-gate uint_t sc_curwin; /* current window */ 907c478bd9Sstevel@tonic-gate off_t sc_win_offset; /* current window offset */ 917c478bd9Sstevel@tonic-gate size_t sc_win_len; /* current window length */ 927c478bd9Sstevel@tonic-gate size_t sc_xfer_bytes; /* current xfer byte count */ 937c478bd9Sstevel@tonic-gate size_t sc_xfer_blks; /* current xfer blk count */ 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* DMA: page table */ 967c478bd9Sstevel@tonic-gate ddi_dma_handle_t sc_pt_dma_hdl; 977c478bd9Sstevel@tonic-gate ddi_acc_handle_t sc_pt_acc_hdl; 987c478bd9Sstevel@tonic-gate ddi_dma_cookie_t sc_pt_dmac; 997c478bd9Sstevel@tonic-gate caddr_t sc_pt_kaddr; 1007c478bd9Sstevel@tonic-gate uint64_t sc_pt_baddr; 1017c478bd9Sstevel@tonic-gate t1394_addr_handle_t sc_pt_addr_hdl; 1027c478bd9Sstevel@tonic-gate size_t sc_pt_ent_alloc; /* # allocated entries */ 1037c478bd9Sstevel@tonic-gate int sc_pt_cmd_size; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate /* for symbios mode only */ 1067c478bd9Sstevel@tonic-gate int sc_lba; /* start LBA */ 1077c478bd9Sstevel@tonic-gate int sc_blk_size; /* xfer block size */ 1087c478bd9Sstevel@tonic-gate size_t sc_total_blks; /* total xfer blocks */ 1097c478bd9Sstevel@tonic-gate size_t sc_resid_blks; /* blocks left */ 1107c478bd9Sstevel@tonic-gate 111*602ca9eaScth struct scsi_pkt sc_scsi_pkt; /* must be last */ 112*602ca9eaScth /* embedded SCSI packet */ 113*602ca9eaScth /* ... scsi_pkt_size() */ 1147c478bd9Sstevel@tonic-gate } scsa1394_cmd_t; 115*602ca9eaScth #define SCSA1394_CMD_SIZE (sizeof (struct scsa1394_cmd) - \ 116*602ca9eaScth sizeof (struct scsi_pkt) + scsi_pkt_size()) 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per task", { scsa1394_cmd scsa1394_cmd_seg 1197c478bd9Sstevel@tonic-gate scsi_pkt scsi_inquiry scsi_extended_sense scsi_cdb scsi_arq_status })) 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #define PKT2CMD(pktp) ((scsa1394_cmd_t *)((pktp)->pkt_ha_private)) 1227c478bd9Sstevel@tonic-gate #define CMD2PKT(cmdp) ((struct scsi_pkt *)((cmdp)->sc_pkt)) 1237c478bd9Sstevel@tonic-gate #define TASK2CMD(task) ((scsa1394_cmd_t *)(task)->ts_drv_priv) 1247c478bd9Sstevel@tonic-gate #define CMD2TASK(cmdp) ((sbp2_task_t *)&(cmdp)->sc_task) 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* state */ 1277c478bd9Sstevel@tonic-gate enum { 1287c478bd9Sstevel@tonic-gate SCSA1394_CMD_INIT, 1297c478bd9Sstevel@tonic-gate SCSA1394_CMD_START, 1307c478bd9Sstevel@tonic-gate SCSA1394_CMD_STATUS 1317c478bd9Sstevel@tonic-gate }; 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate /* flags */ 1347c478bd9Sstevel@tonic-gate enum { 1357c478bd9Sstevel@tonic-gate SCSA1394_CMD_CDB_EXT = 0x0001, 1367c478bd9Sstevel@tonic-gate SCSA1394_CMD_PRIV_EXT = 0x0002, 1377c478bd9Sstevel@tonic-gate SCSA1394_CMD_SCB_EXT = 0x0004, 1387c478bd9Sstevel@tonic-gate SCSA1394_CMD_EXT = (SCSA1394_CMD_CDB_EXT | 1397c478bd9Sstevel@tonic-gate SCSA1394_CMD_PRIV_EXT | 1407c478bd9Sstevel@tonic-gate SCSA1394_CMD_SCB_EXT), 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate SCSA1394_CMD_DMA_CDB_VALID = 0x0008, 1437c478bd9Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_BIND_VALID = 0x0010, 1447c478bd9Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_PT_VALID = 0x0020, 1457c478bd9Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_ADDR_VALID = 0x0040, 1467c478bd9Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_VALID = (SCSA1394_CMD_DMA_BUF_BIND_VALID | 1477c478bd9Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_ADDR_VALID | 1487c478bd9Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_PT_VALID), 1497c478bd9Sstevel@tonic-gate SCSA1394_CMD_DMA_BUF_MAPIN = 0x0080, 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate SCSA1394_CMD_READ = 0x0100, 1527c478bd9Sstevel@tonic-gate SCSA1394_CMD_WRITE = 0x0200, 1537c478bd9Sstevel@tonic-gate SCSA1394_CMD_RDWR = (SCSA1394_CMD_READ | 1547c478bd9Sstevel@tonic-gate SCSA1394_CMD_WRITE), 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate SCSA1394_CMD_SYMBIOS_BREAKUP = 0x400 1577c478bd9Sstevel@tonic-gate }; 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1607c478bd9Sstevel@tonic-gate } 1617c478bd9Sstevel@tonic-gate #endif 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate #endif /* _SYS_1394_TARGETS_SCSA1394_CMD_H */ 164