patch-2.4.2 linux/drivers/net/rclanmtl.c

Next file: linux/drivers/net/rclanmtl.h
Previous file: linux/drivers/net/pppox.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.1/linux/drivers/net/rclanmtl.c linux/drivers/net/rclanmtl.c
@@ -36,15 +36,11 @@
 ** *************************************************************************
 */
 
-#undef DEBUG
+#define DEBUG 1
 
 #define RC_LINUX_MODULE
 #include "rclanmtl.h"
 
-#define dprintf kprintf
-
-extern int printk(const char * fmt, ...);
-
  /* RedCreek LAN device Target ID */
 #define RC_LAN_TARGET_ID  0x10 
  /* RedCreek's OSM default LAN receive Initiator */
@@ -216,8 +212,8 @@
 /* #define RC_PRIVATE_GET_IP_AND_MASK  0x0007 */ /* OBSOLETE */
 #define RC_PRIVATE_GET_LINK_SPEED   0x0008
 #define RC_PRIVATE_GET_FIRMWARE_REV 0x0009
-/* #define RC_PRIVATE_GET_MAC_ADDR     0x000A *//**/
-#define RC_PRIVATE_GET_IP_AND_MASK  0x000B /**/
+/* #define RC_PRIVATE_GET_MAC_ADDR     0x000A */
+#define RC_PRIVATE_GET_IP_AND_MASK  0x000B 
 #define RC_PRIVATE_DEBUG_MSG        0x000C
 #define RC_PRIVATE_REPORT_DRIVER_CAPABILITY  0x000D
 #define RC_PRIVATE_SET_PROMISCUOUS_MODE  0x000e
@@ -247,72 +243,11 @@
 #define MSG_FRAME_SIZE  512
 #define NMBR_MSG_FRAMES 30
 
-/*
-**  Message Unit CSR definitions for RedCreek PCI45 board
-*/
-typedef struct tag_rcatu 
-{
-    volatile unsigned long APICRegSel;  /* APIC Register Select */
-    volatile unsigned long reserved0;
-    volatile unsigned long APICWinReg;  /* APIC Window Register */
-    volatile unsigned long reserved1;
-    volatile unsigned long InMsgReg0;   /* inbound message register 0 */
-    volatile unsigned long InMsgReg1;   /* inbound message register 1 */
-    volatile unsigned long OutMsgReg0;  /* outbound message register 0 */
-    volatile unsigned long OutMsgReg1;  /* outbound message register 1 */
-    volatile unsigned long InDoorReg;   /* inbound doorbell register */
-    volatile unsigned long InIntStat;   /* inbound interrupt status register */
-    volatile unsigned long InIntMask;   /* inbound interrupt mask register */
-    volatile unsigned long OutDoorReg;  /* outbound doorbell register */
-    volatile unsigned long OutIntStat;  /* outbound interrupt status register */
-    volatile unsigned long OutIntMask;  /* outbound interrupt mask register */
-    volatile unsigned long reserved2;
-    volatile unsigned long reserved3;
-    volatile unsigned long InQueue;     /* inbound queue port */
-    volatile unsigned long OutQueue;    /* outbound queue port */
-    volatile unsigned long reserved4;
-    volatile unsigned long reserver5;
-    /* RedCreek extension */
-    volatile unsigned long EtherMacLow;
-    volatile unsigned long EtherMacHi;
-    volatile unsigned long IPaddr;
-    volatile unsigned long IPmask;
-}
-ATU, *PATU;
-
- /* 
- ** typedef PAB
- **
- ** PCI Adapter Block - holds instance specific information and is located
- ** in a reserved space at the start of the message buffer allocated by user.
- */
-typedef struct
-{
-    PATU             p_atu;                /* ptr to  ATU register block */
-    PU8              pPci45LinBaseAddr;
-    PU8              pLinOutMsgBlock;
-    U32              outMsgBlockPhyAddr; 
-    PFNTXCALLBACK    pTransCallbackFunc;
-    PFNRXCALLBACK    pRecvCallbackFunc;
-    PFNCALLBACK      pRebootCallbackFunc;
-    PFNCALLBACK      pCallbackFunc;
-    U16              IOPState;
-    U16              InboundMFrameSize;
-}
-PAB, *PPAB;
-
  /* 
  ** in reserved space right after PAB in host memory is area for returning
  ** values from card 
  */
 
- /* 
- ** Array of pointers to PCI Adapter Blocks.
- ** Indexed by a zero based (0-31) interface number.
- */ 
-#define MAX_ADAPTERS 32
-static PPAB  PCIAdapterBlock[MAX_ADAPTERS];
-
 /*
 ** typedef NICSTAT
 **
@@ -357,19 +292,13 @@
 static int SendEnableSysMsg(PPAB pPab);
 
 
-/* 1st 100h bytes of message block is reserved for messenger instance */
-#define ADAPTER_BLOCK_RESERVED_SPACE 0x100
-
 /*
 ** =========================================================================
 ** RCInitI2OMsgLayer()
 **
 ** Initialize the RedCreek I2O Module and adapter.
 **
-** Inputs:  AdapterID - interface number from 0 to 15
-**          pciBaseAddr - virual base address of PCI (set by BIOS)
-**          p_msgbuf - virual address to private message block (min. 16K)
-**          p_phymsgbuf - physical address of private message block
+** Inputs:  dev - the devices net_device struct
 **          TransmitCallbackFunction - address of transmit callback function
 **          ReceiveCallbackFunction  - address of receive  callback function
 **
@@ -379,42 +308,49 @@
 ** =========================================================================
 */
 RC_RETURN
