scsi_targ_bh.c (164906) | scsi_targ_bh.c (168752) |
---|---|
1/*- 2 * Implementation of the Target Mode 'Black Hole device' for CAM. 3 * 4 * Copyright (c) 1999 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Implementation of the Target Mode 'Black Hole device' for CAM. 3 * 4 * Copyright (c) 1999 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_targ_bh.c 164906 2006-12-05 07:45:28Z mjacob $"); | 30__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_targ_bh.c 168752 2007-04-15 08:49:19Z scottl $"); |
31 32#include <sys/param.h> 33#include <sys/queue.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/types.h> 37#include <sys/bio.h> 38#include <sys/conf.h> 39#include <sys/devicestat.h> 40#include <sys/malloc.h> 41#include <sys/uio.h> 42 43#include <cam/cam.h> 44#include <cam/cam_ccb.h> 45#include <cam/cam_periph.h> 46#include <cam/cam_queue.h> 47#include <cam/cam_xpt_periph.h> 48#include <cam/cam_debug.h> | 31 32#include <sys/param.h> 33#include <sys/queue.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/types.h> 37#include <sys/bio.h> 38#include <sys/conf.h> 39#include <sys/devicestat.h> 40#include <sys/malloc.h> 41#include <sys/uio.h> 42 43#include <cam/cam.h> 44#include <cam/cam_ccb.h> 45#include <cam/cam_periph.h> 46#include <cam/cam_queue.h> 47#include <cam/cam_xpt_periph.h> 48#include <cam/cam_debug.h> |
49#include <cam/cam_sim.h> |
|
49 50#include <cam/scsi/scsi_all.h> 51#include <cam/scsi/scsi_message.h> 52 53MALLOC_DEFINE(M_SCSIBH, "SCSI bh", "SCSI blackhole buffers"); 54 55typedef enum { 56 TARGBH_STATE_NORMAL, --- 385 unchanged lines hidden (view full) --- 442 443 switch (softc->init_level) { 444 case 0: 445 panic("targdtor - impossible init level");; 446 case 1: 447 /* FALLTHROUGH */ 448 default: 449 /* XXX Wait for callback of targbhdislun() */ | 50 51#include <cam/scsi/scsi_all.h> 52#include <cam/scsi/scsi_message.h> 53 54MALLOC_DEFINE(M_SCSIBH, "SCSI bh", "SCSI blackhole buffers"); 55 56typedef enum { 57 TARGBH_STATE_NORMAL, --- 385 unchanged lines hidden (view full) --- 443 444 switch (softc->init_level) { 445 case 0: 446 panic("targdtor - impossible init level");; 447 case 1: 448 /* FALLTHROUGH */ 449 default: 450 /* XXX Wait for callback of targbhdislun() */ |
450 tsleep(softc, PRIBIO, "targbh", hz/2); | 451 msleep(softc, periph->sim->mtx, PRIBIO, "targbh", hz/2); |
451 free(softc, M_SCSIBH); 452 break; 453 } 454} 455 456static void 457targbhstart(struct cam_periph *periph, union ccb *start_ccb) 458{ 459 struct targbh_softc *softc; 460 struct ccb_hdr *ccbh; 461 struct ccb_accept_tio *atio; 462 struct targbh_cmd_desc *desc; 463 struct ccb_scsiio *csio; 464 ccb_flags flags; | 452 free(softc, M_SCSIBH); 453 break; 454 } 455} 456 457static void 458targbhstart(struct cam_periph *periph, union ccb *start_ccb) 459{ 460 struct targbh_softc *softc; 461 struct ccb_hdr *ccbh; 462 struct ccb_accept_tio *atio; 463 struct targbh_cmd_desc *desc; 464 struct ccb_scsiio *csio; 465 ccb_flags flags; |
465 int s; | |
466 467 softc = (struct targbh_softc *)periph->softc; 468 | 466 467 softc = (struct targbh_softc *)periph->softc; 468 |
469 s = splbio(); | |
470 ccbh = TAILQ_FIRST(&softc->work_queue); 471 if (periph->immediate_priority <= periph->pinfo.priority) { 472 start_ccb->ccb_h.ccb_type = TARGBH_CCB_WAITING; 473 SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, 474 periph_links.sle); 475 periph->immediate_priority = CAM_PRIORITY_NONE; | 469 ccbh = TAILQ_FIRST(&softc->work_queue); 470 if (periph->immediate_priority <= periph->pinfo.priority) { 471 start_ccb->ccb_h.ccb_type = TARGBH_CCB_WAITING; 472 SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, 473 periph_links.sle); 474 periph->immediate_priority = CAM_PRIORITY_NONE; |
476 splx(s); | |
477 wakeup(&periph->ccb_list); 478 } else if (ccbh == NULL) { | 475 wakeup(&periph->ccb_list); 476 } else if (ccbh == NULL) { |
479 splx(s); | |
480 xpt_release_ccb(start_ccb); 481 } else { 482 TAILQ_REMOVE(&softc->work_queue, ccbh, periph_links.tqe); 483 TAILQ_INSERT_HEAD(&softc->pending_queue, ccbh, 484 periph_links.tqe); | 477 xpt_release_ccb(start_ccb); 478 } else { 479 TAILQ_REMOVE(&softc->work_queue, ccbh, periph_links.tqe); 480 TAILQ_INSERT_HEAD(&softc->pending_queue, ccbh, 481 periph_links.tqe); |
485 splx(s); | |
486 atio = (struct ccb_accept_tio*)ccbh; 487 desc = (struct targbh_cmd_desc *)atio->ccb_h.ccb_descr; 488 489 /* Is this a tagged request? */ 490 flags = atio->ccb_h.flags & 491 (CAM_DIS_DISCONNECT|CAM_TAG_ACTION_VALID|CAM_DIR_MASK); 492 493 csio = &start_ccb->csio; --- 44 unchanged lines hidden (view full) --- 538 if ((atio->ccb_h.status & CAM_DEV_QFRZN) != 0) { 539 cam_release_devq(periph->path, 540 /*relsim_flags*/0, 541 /*reduction*/0, 542 /*timeout*/0, 543 /*getcount_only*/0); 544 atio->ccb_h.status &= ~CAM_DEV_QFRZN; 545 } | 482 atio = (struct ccb_accept_tio*)ccbh; 483 desc = (struct targbh_cmd_desc *)atio->ccb_h.ccb_descr; 484 485 /* Is this a tagged request? */ 486 flags = atio->ccb_h.flags & 487 (CAM_DIS_DISCONNECT|CAM_TAG_ACTION_VALID|CAM_DIR_MASK); 488 489 csio = &start_ccb->csio; --- 44 unchanged lines hidden (view full) --- 534 if ((atio->ccb_h.status & CAM_DEV_QFRZN) != 0) { 535 cam_release_devq(periph->path, 536 /*relsim_flags*/0, 537 /*reduction*/0, 538 /*timeout*/0, 539 /*getcount_only*/0); 540 atio->ccb_h.status &= ~CAM_DEV_QFRZN; 541 } |
546 s = splbio(); | |
547 ccbh = TAILQ_FIRST(&softc->work_queue); | 542 ccbh = TAILQ_FIRST(&softc->work_queue); |
548 splx(s); | |
549 } 550 if (ccbh != NULL) 551 xpt_schedule(periph, /*priority*/1); 552} 553 554static void 555targbhdone(struct cam_periph *periph, union ccb *done_ccb) 556{ --- 241 unchanged lines hidden --- | 543 } 544 if (ccbh != NULL) 545 xpt_schedule(periph, /*priority*/1); 546} 547 548static void 549targbhdone(struct cam_periph *periph, union ccb *done_ccb) 550{ --- 241 unchanged lines hidden --- |