summaryrefslogtreecommitdiffstats
path: root/sys/sys/chio.h
diff options
context:
space:
mode:
authorken <ken@FreeBSD.org>2013-04-19 20:03:51 +0000
committerken <ken@FreeBSD.org>2013-04-19 20:03:51 +0000
commit9a543047eb5c6caa745ab785627c29aa050f3fe6 (patch)
treea42129446c56829e1277cb13ece82f7720559ea6 /sys/sys/chio.h
parent120125784a1ca698c656c6ef5e21e219df994f64 (diff)
downloadFreeBSD-src-9a543047eb5c6caa745ab785627c29aa050f3fe6.zip
FreeBSD-src-9a543047eb5c6caa745ab785627c29aa050f3fe6.tar.gz
Update chio(1) and ch(4) to support reporting element designators.
This allows mapping a tape drive in a changer (as reported by 'chio status') to a sa(4) driver instance by comparing the serial numbers. The designators can be ASCII (which is printed out directly), binary (which is printed in hex format) or UTF-8, which is printed in either native UTF-8 format if the terminal can support it, or in %XX notation for non-ASCII characters. Thanks to Hiroki Sato <hrs@> for the explaining UTF-8 printing and example UTF-8 printing code. chio.h: Modify the changer_element_status structure to add new fields and definitions from the SMC3r16 spec. Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and define a new CHIOGSTATUS ioctl. Clean up some tab/space issues. chio.c: For the 'status' subcommand, print the designator field if it is supplied by a device. scsi_ch.h: Add new flags for DVCID and CURDATA to the READ ELEMENT STATUS command structure. Add a read_element_status_device_id structure for the data fields in the new standard. Add new unions, dt_or_obsolete and voltage_devid, to hold and address data from either SCSI-2 or newer devices. scsi_ch.c: Implement support for fetching device IDs with READ ELEMENT STATUS data. Add new arguments to scsi_read_element_status() to allow the user to request the DVCID and CURDATA bits. This isn't compiled into libcam (it's only an internal kernel interface), so we don't need any special handling for the API change. If the user issues the new CHIOGSTATUS ioctl, copy all of the available element status data out. If he issues the OCHIOGSTATUS ioctl, we don't copy the new fields in the structure. Fix a bug in chopen() that would result in the peripheral never getting unheld if chgetparams() failed. Sponsored by: Spectra Logic Submitted by: Po-Li Soong MFC After: 1 week
Diffstat (limited to 'sys/sys/chio.h')
-rw-r--r--sys/sys/chio.h83
1 files changed, 67 insertions, 16 deletions
diff --git a/sys/sys/chio.h b/sys/sys/chio.h
index aa55f7c..edf1ab7 100644
--- a/sys/sys/chio.h
+++ b/sys/sys/chio.h
@@ -152,7 +152,8 @@ typedef enum {
CES_INVERT = 0x040, /* invert bit */
CES_SOURCE_VALID = 0x080, /* source address (ces_source) valid */
CES_SCSIID_VALID = 0x100, /* ces_scsi_id is valid */
- CES_LUN_VALID = 0x200 /* ces_scsi_lun is valid */
+ CES_LUN_VALID = 0x200, /* ces_scsi_lun is valid */
+ CES_PIV = 0x400 /* ces_protocol_id is valid */
} ces_status_flags;
struct changer_element_status {
@@ -181,6 +182,55 @@ struct changer_element_status {
changer_voltag_t ces_avoltag; /* alternate volume tag */
u_int8_t ces_scsi_id; /* SCSI id of element */
u_int8_t ces_scsi_lun; /* SCSI lun of element */
+
+ /*
+ * Data members for SMC3 and later versions
+ */
+ u_int8_t ces_medium_type;
+#define CES_MEDIUM_TYPE_UNKNOWN 0 /* Medium type unspecified */
+#define CES_MEDIUM_TYPE_DATA 1 /* Data medium */
+#define CES_MEDIUM_TYPE_CLEANING 2 /* Cleaning medium */
+#define CES_MEDIUM_TYPE_DIAGNOSTIC 3 /* Diagnostic medium */
+#define CES_MEDIUM_TYPE_WORM 4 /* WORM medium */
+#define CES_MEDIUM_TYPE_MICROCODE 5 /* Microcode image medium */
+
+ u_int8_t ces_protocol_id;
+#define CES_PROTOCOL_ID_FCP_4 0 /* Fiber channel */
+#define CES_PROTOCOL_ID_SPI_5 1 /* Parallel SCSI */
+#define CES_PROTOCOL_ID_SSA_S3P 2 /* SSA */
+#define CES_PROTOCOL_ID_SBP_3 3 /* IEEE 1394 */
+#define CES_PROTOCOL_ID_SRP 4 /* SCSI Remote DMA */
+#define CES_PROTOCOL_ID_ISCSI 5 /* iSCSI */
+#define CES_PROTOCOL_ID_SPL 6 /* SAS */
+#define CES_PROTOCOL_ID_ADT_2 7 /* Automation/Drive Interface */
+#define CES_PROTOCOL_ID_ACS_2 8 /* ATA */
+
+ u_int8_t ces_assoc;
+#define CES_ASSOC_LOGICAL_UNIT 0
+#define CES_ASSOC_TARGET_PORT 1
+#define CES_ASSOC_TARGET_DEVICE 2
+
+ u_int8_t ces_designator_type;
+#define CES_DESIGNATOR_TYPE_VENDOR_SPECIFIC 0
+#define CES_DESIGNATOR_TYPE_T10_VENDOR_ID 1
+#define CES_DESIGNATOR_TYPE_EUI_64 2
+#define CES_DESIGNATOR_TYPE_NAA 3
+#define CES_DESIGNATOR_TYPE_TARGET_PORT_ID 4
+#define CES_DESIGNATOR_TYPE_TARGET_PORT_GRP 5
+#define CES_DESIGNATOR_TYPE_LOGICAL_UNIT_GRP 6
+#define CES_DESIGNATOR_TYPE_MD5_LOGICAL_UNIT_ID 7
+#define CES_DESIGNATOR_TYPE_SCSI_NAME_STRING 8
+
+ u_int8_t ces_code_set;
+#define CES_CODE_SET_RESERVED 0
+#define CES_CODE_SET_BINARY 1
+#define CES_CODE_SET_ASCII 2
+#define CES_CODE_SET_UTF_8 3
+
+ u_int8_t ces_designator_length;
+
+#define CES_MAX_DESIGNATOR_LENGTH (1 << 8)
+ u_int8_t ces_designator[CES_MAX_DESIGNATOR_LENGTH + 1];
};
struct changer_element_status_request {
@@ -189,7 +239,7 @@ struct changer_element_status_request {
u_int16_t cesr_element_count;
u_int16_t cesr_flags;
-#define CESR_VOLTAGS 0x01
+#define CESR_VOLTAGS 0x01
struct changer_element_status *cesr_element_status;
};
@@ -200,28 +250,29 @@ struct changer_set_voltag_request {
u_int16_t csvr_addr;
u_int16_t csvr_flags;
-#define CSVR_MODE_MASK 0x0f /* mode mask, acceptable modes below: */
+#define CSVR_MODE_MASK 0x0f /* mode mask, acceptable modes below: */
#define CSVR_MODE_SET 0x00 /* set volume tag if not set */
-#define CSVR_MODE_REPLACE 0x01 /* unconditionally replace volume tag */
-#define CSVR_MODE_CLEAR 0x02 /* clear volume tag */
+#define CSVR_MODE_REPLACE 0x01 /* unconditionally replace volume tag */
+#define CSVR_MODE_CLEAR 0x02 /* clear volume tag */
-#define CSVR_ALTERNATE 0x10 /* set to work with alternate voltag */
+#define CSVR_ALTERNATE 0x10 /* set to work with alternate voltag */
changer_voltag_t csvr_voltag;
};
-#define CESTATUS_BITS \
+#define CESTATUS_BITS \
"\20\6INEAB\5EXENAB\4ACCESS\3EXCEPT\2IMPEXP\1FULL"
-#define CHIOMOVE _IOW('c', 0x01, struct changer_move)
-#define CHIOEXCHANGE _IOW('c', 0x02, struct changer_exchange)
-#define CHIOPOSITION _IOW('c', 0x03, struct changer_position)
-#define CHIOGPICKER _IOR('c', 0x04, int)
-#define CHIOSPICKER _IOW('c', 0x05, int)
-#define CHIOGPARAMS _IOR('c', 0x06, struct changer_params)
-#define CHIOIELEM _IOW('c', 0x07, u_int32_t)
-#define CHIOGSTATUS _IOW('c', 0x08, struct changer_element_status_request)
-#define CHIOSETVOLTAG _IOW('c', 0x09, struct changer_set_voltag_request)
+#define CHIOMOVE _IOW('c', 0x01, struct changer_move)
+#define CHIOEXCHANGE _IOW('c', 0x02, struct changer_exchange)
+#define CHIOPOSITION _IOW('c', 0x03, struct changer_position)
+#define CHIOGPICKER _IOR('c', 0x04, int)
+#define CHIOSPICKER _IOW('c', 0x05, int)
+#define CHIOGPARAMS _IOR('c', 0x06, struct changer_params)
+#define CHIOIELEM _IOW('c', 0x07, u_int32_t)
+#define OCHIOGSTATUS _IOW('c', 0x08, struct changer_element_status_request)
+#define CHIOSETVOLTAG _IOW('c', 0x09, struct changer_set_voltag_request)
+#define CHIOGSTATUS _IOW('c', 0x0A, struct changer_element_status_request)
#endif /* !_SYS_CHIO_H_ */
OpenPOWER on IntegriCloud