2 * Copyright (c) 2010 by Panasas, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice immediately at the beginning of the file, without modification,
10 * this list of conditions, and the following disclaimer.
11 * 2. The name of the author may not be used to endorse or promote products
12 * derived from this software without specific prior written permission.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/endian.h>
35 #include <sys/kernel.h>
36 #include <sys/queue.h>
37 #include <sys/queue.h>
38 #include <sys/malloc.h>
39 #include <sys/taskqueue.h>
40 #include <sys/mutex.h>
41 #include <sys/condvar.h>
45 #include <machine/bus.h>
46 #include <machine/cpu.h>
47 #include <machine/stdarg.h>
50 #include <cam/cam_debug.h>
51 #include <cam/cam_ccb.h>
52 #include <cam/cam_sim.h>
53 #include <cam/cam_xpt.h>
54 #include <cam/cam_xpt_sim.h>
55 #include <cam/cam_debug.h>
56 #include <cam/scsi/scsi_all.h>
57 #include <cam/scsi/scsi_message.h>
60 #include <sys/unistd.h>
61 #include <sys/kthread.h>
63 #include <sys/module.h>
64 #include <sys/ioccom.h>
65 #include <sys/devicestat.h>
66 #include <cam/cam_periph.h>
67 #include <cam/cam_xpt_periph.h>
69 #define VHBA_MAXTGT 64
70 #define VHBA_MAXCMDS 256
75 struct cam_devq * devq;
76 TAILQ_HEAD(, ccb_hdr) actv;
77 TAILQ_HEAD(, ccb_hdr) done;
82 * Each different instantiation of a fake HBA needs to
83 * provide these as function entry points. It's responsible
84 * for setting up some thread or regular timeout that will
85 * dequeue things from the actv queue and put done items
88 void vhba_init(vhba_softc_t *);
89 void vhba_fini(vhba_softc_t *);
90 void vhba_kick(vhba_softc_t *);
95 void vhba_fill_sense(struct ccb_scsiio *, uint8_t, uint8_t, uint8_t);
96 int vhba_rwparm(uint8_t *, uint64_t *, uint32_t *, uint64_t, uint32_t);
97 void vhba_default_cmd(struct ccb_scsiio *, lun_id_t, uint8_t *);
98 void vhba_set_status(struct ccb_hdr *, cam_status);
101 * Common module loader function
103 int vhba_modprobe(module_t, int, void *);
109 #define MODE_SENSE 0x1a
111 #ifndef SMS_FORMAT_DEVICE_PAGE
112 #define SMS_FORMAT_DEVICE_PAGE 0x03
114 #ifndef SMS_GEOMETRY_PAGE
115 #define SMS_GEOMETRY_PAGE 0x04