summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormjacob <mjacob@FreeBSD.org>2002-06-04 17:41:47 +0000
committermjacob <mjacob@FreeBSD.org>2002-06-04 17:41:47 +0000
commit845c7be0e802934c939612825c8534aad41c0bf9 (patch)
treedfa81096fe42c31fd66eed86d365b1c9f130dc21 /sys
parent64e4db86986a7cd56a202b1bcee6847dc6ac9d46 (diff)
downloadFreeBSD-src-845c7be0e802934c939612825c8534aad41c0bf9.zip
FreeBSD-src-845c7be0e802934c939612825c8534aad41c0bf9.tar.gz
Add REPORT LUNS basic infrastructure.
Diffstat (limited to 'sys')
-rw-r--r--sys/cam/scsi/scsi_all.c54
-rw-r--r--sys/cam/scsi/scsi_all.h43
2 files changed, 77 insertions, 20 deletions
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c
index df23ff9..d2c8fbb 100644
--- a/sys/cam/scsi/scsi_all.c
+++ b/sys/cam/scsi/scsi_all.c
@@ -2582,6 +2582,34 @@ scsi_log_select(struct ccb_scsiio *csio, u_int32_t retries,
timeout);
}
+/*
+ * Prevent or allow the user to remove the media
+ */
+void
+scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries,
+ void (*cbfcnp)(struct cam_periph *, union ccb *),
+ u_int8_t tag_action, u_int8_t action,
+ u_int8_t sense_len, u_int32_t timeout)
+{
+ struct scsi_prevent *scsi_cmd;
+
+ cam_fill_csio(csio,
+ retries,
+ cbfcnp,
+ /*flags*/CAM_DIR_NONE,
+ tag_action,
+ /*data_ptr*/NULL,
+ /*dxfer_len*/0,
+ sense_len,
+ sizeof(*scsi_cmd),
+ timeout);
+
+ scsi_cmd = (struct scsi_prevent *)&csio->cdb_io.cdb_bytes;
+ bzero(scsi_cmd, sizeof(*scsi_cmd));
+ scsi_cmd->opcode = PREVENT_ALLOW;
+ scsi_cmd->how = action;
+}
+
/* XXX allow specification of address and PMI bit and LBA */
void
scsi_read_capacity(struct ccb_scsiio *csio, u_int32_t retries,
@@ -2608,32 +2636,28 @@ scsi_read_capacity(struct ccb_scsiio *csio, u_int32_t retries,
scsi_cmd->opcode = READ_CAPACITY;
}
-/*
- * Prevent or allow the user to remove the media
- */
void
-scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries,
- void (*cbfcnp)(struct cam_periph *, union ccb *),
- u_int8_t tag_action, u_int8_t action,
- u_int8_t sense_len, u_int32_t timeout)
+scsi_report_luns(struct ccb_scsiio *csio, u_int32_t retries,
+ void (*cbfcnp)(struct cam_periph *, union ccb *),
+ u_int8_t tag_action, struct scsi_report_luns_data *rpl_buf,
+ u_int32_t alloc_len, u_int8_t sense_len, u_int32_t timeout)
{
- struct scsi_prevent *scsi_cmd;
+ struct scsi_report_luns *scsi_cmd;
cam_fill_csio(csio,
retries,
cbfcnp,
- /*flags*/CAM_DIR_NONE,
+ /*flags*/CAM_DIR_IN,
tag_action,
- /*data_ptr*/NULL,
- /*dxfer_len*/0,
+ /*data_ptr*/(u_int8_t *)rpl_buf,
+ /*dxfer_len*/alloc_len,
sense_len,
sizeof(*scsi_cmd),
timeout);
-
- scsi_cmd = (struct scsi_prevent *)&csio->cdb_io.cdb_bytes;
+ scsi_cmd = (struct scsi_report_luns *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
- scsi_cmd->opcode = PREVENT_ALLOW;
- scsi_cmd->how = action;
+ scsi_cmd->opcode = REPORT_LUNS;
+ scsi_ulto4b(alloc_len, scsi_cmd->addr);
}
/*
diff --git a/sys/cam/scsi/scsi_all.h b/sys/cam/scsi/scsi_all.h
index 6a873f09..9c5993b 100644
--- a/sys/cam/scsi/scsi_all.h
+++ b/sys/cam/scsi/scsi_all.h
@@ -505,6 +505,7 @@ struct scsi_start_stop_unit
#define LOG_SENSE 0x4d
#define MODE_SELECT_10 0x55
#define MODE_SENSE_10 0x5A
+#define REPORT_LUNS 0xA0
#define MOVE_MEDIUM 0xa5
#define READ_12 0xa8
#define WRITE_12 0xaa
@@ -675,6 +676,29 @@ struct scsi_read_capacity_data
u_int8_t length[4];
};
+struct scsi_report_luns
+{
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[3];
+ u_int8_t addr[4];
+ u_int8_t control;
+};
+
+struct scsi_report_luns_data {
+ u_int8_t length[4]; /* length of LUN inventory, in bytes */
+ u_int8_t reserved[4]; /* unused */
+ /*
+ * LUN inventory- we only support the type zero form for now.
+ */
+ struct {
+ u_int8_t lundata[8];
+ } luns[1];
+};
+#define RPL_LUNDATA_ATYP_MASK 0xc0 /* MBZ for type 0 lun */
+#define RPL_LUNDATA_T0LUN 1 /* @ lundata[1] */
+
+
struct scsi_sense_data
{
u_int8_t error_code;
@@ -753,6 +777,8 @@ struct scsi_mode_blk_desc
#define SCSI_DEFAULT_DENSITY 0x00 /* use 'default' density */
#define SCSI_SAME_DENSITY 0x7f /* use 'same' density- >= SCSI-2 only */
+
+
/*
* Status Byte
*/
@@ -943,16 +969,23 @@ void scsi_log_select(struct ccb_scsiio *csio, u_int32_t retries,
u_int32_t param_len, u_int8_t sense_len,
u_int32_t timeout);
+void scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries,
+ void (*cbfcnp)(struct cam_periph *, union ccb *),
+ u_int8_t tag_action, u_int8_t action,
+ u_int8_t sense_len, u_int32_t timeout);
+
void scsi_read_capacity(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *,
union ccb *), u_int8_t tag_action,
- struct scsi_read_capacity_data *rcap_buf,
+ struct scsi_read_capacity_data *,
u_int8_t sense_len, u_int32_t timeout);
-void scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries,
- void (*cbfcnp)(struct cam_periph *, union ccb *),
- u_int8_t tag_action, u_int8_t action,
- u_int8_t sense_len, u_int32_t timeout);
+void scsi_report_luns(struct ccb_scsiio *csio, u_int32_t retries,
+ void (*cbfcnp)(struct cam_periph *,
+ union ccb *), u_int8_t tag_action,
+ struct scsi_report_luns_data *,
+ u_int32_t alloc_len, u_int8_t sense_len,
+ u_int32_t timeout);
void scsi_synchronize_cache(struct ccb_scsiio *csio,
u_int32_t retries,
OpenPOWER on IntegriCloud