-RCInitI2OMsgLayer(U16 AdapterID, U32 pciBaseAddr, 
-                  PU8 p_msgbuf,  PU8 p_phymsgbuf,
+RCInitI2OMsgLayer(struct net_device *dev,
                   PFNTXCALLBACK  TransmitCallbackFunction,
                   PFNRXCALLBACK  ReceiveCallbackFunction,
                   PFNCALLBACK    RebootCallbackFunction)
 {
     int result;
     PPAB pPab; 
-    
-#ifdef DEBUG
-    kprintf("InitI2O: Adapter:0x%04.4ux ATU:0x%08.8ulx msgbuf:0x%08.8ulx phymsgbuf:0x%08.8ulx\n"
-            "TransmitCallbackFunction:0x%08.8ulx  ReceiveCallbackFunction:0x%08.8ulx\n",
-            AdapterID, pciBaseAddr, p_msgbuf, p_phymsgbuf, TransmitCallbackFunction, ReceiveCallbackFunction);
-#endif /* DEBUG */
+    U32 pciBaseAddr = dev->base_addr;
+    PDPA pDpa = dev->priv;
+    PU8 p_msgbuf = pDpa->PLanApiPA;
+    PU8 p_phymsgbuf = (PU8)virt_to_bus((void *) p_msgbuf);    
+    
+    dprintk("InitI2O: Adapter:0x%04ux ATU:0x%08ulx msgbuf:0x%08ulx phymsgbuf:0x%08ulx\n"
+            "TransmitCallbackFunction:0x%08ulx  ReceiveCallbackFunction:0x%08ulx\n",
+            pDpa->id, pciBaseAddr, (u32)p_msgbuf, (u32)p_phymsgbuf, 
+	    (u32)TransmitCallbackFunction, (u32)ReceiveCallbackFunction);
 
     
     /* Check if this interface already initialized - if so, shut it down */
-    if (PCIAdapterBlock[AdapterID] != NULL)
-    {
-        printk("PCIAdapterBlock[%d]!=NULL\n", AdapterID);
-//        RCResetLANCard(AdapterID, 0, (PU32)NULL, (PFNCALLBACK)NULL);
-        PCIAdapterBlock[AdapterID] = NULL;
+    if (pDpa->pPab != NULL) {
+	    printk(KERN_WARNING "(rcpci45 driver:) pDpa->pPab [%d] != NULL\n", pDpa->id);
+/*          RCResetLANCard(pDpa->id, 0, (PU32)NULL, (PFNCALLBACK)NULL); */
+	    pDpa->pPab = NULL;
     }
 
-    /* 
-    ** store adapter instance values in adapter block.
-    ** Adapter block is at beginning of message buffer
-    */  
-    pPab = (PPAB)p_msgbuf;
+    /* store adapter instance values in adapter block.
+     * Adapter block is at beginning of message buffer */  
     
+    pPab = kmalloc(sizeof(*pPab), GFP_KERNEL);
+    if (!pPab) {
+	    printk(KERN_ERR "(rcpci45 driver:) RCInitI2OMsgLayer: Could not allocate memory for PAB struct!\n");
+	    result = RC_RTN_MALLOC_ERROR;
+	    goto err_out;
+    }
+
+    memset(pPab, 0, sizeof(*pPab));
+    pDpa->pPab = pPab;
     pPab->p_atu = (PATU)pciBaseAddr;
     pPab->pPci45LinBaseAddr =  (PU8)pciBaseAddr;
     
-    /* Set outbound message frame addr - skip over Adapter Block */
-    pPab->outMsgBlockPhyAddr = (U32)(p_phymsgbuf + ADAPTER_BLOCK_RESERVED_SPACE);
-    pPab->pLinOutMsgBlock    = (PU8)(p_msgbuf + ADAPTER_BLOCK_RESERVED_SPACE);
+    /* Set outbound message frame addr */
+    pPab->outMsgBlockPhyAddr = (U32)p_phymsgbuf;
+    pPab->pLinOutMsgBlock    = (PU8)p_msgbuf;
 
     /* store callback function addresses */
     pPab->pTransCallbackFunc = TransmitCallbackFunction;
@@ -428,26 +364,29 @@
     result = GetI2OStatus(pPab);
     
     if (result != RC_RTN_NO_ERROR)
-        return result;
+	    goto err_out_dealloc;
 
-    if (pPab->IOPState == I2O_IOP_STATE_OPERATIONAL)
-    {
-        printk("pPab->IOPState == op: resetting adapter\n");
-        RCResetLANCard(AdapterID, 0, (PU32)NULL, (PFNCALLBACK)NULL);
+    if (pPab->IOPState == I2O_IOP_STATE_OPERATIONAL) {
+        printk(KERN_INFO "(rcpci45 driver:) pPab->IOPState == op: resetting adapter\n");
+        RCResetLANCard(dev, 0, (PU32)NULL, (PFNCALLBACK)NULL);
     }
         
     result = SendI2OOutboundQInitMsg(pPab);
     
     if (result != RC_RTN_NO_ERROR)
-        return result;
+	    goto err_out_dealloc;
 
     result = SendEnableSysMsg(pPab);
    
     if (result != RC_RTN_NO_ERROR)
-        return result;
+	    goto err_out_dealloc;
    
-    PCIAdapterBlock[AdapterID] = pPab;
     return RC_RTN_NO_ERROR;
+
+ err_out_dealloc:
+    kfree(pPab);
+ err_out:
+    return result;
 }
 
 /*
@@ -462,13 +401,11 @@
 */
 #define i960_OUT_POST_Q_INT_BIT        0x0008 /* bit set masks interrupts */
 
-RC_RETURN RCDisableI2OInterrupts(U16 AdapterID)
+RC_RETURN RCDisableI2OInterrupts(struct net_device *dev)
 {
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
 
-    pPab = PCIAdapterBlock[AdapterID];
-    
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
         
@@ -477,12 +414,11 @@
     return RC_RTN_NO_ERROR;
 }
 
-RC_RETURN RCEnableI2OInterrupts(U16 AdapterID)
+RC_RETURN RCEnableI2OInterrupts(struct net_device *dev)
 {
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
+
 
-    pPab = PCIAdapterBlock[AdapterID];
-    
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
     
@@ -499,18 +435,16 @@
 ** =========================================================================
 */
 RC_RETURN
-RCI2OSendPacket(U16 AdapterID, U32 InitiatorContext, PRCTCB pTransCtrlBlock)
+RCI2OSendPacket(struct net_device *dev, U32 InitiatorContext, 
+		PRCTCB pTransCtrlBlock)
 {
     U32 msgOffset;
     PU32 pMsg;
     int size;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
-#ifdef DEBUG
-    kprintf("RCI2OSendPacket()...\n");
-#endif /* DEBUG */
-    
-    pPab = PCIAdapterBlock[AdapterID];
+
+    dprintk("RCI2OSendPacket()...\n");
 
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
@@ -522,9 +456,7 @@
 
     if (msgOffset == 0xFFFFFFFF)
     {
-#ifdef DEBUG
-        kprintf("RCI2OSendPacket(): Inbound Free Q empty!\n");
-#endif /* DEBUG */
+        dprintk("RCI2OSendPacket(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
     }
         
@@ -535,9 +467,7 @@
 
     if (size == -1) /* error processing TCB - send NOP msg */
     {
-#ifdef DEBUG
-        kprintf("RCI2OSendPacket(): Error Rrocess TCB!\n");
-#endif /* DEBUG */
+        dprintk("RCI2OSendPacket(): Error Rrocess TCB!\n");
         pMsg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0;
         pMsg[1] = I2O_UTIL_NOP << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
         return RC_RTN_TCB_ERROR;
@@ -565,35 +495,28 @@
 ** =========================================================================
 */
 RC_RETURN
-RCPostRecvBuffers(U16 AdapterID, PRCTCB pTransCtrlBlock)
+RCPostRecvBuffers(struct net_device *dev, PRCTCB pTransCtrlBlock)
 {
     U32 msgOffset;
     PU32 pMsg;
     int size;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
-#ifdef DEBUG
-    kprintf("RCPostRecvBuffers()...\n");
-#endif /* DEBUG */
+    dprintk("RCPostRecvBuffers()...\n");
     
     /* search for DeviceHandle */
-    pPab = PCIAdapterBlock[AdapterID];
 
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
     
-
     /* get Inbound free Q entry - reading from In Q gets free Q entry */
     /* offset to Msg Frame in PCI msg block */
     msgOffset = pPab->p_atu->InQueue; 
 
     if (msgOffset == 0xFFFFFFFF)
     {
-#ifdef DEBUG
-        kprintf("RCPostRecvBuffers(): Inbound Free Q empty!\n");
-#endif /* DEBUG */
+        dprintk("RCPostRecvBuffers(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
-   
     }
     /* calc virual address of msg - virual already mapped to physical */    
     pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
@@ -602,9 +525,7 @@
 
     if (size == -1) /* error prcessing TCB - send 3 DWORD private msg == NOP */
     {
-#ifdef DEBUG
-        kprintf("RCPostRecvBuffers(): Error Processing TCB! size = %d\n", size);
-#endif /* DEBUG */
+        dprintk("RCPostRecvBuffers(): Error Processing TCB! size = %d\n", size);
         pMsg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0;
         pMsg[1] = I2O_UTIL_NOP << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
         /* post to Post Q */   
@@ -632,17 +553,16 @@
 ** =========================================================================
 */
 void 
-RCProcI2OMsgQ(U16 AdapterID)
+RCProcI2OMsgQ(struct net_device *dev)
 {
     U32 phyAddrMsg;
     PU8 p8Msg;
     PU32 p32;
     U16 count;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
     unsigned char debug_msg[20];
     
-    pPab = PCIAdapterBlock[AdapterID];
-    
+
     if (pPab == NULL)
         return;
     
@@ -653,89 +573,66 @@
         p8Msg = pPab->pLinOutMsgBlock + (phyAddrMsg - pPab->outMsgBlockPhyAddr);
         p32 = (PU32)p8Msg;
         
-        //printk(" msg: 0x%x  0x%x \n", p8Msg[7], p32[5]);
+        dprintk("msg: 0x%x  0x%x \n", p8Msg[7], p32[5]);
 
-        /* 
-        ** Send Packet Reply Msg
-        */
-        if (I2O_LAN_PACKET_SEND == p8Msg[7])  /* function code byte */
-        {
+        /* Send Packet Reply Msg */
+        if (I2O_LAN_PACKET_SEND == p8Msg[7]) {  /* function code byte */
             count = *(PU16)(p8Msg+2);
             count -= p8Msg[0] >> 4;
             /* status, count, context[], adapter */
-            (*pPab->pTransCallbackFunc)(p8Msg[19], count, p32+5, AdapterID);
-        }             
-        /* 
-        ** Receive Packet Reply Msg */
-        else if (I2O_LAN_RECEIVE_POST == p8Msg[7])
-        {
-#ifdef DEBUG    
-            kprintf("I2O_RECV_REPLY pPab:0x%08.8ulx p8Msg:0x%08.8ulx p32:0x%08.8ulx\n", pPab, p8Msg, p32);
-            kprintf("msg: 0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n",
-                    p32[0], p32[1], p32[2], p32[3]);
-            kprintf("     0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n",
-                    p32[4], p32[5], p32[6], p32[7]);
-            kprintf("     0x%08.8ulx:0X%08.8ulx:0x%08.8ulx:0x%08.8ulx\n",
-                    p32[8], p32[9], p32[10], p32[11]);
-#endif
-            /*  status, count, buckets remaining, packetParmBlock, adapter */
-            (*pPab->pRecvCallbackFunc)(p8Msg[19], p8Msg[12], p32[5], p32+6, AdapterID);
-      
-      
-        }
-        else if (I2O_LAN_RESET == p8Msg[7] || I2O_LAN_SHUTDOWN == p8Msg[7])
-        {
-            if (pPab->pCallbackFunc)
-            {
-                (*pPab->pCallbackFunc)(p8Msg[19],0,0,AdapterID);
-            }
-            else
-            {
-                pPab->pCallbackFunc = (PFNCALLBACK) 1;
-            }
-            //PCIAdapterBlock[AdapterID] = 0;
-        }
-        else if (I2O_PRIVATE == p8Msg[7])
-        {
-            //printk("i2o private 0x%x, 0x%x \n", p8Msg[7], p32[5]);
+            (*pPab->pTransCallbackFunc)(p8Msg[19], count, p32+5, dev);
+        } else if (I2O_LAN_RECEIVE_POST == p8Msg[7]) { /* Receive Packet Reply Msg */
+		dprintk("I2O_RECV_REPLY pPab:0x%08ulx p8Msg:0x%08ulx p32:0x%08ulx\n", (u32)pPab, (u32)p8Msg, (u32)p32);
+		dprintk("msg: 0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
+			p32[0], p32[1], p32[2], p32[3]);
+		dprintk("     0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
+			p32[4], p32[5], p32[6], p32[7]);
+		dprintk("     0x%08ulx:0X%08ulx:0x%08ulx:0x%08ulx\n",
+			p32[8], p32[9], p32[10], p32[11]);
+		/*  status, count, buckets remaining, packetParmBlock, adapter */
+		(*pPab->pRecvCallbackFunc)(p8Msg[19], p8Msg[12], p32[5], p32+6, dev);      
+        } else if (I2O_LAN_RESET == p8Msg[7] || I2O_LAN_SHUTDOWN == p8Msg[7])
+		if (pPab->pCallbackFunc)
+			(*pPab->pCallbackFunc)(p8Msg[19],0,0,dev);
+		else		
+			pPab->pCallbackFunc = (PFNCALLBACK) 1;
+        else if (I2O_PRIVATE == p8Msg[7]) {
+	    dprintk("i2o private 0x%x, 0x%x \n", p8Msg[7], p32[5]);
             switch (p32[5])
             {
             case RC_PRIVATE_DEBUG_MSG:
                 msgFlag = 1;
-                /*printk("Received I2O_PRIVATE msg\n");*/
-                debug_msg[15]  = (p32[6]&0xff000000) >> 24;
-                debug_msg[14]  = (p32[6]&0x00ff0000) >> 16;
-                debug_msg[13]  = (p32[6]&0x0000ff00) >> 8;
-                debug_msg[12]  = (p32[6]&0x000000ff);
-
-                debug_msg[11]  = (p32[7]&0xff000000) >> 24;
-                debug_msg[10]  = (p32[7]&0x00ff0000) >> 16;
-                debug_msg[ 9]  = (p32[7]&0x0000ff00) >> 8;
-                debug_msg[ 8]  = (p32[7]&0x000000ff);
-
-                debug_msg[ 7]  = (p32[8]&0xff000000) >> 24;
-                debug_msg[ 6]  = (p32[8]&0x00ff0000) >> 16;
+                dprintk("Received I2O_PRIVATE msg\n");
+                debug_msg[15] = (p32[6]&0xff000000) >> 24;
+                debug_msg[14] = (p32[6]&0x00ff0000) >> 16;
+                debug_msg[13] = (p32[6]&0x0000ff00) >> 8;
+                debug_msg[12] = (p32[6]&0x000000ff);
+			      
+                debug_msg[11] = (p32[7]&0xff000000) >> 24;
+                debug_msg[10] = (p32[7]&0x00ff0000) >> 16;
+                debug_msg[ 9] = (p32[7]&0x0000ff00) >> 8;
+                debug_msg[ 8] = (p32[7]&0x000000ff);
+			      
+                debug_msg[ 7] = (p32[8]&0xff000000) >> 24;
+                debug_msg[ 6] = (p32[8]&0x00ff0000) >> 16;
                 debug_msg[ 5] = (p32[8]&0x0000ff00) >> 8;
                 debug_msg[ 4] = (p32[8]&0x000000ff);
-
+			      
                 debug_msg[ 3] = (p32[9]&0xff000000) >> 24;
                 debug_msg[ 2] = (p32[9]&0x00ff0000) >> 16;
                 debug_msg[ 1] = (p32[9]&0x0000ff00) >> 8;
                 debug_msg[ 0] = (p32[9]&0x000000ff);
 
                 debug_msg[16] = '\0';
-                printk (debug_msg);
+                dprintk("%s", debug_msg);
                 break;
             case RC_PRIVATE_REBOOT:
-                printk("Adapter reboot initiated...\n");
+                dprintk("Adapter reboot initiated...\n");
                 if (pPab->pRebootCallbackFunc)
-                {
-                    (*pPab->pRebootCallbackFunc)(0,0,0,AdapterID);
-                }
+                    (*pPab->pRebootCallbackFunc)(0,0,0,dev);
                 break;
             default:
-                printk("Unknown private I2O msg received: 0x%lx\n",
-                       p32[5]);
+                printk(KERN_WARNING "(rcpci45 driver:) Unknown private I2O msg received: 0x%x\n", p32[5]);
                 break;
             }
         }
@@ -744,9 +641,7 @@
         ** Process other Msg's
         */
         else
-        {
             ProcessOutboundI2OMsg(pPab, phyAddrMsg);
-        }
         
         /* return MFA to outbound free Q*/
         pPab->p_atu->OutQueue = phyAddrMsg;
@@ -766,7 +661,7 @@
 ** =========================================================================
 */
 RC_RETURN
-RCGetLinkStatistics(U16 AdapterID, 
+RCGetLinkStatistics(struct net_device *dev, 
                     P_RCLINKSTATS StatsReturnAddr,
                     PFNWAITCALLBACK WaitCallback)
 {
@@ -776,11 +671,10 @@
     volatile PU32 p32, pReturnAddr;
     P_NICSTAT pStats;
     int i;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
-/*kprintf("Get82558Stats() StatsReturnAddr:0x%08.8ulx\n", StatsReturnAddr);*/
 
-    pPab = PCIAdapterBlock[AdapterID];
+/*dprintk("Get82558Stats() StatsReturnAddr:0x%08ulx\n", StatsReturnAddr); */
 
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
@@ -789,28 +683,25 @@
 
     if (msgOffset == 0xFFFFFFFF)
     {
-#ifdef DEBUG
-        kprintf("Get8255XStats(): Inbound Free Q empty!\n");
-#endif
+        dprintk("Get8255XStats(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
     }
 
     /* calc virual address of msg - virual already mapped to physical */
     pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
 
-/*dprintf("Get82558Stats - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
-/*dprintf("Get82558Stats - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
+/*dprintk("Get82558Stats - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
+/*dprintk("Get82558Stats - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
 
     pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
     pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
     pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
     pMsg[3] = 0x112; /* transaction context */
     pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_NIC_STATS;
-    pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); 
-
-    p32 = (PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB));
-
-    pStats = (P_NICSTAT)p32;
+    pMsg[5] = pPab->outMsgBlockPhyAddr;
+    
+    p32 = (PU32) pPab->outMsgBlockPhyAddr;
+    pStats = (P_NICSTAT)pPab->pLinOutMsgBlock;
     pStats->dump_status = 0xFFFFFFFF;
 
     /* post to Inbound Post Q */
@@ -822,17 +713,14 @@
         if (WaitCallback)
             (*WaitCallback)();
         
-        for (i = 0; i < 1000; i++)
-            ;
+	udelay(10);
 
         if (pStats->dump_status != 0xFFFFFFFF)
             break;
 
         if (!timeout--)
         {
-#ifdef DEBUG
-            kprintf("RCGet82558Stats() Timeout waiting for NIC statistics\n");
-#endif
+            dprintk("RCGet82558Stats() Timeout waiting for NIC statistics\n");
             return RC_RTN_MSG_REPLY_TIMEOUT;
         }
     }
@@ -853,17 +741,17 @@
 ** =========================================================================
 */
 RC_RETURN
-RCGetLinkStatus(U16 AdapterID, PU32 ReturnAddr, PFNWAITCALLBACK WaitCallback)
+RCGetLinkStatus(struct net_device *dev, PU32 ReturnAddr, 
+		PFNWAITCALLBACK WaitCallback)
 {
     U32 msgOffset;
     volatile U32 timeout;
     volatile PU32 pMsg;
     volatile PU32 p32;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
-/*kprintf("Get82558LinkStatus() ReturnPhysAddr:0x%08.8ulx\n", ReturnAddr);*/
 
-    pPab = PCIAdapterBlock[AdapterID];
+    dprintk("Get82558LinkStatus() ReturnPhysAddr:0x%08ulx\n", (u32)ReturnAddr);
 
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
@@ -872,49 +760,40 @@
 
     if (msgOffset == 0xFFFFFFFF)
     {
-#ifdef DEBUG
-        dprintf("Get82558LinkStatus(): Inbound Free Q empty!\n");
-#endif
+        dprintk("Get82558LinkStatus(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
     }
 
     /* calc virual address of msg - virual already mapped to physical */
     pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
-/*dprintf("Get82558LinkStatus - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
-/*dprintf("Get82558LinkStatus - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
+/*dprintk("Get82558LinkStatus - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
+/*dprintk("Get82558LinkStatus - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
 
     pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
     pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
     pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
     pMsg[3] = 0x112; /* transaction context */
     pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LINK_STATUS;
-    pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); 
+    pMsg[5] = pPab->outMsgBlockPhyAddr;
 
-    p32 = (PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB));
+    p32 = (PU32)pPab->pLinOutMsgBlock;
     *p32 = 0xFFFFFFFF;
     
     /* post to Inbound Post Q */
     pPab->p_atu->InQueue = msgOffset;
 
     timeout = 100000;
-    while (1)
-    {
-        U32 i;
-
+    while (1) {
         if (WaitCallback)
             (*WaitCallback)();
         
-        for (i = 0; i < 1000; i++)
-            ;
+	udelay(10);
 
         if (*p32 != 0xFFFFFFFF)
             break;
 
-        if (!timeout--)
-        {
-#ifdef DEBUG
-            kprintf("Timeout waiting for link status\n");
-#endif    
+        if (!timeout--) {
+            dprintk("Timeout waiting for link status\n");
             return RC_RTN_MSG_REPLY_TIMEOUT;
         }
     }
@@ -934,17 +813,16 @@
 ** =========================================================================
 */
 RC_RETURN
-RCGetMAC(U16 AdapterID, PU8 mac, PFNWAITCALLBACK WaitCallback)
+RCGetMAC(struct net_device *dev, PFNWAITCALLBACK WaitCallback)
 {
-    unsigned i, timeout;
+    unsigned timeout;
     U32      off;
+    PU8      mac = dev->dev_addr;
     PU32     p;
     U32      temp[2];
-    PPAB     pPab;
+    PPAB     pPab = ((PDPA)dev->priv)->pPab;
     PATU     p_atu;
     
-    pPab = PCIAdapterBlock[AdapterID];
-    
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
     
@@ -960,10 +838,8 @@
 
     p = (PU32)(pPab->pPci45LinBaseAddr + off);
 
-#ifdef RCDEBUG
-    printk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n", 
+    dprintk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n", 
            (uint)p_atu, (uint)off, (uint)p);
-#endif /* RCDEBUG */
     /* setup private message */
     p[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0;
     p[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
@@ -973,10 +849,8 @@
 
 
     p_atu->InQueue = off;   /* send it to the I2O device */
-#ifdef RCDEBUG
-    printk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n", 
+    dprintk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n", 
            (uint)p_atu, (uint)off, (uint)p);
-#endif /* RCDEBUG */
 
     /* wait for the rcpci45 board to update the info */
     timeout = 1000000;
@@ -985,8 +859,7 @@
         if (WaitCallback)
             (*WaitCallback)();
     
-        for (i = 0; i < 1000; i++)
-            ;
+	udelay(10);
 
         if (!timeout--)
         {
@@ -1001,9 +874,7 @@
     memcpy((char *)mac, (char *)temp, 6);
 
 
-#ifdef RCDEBUG
-//    printk("rc_getmac: 0x%X\n", ptr);
-#endif /* RCDEBUG */
+    dprintk("rc_getmac: 0x%x\n", (u32)mac);
 
     return RC_RTN_NO_ERROR;
 }
@@ -1018,15 +889,13 @@
 ** =========================================================================
 */
 RC_RETURN
-RCSetMAC(U16 AdapterID, PU8 mac)
+RCSetMAC(struct net_device *dev, PU8 mac)
 {
     U32  off;
     PU32 pMsg;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
 
-    pPab = PCIAdapterBlock[AdapterID];
-    
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
     
@@ -1067,15 +936,13 @@
 ** =========================================================================
 */
 RC_RETURN
-RCSetLinkSpeed(U16 AdapterID, U16 LinkSpeedCode)
+RCSetLinkSpeed(struct net_device *dev, U16 LinkSpeedCode)
 {
     U32  off;
     PU32 pMsg;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
     
-    pPab =PCIAdapterBlock[AdapterID];
-     
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
     
@@ -1109,14 +976,12 @@
 ** =========================================================================
 */
 RC_RETURN
-RCSetPromiscuousMode(U16 AdapterID, U16 Mode)
+RCSetPromiscuousMode(struct net_device *dev, U16 Mode)
 {
     U32  off;
     PU32 pMsg;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
     
-    pPab =PCIAdapterBlock[AdapterID];
-     
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
     
@@ -1152,22 +1017,20 @@
 ** =========================================================================
 */
 RC_RETURN
-RCGetPromiscuousMode(U16 AdapterID, PU32 pMode, PFNWAITCALLBACK WaitCallback)
+RCGetPromiscuousMode(struct net_device *dev, PU32 pMode, 
+		     PFNWAITCALLBACK WaitCallback)
 {
     U32 msgOffset, timeout;
     PU32 pMsg;
     volatile PU32 p32;
-    PPAB pPab;
-
-    pPab =PCIAdapterBlock[AdapterID];
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
 
     msgOffset = pPab->p_atu->InQueue;
 
-
     if (msgOffset == 0xFFFFFFFF)
     {
-        kprintf("RCGetLinkSpeed(): Inbound Free Q empty!\n");
+	printk(KERN_WARNING "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
     }
 
@@ -1175,7 +1038,7 @@
     pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
 
     /* virtual pointer to return buffer - clear first two dwords */
-    p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB));
+    p32 = (volatile PU32)pPab->pLinOutMsgBlock;
     p32[0] = 0xff;
 
     /* setup private message */
@@ -1185,7 +1048,7 @@
     pMsg[3] = 0x219;             /* transaction context */
     pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_PROMISCUOUS_MODE;
     /* phys address to return status - area right after PAB */
-    pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); 
+    pMsg[5] = pPab->outMsgBlockPhyAddr;
    
     /* post to Inbound Post Q */   
 
@@ -1193,23 +1056,19 @@
 
     /* wait for response */
     timeout = 1000000;
-    while(1)
-    {
-        int i;
-        
+    while(1) {
         if (WaitCallback)
             (*WaitCallback)();
 
-        for (i = 0; i < 1000; i++)      /* please don't hog the bus!!! */
-            ;
-            
+	udelay(10);  /* please don't hog the bus!!! */
+
         if (p32[0] != 0xff)
             break;
             
         if (!timeout--)
         {
-            kprintf("Timeout waiting for promiscuous mode from adapter\n");
-            kprintf("0x%8.8lx\n", p32[0]);
+	    dprintk("Timeout waiting for promiscuous mode from adapter\n");
+            dprintk("0x%8x\n", p32[0]);
             return RC_RTN_NO_LINK_SPEED;
         }
     }
@@ -1230,14 +1089,13 @@
 ** =========================================================================
 */
 RC_RETURN
-RCSetBroadcastMode(U16 AdapterID, U16 Mode)
+RCSetBroadcastMode(struct net_device *dev, U16 Mode)
 {
     U32  off;
     PU32 pMsg;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
     
-    pPab =PCIAdapterBlock[AdapterID];
-     
+
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
     
@@ -1273,22 +1131,20 @@
 ** =========================================================================
 */
 RC_RETURN
-RCGetBroadcastMode(U16 AdapterID, PU32 pMode, PFNWAITCALLBACK WaitCallback)
+RCGetBroadcastMode(struct net_device *dev, PU32 pMode, 
+		   PFNWAITCALLBACK WaitCallback)
 {
     U32 msgOffset, timeout;
     PU32 pMsg;
     volatile PU32 p32;
-    PPAB pPab;
-
-    pPab =PCIAdapterBlock[AdapterID];
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
 
     msgOffset = pPab->p_atu->InQueue;
 
-
     if (msgOffset == 0xFFFFFFFF)
     {
-        kprintf("RCGetLinkSpeed(): Inbound Free Q empty!\n");
+        printk(KERN_WARNING "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
     }
 
@@ -1296,7 +1152,7 @@
     pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
 
     /* virtual pointer to return buffer - clear first two dwords */
-    p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB));
+    p32 = (volatile PU32)pPab->pLinOutMsgBlock;
     p32[0] = 0xff;
 
     /* setup private message */
@@ -1306,7 +1162,7 @@
     pMsg[3] = 0x219;             /* transaction context */
     pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_BROADCAST_MODE;
     /* phys address to return status - area right after PAB */
-    pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); 
+    pMsg[5] = pPab->outMsgBlockPhyAddr;
    
     /* post to Inbound Post Q */   
 
@@ -1314,23 +1170,19 @@
 
     /* wait for response */
     timeout = 1000000;
-    while(1)
-    {
-        int i;
-        
+    while(1) {
         if (WaitCallback)
             (*WaitCallback)();
 
-        for (i = 0; i < 1000; i++)      /* please don't hog the bus!!! */
-            ;
+        udelay(10);      /* please don't hog the bus!!! */
             
         if (p32[0] != 0xff)
             break;
             
         if (!timeout--)
         {
-            kprintf("Timeout waiting for promiscuous mode from adapter\n");
-            kprintf("0x%8.8lx\n", p32[0]);
+            printk(KERN_WARNING "(rcpci45 driver:) Timeout waiting for promiscuous mode from adapter\n");
+            printk(KERN_WARNING "(rcpci45 driver:) 0x%8x\n", p32[0]);
             return RC_RTN_NO_LINK_SPEED;
         }
     }
@@ -1356,23 +1208,21 @@
 ** =========================================================================
 */
 RC_RETURN
-RCGetLinkSpeed(U16 AdapterID, PU32 pLinkSpeedCode, PFNWAITCALLBACK WaitCallback)
+RCGetLinkSpeed(struct net_device *dev, PU32 pLinkSpeedCode, 
+	       PFNWAITCALLBACK WaitCallback)
 {
     U32 msgOffset, timeout;
     PU32 pMsg;
     volatile PU32 p32;
     U8 IOPLinkSpeed;
-    PPAB pPab;
-
-    pPab =PCIAdapterBlock[AdapterID];
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
 
     msgOffset = pPab->p_atu->InQueue;
 
-
     if (msgOffset == 0xFFFFFFFF)
     {
-        kprintf("RCGetLinkSpeed(): Inbound Free Q empty!\n");
+        printk(KERN_WARNING "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
     }
 
@@ -1380,7 +1230,7 @@
     pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
 
     /* virtual pointer to return buffer - clear first two dwords */
-    p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB));
+    p32 = (volatile PU32)pPab->pLinOutMsgBlock;
     p32[0] = 0xff;
 
     /* setup private message */
@@ -1390,7 +1240,7 @@
     pMsg[3] = 0x219;             /* transaction context */
     pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LINK_SPEED;
     /* phys address to return status - area right after PAB */
-    pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); 
+    pMsg[5] = pPab->outMsgBlockPhyAddr;
    
     /* post to Inbound Post Q */   
 
@@ -1398,23 +1248,19 @@
 
     /* wait for response */
     timeout = 1000000;
-    while(1)
-    {
-        int i;
-        
+    while(1) {
         if (WaitCallback)
             (*WaitCallback)();
 
-        for (i = 0; i < 1000; i++)      /* please don't hog the bus!!! */
-            ;
+        udelay(10);      /* please don't hog the bus!!! */
             
         if (p32[0] != 0xff)
             break;
             
         if (!timeout--)
         {
-            kprintf("Timeout waiting for link speed from IOP\n");
-            kprintf("0x%8.8lx\n", p32[0]);
+            dprintk("Timeout waiting for link speed from IOP\n");
+            dprintk("0x%8x\n", p32[0]);
             return RC_RTN_NO_LINK_SPEED;
         }
     }
@@ -1429,7 +1275,7 @@
 
 /*
 ** =========================================================================
-** RCReportDriverCapability(U16 AdapterID, U32 capability)
+** RCReportDriverCapability(struct net_device *dev, U32 capability)
 **
 ** Currently defined bits:
 ** WARM_REBOOT_CAPABLE   0x01
@@ -1437,14 +1283,12 @@
 ** =========================================================================
 */
 RC_RETURN
-RCReportDriverCapability(U16 AdapterID, U32 capability)
+RCReportDriverCapability(struct net_device *dev, U32 capability)
 {
     U32  off;
     PU32 pMsg;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
-    pPab =PCIAdapterBlock[AdapterID];
-     
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
     
@@ -1477,21 +1321,19 @@
 ** =========================================================================
 */
 RC_RETURN
-RCGetFirmwareVer(U16 AdapterID, PU8 pFirmString, PFNWAITCALLBACK WaitCallback)
+RCGetFirmwareVer(struct net_device *dev, PU8 pFirmString, 
+		 PFNWAITCALLBACK WaitCallback)
 {
     U32 msgOffset, timeout;
     PU32 pMsg;
     volatile PU32 p32;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
-    pPab =PCIAdapterBlock[AdapterID];
 
     msgOffset = pPab->p_atu->InQueue;
-
-
     if (msgOffset == 0xFFFFFFFF)
     {
-        kprintf("RCGetFirmwareVer(): Inbound Free Q empty!\n");
+        dprintk("RCGetFirmwareVer(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
     }
 
@@ -1499,7 +1341,7 @@
     pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
 
     /* virtual pointer to return buffer - clear first two dwords */
-    p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB));
+    p32 = (volatile PU32)pPab->pLinOutMsgBlock;
     p32[0] = 0xff;
 
     /* setup private message */
@@ -1509,7 +1351,7 @@
     pMsg[3] = 0x219;             /* transaction context */
     pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_FIRMWARE_REV;
     /* phys address to return status - area right after PAB */
-    pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); 
+    pMsg[5] = pPab->outMsgBlockPhyAddr;
 
 
    
@@ -1520,22 +1362,18 @@
     
     /* wait for response */
     timeout = 1000000;
-    while(1)
-    {
-        int i;
-        
-        if (WaitCallback)
+    while(1) {
+	if (WaitCallback)
             (*WaitCallback)();
             
-        for (i = 0; i < 1000; i++)      /* please don't hog the bus!!! */
-            ;
+        udelay(10);     /* please don't hog the bus!!! */
 
         if (p32[0] != 0xff)
             break;
             
         if (!timeout--)
         {
-            kprintf("Timeout waiting for link speed from IOP\n");
+            dprintk("Timeout waiting for link speed from IOP\n");
             return RC_RTN_NO_FIRM_VER;
         }
     }
@@ -1558,17 +1396,15 @@
 ** =========================================================================
 */
 RC_RETURN 
-RCResetLANCard(U16 AdapterID, U16 ResourceFlags, PU32 ReturnAddr, PFNCALLBACK CallbackFunction)
+RCResetLANCard(struct net_device *dev, U16 ResourceFlags, PU32 ReturnAddr, 
+	       PFNCALLBACK CallbackFunction)
 {
     unsigned long off;
     PU32 pMsg;
-    PPAB pPab;
-    int i;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
     long timeout = 0;
 
     
-    pPab =PCIAdapterBlock[AdapterID];
-     
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
 
@@ -1595,9 +1431,8 @@
            or until timer goes off */
         while (pPab->pCallbackFunc == (PFNCALLBACK)NULL)
         {
-            RCProcI2OMsgQ(AdapterID);
-            for (i = 0; i < 100000; i++)     /* please don't hog the bus!!! */
-                ;
+            RCProcI2OMsgQ(dev);
+            udelay(1000);    /* please don't hog the bus!!! */
             timeout++;
             if (timeout > 10000)
             {
@@ -1619,14 +1454,13 @@
 ** =========================================================================
 */
 RC_RETURN 
-RCResetIOP(U16 AdapterID)
+RCResetIOP(struct net_device *dev)
 {
     U32 msgOffset, timeout;
     PU32 pMsg;
-    PPAB pPab;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
     volatile PU32 p32;
     
-    pPab = PCIAdapterBlock[AdapterID];
     msgOffset = pPab->p_atu->InQueue;
 
     if (msgOffset == 0xFFFFFFFF)
@@ -1644,12 +1478,12 @@
     pMsg[4] = 0; /* universal context */
     pMsg[5] = 0; /* universal context */
     /* phys address to return status - area right after PAB */
-    pMsg[6] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); 
+    pMsg[6] = pPab->outMsgBlockPhyAddr;
     pMsg[7] = 0;
     pMsg[8] = 1;  /*  return 1 byte */
 
     /* virual pointer to return buffer - clear first two dwords */
-    p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB));
+    p32 = (volatile PU32)pPab->pLinOutMsgBlock;
     p32[0] = 0;
     p32[1] = 0;
 
@@ -1659,19 +1493,15 @@
 
     /* wait for response */
     timeout = 1000000;
-    while(1)
-    {
-        int i;
-        
-        for (i = 0; i < 1000; i++)      /* please don't hog the bus!!! */
-            ;
+    while(1) {        
+        udelay(10);     /* please don't hog the bus!!! */
             
         if (p32[0] || p32[1])
             break;
             
         if (!timeout--)
         {
-            printk("RCResetIOP timeout\n");
+            dprintk("RCResetIOP timeout\n");
             return RC_RTN_MSG_REPLY_TIMEOUT;
         }
     }
@@ -1692,16 +1522,14 @@
 ** =========================================================================
 */
 RC_RETURN 
-RCShutdownLANCard(U16 AdapterID, U16 ResourceFlags, PU32 ReturnAddr, PFNCALLBACK CallbackFunction)
+RCShutdownLANCard(struct net_device *dev, U16 ResourceFlags, 
+		  PU32 ReturnAddr, PFNCALLBACK CallbackFunction)
 {
     volatile PU32 pMsg;
     U32 off;
-    PPAB pPab;
-    int i;
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
     long timeout = 0;
 
-    pPab = PCIAdapterBlock[AdapterID];
-
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
 
@@ -1728,13 +1556,12 @@
            or until timer goes off */
         while (pPab->pCallbackFunc == (PFNCALLBACK)NULL)
         {
-            RCProcI2OMsgQ(AdapterID);
-            for (i = 0; i < 100000; i++)     /* please don't hog the bus!!! */
-                ;
+            RCProcI2OMsgQ(dev);
+            udelay(1000);     /* please don't hog the bus!!! */
             timeout++;
             if (timeout > 10000)
             {
-				printk("RCShutdownLANCard(): timeout\n");
+		printk(KERN_WARNING "(rcpci45 driver:) RCShutdownLANCard(): timeout\n");
                 break;
             }
         }
@@ -1758,13 +1585,11 @@
 ** =========================================================================
 */
 RC_RETURN
-RCSetRavlinIPandMask(U16 AdapterID, U32 ipAddr, U32 netMask)
+RCSetRavlinIPandMask(struct net_device *dev, U32 ipAddr, U32 netMask)
 {
     volatile PU32 pMsg;
     U32 off;
-    PPAB pPab;
-
-    pPab = PCIAdapterBlock[AdapterID];
+    PPAB pPab = ((PDPA)dev->priv)->pPab;
 
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
@@ -1800,21 +1625,17 @@
 ** =========================================================================
 */
 RC_RETURN
-RCGetRavlinIPandMask(U16 AdapterID, PU32 pIpAddr, PU32 pNetMask, 
+RCGetRavlinIPandMask(struct net_device *dev, PU32 pIpAddr, PU32 pNetMask, 
                      PFNWAITCALLBACK WaitCallback)
 {
-    unsigned i, timeout;
+    unsigned timeout;
     U32      off;
     PU32     pMsg, p32;
-    PPAB     pPab;
+    PPAB     pPab = ((PDPA)dev->priv)->pPab;
     PATU     p_atu;
     
-#ifdef DEBUG
-    kprintf("RCGetRavlinIPandMask: pIpAddr is 0x%08.8ulx, *IpAddr is 0x%08.8ulx\n", pIpAddr, *pIpAddr);
-#endif /* DEBUG */
+    dprintk("RCGetRavlinIPandMask: pIpAddr is 0x%08ulx, *IpAddr is 0x%08ulx\n", (u32)pIpAddr, *pIpAddr);
 
-    pPab = PCIAdapterBlock[AdapterID];
-    
     if (pPab == NULL)
         return RC_RTN_ADPTR_NOT_REGISTERED;
     
@@ -1824,26 +1645,22 @@
     if (0xFFFFFFFF == off)
         return RC_RTN_FREE_Q_EMPTY;
 
-    p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB));
+    p32 = (volatile PU32)pPab->pLinOutMsgBlock;
     *p32 = 0xFFFFFFFF;
 
     pMsg = (PU32)(pPab->pPci45LinBaseAddr + off);
 
-#ifdef DEBUG
-    kprintf("RCGetRavlinIPandMask: p_atu 0x%08.8ulx, off 0x%08.8ulx, p32 0x%08.8ulx\n", p_atu, off, p32);
-#endif /* DEBUG */
+    dprintk("RCGetRavlinIPandMask: p_atu 0x%08ulx, off 0x%08ulx, p32 0x%08ulx\n", (u32)p_atu, off, (u32)p32);
     /* setup private message */
     pMsg[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0;
     pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
     pMsg[2] = 0;               /* initiator context */
     pMsg[3] = 0x218;           /* transaction context */
     pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_IP_AND_MASK;
-    pMsg[5] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); 
+    pMsg[5] = pPab->outMsgBlockPhyAddr;
 
     p_atu->InQueue = off;   /* send it to the I2O device */
-#ifdef DEBUG
-    kprintf("RCGetRavlinIPandMask: p_atu 0x%08.8ulx, off 0x%08.8ulx, p32 0x%08.8ulx\n", p_atu, off, p32);
-#endif /* DEBUG */
+    dprintk("RCGetRavlinIPandMask: p_atu 0x%08ulx, off 0x%08ulx, p32 0x%08ulx\n", (u32)p_atu, off, (u32)p32);
 
     /* wait for the rcpci45 board to update the info */
     timeout = 100000;
@@ -1851,32 +1668,24 @@
     {
         if (WaitCallback)
             (*WaitCallback)();
-    
-        for (i = 0; i < 1000; i++)
-            ;
+
+	udelay(10);
 
         if (!timeout--)
         {
-#ifdef DEBUG
-            kprintf("RCGetRavlinIPandMask: Timeout\n");
-#endif /* DEBUG */
+            dprintk("RCGetRavlinIPandMask: Timeout\n");
             return RC_RTN_MSG_REPLY_TIMEOUT;
         }
     }
 
-#ifdef DEBUG
-    kprintf("RCGetRavlinIPandMask: after time out\n", \
-            "p32[0] (IpAddr) 0x%08.8ulx, p32[1] (IPmask) 0x%08.8ulx\n", p32[0], p32[1]);
-#endif /* DEBUG */
+    dprintk("RCGetRavlinIPandMask: after time out\np32[0] (IpAddr) 0x%08ulx, p32[1] (IPmask) 0x%08ulx\n", p32[0], p32[1]);
     
     /* send IP and mask to user's space  */
     *pIpAddr  = p32[0];
     *pNetMask = p32[1];
 
 
-#ifdef DEBUG
-    kprintf("RCGetRavlinIPandMask: pIpAddr is 0x%08.8ulx, *IpAddr is 0x%08.8ulx\n", pIpAddr, *pIpAddr);
-#endif /* DEBUG */
+    dprintk("RCGetRavlinIPandMask: pIpAddr is 0x%08ulx, *IpAddr is 0x%08ulx\n", (u32)pIpAddr, *pIpAddr);
 
     return RC_RTN_NO_ERROR;
 }
@@ -1911,9 +1720,7 @@
     
     if (msgOffset == 0xFFFFFFFF)
     {
-#ifdef DEBUG
-        kprintf("SendI2OOutboundQInitMsg(): Inbound Free Q empty!\n");
-#endif /* DEBUG */
+        dprintk("SendI2OOutboundQInitMsg(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
     }
     
@@ -1921,9 +1728,7 @@
     /* calc virual address of msg - virual already mapped to physical */    
     pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
 
-#ifdef DEBUG
-    kprintf("SendI2OOutboundQInitMsg - pMsg = 0x%08.8ulx, InQ msgOffset = 0x%08.8ulx\n", pMsg, msgOffset);
-#endif /* DEBUG */
+    dprintk("SendI2OOutboundQInitMsg - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", (u32)pMsg, msgOffset);
 
     pMsg[0] = EIGHT_WORD_MSG_SIZE | TRL_OFFSET_6;
     pMsg[1] = I2O_EXEC_OUTBOUND_INIT << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
@@ -1933,10 +1738,10 @@
     pMsg[5] = MSG_FRAME_SIZE  << 16 | 0x80; /* outbound msg frame size and Initcode */
     pMsg[6] = 0xD0000004;       /* simple sgl element LE, EOB */
     /* phys address to return status - area right after PAB */
-    pMsg[7] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); 
+    pMsg[7] = pPab->outMsgBlockPhyAddr;
 
     /* virual pointer to return buffer - clear first two dwords */
-    p32 = (PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB));
+    p32 = (PU32)pPab->pLinOutMsgBlock;
     p32[0] = 0;
     
     /* post to Inbound Post Q */   
@@ -1946,17 +1751,14 @@
     timeout = 100000;
     while(1)
     {
-        for (i = 0; i < 1000; i++)      /* please don't hog the bus!!! */
-            ;
+        udelay(10);      /* please don't hog the bus!!! */
             
         if (p32[0])
             break;
             
         if (!timeout--)
         {
-#ifdef DEBUG
-            kprintf("Timeout wait for InitOutQ InPrgress status from IOP\n");
-#endif /* DEBUG */
+            dprintk("Timeout wait for InitOutQ InPrgress status from IOP\n");
             return RC_RTN_NO_I2O_STATUS;
         }
     }
@@ -1964,17 +1766,14 @@
     timeout = 100000;
     while(1)
     {
-        for (i = 0; i < 1000; i++)      /* please don't hog the bus!!! */
-            ;
+	udelay(10);    /* please don't hog the bus!!! */
             
         if (p32[0] == I2O_EXEC_OUTBOUND_INIT_COMPLETE)
             break;
 
         if (!timeout--)
         {
-#ifdef DEBUG
-            kprintf("Timeout wait for InitOutQ Complete status from IOP\n");
-#endif /* DEBUG */
+            dprintk("Timeout wait for InitOutQ Complete status from IOP\n");
             return RC_RTN_NO_I2O_STATUS;
         }
     }
@@ -2008,14 +1807,10 @@
     
     
     msgOffset = pPab->p_atu->InQueue; 
-#ifdef DEBUG
-    printk("GetI2OStatus: msg offset = 0x%x\n", msgOffset);
-#endif /* DEBUG */
+    dprintk("GetI2OStatus: msg offset = 0x%x\n", msgOffset);
     if (msgOffset == 0xFFFFFFFF)
     {
-#ifdef DEBUG
-        kprintf("GetI2OStatus(): Inbound Free Q empty!\n");
-#endif /* DEBUG */
+        dprintk("GetI2OStatus(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
     }
 
@@ -2029,64 +1824,50 @@
     pMsg[4] = 0; /* universal context */
     pMsg[5] = 0; /* universal context */
     /* phys address to return status - area right after PAB */
-    pMsg[6] = pPab->outMsgBlockPhyAddr - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB); 
+    pMsg[6] = pPab->outMsgBlockPhyAddr;
     pMsg[7] = 0;
     pMsg[8] = 88;  /*  return 88 bytes */
 
     /* virual pointer to return buffer - clear first two dwords */
-    p32 = (volatile PU32)(pPab->pLinOutMsgBlock - ADAPTER_BLOCK_RESERVED_SPACE + sizeof(PAB));
+    p32 = (volatile PU32)pPab->pLinOutMsgBlock;
     p32[0] = 0;
     p32[1] = 0;
 
-#ifdef DEBUG
-    kprintf("GetI2OStatus - pMsg:0x%08.8ulx, msgOffset:0x%08.8ulx, [1]:0x%08.8ulx, [6]:0x%08.8ulx\n",
-            pMsg, msgOffset, pMsg[1], pMsg[6]);
-#endif /* DEBUG */
+    dprintk("GetI2OStatus - pMsg:0x%08ulx, msgOffset:0x%08ulx, [1]:0x%08ulx, [6]:0x%08ulx\n",
+            (u32)pMsg, msgOffset, pMsg[1], pMsg[6]);
    
     /* post to Inbound Post Q */   
     pPab->p_atu->InQueue = msgOffset;
     
-#ifdef DEBUG
-    kprintf("Return status to p32 = 0x%08.8ulx\n", p32);
-#endif /* DEBUG */
+    dprintk("Return status to p32 = 0x%08ulx\n", (u32)p32);
     
     /* wait for response */
     timeout = 1000000;
-    while(1)
-    {
-        int i;
-        
-        for (i = 0; i < 1000; i++)      /* please don't hog the bus!!! */
-            ;
+    while(1) {
+        udelay(10);      /* please don't hog the bus!!! */
             
         if (p32[0] && p32[1])
             break;
             
         if (!timeout--)
         {
-#ifdef DEBUG
-            kprintf("Timeout waiting for status from IOP\n");
-            kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[0], p32[1], p32[2], p32[3]);
-            kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[4], p32[5], p32[6], p32[7]);
-            kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[8], p32[9], p32[10], p32[11]);
-#endif /* DEBUG */
+            dprintk("Timeout waiting for status from IOP\n");
+            dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[0], p32[1], p32[2], p32[3]);
+            dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[4], p32[5], p32[6], p32[7]);
+            dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[8], p32[9], p32[10], p32[11]);
             return RC_RTN_NO_I2O_STATUS;
         }
     }
             
-#ifdef DEBUG
-    kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[0], p32[1], p32[2], p32[3]);
-    kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[4], p32[5], p32[6], p32[7]);
-    kprintf("0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[8], p32[9], p32[10], p32[11]);
-#endif /* DEBUG */
+    dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[0], p32[1], p32[2], p32[3]);
+    dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[4], p32[5], p32[6], p32[7]);
+    dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[8], p32[9], p32[10], p32[11]);
     /* get IOP state */
     pPab->IOPState = ((volatile PU8)p32)[10];
     pPab->InboundMFrameSize  = ((volatile PU16)p32)[6];
     
-#ifdef DEBUG
-    kprintf("IOP state 0x%02.2x InFrameSize = 0x%04.4x\n", 
+    dprintk("IOP state 0x%02x InFrameSize = 0x%04x\n", 
             pPab->IOPState, pPab->InboundMFrameSize);
-#endif /* DEBUG */
     return RC_RTN_NO_ERROR;
 }
 
@@ -2101,25 +1882,21 @@
 static int 
 SendEnableSysMsg(PPAB pPab)
 {
-    U32 msgOffset; // timeout;
+    U32 msgOffset; 
     volatile PU32 pMsg;
 
     msgOffset = pPab->p_atu->InQueue;
 
     if (msgOffset == 0xFFFFFFFF)
     {
-#ifdef DEBUG
-        kprintf("SendEnableSysMsg(): Inbound Free Q empty!\n");
-#endif /* DEBUG */
+        dprintk("SendEnableSysMsg(): Inbound Free Q empty!\n");
         return RC_RTN_FREE_Q_EMPTY;
     }
 
     /* calc virual address of msg - virual already mapped to physical */
     pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
 
-#ifdef DEBUG
-    kprintf("SendEnableSysMsg - pMsg = 0x%08.8ulx, InQ msgOffset = 0x%08.8ulx\n", pMsg, msgOffset);
-#endif /* DEBUG */
+    dprintk("SendEnableSysMsg - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", (u32)pMsg, msgOffset);
 
     pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0;
     pMsg[1] = I2O_EXEC_SYS_ENABLE << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
@@ -2160,12 +1937,10 @@
     pMsg = pMsgFrame;
     nmbrDwords = 0;
 
-#ifdef DEBUG
-    kprintf("FillI2OMsgSGLFromTCBX\n");
-    kprintf("TCB  0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n",
+    dprintk("FillI2OMsgSGLFromTCBX\n");
+    dprintk("TCB  0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
             pTCB[0], pTCB[1], pTCB[2], pTCB[3], pTCB[4]);
-    kprintf("pTCB 0x%08.8ulx, pMsg 0x%08.8ulx\n", pTCB, pMsg);
-#endif /* DEBUG */
+    dprintk("pTCB 0x%08ulx, pMsg 0x%08ulx\n", (u32)pTCB, (u32)pMsg);
     
     nmbrBuffers = *pTCB++;
     
@@ -2245,23 +2020,19 @@
 {
     PU8 p8Msg;
     PU32 p32;
-    //  U16 count;
+/*      U16 count; */
     
     
     p8Msg = pPab->pLinOutMsgBlock + (phyAddrMsg - pPab->outMsgBlockPhyAddr);
     p32 = (PU32)p8Msg;
     
-#ifdef DEBUG
-    kprintf("VXD: ProcessOutboundI2OMsg - pPab 0x%08.8ulx, phyAdr 0x%08.8ulx, linAdr 0x%08.8ulx\n", pPab, phyAddrMsg, p8Msg);
-    kprintf("msg :0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[0], p32[1], p32[2], p32[3]);
-    kprintf("msg :0x%08.8ulx:0x%08.8ulx:0x%08.8ulx:0x%08.8ulx\n", p32[4], p32[5], p32[6], p32[7]);
-#endif /* DEBUG */
+    dprintk("VXD: ProcessOutboundI2OMsg - pPab 0x%08ulx, phyAdr 0x%08ulx, linAdr 0x%08ulx\n", (u32)pPab, phyAddrMsg, (u32)p8Msg);
+    dprintk("msg :0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[0], p32[1], p32[2], p32[3]);
+    dprintk("msg :0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[4], p32[5], p32[6], p32[7]);
 
     if (p32[4] >> 24 != I2O_REPLY_STATUS_SUCCESS)
     {
-#ifdef DEBUG
-        kprintf("Message reply status not success\n");
-#endif /* DEBUG */
+        dprintk("Message reply status not success\n");
         return;
     }
     
@@ -2269,36 +2040,26 @@
     {
     case I2O_EXEC_SYS_TAB_SET:
         msgFlag = 1;
-#ifdef DEBUG
-        kprintf("Received I2O_EXEC_SYS_TAB_SET reply\n");
-#endif /* DEBUG */
+        dprintk("Received I2O_EXEC_SYS_TAB_SET reply\n");
         break;
 
     case I2O_EXEC_HRT_GET:
         msgFlag = 1;
-#ifdef DEBUG
-        kprintf("Received I2O_EXEC_HRT_GET reply\n");
-#endif /* DEBUG */
+        dprintk("Received I2O_EXEC_HRT_GET reply\n");
         break;
         
     case I2O_EXEC_LCT_NOTIFY:
         msgFlag = 1;
-#ifdef DEBUG
-        kprintf("Received I2O_EXEC_LCT_NOTIFY reply\n");
-#endif /* DEBUG */
+        dprintk("Received I2O_EXEC_LCT_NOTIFY reply\n");
         break;
         
     case I2O_EXEC_SYS_ENABLE:
         msgFlag = 1;
-#ifdef DEBUG
-        kprintf("Received I2O_EXEC_SYS_ENABLE reply\n");
-#endif /* DEBUG */
+        dprintk("Received I2O_EXEC_SYS_ENABLE reply\n");
         break;
 
     default:    
-#ifdef DEBUG
-        kprintf("Received UNKNOWN reply\n");
-#endif /* DEBUG */
+        dprintk("Received UNKNOWN reply\n");
         break;
     }
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)