2 * Written by: David Jeffery
3 * Copyright (c) 2002 Adaptec Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * $FreeBSD: src/sys/dev/ips/ips_commands.c,v 1.10 2004/05/30 04:01:29 scottl Exp $
30 #include <sys/devicestat.h>
31 #include <sys/sysctl.h>
32 #include <dev/raid/ips/ips.h>
33 #include <dev/raid/ips/ips_disk.h>
35 static int ips_debug_ignore_flush_cmd;
36 TUNABLE_INT("debug.ips.ignore_flush_cmd", &ips_debug_ignore_flush_cmd);
37 SYSCTL_NODE(_debug, OID_AUTO, ips, CTLFLAG_RD, 0, "");
38 SYSCTL_INT(_debug_ips, OID_AUTO, ignore_flush_cmd, CTLFLAG_RW,
39 &ips_debug_ignore_flush_cmd, 0,
40 "Do not issue IPS_CACHE_FLUSH_CMD on BUF_CMD_FLUSH");
43 ips_timed_wait(ips_command_t *command, const char *id, int timo)
47 while (command->completed == 0) {
49 if (command->completed == 0)
50 error = tsleep(&command->completed, 0, id, timo);
52 if (error == EWOULDBLOCK) {
61 * This is an interrupt callback. It is called from
62 * interrupt context when the adapter has completed the
63 * command, and wakes up anyone waiting on the command.
66 ips_wakeup_callback(ips_command_t *command)
68 bus_dmamap_sync(command->sc->command_dmatag, command->command_dmamap,
69 BUS_DMASYNC_POSTWRITE);
70 command->completed = 1;
71 wakeup(&command->completed);
75 * Below are a series of functions for sending an IO request
76 * to the adapter. The flow order is: start, send, callback, finish.
77 * The caller must have already assembled an iorequest struct to hold
78 * the details of the IO request.
81 ips_io_request_finish(ips_command_t *command)
83 struct bio *bio = command->arg;
85 if (ips_read_request(bio)) {
86 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
87 BUS_DMASYNC_POSTREAD);
89 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
90 BUS_DMASYNC_POSTWRITE);
92 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
93 if (COMMAND_ERROR(&command->status)) {
94 bio->bio_buf->b_flags |=B_ERROR;
95 bio->bio_buf->b_error = EIO;
97 ips_insert_free_cmd(command->sc, command);
102 ips_io_request_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
106 ips_command_t *command = cmdptr;
107 ips_sg_element_t *sg_list;
108 ips_io_cmd *command_struct;
109 struct bio *bio = command->arg;
110 struct buf *bp = bio->bio_buf;
111 ipsdisk_softc_t *dsc;
117 kprintf("ips: error = %d in ips_sg_request_callback\n", error);
118 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
119 bp->b_flags |= B_ERROR;
120 bp->b_error = ENOMEM;
121 ips_insert_free_cmd(sc, command);
125 dsc = bio->bio_driver_info;
126 command_struct = (ips_io_cmd *)command->command_buffer;
127 command_struct->id = command->id;
128 command_struct->drivenum = dsc->sc->drives[dsc->disk_number].drivenum;
131 if (ips_read_request(bio))
132 cmdtype = IPS_SG_READ_CMD;
134 cmdtype = IPS_SG_WRITE_CMD;
135 command_struct->segnum = segnum;
136 sg_list = (ips_sg_element_t *)((u_int8_t *)
137 command->command_buffer + IPS_COMMAND_LEN);
138 for (i = 0; i < segnum; i++) {
139 sg_list[i].addr = segments[i].ds_addr;
140 sg_list[i].len = segments[i].ds_len;
141 length += segments[i].ds_len;
143 command_struct->buffaddr =
144 (u_int32_t)command->command_phys_addr + IPS_COMMAND_LEN;
146 if (ips_read_request(bio))
147 cmdtype = IPS_READ_CMD;
149 cmdtype = IPS_WRITE_CMD;
150 command_struct->buffaddr = segments[0].ds_addr;
151 length = segments[0].ds_len;
153 command_struct->command = cmdtype;
154 command_struct->lba = bio->bio_offset / IPS_BLKSIZE;
155 length = (length + IPS_BLKSIZE - 1)/IPS_BLKSIZE;
156 command_struct->length = length;
157 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
158 BUS_DMASYNC_PREWRITE);
159 if (ips_read_request(bio)) {
160 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
161 BUS_DMASYNC_PREREAD);
163 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
164 BUS_DMASYNC_PREWRITE);
166 PRINTF(10, "ips test: command id: %d segments: %d "
167 "pblkno: %lld length: %d, ds_len: %d\n", command->id, segnum,
168 bio->bio_offset / IPS_BLKSIZE,
169 length, segments[0].ds_len);
171 sc->ips_issue_cmd(command);
176 ips_flush_request_finish(ips_command_t *command)
178 ips_generic_cmd *gencmd = command->command_buffer;
179 struct bio *bio = command->arg;
181 if (COMMAND_ERROR(&command->status)) {
182 device_printf(command->sc->dev,
183 "cmd=0x%x,st=0x%x,est=0x%x\n",
185 command->status.fields.basic_status,
186 command->status.fields.extended_status);
188 bio->bio_buf->b_flags |= B_ERROR;
189 bio->bio_buf->b_error = EIO;
191 ips_insert_free_cmd(command->sc, command);
196 ips_send_flush_request(ips_command_t *command, struct bio *bio)
199 ips_generic_cmd *flush_cmd;
200 ips_softc_t *sc = command->sc;
202 if (!ips_debug_ignore_flush_cmd) {
203 ips_insert_free_cmd(sc, command);
208 command->callback = ips_flush_request_finish;
209 flush_cmd = command->command_buffer;
210 flush_cmd->command = IPS_CACHE_FLUSH_CMD;
211 flush_cmd->id = command->id;
212 flush_cmd->drivenum = 0;
213 flush_cmd->buffaddr = 0;
215 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
216 BUS_DMASYNC_PREWRITE);
218 sc->ips_issue_cmd(command);
224 ips_send_io_request(ips_command_t *command, struct bio *bio)
226 struct buf *bp = bio->bio_buf;
228 command->callback = ips_io_request_finish;
230 PRINTF(10, "ips test: : bcount %ld\n", bp->b_bcount);
231 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
232 bp->b_data, bp->b_bcount,
233 ips_io_request_callback, command, 0);
238 ips_start_io_request(ips_softc_t *sc)
240 ips_command_t *command;
243 bio = bioq_first(&sc->bio_queue);
246 if (ips_get_free_cmd(sc, &command, 0) != 0)
248 bioq_remove(&sc->bio_queue, bio);
249 if (bio->bio_buf->b_cmd == BUF_CMD_FLUSH)
250 ips_send_flush_request(command, bio);
252 ips_send_io_request(command, bio);
256 * Below are a series of functions for sending an adapter info request
257 * to the adapter. The flow order is: get, send, callback. It uses
258 * the generic finish callback at the top of this file.
259 * This can be used to get configuration/status info from the card
262 ips_adapter_info_callback(void *cmdptr, bus_dma_segment_t *segments,int segnum,
266 ips_command_t *command = cmdptr;
267 ips_adapter_info_cmd *command_struct;
270 command->status.value = IPS_ERROR_STATUS; /* a lovely error value */
271 ips_insert_free_cmd(sc, command);
272 kprintf("ips: error = %d in ips_get_adapter_info\n", error);
275 command_struct = (ips_adapter_info_cmd *)command->command_buffer;
276 command_struct->command = IPS_ADAPTER_INFO_CMD;
277 command_struct->id = command->id;
278 command_struct->buffaddr = segments[0].ds_addr;
280 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
281 BUS_DMASYNC_PREWRITE);
282 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
283 BUS_DMASYNC_PREREAD);
284 sc->ips_issue_cmd(command);
288 ips_send_adapter_info_cmd(ips_command_t *command)
290 ips_softc_t *sc = command->sc;
293 if (bus_dma_tag_create( /* parent */ sc->adapter_dmatag,
296 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT,
297 /* highaddr */ BUS_SPACE_MAXADDR,
299 /* filterarg */ NULL,
300 /* maxsize */ IPS_ADAPTER_INFO_LEN,
302 /* maxsegsize*/ IPS_ADAPTER_INFO_LEN,
304 &command->data_dmatag) != 0) {
305 kprintf("ips: can't alloc dma tag for adapter status\n");
309 if (bus_dmamem_alloc(command->data_dmatag, &command->data_buffer,
310 BUS_DMA_NOWAIT, &command->data_dmamap)) {
314 command->callback = ips_wakeup_callback;
315 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
316 command->data_buffer, IPS_ADAPTER_INFO_LEN,
317 ips_adapter_info_callback, command, BUS_DMA_NOWAIT);
318 if ((command->status.value == IPS_ERROR_STATUS) ||
319 ips_timed_wait(command, "ips", 30 * hz) != 0)
322 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
323 BUS_DMASYNC_POSTREAD);
324 memcpy(&(sc->adapter_info), command->data_buffer,
325 IPS_ADAPTER_INFO_LEN);
327 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
329 /* I suppose I should clean up my memory allocations */
330 bus_dmamem_free(command->data_dmatag, command->data_buffer,
331 command->data_dmamap);
332 bus_dma_tag_destroy(command->data_dmatag);
333 ips_insert_free_cmd(sc, command);
338 ips_get_adapter_info(ips_softc_t *sc)
340 ips_command_t *command;
343 if (ips_get_free_cmd(sc, &command, IPS_STATIC_FLAG) != 0) {
344 device_printf(sc->dev, "unable to get adapter configuration\n");
347 ips_send_adapter_info_cmd(command);
348 if (COMMAND_ERROR(&command->status))
354 * Below are a series of functions for sending a drive info request
355 * to the adapter. The flow order is: get, send, callback. It uses
356 * the generic finish callback at the top of this file.
357 * This can be used to get drive status info from the card
360 ips_drive_info_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
364 ips_command_t *command = cmdptr;
365 ips_drive_cmd *command_struct;
370 command->status.value = IPS_ERROR_STATUS;
371 ips_insert_free_cmd(sc, command);
372 kprintf("ips: error = %d in ips_get_drive_info\n", error);
375 command_struct = (ips_drive_cmd *)command->command_buffer;
376 command_struct->command = IPS_DRIVE_INFO_CMD;
377 command_struct->id = command->id;
378 command_struct->buffaddr = segments[0].ds_addr;
379 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
380 BUS_DMASYNC_PREWRITE);
381 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
382 BUS_DMASYNC_PREREAD);
383 sc->ips_issue_cmd(command);
387 ips_send_drive_info_cmd(ips_command_t *command)
390 ips_softc_t *sc = command->sc;
391 ips_drive_info_t *driveinfo;
393 if (bus_dma_tag_create( /* parent */ sc->adapter_dmatag,
396 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT,
397 /* highaddr */ BUS_SPACE_MAXADDR,
399 /* filterarg */ NULL,
400 /* maxsize */ IPS_DRIVE_INFO_LEN,
402 /* maxsegsize*/ IPS_DRIVE_INFO_LEN,
404 &command->data_dmatag) != 0) {
405 kprintf("ips: can't alloc dma tag for drive status\n");
409 if (bus_dmamem_alloc(command->data_dmatag, &command->data_buffer,
410 BUS_DMA_NOWAIT, &command->data_dmamap)) {
414 command->callback = ips_wakeup_callback;
415 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
416 command->data_buffer,IPS_DRIVE_INFO_LEN,
417 ips_drive_info_callback, command, BUS_DMA_NOWAIT);
418 if ((command->status.value == IPS_ERROR_STATUS) ||
419 ips_timed_wait(command, "ips", 10 * hz) != 0)
423 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
424 BUS_DMASYNC_POSTREAD);
425 driveinfo = command->data_buffer;
426 memcpy(sc->drives, driveinfo->drives, sizeof(ips_drive_t) * 8);
427 sc->drivecount = driveinfo->drivecount;
428 device_printf(sc->dev, "logical drives: %d\n", sc->drivecount);
430 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
432 /* I suppose I should clean up my memory allocations */
433 bus_dmamem_free(command->data_dmatag, command->data_buffer,
434 command->data_dmamap);
435 bus_dma_tag_destroy(command->data_dmatag);
436 ips_insert_free_cmd(sc, command);
441 ips_get_drive_info(ips_softc_t *sc)
444 ips_command_t *command;
446 if (ips_get_free_cmd(sc, &command, IPS_STATIC_FLAG) != 0) {
447 device_printf(sc->dev, "unable to get drive configuration\n");
450 ips_send_drive_info_cmd(command);
451 if (COMMAND_ERROR(&command->status))
457 * Below is a pair of functions for making sure data is safely
458 * on disk by flushing the adapter's cache.
461 ips_send_flush_cache_cmd(ips_command_t *command)
463 ips_softc_t *sc = command->sc;
464 ips_generic_cmd *command_struct;
466 PRINTF(10,"ips test: got a command, building flush command\n");
467 command->callback = ips_wakeup_callback;
468 command_struct = (ips_generic_cmd *)command->command_buffer;
469 command_struct->command = IPS_CACHE_FLUSH_CMD;
470 command_struct->id = command->id;
471 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
472 BUS_DMASYNC_PREWRITE);
473 sc->ips_issue_cmd(command);
474 if (command->status.value != IPS_ERROR_STATUS)
475 ips_timed_wait(command, "flush2", 0);
476 ips_insert_free_cmd(sc, command);
481 ips_flush_cache(ips_softc_t *sc)
483 ips_command_t *command;
485 device_printf(sc->dev, "flushing cache\n");
486 if (ips_get_free_cmd(sc, &command, IPS_STATIC_FLAG) != 0) {
487 device_printf(sc->dev, "ERROR: unable to get a command! "
488 "can't flush cache!\n");
491 ips_send_flush_cache_cmd(command);
492 if (COMMAND_ERROR(&command->status)) {
493 device_printf(sc->dev, "ERROR: cache flush command failed!\n");
500 * Simplified localtime to provide timevalues for ffdc.
501 * Taken from libc/stdtime/localtime.c
504 ips_ffdc_settime(ips_adapter_ffdc_cmd *command, time_t sctime)
507 int yleap, *ip, month;
508 int year_lengths[2] = { IPS_DAYSPERNYEAR, IPS_DAYSPERLYEAR };
509 int mon_lengths[2][IPS_MONSPERYEAR] = {
510 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
511 { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
514 days = sctime / IPS_SECSPERDAY;
515 rem = sctime % IPS_SECSPERDAY;
517 command->hour = rem / IPS_SECSPERHOUR;
518 rem = rem % IPS_SECSPERHOUR;
520 command->minute = rem / IPS_SECSPERMIN;
521 command->second = rem % IPS_SECSPERMIN;
524 while (days < 0 || days >= (long)year_lengths[yleap = ips_isleap(y)]) {
527 newy = y + days / IPS_DAYSPERNYEAR;
530 days -= (newy - y) * IPS_DAYSPERNYEAR +
531 IPS_LEAPS_THRU_END_OF(newy - 1) -
532 IPS_LEAPS_THRU_END_OF(y - 1);
535 command->yearH = y / 100;
536 command->yearL = y % 100;
537 ip = mon_lengths[yleap];
538 for (month = 0; days >= (long)ip[month]; ++month)
539 days = days - (long)ip[month];
540 command->month = month + 1;
541 command->day = days + 1;
545 ips_send_ffdc_reset_cmd(ips_command_t *command)
547 ips_softc_t *sc = command->sc;
548 ips_adapter_ffdc_cmd *command_struct;
550 PRINTF(10, "ips test: got a command, building ffdc reset command\n");
551 command->callback = ips_wakeup_callback;
552 command_struct = (ips_adapter_ffdc_cmd *)command->command_buffer;
553 command_struct->command = IPS_FFDC_CMD;
554 command_struct->id = command->id;
555 command_struct->reset_count = sc->ffdc_resetcount;
556 command_struct->reset_type = 0x0;
557 ips_ffdc_settime(command_struct, sc->ffdc_resettime.tv_sec);
558 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
559 BUS_DMASYNC_PREWRITE);
560 sc->ips_issue_cmd(command);
561 if (command->status.value != IPS_ERROR_STATUS)
562 ips_timed_wait(command, "ffdc", 0);
563 ips_insert_free_cmd(sc, command);
568 ips_ffdc_reset(ips_softc_t *sc)
570 ips_command_t *command;
572 if (ips_get_free_cmd(sc, &command, IPS_STATIC_FLAG) != 0) {
573 device_printf(sc->dev, "ERROR: unable to get a command! "
574 "can't send ffdc reset!\n");
577 ips_send_ffdc_reset_cmd(command);
578 if (COMMAND_ERROR(&command->status)) {
580 * apparently some cards may report error status for
581 * an ffdc reset command, even though it works correctly
582 * afterwards. just complain about that and proceed here.
584 device_printf(sc->dev,
585 "ERROR: ffdc reset command failed(0x%04x)!\n",
586 command->status.value);
592 ips_write_nvram(ips_command_t *command)
594 ips_softc_t *sc = command->sc;
595 ips_rw_nvram_cmd *command_struct;
596 ips_nvram_page5 *nvram;
598 /*FIXME check for error */
599 command->callback = ips_wakeup_callback;
600 command_struct = (ips_rw_nvram_cmd *)command->command_buffer;
601 command_struct->command = IPS_RW_NVRAM_CMD;
602 command_struct->id = command->id;
603 command_struct->pagenum = 5;
604 command_struct->rw = 1; /* write */
605 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
606 BUS_DMASYNC_POSTREAD);
607 nvram = command->data_buffer;
608 /* retrieve adapter info and save in sc */
609 sc->adapter_type = nvram->adapter_type;
610 strncpy(nvram->driver_high, IPS_VERSION_MAJOR, 4);
611 strncpy(nvram->driver_low, IPS_VERSION_MINOR, 4);
612 nvram->operating_system = IPS_OS_FREEBSD;
613 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
614 BUS_DMASYNC_PREWRITE);
615 sc->ips_issue_cmd(command);
619 ips_read_nvram_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
623 ips_command_t *command = cmdptr;
624 ips_rw_nvram_cmd *command_struct;
628 command->status.value = IPS_ERROR_STATUS;
629 ips_insert_free_cmd(sc, command);
630 kprintf("ips: error = %d in ips_read_nvram_callback\n", error);
633 command_struct = (ips_rw_nvram_cmd *)command->command_buffer;
634 command_struct->command = IPS_RW_NVRAM_CMD;
635 command_struct->id = command->id;
636 command_struct->pagenum = 5;
637 command_struct->rw = 0;
638 command_struct->buffaddr = segments[0].ds_addr;
640 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
641 BUS_DMASYNC_PREWRITE);
642 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
643 BUS_DMASYNC_PREREAD);
644 sc->ips_issue_cmd(command);
648 ips_read_nvram(ips_command_t *command)
651 ips_softc_t *sc = command->sc;
653 if (bus_dma_tag_create( /* parent */ sc->adapter_dmatag,
656 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT,
657 /* highaddr */ BUS_SPACE_MAXADDR,
659 /* filterarg */ NULL,
660 /* maxsize */ IPS_NVRAM_PAGE_SIZE,
662 /* maxsegsize*/ IPS_NVRAM_PAGE_SIZE,
664 &command->data_dmatag) != 0) {
665 kprintf("ips: can't alloc dma tag for nvram\n");
669 if (bus_dmamem_alloc(command->data_dmatag, &command->data_buffer,
670 BUS_DMA_NOWAIT, &command->data_dmamap)) {
674 command->callback = ips_write_nvram;
675 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
676 command->data_buffer, IPS_NVRAM_PAGE_SIZE, ips_read_nvram_callback,
677 command, BUS_DMA_NOWAIT);
678 if ((command->status.value == IPS_ERROR_STATUS) ||
679 ips_timed_wait(command, "ips", 0) != 0)
682 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
683 BUS_DMASYNC_POSTWRITE);
685 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
687 bus_dmamem_free(command->data_dmatag, command->data_buffer,
688 command->data_dmamap);
689 bus_dma_tag_destroy(command->data_dmatag);
690 ips_insert_free_cmd(sc, command);
695 ips_update_nvram(ips_softc_t *sc)
697 ips_command_t *command;
699 if (ips_get_free_cmd(sc, &command, IPS_STATIC_FLAG) != 0) {
700 device_printf(sc->dev, "ERROR: unable to get a command! "
701 "can't update nvram\n");
704 ips_read_nvram(command);
705 if (COMMAND_ERROR(&command->status)) {
706 device_printf(sc->dev, "ERROR: nvram update command failed!\n");
713 ips_send_config_sync_cmd(ips_command_t *command)
715 ips_softc_t *sc = command->sc;
716 ips_generic_cmd *command_struct;
718 PRINTF(10, "ips test: got a command, building flush command\n");
719 command->callback = ips_wakeup_callback;
720 command_struct = (ips_generic_cmd *)command->command_buffer;
721 command_struct->command = IPS_CONFIG_SYNC_CMD;
722 command_struct->id = command->id;
723 command_struct->reserve2 = IPS_POCL;
724 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
725 BUS_DMASYNC_PREWRITE);
726 sc->ips_issue_cmd(command);
727 if (command->status.value != IPS_ERROR_STATUS)
728 ips_timed_wait(command, "ipssyn", 0);
729 ips_insert_free_cmd(sc, command);
734 ips_send_error_table_cmd(ips_command_t *command)
736 ips_softc_t *sc = command->sc;
737 ips_generic_cmd *command_struct;
739 PRINTF(10, "ips test: got a command, building errortable command\n");
740 command->callback = ips_wakeup_callback;
741 command_struct = (ips_generic_cmd *)command->command_buffer;
742 command_struct->command = IPS_ERROR_TABLE_CMD;
743 command_struct->id = command->id;
744 command_struct->reserve2 = IPS_CSL;
745 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
746 BUS_DMASYNC_PREWRITE);
747 sc->ips_issue_cmd(command);
748 if (command->status.value != IPS_ERROR_STATUS)
749 ips_timed_wait(command, "ipsetc", 0);
750 ips_insert_free_cmd(sc, command);
755 ips_clear_adapter(ips_softc_t *sc)
757 ips_command_t *command;
759 device_printf(sc->dev, "syncing config\n");
760 if (ips_get_free_cmd(sc, &command, IPS_STATIC_FLAG) != 0) {
761 device_printf(sc->dev, "ERROR: unable to get a command! "
762 "can't sync cache!\n");
765 ips_send_config_sync_cmd(command);
766 if (COMMAND_ERROR(&command->status)) {
767 device_printf(sc->dev, "ERROR: cache sync command failed!\n");
770 device_printf(sc->dev, "clearing error table\n");
771 if (ips_get_free_cmd(sc, &command, IPS_STATIC_FLAG) != 0) {
772 device_printf(sc->dev, "ERROR: unable to get a command! "
773 "can't sync cache!\n");
776 ips_send_error_table_cmd(command);
777 if (COMMAND_ERROR(&command->status)) {
778 device_printf(sc->dev, "ERROR: etable command failed!\n");