Deleted Added
full compact
aac.c (150119) aac.c (151086)
1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2001 Scott Long
4 * Copyright (c) 2000 BSDi
5 * Copyright (c) 2001 Adaptec, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2001 Scott Long
4 * Copyright (c) 2000 BSDi
5 * Copyright (c) 2001 Adaptec, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/aac/aac.c 150119 2005-09-14 05:46:28Z scottl $");
31__FBSDID("$FreeBSD: head/sys/dev/aac/aac.c 151086 2005-10-08 15:55:09Z scottl $");
32
33/*
34 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters.
35 */
32
33/*
34 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters.
35 */
36#define AAC_DRIVER_VERSION 0x02000000
37#define AAC_DRIVER_BUILD_DATE __DATE__ " " __TIME__
38#define AAC_DRIVERNAME "aac"
36
37#include "opt_aac.h"
38
39/* #include <stddef.h> */
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/malloc.h>
43#include <sys/kernel.h>
44#include <sys/kthread.h>
45#include <sys/sysctl.h>
46#include <sys/poll.h>
47#include <sys/ioccom.h>
48
49#include <sys/bus.h>
50#include <sys/conf.h>
51#include <sys/signalvar.h>
52#include <sys/time.h>
53#include <sys/eventhandler.h>
39
40#include "opt_aac.h"
41
42/* #include <stddef.h> */
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/malloc.h>
46#include <sys/kernel.h>
47#include <sys/kthread.h>
48#include <sys/sysctl.h>
49#include <sys/poll.h>
50#include <sys/ioccom.h>
51
52#include <sys/bus.h>
53#include <sys/conf.h>
54#include <sys/signalvar.h>
55#include <sys/time.h>
56#include <sys/eventhandler.h>
57#include <sys/rman.h>
54
55#include <machine/bus.h>
56#include <sys/bus_dma.h>
57#include <machine/resource.h>
58
58
59#include <machine/bus.h>
60#include <sys/bus_dma.h>
61#include <machine/resource.h>
62
63#include <dev/pci/pcireg.h>
64#include <dev/pci/pcivar.h>
65
59#include <dev/aac/aacreg.h>
60#include <sys/aac_ioctl.h>
61#include <dev/aac/aacvar.h>
62#include <dev/aac/aac_tables.h>
63
64static void aac_startup(void *arg);
65static void aac_add_container(struct aac_softc *sc,
66 struct aac_mntinforesp *mir, int f);

--- 44 unchanged lines hidden (view full) ---

