[priority] update the alua prioritizer 0.4.5
authorroot <root@zezette.localdomain>
Fri, 26 Aug 2005 20:19:56 +0000 (22:19 +0200)
committerroot <root@zezette.localdomain>
Fri, 26 Aug 2005 20:19:56 +0000 (22:19 +0200)
Removes bitfields in the SCSI structs.
This didn't work on i386.

From Stefan Bader, IBM

path_priority/pp_alua/main.c
path_priority/pp_alua/rtpg.c
path_priority/pp_alua/spc3.h

index f7d160dc5d0a9cee7c2f72a4ffbb001d31d7a1df..190fbdcebadd8a49b0afab09b55d144201fcba29 100644 (file)
@@ -35,7 +35,7 @@
 #define ALUA_PRIO_GETAAS_FAILED                        5
 
 #define ALUA_PRIO_MAJOR                                0
-#define ALUA_PRIO_MINOR                                5
+#define ALUA_PRIO_MINOR                                6
 
 #define PRINT_ERROR(f, a...) \
                if (verbose) \
index 5eb1a1c29ddc2031953506873d69fd1354f567ae..9aea5607ddd81514a9795ce9d9d2b9e940a1ef1f 100644 (file)
@@ -123,7 +123,7 @@ do_inquiry(int fd, int evpd, unsigned int codepage, void *resp, int resplen)
        memset(&cmd, 0, sizeof(cmd));
        cmd.op = OPERATION_CODE_INQUIRY;
        if (evpd) {
-               cmd.evpd = 1;
+               inquiry_command_set_evpd(&cmd);
                cmd.page = codepage;
        }
        set_uint16(cmd.length, resplen);
@@ -166,7 +166,7 @@ get_target_port_group_support(int fd)
 
        rc = do_inquiry(fd, 0, 0x00, &inq, sizeof(inq));
        if (!rc) {
-               rc = inq.tpgs;
+               rc = inquiry_data_get_tpgs(&inq);
        }
 
        return rc;
@@ -189,7 +189,7 @@ get_target_port_group(int fd)
                        if ((((char *) dscr) - ((char *) vpd83)) > sizeof(buf))
                                break;
 
-                       if (dscr->id_type == IDTYPE_TARGET_PORT_GROUP) {
+                       if (vpd83_dscr_istype(dscr, IDTYPE_TARGET_PORT_GROUP)) {
                                struct vpd83_tpg_dscr * p;
 
                                if (rc != -RTPG_NO_TPG_IDENTIFIER) {
@@ -221,7 +221,7 @@ do_rtpg(int fd, void* resp, long resplen)
 
        memset(&cmd, 0, sizeof(cmd));
        cmd.op                  = OPERATION_CODE_RTPG;
-       cmd.service_action      = SERVICE_ACTION_RTPG;
+       rtpg_command_set_service_action(&cmd);
        set_uint32(cmd.length, resplen);
        PRINT_HEX((unsigned char *) &cmd, sizeof(cmd));
 
@@ -270,7 +270,7 @@ get_asymmetric_access_state(int fd, unsigned int tpg)
                                        "group.\n");
                        } else {
                                PRINT_DEBUG("pref=%i\n", dscr->pref);
-                               rc = dscr->aas;
+                               rc = rtpg_tpg_dscr_get_aas(dscr);
                        }
                }
        }
index eac647dca4a3c3aef63b50b644b4e3ba45677ce8..11f5dbdf1fd5ce098576b361d3fdfc42fa72d2fb 100644 (file)
@@ -57,14 +57,20 @@ set_uint32(unsigned char *p, unsigned int v)
 
 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.
  *-----------------------------------------------------------------------------
@@ -109,64 +115,58 @@ struct 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.
  *-----------------------------------------------------------------------------
@@ -195,23 +195,28 @@ struct vpd83_tpg_dscr {
 } __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));
 
@@ -243,15 +248,21 @@ struct vpd83_data {
 #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. */
@@ -269,14 +280,14 @@ struct rtpg_tp_dscr {
 #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;
@@ -285,6 +296,12 @@ struct rtpg_tpg_dscr {
        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];