Lines Matching +full:frame +full:- +full:buffer

89         struct mrsas_softc *sc = cb->sc;  in mrsas_passthru_load_cb()
93 cb->error_code = error; in mrsas_passthru_load_cb()
95 device_printf(sc->mrsas_dev, "mrsas_passthru_load_cb: " in mrsas_passthru_load_cb()
97 cb->complete = 1; in mrsas_passthru_load_cb()
100 device_printf(sc->mrsas_dev, "mrsas_passthru_load_cb: " in mrsas_passthru_load_cb()
105 cb->error_code = EFBIG; in mrsas_passthru_load_cb()
106 device_printf(sc->mrsas_dev, "mrsas_passthru_load_cb: " in mrsas_passthru_load_cb()
108 cb->complete = 1; in mrsas_passthru_load_cb()
113 cb->kern_sge[i].phys_addr = htole64(segs[i].ds_addr); in mrsas_passthru_load_cb()
114 cb->kern_sge[i].length = htole32(segs[i].ds_len); in mrsas_passthru_load_cb()
116 cb->sge_count = nseg; in mrsas_passthru_load_cb()
118 bus_dmamap_sync(cb->ioctl_data_tag, cb->ioctl_data_dmamap, in mrsas_passthru_load_cb()
121 cb->complete = 1; in mrsas_passthru_load_cb()
125 * mrsas_passthru: Handle pass-through commands
128 * This function is called from mrsas_ioctl() to handle pass-through and ioctl
140 union mrsas_frame *in_cmd = (union mrsas_frame *)&(user_ioc->frame.raw); in mrsas_passthru()
160 if (in_cmd->dcmd.opcode == 0) { in mrsas_passthru()
161 device_printf(sc->mrsas_dev, "In %s() Got a NOP\n", __func__); in mrsas_passthru()
162 user_ioc->frame.hdr.cmd_status = MFI_STAT_OK; in mrsas_passthru()
166 if (user_ioc->sge_count > MAX_IOCTL_SGE) { in mrsas_passthru()
167 device_printf(sc->mrsas_dev, "In %s() SGL is too long (%d > 8).\n", in mrsas_passthru()
168 __func__, user_ioc->sge_count); in mrsas_passthru()
174 device_printf(sc->mrsas_dev, "Failed to get a free cmd for IOCTL\n"); in mrsas_passthru()
179 * into our cmd's frames. cmd->frame's context will get overwritten in mrsas_passthru()
183 memcpy(cmd->frame, user_ioc->frame.raw, 2 * MEGAMFI_FRAME_SIZE); in mrsas_passthru()
184 cmd->frame->hdr.context = cmd->index; in mrsas_passthru()
185 cmd->frame->hdr.pad_0 = 0; in mrsas_passthru()
186 cmd->frame->hdr.flags &= ~(MFI_FRAME_IEEE | MFI_FRAME_SGL64 | in mrsas_passthru()
198 ((uintptr_t)cmd->frame + user_ioc->sgl_off); in mrsas_passthru()
206 * For each user buffer, create a mirror buffer and copy in in mrsas_passthru()
208 for (i = 0; i < user_ioc->sge_count; i++) { in mrsas_passthru()
210 if (!user_ioc->sgl[i].iov_len) in mrsas_passthru()
212 ioctl_data_size = user_ioc->sgl[i].iov_len; in mrsas_passthru()
215 if (!user_ioc32->sgl[i].iov_len) in mrsas_passthru()
217 ioctl_data_size = user_ioc32->sgl[i].iov_len; in mrsas_passthru()
220 if (bus_dma_tag_create(sc->mrsas_parent_tag, in mrsas_passthru()
231 device_printf(sc->mrsas_dev, "Cannot allocate ioctl data tag\n"); in mrsas_passthru()
237 device_printf(sc->mrsas_dev, "Cannot allocate ioctl data mem\n"); in mrsas_passthru()
244 device_printf(sc->mrsas_dev, "Cannot load ioctl data mem\n"); in mrsas_passthru()
252 kern_sge32[i].length = user_ioc->sgl[i].iov_len; in mrsas_passthru()
254 iov_base_ptrin = user_ioc->sgl[i].iov_base; in mrsas_passthru()
255 iov_len = user_ioc->sgl[i].iov_len; in mrsas_passthru()
258 kern_sge32[i].length = user_ioc32->sgl[i].iov_len; in mrsas_passthru()
260 iov_base_ptrin = PTRIN(user_ioc32->sgl[i].iov_base); in mrsas_passthru()
261 iov_len = user_ioc32->sgl[i].iov_len; in mrsas_passthru()
268 device_printf(sc->mrsas_dev, "IOCTL copyin failed!\n"); in mrsas_passthru()
273 ioctl_sense_size = user_ioc->sense_len; in mrsas_passthru()
275 if (user_ioc->sense_len) { in mrsas_passthru()
276 if (bus_dma_tag_create(sc->mrsas_parent_tag, in mrsas_passthru()
287 device_printf(sc->mrsas_dev, "Cannot allocate ioctl sense tag\n"); in mrsas_passthru()
293 device_printf(sc->mrsas_dev, "Cannot allocate ioctl sense mem\n"); in mrsas_passthru()
300 device_printf(sc->mrsas_dev, "Cannot load ioctl sense mem\n"); in mrsas_passthru()
305 (unsigned long *)((uintptr_t)cmd->frame + user_ioc->sense_off); in mrsas_passthru()
310 * cmd to the SCSI mid-layer in mrsas_passthru()
312 cmd->sync_cmd = 1; in mrsas_passthru()
317 sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR; in mrsas_passthru()
321 cmd->sync_cmd = 0; in mrsas_passthru()
326 for (i = 0; i < user_ioc->sge_count; i++) { in mrsas_passthru()
328 iov_base_ptrin = user_ioc->sgl[i].iov_base; in mrsas_passthru()
329 iov_len = user_ioc->sgl[i].iov_len; in mrsas_passthru()
332 iov_base_ptrin = PTRIN(user_ioc32->sgl[i].iov_base); in mrsas_passthru()
333 iov_len = user_ioc32->sgl[i].iov_len; in mrsas_passthru()
339 device_printf(sc->mrsas_dev, "IOCTL copyout failed!\n"); in mrsas_passthru()
347 if (user_ioc->sense_len) { in mrsas_passthru()
350 * buffer address in mrsas_passthru()
352 sense_ptr = (unsigned long *)((uintptr_t)user_ioc->frame.raw + in mrsas_passthru()
353 user_ioc->sense_off); in mrsas_passthru()
355 user_ioc->sense_len); in mrsas_passthru()
357 device_printf(sc->mrsas_dev, "IOCTL sense copyout failed!\n"); in mrsas_passthru()
364 memcpy(&user_ioc->frame.hdr.cmd_status, &cmd->frame->hdr.cmd_status, in mrsas_passthru()
369 * Release sense buffer in mrsas_passthru()
371 if (user_ioc->sense_len) { in mrsas_passthru()
382 for (i = 0; i < user_ioc->sge_count; i++) { in mrsas_passthru()
384 if (!user_ioc->sgl[i].iov_len) in mrsas_passthru()
388 if (!user_ioc32->sgl[i].iov_len) in mrsas_passthru()
407 * mrsas_user_command: Handle user mode DCMD and buffer
439 device_printf(sc->mrsas_dev, in mrsas_user_command()
445 * Frame is DCMD in mrsas_user_command()
447 dcmd = (struct mrsas_dcmd_frame *)cmd->frame; in mrsas_user_command()
448 memcpy(dcmd, &ioc->ioc_frame, sizeof(struct mrsas_dcmd_frame)); in mrsas_user_command()
450 ioctl_data_size = ioc->buf_size; in mrsas_user_command()
452 cmd->frame->hdr.context = cmd->index; in mrsas_user_command()
453 cmd->frame->hdr.pad_0 = 0; in mrsas_user_command()
454 cmd->frame->hdr.flags = MFI_FRAME_DIR_BOTH; in mrsas_user_command()
456 cmd->frame->hdr.flags |= MFI_FRAME_SGL64 | MFI_FRAME_SENSE64; in mrsas_user_command()
458 kern_sge = (struct mrsas_sge64 *)(&dcmd->sgl); in mrsas_user_command()
464 ioctl_temp_data_mem = malloc(ioc->buf_size, M_MRSAS, M_WAITOK); in mrsas_user_command()
467 ret = copyin(ioc->buf, ioctl_temp_data_mem, ioc->buf_size); in mrsas_user_command()
469 device_printf(sc->mrsas_dev, "IOCTL copyin failed!\n"); in mrsas_user_command()
479 passcmd->complete = 0; in mrsas_user_command()
480 passcmd->sc = sc; in mrsas_user_command()
481 passcmd->cmd = cmd; in mrsas_user_command()
482 passcmd->kern_sge = kern_sge; in mrsas_user_command()
487 if (bus_dma_tag_create(sc->mrsas_parent_tag, /* parent */ in mrsas_user_command()
497 &sc->ioctl_lock, /* lockarg */ in mrsas_user_command()
499 device_printf(sc->mrsas_dev, in mrsas_user_command()
501 ioc->buf_size); in mrsas_user_command()
508 device_printf(sc->mrsas_dev, "Cannot create ioctl " in mrsas_user_command()
514 passcmd->ioctl_data_tag = ioctl_data_tag; in mrsas_user_command()
515 passcmd->ioctl_data_dmamap = ioctl_data_dmamap; in mrsas_user_command()
517 /* Map data buffer into bus space */ in mrsas_user_command()
519 ioctl_temp_data_mem, ioc->buf_size, mrsas_passthru_load_cb, in mrsas_user_command()
521 device_printf(sc->mrsas_dev, "Cannot load ioctl " in mrsas_user_command()
522 "passthru data mem%s %d\n", curproc->p_comm, ioctl_data_size); in mrsas_user_command()
527 while (passcmd->complete == 0) { in mrsas_user_command()
531 cmd->frame->dcmd.sge_count = passcmd->sge_count; in mrsas_user_command()
536 * cmd to the SCSI mid-layer in mrsas_user_command()
538 cmd->sync_cmd = 1; in mrsas_user_command()
540 cmd->sync_cmd = 0; in mrsas_user_command()
548 ret = copyout(ioctl_temp_data_mem, ioc->buf, ioc->buf_size); in mrsas_user_command()
550 device_printf(sc->mrsas_dev, in mrsas_user_command()
559 memcpy(&ioc->ioc_frame.cmd_status, &cmd->frame->hdr.cmd_status, in mrsas_user_command()
592 * local data structure called mrsas_mfi_cmd. The frame embedded in this
607 * sc->mfi_cmd_list is an array of struct mrsas_mfi_cmd pointers. in mrsas_alloc_mfi_cmds()
611 sc->mfi_cmd_list = malloc(sizeof(struct mrsas_mfi_cmd *) * max_cmd, M_MRSAS, M_NOWAIT); in mrsas_alloc_mfi_cmds()
612 if (!sc->mfi_cmd_list) { in mrsas_alloc_mfi_cmds()
613 device_printf(sc->mrsas_dev, "Cannot alloc memory for mfi_cmd cmd_list.\n"); in mrsas_alloc_mfi_cmds()
616 memset(sc->mfi_cmd_list, 0, sizeof(struct mrsas_mfi_cmd *) * max_cmd); in mrsas_alloc_mfi_cmds()
618 sc->mfi_cmd_list[i] = malloc(sizeof(struct mrsas_mfi_cmd), in mrsas_alloc_mfi_cmds()
620 if (!sc->mfi_cmd_list[i]) { in mrsas_alloc_mfi_cmds()
622 free(sc->mfi_cmd_list[j], M_MRSAS); in mrsas_alloc_mfi_cmds()
623 free(sc->mfi_cmd_list, M_MRSAS); in mrsas_alloc_mfi_cmds()
624 sc->mfi_cmd_list = NULL; in mrsas_alloc_mfi_cmds()
630 cmd = sc->mfi_cmd_list[i]; in mrsas_alloc_mfi_cmds()
632 cmd->index = i; in mrsas_alloc_mfi_cmds()
633 cmd->ccb_ptr = NULL; in mrsas_alloc_mfi_cmds()
634 cmd->sc = sc; in mrsas_alloc_mfi_cmds()
635 TAILQ_INSERT_TAIL(&(sc->mrsas_mfi_cmd_list_head), cmd, next); in mrsas_alloc_mfi_cmds()
638 /* create a frame pool and assign one frame to each command */ in mrsas_alloc_mfi_cmds()
640 device_printf(sc->mrsas_dev, "Cannot allocate DMA frame pool.\n"); in mrsas_alloc_mfi_cmds()
643 cmd = sc->mfi_cmd_list[i]; in mrsas_alloc_mfi_cmds()
646 if (sc->mficmd_frame_tag != NULL) in mrsas_alloc_mfi_cmds()
647 bus_dma_tag_destroy(sc->mficmd_frame_tag); in mrsas_alloc_mfi_cmds()
657 * Each command packet has an embedded DMA memory buffer that is used for
658 * filling MFI frame and the SG list that immediately follows the frame. This
669 if (bus_dma_tag_create(sc->mrsas_parent_tag, in mrsas_create_frame_pool()
679 &sc->mficmd_frame_tag)) { in mrsas_create_frame_pool()
680 device_printf(sc->mrsas_dev, "Cannot create MFI frame tag\n"); in mrsas_create_frame_pool()
684 cmd = sc->mfi_cmd_list[i]; in mrsas_create_frame_pool()
685 cmd->frame = mrsas_alloc_frame(sc, cmd); in mrsas_create_frame_pool()
686 if (cmd->frame == NULL) { in mrsas_create_frame_pool()
687 device_printf(sc->mrsas_dev, "Cannot alloc MFI frame memory\n"); in mrsas_create_frame_pool()
694 * Totl 960 byte (15 MFI frame of 64 byte) in mrsas_create_frame_pool()
696 * Fusion adapter require only 3 extra frame. in mrsas_create_frame_pool()
699 * Total 192 byte (3 MFI frame of 64 byte) in mrsas_create_frame_pool()
701 memset(cmd->frame, 0, MRSAS_MFI_FRAME_SIZE); in mrsas_create_frame_pool()
702 cmd->frame->io.context = cmd->index; in mrsas_create_frame_pool()
703 cmd->frame->io.pad_0 = 0; in mrsas_create_frame_pool()
721 if (bus_dmamem_alloc(sc->mficmd_frame_tag, (void **)&cmd->frame_mem, in mrsas_alloc_frame()
722 BUS_DMA_NOWAIT, &cmd->frame_dmamap)) { in mrsas_alloc_frame()
723 device_printf(sc->mrsas_dev, "Cannot alloc MFI frame memory\n"); in mrsas_alloc_frame()
726 if (bus_dmamap_load(sc->mficmd_frame_tag, cmd->frame_dmamap, in mrsas_alloc_frame()
727 cmd->frame_mem, frame_size, mrsas_alloc_cb, in mrsas_alloc_frame()
728 &cmd->frame_phys_addr, BUS_DMA_NOWAIT)) { in mrsas_alloc_frame()
729 device_printf(sc->mrsas_dev, "Cannot load IO request memory\n"); in mrsas_alloc_frame()
732 return (cmd->frame_mem); in mrsas_alloc_frame()
761 * and error case during creation of frame pool.
766 if (cmd->frame_phys_addr) in mrsas_free_frame()
767 bus_dmamap_unload(sc->mficmd_frame_tag, cmd->frame_dmamap); in mrsas_free_frame()
768 if (cmd->frame_mem != NULL) in mrsas_free_frame()
769 bus_dmamem_free(sc->mficmd_frame_tag, cmd->frame_mem, cmd->frame_dmamap); in mrsas_free_frame()