111
112struct aac_interface aac_fa_interface = {
113 aac_fa_get_fwstatus,
114 aac_fa_qnotify,
115 aac_fa_get_istatus,
116 aac_fa_clear_istatus,
117 aac_fa_set_mailbox,
118 aac_fa_get_mailbox,
66#include <dev/aac/aacreg.h>
67#include <sys/aac_ioctl.h>
68#include <dev/aac/aacvar.h>
69#include <dev/aac/aac_tables.h>
70
71static void aac_startup(void *arg);
72static void aac_add_container(struct aac_softc *sc,
73 struct aac_mntinforesp *mir, int f);

--- 44 unchanged lines hidden (view full) ---

118
119struct aac_interface aac_fa_interface = {
120 aac_fa_get_fwstatus,
121 aac_fa_qnotify,
122 aac_fa_get_istatus,
123 aac_fa_clear_istatus,
124 aac_fa_set_mailbox,
125 aac_fa_get_mailbox,
119 aac_fa_set_interrupts
126 aac_fa_set_interrupts,
127 NULL, NULL, NULL
120};
121
122/* StrongARM interface */
123static int aac_sa_get_fwstatus(struct aac_softc *sc);
124static void aac_sa_qnotify(struct aac_softc *sc, int qbit);
125static int aac_sa_get_istatus(struct aac_softc *sc);
126static void aac_sa_clear_istatus(struct aac_softc *sc, int mask);
127static void aac_sa_set_mailbox(struct aac_softc *sc, u_int32_t command,

--- 4 unchanged lines hidden (view full) ---

132
133struct aac_interface aac_sa_interface = {
134 aac_sa_get_fwstatus,
135 aac_sa_qnotify,
136 aac_sa_get_istatus,
137 aac_sa_clear_istatus,
138 aac_sa_set_mailbox,
139 aac_sa_get_mailbox,
128};
129
130/* StrongARM interface */
131static int aac_sa_get_fwstatus(struct aac_softc *sc);
132static void aac_sa_qnotify(struct aac_softc *sc, int qbit);
133static int aac_sa_get_istatus(struct aac_softc *sc);
134static void aac_sa_clear_istatus(struct aac_softc *sc, int mask);
135static void aac_sa_set_mailbox(struct aac_softc *sc, u_int32_t command,

--- 4 unchanged lines hidden (view full) ---

140
141struct aac_interface aac_sa_interface = {
142 aac_sa_get_fwstatus,
143 aac_sa_qnotify,
144 aac_sa_get_istatus,
145 aac_sa_clear_istatus,
146 aac_sa_set_mailbox,
147 aac_sa_get_mailbox,
140 aac_sa_set_interrupts
148 aac_sa_set_interrupts,
149 NULL, NULL, NULL
141};
142
143/* i960Rx interface */
144static int aac_rx_get_fwstatus(struct aac_softc *sc);
145static void aac_rx_qnotify(struct aac_softc *sc, int qbit);
146static int aac_rx_get_istatus(struct aac_softc *sc);
147static void aac_rx_clear_istatus(struct aac_softc *sc, int mask);
148static void aac_rx_set_mailbox(struct aac_softc *sc, u_int32_t command,
149 u_int32_t arg0, u_int32_t arg1,
150 u_int32_t arg2, u_int32_t arg3);
151static int aac_rx_get_mailbox(struct aac_softc *sc, int mb);
152static void aac_rx_set_interrupts(struct aac_softc *sc, int enable);
150};
151
152/* i960Rx interface */
153static int aac_rx_get_fwstatus(struct aac_softc *sc);
154static void aac_rx_qnotify(struct aac_softc *sc, int qbit);
155static int aac_rx_get_istatus(struct aac_softc *sc);
156static void aac_rx_clear_istatus(struct aac_softc *sc, int mask);
157static void aac_rx_set_mailbox(struct aac_softc *sc, u_int32_t command,
158 u_int32_t arg0, u_int32_t arg1,
159 u_int32_t arg2, u_int32_t arg3);
160static int aac_rx_get_mailbox(struct aac_softc *sc, int mb);
161static void aac_rx_set_interrupts(struct aac_softc *sc, int enable);
162static int aac_rx_send_command(struct aac_softc *sc, struct aac_command *cm);
163static int aac_rx_get_outb_queue(struct aac_softc *sc);
164static void aac_rx_set_outb_queue(struct aac_softc *sc, int index);
153
154struct aac_interface aac_rx_interface = {
155 aac_rx_get_fwstatus,
156 aac_rx_qnotify,
157 aac_rx_get_istatus,
158 aac_rx_clear_istatus,
159 aac_rx_set_mailbox,
160 aac_rx_get_mailbox,
165
166struct aac_interface aac_rx_interface = {
167 aac_rx_get_fwstatus,
168 aac_rx_qnotify,
169 aac_rx_get_istatus,
170 aac_rx_clear_istatus,
171 aac_rx_set_mailbox,
172 aac_rx_get_mailbox,
161 aac_rx_set_interrupts
173 aac_rx_set_interrupts,
174 aac_rx_send_command,
175 aac_rx_get_outb_queue,
176 aac_rx_set_outb_queue
162};
163
164/* Rocket/MIPS interface */
165static int aac_rkt_get_fwstatus(struct aac_softc *sc);
166static void aac_rkt_qnotify(struct aac_softc *sc, int qbit);
167static int aac_rkt_get_istatus(struct aac_softc *sc);
168static void aac_rkt_clear_istatus(struct aac_softc *sc, int mask);
169static void aac_rkt_set_mailbox(struct aac_softc *sc, u_int32_t command,
170 u_int32_t arg0, u_int32_t arg1,
171 u_int32_t arg2, u_int32_t arg3);
172static int aac_rkt_get_mailbox(struct aac_softc *sc, int mb);
173static void aac_rkt_set_interrupts(struct aac_softc *sc, int enable);
177};
178
179/* Rocket/MIPS interface */
180static int aac_rkt_get_fwstatus(struct aac_softc *sc);
181static void aac_rkt_qnotify(struct aac_softc *sc, int qbit);
182static int aac_rkt_get_istatus(struct aac_softc *sc);
183static void aac_rkt_clear_istatus(struct aac_softc *sc, int mask);
184static void aac_rkt_set_mailbox(struct aac_softc *sc, u_int32_t command,
185 u_int32_t arg0, u_int32_t arg1,
186 u_int32_t arg2, u_int32_t arg3);
187static int aac_rkt_get_mailbox(struct aac_softc *sc, int mb);
188static void aac_rkt_set_interrupts(struct aac_softc *sc, int enable);
189static int aac_rkt_send_command(struct aac_softc *sc, struct aac_command *cm);
190static int aac_rkt_get_outb_queue(struct aac_softc *sc);
191static void aac_rkt_set_outb_queue(struct aac_softc *sc, int index);
174
175struct aac_interface aac_rkt_interface = {
176 aac_rkt_get_fwstatus,
177 aac_rkt_qnotify,
178 aac_rkt_get_istatus,
179 aac_rkt_clear_istatus,
180 aac_rkt_set_mailbox,
181 aac_rkt_get_mailbox,
192
193struct aac_interface aac_rkt_interface = {
194 aac_rkt_get_fwstatus,
195 aac_rkt_qnotify,
196 aac_rkt_get_istatus,
197 aac_rkt_clear_istatus,
198 aac_rkt_set_mailbox,
199 aac_rkt_get_mailbox,
182 aac_rkt_set_interrupts
200 aac_rkt_set_interrupts,
201 aac_rkt_send_command,
202 aac_rkt_get_outb_queue,
203 aac_rkt_set_outb_queue
183};
184
185/* Debugging and Diagnostics */
186static void aac_describe_controller(struct aac_softc *sc);
187static char *aac_describe_code(struct aac_code_lookup *table,
188 u_int32_t code);
189
190/* Management Interface */
191static d_open_t aac_open;
192static d_close_t aac_close;
193static d_ioctl_t aac_ioctl;
194static d_poll_t aac_poll;
195static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib);
196static void aac_handle_aif(struct aac_softc *sc,
197 struct aac_fib *fib);
198static int aac_rev_check(struct aac_softc *sc, caddr_t udata);
199static int aac_getnext_aif(struct aac_softc *sc, caddr_t arg);
200static int aac_return_aif(struct aac_softc *sc, caddr_t uptr);
201static int aac_query_disk(struct aac_softc *sc, caddr_t uptr);
204};
205
206/* Debugging and Diagnostics */
207static void aac_describe_controller(struct aac_softc *sc);
208static char *aac_describe_code(struct aac_code_lookup *table,
209 u_int32_t code);
210
211/* Management Interface */
212static d_open_t aac_open;
213static d_close_t aac_close;
214static d_ioctl_t aac_ioctl;
215static d_poll_t aac_poll;
216static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib);
217static void aac_handle_aif(struct aac_softc *sc,
218 struct aac_fib *fib);
219static int aac_rev_check(struct aac_softc *sc, caddr_t udata);
220static int aac_getnext_aif(struct aac_softc *sc, caddr_t arg);
221static int aac_return_aif(struct aac_softc *sc, caddr_t uptr);
222static int aac_query_disk(struct aac_softc *sc, caddr_t uptr);
223static int aac_get_pci_info(struct aac_softc *sc, caddr_t uptr);
224static void aac_ioctl_event(struct aac_softc *sc,
225 struct aac_event *event, void *arg);
202
203static struct cdevsw aac_cdevsw = {
204 .d_version = D_VERSION,
205 .d_flags = D_NEEDGIANT,
206 .d_open = aac_open,
207 .d_close = aac_close,
208 .d_ioctl = aac_ioctl,
209 .d_poll = aac_poll,

--- 27 unchanged lines hidden (view full) ---

237 aac_initq_busy(sc);
238 aac_initq_bio(sc);
239
240 /*
241 * Initialise command-completion task.
242 */
243 TASK_INIT(&sc->aac_task_complete, 0, aac_complete, sc);
244
226
227static struct cdevsw aac_cdevsw = {
228 .d_version = D_VERSION,
229 .d_flags = D_NEEDGIANT,
230 .d_open = aac_open,
231 .d_close = aac_close,
232 .d_ioctl = aac_ioctl,
233 .d_poll = aac_poll,

--- 27 unchanged lines hidden (view full) ---

261 aac_initq_busy(sc);
262 aac_initq_bio(sc);
263
264 /*
265 * Initialise command-completion task.
266 */
267 TASK_INIT(&sc->aac_task_complete, 0, aac_complete, sc);
268
245 /* disable interrupts before we enable anything */
246 AAC_MASK_INTERRUPTS(sc);
247
248 /* mark controller as suspended until we get ourselves organised */
249 sc->aac_state |= AAC_STATE_SUSPEND;
250
251 /*
252 * Check that the firmware on the card is supported.
253 */
254 if ((error = aac_check_firmware(sc)) != 0)
255 return(error);

--- 11 unchanged lines hidden (view full) ---

267
268 /*
269 * Initialise the adapter.
270 */
271 if ((error = aac_init(sc)) != 0)
272 return(error);
273
274 /*
269 /* mark controller as suspended until we get ourselves organised */
270 sc->aac_state |= AAC_STATE_SUSPEND;
271
272 /*
273 * Check that the firmware on the card is supported.
274 */
275 if ((error = aac_check_firmware(sc)) != 0)
276 return(error);

--- 11 unchanged lines hidden (view full) ---

288
289 /*
290 * Initialise the adapter.
291 */
292 if ((error = aac_init(sc)) != 0)
293 return(error);
294
295 /*
296 * Allocate and connect our interrupt.
297 */
298 sc->aac_irq_rid = 0;
299 if ((sc->aac_irq = bus_alloc_resource_any(sc->aac_dev, SYS_RES_IRQ,
300 &sc->aac_irq_rid,
301 RF_SHAREABLE |
302 RF_ACTIVE)) == NULL) {
303 device_printf(sc->aac_dev, "can't allocate interrupt\n");
304 return (EINVAL);
305 }
306 if (sc->flags & AAC_FLAGS_NEW_COMM) {
307 if (bus_setup_intr(sc->aac_dev, sc->aac_irq,
308 INTR_MPSAFE|INTR_TYPE_BIO, aac_new_intr,
309 sc, &sc->aac_intr)) {
310 device_printf(sc->aac_dev, "can't set up interrupt\n");
311 return (EINVAL);
312 }
313 } else {
314 if (bus_setup_intr(sc->aac_dev, sc->aac_irq,
315 INTR_FAST|INTR_TYPE_BIO, aac_fast_intr,
316 sc, &sc->aac_intr)) {
317 device_printf(sc->aac_dev,
318 "can't set up FAST interrupt\n");
319 if (bus_setup_intr(sc->aac_dev, sc->aac_irq,
320 INTR_MPSAFE|INTR_TYPE_BIO,
321 aac_fast_intr, sc, &sc->aac_intr)) {
322 device_printf(sc->aac_dev,
323 "can't set up MPSAFE interrupt\n");
324 return (EINVAL);
325 }
326 }
327 }
328
329 /*
275 * Print a little information about the controller.
276 */
277 aac_describe_controller(sc);
278
279 /*
280 * Register to probe our containers later.
281 */
282 sc->aac_ich.ich_func = aac_startup;

--- 11 unchanged lines hidden (view full) ---

294 sc->aac_dev_t = make_dev(&aac_cdevsw, unit, UID_ROOT, GID_OPERATOR,
295 0640, "aac%d", unit);
296 (void)make_dev_alias(sc->aac_dev_t, "afa%d", unit);
297 (void)make_dev_alias(sc->aac_dev_t, "hpn%d", unit);
298 sc->aac_dev_t->si_drv1 = sc;
299
300 /* Create the AIF thread */
301 if (kthread_create((void(*)(void *))aac_command_thread, sc,
330 * Print a little information about the controller.
331 */
332 aac_describe_controller(sc);
333
334 /*
335 * Register to probe our containers later.
336 */
337 sc->aac_ich.ich_func = aac_startup;

--- 11 unchanged lines hidden (view full) ---

349 sc->aac_dev_t = make_dev(&aac_cdevsw, unit, UID_ROOT, GID_OPERATOR,
350 0640, "aac%d", unit);
351 (void)make_dev_alias(sc->aac_dev_t, "afa%d", unit);
352 (void)make_dev_alias(sc->aac_dev_t, "hpn%d", unit);
353 sc->aac_dev_t->si_drv1 = sc;
354
355 /* Create the AIF thread */
356 if (kthread_create((void(*)(void *))aac_command_thread, sc,
302 &sc->aifthread, 0, 0, "aac%daif", unit))
357 &sc->aifthread, 0, 0, "aac%daif", unit))
303 panic("Could not create AIF thread\n");
304
305 /* Register the shutdown method to only be called post-dump */
306 if ((sc->eh = EVENTHANDLER_REGISTER(shutdown_final, aac_shutdown,
307 sc->aac_dev, SHUTDOWN_PRI_DEFAULT)) == NULL)
308 device_printf(sc->aac_dev,
309 "shutdown event registration failed\n");
310
311 /* Register with CAM for the non-DASD devices */
312 if ((sc->flags & AAC_FLAGS_ENABLE_CAM) != 0) {
313 TAILQ_INIT(&sc->aac_sim_tqh);
314 aac_get_bus_info(sc);
315 }
316
317 return(0);
318}
319
358 panic("Could not create AIF thread\n");
359
360 /* Register the shutdown method to only be called post-dump */
361 if ((sc->eh = EVENTHANDLER_REGISTER(shutdown_final, aac_shutdown,
362 sc->aac_dev, SHUTDOWN_PRI_DEFAULT)) == NULL)
363 device_printf(sc->aac_dev,
364 "shutdown event registration failed\n");
365
366 /* Register with CAM for the non-DASD devices */
367 if ((sc->flags & AAC_FLAGS_ENABLE_CAM) != 0) {
368 TAILQ_INIT(&sc->aac_sim_tqh);
369 aac_get_bus_info(sc);
370 }
371
372 return(0);
373}
374
375void
376aac_add_event(struct aac_softc *sc, struct aac_event *event)
377{
378
379 switch (event->ev_type & AAC_EVENT_MASK) {
380 case AAC_EVENT_CMFREE:
381 TAILQ_INSERT_TAIL(&sc->aac_ev_cmfree, event, ev_links);
382 break;
383 default:
384 device_printf(sc->aac_dev, "aac_add event: unknown event %d\n",
385 event->ev_type);
386 break;
387 }
388
389 return;
390}
391
320/*
321 * Probe for containers, create disks.
322 */
323static void
324aac_startup(void *arg)
325{
326 struct aac_softc *sc;
327 struct aac_fib *fib;
328 struct aac_mntinfo *mi;
329 struct aac_mntinforesp *mir = NULL;
330 int count = 0, i = 0;
331
332 debug_called(1);
333
334 sc = (struct aac_softc *)arg;
335
336 /* disconnect ourselves from the intrhook chain */
337 config_intrhook_disestablish(&sc->aac_ich);
338
392/*
393 * Probe for containers, create disks.
394 */
395static void
396aac_startup(void *arg)
397{
398 struct aac_softc *sc;
399 struct aac_fib *fib;
400 struct aac_mntinfo *mi;
401 struct aac_mntinforesp *mir = NULL;
402 int count = 0, i = 0;
403
404 debug_called(1);
405
406 sc = (struct aac_softc *)arg;
407
408 /* disconnect ourselves from the intrhook chain */
409 config_intrhook_disestablish(&sc->aac_ich);
410
411 mtx_lock(&sc->aac_io_lock);
339 aac_alloc_sync_fib(sc, &fib);
340 mi = (struct aac_mntinfo *)&fib->data[0];
341
342 /* loop over possible containers */
343 do {
344 /* request information on this container */
345 bzero(mi, sizeof(struct aac_mntinfo));
346 mi->Command = VM_NameServe;

--- 8 unchanged lines hidden (view full) ---

355 mir = (struct aac_mntinforesp *)&fib->data[0];
356 /* XXX Need to check if count changed */
357 count = mir->MntRespCount;
358 aac_add_container(sc, mir, 0);
359 i++;
360 } while ((i < count) && (i < AAC_MAX_CONTAINERS));
361
362 aac_release_sync_fib(sc);
412 aac_alloc_sync_fib(sc, &fib);
413 mi = (struct aac_mntinfo *)&fib->data[0];
414
415 /* loop over possible containers */
416 do {
417 /* request information on this container */
418 bzero(mi, sizeof(struct aac_mntinfo));
419 mi->Command = VM_NameServe;

--- 8 unchanged lines hidden (view full) ---

428 mir = (struct aac_mntinforesp *)&fib->data[0];
429 /* XXX Need to check if count changed */
430 count = mir->MntRespCount;
431 aac_add_container(sc, mir, 0);
432 i++;
433 } while ((i < count) && (i < AAC_MAX_CONTAINERS));
434
435 aac_release_sync_fib(sc);
436 mtx_unlock(&sc->aac_io_lock);
363
364 /* poke the bus to actually attach the child devices */
365 if (bus_generic_attach(sc->aac_dev))
366 device_printf(sc->aac_dev, "bus_generic_attach failed\n");
367
368 /* mark the controller up */
369 sc->aac_state &= ~AAC_STATE_SUSPEND;
370

--- 174 unchanged lines hidden (view full) ---

545
546 /*
547 * Send a Container shutdown followed by a HostShutdown FIB to the
548 * controller to convince it that we don't want to talk to it anymore.
549 * We've been closed and all I/O completed already
550 */
551 device_printf(sc->aac_dev, "shutting down controller...");
552
437
438 /* poke the bus to actually attach the child devices */
439 if (bus_generic_attach(sc->aac_dev))
440 device_printf(sc->aac_dev, "bus_generic_attach failed\n");
441
442 /* mark the controller up */
443 sc->aac_state &= ~AAC_STATE_SUSPEND;
444

--- 174 unchanged lines hidden (view full) ---

619
620 /*
621 * Send a Container shutdown followed by a HostShutdown FIB to the
622 * controller to convince it that we don't want to talk to it anymore.
623 * We've been closed and all I/O completed already
624 */
625 device_printf(sc->aac_dev, "shutting down controller...");
626
627 mtx_lock(&sc->aac_io_lock);
553 aac_alloc_sync_fib(sc, &fib);
554 cc = (struct aac_close_command *)&fib->data[0];
555
556 bzero(cc, sizeof(struct aac_close_command));
557 cc->Command = VM_CloseAll;
558 cc->ContainerId = 0xffffffff;
559 if (aac_sync_fib(sc, ContainerCommand, 0, fib,
560 sizeof(struct aac_close_command)))

--- 15 unchanged lines hidden (view full) ---

576 } else {
577 printf("done.\n");
578 }
579 }
580#endif
581
582 AAC_MASK_INTERRUPTS(sc);
583 aac_release_sync_fib(sc);
628 aac_alloc_sync_fib(sc, &fib);
629 cc = (struct aac_close_command *)&fib->data[0];
630
631 bzero(cc, sizeof(struct aac_close_command));
632 cc->Command = VM_CloseAll;
633 cc->ContainerId = 0xffffffff;
634 if (aac_sync_fib(sc, ContainerCommand, 0, fib,
635 sizeof(struct aac_close_command)))

--- 15 unchanged lines hidden (view full) ---

651 } else {
652 printf("done.\n");
653 }
654 }
655#endif
656
657 AAC_MASK_INTERRUPTS(sc);
658 aac_release_sync_fib(sc);
659 mtx_unlock(&sc->aac_io_lock);
584
585 return(0);
586}
587
588/*
589 * Bring the controller to a quiescent state, ready for system suspend.
590 */
591int

--- 24 unchanged lines hidden (view full) ---

616 sc = device_get_softc(dev);
617
618 sc->aac_state &= ~AAC_STATE_SUSPEND;
619 AAC_UNMASK_INTERRUPTS(sc);
620 return(0);
621}
622
623/*
660
661 return(0);
662}
663
664/*
665 * Bring the controller to a quiescent state, ready for system suspend.
666 */
667int

--- 24 unchanged lines hidden (view full) ---

