]> err.no Git - linux-2.6/commitdiff
[PATCH] powerpc: remove bitfields from HvLpEvent
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 12 Jan 2006 02:47:43 +0000 (13:47 +1100)
committerPaul Mackerras <paulus@samba.org>
Thu, 12 Jan 2006 09:09:29 +0000 (20:09 +1100)
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/platforms/iseries/irq.c
arch/powerpc/platforms/iseries/lpevents.c
arch/powerpc/platforms/iseries/mf.c
arch/powerpc/platforms/iseries/viopath.c
drivers/block/viodasd.c
drivers/cdrom/viocd.c
drivers/char/viocons.c
drivers/net/iseries_veth.c
include/asm-powerpc/iseries/hv_lp_event.h

index 42e978e4897a9d24860ed741abca38ecb2b65133..3d023856405a128b83c5c9309813443552118faf 100644 (file)
@@ -147,20 +147,11 @@ static void int_received(struct pci_event *event, struct pt_regs *regs)
 static void pci_event_handler(struct HvLpEvent *event, struct pt_regs *regs)
 {
        if (event && (event->xType == HvLpEvent_Type_PciIo)) {
-               switch (event->xFlags.xFunction) {
-               case HvLpEvent_Function_Int:
+               if (hvlpevent_is_int(event))
                        int_received((struct pci_event *)event, regs);
-                       break;
-               case HvLpEvent_Function_Ack:
+               else
                        printk(KERN_ERR
                                "pci_event_handler: unexpected ack received\n");
-                       break;
-               default:
-                       printk(KERN_ERR
-                               "pci_event_handler: unexpected event function %d\n",
-                               (int)event->xFlags.xFunction);
-                       break;
-               }
        } else if (event)
                printk(KERN_ERR
                        "pci_event_handler: Unrecognized PCI event type 0x%x\n",
index e9fb98bf895f46fa9d4008dbdca1e6b23b8835a9..0b885300d1d1a9360a32a2418e5d0e9c024c1faf 100644 (file)
@@ -53,7 +53,7 @@ static struct HvLpEvent * get_next_hvlpevent(void)
        struct HvLpEvent * event;
        event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr;
 
-       if (event->xFlags.xValid) {
+       if (hvlpevent_is_valid(event)) {
                /* rmb() needed only for weakly consistent machines (regatta) */
                rmb();
                /* Set pointer to next potential event */
@@ -84,7 +84,7 @@ int hvlpevent_is_pending(void)
 
        next_event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr;
 
-       return next_event->xFlags.xValid |
+       return hvlpevent_is_valid(next_event) ||
                hvlpevent_queue.xPlicOverflowIntPending;
 }
 
@@ -101,18 +101,18 @@ static void hvlpevent_clear_valid(struct HvLpEvent * event)
        switch (extra) {
        case 3:
                tmp = (struct HvLpEvent*)((char*)event + 3 * LpEventAlign);
-               tmp->xFlags.xValid = 0;
+               hvlpevent_invalidate(tmp);
        case 2:
                tmp = (struct HvLpEvent*)((char*)event + 2 * LpEventAlign);
-               tmp->xFlags.xValid = 0;
+               hvlpevent_invalidate(tmp);
        case 1:
                tmp = (struct HvLpEvent*)((char*)event + 1 * LpEventAlign);
-               tmp->xFlags.xValid = 0;
+               hvlpevent_invalidate(tmp);
        }
 
        mb();
 
-       event->xFlags.xValid = 0;
+       hvlpevent_invalidate(event);
 }
 
 void process_hvlpevents(struct pt_regs *regs)
index 49e7e4b85847558bacba928922d85166615075dc..a41d8b78c0cd6e15b8e83c57321eff84fb26dbe9 100644 (file)
@@ -251,10 +251,7 @@ static struct pending_event *new_pending_event(void)
        }
        memset(ev, 0, sizeof(struct pending_event));
        hev = &ev->event.hp_lp_event;
-       hev->xFlags.xValid = 1;
-       hev->xFlags.xAckType = HvLpEvent_AckType_ImmediateAck;
-       hev->xFlags.xAckInd = HvLpEvent_AckInd_DoAck;
-       hev->xFlags.xFunction = HvLpEvent_Function_Int;
+       hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DO_ACK | HV_LP_EVENT_INT;
        hev->xType = HvLpEvent_Type_MachineFac;
        hev->xSourceLp = HvLpConfig_getLpIndex();
        hev->xTargetLp = primary_lp;
@@ -518,17 +515,10 @@ static void handle_ack(struct io_mf_lp_event *event)
 static void hv_handler(struct HvLpEvent *event, struct pt_regs *regs)
 {
        if ((event != NULL) && (event->xType == HvLpEvent_Type_MachineFac)) {
-               switch(event->xFlags.xFunction) {
-               case HvLpEvent_Function_Ack:
+               if (hvlpevent_is_ack(event))
                        handle_ack((struct io_mf_lp_event *)event);
-                       break;
-               case HvLpEvent_Function_Int:
+               else
                        handle_int((struct io_mf_lp_event *)event);
-                       break;
-               default:
-                       printk(KERN_ERR "mf.c: non ack/int event received\n");
-                       break;
-               }
        } else
                printk(KERN_ERR "mf.c: alien event received\n");
 }
index 842672695598e9845f8698e4fe827ec1c20234d8..622a30149b48b700131da58ebd52e098acebf573 100644 (file)
@@ -270,7 +270,7 @@ static void handleMonitorEvent(struct HvLpEvent *event)
         * First see if this is just a normal monitor message from the
         * other partition
         */
-       if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
+       if (hvlpevent_is_int(event)) {
                remoteLp = event->xSourceLp;
                if (!viopathStatus[remoteLp].isActive)
                        sendMonMsg(remoteLp);
@@ -331,13 +331,12 @@ static void handleConfig(struct HvLpEvent *event)
 {
        if (!event)
                return;
-       if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
+       if (hvlpevent_is_int(event)) {
                printk(VIOPATH_KERN_WARN
                       "unexpected config request from partition %d",
                       event->xSourceLp);
 
-               if ((event->xFlags.xFunction == HvLpEvent_Function_Int) &&
-                   (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck)) {
+               if (hvlpevent_need_ack(event)) {
                        event->xRc = HvLpEvent_Rc_InvalidSubtype;
                        HvCallEvent_ackLpEvent(event);
                }
@@ -377,7 +376,7 @@ static void vio_handleEvent(struct HvLpEvent *event, struct pt_regs *regs)
        int subtype = (event->xSubtype & VIOMAJOR_SUBTYPE_MASK)
                >> VIOMAJOR_SUBTYPE_SHIFT;
 
-       if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
+       if (hvlpevent_is_int(event)) {
                remoteLp = event->xSourceLp;
                /*
                 * The isActive is checked because if the hosting partition
@@ -436,8 +435,7 @@ static void vio_handleEvent(struct HvLpEvent *event, struct pt_regs *regs)
                       "unexpected virtual io event subtype %d from partition %d\n",
                       event->xSubtype, remoteLp);
                /* No handler.  Ack if necessary */
-               if ((event->xFlags.xFunction == HvLpEvent_Function_Int) &&
-                   (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck)) {
+               if (hvlpevent_is_int(event) && hvlpevent_need_ack(event)) {
                        event->xRc = HvLpEvent_Rc_InvalidSubtype;
                        HvCallEvent_ackLpEvent(event);
                }
index d1aaf31bd97e85e762c33e2aa50b65748c45f0af..f63e07bd9f9c4e3b23f20c626c95e260451f1639 100644 (file)
@@ -293,6 +293,7 @@ static int send_request(struct request *req)
        u16 viocmd;
        HvLpEvent_Rc hvrc;
        struct vioblocklpevent *bevent;
+       struct HvLpEvent *hev;
        struct scatterlist sg[VIOMAXBLOCKDMA];
        int sgindex;
        int statindex;
@@ -347,22 +348,19 @@ static int send_request(struct request *req)
                 * token so we can match the response up later
                 */
                memset(bevent, 0, sizeof(struct vioblocklpevent));
-               bevent->event.xFlags.xValid = 1;
-               bevent->event.xFlags.xFunction = HvLpEvent_Function_Int;
-               bevent->event.xFlags.xAckInd = HvLpEvent_AckInd_DoAck;
-               bevent->event.xFlags.xAckType = HvLpEvent_AckType_ImmediateAck;
-               bevent->event.xType = HvLpEvent_Type_VirtualIo;
-               bevent->event.xSubtype = viocmd;
-               bevent->event.xSourceLp = HvLpConfig_getLpIndex();
-               bevent->event.xTargetLp = viopath_hostLp;
-               bevent->event.xSizeMinus1 =
+               hev = &bevent->event;
+               hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DO_ACK |
+                       HV_LP_EVENT_INT;
+               hev->xType = HvLpEvent_Type_VirtualIo;
+               hev->xSubtype = viocmd;
+               hev->xSourceLp = HvLpConfig_getLpIndex();
+               hev->xTargetLp = viopath_hostLp;
+               hev->xSizeMinus1 =
                        offsetof(struct vioblocklpevent, u.rw_data.dma_info) +
                        (sizeof(bevent->u.rw_data.dma_info[0]) * nsg) - 1;
-               bevent->event.xSourceInstanceId =
-                       viopath_sourceinst(viopath_hostLp);
-               bevent->event.xTargetInstanceId =
-                       viopath_targetinst(viopath_hostLp);
-               bevent->event.xCorrelationToken = (u64)req;
+               hev->xSourceInstanceId = viopath_sourceinst(viopath_hostLp);
+               hev->xTargetInstanceId = viopath_targetinst(viopath_hostLp);
+               hev->xCorrelationToken = (u64)req;
                bevent->version = VIOVERSION;
                bevent->disk = DEVICE_NO(d);
                bevent->u.rw_data.offset = start;
@@ -649,10 +647,10 @@ static void handle_block_event(struct HvLpEvent *event)
                /* Notification that a partition went away! */
                return;
        /* First, we should NEVER get an int here...only acks */
-       if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
+       if (hvlpevent_is_int(event)) {
                printk(VIOD_KERN_WARNING
                       "Yikes! got an int in viodasd event handler!\n");
-               if (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck) {
+               if (hvlpevent_need_ack(event)) {
                        event->xRc = HvLpEvent_Rc_InvalidSubtype;
                        HvCallEvent_ackLpEvent(event);
                }
@@ -695,7 +693,7 @@ static void handle_block_event(struct HvLpEvent *event)
 
        default:
                printk(VIOD_KERN_WARNING "invalid subtype!");
-               if (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck) {
+               if (hvlpevent_need_ack(event)) {
                        event->xRc = HvLpEvent_Rc_InvalidSubtype;
                        HvCallEvent_ackLpEvent(event);
                }
index b5191780ecca44ae9abf782a6a7c04f57916d3f2..193446e6a08a80f4232cd13fcd50526c37de1914 100644 (file)
@@ -542,10 +542,10 @@ static void vio_handle_cd_event(struct HvLpEvent *event)
                /* Notification that a partition went away! */
                return;
        /* First, we should NEVER get an int here...only acks */
-       if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
+       if (hvlpevent_is_int(event)) {
                printk(VIOCD_KERN_WARNING
                                "Yikes! got an int in viocd event handler!\n");
-               if (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck) {
+               if (hvlpevent_need_ack(event)) {
                        event->xRc = HvLpEvent_Rc_InvalidSubtype;
                        HvCallEvent_ackLpEvent(event);
                }
@@ -616,7 +616,7 @@ return_complete:
                printk(VIOCD_KERN_WARNING
                                "message with invalid subtype %0x04X!\n",
                                event->xSubtype & VIOMINOR_SUBTYPE_MASK);
-               if (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck) {
+               if (hvlpevent_need_ack(event)) {
                        event->xRc = HvLpEvent_Rc_InvalidSubtype;
                        HvCallEvent_ackLpEvent(event);
                }
index faee5e7acaf7ae7707847bcb9f2ff8f044f41279..4e5360388748e7facd991ceefe64a06439f3b35c 100644 (file)
@@ -476,19 +476,19 @@ static struct port_info *get_port_data(struct tty_struct *tty)
  */
 static void initDataEvent(struct viocharlpevent *viochar, HvLpIndex lp)
 {
+       struct HvLpEvent *hev = &viochar->event;
+
        memset(viochar, 0, sizeof(struct viocharlpevent));
 
-       viochar->event.xFlags.xValid = 1;
-       viochar->event.xFlags.xFunction = HvLpEvent_Function_Int;
-       viochar->event.xFlags.xAckInd = HvLpEvent_AckInd_NoAck;
-       viochar->event.xFlags.xAckType = HvLpEvent_AckType_DeferredAck;
-       viochar->event.xType = HvLpEvent_Type_VirtualIo;
-       viochar->event.xSubtype = viomajorsubtype_chario | viochardata;
-       viochar->event.xSourceLp = HvLpConfig_getLpIndex();
-       viochar->event.xTargetLp = lp;
-       viochar->event.xSizeMinus1 = sizeof(struct viocharlpevent);
-       viochar->event.xSourceInstanceId = viopath_sourceinst(lp);
-       viochar->event.xTargetInstanceId = viopath_targetinst(lp);
+       hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DEFERRED_ACK |
+               HV_LP_EVENT_INT;
+       hev->xType = HvLpEvent_Type_VirtualIo;
+       hev->xSubtype = viomajorsubtype_chario | viochardata;
+       hev->xSourceLp = HvLpConfig_getLpIndex();
+       hev->xTargetLp = lp;
+       hev->xSizeMinus1 = sizeof(struct viocharlpevent);
+       hev->xSourceInstanceId = viopath_sourceinst(lp);
+       hev->xTargetInstanceId = viopath_targetinst(lp);
 }
 
 /*
@@ -752,7 +752,7 @@ static void vioHandleOpenEvent(struct HvLpEvent *event)
        struct port_info *pi;
        int reject = 0;
 
-       if (event->xFlags.xFunction == HvLpEvent_Function_Ack) {
+       if (hvlpevent_is_ack(event)) {
                if (port >= VTTY_PORTS)
                        return;
 
@@ -788,7 +788,7 @@ static void vioHandleOpenEvent(struct HvLpEvent *event)
        }
 
        /* This had better require an ack, otherwise complain */
-       if (event->xFlags.xAckInd != HvLpEvent_AckInd_DoAck) {
+       if (!hvlpevent_need_ack(event)) {
                printk(VIOCONS_KERN_WARN "viocharopen without ack bit!\n");
                return;
        }
@@ -856,7 +856,7 @@ static void vioHandleCloseEvent(struct HvLpEvent *event)
        struct viocharlpevent *cevent = (struct viocharlpevent *)event;
        u8 port = cevent->virtual_device;
 
-       if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
+       if (hvlpevent_is_int(event)) {
                if (port >= VTTY_PORTS) {
                        printk(VIOCONS_KERN_WARN
                                        "close message from invalid virtual device.\n");
@@ -1056,8 +1056,7 @@ static void vioHandleCharEvent(struct HvLpEvent *event)
                vioHandleConfig(event);
                break;
        default:
-               if ((event->xFlags.xFunction == HvLpEvent_Function_Int) &&
-                   (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck)) {
+               if (hvlpevent_is_int(event) && hvlpevent_need_ack(event)) {
                        event->xRc = HvLpEvent_Rc_InvalidSubtype;
                        HvCallEvent_ackLpEvent(event);
                }
index 77eadf84cb2cb7895597180ce5f35e77b34d2d0c..f0f04be989d62bf5003838fbea839ee097f88883 100644 (file)
@@ -590,9 +590,9 @@ static void veth_handle_event(struct HvLpEvent *event, struct pt_regs *regs)
 {
        struct veth_lpevent *veth_event = (struct veth_lpevent *)event;
 
-       if (event->xFlags.xFunction == HvLpEvent_Function_Ack)
+       if (hvlpevent_is_ack(event))
                veth_handle_ack(veth_event);
-       else if (event->xFlags.xFunction == HvLpEvent_Function_Int)
+       else
                veth_handle_int(veth_event);
 }
 
index 499ab1ad01854ae9deefaa3bb2b38ea17ec46ab1..8ee89b67b8fd79d88502f6144b87ef7f18f3342d 100644 (file)
  * partitions through PLIC.
  */
 
-struct HvEventFlags {
-       u8      xValid:1;       /* Indicates a valid request    x00-x00 */
-       u8      xRsvd1:4;       /* Reserved                     ... */
-       u8      xAckType:1;     /* Immediate or deferred        ... */
-       u8      xAckInd:1;      /* Indicates if ACK required    ... */
-       u8      xFunction:1;    /* Interrupt or Acknowledge     ... */
-};
-
-
 struct HvLpEvent {
-       struct HvEventFlags xFlags;     /* Event flags                x00-x00 */
+       u8      flags;                  /* Event flags                x00-x00 */
        u8      xType;                  /* Type of message            x01-x01 */
        u16     xSubtype;               /* Subtype for event          x02-x03 */
        u8      xSourceLp;              /* Source LP                  x04-x04 */
@@ -126,6 +117,11 @@ extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
 #define HvLpEvent_AckType_ImmediateAck 0
 #define HvLpEvent_AckType_DeferredAck 1
 
+#define HV_LP_EVENT_INT                        0x01
+#define HV_LP_EVENT_DO_ACK             0x02
+#define HV_LP_EVENT_DEFERRED_ACK       0x04
+#define HV_LP_EVENT_VALID              0x80
+
 #define HvLpDma_Direction_LocalToRemote 0
 #define HvLpDma_Direction_RemoteToLocal 1
 
@@ -139,4 +135,29 @@ extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
 #define HvLpDma_Rc_InvalidAddress 4
 #define HvLpDma_Rc_InvalidLength 5
 
+static inline int hvlpevent_is_valid(struct HvLpEvent *h)
+{
+       return h->flags & HV_LP_EVENT_VALID;
+}
+
+static inline void hvlpevent_invalidate(struct HvLpEvent *h)
+{
+       h->flags &= ~ HV_LP_EVENT_VALID;
+}
+
+static inline int hvlpevent_is_int(struct HvLpEvent *h)
+{
+       return h->flags & HV_LP_EVENT_INT;
+}
+
+static inline int hvlpevent_is_ack(struct HvLpEvent *h)
+{
+       return !hvlpevent_is_int(h);
+}
+
+static inline int hvlpevent_need_ack(struct HvLpEvent *h)
+{
+       return h->flags & HV_LP_EVENT_DO_ACK;
+}
+
 #endif /* _ASM_POWERPC_ISERIES_HV_LP_EVENT_H */