37#include <sys/kernel.h>
40#include <sys/devicestat.h>
41#include <sys/malloc.h>
76#define ccb_state ppriv_field0
77#define ccb_bp ppriv_ptr1
93static void ptasync(
void *callback_arg, u_int32_t code,
100 union ccb *done_ccb);
103 u_int32_t sense_flags);
107 u_int tag_action,
int readop, u_int byte2,
108 u_int32_t xfer_len, u_int8_t *data_ptr,
109 u_int8_t sense_len, u_int32_t timeout);
114 TAILQ_HEAD_INITIALIZER(
ptdriver.units), 0
120 .d_version = D_VERSION,
125 .d_write = physwrite,
131#ifndef SCSI_PT_DEFAULT_TIMEOUT
132#define SCSI_PT_DEFAULT_TIMEOUT 60
136ptopen(
struct cdev *dev,
int flags,
int fmt,
struct thread *td)
163 (
"ptopen: dev=%s\n", devtoname(dev)));
170ptclose(
struct cdev *dev,
int flag,
int fmt,
struct thread *td)
180 softc->flags &= ~PT_FLAG_OPEN;
197 periph = (
struct cam_periph *)bp->bio_dev->si_drv1;
198 bp->bio_resid = bp->bio_bcount;
199 if (periph == NULL) {
200 biofinish(bp, NULL, ENXIO);
211 biofinish(bp, NULL, ENXIO);
241 printf(
"pt: Failed to attach master async callback "
242 "due to status 0x%x!\n", status);
252 struct make_dev_args args;
257 printf(
"ptregister: no getdev CCB, can't register device\n");
261 softc = (
struct pt_softc *)malloc(
sizeof(*softc),M_DEVBUF,M_NOWAIT);
264 printf(
"daregister: Unable to probe new device. "
265 "Unable to allocate softc\n");
269 bzero(softc,
sizeof(*softc));
270 LIST_INIT(&softc->pending_ccbs);
276 periph->
softc = softc;
282 make_dev_args_init(&args);
285 args.mda_uid = UID_ROOT;
286 args.mda_gid = GID_OPERATOR;
287 args.mda_mode = 0600;
288 args.mda_si_drv1 = periph;
289 error = make_dev_s(&args, &softc->dev,
"%s%d", periph->
periph_name,
298 DEVSTAT_NO_BLOCKSIZE,
301 DEVSTAT_PRIORITY_OTHER);
341 bioq_flush(&softc->
bio_queue, NULL, ENXIO);
353 destroy_dev(softc->dev);
355 free(softc, M_DEVBUF);
393 printf(
"ptasync: Unable to attach to new device "
394 "due to status 0x%x\n", status);
409 LIST_FOREACH(ccbh, &softc->pending_ccbs, periph_links.le)
444 bp->bio_cmd == BIO_READ,
457 LIST_INSERT_HEAD(&softc->pending_ccbs, &start_ccb->
ccb_h,
460 start_ccb->
ccb_h.ccb_bp = bp;
482 csio = &done_ccb->
csio;
483 switch (csio->
ccb_h.ccb_state) {
489 bp = (
struct bio *)done_ccb->
ccb_h.ccb_bp;
500 if (error == ERESTART) {
508 if (error == ENXIO) {
514 "Invalidating device\n");
523 bioq_flush(&softc->
bio_queue, NULL, EIO);
524 bp->bio_error = error;
525 bp->bio_resid = bp->bio_bcount;
526 bp->bio_flags |= BIO_ERROR;
528 bp->bio_resid = csio->
resid;
530 if (bp->bio_resid != 0) {
532 bp->bio_flags |= BIO_ERROR;
542 bp->bio_resid = csio->
resid;
543 if (bp->bio_resid != 0)
544 bp->bio_flags |= BIO_ERROR;
551 LIST_REMOVE(&done_ccb->
ccb_h, periph_links.le);
568ptioctl(
struct cdev *dev, u_long cmd, caddr_t addr,
int flag,
struct thread *td)
580 case PTIOCGETTIMEOUT:
581 if (
softc->io_timeout >= 1000)
582 *(
int *)addr =
softc->io_timeout / 1000;
586 case PTIOCSETTIMEOUT:
587 if (*(
int *)addr < 1) {
592 softc->io_timeout = *(
int *)addr * 1000;
608 u_int tag_action,
int readop, u_int byte2,
609 u_int32_t xfer_len, u_int8_t *data_ptr, u_int8_t sense_len,
#define CAM_PRIORITY_NORMAL
static __BEGIN_DECLS __inline void cam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries, void(*cbfcnp)(struct cam_periph *, union ccb *), u_int32_t flags, u_int8_t tag_action, u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len, u_int8_t cdb_len, u_int32_t timeout)
#define XPORT_DEVSTAT_TYPE(t)
#define CAM_DEBUG(path, flag, printfargs)
void cam_periph_release_locked(struct cam_periph *periph)
u_int32_t cam_release_devq(struct cam_path *path, u_int32_t relsim_flags, u_int32_t openings, u_int32_t arg, int getcount_only)
int cam_periph_acquire(struct cam_periph *periph)
void cam_periph_async(struct cam_periph *periph, u_int32_t code, struct cam_path *path, void *arg)
void cam_periph_release(struct cam_periph *periph)
int cam_periph_error(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags)
int cam_periph_ioctl(struct cam_periph *periph, u_long cmd, caddr_t addr, int(*error_routine)(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags))
cam_status cam_periph_alloc(periph_ctor_t *periph_ctor, periph_oninv_t *periph_oninvalidate, periph_dtor_t *periph_dtor, periph_start_t *periph_start, char *name, cam_periph_type type, struct cam_path *path, ac_callback_t *ac_callback, ac_code code, void *arg)
cam_status periph_ctor_t(struct cam_periph *periph, void *arg)
void periph_oninv_t(struct cam_periph *periph)
#define cam_periph_lock(periph)
#define cam_periph_unlock(periph)
void periph_dtor_t(struct cam_periph *periph)
void periph_start_t(struct cam_periph *periph, union ccb *start_ccb)
void() periph_init_t(void)
LIST_HEAD(ccb_hdr_list, ccb_hdr)
void xpt_schedule(struct cam_periph *periph, u_int32_t new_priority)
void xpt_print(struct cam_path *path, const char *fmt,...)
void xpt_announce_periph(struct cam_periph *periph, char *announce_string)
void xpt_action(union ccb *start_ccb)
cam_status xpt_register_async(int event, ac_callback_t *cbfunc, void *cbarg, struct cam_path *path)
void xpt_release_ccb(union ccb *free_ccb)
static void xpt_path_inq(struct ccb_pathinq *cpi, struct cam_path *path)
#define SID_QUAL_LU_CONNECTED
#define SID_TYPE(inq_data)
#define SID_QUAL(inq_data)
static __inline void scsi_ulto3b(u_int32_t val, u_int8_t *bytes)
static periph_ctor_t ptctor
void scsi_send_receive(struct ccb_scsiio *csio, u_int32_t retries, void(*cbfcnp)(struct cam_periph *, union ccb *), u_int tag_action, int readop, u_int byte2, u_int32_t xfer_len, u_int8_t *data_ptr, u_int8_t sense_len, u_int32_t timeout)
static int pterror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
static void ptdone(struct cam_periph *periph, union ccb *done_ccb)
static struct periph_driver ptdriver
static periph_oninv_t ptoninvalidate
static periph_start_t ptstart
static periph_init_t ptinit
static struct cdevsw pt_cdevsw
#define SCSI_PT_DEFAULT_TIMEOUT
PERIPHDRIVER_DECLARE(pt, ptdriver)
static d_strategy_t ptstrategy
static periph_dtor_t ptdtor
static void ptasync(void *callback_arg, u_int32_t code, struct cam_path *path, void *arg)
struct scsi_inquiry_data inq_data
struct devstat * device_stats
struct bio_queue_head bio_queue
u_int8_t cdb_bytes[IOCDBLEN]