692 sc = device_get_softc(dev);
693
694 sc->aac_state &= ~AAC_STATE_SUSPEND;
695 AAC_UNMASK_INTERRUPTS(sc);
696 return(0);
697}
698
699/*
624 * Take an interrupt.
700 * Interrupt handler for NEW_COMM interface.
625 */
626void
701 */
702void
627aac_intr(void *arg)
703aac_new_intr(void *arg)
628{
629 struct aac_softc *sc;
704{
705 struct aac_softc *sc;
706 u_int32_t index, fast;
707 struct aac_command *cm;
708 struct aac_fib *fib;
709 int i;
710
711 debug_called(2);
712
713 sc = (struct aac_softc *)arg;
714
715 mtx_lock(&sc->aac_io_lock);
716 while (1) {
717 index = AAC_GET_OUTB_QUEUE(sc);
718 if (index == 0xffffffff)
719 index = AAC_GET_OUTB_QUEUE(sc);
720 if (index == 0xffffffff)
721 break;
722 if (index & 2) {
723 if (index == 0xfffffffe) {
724 /* XXX This means that the controller wants
725 * more work. Ignore it for now.
726 */
727 continue;
728 }
729 /* AIF */
730 fib = (struct aac_fib *)malloc(sizeof *fib, M_AACBUF,
731 M_NOWAIT | M_ZERO);
732 if (fib == NULL) {
733 /* If we're really this short on memory,
734 * hopefully breaking out of the handler will
735 * allow something to get freed. This
736 * actually sucks a whole lot.
737 */
738 break;
739 }
740 index &= ~2;
741 for (i = 0; i < sizeof(struct aac_fib)/4; ++i)
742 ((u_int32_t *)fib)[i] = AAC_GETREG4(sc, index + i*4);
743 aac_handle_aif(sc, fib);
744 free(fib, M_AACBUF);
745
746 /*
747 * AIF memory is owned by the adapter, so let it
748 * know that we are done with it.
749 */
750 AAC_SET_OUTB_QUEUE(sc, index);
751 AAC_CLEAR_ISTATUS(sc, AAC_DB_RESPONSE_READY);
752 } else {
753 fast = index & 1;
754 cm = sc->aac_commands + (index >> 2);
755 fib = cm->cm_fib;
756 if (fast) {
757 fib->Header.XferState |= AAC_FIBSTATE_DONEADAP;
758 *((u_int32_t *)(fib->data)) = AAC_ERROR_NORMAL;
759 }
760 aac_remove_busy(cm);
761 aac_unmap_command(cm);
762 cm->cm_flags |= AAC_CMD_COMPLETED;
763
764 /* is there a completion handler? */
765 if (cm->cm_complete != NULL) {
766 cm->cm_complete(cm);
767 } else {
768 /* assume that someone is sleeping on this
769 * command
770 */
771 wakeup(cm);
772 }
773 sc->flags &= ~AAC_QUEUE_FRZN;
774 }
775 }
776 /* see if we can start some more I/O */
777 if ((sc->flags & AAC_QUEUE_FRZN) == 0)
778 aac_startio(sc);
779
780 mtx_unlock(&sc->aac_io_lock);
781}
782
783void
784aac_fast_intr(void *arg)
785{
786 struct aac_softc *sc;
630 u_int16_t reason;
631
632 debug_called(2);
633
634 sc = (struct aac_softc *)arg;
635
636 /*
637 * Read the status register directly. This is faster than taking the

--- 10 unchanged lines hidden (view full) ---

648
649 /* controller wants to talk to us */
650 if (reason & (AAC_DB_PRINTF | AAC_DB_COMMAND_READY)) {
651 /*
652 * XXX Make sure that we don't get fooled by strange messages
653 * that start with a NULL.
654 */
655 if ((reason & AAC_DB_PRINTF) &&
787 u_int16_t reason;
788
789 debug_called(2);
790
791 sc = (struct aac_softc *)arg;
792
793 /*
794 * Read the status register directly. This is faster than taking the

--- 10 unchanged lines hidden (view full) ---

805
806 /* controller wants to talk to us */
807 if (reason & (AAC_DB_PRINTF | AAC_DB_COMMAND_READY)) {
808 /*
809 * XXX Make sure that we don't get fooled by strange messages
810 * that start with a NULL.
811 */
812 if ((reason & AAC_DB_PRINTF) &&
656 (sc->aac_common->ac_printf[0] == 0))
813 (sc->aac_common->ac_printf[0] == 0))
657 sc->aac_common->ac_printf[0] = 32;
658
659 /*
660 * This might miss doing the actual wakeup. However, the
661 * msleep that this is waking up has a timeout, so it will
662 * wake up eventually. AIFs and printfs are low enough
663 * priority that they can handle hanging out for a few seconds
664 * if needed.

--- 111 unchanged lines hidden (view full) ---

776 if (retval == EWOULDBLOCK)
777 aac_timeout(sc);
778
779 /* Check the hardware printf message buffer */
780 if (sc->aac_common->ac_printf[0] != 0)
781 aac_print_printf(sc);
782
783 /* Also check to see if the adapter has a command for us. */
814 sc->aac_common->ac_printf[0] = 32;
815
816 /*
817 * This might miss doing the actual wakeup. However, the
818 * msleep that this is waking up has a timeout, so it will
819 * wake up eventually. AIFs and printfs are low enough
820 * priority that they can handle hanging out for a few seconds
821 * if needed.

--- 111 unchanged lines hidden (view full) ---

933 if (retval == EWOULDBLOCK)
934 aac_timeout(sc);
935
936 /* Check the hardware printf message buffer */
937 if (sc->aac_common->ac_printf[0] != 0)
938 aac_print_printf(sc);
939
940 /* Also check to see if the adapter has a command for us. */
784 while (aac_dequeue_fib(sc, AAC_HOST_NORM_CMD_QUEUE,
785 &fib_size, &fib) == 0) {
941 if (sc->flags & AAC_FLAGS_NEW_COMM)
942 continue;
943 for (;;) {
944 if (aac_dequeue_fib(sc, AAC_HOST_NORM_CMD_QUEUE,
945 &fib_size, &fib))
946 break;
786
787 AAC_PRINT_FIB(sc, fib);
788
789 switch (fib->Header.Command) {
790 case AifRequest:
791 aac_handle_aif(sc, fib);
792 break;
793 default:
794 device_printf(sc->aac_dev, "unknown command "
795 "from controller\n");
796 break;
797 }
798
799 if ((fib->Header.XferState == 0) ||
947
948 AAC_PRINT_FIB(sc, fib);
949
950 switch (fib->Header.Command) {
951 case AifRequest:
952 aac_handle_aif(sc, fib);
953 break;
954 default:
955 device_printf(sc->aac_dev, "unknown command "
956 "from controller\n");
957 break;
958 }
959
960 if ((fib->Header.XferState == 0) ||
800 (fib->Header.StructType != AAC_FIBTYPE_TFIB))
961 (fib->Header.StructType != AAC_FIBTYPE_TFIB)) {
801 break;
962 break;
963 }
802
803 /* Return the AIF to the controller. */
804 if (fib->Header.XferState & AAC_FIBSTATE_FROMADAP) {
805 fib->Header.XferState |= AAC_FIBSTATE_DONEHOST;
806 *(AAC_FSAStatus*)fib->data = ST_OK;
807
808 /* XXX Compute the Size field? */
809 size = fib->Header.Size;
810 if (size > sizeof(struct aac_fib)) {
811 size = sizeof(struct aac_fib);
812 fib->Header.Size = size;
813 }
814 /*
815 * Since we did not generate this command, it
816 * cannot go through the normal
817 * enqueue->startio chain.
818 */
819 aac_enqueue_response(sc,
964
965 /* Return the AIF to the controller. */
966 if (fib->Header.XferState & AAC_FIBSTATE_FROMADAP) {
967 fib->Header.XferState |= AAC_FIBSTATE_DONEHOST;
968 *(AAC_FSAStatus*)fib->data = ST_OK;
969
970 /* XXX Compute the Size field? */
971 size = fib->Header.Size;
972 if (size > sizeof(struct aac_fib)) {
973 size = sizeof(struct aac_fib);
974 fib->Header.Size = size;
975 }
976 /*
977 * Since we did not generate this command, it
978 * cannot go through the normal
979 * enqueue->startio chain.
980 */
981 aac_enqueue_response(sc,
820 AAC_ADAP_NORM_RESP_QUEUE,
821 fib);
982 AAC_ADAP_NORM_RESP_QUEUE,
983 fib);
822 }
823 }
824 }
825 sc->aifflags &= ~AAC_AIFFLAGS_RUNNING;
826 mtx_unlock(&sc->aac_io_lock);
827 wakeup(sc->aac_dev);
828
829 kthread_exit(0);

--- 15 unchanged lines hidden (view full) ---

845 sc = (struct aac_softc *)context;
846
847 mtx_lock(&sc->aac_io_lock);
848
849 /* pull completed commands off the queue */
850 for (;;) {
851 /* look for completed FIBs on our queue */
852 if (aac_dequeue_fib(sc, AAC_HOST_NORM_RESP_QUEUE, &fib_size,
984 }
985 }
986 }
987 sc->aifflags &= ~AAC_AIFFLAGS_RUNNING;
988 mtx_unlock(&sc->aac_io_lock);
989 wakeup(sc->aac_dev);
990
991 kthread_exit(0);

--- 15 unchanged lines hidden (view full) ---

1007 sc = (struct aac_softc *)context;
1008
1009 mtx_lock(&sc->aac_io_lock);
1010
1011 /* pull completed commands off the queue */
1012 for (;;) {
1013 /* look for completed FIBs on our queue */
1014 if (aac_dequeue_fib(sc, AAC_HOST_NORM_RESP_QUEUE, &fib_size,
853 &fib))
1015 &fib))
854 break; /* nothing to do */
855
856 /* get the command, unmap and hand off for processing */
857 cm = sc->aac_commands + fib->Header.SenderData;
858 if (cm == NULL) {
859 AAC_PRINT_FIB(sc, fib);
860 break;
861 }
1016 break; /* nothing to do */
1017
1018 /* get the command, unmap and hand off for processing */
1019 cm = sc->aac_commands + fib->Header.SenderData;
1020 if (cm == NULL) {
1021 AAC_PRINT_FIB(sc, fib);
1022 break;
1023 }
862
863 aac_remove_busy(cm);
1024 aac_remove_busy(cm);
864 aac_unmap_command(cm);
1025
1026 aac_unmap_command(cm);
865 cm->cm_flags |= AAC_CMD_COMPLETED;
866
867 /* is there a completion handler? */
868 if (cm->cm_complete != NULL) {
869 cm->cm_complete(cm);
870 } else {
871 /* assume that someone is sleeping on this command */
872 wakeup(cm);

--- 66 unchanged lines hidden (view full) ---

939 AAC_FIBSTATE_REXPECTED |
940 AAC_FIBSTATE_NORM |
941 AAC_FIBSTATE_ASYNC |
942 AAC_FIBSTATE_FAST_RESPONSE;
943
944 /* build the read/write request */
945 ad = (struct aac_disk *)bp->bio_disk->d_drv1;
946
1027 cm->cm_flags |= AAC_CMD_COMPLETED;
1028
1029 /* is there a completion handler? */
1030 if (cm->cm_complete != NULL) {
1031 cm->cm_complete(cm);
1032 } else {
1033 /* assume that someone is sleeping on this command */
1034 wakeup(cm);

--- 66 unchanged lines hidden (view full) ---

1101 AAC_FIBSTATE_REXPECTED |
1102 AAC_FIBSTATE_NORM |
1103 AAC_FIBSTATE_ASYNC |
1104 AAC_FIBSTATE_FAST_RESPONSE;
1105
1106 /* build the read/write request */
1107 ad = (struct aac_disk *)bp->bio_disk->d_drv1;
1108
947 if ((sc->flags & AAC_FLAGS_SG_64BIT) == 0) {
1109 if (sc->flags & AAC_FLAGS_RAW_IO) {
1110 struct aac_raw_io *raw;
1111 raw = (struct aac_raw_io *)&fib->data[0];
1112 fib->Header.Command = RawIo;
1113 raw->BlockNumber = (u_int64_t)bp->bio_pblkno;
1114 raw->ByteCount = bp->bio_bcount;
1115 raw->ContainerId = ad->ad_container->co_mntobj.ObjectId;
1116 raw->BpTotal = 0;
1117 raw->BpComplete = 0;
1118 fib->Header.Size += sizeof(struct aac_raw_io);
1119 cm->cm_sgtable = (struct aac_sg_table *)&raw->SgMapRaw;
1120 if (bp->bio_cmd == BIO_READ) {
1121 raw->Flags = 1;
1122 cm->cm_flags |= AAC_CMD_DATAIN;
1123 } else {
1124 raw->Flags = 0;
1125 cm->cm_flags |= AAC_CMD_DATAOUT;
1126 }
1127 } else if ((sc->flags & AAC_FLAGS_SG_64BIT) == 0) {
948 fib->Header.Command = ContainerCommand;
949 if (bp->bio_cmd == BIO_READ) {
950 struct aac_blockread *br;
951 br = (struct aac_blockread *)&fib->data[0];
952 br->Command = VM_CtBlockRead;
953 br->ContainerId = ad->ad_container->co_mntobj.ObjectId;
954 br->BlockNumber = bp->bio_pblkno;
955 br->ByteCount = bp->bio_bcount;

--- 40 unchanged lines hidden (view full) ---

996 cm->cm_sgtable = (struct aac_sg_table *)&bw->SgMap64;
997 }
998 }
999
1000 *cmp = cm;
1001 return(0);
1002
1003fail:
1128 fib->Header.Command = ContainerCommand;
1129 if (bp->bio_cmd == BIO_READ) {
1130 struct aac_blockread *br;
1131 br = (struct aac_blockread *)&fib->data[0];
1132 br->Command = VM_CtBlockRead;
1133 br->ContainerId = ad->ad_container->co_mntobj.ObjectId;
1134 br->BlockNumber = bp->bio_pblkno;
1135 br->ByteCount = bp->bio_bcount;

--- 40 unchanged lines hidden (view full) ---

1176 cm->cm_sgtable = (struct aac_sg_table *)&bw->SgMap64;
1177 }
1178 }
1179
1180 *cmp = cm;
1181 return(0);
1182
1183fail:
1184 if (bp != NULL)
1185 aac_enqueue_bio(sc, bp);
1004 if (cm != NULL)
1005 aac_release_command(cm);
1006 return(ENOMEM);
1007}
1008
1009/*
1010 * Handle a bio-instigated command that has been completed.
1011 */

--- 84 unchanged lines hidden (view full) ---

1096}
1097
1098/*
1099 * Release a command back to the freelist.
1100 */
1101void
1102aac_release_command(struct aac_command *cm)
1103{
1186 if (cm != NULL)
1187 aac_release_command(cm);
1188 return(ENOMEM);
1189}
1190
1191/*
1192 * Handle a bio-instigated command that has been completed.
1193 */

--- 84 unchanged lines hidden (view full) ---

1278}
1279
1280/*
1281 * Release a command back to the freelist.
1282 */
1283void
1284aac_release_command(struct aac_command *cm)
1285{
1286 struct aac_event *event;
1287 struct aac_softc *sc;
1288
1104 debug_called(3);
1105
1106 /* (re)initialise the command/FIB */
1107 cm->cm_sgtable = NULL;
1108 cm->cm_flags = 0;
1109 cm->cm_complete = NULL;
1110 cm->cm_private = NULL;
1111 cm->cm_fib->Header.XferState = AAC_FIBSTATE_EMPTY;
1112 cm->cm_fib->Header.StructType = AAC_FIBTYPE_TFIB;
1113 cm->cm_fib->Header.Flags = 0;
1289 debug_called(3);
1290
1291 /* (re)initialise the command/FIB */
1292 cm->cm_sgtable = NULL;
1293 cm->cm_flags = 0;
1294 cm->cm_complete = NULL;
1295 cm->cm_private = NULL;
1296 cm->cm_fib->Header.XferState = AAC_FIBSTATE_EMPTY;
1297 cm->cm_fib->Header.StructType = AAC_FIBTYPE_TFIB;
1298 cm->cm_fib->Header.Flags = 0;
1114 cm->cm_fib->Header.SenderSize = sizeof(struct aac_fib);
1299 cm->cm_fib->Header.SenderSize = cm->cm_sc->aac_max_fib_size;
1115
1116 /*
1117 * These are duplicated in aac_start to cover the case where an
1118 * intermediate stage may have destroyed them. They're left
1119 * initialised here for debugging purposes only.
1120 */
1121 cm->cm_fib->Header.ReceiverFibAddress = (u_int32_t)cm->cm_fibphys;
1122 cm->cm_fib->Header.SenderData = 0;
1123
1124 aac_enqueue_free(cm);
1300
1301 /*
1302 * These are duplicated in aac_start to cover the case where an
1303 * intermediate stage may have destroyed them. They're left
1304 * initialised here for debugging purposes only.
1305 */
1306 cm->cm_fib->Header.ReceiverFibAddress = (u_int32_t)cm->cm_fibphys;
1307 cm->cm_fib->Header.SenderData = 0;
1308
1309 aac_enqueue_free(cm);
1310
1311 sc = cm->cm_sc;
1312 event = TAILQ_FIRST(&sc->aac_ev_cmfree);
1313 if (event != NULL) {
1314 TAILQ_REMOVE(&sc->aac_ev_cmfree, event, ev_links);
1315 event->ev_callback(sc, event, event->ev_arg);
1316 }
1125}
1126
1127/*
1128 * Map helper for command/FIB allocation.
1129 */
1130static void
1131aac_map_command_helper(void *arg, bus_dma_segment_t *segs, int nseg, int error)
1132{
1317}
1318
1319/*
1320 * Map helper for command/FIB allocation.
1321 */
1322static void
1323aac_map_command_helper(void *arg, bus_dma_segment_t *segs, int nseg, int error)
1324{
1133 uint32_t *fibphys;
1325 uint64_t *fibphys;
1134
1326
1135 fibphys = (uint32_t *)arg;
1327 fibphys = (uint64_t *)arg;
1136
1137 debug_called(3);
1138
1139 *fibphys = segs[0].ds_addr;
1140}
1141
1142/*
1143 * Allocate and initialise commands/FIBs for this adapter.
1144 */
1145static int
1146aac_alloc_commands(struct aac_softc *sc)
1147{
1148 struct aac_command *cm;
1149 struct aac_fibmap *fm;
1328
1329 debug_called(3);
1330
1331 *fibphys = segs[0].ds_addr;
1332}
1333
1334/*
1335 * Allocate and initialise commands/FIBs for this adapter.
1336 */
1337static int
1338aac_alloc_commands(struct aac_softc *sc)
1339{
1340 struct aac_command *cm;
1341 struct aac_fibmap *fm;
1150 uint32_t fibphys;
1342 uint64_t fibphys;
1151 int i, error;
1152
1153 debug_called(2);
1154
1343 int i, error;
1344
1345 debug_called(2);
1346
1155 if (sc->total_fibs + AAC_FIB_COUNT > sc->aac_max_fibs)
1347 if (sc->total_fibs + sc->aac_max_fibs_alloc > sc->aac_max_fibs)
1156 return (ENOMEM);
1157
1158 fm = malloc(sizeof(struct aac_fibmap), M_AACBUF, M_NOWAIT|M_ZERO);
1159 if (fm == NULL)
1160 return (ENOMEM);
1161
1162 /* allocate the FIBs in DMAable memory and load them */
1163 if (bus_dmamem_alloc(sc->aac_fib_dmat, (void **)&fm->aac_fibs,
1164 BUS_DMA_NOWAIT, &fm->aac_fibmap)) {
1165 device_printf(sc->aac_dev,
1166 "Not enough contiguous memory available.\n");
1167 free(fm, M_AACBUF);
1168 return (ENOMEM);
1169 }
1170
1171 /* Ignore errors since this doesn't bounce */
1172 (void)bus_dmamap_load(sc->aac_fib_dmat, fm->aac_fibmap, fm->aac_fibs,
1348 return (ENOMEM);
1349
1350 fm = malloc(sizeof(struct aac_fibmap), M_AACBUF, M_NOWAIT|M_ZERO);
1351 if (fm == NULL)
1352 return (ENOMEM);
1353
1354 /* allocate the FIBs in DMAable memory and load them */
1355 if (bus_dmamem_alloc(sc->aac_fib_dmat, (void **)&fm->aac_fibs,
1356 BUS_DMA_NOWAIT, &fm->aac_fibmap)) {
1357 device_printf(sc->aac_dev,
1358 "Not enough contiguous memory available.\n");
1359 free(fm, M_AACBUF);
1360 return (ENOMEM);
1361 }
1362
1363 /* Ignore errors since this doesn't bounce */
1364 (void)bus_dmamap_load(sc->aac_fib_dmat, fm->aac_fibmap, fm->aac_fibs,
1173 AAC_FIB_COUNT * sizeof(struct aac_fib),
1365 sc->aac_max_fibs_alloc * sc->aac_max_fib_size,
1174 aac_map_command_helper, &fibphys, 0);
1175
1176 /* initialise constant fields in the command structure */
1177 mtx_lock(&sc->aac_io_lock);
1366 aac_map_command_helper, &fibphys, 0);
1367
1368 /* initialise constant fields in the command structure */
1369 mtx_lock(&sc->aac_io_lock);
1178 bzero(fm->aac_fibs, AAC_FIB_COUNT * sizeof(struct aac_fib));
1179 for (i = 0; i < AAC_FIB_COUNT; i++) {
1370 bzero(fm->aac_fibs, sc->aac_max_fibs_alloc * sc->aac_max_fib_size);
1371 for (i = 0; i < sc->aac_max_fibs_alloc; i++) {
1180 cm = sc->aac_commands + sc->total_fibs;
1181 fm->aac_commands = cm;
1182 cm->cm_sc = sc;
1372 cm = sc->aac_commands + sc->total_fibs;
1373 fm->aac_commands = cm;
1374 cm->cm_sc = sc;
1183 cm->cm_fib = fm->aac_fibs + i;
1184 cm->cm_fibphys = fibphys + (i * sizeof(struct aac_fib));
1375 cm->cm_fib = (struct aac_fib *)
1376 ((u_int8_t *)fm->aac_fibs + i*sc->aac_max_fib_size);
1377 cm->cm_fibphys = fibphys + i*sc->aac_max_fib_size;
1185 cm->cm_index = sc->total_fibs;
1186
1187 if ((error = bus_dmamap_create(sc->aac_buffer_dmat, 0,
1188 &cm->cm_datamap)) == 0)
1189 aac_release_command(cm);
1190 else
1191 break;
1192 sc->total_fibs++;

--- 27 unchanged lines hidden (view full) ---

1220
1221 while ((fm = TAILQ_FIRST(&sc->aac_fibmap_tqh)) != NULL) {
1222
1223 TAILQ_REMOVE(&sc->aac_fibmap_tqh, fm, fm_link);
1224 /*
1225 * We check against total_fibs to handle partially
1226 * allocated blocks.
1227 */
1378 cm->cm_index = sc->total_fibs;
1379
1380 if ((error = bus_dmamap_create(sc->aac_buffer_dmat, 0,
1381 &cm->cm_datamap)) == 0)
1382 aac_release_command(cm);
1383 else
1384 break;
1385 sc->total_fibs++;

--- 27 unchanged lines hidden (view full) ---

1413
1414 while ((fm = TAILQ_FIRST(&sc->aac_fibmap_tqh)) != NULL) {
1415
1416 TAILQ_REMOVE(&sc->aac_fibmap_tqh, fm, fm_link);
1417 /*
1418 * We check against total_fibs to handle partially
1419 * allocated blocks.
1420 */
1228 for (i = 0; i < AAC_FIB_COUNT && sc->total_fibs--; i++) {
1421 for (i = 0; i < sc->aac_max_fibs_alloc && sc->total_fibs--; i++) {
1229 cm = fm->aac_commands + i;
1230 bus_dmamap_destroy(sc->aac_buffer_dmat, cm->cm_datamap);
1231 }
1232 bus_dmamap_unload(sc->aac_fib_dmat, fm->aac_fibmap);
1233 bus_dmamem_free(sc->aac_fib_dmat, fm->aac_fibs, fm->aac_fibmap);
1234 free(fm, M_AACBUF);
1235 }
1236}

--- 12 unchanged lines hidden (view full) ---

1249 debug_called(3);
1250
1251 cm = (struct aac_command *)arg;
1252 sc = cm->cm_sc;
1253 fib = cm->cm_fib;
1254
1255 /* copy into the FIB */
1256 if (cm->cm_sgtable != NULL) {
1422 cm = fm->aac_commands + i;
1423 bus_dmamap_destroy(sc->aac_buffer_dmat, cm->cm_datamap);
1424 }
1425 bus_dmamap_unload(sc->aac_fib_dmat, fm->aac_fibmap);
1426 bus_dmamem_free(sc->aac_fib_dmat, fm->aac_fibs, fm->aac_fibmap);
1427 free(fm, M_AACBUF);
1428 }
1429}

--- 12 unchanged lines hidden (view full) ---

1442 debug_called(3);
1443
1444 cm = (struct aac_command *)arg;
1445 sc = cm->cm_sc;
1446 fib = cm->cm_fib;
1447
1448 /* copy into the FIB */
1449 if (cm->cm_sgtable != NULL) {
1257 if ((cm->cm_sc->flags & AAC_FLAGS_SG_64BIT) == 0) {
1450 if (fib->Header.Command == RawIo) {
1451 struct aac_sg_tableraw *sg;
1452 sg = (struct aac_sg_tableraw *)cm->cm_sgtable;
1453 sg->SgCount = nseg;
1454 for (i = 0; i < nseg; i++) {
1455 sg->SgEntryRaw[i].SgAddress = segs[i].ds_addr;
1456 sg->SgEntryRaw[i].SgByteCount = segs[i].ds_len;
1457 sg->SgEntryRaw[i].Next = 0;
1458 sg->SgEntryRaw[i].Prev = 0;
1459 sg->SgEntryRaw[i].Flags = 0;
1460 }
1461 /* update the FIB size for the s/g count */
1462 fib->Header.Size += nseg*sizeof(struct aac_sg_entryraw);
1463 } else if ((cm->cm_sc->flags & AAC_FLAGS_SG_64BIT) == 0) {
1258 struct aac_sg_table *sg;
1259 sg = cm->cm_sgtable;
1260 sg->SgCount = nseg;
1261 for (i = 0; i < nseg; i++) {
1262 sg->SgEntry[i].SgAddress = segs[i].ds_addr;
1263 sg->SgEntry[i].SgByteCount = segs[i].ds_len;
1264 }
1265 /* update the FIB size for the s/g count */
1464 struct aac_sg_table *sg;
1465 sg = cm->cm_sgtable;
1466 sg->SgCount = nseg;
1467 for (i = 0; i < nseg; i++) {
1468 sg->SgEntry[i].SgAddress = segs[i].ds_addr;
1469 sg->SgEntry[i].SgByteCount = segs[i].ds_len;
1470 }
1471 /* update the FIB size for the s/g count */
1266 fib->Header.Size += nseg * sizeof(struct aac_sg_entry);
1472 fib->Header.Size += nseg*sizeof(struct aac_sg_entry);
1267 } else {
1268 struct aac_sg_table64 *sg;
1269 sg = (struct aac_sg_table64 *)cm->cm_sgtable;
1270 sg->SgCount = nseg;
1271 for (i = 0; i < nseg; i++) {
1272 sg->SgEntry64[i].SgAddress = segs[i].ds_addr;
1273 sg->SgEntry64[i].SgByteCount = segs[i].ds_len;
1274 }
1275 /* update the FIB size for the s/g count */
1276 fib->Header.Size += nseg*sizeof(struct aac_sg_entry64);
1277 }
1278 }
1279
1280 /* Fix up the address values in the FIB. Use the command array index
1281 * instead of a pointer since these fields are only 32 bits. Shift
1473 } else {
1474 struct aac_sg_table64 *sg;
1475 sg = (struct aac_sg_table64 *)cm->cm_sgtable;
1476 sg->SgCount = nseg;
1477 for (i = 0; i < nseg; i++) {
1478 sg->SgEntry64[i].SgAddress = segs[i].ds_addr;
1479 sg->SgEntry64[i].SgByteCount = segs[i].ds_len;
1480 }
1481 /* update the FIB size for the s/g count */
1482 fib->Header.Size += nseg*sizeof(struct aac_sg_entry64);
1483 }
1484 }
1485
1486 /* Fix up the address values in the FIB. Use the command array index
1487 * instead of a pointer since these fields are only 32 bits. Shift
1282 * the SenderFibAddress over to make room for the fast response bit.
1488 * the SenderFibAddress over to make room for the fast response bit
1489 * and for the AIF bit
1283 */
1490 */
1284 cm->cm_fib->Header.SenderFibAddress = (cm->cm_index << 1);
1285 cm->cm_fib->Header.ReceiverFibAddress = cm->cm_fibphys;
1491 cm->cm_fib->Header.SenderFibAddress = (cm->cm_index << 2);
1492 cm->cm_fib->Header.ReceiverFibAddress = (u_int32_t)cm->cm_fibphys;
1286
1287 /* save a pointer to the command for speedy reverse-lookup */
1288 cm->cm_fib->Header.SenderData = cm->cm_index;
1289
1290 if (cm->cm_flags & AAC_CMD_DATAIN)
1291 bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap,
1292 BUS_DMASYNC_PREREAD);
1293 if (cm->cm_flags & AAC_CMD_DATAOUT)
1294 bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap,
1295 BUS_DMASYNC_PREWRITE);
1296 cm->cm_flags |= AAC_CMD_MAPPED;
1297
1493
1494 /* save a pointer to the command for speedy reverse-lookup */
1495 cm->cm_fib->Header.SenderData = cm->cm_index;
1496
1497 if (cm->cm_flags & AAC_CMD_DATAIN)
1498 bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap,
1499 BUS_DMASYNC_PREREAD);
1500 if (cm->cm_flags & AAC_CMD_DATAOUT)
1501 bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap,
1502 BUS_DMASYNC_PREWRITE);
1503 cm->cm_flags |= AAC_CMD_MAPPED;
1504
1298 /* Put the FIB on the outbound queue */
1299 if (aac_enqueue_fib(sc, cm->cm_queue, cm) == EBUSY) {
1300 aac_unmap_command(cm);
1301 sc->flags |= AAC_QUEUE_FRZN;
1302 aac_requeue_ready(cm);
1505 if (sc->flags & AAC_FLAGS_NEW_COMM) {
1506 int count = 10000000L;
1507 while (AAC_SEND_COMMAND(sc, cm) != 0) {
1508 if (--count == 0) {
1509 aac_unmap_command(cm);
1510 sc->flags |= AAC_QUEUE_FRZN;
1511 aac_requeue_ready(cm);
1512 }
1513 DELAY(5); /* wait 5 usec. */
1514 }
1515 } else {
1516 /* Put the FIB on the outbound queue */
1517 if (aac_enqueue_fib(sc, cm->cm_queue, cm) == EBUSY) {
1518 aac_unmap_command(cm);
1519 sc->flags |= AAC_QUEUE_FRZN;
1520 aac_requeue_ready(cm);
1521 }
1303 }
1304
1305 return;
1306}
1307
1308/*
1309 * Unmap a command from controller-visible space.
1310 */

