2 * Copyright (c) 2008 Yahoo!, Inc.
4 * Written by: John Baldwin <jhb@FreeBSD.org>
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.
14 * 3. Neither the name of the author nor the names of any co-contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * LSI MPT-Fusion Host Adapter FreeBSD userland interface
32 * $FreeBSD: src/sys/dev/mpt/mpt_user.c,v 1.5 2011/03/06 12:48:15 marius Exp $
35 #include <sys/param.h>
37 #include <sys/device.h>
38 #include <sys/errno.h>
39 #include <sys/ioccom.h>
40 #include <sys/mpt_ioctl.h>
42 #include <dev/disk/mpt/mpt.h>
44 struct mpt_user_raid_action_result {
45 uint32_t volume_status;
46 uint32_t action_data[4];
47 uint16_t action_status;
50 struct mpt_page_memory {
57 static mpt_probe_handler_t mpt_user_probe;
58 static mpt_attach_handler_t mpt_user_attach;
59 static mpt_enable_handler_t mpt_user_enable;
60 static mpt_ready_handler_t mpt_user_ready;
61 static mpt_event_handler_t mpt_user_event;
62 static mpt_reset_handler_t mpt_user_reset;
63 static mpt_detach_handler_t mpt_user_detach;
65 static struct mpt_personality mpt_user_personality = {
67 .probe = mpt_user_probe,
68 .attach = mpt_user_attach,
69 .enable = mpt_user_enable,
70 .ready = mpt_user_ready,
71 .event = mpt_user_event,
72 .reset = mpt_user_reset,
73 .detach = mpt_user_detach,
76 DECLARE_MPT_PERSONALITY(mpt_user, SI_ORDER_SECOND);
78 static mpt_reply_handler_t mpt_user_reply_handler;
80 static d_open_t mpt_open;
81 static d_close_t mpt_close;
82 static d_ioctl_t mpt_ioctl;
84 static struct dev_ops mpt_ops = {
91 static MALLOC_DEFINE(M_MPTUSER, "mpt_user", "Buffers for mpt(4) ioctls");
93 static uint32_t user_handler_id = MPT_HANDLER_ID_NONE;
96 mpt_user_probe(struct mpt_softc *mpt)
99 /* Attach to every controller. */
104 mpt_user_attach(struct mpt_softc *mpt)
106 mpt_handler_t handler;
110 handler.reply_handler = mpt_user_reply_handler;
111 error = mpt_register_handler(mpt, MPT_HANDLER_REPLY, handler,
115 mpt_prt(mpt, "Unable to register user handler!\n");
118 unit = device_get_unit(mpt->dev);
119 mpt->cdev = make_dev(&mpt_ops, unit, UID_ROOT, GID_OPERATOR, 0640,
121 if (mpt->cdev == NULL) {
123 mpt_deregister_handler(mpt, MPT_HANDLER_REPLY, handler,
128 mpt->cdev->si_drv1 = mpt;
133 mpt_user_enable(struct mpt_softc *mpt)
140 mpt_user_ready(struct mpt_softc *mpt)
145 mpt_user_event(struct mpt_softc *mpt, request_t *req,
146 MSG_EVENT_NOTIFY_REPLY *msg)
149 /* Someday we may want to let a user daemon listen for events? */
154 mpt_user_reset(struct mpt_softc *mpt, int type)
159 mpt_user_detach(struct mpt_softc *mpt)
161 mpt_handler_t handler;
163 /* XXX: do a purge of pending requests? */
164 destroy_dev(mpt->cdev);
167 handler.reply_handler = mpt_user_reply_handler;
168 mpt_deregister_handler(mpt, MPT_HANDLER_REPLY, handler,
174 mpt_open(struct dev_open_args *ap)
181 mpt_close(struct dev_close_args *ap)
188 mpt_alloc_buffer(struct mpt_softc *mpt, struct mpt_page_memory *page_mem,
191 struct mpt_map_info mi;
194 page_mem->vaddr = NULL;
196 /* Limit requests to 16M. */
197 if (len > 16 * 1024 * 1024)
199 error = mpt_dma_tag_create(mpt, mpt->parent_dmat, 1, 0,
200 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
201 len, 1, len, 0, &page_mem->tag);
204 error = bus_dmamem_alloc(page_mem->tag, &page_mem->vaddr,
205 BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &page_mem->map);
207 bus_dma_tag_destroy(page_mem->tag);
211 error = bus_dmamap_load(page_mem->tag, page_mem->map, page_mem->vaddr,
212 len, mpt_map_rquest, &mi, BUS_DMA_NOWAIT);
216 bus_dmamem_free(page_mem->tag, page_mem->vaddr, page_mem->map);
217 bus_dma_tag_destroy(page_mem->tag);
218 page_mem->vaddr = NULL;
221 page_mem->paddr = mi.phys;
226 mpt_free_buffer(struct mpt_page_memory *page_mem)
229 if (page_mem->vaddr == NULL)
231 bus_dmamap_unload(page_mem->tag, page_mem->map);
232 bus_dmamem_free(page_mem->tag, page_mem->vaddr, page_mem->map);
233 bus_dma_tag_destroy(page_mem->tag);
234 page_mem->vaddr = NULL;
238 mpt_user_read_cfg_header(struct mpt_softc *mpt,
239 struct mpt_cfg_page_req *page_req)
246 req = mpt_get_request(mpt, TRUE);
248 mpt_prt(mpt, "mpt_user_read_cfg_header: Get request failed!\n");
252 params.Action = MPI_CONFIG_ACTION_PAGE_HEADER;
253 params.PageVersion = 0;
254 params.PageLength = 0;
255 params.PageNumber = page_req->header.PageNumber;
256 params.PageType = page_req->header.PageType;
257 params.PageAddress = le32toh(page_req->page_address);
258 error = mpt_issue_cfg_req(mpt, req, ¶ms, /*addr*/0, /*len*/0,
262 * Leave the request. Without resetting the chip, it's
263 * still owned by it and we'll just get into trouble
264 * freeing it now. Mark it as abandoned so that if it
265 * shows up later it can be freed.
267 mpt_prt(mpt, "read_cfg_header timed out\n");
271 page_req->ioc_status = htole16(req->IOCStatus);
272 if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) {
273 cfgp = req->req_vbuf;
274 bcopy(&cfgp->Header, &page_req->header,
275 sizeof(page_req->header));
277 mpt_free_request(mpt, req);
282 mpt_user_read_cfg_page(struct mpt_softc *mpt, struct mpt_cfg_page_req *page_req,
283 struct mpt_page_memory *mpt_page)
285 CONFIG_PAGE_HEADER *hdr;
290 req = mpt_get_request(mpt, TRUE);
292 mpt_prt(mpt, "mpt_user_read_cfg_page: Get request failed!\n");
296 hdr = mpt_page->vaddr;
297 params.Action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
298 params.PageVersion = hdr->PageVersion;
299 params.PageLength = hdr->PageLength;
300 params.PageNumber = hdr->PageNumber;
301 params.PageType = hdr->PageType & MPI_CONFIG_PAGETYPE_MASK;
302 params.PageAddress = le32toh(page_req->page_address);
303 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
304 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
305 error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr,
306 le32toh(page_req->len), TRUE, 5000);
308 mpt_prt(mpt, "mpt_user_read_cfg_page timed out\n");
312 page_req->ioc_status = htole16(req->IOCStatus);
313 if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS)
314 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
315 BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
316 mpt_free_request(mpt, req);
321 mpt_user_read_extcfg_header(struct mpt_softc *mpt,
322 struct mpt_ext_cfg_page_req *ext_page_req)
326 MSG_CONFIG_REPLY *cfgp;
329 req = mpt_get_request(mpt, TRUE);
331 mpt_prt(mpt, "mpt_user_read_extcfg_header: Get request failed!\n");
335 params.Action = MPI_CONFIG_ACTION_PAGE_HEADER;
336 params.PageVersion = ext_page_req->header.PageVersion;
337 params.PageLength = 0;
338 params.PageNumber = ext_page_req->header.PageNumber;
339 params.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
340 params.PageAddress = le32toh(ext_page_req->page_address);
341 params.ExtPageType = ext_page_req->header.ExtPageType;
342 params.ExtPageLength = 0;
343 error = mpt_issue_cfg_req(mpt, req, ¶ms, /*addr*/0, /*len*/0,
347 * Leave the request. Without resetting the chip, it's
348 * still owned by it and we'll just get into trouble
349 * freeing it now. Mark it as abandoned so that if it
350 * shows up later it can be freed.
352 mpt_prt(mpt, "mpt_user_read_extcfg_header timed out\n");
356 ext_page_req->ioc_status = htole16(req->IOCStatus);
357 if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) {
358 cfgp = req->req_vbuf;
359 ext_page_req->header.PageVersion = cfgp->Header.PageVersion;
360 ext_page_req->header.PageNumber = cfgp->Header.PageNumber;
361 ext_page_req->header.PageType = cfgp->Header.PageType;
362 ext_page_req->header.ExtPageLength = cfgp->ExtPageLength;
363 ext_page_req->header.ExtPageType = cfgp->ExtPageType;
365 mpt_free_request(mpt, req);
370 mpt_user_read_extcfg_page(struct mpt_softc *mpt,
371 struct mpt_ext_cfg_page_req *ext_page_req, struct mpt_page_memory *mpt_page)
373 CONFIG_EXTENDED_PAGE_HEADER *hdr;
378 req = mpt_get_request(mpt, TRUE);
380 mpt_prt(mpt, "mpt_user_read_extcfg_page: Get request failed!\n");
384 hdr = mpt_page->vaddr;
385 params.Action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
386 params.PageVersion = hdr->PageVersion;
387 params.PageLength = 0;
388 params.PageNumber = hdr->PageNumber;
389 params.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
390 params.PageAddress = le32toh(ext_page_req->page_address);
391 params.ExtPageType = hdr->ExtPageType;
392 params.ExtPageLength = hdr->ExtPageLength;
393 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
394 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
395 error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr,
396 le32toh(ext_page_req->len), TRUE, 5000);
398 mpt_prt(mpt, "mpt_user_read_extcfg_page timed out\n");
402 ext_page_req->ioc_status = htole16(req->IOCStatus);
403 if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS)
404 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
405 BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
406 mpt_free_request(mpt, req);
411 mpt_user_write_cfg_page(struct mpt_softc *mpt,
412 struct mpt_cfg_page_req *page_req, struct mpt_page_memory *mpt_page)
414 CONFIG_PAGE_HEADER *hdr;
420 hdr = mpt_page->vaddr;
421 hdr_attr = hdr->PageType & MPI_CONFIG_PAGEATTR_MASK;
422 if (hdr_attr != MPI_CONFIG_PAGEATTR_CHANGEABLE &&
423 hdr_attr != MPI_CONFIG_PAGEATTR_PERSISTENT) {
424 mpt_prt(mpt, "page type 0x%x not changeable\n",
425 hdr->PageType & MPI_CONFIG_PAGETYPE_MASK);
431 * We shouldn't mask off other bits here.
433 hdr->PageType &= ~MPI_CONFIG_PAGETYPE_MASK;
436 req = mpt_get_request(mpt, TRUE);
440 bus_dmamap_sync(mpt_page->tag, mpt_page->map, BUS_DMASYNC_PREREAD |
441 BUS_DMASYNC_PREWRITE);
444 * There isn't any point in restoring stripped out attributes
445 * if you then mask them going down to issue the request.
448 params.Action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
449 params.PageVersion = hdr->PageVersion;
450 params.PageLength = hdr->PageLength;
451 params.PageNumber = hdr->PageNumber;
452 params.PageAddress = le32toh(page_req->page_address);
454 /* Restore stripped out attributes */
455 hdr->PageType |= hdr_attr;
456 params.PageType = hdr->PageType & MPI_CONFIG_PAGETYPE_MASK;
458 params.PageType = hdr->PageType;
460 error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr,
461 le32toh(page_req->len), TRUE, 5000);
463 mpt_prt(mpt, "mpt_write_cfg_page timed out\n");
467 page_req->ioc_status = htole16(req->IOCStatus);
468 bus_dmamap_sync(mpt_page->tag, mpt_page->map, BUS_DMASYNC_POSTREAD |
469 BUS_DMASYNC_POSTWRITE);
470 mpt_free_request(mpt, req);
475 mpt_user_reply_handler(struct mpt_softc *mpt, request_t *req,
476 uint32_t reply_desc, MSG_DEFAULT_REPLY *reply_frame)
478 MSG_RAID_ACTION_REPLY *reply;
479 struct mpt_user_raid_action_result *res;
484 if (reply_frame != NULL) {
485 reply = (MSG_RAID_ACTION_REPLY *)reply_frame;
486 req->IOCStatus = le16toh(reply->IOCStatus);
487 res = (struct mpt_user_raid_action_result *)
488 (((uint8_t *)req->req_vbuf) + MPT_RQSL(mpt));
489 res->action_status = reply->ActionStatus;
490 res->volume_status = reply->VolumeStatus;
491 bcopy(&reply->ActionData, res->action_data,
492 sizeof(res->action_data));
495 req->state &= ~REQ_STATE_QUEUED;
496 req->state |= REQ_STATE_DONE;
497 TAILQ_REMOVE(&mpt->request_pending_list, req, links);
499 if ((req->state & REQ_STATE_NEED_WAKEUP) != 0) {
501 } else if ((req->state & REQ_STATE_TIMEDOUT) != 0) {
503 * Whew- we can free this request (late completion)
505 mpt_free_request(mpt, req);
512 * We use the first part of the request buffer after the request frame
513 * to hold the action data and action status from the RAID reply. The
514 * rest of the request buffer is used to hold the buffer for the
518 mpt_user_raid_action(struct mpt_softc *mpt, struct mpt_raid_action *raid_act,
519 struct mpt_page_memory *mpt_page)
522 struct mpt_user_raid_action_result *res;
523 MSG_RAID_ACTION_REQUEST *rap;
527 req = mpt_get_request(mpt, TRUE);
531 memset(rap, 0, sizeof *rap);
532 rap->Action = raid_act->action;
533 rap->ActionDataWord = raid_act->action_data_word;
534 rap->Function = MPI_FUNCTION_RAID_ACTION;
535 rap->VolumeID = raid_act->volume_id;
536 rap->VolumeBus = raid_act->volume_bus;
537 rap->PhysDiskNum = raid_act->phys_disk_num;
538 se = (SGE_SIMPLE32 *)&rap->ActionDataSGE;
539 if (mpt_page->vaddr != NULL && raid_act->len != 0) {
540 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
541 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
542 se->Address = htole32(mpt_page->paddr);
543 MPI_pSGE_SET_LENGTH(se, le32toh(raid_act->len));
544 MPI_pSGE_SET_FLAGS(se, (MPI_SGE_FLAGS_SIMPLE_ELEMENT |
545 MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER |
546 MPI_SGE_FLAGS_END_OF_LIST |
547 raid_act->write ? MPI_SGE_FLAGS_HOST_TO_IOC :
548 MPI_SGE_FLAGS_IOC_TO_HOST));
550 se->FlagsLength = htole32(se->FlagsLength);
551 rap->MsgContext = htole32(req->index | user_handler_id);
553 mpt_check_doorbell(mpt);
554 mpt_send_cmd(mpt, req);
556 error = mpt_wait_req(mpt, req, REQ_STATE_DONE, REQ_STATE_DONE, TRUE,
560 * Leave request so it can be cleaned up later.
562 mpt_prt(mpt, "mpt_user_raid_action timed out\n");
566 raid_act->ioc_status = htole16(req->IOCStatus);
567 if ((req->IOCStatus & MPI_IOCSTATUS_MASK) != MPI_IOCSTATUS_SUCCESS) {
568 mpt_free_request(mpt, req);
572 res = (struct mpt_user_raid_action_result *)
573 (((uint8_t *)req->req_vbuf) + MPT_RQSL(mpt));
574 raid_act->volume_status = res->volume_status;
575 raid_act->action_status = res->action_status;
576 bcopy(res->action_data, raid_act->action_data,
577 sizeof(res->action_data));
578 if (mpt_page->vaddr != NULL)
579 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
580 BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
581 mpt_free_request(mpt, req);
586 #define PTRIN(p) ((void *)(uintptr_t)(p))
587 #define PTROUT(v) ((u_int32_t)(uintptr_t)(v))
591 mpt_ioctl(struct dev_ioctl_args *ap)
593 cdev_t dev = ap->a_head.a_dev;
594 u_long cmd = ap->a_cmd;
595 caddr_t arg = ap->a_data;
596 struct mpt_softc *mpt;
597 struct mpt_cfg_page_req *page_req;
598 struct mpt_ext_cfg_page_req *ext_page_req;
599 struct mpt_raid_action *raid_act;
600 struct mpt_page_memory mpt_page;
602 struct mpt_cfg_page_req32 *page_req32;
603 struct mpt_cfg_page_req page_req_swab;
604 struct mpt_ext_cfg_page_req32 *ext_page_req32;
605 struct mpt_ext_cfg_page_req ext_page_req_swab;
606 struct mpt_raid_action32 *raid_act32;
607 struct mpt_raid_action raid_act_swab;
612 page_req = (void *)arg;
613 ext_page_req = (void *)arg;
614 raid_act = (void *)arg;
615 mpt_page.vaddr = NULL;
618 /* Convert 32-bit structs to native ones. */
619 page_req32 = (void *)arg;
620 ext_page_req32 = (void *)arg;
621 raid_act32 = (void *)arg;
623 case MPTIO_READ_CFG_HEADER32:
624 case MPTIO_READ_CFG_PAGE32:
625 case MPTIO_WRITE_CFG_PAGE32:
626 page_req = &page_req_swab;
627 page_req->header = page_req32->header;
628 page_req->page_address = page_req32->page_address;
629 page_req->buf = PTRIN(page_req32->buf);
630 page_req->len = page_req32->len;
631 page_req->ioc_status = page_req32->ioc_status;
633 case MPTIO_READ_EXT_CFG_HEADER32:
634 case MPTIO_READ_EXT_CFG_PAGE32:
635 ext_page_req = &ext_page_req_swab;
636 ext_page_req->header = ext_page_req32->header;
637 ext_page_req->page_address = ext_page_req32->page_address;
638 ext_page_req->buf = PTRIN(ext_page_req32->buf);
639 ext_page_req->len = ext_page_req32->len;
640 ext_page_req->ioc_status = ext_page_req32->ioc_status;
642 case MPTIO_RAID_ACTION32:
643 raid_act = &raid_act_swab;
644 raid_act->action = raid_act32->action;
645 raid_act->volume_bus = raid_act32->volume_bus;
646 raid_act->volume_id = raid_act32->volume_id;
647 raid_act->phys_disk_num = raid_act32->phys_disk_num;
648 raid_act->action_data_word = raid_act32->action_data_word;
649 raid_act->buf = PTRIN(raid_act32->buf);
650 raid_act->len = raid_act32->len;
651 raid_act->volume_status = raid_act32->volume_status;
652 bcopy(raid_act32->action_data, raid_act->action_data,
653 sizeof(raid_act->action_data));
654 raid_act->action_status = raid_act32->action_status;
655 raid_act->ioc_status = raid_act32->ioc_status;
656 raid_act->write = raid_act32->write;
663 case MPTIO_READ_CFG_HEADER32:
665 case MPTIO_READ_CFG_HEADER:
667 error = mpt_user_read_cfg_header(mpt, page_req);
671 case MPTIO_READ_CFG_PAGE32:
673 case MPTIO_READ_CFG_PAGE:
674 error = mpt_alloc_buffer(mpt, &mpt_page, page_req->len);
677 error = copyin(page_req->buf, mpt_page.vaddr,
678 sizeof(CONFIG_PAGE_HEADER));
682 error = mpt_user_read_cfg_page(mpt, page_req, &mpt_page);
686 error = copyout(mpt_page.vaddr, page_req->buf, page_req->len);
689 case MPTIO_READ_EXT_CFG_HEADER32:
691 case MPTIO_READ_EXT_CFG_HEADER:
693 error = mpt_user_read_extcfg_header(mpt, ext_page_req);
697 case MPTIO_READ_EXT_CFG_PAGE32:
699 case MPTIO_READ_EXT_CFG_PAGE:
700 error = mpt_alloc_buffer(mpt, &mpt_page, ext_page_req->len);
703 error = copyin(ext_page_req->buf, mpt_page.vaddr,
704 sizeof(CONFIG_EXTENDED_PAGE_HEADER));
708 error = mpt_user_read_extcfg_page(mpt, ext_page_req, &mpt_page);
712 error = copyout(mpt_page.vaddr, ext_page_req->buf,
716 case MPTIO_WRITE_CFG_PAGE32:
718 case MPTIO_WRITE_CFG_PAGE:
719 error = mpt_alloc_buffer(mpt, &mpt_page, page_req->len);
722 error = copyin(page_req->buf, mpt_page.vaddr, page_req->len);
726 error = mpt_user_write_cfg_page(mpt, page_req, &mpt_page);
730 case MPTIO_RAID_ACTION32:
732 case MPTIO_RAID_ACTION:
733 if (raid_act->buf != NULL) {
734 error = mpt_alloc_buffer(mpt, &mpt_page, raid_act->len);
737 error = copyin(raid_act->buf, mpt_page.vaddr,
743 error = mpt_user_raid_action(mpt, raid_act, &mpt_page);
747 if (raid_act->buf != NULL)
748 error = copyout(mpt_page.vaddr, raid_act->buf,
756 mpt_free_buffer(&mpt_page);
762 /* Convert native structs to 32-bit ones. */
764 case MPTIO_READ_CFG_HEADER32:
765 case MPTIO_READ_CFG_PAGE32:
766 case MPTIO_WRITE_CFG_PAGE32:
767 page_req32->header = page_req->header;
768 page_req32->page_address = page_req->page_address;
769 page_req32->buf = PTROUT(page_req->buf);
770 page_req32->len = page_req->len;
771 page_req32->ioc_status = page_req->ioc_status;
773 case MPTIO_READ_EXT_CFG_HEADER32:
774 case MPTIO_READ_EXT_CFG_PAGE32:
775 ext_page_req32->header = ext_page_req->header;
776 ext_page_req32->page_address = ext_page_req->page_address;
777 ext_page_req32->buf = PTROUT(ext_page_req->buf);
778 ext_page_req32->len = ext_page_req->len;
779 ext_page_req32->ioc_status = ext_page_req->ioc_status;
781 case MPTIO_RAID_ACTION32:
782 raid_act32->action = raid_act->action;
783 raid_act32->volume_bus = raid_act->volume_bus;
784 raid_act32->volume_id = raid_act->volume_id;
785 raid_act32->phys_disk_num = raid_act->phys_disk_num;
786 raid_act32->action_data_word = raid_act->action_data_word;
787 raid_act32->buf = PTROUT(raid_act->buf);
788 raid_act32->len = raid_act->len;
789 raid_act32->volume_status = raid_act->volume_status;
790 bcopy(raid_act->action_data, raid_act32->action_data,
791 sizeof(raid_act->action_data));
792 raid_act32->action_status = raid_act->action_status;
793 raid_act32->ioc_status = raid_act->ioc_status;
794 raid_act32->write = raid_act->write;