struct inquiry_command {
unsigned char op;
- unsigned char reserved1 : 6;
- unsigned char obsolete1 : 1;
- unsigned char evpd : 1;
+ unsigned char b1; /* xxxxxx.. = reserved */
+ /* ......x. = obsolete */
+ /* .......x = evpd */
unsigned char page;
unsigned char length[2];
unsigned char control;
} __attribute__((packed));
+static inline void
+inquiry_command_set_evpd(struct inquiry_command *ic)
+{
+ ic->b1 |= 1;
+}
+
/*-----------------------------------------------------------------------------
* Data returned by the standard inquiry command.
*-----------------------------------------------------------------------------
#define TPGS_BOTH 0x3
struct inquiry_data {
- unsigned char peripheral_qualifier : 3;
- unsigned char peripheral_device_type : 5;
- /* Removable Medium Bit (1 == removable) */
- unsigned char rmb : 1;
- unsigned char reserved1 : 7;
+ unsigned char b0; /* xxx..... = peripheral_qualifier */
+ /* ...xxxxx = peripheral_device_type */
+ unsigned char b1; /* x....... = removable medium */
+ /* .xxxxxxx = reserverd */
unsigned char version;
- unsigned char obsolete1 : 2;
- /* Normal ACA Supported */
- unsigned char norm_aca : 1;
- /* Hierarchical LUN assignment support */
- unsigned char hi_sup : 1;
- /* If 2 then response data is as defined in SPC-3. */
- unsigned char response_data_format : 4;
+ unsigned char b3; /* xx...... = obsolete */
+ /* ..x..... = normal aca supported */
+ /* ...x.... = hirarchichal lun supp. */
+ /* ....xxxx = response format */
+ /* 2 is spc-3 format */
unsigned char length;
- /* Storage Controller Component Supported. */
- unsigned char sccs : 1;
- /* Access Controls Cordinator. */
- unsigned char acc : 1;
- /* Target Port Group Support */
- unsigned char tpgs : 2;
- /* Third Party Copy support. */
- unsigned char tpc : 1;
- unsigned char reserved2 : 2;
- /* PROTECTion information supported. */
- unsigned char protect : 1;
- /* Basic task management model supported (CmdQue must be 0). */
- unsigned char bque : 1;
- /* ENClosure SERVices supported. */
- unsigned char encserv : 1;
- unsigned char vs1 : 1;
- /* MULTIPort support. */
- unsigned char multip : 1;
- /* Medium CHaNGeR. */
- unsigned char mchngr : 1;
- unsigned char obsolete2 : 2;
- unsigned char addr16 : 1;
- unsigned char obsolete3 : 2;
- unsigned char wbus16 : 1;
- unsigned char sync : 1;
- /* LINKed commands supported. */
- unsigned char link : 1;
- unsigned char obsolete4 : 1;
- unsigned char cmdque : 1;
- unsigned char vs2 : 1;
+ unsigned char b5; /* x....... = storage controller */
+ /* component supported */
+ /* .x...... = access controls coord. */
+ /* ..xx.... = target port group supp.*/
+ /* ....x... = third party copy supp. */
+ /* .....xx. = reserved */
+ /* .......x = protection info supp. */
+ unsigned char b6; /* x....... = bque */
+ /* .x...... = enclosure services sup.*/
+ /* ..x..... = vs1 */
+ /* ...x.... = multiport support */
+ /* ....x... = medium changer */
+ /* .....xx. = obsolete */
+ /* .......x = add16 */
+ unsigned char b7; /* xx...... = obsolete */
+ /* ..x..... = wbus16 */
+ /* ...x.... = sync */
+ /* ....x... = linked commands supp. */
+ /* .....x.. = obsolete */
+ /* ......x. = command queue support */
+ /* .......x = vs2 */
unsigned char vendor_identification[8];
unsigned char product_identification[8];
unsigned char product_revision[4];
unsigned char vendor_specific[20];
- unsigned char reserved3 : 4;
- unsigned char clocking : 2;
- unsigned char qas : 1;
- unsigned char ius : 1;
+ unsigned char b48; /* xxxx.... = reserved */
+ /* ....xx.. = clocking */
+ /* ......x. = qas */
+ /* .......x = ius */
unsigned char reserved4;
unsigned char version_descriptor[8][2];
unsigned char reserved5[22];
unsigned char vendor_parameters[0];
} __attribute__((packed));
+static inline int
+inquiry_data_get_tpgs(struct inquiry_data *id)
+{
+ return (id->b5 >> 4) & 3;
+}
+
/*-----------------------------------------------------------------------------
* Inquiry data returned when requesting vital product data page 0x83.
*-----------------------------------------------------------------------------
} __attribute__((packed));
struct vpd83_dscr {
- unsigned char protocol_id : 4;
- unsigned char codeset : 4;
- /* Set if the protocol_id field is valid. */
- unsigned char piv : 1;
- unsigned char reserved1 : 1;
- unsigned char association : 2;
- unsigned char id_type : 4;
+ unsigned char b0; /* xxxx.... = protocol id */
+ /* ....xxxx = codeset */
+ unsigned char b1; /* x....... = protocol id valid */
+ /* .x...... = reserved */
+ /* ..xx.... = association */
+ /* ....xxxx = id type */
unsigned char reserved2;
- unsigned char length; /* size-4 */
+ unsigned char length; /* size-4 */
unsigned char data[0];
} __attribute__((packed));
+static inline int
+vpd83_dscr_istype(struct vpd83_dscr *d, unsigned char type)
+{
+ return ((d->b1 & 7) == type);
+}
+
struct vpd83_data {
- unsigned char peripheral_qualifier : 3;
- unsigned char peripheral_device_type : 5;
- unsigned char page_code; /* 0x83 */
- unsigned char length[2]; /* size-4 */
+ unsigned char b0; /* xxx..... = peripheral_qualifier */
+ /* ...xxxxx = peripheral_device_type */
+ unsigned char page_code; /* 0x83 */
+ unsigned char length[2]; /* size-4 */
struct vpd83_dscr data[0];
} __attribute__((packed));
#define SERVICE_ACTION_RTPG 0x0a
struct rtpg_command {
- unsigned char op; /* 0xa3 */
- unsigned char reserved1 : 3;
- unsigned char service_action : 5; /* 0x0a */
+ unsigned char op; /* 0xa3 */
+ unsigned char b1; /* xxx..... = reserved */
+ /* ...xxxxx = service action (0x0a) */
unsigned char reserved2[4];
unsigned char length[4];
unsigned char reserved3;
unsigned char control;
} __attribute__((packed));
+static inline void
+rtpg_command_set_service_action(struct rtpg_command *cmd)
+{
+ cmd->b1 = (cmd->b1 & 0xe0) | SERVICE_ACTION_RTPG;
+}
+
struct rtpg_tp_dscr {
unsigned char obsolete1[2];
/* The Relative Target Port Identifier of a target port. */
#define TPG_STATUS_IMPLICIT_CHANGE 0x2
struct rtpg_tpg_dscr {
- unsigned char pref : 1;
- unsigned char reserved1 : 3;
- unsigned char aas : 4;
- unsigned char reserved2 : 4;
- unsigned char u_sup : 1;
- unsigned char s_sup : 1;
- unsigned char an_sup : 1;
- unsigned char ao_sup : 1;
+ unsigned char b0; /* x....... = pref(ered) port */
+ /* .xxx.... = reserved */
+ /* ....xxxx = asymetric access state */
+ unsigned char b1; /* xxxx.... = reserved */
+ /* ....x... = unavailable support */
+ /* .....x.. = standby support */
+ /* ......x. = non-optimized support */
+ /* .......x = optimized support */
unsigned char tpg[2];
unsigned char reserved3;
unsigned char status;
struct rtpg_tp_dscr data[0];
} __attribute__((packed));
+static inline int
+rtpg_tpg_dscr_get_aas(struct rtpg_tpg_dscr *d)
+{
+ return (d->b0 & 0x0f);
+}
+
struct rtpg_data {
unsigned char length[4]; /* size-4 */
struct rtpg_tpg_dscr data[0];