--- 39 unchanged lines hidden (view full) ---

1350 sc = (struct aac_softc *)arg;
1351
1352 sc->aac_common_busaddr = segs[0].ds_addr;
1353}
1354
1355static int
1356aac_check_firmware(struct aac_softc *sc)
1357{
1522 }
1523
1524 return;
1525}
1526
1527/*
1528 * Unmap a command from controller-visible space.
1529 */

--- 39 unchanged lines hidden (view full) ---

1569 sc = (struct aac_softc *)arg;
1570
1571 sc->aac_common_busaddr = segs[0].ds_addr;
1572}
1573
1574static int
1575aac_check_firmware(struct aac_softc *sc)
1576{
1358 u_int32_t major, minor, options;
1577 u_int32_t major, minor, options, atu_size;
1359
1360 debug_called(1);
1361
1362 /*
1363 * Retrieve the firmware version numbers. Dell PERC2/QC cards with
1364 * firmware version 1.x are not compatible with this driver.
1365 */
1366 if (sc->flags & AAC_FLAGS_PERC2QC) {

--- 19 unchanged lines hidden (view full) ---

1386 * Retrieve the capabilities/supported options word so we know what
1387 * work-arounds to enable.
1388 */
1389 if (aac_sync_command(sc, AAC_MONKER_GETINFO, 0, 0, 0, 0, NULL)) {
1390 device_printf(sc->aac_dev, "RequestAdapterInfo failed\n");
1391 return (EIO);
1392 }
1393 options = AAC_GET_MAILBOX(sc, 1);
1578
1579 debug_called(1);
1580
1581 /*
1582 * Retrieve the firmware version numbers. Dell PERC2/QC cards with
1583 * firmware version 1.x are not compatible with this driver.
1584 */
1585 if (sc->flags & AAC_FLAGS_PERC2QC) {

--- 19 unchanged lines hidden (view full) ---

1605 * Retrieve the capabilities/supported options word so we know what
1606 * work-arounds to enable.
1607 */
1608 if (aac_sync_command(sc, AAC_MONKER_GETINFO, 0, 0, 0, 0, NULL)) {
1609 device_printf(sc->aac_dev, "RequestAdapterInfo failed\n");
1610 return (EIO);
1611 }
1612 options = AAC_GET_MAILBOX(sc, 1);
1613 atu_size = AAC_GET_MAILBOX(sc, 2);
1394 sc->supported_options = options;
1395
1396 if ((options & AAC_SUPPORTED_4GB_WINDOW) != 0 &&
1397 (sc->flags & AAC_FLAGS_NO4GB) == 0)
1398 sc->flags |= AAC_FLAGS_4GB_WINDOW;
1399 if (options & AAC_SUPPORTED_NONDASD)
1400 sc->flags |= AAC_FLAGS_ENABLE_CAM;
1401 if ((options & AAC_SUPPORTED_SGMAP_HOST64) != 0
1402 && (sizeof(bus_addr_t) > 4)) {
1403 device_printf(sc->aac_dev, "Enabling 64-bit address support\n");
1404 sc->flags |= AAC_FLAGS_SG_64BIT;
1405 }
1614 sc->supported_options = options;
1615
1616 if ((options & AAC_SUPPORTED_4GB_WINDOW) != 0 &&
1617 (sc->flags & AAC_FLAGS_NO4GB) == 0)
1618 sc->flags |= AAC_FLAGS_4GB_WINDOW;
1619 if (options & AAC_SUPPORTED_NONDASD)
1620 sc->flags |= AAC_FLAGS_ENABLE_CAM;
1621 if ((options & AAC_SUPPORTED_SGMAP_HOST64) != 0
1622 && (sizeof(bus_addr_t) > 4)) {
1623 device_printf(sc->aac_dev, "Enabling 64-bit address support\n");
1624 sc->flags |= AAC_FLAGS_SG_64BIT;
1625 }
1626 if ((options & AAC_SUPPORTED_NEW_COMM) && sc->aac_if.aif_send_command)
1627 sc->flags |= AAC_FLAGS_NEW_COMM;
1628 if (options & AAC_SUPPORTED_64BIT_ARRAYSIZE)
1629 sc->flags |= AAC_FLAGS_ARRAY_64BIT;
1406
1407 /* Check for broken hardware that does a lower number of commands */
1630
1631 /* Check for broken hardware that does a lower number of commands */
1408 if ((sc->flags & AAC_FLAGS_256FIBS) == 0)
1409 sc->aac_max_fibs = AAC_MAX_FIBS;
1410 else
1411 sc->aac_max_fibs = 256;
1632 sc->aac_max_fibs = (sc->flags & AAC_FLAGS_256FIBS ? 256:512);
1412
1633
1634 /* Remap mem. resource, if required */
1635 if ((sc->flags & AAC_FLAGS_NEW_COMM) &&
1636 atu_size > rman_get_size(sc->aac_regs_resource)) {
1637 bus_release_resource(
1638 sc->aac_dev, SYS_RES_MEMORY,
1639 sc->aac_regs_rid, sc->aac_regs_resource);
1640 sc->aac_regs_resource = bus_alloc_resource(
1641 sc->aac_dev, SYS_RES_MEMORY, &sc->aac_regs_rid,
1642 0ul, ~0ul, atu_size, RF_ACTIVE);
1643 if (sc->aac_regs_resource == NULL) {
1644 sc->aac_regs_resource = bus_alloc_resource_any(
1645 sc->aac_dev, SYS_RES_MEMORY,
1646 &sc->aac_regs_rid, RF_ACTIVE);
1647 if (sc->aac_regs_resource == NULL) {
1648 device_printf(sc->aac_dev,
1649 "couldn't allocate register window\n");
1650 return (ENXIO);
1651 }
1652 sc->flags &= ~AAC_FLAGS_NEW_COMM;
1653 }
1654 sc->aac_btag = rman_get_bustag(sc->aac_regs_resource);
1655 sc->aac_bhandle = rman_get_bushandle(sc->aac_regs_resource);
1656 }
1657
1658 /* Read preferred settings */
1659 sc->aac_max_fib_size = sizeof(struct aac_fib);
1660 sc->aac_max_sectors = 128; /* 64KB */
1661 if (sc->flags & AAC_FLAGS_SG_64BIT)
1662 sc->aac_sg_tablesize = (AAC_FIB_DATASIZE - sizeof(struct aac_blockwrite64)
1663 + sizeof(struct aac_sg_table64)) / sizeof(struct aac_sg_table64);
1664 else
1665 sc->aac_sg_tablesize = (AAC_FIB_DATASIZE - sizeof(struct aac_blockwrite)
1666 + sizeof(struct aac_sg_table)) / sizeof(struct aac_sg_table);
1667 if (!aac_sync_command(sc, AAC_MONKER_GETCOMMPREF, 0, 0, 0, 0, NULL)) {
1668 options = AAC_GET_MAILBOX(sc, 1);
1669 sc->aac_max_fib_size = (options & 0xFFFF);
1670 sc->aac_max_sectors = (options >> 16) << 1;
1671 options = AAC_GET_MAILBOX(sc, 2);
1672 sc->aac_sg_tablesize = (options >> 16);
1673 options = AAC_GET_MAILBOX(sc, 3);
1674 sc->aac_max_fibs = (options & 0xFFFF);
1675 }
1676 if (sc->aac_max_fib_size > PAGE_SIZE)
1677 sc->aac_max_fib_size = PAGE_SIZE;
1678 sc->aac_max_fibs_alloc = PAGE_SIZE / sc->aac_max_fib_size;
1679
1413 return (0);
1414}
1415
1416static int
1417aac_init(struct aac_softc *sc)
1418{
1419 struct aac_adapter_init *ip;
1420 time_t then;

--- 32 unchanged lines hidden (view full) ---

1453 if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */
1454 1, 0, /* algnmnt, boundary */
1455 (sc->flags & AAC_FLAGS_SG_64BIT) ?
1456 BUS_SPACE_MAXADDR :
1457 BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
1458 BUS_SPACE_MAXADDR, /* highaddr */
1459 NULL, NULL, /* filter, filterarg */
1460 MAXBSIZE, /* maxsize */
1680 return (0);
1681}
1682
1683static int
1684aac_init(struct aac_softc *sc)
1685{
1686 struct aac_adapter_init *ip;
1687 time_t then;

--- 32 unchanged lines hidden (view full) ---

1720 if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */
1721 1, 0, /* algnmnt, boundary */
1722 (sc->flags & AAC_FLAGS_SG_64BIT) ?
1723 BUS_SPACE_MAXADDR :
1724 BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
1725 BUS_SPACE_MAXADDR, /* highaddr */
1726 NULL, NULL, /* filter, filterarg */
1727 MAXBSIZE, /* maxsize */
1461 AAC_MAXSGENTRIES, /* nsegments */
1728 sc->aac_sg_tablesize, /* nsegments */
1462 MAXBSIZE, /* maxsegsize */
1463 BUS_DMA_ALLOCNOW, /* flags */
1464 busdma_lock_mutex, /* lockfunc */
1465 &sc->aac_io_lock, /* lockfuncarg */
1466 &sc->aac_buffer_dmat)) {
1467 device_printf(sc->aac_dev, "can't allocate buffer DMA tag\n");
1468 goto out;
1469 }
1470
1471 /*
1472 * Create DMA tag for mapping FIBs into controller-addressable space..
1473 */
1474 if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */
1475 1, 0, /* algnmnt, boundary */
1476 (sc->flags & AAC_FLAGS_4GB_WINDOW) ?
1477 BUS_SPACE_MAXADDR_32BIT :
1478 0x7fffffff, /* lowaddr */
1479 BUS_SPACE_MAXADDR, /* highaddr */
1480 NULL, NULL, /* filter, filterarg */
1729 MAXBSIZE, /* maxsegsize */
1730 BUS_DMA_ALLOCNOW, /* flags */
1731 busdma_lock_mutex, /* lockfunc */
1732 &sc->aac_io_lock, /* lockfuncarg */
1733 &sc->aac_buffer_dmat)) {
1734 device_printf(sc->aac_dev, "can't allocate buffer DMA tag\n");
1735 goto out;
1736 }
1737
1738 /*
1739 * Create DMA tag for mapping FIBs into controller-addressable space..
1740 */
1741 if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */
1742 1, 0, /* algnmnt, boundary */
1743 (sc->flags & AAC_FLAGS_4GB_WINDOW) ?
1744 BUS_SPACE_MAXADDR_32BIT :
1745 0x7fffffff, /* lowaddr */
1746 BUS_SPACE_MAXADDR, /* highaddr */
1747 NULL, NULL, /* filter, filterarg */
1481 AAC_FIB_COUNT *
1482 sizeof(struct aac_fib), /* maxsize */
1748 sc->aac_max_fibs_alloc *
1749 sc->aac_max_fib_size, /* maxsize */
1483 1, /* nsegments */
1750 1, /* nsegments */
1484 AAC_FIB_COUNT *
1485 sizeof(struct aac_fib), /* maxsegsize */
1751 sc->aac_max_fibs_alloc *
1752 sc->aac_max_fib_size, /* maxsegsize */
1486 0, /* flags */
1487 NULL, NULL, /* No locking needed */
1488 &sc->aac_fib_dmat)) {
1489 device_printf(sc->aac_dev, "can't allocate FIB DMA tag\n");;
1490 goto out;
1491 }
1492
1493 /*

--- 36 unchanged lines hidden (view full) ---

1530 sc->aac_common = (struct aac_common *)
1531 ((uint8_t *)sc->aac_common + 8192);
1532 sc->aac_common_busaddr += 8192;
1533 }
1534 bzero(sc->aac_common, sizeof(*sc->aac_common));
1535
1536 /* Allocate some FIBs and associated command structs */
1537 TAILQ_INIT(&sc->aac_fibmap_tqh);
1753 0, /* flags */
1754 NULL, NULL, /* No locking needed */
1755 &sc->aac_fib_dmat)) {
1756 device_printf(sc->aac_dev, "can't allocate FIB DMA tag\n");;
1757 goto out;
1758 }
1759
1760 /*

--- 36 unchanged lines hidden (view full) ---

1797 sc->aac_common = (struct aac_common *)
1798 ((uint8_t *)sc->aac_common + 8192);
1799 sc->aac_common_busaddr += 8192;
1800 }
1801 bzero(sc->aac_common, sizeof(*sc->aac_common));
1802
1803 /* Allocate some FIBs and associated command structs */
1804 TAILQ_INIT(&sc->aac_fibmap_tqh);
1538 sc->aac_commands = malloc(AAC_MAX_FIBS * sizeof(struct aac_command),
1805 sc->aac_commands = malloc(sc->aac_max_fibs * sizeof(struct aac_command),
1539 M_AACBUF, M_WAITOK|M_ZERO);
1540 while (sc->total_fibs < AAC_PREALLOCATE_FIBS) {
1541 if (aac_alloc_commands(sc) != 0)
1542 break;
1543 }
1544 if (sc->total_fibs == 0)
1545 goto out;
1546
1547 /*
1548 * Fill in the init structure. This tells the adapter about the
1549 * physical location of various important shared data structures.
1550 */
1551 ip = &sc->aac_common->ac_init;
1552 ip->InitStructRevision = AAC_INIT_STRUCT_REVISION;
1806 M_AACBUF, M_WAITOK|M_ZERO);
1807 while (sc->total_fibs < AAC_PREALLOCATE_FIBS) {
1808 if (aac_alloc_commands(sc) != 0)
1809 break;
1810 }
1811 if (sc->total_fibs == 0)
1812 goto out;
1813
1814 /*
1815 * Fill in the init structure. This tells the adapter about the
1816 * physical location of various important shared data structures.
1817 */
1818 ip = &sc->aac_common->ac_init;
1819 ip->InitStructRevision = AAC_INIT_STRUCT_REVISION;
1820 if (sc->aac_max_fib_size > sizeof(struct aac_fib)) {
1821 ip->InitStructRevision = AAC_INIT_STRUCT_REVISION_4;
1822 sc->flags |= AAC_FLAGS_RAW_IO;
1823 }
1553 ip->MiniPortRevision = AAC_INIT_STRUCT_MINIPORT_REVISION;
1554
1555 ip->AdapterFibsPhysicalAddress = sc->aac_common_busaddr +
1556 offsetof(struct aac_common, ac_fibs);
1557 ip->AdapterFibsVirtualAddress = 0;
1558 ip->AdapterFibsSize = AAC_ADAPTER_FIBS * sizeof(struct aac_fib);
1559 ip->AdapterFibAlign = sizeof(struct aac_fib);
1560

