scsi_target.c (109345) | scsi_target.c (109623) |
---|---|
1/* 2 * Generic SCSI Target Kernel Mode Driver 3 * 4 * Copyright (c) 2002 Nate Lawson. 5 * Copyright (c) 1998, 1999, 2001, 2002 Justin T. Gibbs. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/* 2 * Generic SCSI Target Kernel Mode Driver 3 * 4 * Copyright (c) 2002 Nate Lawson. 5 * Copyright (c) 1998, 1999, 2001, 2002 Justin T. Gibbs. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/cam/scsi/scsi_target.c 109345 2003-01-16 00:24:29Z njl $ | 29 * $FreeBSD: head/sys/cam/scsi/scsi_target.c 109623 2003-01-21 08:56:16Z alfred $ |
30 */ 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/conf.h> 36#include <sys/malloc.h> 37#include <sys/poll.h> --- 146 unchanged lines hidden (view full) --- 184 mtx_unlock(&targ_mtx); 185 186 /* Create the targ device, allocate its softc, initialize it */ 187 if ((dev->si_flags & SI_NAMED) == 0) { 188 make_dev(&targ_cdevsw, minor(dev), UID_ROOT, GID_WHEEL, 0600, 189 "targ%d", dev2unit(dev)); 190 } 191 MALLOC(softc, struct targ_softc *, sizeof(*softc), M_TARG, | 30 */ 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/conf.h> 36#include <sys/malloc.h> 37#include <sys/poll.h> --- 146 unchanged lines hidden (view full) --- 184 mtx_unlock(&targ_mtx); 185 186 /* Create the targ device, allocate its softc, initialize it */ 187 if ((dev->si_flags & SI_NAMED) == 0) { 188 make_dev(&targ_cdevsw, minor(dev), UID_ROOT, GID_WHEEL, 0600, 189 "targ%d", dev2unit(dev)); 190 } 191 MALLOC(softc, struct targ_softc *, sizeof(*softc), M_TARG, |
192 M_WAITOK | M_ZERO); | 192 M_ZERO); |
193 dev->si_drv1 = softc; 194 softc->state = TARG_STATE_OPENED; 195 softc->periph = NULL; 196 softc->path = NULL; 197 mtx_init(&softc->mtx, devtoname(dev), "targ cdev", MTX_DEF); 198 199 TAILQ_INIT(&softc->pending_ccb_queue); 200 TAILQ_INIT(&softc->work_queue); --- 771 unchanged lines hidden (view full) --- 972 973static union ccb * 974targgetccb(struct targ_softc *softc, xpt_opcode type, int priority) 975{ 976 union ccb *ccb; 977 int ccb_len; 978 979 ccb_len = targccblen(type); | 193 dev->si_drv1 = softc; 194 softc->state = TARG_STATE_OPENED; 195 softc->periph = NULL; 196 softc->path = NULL; 197 mtx_init(&softc->mtx, devtoname(dev), "targ cdev", MTX_DEF); 198 199 TAILQ_INIT(&softc->pending_ccb_queue); 200 TAILQ_INIT(&softc->work_queue); --- 771 unchanged lines hidden (view full) --- 972 973static union ccb * 974targgetccb(struct targ_softc *softc, xpt_opcode type, int priority) 975{ 976 union ccb *ccb; 977 int ccb_len; 978 979 ccb_len = targccblen(type); |
980 MALLOC(ccb, union ccb *, ccb_len, M_TARG, M_WAITOK); | 980 MALLOC(ccb, union ccb *, ccb_len, M_TARG, 0); |
981 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("getccb %p\n", ccb)); 982 983 xpt_setup_ccb(&ccb->ccb_h, softc->path, priority); 984 ccb->ccb_h.func_code = type; 985 ccb->ccb_h.cbfcnp = targdone; 986 ccb->ccb_h.targ_descr = targgetdescr(softc); 987 return (ccb); 988} --- 27 unchanged lines hidden (view full) --- 1016} 1017 1018static struct targ_cmd_descr * 1019targgetdescr(struct targ_softc *softc) 1020{ 1021 struct targ_cmd_descr *descr; 1022 1023 MALLOC(descr, struct targ_cmd_descr *, sizeof(*descr), M_TARG, | 981 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("getccb %p\n", ccb)); 982 983 xpt_setup_ccb(&ccb->ccb_h, softc->path, priority); 984 ccb->ccb_h.func_code = type; 985 ccb->ccb_h.cbfcnp = targdone; 986 ccb->ccb_h.targ_descr = targgetdescr(softc); 987 return (ccb); 988} --- 27 unchanged lines hidden (view full) --- 1016} 1017 1018static struct targ_cmd_descr * 1019targgetdescr(struct targ_softc *softc) 1020{ 1021 struct targ_cmd_descr *descr; 1022 1023 MALLOC(descr, struct targ_cmd_descr *, sizeof(*descr), M_TARG, |
1024 M_WAITOK); | 1024 0); |
1025 descr->mapinfo.num_bufs_used = 0; 1026 return (descr); 1027} 1028 1029static void 1030targinit(void) 1031{ 1032 mtx_init(&targ_mtx, "targ global", NULL, MTX_DEF); --- 164 unchanged lines hidden --- | 1025 descr->mapinfo.num_bufs_used = 0; 1026 return (descr); 1027} 1028 1029static void 1030targinit(void) 1031{ 1032 mtx_init(&targ_mtx, "targ global", NULL, MTX_DEF); --- 164 unchanged lines hidden --- |