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 $
28 * $DragonFly: src/sys/dev/raid/ips/ips_commands.c,v 1.8 2004/12/10 04:09:46 y0netan1 Exp $
31 #include <dev/raid/ips/ips.h>
34 * This is an interrupt callback. It is called from
35 * interrupt context when the adapter has completed the
36 * command. This very generic callback simply stores
37 * the command's return value in command->arg and wake's
38 * up anyone waiting on the command.
41 ips_wakeup_callback(ips_command_t *command)
43 ips_cmd_status_t *status;
45 status = command->arg;
46 status->value = command->status.value;
47 bus_dmamap_sync(command->sc->command_dmatag, command->command_dmamap,
48 BUS_DMASYNC_POSTWRITE);
53 * Below are a series of functions for sending an IO request
54 * to the adapter. The flow order is: start, send, callback, finish.
55 * The caller must have already assembled an iorequest struct to hold
56 * the details of the IO request.
59 ips_io_request_finish(ips_command_t *command)
61 struct bio *iobuf = command->arg;
63 if (ips_read_request(iobuf)) {
64 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
65 BUS_DMASYNC_POSTREAD);
67 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
68 BUS_DMASYNC_POSTWRITE);
70 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
71 bus_dmamap_destroy(command->data_dmatag, command->data_dmamap);
72 if (COMMAND_ERROR(&command->status)) {
73 iobuf->bio_flags |=BIO_ERROR;
74 iobuf->bio_error = EIO;
76 ips_insert_free_cmd(command->sc, command);
81 ips_io_request_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
85 ips_command_t *command = cmdptr;
86 ips_sg_element_t *sg_list;
87 ips_io_cmd *command_struct;
88 struct bio *iobuf = command->arg;
94 printf("ips: error = %d in ips_sg_request_callback\n", error);
95 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
96 bus_dmamap_destroy(command->data_dmatag, command->data_dmamap);
97 iobuf->bio_flags |= BIO_ERROR;
98 iobuf->bio_error = ENOMEM;
99 ips_insert_free_cmd(sc, command);
103 command_struct = (ips_io_cmd *)command->command_buffer;
104 command_struct->id = command->id;
105 command_struct->drivenum = (uintptr_t)iobuf->bio_driver1;
107 if (ips_read_request(iobuf))
108 cmdtype = IPS_SG_READ_CMD;
110 cmdtype = IPS_SG_WRITE_CMD;
111 command_struct->segnum = segnum;
112 sg_list = (ips_sg_element_t *)((u_int8_t *)
113 command->command_buffer + IPS_COMMAND_LEN);
114 for (i = 0; i < segnum; i++) {
115 sg_list[i].addr = segments[i].ds_addr;
116 sg_list[i].len = segments[i].ds_len;
117 length += segments[i].ds_len;
119 command_struct->buffaddr =
120 (u_int32_t)command->command_phys_addr + IPS_COMMAND_LEN;
122 if (ips_read_request(iobuf))
123 cmdtype = IPS_READ_CMD;
125 cmdtype = IPS_WRITE_CMD;
126 command_struct->buffaddr = segments[0].ds_addr;
127 length = segments[0].ds_len;
129 command_struct->command = cmdtype;
130 command_struct->lba = iobuf->bio_pblkno;
131 length = (length + IPS_BLKSIZE - 1)/IPS_BLKSIZE;
132 command_struct->length = length;
133 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
134 BUS_DMASYNC_PREWRITE);
135 if (ips_read_request(iobuf)) {
136 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
137 BUS_DMASYNC_PREREAD);
139 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
140 BUS_DMASYNC_PREWRITE);
143 * the cast to long long below is necessary because our b_pblkno
144 * is 32bit wide whereas it's 64bit on FreeBSD-CURRENT.
146 PRINTF(10, "ips test: command id: %d segments: %d "
147 "pblkno: %lld length: %d, ds_len: %d\n", command->id, segnum,
148 (long long)iobuf->bio_pblkno,
149 length, segments[0].ds_len);
151 sc->ips_issue_cmd(command);
156 ips_send_io_request(ips_command_t *command)
158 ips_softc_t *sc = command->sc;
159 struct bio *iobuf = command->arg;
160 command->data_dmatag = sc->sg_dmatag;
162 if (bus_dmamap_create(command->data_dmatag, 0, &command->data_dmamap)) {
163 device_printf(sc->dev, "dmamap failed\n");
164 iobuf->bio_flags |= BIO_ERROR;
165 iobuf->bio_error = ENOMEM;
166 ips_insert_free_cmd(sc, command);
170 command->callback = ips_io_request_finish;
171 PRINTF(10, "ips test: : bcount %ld\n", iobuf->bio_bcount);
172 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
173 iobuf->bio_data, iobuf->bio_bcount,
174 ips_io_request_callback, command, 0);
179 ips_start_io_request(ips_softc_t *sc, struct bio *iobuf)
181 if (ips_get_free_cmd(sc, ips_send_io_request, iobuf, 0)) {
182 device_printf(sc->dev, "no mem for command slots!\n");
183 iobuf->bio_flags |= BIO_ERROR;
184 iobuf->bio_error = ENOMEM;
192 * Below are a series of functions for sending an adapter info request
193 * to the adapter. The flow order is: get, send, callback. It uses
194 * the generic finish callback at the top of this file.
195 * This can be used to get configuration/status info from the card
198 ips_adapter_info_callback(void *cmdptr, bus_dma_segment_t *segments,int segnum,
202 ips_command_t *command = cmdptr;
203 ips_adapter_info_cmd *command_struct;
206 ips_cmd_status_t * status = command->arg;
207 status->value = IPS_ERROR_STATUS; /* a lovely error value */
208 ips_insert_free_cmd(sc, command);
209 printf("ips: error = %d in ips_get_adapter_info\n", error);
212 command_struct = (ips_adapter_info_cmd *)command->command_buffer;
213 command_struct->command = IPS_ADAPTER_INFO_CMD;
214 command_struct->id = command->id;
215 command_struct->buffaddr = segments[0].ds_addr;
217 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
218 BUS_DMASYNC_PREWRITE);
219 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
220 BUS_DMASYNC_PREREAD);
221 sc->ips_issue_cmd(command);
225 ips_send_adapter_info_cmd(ips_command_t *command)
227 ips_softc_t *sc = command->sc;
228 ips_cmd_status_t *status = command->arg;
231 if (bus_dma_tag_create( /* parent */ sc->adapter_dmatag,
234 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT,
235 /* highaddr */ BUS_SPACE_MAXADDR,
237 /* filterarg */ NULL,
238 /* maxsize */ IPS_ADAPTER_INFO_LEN,
240 /* maxsegsize*/ IPS_ADAPTER_INFO_LEN,
242 &command->data_dmatag) != 0) {
243 printf("ips: can't alloc dma tag for adapter status\n");
247 if (bus_dmamem_alloc(command->data_dmatag, &command->data_buffer,
248 BUS_DMA_NOWAIT, &command->data_dmamap)) {
252 command->callback = ips_wakeup_callback;
253 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
254 command->data_buffer, IPS_ADAPTER_INFO_LEN,
255 ips_adapter_info_callback, command, BUS_DMA_NOWAIT);
256 if ((status->value == IPS_ERROR_STATUS) ||
257 tsleep(status, 0, "ips", 30 * hz) == EWOULDBLOCK)
260 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
261 BUS_DMASYNC_POSTREAD);
262 memcpy(&(sc->adapter_info), command->data_buffer,
263 IPS_ADAPTER_INFO_LEN);
265 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
267 /* I suppose I should clean up my memory allocations */
268 bus_dmamem_free(command->data_dmatag, command->data_buffer,
269 command->data_dmamap);
270 bus_dma_tag_destroy(command->data_dmatag);
271 ips_insert_free_cmd(sc, command);
276 ips_get_adapter_info(ips_softc_t *sc)
279 ips_cmd_status_t *status;
281 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
282 if (ips_get_free_cmd(sc, ips_send_adapter_info_cmd, status,
283 IPS_NOWAIT_FLAG) > 0) {
284 device_printf(sc->dev, "unable to get adapter configuration\n");
285 free(status, M_IPSBUF);
288 if (COMMAND_ERROR(status))
290 free(status, M_IPSBUF);
295 * Below are a series of functions for sending a drive info request
296 * to the adapter. The flow order is: get, send, callback. It uses
297 * the generic finish callback at the top of this file.
298 * This can be used to get drive status info from the card
301 ips_drive_info_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
305 ips_command_t *command = cmdptr;
306 ips_drive_cmd *command_struct;
310 ips_cmd_status_t *status = command->arg;
312 status->value = IPS_ERROR_STATUS;
313 ips_insert_free_cmd(sc, command);
314 printf("ips: error = %d in ips_get_drive_info\n", error);
317 command_struct = (ips_drive_cmd *)command->command_buffer;
318 command_struct->command = IPS_DRIVE_INFO_CMD;
319 command_struct->id = command->id;
320 command_struct->buffaddr = segments[0].ds_addr;
321 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
322 BUS_DMASYNC_PREWRITE);
323 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
324 BUS_DMASYNC_PREREAD);
325 sc->ips_issue_cmd(command);
329 ips_send_drive_info_cmd(ips_command_t *command)
332 ips_softc_t *sc = command->sc;
333 ips_cmd_status_t *status = command->arg;
334 ips_drive_info_t *driveinfo;
336 if (bus_dma_tag_create( /* parent */ sc->adapter_dmatag,
339 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT,
340 /* highaddr */ BUS_SPACE_MAXADDR,
342 /* filterarg */ NULL,
343 /* maxsize */ IPS_DRIVE_INFO_LEN,
345 /* maxsegsize*/ IPS_DRIVE_INFO_LEN,
347 &command->data_dmatag) != 0) {
348 printf("ips: can't alloc dma tag for drive status\n");
352 if (bus_dmamem_alloc(command->data_dmatag, &command->data_buffer,
353 BUS_DMA_NOWAIT, &command->data_dmamap)) {
357 command->callback = ips_wakeup_callback;
358 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
359 command->data_buffer,IPS_DRIVE_INFO_LEN,
360 ips_drive_info_callback, command, BUS_DMA_NOWAIT);
361 if ((status->value == IPS_ERROR_STATUS) ||
362 tsleep(status, 0, "ips", 10 * hz) == EWOULDBLOCK)
366 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
367 BUS_DMASYNC_POSTREAD);
368 driveinfo = command->data_buffer;
369 memcpy(sc->drives, driveinfo->drives, sizeof(ips_drive_t) * 8);
370 sc->drivecount = driveinfo->drivecount;
371 device_printf(sc->dev, "logical drives: %d\n", sc->drivecount);
373 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
375 /* I suppose I should clean up my memory allocations */
376 bus_dmamem_free(command->data_dmatag, command->data_buffer,
377 command->data_dmamap);
378 bus_dma_tag_destroy(command->data_dmatag);
379 ips_insert_free_cmd(sc, command);
384 ips_get_drive_info(ips_softc_t *sc)
387 ips_cmd_status_t *status;
389 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
390 if (ips_get_free_cmd(sc, ips_send_drive_info_cmd, status,
391 IPS_NOWAIT_FLAG) > 0) {
392 free(status, M_IPSBUF);
393 device_printf(sc->dev, "unable to get drive configuration\n");
396 if (COMMAND_ERROR(status))
398 free(status, M_IPSBUF);
403 * Below is a pair of functions for making sure data is safely
404 * on disk by flushing the adapter's cache.
407 ips_send_flush_cache_cmd(ips_command_t *command)
409 ips_softc_t *sc = command->sc;
410 ips_cmd_status_t *status = command->arg;
411 ips_generic_cmd *command_struct;
413 PRINTF(10,"ips test: got a command, building flush command\n");
414 command->callback = ips_wakeup_callback;
415 command_struct = (ips_generic_cmd *)command->command_buffer;
416 command_struct->command = IPS_CACHE_FLUSH_CMD;
417 command_struct->id = command->id;
418 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
419 BUS_DMASYNC_PREWRITE);
420 sc->ips_issue_cmd(command);
421 if (status->value != IPS_ERROR_STATUS)
422 tsleep(status, 0, "flush2", 0);
423 ips_insert_free_cmd(sc, command);
428 ips_flush_cache(ips_softc_t *sc)
430 ips_cmd_status_t *status;
432 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
433 device_printf(sc->dev, "flushing cache\n");
434 if (ips_get_free_cmd(sc, ips_send_flush_cache_cmd, status,
436 free(status, M_IPSBUF);
437 device_printf(sc->dev, "ERROR: unable to get a command! "
438 "can't flush cache!\n");
441 if (COMMAND_ERROR(status)) {
442 free(status, M_IPSBUF);
443 device_printf(sc->dev, "ERROR: cache flush command failed!\n");
446 free(status, M_IPSBUF);
451 * Simplified localtime to provide timevalues for ffdc.
452 * Taken from libc/stdtime/localtime.c
455 ips_ffdc_settime(ips_adapter_ffdc_cmd *command, time_t sctime)
458 int yleap, *ip, month;
459 int year_lengths[2] = { IPS_DAYSPERNYEAR, IPS_DAYSPERLYEAR };
460 int mon_lengths[2][IPS_MONSPERYEAR] = {
461 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
462 { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
465 days = sctime / IPS_SECSPERDAY;
466 rem = sctime % IPS_SECSPERDAY;
468 command->hour = rem / IPS_SECSPERHOUR;
469 rem = rem % IPS_SECSPERHOUR;
471 command->minute = rem / IPS_SECSPERMIN;
472 command->second = rem % IPS_SECSPERMIN;
475 while (days < 0 || days >= (long)year_lengths[yleap = ips_isleap(y)]) {
478 newy = y + days / IPS_DAYSPERNYEAR;
481 days -= (newy - y) * IPS_DAYSPERNYEAR +
482 IPS_LEAPS_THRU_END_OF(newy - 1) -
483 IPS_LEAPS_THRU_END_OF(y - 1);
486 command->yearH = y / 100;
487 command->yearL = y % 100;
488 ip = mon_lengths[yleap];
489 for (month = 0; days >= (long)ip[month]; ++month)
490 days = days - (long)ip[month];
491 command->month = month + 1;
492 command->day = days + 1;
496 ips_send_ffdc_reset_cmd(ips_command_t *command)
498 ips_softc_t *sc = command->sc;
499 ips_cmd_status_t *status = command->arg;
500 ips_adapter_ffdc_cmd *command_struct;
502 PRINTF(10, "ips test: got a command, building ffdc reset command\n");
503 command->callback = ips_wakeup_callback;
504 command_struct = (ips_adapter_ffdc_cmd *)command->command_buffer;
505 command_struct->command = IPS_FFDC_CMD;
506 command_struct->id = command->id;
507 command_struct->reset_count = sc->ffdc_resetcount;
508 command_struct->reset_type = 0x0;
509 ips_ffdc_settime(command_struct, sc->ffdc_resettime.tv_sec);
510 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
511 BUS_DMASYNC_PREWRITE);
512 sc->ips_issue_cmd(command);
513 if (status->value != IPS_ERROR_STATUS)
514 tsleep(status, 0, "ffdc", 0);
515 ips_insert_free_cmd(sc, command);
520 ips_ffdc_reset(ips_softc_t *sc)
522 ips_cmd_status_t *status;
524 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
525 if (ips_get_free_cmd(sc, ips_send_ffdc_reset_cmd, status,
527 free(status, M_IPSBUF);
528 device_printf(sc->dev, "ERROR: unable to get a command! "
529 "can't send ffdc reset!\n");
532 if (COMMAND_ERROR(status)) {
533 free(status, M_IPSBUF);
534 device_printf(sc->dev, "ERROR: ffdc reset command failed!\n");
537 free(status, M_IPSBUF);
542 ips_write_nvram(ips_command_t *command)
544 ips_softc_t *sc = command->sc;
545 ips_rw_nvram_cmd *command_struct;
546 ips_nvram_page5 *nvram;
548 /*FIXME check for error */
549 command->callback = ips_wakeup_callback;
550 command_struct = (ips_rw_nvram_cmd *)command->command_buffer;
551 command_struct->command = IPS_RW_NVRAM_CMD;
552 command_struct->id = command->id;
553 command_struct->pagenum = 5;
554 command_struct->rw = 1; /* write */
555 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
556 BUS_DMASYNC_POSTREAD);
557 nvram = command->data_buffer;
558 /* retrieve adapter info and save in sc */
559 sc->adapter_type = nvram->adapter_type;
560 strncpy(nvram->driver_high, IPS_VERSION_MAJOR, 4);
561 strncpy(nvram->driver_low, IPS_VERSION_MINOR, 4);
562 nvram->operating_system = IPS_OS_FREEBSD;
563 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
564 BUS_DMASYNC_PREWRITE);
565 sc->ips_issue_cmd(command);
569 ips_read_nvram_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
573 ips_command_t *command = cmdptr;
574 ips_rw_nvram_cmd *command_struct;
578 ips_cmd_status_t *status = command->arg;
580 status->value = IPS_ERROR_STATUS;
581 ips_insert_free_cmd(sc, command);
582 printf("ips: error = %d in ips_read_nvram_callback\n", error);
585 command_struct = (ips_rw_nvram_cmd *)command->command_buffer;
586 command_struct->command = IPS_RW_NVRAM_CMD;
587 command_struct->id = command->id;
588 command_struct->pagenum = 5;
589 command_struct->rw = 0;
590 command_struct->buffaddr = segments[0].ds_addr;
592 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
593 BUS_DMASYNC_PREWRITE);
594 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
595 BUS_DMASYNC_PREREAD);
596 sc->ips_issue_cmd(command);
600 ips_read_nvram(ips_command_t *command)
603 ips_softc_t *sc = command->sc;
604 ips_cmd_status_t *status = command->arg;
606 if (bus_dma_tag_create( /* parent */ sc->adapter_dmatag,
609 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT,
610 /* highaddr */ BUS_SPACE_MAXADDR,
612 /* filterarg */ NULL,
613 /* maxsize */ IPS_NVRAM_PAGE_SIZE,
615 /* maxsegsize*/ IPS_NVRAM_PAGE_SIZE,
617 &command->data_dmatag) != 0) {
618 printf("ips: can't alloc dma tag for nvram\n");
622 if (bus_dmamem_alloc(command->data_dmatag, &command->data_buffer,
623 BUS_DMA_NOWAIT, &command->data_dmamap)) {
627 command->callback = ips_write_nvram;
628 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
629 command->data_buffer, IPS_NVRAM_PAGE_SIZE, ips_read_nvram_callback,
630 command, BUS_DMA_NOWAIT);
631 if ((status->value == IPS_ERROR_STATUS) ||
632 tsleep(status, 0, "ips", 0) == EWOULDBLOCK)
635 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
636 BUS_DMASYNC_POSTWRITE);
638 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
640 bus_dmamem_free(command->data_dmatag, command->data_buffer,
641 command->data_dmamap);
642 bus_dma_tag_destroy(command->data_dmatag);
643 ips_insert_free_cmd(sc, command);
648 ips_update_nvram(ips_softc_t *sc)
650 ips_cmd_status_t *status;
652 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
653 if (ips_get_free_cmd(sc, ips_read_nvram, status, IPS_NOWAIT_FLAG)) {
654 free(status, M_IPSBUF);
655 device_printf(sc->dev, "ERROR: unable to get a command! "
656 "can't update nvram\n");
659 if (COMMAND_ERROR(status)) {
660 free(status, M_IPSBUF);
661 device_printf(sc->dev, "ERROR: nvram update command failed!\n");
664 free(status, M_IPSBUF);
669 ips_send_config_sync_cmd(ips_command_t *command)
671 ips_softc_t *sc = command->sc;
672 ips_cmd_status_t *status = command->arg;
673 ips_generic_cmd *command_struct;
675 PRINTF(10, "ips test: got a command, building flush command\n");
676 command->callback = ips_wakeup_callback;
677 command_struct = (ips_generic_cmd *)command->command_buffer;
678 command_struct->command = IPS_CONFIG_SYNC_CMD;
679 command_struct->id = command->id;
680 command_struct->reserve2 = IPS_POCL;
681 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
682 BUS_DMASYNC_PREWRITE);
683 sc->ips_issue_cmd(command);
684 if (status->value != IPS_ERROR_STATUS)
685 tsleep(status, 0, "ipssyn", 0);
686 ips_insert_free_cmd(sc, command);
691 ips_send_error_table_cmd(ips_command_t *command)
693 ips_softc_t *sc = command->sc;
694 ips_cmd_status_t *status = command->arg;
695 ips_generic_cmd *command_struct;
697 PRINTF(10, "ips test: got a command, building errortable command\n");
698 command->callback = ips_wakeup_callback;
699 command_struct = (ips_generic_cmd *)command->command_buffer;
700 command_struct->command = IPS_ERROR_TABLE_CMD;
701 command_struct->id = command->id;
702 command_struct->reserve2 = IPS_CSL;
703 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
704 BUS_DMASYNC_PREWRITE);
705 sc->ips_issue_cmd(command);
706 if (status->value != IPS_ERROR_STATUS)
707 tsleep(status, 0, "ipsetc", 0);
708 ips_insert_free_cmd(sc, command);
713 ips_clear_adapter(ips_softc_t *sc)
715 ips_cmd_status_t *status;
717 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
718 device_printf(sc->dev, "syncing config\n");
719 if (ips_get_free_cmd(sc, ips_send_config_sync_cmd, status,
721 free(status, M_IPSBUF);
722 device_printf(sc->dev, "ERROR: unable to get a command! "
723 "can't sync cache!\n");
726 if (COMMAND_ERROR(status)) {
727 free(status, M_IPSBUF);
728 device_printf(sc->dev, "ERROR: cache sync command failed!\n");
731 device_printf(sc->dev, "clearing error table\n");
732 if (ips_get_free_cmd(sc, ips_send_error_table_cmd, status,
734 free(status, M_IPSBUF);
735 device_printf(sc->dev, "ERROR: unable to get a command! "
736 "can't sync cache!\n");
739 if (COMMAND_ERROR(status)) {
740 device_printf(sc->dev, "ERROR: etable command failed!\n");
741 free(status, M_IPSBUF);
744 free(status, M_IPSBUF);