--- 9 unchanged lines hidden (view full) ---

1570 */
1571 ip->HostPhysMemPages = ctob(physmem) / AAC_PAGE_SIZE;
1572 if (sc->flags & AAC_FLAGS_BROKEN_MEMMAP) {
1573 ip->HostPhysMemPages =
1574 (ip->HostPhysMemPages + AAC_PAGE_SIZE) / AAC_PAGE_SIZE;
1575 }
1576 ip->HostElapsedSeconds = time_uptime; /* reset later if invalid */
1577
1824 ip->MiniPortRevision = AAC_INIT_STRUCT_MINIPORT_REVISION;
1825
1826 ip->AdapterFibsPhysicalAddress = sc->aac_common_busaddr +
1827 offsetof(struct aac_common, ac_fibs);
1828 ip->AdapterFibsVirtualAddress = 0;
1829 ip->AdapterFibsSize = AAC_ADAPTER_FIBS * sizeof(struct aac_fib);
1830 ip->AdapterFibAlign = sizeof(struct aac_fib);
1831

--- 9 unchanged lines hidden (view full) ---

1841 */
1842 ip->HostPhysMemPages = ctob(physmem) / AAC_PAGE_SIZE;
1843 if (sc->flags & AAC_FLAGS_BROKEN_MEMMAP) {
1844 ip->HostPhysMemPages =
1845 (ip->HostPhysMemPages + AAC_PAGE_SIZE) / AAC_PAGE_SIZE;
1846 }
1847 ip->HostElapsedSeconds = time_uptime; /* reset later if invalid */
1848
1849 ip->InitFlags = 0;
1850 if (sc->flags & AAC_FLAGS_NEW_COMM) {
1851 ip->InitFlags = INITFLAGS_NEW_COMM_SUPPORTED;
1852 device_printf(sc->aac_dev, "New comm. interface enabled\n");
1853 }
1854
1855 ip->MaxIoCommands = sc->aac_max_fibs;
1856 ip->MaxIoSize = sc->aac_max_sectors << 9;
1857 ip->MaxFibSize = sc->aac_max_fib_size;
1858
1578 /*
1579 * Initialise FIB queues. Note that it appears that the layout of the
1580 * indexes and the segmentation of the entries may be mandated by the
1581 * adapter, which is only told about the base of the queue index fields.
1582 *
1583 * The initial values of the indices are assumed to inform the adapter
1584 * of the sizes of the respective queues, and theoretically it could
1585 * work out the entire layout of the queue structures from this. We

--- 89 unchanged lines hidden (view full) ---

1675
1676 error = 0;
1677out:
1678 return(error);
1679}
1680
1681/*
1682 * Send a synchronous command to the controller and wait for a result.
1859 /*
1860 * Initialise FIB queues. Note that it appears that the layout of the
1861 * indexes and the segmentation of the entries may be mandated by the
1862 * adapter, which is only told about the base of the queue index fields.
1863 *
1864 * The initial values of the indices are assumed to inform the adapter
1865 * of the sizes of the respective queues, and theoretically it could
1866 * work out the entire layout of the queue structures from this. We

--- 89 unchanged lines hidden (view full) ---

1956
1957 error = 0;
1958out:
1959 return(error);
1960}
1961
1962/*
1963 * Send a synchronous command to the controller and wait for a result.
1964 * Indicate if the controller completed the command with an error status.
1683 */
1684static int
1685aac_sync_command(struct aac_softc *sc, u_int32_t command,
1686 u_int32_t arg0, u_int32_t arg1, u_int32_t arg2, u_int32_t arg3,
1687 u_int32_t *sp)
1688{
1689 time_t then;
1690 u_int32_t status;

--- 20 unchanged lines hidden (view full) ---

1711
1712 /* clear the completion flag */
1713 AAC_CLEAR_ISTATUS(sc, AAC_DB_SYNC_COMMAND);
1714
1715 /* get the command status */
1716 status = AAC_GET_MAILBOX(sc, 0);
1717 if (sp != NULL)
1718 *sp = status;
1965 */
1966static int
1967aac_sync_command(struct aac_softc *sc, u_int32_t command,
1968 u_int32_t arg0, u_int32_t arg1, u_int32_t arg2, u_int32_t arg3,
1969 u_int32_t *sp)
1970{
1971 time_t then;
1972 u_int32_t status;

--- 20 unchanged lines hidden (view full) ---

1993
1994 /* clear the completion flag */
1995 AAC_CLEAR_ISTATUS(sc, AAC_DB_SYNC_COMMAND);
1996
1997 /* get the command status */
1998 status = AAC_GET_MAILBOX(sc, 0);
1999 if (sp != NULL)
2000 *sp = status;
2001
2002 if (status != 0x01)
2003 return (-1);
1719 return(0);
1720}
1721
1722int
1723aac_sync_fib(struct aac_softc *sc, u_int32_t command, u_int32_t xferstate,
1724 struct aac_fib *fib, u_int16_t datasize)
1725{
1726 debug_called(3);
2004 return(0);
2005}
2006
2007int
2008aac_sync_fib(struct aac_softc *sc, u_int32_t command, u_int32_t xferstate,
2009 struct aac_fib *fib, u_int16_t datasize)
2010{
2011 debug_called(3);
2012 mtx_assert(&sc->aac_io_lock, MA_OWNED);
1727
1728 if (datasize > AAC_FIB_DATASIZE)
1729 return(EINVAL);
1730
1731 /*
1732 * Set up the sync FIB
1733 */
1734 fib->Header.XferState = AAC_FIBSTATE_HOSTOWNED |

--- 162 unchanged lines hidden (view full) ---

1897 /*
1898 * As above, an index is used instead of an actual address.
1899 * Gotta shift the index to account for the fast response
1900 * bit. No other correction is needed since this value was
1901 * originally provided by the driver via the SenderFibAddress
1902 * field.
1903 */
1904 fib_index = (sc->aac_qentries[queue] + ci)->aq_fib_addr;
2013
2014 if (datasize > AAC_FIB_DATASIZE)
2015 return(EINVAL);
2016
2017 /*
2018 * Set up the sync FIB
2019 */
2020 fib->Header.XferState = AAC_FIBSTATE_HOSTOWNED |

--- 162 unchanged lines hidden (view full) ---

2183 /*
2184 * As above, an index is used instead of an actual address.
2185 * Gotta shift the index to account for the fast response
2186 * bit. No other correction is needed since this value was
2187 * originally provided by the driver via the SenderFibAddress
2188 * field.
2189 */
2190 fib_index = (sc->aac_qentries[queue] + ci)->aq_fib_addr;
1905 cm = sc->aac_commands + (fib_index >> 1);
2191 cm = sc->aac_commands + (fib_index >> 2);
1906 *fib_addr = cm->cm_fib;
1907
1908 /*
1909 * Is this a fast response? If it is, update the fib fields in
1910 * local memory since the whole fib isn't DMA'd back up.
1911 */
1912 if (fib_index & 0x01) {
1913 (*fib_addr)->Header.XferState |= AAC_FIBSTATE_DONEADAP;

--- 373 unchanged lines hidden (view full) ---

2287}
2288
2289static void
2290aac_rx_set_interrupts(struct aac_softc *sc, int enable)
2291{
2292 debug(2, "%sable interrupts", enable ? "en" : "dis");
2293
2294 if (enable) {
2192 *fib_addr = cm->cm_fib;
2193
2194 /*
2195 * Is this a fast response? If it is, update the fib fields in
2196 * local memory since the whole fib isn't DMA'd back up.
2197 */
2198 if (fib_index & 0x01) {
2199 (*fib_addr)->Header.XferState |= AAC_FIBSTATE_DONEADAP;

--- 373 unchanged lines hidden (view full) ---

2573}
2574
2575static void
2576aac_rx_set_interrupts(struct aac_softc *sc, int enable)
2577{
2578 debug(2, "%sable interrupts", enable ? "en" : "dis");
2579
2580 if (enable) {
2295 AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS);
2581 if (sc->flags & AAC_FLAGS_NEW_COMM)
2582 AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INT_NEW_COMM);
2583 else
2584 AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS);
2296 } else {
2297 AAC_SETREG4(sc, AAC_RX_OIMR, ~0);
2298 }
2299}
2300
2301static void
2302aac_fa_set_interrupts(struct aac_softc *sc, int enable)
2303{

--- 9 unchanged lines hidden (view full) ---

2313}
2314
2315static void
2316aac_rkt_set_interrupts(struct aac_softc *sc, int enable)
2317{
2318 debug(2, "%sable interrupts", enable ? "en" : "dis");
2319
2320 if (enable) {
2585 } else {
2586 AAC_SETREG4(sc, AAC_RX_OIMR, ~0);
2587 }
2588}
2589
2590static void
2591aac_fa_set_interrupts(struct aac_softc *sc, int enable)
2592{

--- 9 unchanged lines hidden (view full) ---

2602}
2603
2604static void
2605aac_rkt_set_interrupts(struct aac_softc *sc, int enable)
2606{
2607 debug(2, "%sable interrupts", enable ? "en" : "dis");
2608
2609 if (enable) {
2321 AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INTERRUPTS);
2610 if (sc->flags & AAC_FLAGS_NEW_COMM)
2611 AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INT_NEW_COMM);
2612 else
2613 AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INTERRUPTS);
2322 } else {
2323 AAC_SETREG4(sc, AAC_RKT_OIMR, ~0);
2324 }
2325}
2326
2327/*
2614 } else {
2615 AAC_SETREG4(sc, AAC_RKT_OIMR, ~0);
2616 }
2617}
2618
2619/*
2620 * New comm. interface: Send command functions
2621 */
2622static int
2623aac_rx_send_command(struct aac_softc *sc, struct aac_command *cm)
2624{
2625 u_int32_t index, device;
2626
2627 debug(2, "send command (new comm.)");
2628
2629 index = AAC_GETREG4(sc, AAC_RX_IQUE);
2630 if (index == 0xffffffffL)
2631 index = AAC_GETREG4(sc, AAC_RX_IQUE);
2632 if (index == 0xffffffffL)
2633 return index;
2634 aac_enqueue_busy(cm);
2635 device = index;
2636 AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL));
2637 device += 4;
2638 AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32));
2639 device += 4;
2640 AAC_SETREG4(sc, device, cm->cm_fib->Header.Size);
2641 AAC_SETREG4(sc, AAC_RX_IQUE, index);
2642 return 0;
2643}
2644
2645static int
2646aac_rkt_send_command(struct aac_softc *sc, struct aac_command *cm)
2647{
2648 u_int32_t index, device;
2649
2650 debug(2, "send command (new comm.)");
2651
2652 index = AAC_GETREG4(sc, AAC_RKT_IQUE);
2653 if (index == 0xffffffffL)
2654 index = AAC_GETREG4(sc, AAC_RKT_IQUE);
2655 if (index == 0xffffffffL)
2656 return index;
2657 aac_enqueue_busy(cm);
2658 device = index;
2659 AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL));
2660 device += 4;
2661 AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32));
2662 device += 4;
2663 AAC_SETREG4(sc, device, cm->cm_fib->Header.Size);
2664 AAC_SETREG4(sc, AAC_RKT_IQUE, index);
2665 return 0;
2666}
2667
2668/*
2669 * New comm. interface: get, set outbound queue index
2670 */
2671static int
2672aac_rx_get_outb_queue(struct aac_softc *sc)
2673{
2674 debug_called(3);
2675
2676 return(AAC_GETREG4(sc, AAC_RX_OQUE));
2677}
2678
2679static int
2680aac_rkt_get_outb_queue(struct aac_softc *sc)
2681{
2682 debug_called(3);
2683
2684 return(AAC_GETREG4(sc, AAC_RKT_OQUE));
2685}
2686
2687static void
2688aac_rx_set_outb_queue(struct aac_softc *sc, int index)
2689{
2690 debug_called(3);
2691
2692 AAC_SETREG4(sc, AAC_RX_OQUE, index);
2693}
2694
2695static void
2696aac_rkt_set_outb_queue(struct aac_softc *sc, int index)
2697{
2698 debug_called(3);
2699
2700 AAC_SETREG4(sc, AAC_RKT_OQUE, index);
2701}
2702
2703/*
2328 * Debugging and Diagnostics
2329 */
2330
2331/*
2332 * Print some information about the controller.
2333 */
2334static void
2335aac_describe_controller(struct aac_softc *sc)

