vserver 1.9.5.x5
[linux-2.6.git] / arch / ppc64 / kernel / viopath.c
index 50df816..74f185e 100644 (file)
 #include <linux/dma-mapping.h>
 #include <linux/wait.h>
 #include <linux/seq_file.h>
+#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
 
-#include <asm/hardirq.h>
+#include <asm/system.h>
 #include <asm/uaccess.h>
 #include <asm/iSeries/LparData.h>
 #include <asm/iSeries/HvLpEvent.h>
@@ -62,7 +64,7 @@ static struct viopathStatus {
        int numberAllocated;
 } viopathStatus[HVMAXARCHITECTEDLPS];
 
-static spinlock_t statuslock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(statuslock);
 
 /*
  * For each kind of event we allocate a buffer that is
@@ -108,88 +110,10 @@ static vio_event_handler_t *vio_handler[VIO_MAX_SUBTYPES];
 #define VIOPATH_KERN_WARN      KERN_WARNING "viopath: "
 #define VIOPATH_KERN_INFO      KERN_INFO "viopath: "
 
-static unsigned char e2a(unsigned char x)
-{
-       switch (x) {
-       case 0xF0:
-               return '0';
-       case 0xF1:
-               return '1';
-       case 0xF2:
-               return '2';
-       case 0xF3:
-               return '3';
-       case 0xF4:
-               return '4';
-       case 0xF5:
-               return '5';
-       case 0xF6:
-               return '6';
-       case 0xF7:
-               return '7';
-       case 0xF8:
-               return '8';
-       case 0xF9:
-               return '9';
-       case 0xC1:
-               return 'A';
-       case 0xC2:
-               return 'B';
-       case 0xC3:
-               return 'C';
-       case 0xC4:
-               return 'D';
-       case 0xC5:
-               return 'E';
-       case 0xC6:
-               return 'F';
-       case 0xC7:
-               return 'G';
-       case 0xC8:
-               return 'H';
-       case 0xC9:
-               return 'I';
-       case 0xD1:
-               return 'J';
-       case 0xD2:
-               return 'K';
-       case 0xD3:
-               return 'L';
-       case 0xD4:
-               return 'M';
-       case 0xD5:
-               return 'N';
-       case 0xD6:
-               return 'O';
-       case 0xD7:
-               return 'P';
-       case 0xD8:
-               return 'Q';
-       case 0xD9:
-               return 'R';
-       case 0xE2:
-               return 'S';
-       case 0xE3:
-               return 'T';
-       case 0xE4:
-               return 'U';
-       case 0xE5:
-               return 'V';
-       case 0xE6:
-               return 'W';
-       case 0xE7:
-               return 'X';
-       case 0xE8:
-               return 'Y';
-       case 0xE9:
-               return 'Z';
-       }
-       return ' ';
-}
-
 static int proc_viopath_show(struct seq_file *m, void *v)
 {
        char *buf;
+       u16 vlanMap;
        dma_addr_t handle;
        HvLpEvent_Rc hvrc;
        DECLARE_MUTEX_LOCKED(Semaphore);
@@ -216,12 +140,11 @@ static int proc_viopath_show(struct seq_file *m, void *v)
 
        down(&Semaphore);
 
-       dma_unmap_single(iSeries_vio_dev, handle, PAGE_SIZE, DMA_FROM_DEVICE);
-       kfree(buf);
+       vlanMap = HvLpConfig_getVirtualLanIndexMap();
 
-       buf[PAGE_SIZE] = '\0';
+       buf[PAGE_SIZE-1] = '\0';
        seq_printf(m, "%s", buf);
-
+       seq_printf(m, "AVAILABLE_VETH=%x\n", vlanMap);
        seq_printf(m, "SRLNBR=%c%c%c%c%c%c%c\n",
                   e2a(xItExtVpdPanel.mfgID[2]),
                   e2a(xItExtVpdPanel.mfgID[3]),
@@ -231,6 +154,9 @@ static int proc_viopath_show(struct seq_file *m, void *v)
                   e2a(xItExtVpdPanel.systemSerial[4]),
                   e2a(xItExtVpdPanel.systemSerial[5]));
 
+       dma_unmap_single(iSeries_vio_dev, handle, PAGE_SIZE, DMA_FROM_DEVICE);
+       kfree(buf);
+
        return 0;
 }
 
@@ -547,7 +473,7 @@ static int allocateEvents(HvLpIndex remoteLp, int numEvents)
                parms.used_wait_atomic = 0;
                parms.sem = &Semaphore;
        }
-       mf_allocateLpEvents(remoteLp, HvLpEvent_Type_VirtualIo, 250,    /* It would be nice to put a real number here! */
+       mf_allocate_lp_events(remoteLp, HvLpEvent_Type_VirtualIo, 250,  /* It would be nice to put a real number here! */
                            numEvents, &viopath_donealloc, &parms);
        if (in_atomic()) {
                while (atomic_read(&wait_atomic))
@@ -656,7 +582,7 @@ int viopath_close(HvLpIndex remoteLp, int subtype, int numReq)
 
        doneAllocParms.used_wait_atomic = 0;
        doneAllocParms.sem = &Semaphore;
-       mf_deallocateLpEvents(remoteLp, HvLpEvent_Type_VirtualIo,
+       mf_deallocate_lp_events(remoteLp, HvLpEvent_Type_VirtualIo,
                              numReq, &viopath_donealloc, &doneAllocParms);
        down(&Semaphore);