1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_1394_TARGETS_SCSA1394_CMD_H 27 #define _SYS_1394_TARGETS_SCSA1394_CMD_H 28 29 /* 30 * scsa1394 command 31 */ 32 33 #include <sys/scsi/scsi_types.h> 34 #include <sys/1394/targets/scsa1394/sbp2.h> 35 #include <sys/note.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* entry describing a page table segment */ 42 typedef struct scsa1394_cmd_seg { 43 size_t ss_len; 44 uint64_t ss_daddr; 45 uint64_t ss_baddr; 46 t1394_addr_handle_t ss_addr_hdl; 47 } scsa1394_cmd_seg_t; 48 49 /* command packet structure */ 50 typedef struct scsa1394_cmd { 51 sbp2_task_t sc_task; /* corresponding SBP-2 task */ 52 struct scsa1394_lun *sc_lun; /* lun it belongs to */ 53 int sc_state; /* command state */ 54 int sc_flags; /* command flags */ 55 struct buf *sc_bp; /* data buffer */ 56 struct scsi_pkt *sc_pkt; /* corresponding scsi pkt */ 57 size_t sc_orig_cdblen; 58 clock_t sc_start_time; 59 int sc_timeout; 60 61 /* DMA: command ORB */ 62 ddi_dma_handle_t sc_orb_dma_hdl; 63 ddi_acc_handle_t sc_orb_acc_hdl; 64 ddi_dma_cookie_t sc_orb_dmac; 65 t1394_addr_handle_t sc_orb_addr_hdl; 66 67 /* DMA: data buffer */ 68 ddi_dma_handle_t sc_buf_dma_hdl; 69 uint_t sc_buf_nsegs; /* # of segments/cookies */ 70 uint_t sc_buf_nsegs_alloc; /* # of entries allocated */ 71 scsa1394_cmd_seg_t *sc_buf_seg; /* segment array */ 72 scsa1394_cmd_seg_t sc_buf_seg_mem; /* backstore for one segment */ 73 uint_t sc_nwin; /* # windows */ 74 uint_t sc_curwin; /* current window */ 75 off_t sc_win_offset; /* current window offset */ 76 size_t sc_win_len; /* current window length */ 77 size_t sc_xfer_bytes; /* current xfer byte count */ 78 size_t sc_xfer_blks; /* current xfer blk count */ 79 80 /* DMA: page table */ 81 ddi_dma_handle_t sc_pt_dma_hdl; 82 ddi_acc_handle_t sc_pt_acc_hdl; 83 ddi_dma_cookie_t sc_pt_dmac; 84 caddr_t sc_pt_kaddr; 85 uint64_t sc_pt_baddr; 86 t1394_addr_handle_t sc_pt_addr_hdl; 87 size_t sc_pt_ent_alloc; /* # allocated entries */ 88 int sc_pt_cmd_size; 89 90 /* for symbios mode only */ 91 int sc_lba; /* start LBA */ 92 int sc_blk_size; /* xfer block size */ 93 size_t sc_total_blks; /* total xfer blocks */ 94 size_t sc_resid_blks; /* blocks left */ 95 } scsa1394_cmd_t; 96 97 _NOTE(SCHEME_PROTECTS_DATA("unique per task", { scsa1394_cmd scsa1394_cmd_seg 98 scsi_pkt scsi_inquiry scsi_extended_sense scsi_cdb scsi_arq_status })) 99 100 #define PKT2CMD(pktp) ((scsa1394_cmd_t *)((pktp)->pkt_ha_private)) 101 #define CMD2PKT(cmdp) ((cmdp)->sc_pkt) 102 #define TASK2CMD(task) ((scsa1394_cmd_t *)(task)->ts_drv_priv) 103 #define CMD2TASK(cmdp) ((sbp2_task_t *)&(cmdp)->sc_task) 104 105 /* state */ 106 enum { 107 SCSA1394_CMD_INIT, 108 SCSA1394_CMD_START, 109 SCSA1394_CMD_STATUS 110 }; 111 112 /* flags */ 113 enum { 114 SCSA1394_CMD_DMA_CDB_VALID = 0x0008, 115 SCSA1394_CMD_DMA_BUF_BIND_VALID = 0x0010, 116 SCSA1394_CMD_DMA_BUF_PT_VALID = 0x0020, 117 SCSA1394_CMD_DMA_BUF_ADDR_VALID = 0x0040, 118 SCSA1394_CMD_DMA_BUF_VALID = (SCSA1394_CMD_DMA_BUF_BIND_VALID | 119 SCSA1394_CMD_DMA_BUF_ADDR_VALID | 120 SCSA1394_CMD_DMA_BUF_PT_VALID), 121 SCSA1394_CMD_DMA_BUF_MAPIN = 0x0080, 122 123 SCSA1394_CMD_READ = 0x0100, 124 SCSA1394_CMD_WRITE = 0x0200, 125 SCSA1394_CMD_RDWR = (SCSA1394_CMD_READ | 126 SCSA1394_CMD_WRITE), 127 128 SCSA1394_CMD_SYMBIOS_BREAKUP = 0x400 129 }; 130 131 #ifdef __cplusplus 132 } 133 #endif 134 135 #endif /* _SYS_1394_TARGETS_SCSA1394_CMD_H */