1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1999,2000 Michael Smith
* Copyright (c) 2000 BSDi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Copyright (c) 2002 Eric Moore
* Copyright (c) 2002 LSI Logic Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The party using or redistributing the source code and binary forms
* agrees to the disclaimer below and the terms and conditions set forth
* herein.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _AMRVAR_H
#define _AMRVAR_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#define AMR_DEBUG
#ifdef AMR_DEBUG
#define AMRDB_PRINT(fmt) if (amr_debug_var) cmn_err fmt
#else
#define AMRDB_PRINT(fmt)
#endif
#define AMRDB_PANIC(fmt) cmn_err fmt
#define AMR_PERIODIC_TIMEOUT 60
#define AMR_RETRYCOUNT 10000
/* for scsi commands */
#ifndef SD_MODE_SENSE_PAGE3_CODE
#define SD_MODE_SENSE_PAGE3_CODE 0x03
#endif
#ifndef SD_MODE_SENSE_PAGE4_CODE
#define SD_MODE_SENSE_PAGE4_CODE 0x04
#endif
#ifndef SCMD_SYNCHRONIZE_CACHE
#define SCMD_SYNCHRONIZE_CACHE 0x35
#endif
#define AMR_DEFAULT_SECTORS 512
#define AMR_DEFAULT_HEADS 255
#define AMR_DEFAULT_CYLINDERS 63
#define AMR_DEFAULT_ROTATIONS 10000
#define AMR_INQ_ADDITIONAL_LEN 31
#define AMR_INQ_ANSI_VER 2
#define AMR_INQ_RESP_DATA_FORMAT 2
#define AMR_PRODUCT_INFO_SIZE \
sizeof (((struct scsi_inquiry *)(NULL))->inq_pid)
#define AMR_FIRMWARE_VER_SIZE \
sizeof (((struct scsi_inquiry *)(NULL))->inq_revision)
#define AMR_LAST_COOKIE_TAG 0xffffffff
/*
* Per-logical-drive datastructure
*/
struct amr_logdrive
{
uint32_t al_size;
uint8_t al_state;
uint8_t al_properties;
};
/*
* Per-command control structure.
*/
struct amr_command
{
struct amr_command *ac_prev;
struct amr_command *ac_next;
struct amr_softs *ac_softs;
uint8_t ac_slot;
uint8_t ac_status;
uint32_t ac_flags;
struct buf *ac_buf;
uint32_t cmdlen;
struct scsi_pkt *pkt;
void *ac_data;
size_t ac_length;
uint32_t ac_dataphys;
ddi_dma_handle_t sg_dma_handle;
ddi_dma_cookie_t sg_dma_cookie;
uint_t sg_dma_cookien;
ddi_dma_handle_t buffer_dma_handle;
ddi_dma_cookie_t buffer_dma_cookie;
ddi_acc_handle_t buffer_acc_handle;
uint_t num_of_cookie;
uint_t num_of_win;
uint_t current_cookie;
uint_t current_win;
uint32_t data_transfered;
uint32_t transfer_size;
struct amr_mailbox mailbox;
struct amr_sgentry sgtable[AMR_NSEG];
time_t ac_timestamp;
};
/*
* ac_flags values in amr_command
*/
#define AMR_CMD_DATAIN (1<<0)
#define AMR_CMD_DATAOUT (1<<1)
#define AMR_CMD_CCB_DATAIN (1<<2)
#define AMR_CMD_CCB_DATAOUT (1<<3)
#define AMR_CMD_PRIORITY (1<<4)
#define AMR_CMD_MAPPED (1<<5)
#define AMR_CMD_SLEEP (1<<6)
#define AMR_CMD_BUSY (1<<7)
#define AMR_CMD_PKT_CONSISTENT (1<<8)
#define AMR_CMD_PKT_DMA_PARTIAL (1<<9)
#define AMR_CMD_GOT_SLOT (1<<10)
struct sg_item {
struct amr_sgentry *sg_table;
ddi_dma_handle_t sg_handle;
ddi_acc_handle_t sg_acc_handle;
uint32_t sg_phyaddr;
};
struct product_info {
uint8_t pi_firmware_ver[AMR_FIRMWARE_VER_SIZE+1];
uint8_t pi_product_name[AMR_PRODUCT_INFO_SIZE+1];
};
/*
* Per-controller-instance data
*/
struct amr_softs
{
/* bus attachments */
dev_info_t *dev_info_p;
ddi_acc_handle_t pciconfig_handle;
ddi_acc_handle_t regsmap_handle;
ddi_iblock_cookie_t iblock_cookiep;
ddi_dma_handle_t mbox_dma_handle;
ddi_acc_handle_t mbox_acc_handle;
ddi_dma_cookie_t mbox_dma_cookie;
uint_t mbox_dma_cookien;
/* controller limits and features */
uint8_t maxio; /* maximum number of I/O transactions */
uint8_t maxdrives; /* max number of logical drives */
uint8_t maxchan; /* count of SCSI channels */
uint8_t amr_nlogdrives;
/* connected logical drives */
struct amr_logdrive logic_drive[AMR_MAXLD];
/* product info of the card */
struct product_info amr_product_info;
/* controller state */
uint32_t state;
struct amr_mailbox *mailbox;
void *mbox;
uint32_t mbox_phyaddr;
/* per-controller poll command */
kmutex_t cmd_mutex;
kcondvar_t cmd_cv;
uint32_t amr_busyslots;
struct amr_command *busycmd[AMR_MAXCMD];
struct sg_item sg_items[AMR_MAXCMD];
uint32_t sg_max_count;
struct amr_command *waiting_q_head;
struct amr_command *waiting_q_tail;
kmutex_t queue_mutex;
/* periodic status check */
timeout_id_t timeout_t;
kmutex_t periodic_mutex;
scsi_hba_tran_t *hba_tran;
ddi_taskq_t *amr_taskq;
uint32_t amr_interrupts_counter;
};
/*
* state values in amr_softs
*/
#define AMR_STATE_OPEN (1<<0)
#define AMR_STATE_SUSPEND (1<<1)
#define AMR_STATE_CARD_DETECTED (1<<2)
#define AMR_STATE_BUS_MASTER_ENABLED (1<<3)
#define AMR_STATE_SOFT_STATE_SETUP (1<<4)
#define AMR_STATE_PCI_CONFIG_SETUP (1<<5)
#define AMR_STATE_PCI_MEM_MAPPED (1<<6)
#define AMR_STATE_KMUTEX_INITED (1<<7)
#define AMR_STATE_MAILBOX_SETUP (1<<8)
#define AMR_STATE_SG_TABLES_SETUP (1<<9)
#define AMR_STATE_INTR_SETUP (1<<10)
#define AMR_STATE_TASKQ_SETUP (1<<11)
#define AMR_STATE_TRAN_SETUP (1<<12)
#define AMR_STATE_TIMEOUT_ENABLED (1<<13)
#ifdef __cplusplus
}
#endif
#endif /* _AMRVAR_H */
|