2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2008 Yahoo!, Inc.
6 * Written by: John Baldwin <jhb@FreeBSD.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * LSI MPT-Fusion Host Adapter FreeBSD userland interface
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
38 #include <sys/param.h>
40 #include <sys/errno.h>
41 #include <sys/ioccom.h>
42 #include <sys/mpt_ioctl.h>
44 #include <dev/mpt/mpt.h>
46 struct mpt_user_raid_action_result {
47 uint32_t volume_status;
48 uint32_t action_data[4];
49 uint16_t action_status;
52 struct mpt_page_memory {
59 static mpt_probe_handler_t mpt_user_probe;
60 static mpt_attach_handler_t mpt_user_attach;
61 static mpt_enable_handler_t mpt_user_enable;
62 static mpt_ready_handler_t mpt_user_ready;
63 static mpt_event_handler_t mpt_user_event;
64 static mpt_reset_handler_t mpt_user_reset;
65 static mpt_detach_handler_t mpt_user_detach;
67 static struct mpt_personality mpt_user_personality = {
69 .probe = mpt_user_probe,
70 .attach = mpt_user_attach,
71 .enable = mpt_user_enable,
72 .ready = mpt_user_ready,
73 .event = mpt_user_event,
74 .reset = mpt_user_reset,
75 .detach = mpt_user_detach,
78 DECLARE_MPT_PERSONALITY(mpt_user, SI_ORDER_SECOND);
80 static mpt_reply_handler_t mpt_user_reply_handler;
82 static d_open_t mpt_open;
83 static d_close_t mpt_close;
84 static d_ioctl_t mpt_ioctl;
86 static struct cdevsw mpt_cdevsw = {
87 .d_version = D_VERSION,
95 static MALLOC_DEFINE(M_MPTUSER, "mpt_user", "Buffers for mpt(4) ioctls");
97 static uint32_t user_handler_id = MPT_HANDLER_ID_NONE;
100 mpt_user_probe(struct mpt_softc *mpt)
103 /* Attach to every controller. */
108 mpt_user_attach(struct mpt_softc *mpt)
110 mpt_handler_t handler;
114 handler.reply_handler = mpt_user_reply_handler;
115 error = mpt_register_handler(mpt, MPT_HANDLER_REPLY, handler,
119 mpt_prt(mpt, "Unable to register user handler!\n");
122 unit = device_get_unit(mpt->dev);
123 mpt->cdev = make_dev(&mpt_cdevsw, unit, UID_ROOT, GID_OPERATOR, 0640,
125 if (mpt->cdev == NULL) {
127 mpt_deregister_handler(mpt, MPT_HANDLER_REPLY, handler,
132 mpt->cdev->si_drv1 = mpt;
137 mpt_user_enable(struct mpt_softc *mpt)
144 mpt_user_ready(struct mpt_softc *mpt)
150 mpt_user_event(struct mpt_softc *mpt, request_t *req,
151 MSG_EVENT_NOTIFY_REPLY *msg)
154 /* Someday we may want to let a user daemon listen for events? */
159 mpt_user_reset(struct mpt_softc *mpt, int type)
165 mpt_user_detach(struct mpt_softc *mpt)
167 mpt_handler_t handler;
169 /* XXX: do a purge of pending requests? */
170 destroy_dev(mpt->cdev);
173 handler.reply_handler = mpt_user_reply_handler;
174 mpt_deregister_handler(mpt, MPT_HANDLER_REPLY, handler,
180 mpt_open(struct cdev *dev, int flags, int fmt, struct thread *td)
187 mpt_close(struct cdev *dev, int flags, int fmt, struct thread *td)
194 mpt_alloc_buffer(struct mpt_softc *mpt, struct mpt_page_memory *page_mem,
197 struct mpt_map_info mi;
200 page_mem->vaddr = NULL;
202 /* Limit requests to 16M. */
203 if (len > 16 * 1024 * 1024)
205 error = mpt_dma_tag_create(mpt, mpt->parent_dmat, 1, 0,
206 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
207 len, 1, len, 0, &page_mem->tag);
210 error = bus_dmamem_alloc(page_mem->tag, &page_mem->vaddr,
211 BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &page_mem->map);
213 bus_dma_tag_destroy(page_mem->tag);
217 error = bus_dmamap_load(page_mem->tag, page_mem->map, page_mem->vaddr,
218 len, mpt_map_rquest, &mi, BUS_DMA_NOWAIT);
222 bus_dmamem_free(page_mem->tag, page_mem->vaddr, page_mem->map);
223 bus_dma_tag_destroy(page_mem->tag);
224 page_mem->vaddr = NULL;
227 page_mem->paddr = mi.phys;
232 mpt_free_buffer(struct mpt_page_memory *page_mem)
235 if (page_mem->vaddr == NULL)
237 bus_dmamap_unload(page_mem->tag, page_mem->map);
238 bus_dmamem_free(page_mem->tag, page_mem->vaddr, page_mem->map);
239 bus_dma_tag_destroy(page_mem->tag);
240 page_mem->vaddr = NULL;
244 mpt_user_read_cfg_header(struct mpt_softc *mpt,
245 struct mpt_cfg_page_req *page_req)
252 req = mpt_get_request(mpt, TRUE);
254 mpt_prt(mpt, "mpt_user_read_cfg_header: Get request failed!\n");
258 params.Action = MPI_CONFIG_ACTION_PAGE_HEADER;
259 params.PageVersion = 0;
260 params.PageLength = 0;
261 params.PageNumber = page_req->header.PageNumber;
262 params.PageType = page_req->header.PageType;
263 params.PageAddress = le32toh(page_req->page_address);
264 error = mpt_issue_cfg_req(mpt, req, ¶ms, /*addr*/0, /*len*/0,
268 * Leave the request. Without resetting the chip, it's
269 * still owned by it and we'll just get into trouble
270 * freeing it now. Mark it as abandoned so that if it
271 * shows up later it can be freed.
273 mpt_prt(mpt, "read_cfg_header timed out\n");
277 page_req->ioc_status = htole16(req->IOCStatus);
278 if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) {
279 cfgp = req->req_vbuf;
280 bcopy(&cfgp->Header, &page_req->header,
281 sizeof(page_req->header));
283 mpt_free_request(mpt, req);
288 mpt_user_read_cfg_page(struct mpt_softc *mpt, struct mpt_cfg_page_req *page_req,
289 struct mpt_page_memory *mpt_page)
291 CONFIG_PAGE_HEADER *hdr;
296 req = mpt_get_request(mpt, TRUE);
298 mpt_prt(mpt, "mpt_user_read_cfg_page: Get request failed!\n");
302 hdr = mpt_page->vaddr;
303 params.Action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
304 params.PageVersion = hdr->PageVersion;
305 params.PageLength = hdr->PageLength;
306 params.PageNumber = hdr->PageNumber;
307 params.PageType = hdr->PageType & MPI_CONFIG_PAGETYPE_MASK;
308 params.PageAddress = le32toh(page_req->page_address);
309 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
310 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
311 error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr,
312 le32toh(page_req->len), TRUE, 5000);
314 mpt_prt(mpt, "mpt_user_read_cfg_page timed out\n");
318 page_req->ioc_status = htole16(req->IOCStatus);
319 if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS)
320 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
321 BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
322 mpt_free_request(mpt, req);
327 mpt_user_read_extcfg_header(struct mpt_softc *mpt,
328 struct mpt_ext_cfg_page_req *ext_page_req)
332 MSG_CONFIG_REPLY *cfgp;
335 req = mpt_get_request(mpt, TRUE);
337 mpt_prt(mpt, "mpt_user_read_extcfg_header: Get request failed!\n");
341 params.Action = MPI_CONFIG_ACTION_PAGE_HEADER;
342 params.PageVersion = ext_page_req->header.PageVersion;
343 params.PageLength = 0;
344 params.PageNumber = ext_page_req->header.PageNumber;
345 params.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
346 params.PageAddress = le32toh(ext_page_req->page_address);
347 params.ExtPageType = ext_page_req->header.ExtPageType;
348 params.ExtPageLength = 0;
349 error = mpt_issue_cfg_req(mpt, req, ¶ms, /*addr*/0, /*len*/0,
353 * Leave the request. Without resetting the chip, it's
354 * still owned by it and we'll just get into trouble
355 * freeing it now. Mark it as abandoned so that if it
356 * shows up later it can be freed.
358 mpt_prt(mpt, "mpt_user_read_extcfg_header timed out\n");
362 ext_page_req->ioc_status = htole16(req->IOCStatus);
363 if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) {
364 cfgp = req->req_vbuf;
365 ext_page_req->header.PageVersion = cfgp->Header.PageVersion;
366 ext_page_req->header.PageNumber = cfgp->Header.PageNumber;
367 ext_page_req->header.PageType = cfgp->Header.PageType;
368 ext_page_req->header.ExtPageLength = cfgp->ExtPageLength;
369 ext_page_req->header.ExtPageType = cfgp->ExtPageType;
371 mpt_free_request(mpt, req);
376 mpt_user_read_extcfg_page(struct mpt_softc *mpt,
377 struct mpt_ext_cfg_page_req *ext_page_req, struct mpt_page_memory *mpt_page)
379 CONFIG_EXTENDED_PAGE_HEADER *hdr;
384 req = mpt_get_request(mpt, TRUE);
386 mpt_prt(mpt, "mpt_user_read_extcfg_page: Get request failed!\n");
390 hdr = mpt_page->vaddr;
391 params.Action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
392 params.PageVersion = hdr->PageVersion;
393 params.PageLength = 0;
394 params.PageNumber = hdr->PageNumber;
395 params.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
396 params.PageAddress = le32toh(ext_page_req->page_address);
397 params.ExtPageType = hdr->ExtPageType;
398 params.ExtPageLength = hdr->ExtPageLength;
399 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
400 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
401 error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr,
402 le32toh(ext_page_req->len), TRUE, 5000);
404 mpt_prt(mpt, "mpt_user_read_extcfg_page timed out\n");
408 ext_page_req->ioc_status = htole16(req->IOCStatus);
409 if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS)
410 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
411 BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
412 mpt_free_request(mpt, req);
417 mpt_user_write_cfg_page(struct mpt_softc *mpt,
418 struct mpt_cfg_page_req *page_req, struct mpt_page_memory *mpt_page)
420 CONFIG_PAGE_HEADER *hdr;
426 hdr = mpt_page->vaddr;
427 hdr_attr = hdr->PageType & MPI_CONFIG_PAGEATTR_MASK;
428 if (hdr_attr != MPI_CONFIG_PAGEATTR_CHANGEABLE &&
429 hdr_attr != MPI_CONFIG_PAGEATTR_PERSISTENT) {
430 mpt_prt(mpt, "page type 0x%x not changeable\n",
431 hdr->PageType & MPI_CONFIG_PAGETYPE_MASK);
437 * We shouldn't mask off other bits here.
439 hdr->PageType &= ~MPI_CONFIG_PAGETYPE_MASK;
442 req = mpt_get_request(mpt, TRUE);
446 bus_dmamap_sync(mpt_page->tag, mpt_page->map, BUS_DMASYNC_PREREAD |
447 BUS_DMASYNC_PREWRITE);
450 * There isn't any point in restoring stripped out attributes
451 * if you then mask them going down to issue the request.
454 params.Action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
455 params.PageVersion = hdr->PageVersion;
456 params.PageLength = hdr->PageLength;
457 params.PageNumber = hdr->PageNumber;
458 params.PageAddress = le32toh(page_req->page_address);
460 /* Restore stripped out attributes */
461 hdr->PageType |= hdr_attr;
462 params.PageType = hdr->PageType & MPI_CONFIG_PAGETYPE_MASK;
464 params.PageType = hdr->PageType;
466 error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr,
467 le32toh(page_req->len), TRUE, 5000);
469 mpt_prt(mpt, "mpt_write_cfg_page timed out\n");
473 page_req->ioc_status = htole16(req->IOCStatus);
474 bus_dmamap_sync(mpt_page->tag, mpt_page->map, BUS_DMASYNC_POSTREAD |
475 BUS_DMASYNC_POSTWRITE);
476 mpt_free_request(mpt, req);
481 mpt_user_reply_handler(struct mpt_softc *mpt, request_t *req,
482 uint32_t reply_desc, MSG_DEFAULT_REPLY *reply_frame)
484 MSG_RAID_ACTION_REPLY *reply;
485 struct mpt_user_raid_action_result *res;
490 if (reply_frame != NULL) {
491 reply = (MSG_RAID_ACTION_REPLY *)reply_frame;
492 req->IOCStatus = le16toh(reply->IOCStatus);
493 res = (struct mpt_user_raid_action_result *)
494 (((uint8_t *)req->req_vbuf) + MPT_RQSL(mpt));
495 res->action_status = reply->ActionStatus;
496 res->volume_status = reply->VolumeStatus;
497 bcopy(&reply->ActionData, res->action_data,
498 sizeof(res->action_data));
501 req->state &= ~REQ_STATE_QUEUED;
502 req->state |= REQ_STATE_DONE;
503 TAILQ_REMOVE(&mpt->request_pending_list, req, links);
505 if ((req->state & REQ_STATE_NEED_WAKEUP) != 0) {
507 } else if ((req->state & REQ_STATE_TIMEDOUT) != 0) {
509 * Whew- we can free this request (late completion)
511 mpt_free_request(mpt, req);
518 * We use the first part of the request buffer after the request frame
519 * to hold the action data and action status from the RAID reply. The
520 * rest of the request buffer is used to hold the buffer for the
524 mpt_user_raid_action(struct mpt_softc *mpt, struct mpt_raid_action *raid_act,
525 struct mpt_page_memory *mpt_page)
528 struct mpt_user_raid_action_result *res;
529 MSG_RAID_ACTION_REQUEST *rap;
533 req = mpt_get_request(mpt, TRUE);
537 memset(rap, 0, sizeof *rap);
538 rap->Action = raid_act->action;
539 rap->ActionDataWord = raid_act->action_data_word;
540 rap->Function = MPI_FUNCTION_RAID_ACTION;
541 rap->VolumeID = raid_act->volume_id;
542 rap->VolumeBus = raid_act->volume_bus;
543 rap->PhysDiskNum = raid_act->phys_disk_num;
544 se = (SGE_SIMPLE32 *)&rap->ActionDataSGE;
545 if (mpt_page->vaddr != NULL && raid_act->len != 0) {
546 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
547 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
548 se->Address = htole32(mpt_page->paddr);
549 MPI_pSGE_SET_LENGTH(se, le32toh(raid_act->len));
550 MPI_pSGE_SET_FLAGS(se, (MPI_SGE_FLAGS_SIMPLE_ELEMENT |
551 MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER |
552 MPI_SGE_FLAGS_END_OF_LIST |
553 (raid_act->write ? MPI_SGE_FLAGS_HOST_TO_IOC :
554 MPI_SGE_FLAGS_IOC_TO_HOST)));
556 se->FlagsLength = htole32(se->FlagsLength);
557 rap->MsgContext = htole32(req->index | user_handler_id);
559 mpt_check_doorbell(mpt);
560 mpt_send_cmd(mpt, req);
562 error = mpt_wait_req(mpt, req, REQ_STATE_DONE, REQ_STATE_DONE, TRUE,
566 * Leave request so it can be cleaned up later.
568 mpt_prt(mpt, "mpt_user_raid_action timed out\n");
572 raid_act->ioc_status = htole16(req->IOCStatus);
573 if ((req->IOCStatus & MPI_IOCSTATUS_MASK) != MPI_IOCSTATUS_SUCCESS) {
574 mpt_free_request(mpt, req);
578 res = (struct mpt_user_raid_action_result *)
579 (((uint8_t *)req->req_vbuf) + MPT_RQSL(mpt));
580 raid_act->volume_status = res->volume_status;
581 raid_act->action_status = res->action_status;
582 bcopy(res->action_data, raid_act->action_data,
583 sizeof(res->action_data));
584 if (mpt_page->vaddr != NULL)
585 bus_dmamap_sync(mpt_page->tag, mpt_page->map,
586 BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
587 mpt_free_request(mpt, req);
592 #define PTRIN(p) ((void *)(uintptr_t)(p))
593 #define PTROUT(v) ((u_int32_t)(uintptr_t)(v))
597 mpt_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
599 struct mpt_softc *mpt;
600 struct mpt_cfg_page_req *page_req;
601 struct mpt_ext_cfg_page_req *ext_page_req;
602 struct mpt_raid_action *raid_act;
603 struct mpt_page_memory mpt_page;
605 struct mpt_cfg_page_req32 *page_req32;
606 struct mpt_cfg_page_req page_req_swab;
607 struct mpt_ext_cfg_page_req32 *ext_page_req32;
608 struct mpt_ext_cfg_page_req ext_page_req_swab;
609 struct mpt_raid_action32 *raid_act32;
610 struct mpt_raid_action raid_act_swab;
615 page_req = (void *)arg;
616 ext_page_req = (void *)arg;
617 raid_act = (void *)arg;
618 mpt_page.vaddr = NULL;
621 /* Convert 32-bit structs to native ones. */
622 page_req32 = (void *)arg;
623 ext_page_req32 = (void *)arg;
624 raid_act32 = (void *)arg;
626 case MPTIO_READ_CFG_HEADER32:
627 case MPTIO_READ_CFG_PAGE32:
628 case MPTIO_WRITE_CFG_PAGE32:
629 page_req = &page_req_swab;
630 page_req->header = page_req32->header;
631 page_req->page_address = page_req32->page_address;
632 page_req->buf = PTRIN(page_req32->buf);
633 page_req->len = page_req32->len;
634 page_req->ioc_status = page_req32->ioc_status;
636 case MPTIO_READ_EXT_CFG_HEADER32:
637 case MPTIO_READ_EXT_CFG_PAGE32:
638 ext_page_req = &ext_page_req_swab;
639 ext_page_req->header = ext_page_req32->header;
640 ext_page_req->page_address = ext_page_req32->page_address;
641 ext_page_req->buf = PTRIN(ext_page_req32->buf);
642 ext_page_req->len = ext_page_req32->len;
643 ext_page_req->ioc_status = ext_page_req32->ioc_status;
645 case MPTIO_RAID_ACTION32:
646 raid_act = &raid_act_swab;
647 raid_act->action = raid_act32->action;
648 raid_act->volume_bus = raid_act32->volume_bus;
649 raid_act->volume_id = raid_act32->volume_id;
650 raid_act->phys_disk_num = raid_act32->phys_disk_num;
651 raid_act->action_data_word = raid_act32->action_data_word;
652 raid_act->buf = PTRIN(raid_act32->buf);
653 raid_act->len = raid_act32->len;
654 raid_act->volume_status = raid_act32->volume_status;
655 bcopy(raid_act32->action_data, raid_act->action_data,
656 sizeof(raid_act->action_data));
657 raid_act->action_status = raid_act32->action_status;
658 raid_act->ioc_status = raid_act32->ioc_status;
659 raid_act->write = raid_act32->write;
666 case MPTIO_READ_CFG_HEADER32:
668 case MPTIO_READ_CFG_HEADER:
670 error = mpt_user_read_cfg_header(mpt, page_req);
674 case MPTIO_READ_CFG_PAGE32:
676 case MPTIO_READ_CFG_PAGE:
677 error = mpt_alloc_buffer(mpt, &mpt_page, page_req->len);
680 error = copyin(page_req->buf, mpt_page.vaddr,
681 sizeof(CONFIG_PAGE_HEADER));
685 error = mpt_user_read_cfg_page(mpt, page_req, &mpt_page);
689 error = copyout(mpt_page.vaddr, page_req->buf, page_req->len);
692 case MPTIO_READ_EXT_CFG_HEADER32:
694 case MPTIO_READ_EXT_CFG_HEADER:
696 error = mpt_user_read_extcfg_header(mpt, ext_page_req);
700 case MPTIO_READ_EXT_CFG_PAGE32:
702 case MPTIO_READ_EXT_CFG_PAGE:
703 error = mpt_alloc_buffer(mpt, &mpt_page, ext_page_req->len);
706 error = copyin(ext_page_req->buf, mpt_page.vaddr,
707 sizeof(CONFIG_EXTENDED_PAGE_HEADER));
711 error = mpt_user_read_extcfg_page(mpt, ext_page_req, &mpt_page);
715 error = copyout(mpt_page.vaddr, ext_page_req->buf,
719 case MPTIO_WRITE_CFG_PAGE32:
721 case MPTIO_WRITE_CFG_PAGE:
722 error = mpt_alloc_buffer(mpt, &mpt_page, page_req->len);
725 error = copyin(page_req->buf, mpt_page.vaddr, page_req->len);
729 error = mpt_user_write_cfg_page(mpt, page_req, &mpt_page);
733 case MPTIO_RAID_ACTION32:
735 case MPTIO_RAID_ACTION:
736 if (raid_act->buf != NULL) {
737 error = mpt_alloc_buffer(mpt, &mpt_page, raid_act->len);
740 error = copyin(raid_act->buf, mpt_page.vaddr,
746 error = mpt_user_raid_action(mpt, raid_act, &mpt_page);
750 if (raid_act->buf != NULL)
751 error = copyout(mpt_page.vaddr, raid_act->buf,
759 mpt_free_buffer(&mpt_page);
765 /* Convert native structs to 32-bit ones. */
767 case MPTIO_READ_CFG_HEADER32:
768 case MPTIO_READ_CFG_PAGE32:
769 case MPTIO_WRITE_CFG_PAGE32:
770 page_req32->header = page_req->header;
771 page_req32->page_address = page_req->page_address;
772 page_req32->buf = PTROUT(page_req->buf);
773 page_req32->len = page_req->len;
774 page_req32->ioc_status = page_req->ioc_status;
776 case MPTIO_READ_EXT_CFG_HEADER32:
777 case MPTIO_READ_EXT_CFG_PAGE32:
778 ext_page_req32->header = ext_page_req->header;
779 ext_page_req32->page_address = ext_page_req->page_address;
780 ext_page_req32->buf = PTROUT(ext_page_req->buf);
781 ext_page_req32->len = ext_page_req->len;
782 ext_page_req32->ioc_status = ext_page_req->ioc_status;
784 case MPTIO_RAID_ACTION32:
785 raid_act32->action = raid_act->action;
786 raid_act32->volume_bus = raid_act->volume_bus;
787 raid_act32->volume_id = raid_act->volume_id;
788 raid_act32->phys_disk_num = raid_act->phys_disk_num;
789 raid_act32->action_data_word = raid_act->action_data_word;
790 raid_act32->buf = PTROUT(raid_act->buf);
791 raid_act32->len = raid_act->len;
792 raid_act32->volume_status = raid_act->volume_status;
793 bcopy(raid_act->action_data, raid_act32->action_data,
794 sizeof(raid_act->action_data));
795 raid_act32->action_status = raid_act->action_status;
796 raid_act32->ioc_status = raid_act->ioc_status;
797 raid_act32->write = raid_act->write;