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 #pragma ident "%Z%%M% %I% %E% SMI"
30
31 /*
32 * scsa1394 command
33 */
34
35 #include <sys/scsi/scsi_types.h>
36 #include <sys/1394/targets/scsa1394/sbp2.h>
37 #include <sys/note.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /* preferred pkt_private length in 64-bit quantities */
44 #ifdef _LP64
45 #define SCSA1394_CMD_PRIV_SIZE 2
46 #else /* _ILP32 */
47 #define SCSA1394_CMD_PRIV_SIZE 1
48 #endif
49 #define SCSA1394_CMD_PRIV_LEN (SCSA1394_CMD_PRIV_SIZE * sizeof (uint64_t))
50
51 /* entry describing a page table segment */
52 typedef struct scsa1394_cmd_seg {
53 size_t ss_len;
54 uint64_t ss_daddr;
55 uint64_t ss_baddr;
56 t1394_addr_handle_t ss_addr_hdl;
57 } scsa1394_cmd_seg_t;
58
59 /* command packet structure */
60 typedef struct scsa1394_cmd {
61 sbp2_task_t sc_task; /* corresponding SBP-2 task */
62 struct scsa1394_lun *sc_lun; /* lun it belongs to */
63 int sc_state; /* command state */
64 int sc_flags; /* command flags */
65 struct buf *sc_bp; /* data buffer */
66 struct scsi_pkt *sc_pkt; /* corresponding scsi pkt */
67 size_t sc_cdb_len;
68 size_t sc_cdb_actual_len;
69 size_t sc_scb_len;
70 size_t sc_priv_len;
71 uchar_t sc_cdb[SCSI_CDB_SIZE];
72 uchar_t sc_pkt_cdb[SCSI_CDB_SIZE];
73 struct scsi_arq_status sc_scb;
74 uint64_t sc_priv[SCSA1394_CMD_PRIV_SIZE];
75 clock_t sc_start_time;
76 int sc_timeout;
77
78 /* DMA: command ORB */
79 ddi_dma_handle_t sc_orb_dma_hdl;
80 ddi_acc_handle_t sc_orb_acc_hdl;
81 ddi_dma_cookie_t sc_orb_dmac;
82 t1394_addr_handle_t sc_orb_addr_hdl;
83
84 /* DMA: data buffer */
85 ddi_dma_handle_t sc_buf_dma_hdl;
86 uint_t sc_buf_nsegs; /* # of segments/cookies */
87 uint_t sc_buf_nsegs_alloc; /* # of entries allocated */
88 scsa1394_cmd_seg_t *sc_buf_seg; /* segment array */
89 scsa1394_cmd_seg_t sc_buf_seg_mem; /* backstore for one segment */
90 uint_t sc_nwin; /* # windows */
91 uint_t sc_curwin; /* current window */
92 off_t sc_win_offset; /* current window offset */
93 size_t sc_win_len; /* current window length */
94 size_t sc_xfer_bytes; /* current xfer byte count */
95 size_t sc_xfer_blks; /* current xfer blk count */
96
97 /* DMA: page table */
98 ddi_dma_handle_t sc_pt_dma_hdl;
99 ddi_acc_handle_t sc_pt_acc_hdl;
100 ddi_dma_cookie_t sc_pt_dmac;
101 caddr_t sc_pt_kaddr;
102 uint64_t sc_pt_baddr;
103 t1394_addr_handle_t sc_pt_addr_hdl;
104 size_t sc_pt_ent_alloc; /* # allocated entries */
105 int sc_pt_cmd_size;
106
107 /* for symbios mode only */
108 int sc_lba; /* start LBA */
109 int sc_blk_size; /* xfer block size */
110 size_t sc_total_blks; /* total xfer blocks */
111 size_t sc_resid_blks; /* blocks left */
112
113 struct scsi_pkt sc_scsi_pkt; /* must be last */
114 /* embedded SCSI packet */
115 /* ... scsi_pkt_size() */
116 } scsa1394_cmd_t;
117 #define SCSA1394_CMD_SIZE (sizeof (struct scsa1394_cmd) - \
118 sizeof (struct scsi_pkt) + scsi_pkt_size())
119
120 _NOTE(SCHEME_PROTECTS_DATA("unique per task", { scsa1394_cmd scsa1394_cmd_seg
121 scsi_pkt scsi_inquiry scsi_extended_sense scsi_cdb scsi_arq_status }))
122
123 #define PKT2CMD(pktp) ((scsa1394_cmd_t *)((pktp)->pkt_ha_private))
124 #define CMD2PKT(cmdp) ((struct scsi_pkt *)((cmdp)->sc_pkt))
125 #define TASK2CMD(task) ((scsa1394_cmd_t *)(task)->ts_drv_priv)
126 #define CMD2TASK(cmdp) ((sbp2_task_t *)&(cmdp)->sc_task)
127
128 /* state */
129 enum {
130 SCSA1394_CMD_INIT,
131 SCSA1394_CMD_START,
132 SCSA1394_CMD_STATUS
133 };
134
135 /* flags */
136 enum {
137 SCSA1394_CMD_CDB_EXT = 0x0001,
138 SCSA1394_CMD_PRIV_EXT = 0x0002,
139 SCSA1394_CMD_SCB_EXT = 0x0004,
140 SCSA1394_CMD_EXT = (SCSA1394_CMD_CDB_EXT |
141 SCSA1394_CMD_PRIV_EXT |
142 SCSA1394_CMD_SCB_EXT),
143
144 SCSA1394_CMD_DMA_CDB_VALID = 0x0008,
145 SCSA1394_CMD_DMA_BUF_BIND_VALID = 0x0010,
146 SCSA1394_CMD_DMA_BUF_PT_VALID = 0x0020,
147 SCSA1394_CMD_DMA_BUF_ADDR_VALID = 0x0040,
148 SCSA1394_CMD_DMA_BUF_VALID = (SCSA1394_CMD_DMA_BUF_BIND_VALID |
149 SCSA1394_CMD_DMA_BUF_ADDR_VALID |
150 SCSA1394_CMD_DMA_BUF_PT_VALID),
151 SCSA1394_CMD_DMA_BUF_MAPIN = 0x0080,
152
153 SCSA1394_CMD_READ = 0x0100,
154 SCSA1394_CMD_WRITE = 0x0200,
155 SCSA1394_CMD_RDWR = (SCSA1394_CMD_READ |
156 SCSA1394_CMD_WRITE),
157
158 SCSA1394_CMD_SYMBIOS_BREAKUP = 0x400
159 };
160
161 #ifdef __cplusplus
162 }
163 #endif
|
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
|