--- 11 unchanged lines hidden (view full) ---

2347 aac_release_sync_fib(sc);
2348 return;
2349 }
2350
2351 /* save the kernel revision structure for later use */
2352 info = (struct aac_adapter_info *)&fib->data[0];
2353 sc->aac_revision = info->KernelRevision;
2354
2704 * Debugging and Diagnostics
2705 */
2706
2707/*
2708 * Print some information about the controller.
2709 */
2710static void
2711aac_describe_controller(struct aac_softc *sc)

--- 11 unchanged lines hidden (view full) ---

2723 aac_release_sync_fib(sc);
2724 return;
2725 }
2726
2727 /* save the kernel revision structure for later use */
2728 info = (struct aac_adapter_info *)&fib->data[0];
2729 sc->aac_revision = info->KernelRevision;
2730
2731 device_printf(sc->aac_dev, "Adaptec Raid Controller %d.%d.%d-%d\n",
2732 AAC_DRIVER_VERSION >> 24,
2733 (AAC_DRIVER_VERSION >> 16) & 0xFF,
2734 AAC_DRIVER_VERSION & 0xFF,
2735 AAC_DRIVER_BUILD);
2736
2355 if (bootverbose) {
2356 device_printf(sc->aac_dev, "%s %dMHz, %dMB memory "
2357 "(%dMB cache, %dMB execution), %s\n",
2358 aac_describe_code(aac_cpu_variant, info->CpuVariant),
2359 info->ClockSpeed, info->TotalMem / (1024 * 1024),
2360 info->BufferMem / (1024 * 1024),
2361 info->ExecutionMem / (1024 * 1024),
2362 aac_describe_code(aac_battery_platform,

--- 17 unchanged lines hidden (view full) ---

2380 "\5HOSTTIME"
2381 "\6RAID50"
2382 "\7WINDOW4GB"
2383 "\10SCSIUPGD"
2384 "\11SOFTERR"
2385 "\12NORECOND"
2386 "\13SGMAP64"
2387 "\14ALARM"
2737 if (bootverbose) {
2738 device_printf(sc->aac_dev, "%s %dMHz, %dMB memory "
2739 "(%dMB cache, %dMB execution), %s\n",
2740 aac_describe_code(aac_cpu_variant, info->CpuVariant),
2741 info->ClockSpeed, info->TotalMem / (1024 * 1024),
2742 info->BufferMem / (1024 * 1024),
2743 info->ExecutionMem / (1024 * 1024),
2744 aac_describe_code(aac_battery_platform,

--- 17 unchanged lines hidden (view full) ---

2762 "\5HOSTTIME"
2763 "\6RAID50"
2764 "\7WINDOW4GB"
2765 "\10SCSIUPGD"
2766 "\11SOFTERR"
2767 "\12NORECOND"
2768 "\13SGMAP64"
2769 "\14ALARM"
2388 "\15NONDASD");
2770 "\15NONDASD"
2771 "\16SCSIMGT"
2772 "\17RAIDSCSI"
2773 "\21ADPTINFO"
2774 "\22NEWCOMM"
2775 "\23ARRAY64BIT"
2776 "\24HEATSENSOR");
2389 }
2390 aac_release_sync_fib(sc);
2391}
2392
2393/*
2394 * Look up a text description of a numeric error code and return a pointer to
2395 * same.
2396 */

--- 121 unchanged lines hidden (view full) ---

2518 debug(1, "FSACTL_MINIPORT_REV_CHECK");
2519 error = aac_rev_check(sc, arg);
2520 break;
2521 case FSACTL_QUERY_DISK:
2522 arg = *(caddr_t*)arg;
2523 case FSACTL_LNX_QUERY_DISK:
2524 debug(1, "FSACTL_QUERY_DISK");
2525 error = aac_query_disk(sc, arg);
2777 }
2778 aac_release_sync_fib(sc);
2779}
2780
2781/*
2782 * Look up a text description of a numeric error code and return a pointer to
2783 * same.
2784 */

