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.7 2004/09/06 16:39:47 joerg Exp $
31 #include <dev/raid/ips/ips.h>
34 ips_msleep(void *ident, struct ips_softc *sc, int priority, const char *wmesg,
40 r = tsleep(ident, priority, wmesg, timo);
46 * This is an interrupt callback. It is called from
47 * interrupt context when the adapter has completed the
48 * command. This very generic callback simply stores
49 * the command's return value in command->arg and wake's
50 * up anyone waiting on the command.
53 ips_wakeup_callback(ips_command_t *command)
55 ips_cmd_status_t *status;
57 status = command->arg;
58 status->value = command->status.value;
59 bus_dmamap_sync(command->sc->command_dmatag, command->command_dmamap,
60 BUS_DMASYNC_POSTWRITE);
61 IPS_LOCK(command->sc);
63 IPS_UNLOCK(command->sc);
67 * Below are a series of functions for sending an IO request
68 * to the adapter. The flow order is: start, send, callback, finish.
69 * The caller must have already assembled an iorequest struct to hold
70 * the details of the IO request.
73 ips_io_request_finish(ips_command_t *command)
75 struct bio *iobuf = command->arg;
77 if (ips_read_request(iobuf)) {
78 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
79 BUS_DMASYNC_POSTREAD);
81 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
82 BUS_DMASYNC_POSTWRITE);
84 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
85 bus_dmamap_destroy(command->data_dmatag, command->data_dmamap);
86 if (COMMAND_ERROR(&command->status)) {
87 iobuf->bio_flags |=BIO_ERROR;
88 iobuf->bio_error = EIO;
90 ips_insert_free_cmd(command->sc, command);
95 ips_io_request_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
99 ips_command_t *command = cmdptr;
100 ips_sg_element_t *sg_list;
101 ips_io_cmd *command_struct;
102 struct bio *iobuf = command->arg;
108 printf("ips: error = %d in ips_sg_request_callback\n", error);
109 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
110 bus_dmamap_destroy(command->data_dmatag, command->data_dmamap);
111 iobuf->bio_flags |= BIO_ERROR;
112 iobuf->bio_error = ENOMEM;
113 ips_insert_free_cmd(sc, command);
117 command_struct = (ips_io_cmd *)command->command_buffer;
118 command_struct->id = command->id;
119 command_struct->drivenum = (uintptr_t)iobuf->bio_driver1;
121 if (ips_read_request(iobuf))
122 cmdtype = IPS_SG_READ_CMD;
124 cmdtype = IPS_SG_WRITE_CMD;
125 command_struct->segnum = segnum;
126 sg_list = (ips_sg_element_t *)((u_int8_t *)
127 command->command_buffer + IPS_COMMAND_LEN);
128 for (i = 0; i < segnum; i++) {
129 sg_list[i].addr = segments[i].ds_addr;
130 sg_list[i].len = segments[i].ds_len;
131 length += segments[i].ds_len;
133 command_struct->buffaddr =
134 (u_int32_t)command->command_phys_addr + IPS_COMMAND_LEN;
136 if (ips_read_request(iobuf))
137 cmdtype = IPS_READ_CMD;
139 cmdtype = IPS_WRITE_CMD;
140 command_struct->buffaddr = segments[0].ds_addr;
141 length = segments[0].ds_len;
143 command_struct->command = cmdtype;
144 command_struct->lba = iobuf->bio_pblkno;
145 length = (length + IPS_BLKSIZE - 1)/IPS_BLKSIZE;
146 command_struct->length = length;
147 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
148 BUS_DMASYNC_PREWRITE);
149 if (ips_read_request(iobuf)) {
150 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
151 BUS_DMASYNC_PREREAD);
153 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
154 BUS_DMASYNC_PREWRITE);
157 * the cast to long long below is necessary because our b_pblkno
158 * is 32bit wide whereas it's 64bit on FreeBSD-CURRENT.
160 PRINTF(10, "ips test: command id: %d segments: %d "
161 "pblkno: %lld length: %d, ds_len: %d\n", command->id, segnum,
162 (long long)iobuf->bio_pblkno,
163 length, segments[0].ds_len);
165 sc->ips_issue_cmd(command);
170 ips_send_io_request(ips_command_t *command)
172 ips_softc_t *sc = command->sc;
173 struct bio *iobuf = command->arg;
174 command->data_dmatag = sc->sg_dmatag;
176 if (bus_dmamap_create(command->data_dmatag, 0, &command->data_dmamap)) {
177 device_printf(sc->dev, "dmamap failed\n");
178 iobuf->bio_flags |= BIO_ERROR;
179 iobuf->bio_error = ENOMEM;
180 ips_insert_free_cmd(sc, command);
184 command->callback = ips_io_request_finish;
185 PRINTF(10, "ips test: : bcount %ld\n", iobuf->bio_bcount);
186 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
187 iobuf->bio_data, iobuf->bio_bcount,
188 ips_io_request_callback, command, 0);
193 ips_start_io_request(ips_softc_t *sc, struct bio *iobuf)
195 if (ips_get_free_cmd(sc, ips_send_io_request, iobuf, 0)) {
196 device_printf(sc->dev, "no mem for command slots!\n");
197 iobuf->bio_flags |= BIO_ERROR;
198 iobuf->bio_error = ENOMEM;
206 * Below are a series of functions for sending an adapter info request
207 * to the adapter. The flow order is: get, send, callback. It uses
208 * the generic finish callback at the top of this file.
209 * This can be used to get configuration/status info from the card
212 ips_adapter_info_callback(void *cmdptr, bus_dma_segment_t *segments,int segnum,
216 ips_command_t *command = cmdptr;
217 ips_adapter_info_cmd *command_struct;
220 ips_cmd_status_t * status = command->arg;
221 status->value = IPS_ERROR_STATUS; /* a lovely error value */
222 ips_insert_free_cmd(sc, command);
223 printf("ips: error = %d in ips_get_adapter_info\n", error);
226 command_struct = (ips_adapter_info_cmd *)command->command_buffer;
227 command_struct->command = IPS_ADAPTER_INFO_CMD;
228 command_struct->id = command->id;
229 command_struct->buffaddr = segments[0].ds_addr;
231 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
232 BUS_DMASYNC_PREWRITE);
233 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
234 BUS_DMASYNC_PREREAD);
235 sc->ips_issue_cmd(command);
239 ips_send_adapter_info_cmd(ips_command_t *command)
241 ips_softc_t *sc = command->sc;
242 ips_cmd_status_t *status = command->arg;
245 if (bus_dma_tag_create( /* parent */ sc->adapter_dmatag,
248 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT,
249 /* highaddr */ BUS_SPACE_MAXADDR,
251 /* filterarg */ NULL,
252 /* maxsize */ IPS_ADAPTER_INFO_LEN,
254 /* maxsegsize*/ IPS_ADAPTER_INFO_LEN,
256 &command->data_dmatag) != 0) {
257 printf("ips: can't alloc dma tag for adapter status\n");
261 if (bus_dmamem_alloc(command->data_dmatag, &command->data_buffer,
262 BUS_DMA_NOWAIT, &command->data_dmamap)) {
266 command->callback = ips_wakeup_callback;
268 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
269 command->data_buffer, IPS_ADAPTER_INFO_LEN,
270 ips_adapter_info_callback, command, BUS_DMA_NOWAIT);
271 if ((status->value == IPS_ERROR_STATUS) ||
272 ips_msleep(status, sc, 0, "ips", 30 * hz) == EWOULDBLOCK)
276 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
277 BUS_DMASYNC_POSTREAD);
278 memcpy(&(sc->adapter_info), command->data_buffer,
279 IPS_ADAPTER_INFO_LEN);
281 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
283 /* I suppose I should clean up my memory allocations */
284 bus_dmamem_free(command->data_dmatag, command->data_buffer,
285 command->data_dmamap);
286 bus_dma_tag_destroy(command->data_dmatag);
287 ips_insert_free_cmd(sc, command);
292 ips_get_adapter_info(ips_softc_t *sc)
295 ips_cmd_status_t *status;
297 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
298 if (ips_get_free_cmd(sc, ips_send_adapter_info_cmd, status,
299 IPS_NOWAIT_FLAG) > 0) {
300 device_printf(sc->dev, "unable to get adapter configuration\n");
301 free(status, M_IPSBUF);
304 if (COMMAND_ERROR(status))
306 free(status, M_IPSBUF);
311 * Below are a series of functions for sending a drive info request
312 * to the adapter. The flow order is: get, send, callback. It uses
313 * the generic finish callback at the top of this file.
314 * This can be used to get drive status info from the card
317 ips_drive_info_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
321 ips_command_t *command = cmdptr;
322 ips_drive_cmd *command_struct;
326 ips_cmd_status_t *status = command->arg;
328 status->value = IPS_ERROR_STATUS;
329 ips_insert_free_cmd(sc, command);
330 printf("ips: error = %d in ips_get_drive_info\n", error);
333 command_struct = (ips_drive_cmd *)command->command_buffer;
334 command_struct->command = IPS_DRIVE_INFO_CMD;
335 command_struct->id = command->id;
336 command_struct->buffaddr = segments[0].ds_addr;
337 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
338 BUS_DMASYNC_PREWRITE);
339 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
340 BUS_DMASYNC_PREREAD);
341 sc->ips_issue_cmd(command);
345 ips_send_drive_info_cmd(ips_command_t *command)
348 ips_softc_t *sc = command->sc;
349 ips_cmd_status_t *status = command->arg;
350 ips_drive_info_t *driveinfo;
352 if (bus_dma_tag_create( /* parent */ sc->adapter_dmatag,
355 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT,
356 /* highaddr */ BUS_SPACE_MAXADDR,
358 /* filterarg */ NULL,
359 /* maxsize */ IPS_DRIVE_INFO_LEN,
361 /* maxsegsize*/ IPS_DRIVE_INFO_LEN,
363 &command->data_dmatag) != 0) {
364 printf("ips: can't alloc dma tag for drive status\n");
368 if (bus_dmamem_alloc(command->data_dmatag, &command->data_buffer,
369 BUS_DMA_NOWAIT, &command->data_dmamap)) {
373 command->callback = ips_wakeup_callback;
375 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
376 command->data_buffer,IPS_DRIVE_INFO_LEN,
377 ips_drive_info_callback, command, BUS_DMA_NOWAIT);
378 if ((status->value == IPS_ERROR_STATUS) ||
379 ips_msleep(status, sc, 0, "ips", 10 * hz) == EWOULDBLOCK)
384 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
385 BUS_DMASYNC_POSTREAD);
386 driveinfo = command->data_buffer;
387 memcpy(sc->drives, driveinfo->drives, sizeof(ips_drive_t) * 8);
388 sc->drivecount = driveinfo->drivecount;
389 device_printf(sc->dev, "logical drives: %d\n", sc->drivecount);
391 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
393 /* I suppose I should clean up my memory allocations */
394 bus_dmamem_free(command->data_dmatag, command->data_buffer,
395 command->data_dmamap);
396 bus_dma_tag_destroy(command->data_dmatag);
397 ips_insert_free_cmd(sc, command);
402 ips_get_drive_info(ips_softc_t *sc)
405 ips_cmd_status_t *status;
407 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
408 if (ips_get_free_cmd(sc, ips_send_drive_info_cmd, status,
409 IPS_NOWAIT_FLAG) > 0) {
410 free(status, M_IPSBUF);
411 device_printf(sc->dev, "unable to get drive configuration\n");
414 if (COMMAND_ERROR(status))
416 free(status, M_IPSBUF);
421 * Below is a pair of functions for making sure data is safely
422 * on disk by flushing the adapter's cache.
425 ips_send_flush_cache_cmd(ips_command_t *command)
427 ips_softc_t *sc = command->sc;
428 ips_cmd_status_t *status = command->arg;
429 ips_generic_cmd *command_struct;
431 PRINTF(10,"ips test: got a command, building flush command\n");
432 command->callback = ips_wakeup_callback;
433 command_struct = (ips_generic_cmd *)command->command_buffer;
434 command_struct->command = IPS_CACHE_FLUSH_CMD;
435 command_struct->id = command->id;
436 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
437 BUS_DMASYNC_PREWRITE);
439 sc->ips_issue_cmd(command);
440 if (status->value != IPS_ERROR_STATUS)
441 ips_msleep(status, sc, 0, "flush2", 0);
443 ips_insert_free_cmd(sc, command);
448 ips_flush_cache(ips_softc_t *sc)
450 ips_cmd_status_t *status;
452 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
453 device_printf(sc->dev, "flushing cache\n");
454 if (ips_get_free_cmd(sc, ips_send_flush_cache_cmd, status,
456 free(status, M_IPSBUF);
457 device_printf(sc->dev, "ERROR: unable to get a command! "
458 "can't flush cache!\n");
461 if (COMMAND_ERROR(status)) {
462 free(status, M_IPSBUF);
463 device_printf(sc->dev, "ERROR: cache flush command failed!\n");
466 free(status, M_IPSBUF);
471 * Simplified localtime to provide timevalues for ffdc.
472 * Taken from libc/stdtime/localtime.c
475 ips_ffdc_settime(ips_adapter_ffdc_cmd *command, time_t sctime)
478 int yleap, *ip, month;
479 int year_lengths[2] = { IPS_DAYSPERNYEAR, IPS_DAYSPERLYEAR };
480 int mon_lengths[2][IPS_MONSPERYEAR] = {
481 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
482 { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
485 days = sctime / IPS_SECSPERDAY;
486 rem = sctime % IPS_SECSPERDAY;
488 command->hour = rem / IPS_SECSPERHOUR;
489 rem = rem % IPS_SECSPERHOUR;
491 command->minute = rem / IPS_SECSPERMIN;
492 command->second = rem % IPS_SECSPERMIN;
495 while (days < 0 || days >= (long)year_lengths[yleap = ips_isleap(y)]) {
498 newy = y + days / IPS_DAYSPERNYEAR;
501 days -= (newy - y) * IPS_DAYSPERNYEAR +
502 IPS_LEAPS_THRU_END_OF(newy - 1) -
503 IPS_LEAPS_THRU_END_OF(y - 1);
506 command->yearH = y / 100;
507 command->yearL = y % 100;
508 ip = mon_lengths[yleap];
509 for (month = 0; days >= (long)ip[month]; ++month)
510 days = days - (long)ip[month];
511 command->month = month + 1;
512 command->day = days + 1;
516 ips_send_ffdc_reset_cmd(ips_command_t *command)
518 ips_softc_t *sc = command->sc;
519 ips_cmd_status_t *status = command->arg;
520 ips_adapter_ffdc_cmd *command_struct;
522 PRINTF(10, "ips test: got a command, building ffdc reset command\n");
523 command->callback = ips_wakeup_callback;
524 command_struct = (ips_adapter_ffdc_cmd *)command->command_buffer;
525 command_struct->command = IPS_FFDC_CMD;
526 command_struct->id = command->id;
527 command_struct->reset_count = sc->ffdc_resetcount;
528 command_struct->reset_type = 0x0;
529 ips_ffdc_settime(command_struct, sc->ffdc_resettime.tv_sec);
530 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
531 BUS_DMASYNC_PREWRITE);
533 sc->ips_issue_cmd(command);
534 if (status->value != IPS_ERROR_STATUS)
535 ips_msleep(status, sc, 0, "ffdc", 0);
537 ips_insert_free_cmd(sc, command);
542 ips_ffdc_reset(ips_softc_t *sc)
544 ips_cmd_status_t *status;
546 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
547 if (ips_get_free_cmd(sc, ips_send_ffdc_reset_cmd, status,
549 free(status, M_IPSBUF);
550 device_printf(sc->dev, "ERROR: unable to get a command! "
551 "can't send ffdc reset!\n");
554 if (COMMAND_ERROR(status)) {
555 free(status, M_IPSBUF);
556 device_printf(sc->dev, "ERROR: ffdc reset command failed!\n");
559 free(status, M_IPSBUF);
564 ips_write_nvram(ips_command_t *command)
566 ips_softc_t *sc = command->sc;
567 ips_rw_nvram_cmd *command_struct;
568 ips_nvram_page5 *nvram;
570 /*FIXME check for error */
571 command->callback = ips_wakeup_callback;
572 command_struct = (ips_rw_nvram_cmd *)command->command_buffer;
573 command_struct->command = IPS_RW_NVRAM_CMD;
574 command_struct->id = command->id;
575 command_struct->pagenum = 5;
576 command_struct->rw = 1; /* write */
577 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
578 BUS_DMASYNC_POSTREAD);
579 nvram = command->data_buffer;
580 /* retrieve adapter info and save in sc */
581 sc->adapter_type = nvram->adapter_type;
582 strncpy(nvram->driver_high, IPS_VERSION_MAJOR, 4);
583 strncpy(nvram->driver_low, IPS_VERSION_MINOR, 4);
584 nvram->operating_system = IPS_OS_FREEBSD;
585 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
586 BUS_DMASYNC_PREWRITE);
587 sc->ips_issue_cmd(command);
591 ips_read_nvram_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
595 ips_command_t *command = cmdptr;
596 ips_rw_nvram_cmd *command_struct;
600 ips_cmd_status_t *status = command->arg;
602 status->value = IPS_ERROR_STATUS;
603 ips_insert_free_cmd(sc, command);
604 printf("ips: error = %d in ips_read_nvram_callback\n", error);
607 command_struct = (ips_rw_nvram_cmd *)command->command_buffer;
608 command_struct->command = IPS_RW_NVRAM_CMD;
609 command_struct->id = command->id;
610 command_struct->pagenum = 5;
611 command_struct->rw = 0;
612 command_struct->buffaddr = segments[0].ds_addr;
614 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
615 BUS_DMASYNC_PREWRITE);
616 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
617 BUS_DMASYNC_PREREAD);
618 sc->ips_issue_cmd(command);
622 ips_read_nvram(ips_command_t *command)
625 ips_softc_t *sc = command->sc;
626 ips_cmd_status_t *status = command->arg;
628 if (bus_dma_tag_create( /* parent */ sc->adapter_dmatag,
631 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT,
632 /* highaddr */ BUS_SPACE_MAXADDR,
634 /* filterarg */ NULL,
635 /* maxsize */ IPS_NVRAM_PAGE_SIZE,
637 /* maxsegsize*/ IPS_NVRAM_PAGE_SIZE,
639 &command->data_dmatag) != 0) {
640 printf("ips: can't alloc dma tag for nvram\n");
644 if (bus_dmamem_alloc(command->data_dmatag, &command->data_buffer,
645 BUS_DMA_NOWAIT, &command->data_dmamap)) {
649 command->callback = ips_write_nvram;
651 bus_dmamap_load(command->data_dmatag, command->data_dmamap,
652 command->data_buffer, IPS_NVRAM_PAGE_SIZE, ips_read_nvram_callback,
653 command, BUS_DMA_NOWAIT);
654 if ((status->value == IPS_ERROR_STATUS) ||
655 ips_msleep(status, sc, 0, "ips", 0) == EWOULDBLOCK)
659 bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
660 BUS_DMASYNC_POSTWRITE);
662 bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
664 bus_dmamem_free(command->data_dmatag, command->data_buffer,
665 command->data_dmamap);
666 bus_dma_tag_destroy(command->data_dmatag);
667 ips_insert_free_cmd(sc, command);
672 ips_update_nvram(ips_softc_t *sc)
674 ips_cmd_status_t *status;
676 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
677 if (ips_get_free_cmd(sc, ips_read_nvram, status, IPS_NOWAIT_FLAG)) {
678 free(status, M_IPSBUF);
679 device_printf(sc->dev, "ERROR: unable to get a command! "
680 "can't update nvram\n");
683 if (COMMAND_ERROR(status)) {
684 free(status, M_IPSBUF);
685 device_printf(sc->dev, "ERROR: nvram update command failed!\n");
688 free(status, M_IPSBUF);
693 ips_send_config_sync_cmd(ips_command_t *command)
695 ips_softc_t *sc = command->sc;
696 ips_cmd_status_t *status = command->arg;
697 ips_generic_cmd *command_struct;
699 PRINTF(10, "ips test: got a command, building flush command\n");
700 command->callback = ips_wakeup_callback;
701 command_struct = (ips_generic_cmd *)command->command_buffer;
702 command_struct->command = IPS_CONFIG_SYNC_CMD;
703 command_struct->id = command->id;
704 command_struct->reserve2 = IPS_POCL;
705 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
706 BUS_DMASYNC_PREWRITE);
708 sc->ips_issue_cmd(command);
709 if (status->value != IPS_ERROR_STATUS)
710 ips_msleep(status, sc, 0, "ipssyn", 0);
712 ips_insert_free_cmd(sc, command);
717 ips_send_error_table_cmd(ips_command_t *command)
719 ips_softc_t *sc = command->sc;
720 ips_cmd_status_t *status = command->arg;
721 ips_generic_cmd *command_struct;
723 PRINTF(10, "ips test: got a command, building errortable command\n");
724 command->callback = ips_wakeup_callback;
725 command_struct = (ips_generic_cmd *)command->command_buffer;
726 command_struct->command = IPS_ERROR_TABLE_CMD;
727 command_struct->id = command->id;
728 command_struct->reserve2 = IPS_CSL;
729 bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
730 BUS_DMASYNC_PREWRITE);
732 sc->ips_issue_cmd(command);
733 if (status->value != IPS_ERROR_STATUS)
734 ips_msleep(status, sc, 0, "ipsetc", 0);
736 ips_insert_free_cmd(sc, command);
741 ips_clear_adapter(ips_softc_t *sc)
743 ips_cmd_status_t *status;
745 status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_INTWAIT | M_ZERO);
746 device_printf(sc->dev, "syncing config\n");
747 if (ips_get_free_cmd(sc, ips_send_config_sync_cmd, status,
749 free(status, M_IPSBUF);
750 device_printf(sc->dev, "ERROR: unable to get a command! "
751 "can't sync cache!\n");
754 if (COMMAND_ERROR(status)) {
755 free(status, M_IPSBUF);
756 device_printf(sc->dev, "ERROR: cache sync command failed!\n");
759 device_printf(sc->dev, "clearing error table\n");
760 if (ips_get_free_cmd(sc, ips_send_error_table_cmd, status,
762 free(status, M_IPSBUF);
763 device_printf(sc->dev, "ERROR: unable to get a command! "
764 "can't sync cache!\n");
767 if (COMMAND_ERROR(status)) {
768 device_printf(sc->dev, "ERROR: etable command failed!\n");
769 free(status, M_IPSBUF);
772 free(status, M_IPSBUF);