37#include <sys/kernel.h>
41#include <sys/devicestat.h>
42#include <sys/malloc.h>
74#define MAX_IMMEDIATE 16
75#define MAX_BUF_SIZE 256
78#define ccb_type ppriv_field0
79#define ccb_descr ppriv_ptr1
82#define ccb_atio ppriv_ptr1
132static void targbhasync(
void *callback_arg, u_int32_t code,
140 union ccb *done_ccb);
143 u_int32_t sense_flags);
169 printf(
"targbh: Failed to attach master async callback "
170 "due to status 0x%x!\n", status);
196 printf(
"targbhasync: Unable to create path "
197 "due to status 0x%x\n", status);
244 memset(&immed_ccb, 0,
sizeof(immed_ccb));
256 "targbhenlun - Enable Lun Rejected with status 0x%x\n",
279 if (atio->
ccb_h.ccb_descr == NULL) {
280 free(atio, M_SCSIBH);
299 "targbhenlun - Could not allocate accept tio CCBs: status "
313 M_SCSIBH, M_ZERO | M_NOWAIT);
333 "targbhenlun - Could not allocate immediate notify "
334 "CCBs: status = 0x%x\n", status);
354 memset(&
ccb, 0,
sizeof(
ccb));
386 printf(
"targbhdislun - Disabling lun on controller failed "
389 softc->
flags &= ~TARGBH_FLAG_LUN_ENABLED;
402 printf(
"targctor: unable to malloc softc\n");
406 bzero(softc,
sizeof(*softc));
412 periph->
softc = softc;
433 panic(
"targdtor - impossible init level");
439 free(softc, M_SCSIBH);
460 TAILQ_REMOVE(&softc->
work_queue, ccbh, periph_links.tqe);
470 csio = &start_ccb->
csio;
505 start_ccb->
ccb_h.ccb_atio = atio;
507 (
"Sending a CTIO\n"));
543 atio = &done_ccb->
atio;
564 (
"Saw an inquiry!\n"));
653 (
"Received completed CTIO\n"));
677 printf(
"Releasing Queue\n");
693 (
"Returning ATIO to target\n"));
701 free(atio, M_SCSIBH);
712 printf(
"Freed an immediate notify\n");
727 panic(
"targbhdone: Unexpected ccb opcode");
751 bzero(descr,
sizeof(*descr));
756 free(descr, M_SCSIBH);
767 free(descr, M_SCSIBH);
#define CAM_TARGET_WILDCARD
#define CAM_PRIORITY_NORMAL
static __inline void cam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries, void(*cbfcnp)(struct cam_periph *, union ccb *), u_int32_t flags, u_int tag_action, u_int tag_id, u_int init_id, u_int scsi_status, u_int8_t *data_ptr, u_int32_t dxfer_len, u_int32_t timeout)
#define CAM_DEBUG(path, flag, printfargs)
struct cam_periph * cam_periph_find(struct cam_path *path, char *name)
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)
void cam_periph_invalidate(struct cam_periph *periph)
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_dtor_t(struct cam_periph *periph)
void periph_start_t(struct cam_periph *periph, union ccb *start_ccb)
#define cam_periph_sleep(periph, chan, priority, wmesg, timo)
void() periph_init_t(void)
void xpt_schedule(struct cam_periph *periph, u_int32_t new_priority)
cam_status xpt_create_path(struct cam_path **new_path_ptr, struct cam_periph *perph, path_id_t path_id, target_id_t target_id, lun_id_t lun_id)
void xpt_print(struct cam_path *path, const char *fmt,...)
path_id_t xpt_path_path_id(struct cam_path *path)
void xpt_setup_ccb(struct ccb_hdr *ccb_h, struct cam_path *path, u_int32_t priority)
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_free_path(struct cam_path *path)
void xpt_release_ccb(union ccb *free_ccb)
void xpt_free_ccb(union ccb *free_ccb)
#define SCSI_STATUS_CHECK_COND
#define SCSI_CDB6_LEN(len)
static __inline uint32_t scsi_2btoul(const uint8_t *bytes)
#define SSD_KEY_NOT_READY
#define SSD_ERRCODE_VALID
#define SSD_CURRENT_ERROR
static periph_init_t targbhinit
TAILQ_HEAD(ccb_queue, ccb_hdr)
static cam_status targbhdislun(struct cam_periph *periph)
static struct scsi_sense_data_fixed no_lun_sense_data
PERIPHDRIVER_DECLARE(targbh, targbhdriver)
static MALLOC_DEFINE(M_SCSIBH, "SCSI bh", "SCSI blackhole buffers")
static void targbhasync(void *callback_arg, u_int32_t code, struct cam_path *path, void *arg)
static cam_status targbhenlun(struct cam_periph *periph)
static periph_start_t targbhstart
static struct targbh_cmd_desc * targbhallocdescr(void)
static void targbhdone(struct cam_periph *periph, union ccb *done_ccb)
static void targbhfreedescr(struct targbh_cmd_desc *buf)
static periph_dtor_t targbhdtor
static periph_ctor_t targbhctor
static struct scsi_inquiry_data no_lun_inq_data
@ TARGBH_FLAG_LUN_ENABLED
static const int request_sense_size
static struct periph_driver targbhdriver
struct scsi_sense_data sense_data
void(* cbfcnp)(struct cam_periph *, union ccb *)
struct scsi_sense_data sense_data
struct ccb_accept_tio * atio_link
struct ccb_queue work_queue
struct ccb_queue unknown_atio_queue
struct ccb_accept_tio * accept_tio_list
struct ccb_queue pending_queue
struct devstat device_stats
struct ccb_hdr_slist immed_notify_slist
struct ccb_accept_tio atio
u_int8_t cdb_bytes[IOCDBLEN]