scsi_ctl.c (275032) | scsi_ctl.c (275058) |
---|---|
1/*- 2 * Copyright (c) 2008, 2009 Silicon Graphics International Corp. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 */ 32/* 33 * Peripheral driver interface between CAM and CTL (CAM Target Layer). 34 * 35 * Author: Ken Merry <ken@FreeBSD.org> 36 */ 37 38#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2008, 2009 Silicon Graphics International Corp. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 */ 32/* 33 * Peripheral driver interface between CAM and CTL (CAM Target Layer). 34 * 35 * Author: Ken Merry <ken@FreeBSD.org> 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/sys/cam/ctl/scsi_ctl.c 275032 2014-11-25 12:22:29Z mav $"); | 39__FBSDID("$FreeBSD: head/sys/cam/ctl/scsi_ctl.c 275058 2014-11-25 17:53:35Z mav $"); |
40 41#include <sys/param.h> 42#include <sys/queue.h> 43#include <sys/systm.h> 44#include <sys/kernel.h> 45#include <sys/lock.h> 46#include <sys/mutex.h> 47#include <sys/condvar.h> --- 739 unchanged lines hidden (view full) --- 787 /* Take the ATIO off the work queue */ 788 TAILQ_REMOVE(&softc->work_queue, ccb_h, periph_links.tqe); 789 atio = (struct ccb_accept_tio *)ccb_h; 790 io = (union ctl_io *)ccb_h->io_ptr; 791 csio = &start_ccb->csio; 792 793 flags = atio->ccb_h.flags & 794 (CAM_DIS_DISCONNECT|CAM_TAG_ACTION_VALID|CAM_DIR_MASK); | 40 41#include <sys/param.h> 42#include <sys/queue.h> 43#include <sys/systm.h> 44#include <sys/kernel.h> 45#include <sys/lock.h> 46#include <sys/mutex.h> 47#include <sys/condvar.h> --- 739 unchanged lines hidden (view full) --- 787 /* Take the ATIO off the work queue */ 788 TAILQ_REMOVE(&softc->work_queue, ccb_h, periph_links.tqe); 789 atio = (struct ccb_accept_tio *)ccb_h; 790 io = (union ctl_io *)ccb_h->io_ptr; 791 csio = &start_ccb->csio; 792 793 flags = atio->ccb_h.flags & 794 (CAM_DIS_DISCONNECT|CAM_TAG_ACTION_VALID|CAM_DIR_MASK); |
795 cmd_info = (struct ctlfe_lun_cmd_info *)io->io_hdr.port_priv; 796 cmd_info->cur_transfer_index = 0; 797 cmd_info->cur_transfer_off = 0; 798 cmd_info->flags = 0; |
|
795 796 if (io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) { 797 /* 798 * Datamove call, we need to setup the S/G list. 799 */ | 799 800 if (io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) { 801 /* 802 * Datamove call, we need to setup the S/G list. 803 */ |
800 cmd_info = (struct ctlfe_lun_cmd_info *) 801 io->io_hdr.port_priv; 802 bzero(cmd_info, sizeof(*cmd_info)); | |
803 scsi_status = 0; 804 csio->cdb_len = atio->cdb_len; 805 ctlfedata(softc, io, &flags, &data_ptr, &dxfer_len, 806 &csio->sglist_cnt); 807 io->scsiio.ext_data_filled += dxfer_len; 808 if (io->scsiio.ext_data_filled > io->scsiio.kern_total_len) { 809 xpt_print(periph->path, "%s: tag 0x%04x " 810 "fill len %u > total %u\n", --- 64 unchanged lines hidden (view full) --- 875 * If we still have work to do, ask for 876 * another CCB. Otherwise, deactivate our 877 * callout. 878 */ 879 if (!TAILQ_EMPTY(&softc->work_queue)) 880 xpt_schedule(periph, /*priority*/ 1); 881 return; 882 } | 804 scsi_status = 0; 805 csio->cdb_len = atio->cdb_len; 806 ctlfedata(softc, io, &flags, &data_ptr, &dxfer_len, 807 &csio->sglist_cnt); 808 io->scsiio.ext_data_filled += dxfer_len; 809 if (io->scsiio.ext_data_filled > io->scsiio.kern_total_len) { 810 xpt_print(periph->path, "%s: tag 0x%04x " 811 "fill len %u > total %u\n", --- 64 unchanged lines hidden (view full) --- 876 * If we still have work to do, ask for 877 * another CCB. Otherwise, deactivate our 878 * callout. 879 */ 880 if (!TAILQ_EMPTY(&softc->work_queue)) 881 xpt_schedule(periph, /*priority*/ 1); 882 return; 883 } |
883 | 884 data_ptr = NULL; 885 dxfer_len = 0; 886 csio->sglist_cnt = 0; 887 scsi_status = 0; 888 } 889 if ((io->io_hdr.flags & CTL_FLAG_STATUS_QUEUED) && 890 (cmd_info->flags & CTLFE_CMD_PIECEWISE) == 0 && 891 ((io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) == 0 || 892 io->io_hdr.status == CTL_SUCCESS)) { 893 io->io_hdr.flags |= CTL_FLAG_STATUS_SENT; |
884 flags |= CAM_SEND_STATUS; 885 scsi_status = io->scsiio.scsi_status; 886 csio->sense_len = io->scsiio.sense_len; | 894 flags |= CAM_SEND_STATUS; 895 scsi_status = io->scsiio.scsi_status; 896 csio->sense_len = io->scsiio.sense_len; |
887 data_ptr = NULL; 888 dxfer_len = 0; | |
889#ifdef CTLFEDEBUG 890 printf("%s: tag %04x status %x\n", __func__, 891 atio->tag_id, io->io_hdr.status); 892#endif | 897#ifdef CTLFEDEBUG 898 printf("%s: tag %04x status %x\n", __func__, 899 atio->tag_id, io->io_hdr.status); 900#endif |
893 csio->sglist_cnt = 0; | |
894 if (csio->sense_len != 0) { 895 csio->sense_data = io->scsiio.sense_data; 896 flags |= CAM_SEND_SENSE; 897 } else if (scsi_status == SCSI_STATUS_CHECK_COND) { 898 xpt_print(periph->path, "%s: check condition " 899 "with no sense\n", __func__); 900 } 901 } --- 1135 unchanged lines hidden (view full) --- 2037 ccb->cin1.tag_id, ccb->cin1.seq_id); 2038 /* 2039 * Send the notify acknowledge down to the SIM, to let it 2040 * know we processed the task management command. 2041 */ 2042 ccb->ccb_h.status = CAM_REQ_INPROG; 2043 ccb->ccb_h.func_code = XPT_NOTIFY_ACKNOWLEDGE; 2044 xpt_action(ccb); | 901 if (csio->sense_len != 0) { 902 csio->sense_data = io->scsiio.sense_data; 903 flags |= CAM_SEND_SENSE; 904 } else if (scsi_status == SCSI_STATUS_CHECK_COND) { 905 xpt_print(periph->path, "%s: check condition " 906 "with no sense\n", __func__); 907 } 908 } --- 1135 unchanged lines hidden (view full) --- 2044 ccb->cin1.tag_id, ccb->cin1.seq_id); 2045 /* 2046 * Send the notify acknowledge down to the SIM, to let it 2047 * know we processed the task management command. 2048 */ 2049 ccb->ccb_h.status = CAM_REQ_INPROG; 2050 ccb->ccb_h.func_code = XPT_NOTIFY_ACKNOWLEDGE; 2051 xpt_action(ccb); |
2052 } else if (io->io_hdr.flags & CTL_FLAG_STATUS_SENT) { 2053 if (softc->flags & CTLFE_LUN_WILDCARD) { 2054 ccb->ccb_h.target_id = CAM_TARGET_WILDCARD; 2055 ccb->ccb_h.target_lun = CAM_LUN_WILDCARD; 2056 } 2057 if (periph->flags & CAM_PERIPH_INVALID) { 2058 ctlfe_free_ccb(periph, ccb); 2059 } else { 2060 softc->atios_sent++; 2061 cam_periph_unlock(periph); 2062 xpt_action(ccb); 2063 return; 2064 } |
|
2045 } else { 2046 io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED; 2047 TAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, 2048 periph_links.tqe); 2049 xpt_schedule(periph, /*priority*/ 1); 2050 } 2051 2052 cam_periph_unlock(periph); --- 14 unchanged lines hidden --- | 2065 } else { 2066 io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED; 2067 TAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, 2068 periph_links.tqe); 2069 xpt_schedule(periph, /*priority*/ 1); 2070 } 2071 2072 cam_periph_unlock(periph); --- 14 unchanged lines hidden --- |