--- 121 unchanged lines hidden (view full) ---

2906 debug(1, "FSACTL_MINIPORT_REV_CHECK");
2907 error = aac_rev_check(sc, arg);
2908 break;
2909 case FSACTL_QUERY_DISK:
2910 arg = *(caddr_t*)arg;
2911 case FSACTL_LNX_QUERY_DISK:
2912 debug(1, "FSACTL_QUERY_DISK");
2913 error = aac_query_disk(sc, arg);
2526 break;
2914 break;
2527 case FSACTL_DELETE_DISK:
2528 case FSACTL_LNX_DELETE_DISK:
2529 /*
2530 * We don't trust the underland to tell us when to delete a
2531 * container, rather we rely on an AIF coming from the
2532 * controller
2533 */
2534 error = 0;
2535 break;
2915 case FSACTL_DELETE_DISK:
2916 case FSACTL_LNX_DELETE_DISK:
2917 /*
2918 * We don't trust the underland to tell us when to delete a
2919 * container, rather we rely on an AIF coming from the
2920 * controller
2921 */
2922 error = 0;
2923 break;
2924 case FSACTL_GET_PCI_INFO:
2925 arg = *(caddr_t*)arg;
2926 case FSACTL_LNX_GET_PCI_INFO:
2927 debug(1, "FSACTL_GET_PCI_INFO");
2928 error = aac_get_pci_info(sc, arg);
2929 break;
2536 default:
2537 debug(1, "unsupported cmd 0x%lx\n", cmd);
2538 error = EINVAL;
2539 break;
2540 }
2541 return(error);
2542}
2543

--- 16 unchanged lines hidden (view full) ---

2560 if (revents == 0) {
2561 if (poll_events & (POLLIN | POLLRDNORM))
2562 selrecord(td, &sc->rcv_select);
2563 }
2564
2565 return (revents);
2566}
2567
2930 default:
2931 debug(1, "unsupported cmd 0x%lx\n", cmd);
2932 error = EINVAL;
2933 break;
2934 }
2935 return(error);
2936}
2937

--- 16 unchanged lines hidden (view full) ---

2954 if (revents == 0) {
2955 if (poll_events & (POLLIN | POLLRDNORM))
2956 selrecord(td, &sc->rcv_select);
2957 }
2958
2959 return (revents);
2960}
2961
2962static void
2963aac_ioctl_event(struct aac_softc *sc, struct aac_event *event, void *arg)
2964{
2965
2966 switch (event->ev_type) {
2967 case AAC_EVENT_CMFREE:
2968 mtx_lock(&sc->aac_io_lock);
2969 if (aac_alloc_command(sc, (struct aac_command **)arg) == 0) {
2970 aac_add_event(sc, event);
2971 mtx_unlock(&sc->aac_io_lock);
2972 return;
2973 }
2974 free(event, M_AACBUF);
2975 wakeup(aac_ioctl_sendfib);
2976 mtx_unlock(&sc->aac_io_lock);
2977 break;
2978 default:
2979 break;
2980 }
2981}
2982
2568/*
2569 * Send a FIB supplied from userspace
2570 */
2571static int
2572aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib)
2573{
2574 struct aac_command *cm;
2575 int size, error;
2576
2577 debug_called(2);
2578
2579 cm = NULL;
2580
2581 /*
2582 * Get a command
2583 */
2584 mtx_lock(&sc->aac_io_lock);
2585 if (aac_alloc_command(sc, &cm)) {
2983/*
2984 * Send a FIB supplied from userspace
2985 */
2986static int
2987aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib)
2988{
2989 struct aac_command *cm;
2990 int size, error;
2991
2992 debug_called(2);
2993
2994 cm = NULL;
2995
2996 /*
2997 * Get a command
2998 */
2999 mtx_lock(&sc->aac_io_lock);
3000 if (aac_alloc_command(sc, &cm)) {
2586 error = EBUSY;
2587 goto out;
3001 struct aac_event *event;
3002
3003 event = malloc(sizeof(struct aac_event), M_AACBUF,
3004 M_NOWAIT | M_ZERO);
3005 if (event == NULL) {
3006 error = EBUSY;
3007 goto out;
3008 }
3009 event->ev_type = AAC_EVENT_CMFREE;
3010 event->ev_callback = aac_ioctl_event;
3011 event->ev_arg = &cm;
3012 aac_add_event(sc, event);
3013 msleep(aac_ioctl_sendfib, &sc->aac_io_lock, 0, "sendfib", 0);
2588 }
2589
2590 /*
2591 * Fetch the FIB header, then re-copy to get data as well.
2592 */
2593 if ((error = copyin(ufib, cm->cm_fib,
2594 sizeof(struct aac_fib_header))) != 0)
2595 goto out;

--- 135 unchanged lines hidden (view full) ---

2731 * were not marked 'found'. Since the controller didn't
2732 * list them they must have been deleted. Do the
2733 * appropriate steps to destroy the device. Also reset
2734 * the co->co_found field.
2735 */
2736 co = TAILQ_FIRST(&sc->aac_container_tqh);
2737 while (co != NULL) {
2738 if (co->co_found == 0) {
3014 }
3015
3016 /*
3017 * Fetch the FIB header, then re-copy to get data as well.
3018 */
3019 if ((error = copyin(ufib, cm->cm_fib,
3020 sizeof(struct aac_fib_header))) != 0)
3021 goto out;

--- 135 unchanged lines hidden (view full) ---

3157 * were not marked 'found'. Since the controller didn't
3158 * list them they must have been deleted. Do the
3159 * appropriate steps to destroy the device. Also reset
3160 * the co->co_found field.
3161 */
3162 co = TAILQ_FIRST(&sc->aac_container_tqh);
3163 while (co != NULL) {
3164 if (co->co_found == 0) {
3165 mtx_unlock(&sc->aac_io_lock);
3166 mtx_lock(&Giant);
2739 device_delete_child(sc->aac_dev,
2740 co->co_disk);
3167 device_delete_child(sc->aac_dev,
3168 co->co_disk);
3169 mtx_unlock(&Giant);
3170 mtx_lock(&sc->aac_io_lock);
2741 co_next = TAILQ_NEXT(co, co_link);
2742 mtx_lock(&sc->aac_container_lock);
2743 TAILQ_REMOVE(&sc->aac_container_tqh, co,
2744 co_link);
2745 mtx_unlock(&sc->aac_container_lock);
2746 free(co, M_AACBUF);
2747 co = co_next;
2748 } else {
2749 co->co_found = 0;
2750 co = TAILQ_NEXT(co, co_link);
2751 }
2752 }
2753
2754 /* Attach the newly created containers */
3171 co_next = TAILQ_NEXT(co, co_link);
3172 mtx_lock(&sc->aac_container_lock);
3173 TAILQ_REMOVE(&sc->aac_container_tqh, co,
3174 co_link);
3175 mtx_unlock(&sc->aac_container_lock);
3176 free(co, M_AACBUF);
3177 co = co_next;
3178 } else {
3179 co->co_found = 0;
3180 co = TAILQ_NEXT(co, co_link);
3181 }
3182 }
3183
3184 /* Attach the newly created containers */
2755 if (added)
3185 if (added) {
3186 mtx_unlock(&sc->aac_io_lock);
3187 mtx_lock(&Giant);
2756 bus_generic_attach(sc->aac_dev);
3188 bus_generic_attach(sc->aac_dev);
3189 mtx_unlock(&Giant);
3190 mtx_lock(&sc->aac_io_lock);
3191 }
2757
2758 break;
2759
2760 default:
2761 break;
2762 }
2763
2764 default:

--- 117 unchanged lines hidden (view full) ---

2882 "aac_return_aif: copyout returned %d\n", error);
2883 else
2884 sc->aac_aifq_tail = next;
2885
2886 mtx_unlock(&sc->aac_aifq_lock);
2887 return(error);
2888}
2889
3192
3193 break;
3194
3195 default:
3196 break;
3197 }
3198
3199 default:

--- 117 unchanged lines hidden (view full) ---

3317 "aac_return_aif: copyout returned %d\n", error);
3318 else
3319 sc->aac_aifq_tail = next;
3320
3321 mtx_unlock(&sc->aac_aifq_lock);
3322 return(error);
3323}
3324
3325static int
3326aac_get_pci_info(struct aac_softc *sc, caddr_t uptr)
3327{
3328 struct aac_pci_info {
3329 u_int32_t bus;
3330 u_int32_t slot;
3331 } pciinf;
3332 int error;
3333
3334 debug_called(2);
3335
3336 pciinf.bus = pci_get_bus(sc->aac_dev);
3337 pciinf.slot = pci_get_slot(sc->aac_dev);
3338
3339 error = copyout((caddr_t)&pciinf, uptr,
3340 sizeof(struct aac_pci_info));
3341
3342 return (error);
3343}
3344
2890/*
2891 * Give the userland some information about the container. The AAC arch
2892 * expects the driver to be a SCSI passthrough type driver, so it expects
2893 * the containers to have b:t:l numbers. Fake it.
2894 */
2895static int
2896aac_query_disk(struct aac_softc *sc, caddr_t uptr)
2897{

--- 121 unchanged lines hidden (view full) ---

3019 continue;
3020
3021 caminf = (struct aac_sim *)malloc( sizeof(struct aac_sim),
3022 M_AACBUF, M_NOWAIT | M_ZERO);
3023 if (caminf == NULL) {
3024 device_printf(sc->aac_dev,
3025 "No memory to add passthrough bus %d\n", i);
3026 break;
3345/*
3346 * Give the userland some information about the container. The AAC arch
3347 * expects the driver to be a SCSI passthrough type driver, so it expects
3348 * the containers to have b:t:l numbers. Fake it.
3349 */
3350static int
3351aac_query_disk(struct aac_softc *sc, caddr_t uptr)
3352{

--- 121 unchanged lines hidden (view full) ---

3474 continue;
3475
3476 caminf = (struct aac_sim *)malloc( sizeof(struct aac_sim),
3477 M_AACBUF, M_NOWAIT | M_ZERO);
3478 if (caminf == NULL) {
3479 device_printf(sc->aac_dev,
3480 "No memory to add passthrough bus %d\n", i);
3481 break;
3027 }
3482 };
3028
3029 child = device_add_child(sc->aac_dev, "aacp", -1);
3030 if (child == NULL) {
3031 device_printf(sc->aac_dev,
3032 "device_add_child failed for passthrough bus %d\n",
3033 i);
3034 free(caminf, M_AACBUF);
3483
3484 child = device_add_child(sc->aac_dev, "aacp", -1);
3485 if (child == NULL) {
3486 device_printf(sc->aac_dev,
3487 "device_add_child failed for passthrough bus %d\n",
3488 i);
3489 free(caminf, M_AACBUF);
3035 break;
3490 break;
3036 }
3037
3038 caminf->TargetsPerBus = businfo.TargetsPerBus;
3039 caminf->BusNumber = i;
3040 caminf->InitiatorBusId = businfo.InitiatorBusId[i];
3041 caminf->aac_sc = sc;
3042 caminf->sim_dev = child;
3043

--- 12 unchanged lines hidden ---
3491 }
3492
3493 caminf->TargetsPerBus = businfo.TargetsPerBus;
3494 caminf->BusNumber = i;
3495 caminf->InitiatorBusId = businfo.InitiatorBusId[i];
3496 caminf->aac_sc = sc;
3497 caminf->sim_dev = child;
3498

--- 12 unchanged lines hidden ---