fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / net / defxx.c
index cada0c6..dc3ab3b 100644 (file)
@@ -19,7 +19,7 @@
  *   LVS       Lawrence V. Stefani <lstefani@yahoo.com>
  *
  * Maintainers:
- *   macro     Maciej W. Rozycki <macro@ds2.pg.gda.pl>
+ *   macro     Maciej W. Rozycki <macro@linux-mips.org>
  *
  * Credits:
  *   I'd like to thank Patricia Cross for helping me get started with
  *             Feb 2001                        Skb allocation fixes
  *             Feb 2001        davej           PCI enable cleanups.
  *             04 Aug 2003     macro           Converted to the DMA API.
+ *             14 Aug 2004     macro           Fix device names reported.
+ *             14 Jun 2005     macro           Use irqreturn_t.
+ *             23 Oct 2006     macro           Big-endian host support.
  */
 
 /* Include files */
 #include <linux/netdevice.h>
 #include <linux/fddidevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include "defxx.h"
 
-/* Version information string - should be updated prior to each new release!!! */
+/* Version information string should be updated prior to each new release!  */
+#define DRV_NAME "defxx"
+#define DRV_VERSION "v1.09"
+#define DRV_RELDATE "2006/10/23"
 
 static char version[] __devinitdata =
-       "defxx.c:v1.06 2003/08/04  Lawrence V. Stefani and others\n";
+       DRV_NAME ": " DRV_VERSION " " DRV_RELDATE
+       "  Lawrence V. Stefani and others\n";
 
 #define DYNAMIC_BUFFERS 1
 
@@ -233,7 +240,7 @@ static char version[] __devinitdata =
 static void            dfx_bus_init(struct net_device *dev);
 static void            dfx_bus_config_check(DFX_board_t *bp);
 
-static int             dfx_driver_init(struct net_device *dev);
+static int             dfx_driver_init(struct net_device *dev, const char *print_name);
 static int             dfx_adap_init(DFX_board_t *bp, int get_buffers);
 
 static int             dfx_open(struct net_device *dev);
@@ -242,7 +249,7 @@ static int          dfx_close(struct net_device *dev);
 static void            dfx_int_pr_halt_id(DFX_board_t *bp);
 static void            dfx_int_type_0_process(DFX_board_t *bp);
 static void            dfx_int_common(struct net_device *dev);
-static void            dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t     dfx_interrupt(int irq, void *dev_id);
 
 static struct          net_device_stats *dfx_ctl_get_stats(struct net_device *dev);
 static void            dfx_ctl_set_multicast_list(struct net_device *dev);
@@ -268,7 +275,7 @@ static void         dfx_xmt_flush(DFX_board_t *bp);
 
 static struct net_device *root_dfx_eisa_dev;
 
-\f
+
 /*
  * =======================
  * = dfx_port_write_byte =
@@ -276,13 +283,13 @@ static struct net_device *root_dfx_eisa_dev;
  * = dfx_port_write_long =
  * = dfx_port_read_long  =
  * =======================
- *   
+ *
  * Overview:
  *   Routines for reading and writing values from/to adapter
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp     - pointer to board information
  *   offset - register offset from base I/O address
@@ -294,7 +301,7 @@ static struct net_device *root_dfx_eisa_dev;
  * Functional Description:
  *   These routines perform the correct operation to read or write
  *   the adapter register.
- *   
+ *
  *   EISA port block base addresses are based on the slot number in which the
  *   controller is installed.  For example, if the EISA controller is installed
  *   in slot 4, the port block base address is 0x4000.  If the controller is
@@ -370,18 +377,18 @@ static inline void dfx_port_read_long(
        *data = inl(port);
        }
 
-\f
+
 /*
  * =============
  * = dfx_init_one_pci_or_eisa =
  * =============
- *   
+ *
  * Overview:
  *   Initializes a supported FDDI EISA or PCI controller
- *  
+ *
  * Returns:
  *   Condition code
- *       
+ *
  * Arguments:
  *   pdev - pointer to pci device information (NULL for EISA)
  *   ioaddr - pointer to port (NULL for PCI)
@@ -402,24 +409,25 @@ static inline void dfx_port_read_long(
  */
 static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
 {
+       static int version_disp;
+       char *print_name = DRV_NAME;
        struct net_device *dev;
        DFX_board_t       *bp;                  /* board pointer */
        int alloc_size;                         /* total buffer size used */
        int err;
 
-#ifndef MODULE
-       static int version_disp;
-
-       if (!version_disp)      /* display version info if adapter is found */
-       {
+       if (!version_disp) {    /* display version info if adapter is found */
                version_disp = 1;       /* set display flag to TRUE so that */
                printk(version);        /* we only display this string ONCE */
        }
-#endif
+
+       if (pdev != NULL)
+               print_name = pci_name(pdev);
 
        dev = alloc_fddidev(sizeof(*bp));
        if (!dev) {
-               printk (KERN_ERR "defxx: unable to allocate fddidev, aborting\n");
+               printk(KERN_ERR "%s: unable to allocate fddidev, aborting\n",
+                      print_name);
                return -ENOMEM;
        }
 
@@ -431,13 +439,17 @@ static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
        }
 
        SET_MODULE_OWNER(dev);
-       SET_NETDEV_DEV(dev, &pdev->dev);
+       if (pdev != NULL)
+               SET_NETDEV_DEV(dev, &pdev->dev);
 
        bp = dev->priv;
 
-       if (!request_region (ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN, dev->name)) {
-               printk (KERN_ERR "%s: Cannot reserve I/O resource 0x%x @ 0x%lx, aborting\n",
-                       dev->name, PFI_K_CSR_IO_LEN, ioaddr);
+       if (!request_region(ioaddr,
+                           pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN,
+                           print_name)) {
+               printk(KERN_ERR "%s: Cannot reserve I/O resource "
+                      "0x%x @ 0x%lx, aborting\n", print_name,
+                      pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN, ioaddr);
                err = -EBUSY;
                goto err_out;
        }
@@ -466,7 +478,7 @@ static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
                pci_set_master (pdev);
        }
 
-       if (dfx_driver_init(dev) != DFX_K_SUCCESS) {
+       if (dfx_driver_init(dev, print_name) != DFX_K_SUCCESS) {
                err = -ENODEV;
                goto err_out_region;
        }
@@ -475,6 +487,7 @@ static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
        if (err)
                goto err_out_kfree;
 
+       printk("%s: registered as %s\n", print_name, dev->name);
        return 0;
 
 err_out_kfree:
@@ -524,18 +537,18 @@ static int __init dfx_eisa_init(void)
        }
        return rc;
 }
-\f
+
 /*
  * ================
  * = dfx_bus_init =
  * ================
- *   
+ *
  * Overview:
  *   Initializes EISA and PCI controller bus-specific logic.
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   dev - pointer to device information
  *
@@ -659,19 +672,19 @@ static void __devinit dfx_bus_init(struct net_device *dev)
                }
        }
 
-\f
+
 /*
  * ========================
  * = dfx_bus_config_check =
  * ========================
- *   
+ *
  * Overview:
  *   Checks the configuration (burst size, full-duplex, etc.)  If any parameters
  *   are illegal, then this routine will set new defaults.
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -753,21 +766,22 @@ static void __devinit dfx_bus_config_check(DFX_board_t *bp)
                }
        }
 
-\f
+
 /*
  * ===================
  * = dfx_driver_init =
  * ===================
- *   
+ *
  * Overview:
  *   Initializes remaining adapter board structure information
  *   and makes sure adapter is in a safe state prior to dfx_open().
- *  
+ *
  * Returns:
  *   Condition code
- *       
+ *
  * Arguments:
  *   dev - pointer to device information
+ *   print_name - printable device name
  *
  * Functional Description:
  *   This function allocates additional resources such as the host memory
@@ -790,7 +804,8 @@ static void __devinit dfx_bus_config_check(DFX_board_t *bp)
  *   returning from this routine.
  */
 
-static int __devinit dfx_driver_init(struct net_device *dev)
+static int __devinit dfx_driver_init(struct net_device *dev,
+                                    const char *print_name)
 {
        DFX_board_t *bp = dev->priv;
        int                     alloc_size;                     /* total buffer size needed */
@@ -839,26 +854,22 @@ static int __devinit dfx_driver_init(struct net_device *dev)
 
        /*  Read the factory MAC address from the adapter then save it */
 
-       if (dfx_hw_port_ctrl_req(bp,
-                                                       PI_PCTRL_M_MLA,
-                                                       PI_PDATA_A_MLA_K_LO,
-                                                       0,
-                                                       &data) != DFX_K_SUCCESS)
-               {
-               printk("%s: Could not read adapter factory MAC address!\n", dev->name);
+       if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_LO, 0,
+                                &data) != DFX_K_SUCCESS) {
+               printk("%s: Could not read adapter factory MAC address!\n",
+                      print_name);
                return(DFX_K_FAILURE);
-               }
+       }
+       data = cpu_to_le32(data);
        memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32));
 
-       if (dfx_hw_port_ctrl_req(bp,
-                                                       PI_PCTRL_M_MLA,
-                                                       PI_PDATA_A_MLA_K_HI,
-                                                       0,
-                                                       &data) != DFX_K_SUCCESS)
-               {
-               printk("%s: Could not read adapter factory MAC address!\n", dev->name);
+       if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0,
+                                &data) != DFX_K_SUCCESS) {
+               printk("%s: Could not read adapter factory MAC address!\n",
+                      print_name);
                return(DFX_K_FAILURE);
-               }
+       }
+       data = cpu_to_le32(data);
        memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16));
 
        /*
@@ -870,27 +881,19 @@ static int __devinit dfx_driver_init(struct net_device *dev)
 
        memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN);
        if (bp->bus_type == DFX_BUS_TYPE_EISA)
-               printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
-                               dev->name,
-                               dev->base_addr,
-                               dev->irq,
-                               dev->dev_addr[0],
-                               dev->dev_addr[1],
-                               dev->dev_addr[2],
-                               dev->dev_addr[3],
-                               dev->dev_addr[4],
-                               dev->dev_addr[5]);
+               printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, "
+                      "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
+                      print_name, dev->base_addr, dev->irq,
+                      dev->dev_addr[0], dev->dev_addr[1],
+                      dev->dev_addr[2], dev->dev_addr[3],
+                      dev->dev_addr[4], dev->dev_addr[5]);
        else
-               printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
-                               dev->name,
-                               dev->base_addr,
-                               dev->irq,
-                               dev->dev_addr[0],
-                               dev->dev_addr[1],
-                               dev->dev_addr[2],
-                               dev->dev_addr[3],
-                               dev->dev_addr[4],
-                               dev->dev_addr[5]);
+               printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, "
+                      "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
+                      print_name, dev->base_addr, dev->irq,
+                      dev->dev_addr[0], dev->dev_addr[1],
+                      dev->dev_addr[2], dev->dev_addr[3],
+                      dev->dev_addr[4], dev->dev_addr[5]);
 
        /*
         * Get memory for descriptor block, consumer block, and other buffers
@@ -907,11 +910,11 @@ static int __devinit dfx_driver_init(struct net_device *dev)
                                        (PI_ALIGN_K_DESC_BLK - 1);
        bp->kmalloced = top_v = pci_alloc_consistent(bp->pci_dev, alloc_size,
                                                     &bp->kmalloced_dma);
-       if (top_v == NULL)
-               {
-               printk("%s: Could not allocate memory for host buffers and structures!\n", dev->name);
+       if (top_v == NULL) {
+               printk("%s: Could not allocate memory for host buffers "
+                      "and structures!\n", print_name);
                return(DFX_K_FAILURE);
-               }
+       }
        memset(top_v, 0, alloc_size);   /* zero out memory before continuing */
        top_p = bp->kmalloced_dma;      /* get physical address of buffer */
 
@@ -968,27 +971,33 @@ static int __devinit dfx_driver_init(struct net_device *dev)
 
        /* Display virtual and physical addresses if debug driver */
 
-       DBG_printk("%s: Descriptor block virt = %0lX, phys = %0X\n",                            dev->name, (long)bp->descr_block_virt,  bp->descr_block_phys);
-       DBG_printk("%s: Command Request buffer virt = %0lX, phys = %0X\n",                      dev->name, (long)bp->cmd_req_virt,              bp->cmd_req_phys);
-       DBG_printk("%s: Command Response buffer virt = %0lX, phys = %0X\n",                     dev->name, (long)bp->cmd_rsp_virt,              bp->cmd_rsp_phys);
-       DBG_printk("%s: Receive buffer block virt = %0lX, phys = %0X\n",                        dev->name, (long)bp->rcv_block_virt,    bp->rcv_block_phys);
-       DBG_printk("%s: Consumer block virt = %0lX, phys = %0X\n",                              dev->name, (long)bp->cons_block_virt,   bp->cons_block_phys);
+       DBG_printk("%s: Descriptor block virt = %0lX, phys = %0X\n",
+                  print_name,
+                  (long)bp->descr_block_virt, bp->descr_block_phys);
+       DBG_printk("%s: Command Request buffer virt = %0lX, phys = %0X\n",
+                  print_name, (long)bp->cmd_req_virt, bp->cmd_req_phys);
+       DBG_printk("%s: Command Response buffer virt = %0lX, phys = %0X\n",
+                  print_name, (long)bp->cmd_rsp_virt, bp->cmd_rsp_phys);
+       DBG_printk("%s: Receive buffer block virt = %0lX, phys = %0X\n",
+                  print_name, (long)bp->rcv_block_virt, bp->rcv_block_phys);
+       DBG_printk("%s: Consumer block virt = %0lX, phys = %0X\n",
+                  print_name, (long)bp->cons_block_virt, bp->cons_block_phys);
 
        return(DFX_K_SUCCESS);
-       }
+}
+
 
-\f
 /*
  * =================
  * = dfx_adap_init =
  * =================
- *   
+ *
  * Overview:
  *   Brings the adapter to the link avail/link unavailable state.
- *  
+ *
  * Returns:
  *   Condition code
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *   get_buffers - non-zero if buffers to be allocated
@@ -1079,27 +1088,23 @@ static int dfx_adap_init(DFX_board_t *bp, int get_buffers)
                }
 
        /*
-        * Set base address of Descriptor Block and bring adapter to DMA_AVAILABLE state
+        * Set the base address of Descriptor Block and bring adapter
+        * to DMA_AVAILABLE state.
         *
-        * Note: We also set the literal and data swapping requirements in this
-        *           command.  Since this driver presently runs on Intel platforms
-        *               which are Little Endian, we'll tell the adapter to byte swap
-        *               data only.  This code will need to change when we support
-        *               Big Endian systems (eg. PowerPC).
+        * Note: We also set the literal and data swapping requirements
+        *       in this command.
         *
-        * Assumption: 32-bit physical address of descriptor block is 8Kbyte
-        *             aligned.  That is, bits 0-12 of the address must be zero.
+        * Assumption: 32-bit physical address of descriptor block
+        *       is 8Kbyte aligned.
         */
-
-       if (dfx_hw_port_ctrl_req(bp,
-                                                       PI_PCTRL_M_INIT,
-                                                       (u32) (bp->descr_block_phys | PI_PDATA_A_INIT_M_BSWAP_DATA),
-                                                       0,
-                                                       NULL) != DFX_K_SUCCESS)
-               {
-               printk("%s: Could not set descriptor block address!\n", bp->dev->name);
-               return(DFX_K_FAILURE);
-               }
+       if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_INIT,
+                                (u32)(bp->descr_block_phys |
+                                      PI_PDATA_A_INIT_M_BSWAP_INIT),
+                                0, NULL) != DFX_K_SUCCESS) {
+               printk("%s: Could not set descriptor block address!\n",
+                      bp->dev->name);
+               return DFX_K_FAILURE;
+       }
 
        /* Set transmit flush timeout value */
 
@@ -1181,18 +1186,18 @@ static int dfx_adap_init(DFX_board_t *bp, int get_buffers)
        return(DFX_K_SUCCESS);
        }
 
-\f
+
 /*
  * ============
  * = dfx_open =
  * ============
- *   
+ *
  * Overview:
  *   Opens the adapter
- *  
+ *
  * Returns:
  *   Condition code
- *       
+ *
  * Arguments:
  *   dev - pointer to device information
  *
@@ -1218,10 +1223,10 @@ static int dfx_open(struct net_device *dev)
        DFX_board_t     *bp = dev->priv;
 
        DBG_printk("In dfx_open...\n");
-       
+
        /* Register IRQ - support shared interrupts by passing device ptr */
 
-       ret = request_irq(dev->irq, (void *)dfx_interrupt, SA_SHIRQ, dev->name, dev);
+       ret = request_irq(dev->irq, dfx_interrupt, IRQF_SHARED, dev->name, dev);
        if (ret) {
                printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq);
                return ret;
@@ -1269,18 +1274,18 @@ static int dfx_open(struct net_device *dev)
        return(0);
 }
 
-\f
+
 /*
  * =============
  * = dfx_close =
  * =============
- *   
+ *
  * Overview:
  *   Closes the device/module.
- *  
+ *
  * Returns:
  *   Condition code
- *       
+ *
  * Arguments:
  *   dev - pointer to device information
  *
@@ -1353,26 +1358,26 @@ static int dfx_close(struct net_device *dev)
        /* Clear device structure flags */
 
        netif_stop_queue(dev);
-       
+
        /* Deregister (free) IRQ */
 
        free_irq(dev->irq, dev);
-       
+
        return(0);
 }
 
-\f
+
 /*
  * ======================
  * = dfx_int_pr_halt_id =
  * ======================
- *   
+ *
  * Overview:
  *   Displays halt id's in string form.
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -1445,18 +1450,18 @@ static void dfx_int_pr_halt_id(DFX_board_t      *bp)
                }
        }
 
-\f
+
 /*
  * ==========================
  * = dfx_int_type_0_process =
  * ==========================
- *   
+ *
  * Overview:
  *   Processes Type 0 interrupts.
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -1562,7 +1567,7 @@ static void dfx_int_type_0_process(DFX_board_t    *bp)
        /* Check for adapter state change */
 
        if (type_0_status & PI_TYPE_0_STAT_M_STATE_CHANGE)
-               {                     
+               {
                /* Get latest adapter state */
 
                state = dfx_hw_adap_state_rd(bp);       /* get adapter state */
@@ -1597,18 +1602,18 @@ static void dfx_int_type_0_process(DFX_board_t  *bp)
                }
        }
 
-\f
+
 /*
  * ==================
  * = dfx_int_common =
  * ==================
- *   
+ *
  * Overview:
  *   Interrupt service routine (ISR)
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -1671,22 +1676,21 @@ static void dfx_int_common(struct net_device *dev)
                dfx_int_type_0_process(bp);     /* process Type 0 interrupts */
        }
 
-\f
+
 /*
  * =================
  * = dfx_interrupt =
  * =================
- *   
+ *
  * Overview:
  *   Interrupt processing routine
- *  
+ *
  * Returns:
- *   None
- *       
+ *   Whether a valid interrupt was seen.
+ *
  * Arguments:
  *   irq       - interrupt vector
  *   dev_id    - pointer to device information
- *      regs   - pointer to registers structure
  *
  * Functional Description:
  *   This routine calls the interrupt processing routine for this adapter.  It
@@ -1695,7 +1699,8 @@ static void dfx_int_common(struct net_device *dev)
  *   structure context.
  *
  * Return Codes:
- *   None
+ *   IRQ_HANDLED - an IRQ was handled.
+ *   IRQ_NONE    - no IRQ was handled.
  *
  * Assumptions:
  *   The interrupt acknowledgement at the hardware level (eg. ACKing the PIC
@@ -1708,72 +1713,82 @@ static void dfx_int_common(struct net_device *dev)
  *   Interrupts are disabled, then reenabled at the adapter.
  */
 
-static void dfx_interrupt(int irq, void *dev_id, struct pt_regs        *regs)
-       {
+static irqreturn_t dfx_interrupt(int irq, void *dev_id)
+{
        struct net_device       *dev = dev_id;
        DFX_board_t             *bp;    /* private board structure pointer */
-       u8                              tmp;    /* used for disabling/enabling ints */
 
        /* Get board pointer only if device structure is valid */
 
        bp = dev->priv;
 
-       spin_lock(&bp->lock);
-       
        /* See if we're already servicing an interrupt */
 
        /* Service adapter interrupts */
 
-       if (bp->bus_type == DFX_BUS_TYPE_PCI)
-               {
-               /* Disable PDQ-PFI interrupts at PFI */
+       if (bp->bus_type == DFX_BUS_TYPE_PCI) {
+               u32 status;
 
-               dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, PFI_MODE_M_DMA_ENB);
+               dfx_port_read_long(bp, PFI_K_REG_STATUS, &status);
+               if (!(status & PFI_STATUS_M_PDQ_INT))
+                       return IRQ_NONE;
 
-               /* Call interrupt service routine for this adapter */
+               spin_lock(&bp->lock);
 
+               /* Disable PDQ-PFI interrupts at PFI */
+               dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL,
+                                   PFI_MODE_M_DMA_ENB);
+
+               /* Call interrupt service routine for this adapter */
                dfx_int_common(dev);
 
                /* Clear PDQ interrupt status bit and reenable interrupts */
-
-               dfx_port_write_long(bp, PFI_K_REG_STATUS, PFI_STATUS_M_PDQ_INT);
+               dfx_port_write_long(bp, PFI_K_REG_STATUS,
+                                   PFI_STATUS_M_PDQ_INT);
                dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL,
-                                       (PFI_MODE_M_PDQ_INT_ENB + PFI_MODE_M_DMA_ENB));
-               }
-       else
-               {
-               /* Disable interrupts at the ESIC */
+                                   (PFI_MODE_M_PDQ_INT_ENB |
+                                    PFI_MODE_M_DMA_ENB));
+
+               spin_unlock(&bp->lock);
+       } else {
+               u8 status;
 
-               dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp);
-               tmp &= ~PI_CONFIG_STAT_0_M_INT_ENB;
-               dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp);
+               dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status);
+               if (!(status & PI_CONFIG_STAT_0_M_PEND))
+                       return IRQ_NONE;
 
-               /* Call interrupt service routine for this adapter */
+               spin_lock(&bp->lock);
+
+               /* Disable interrupts at the ESIC */
+               status &= ~PI_CONFIG_STAT_0_M_INT_ENB;
+               dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, status);
 
+               /* Call interrupt service routine for this adapter */
                dfx_int_common(dev);
 
                /* Reenable interrupts at the ESIC */
+               dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status);
+               status |= PI_CONFIG_STAT_0_M_INT_ENB;
+               dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, status);
 
-               dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp);
-               tmp |= PI_CONFIG_STAT_0_M_INT_ENB;
-               dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp);
-               }
-
-       spin_unlock(&bp->lock);
+               spin_unlock(&bp->lock);
        }
 
-\f
+       return IRQ_HANDLED;
+}
+
+
 /*
  * =====================
  * = dfx_ctl_get_stats =
  * =====================
- *   
+ *
  * Overview:
  *   Get statistics for FDDI adapter
- *  
+ *
  * Returns:
  *   Pointer to FDDI statistics structure
- *       
+ *
  * Arguments:
  *   dev - pointer to device information
  *
@@ -1812,16 +1827,18 @@ static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev)
 
        /* Fill the bp->stats structure with driver-maintained counters */
 
-       bp->stats.rx_packets                    = bp->rcv_total_frames;
-       bp->stats.tx_packets                    = bp->xmt_total_frames;
-       bp->stats.rx_bytes                      = bp->rcv_total_bytes;
-       bp->stats.tx_bytes                      = bp->xmt_total_bytes;
-       bp->stats.rx_errors                             = (u32)(bp->rcv_crc_errors + bp->rcv_frame_status_errors + bp->rcv_length_errors);
-       bp->stats.tx_errors                             = bp->xmt_length_errors;
-       bp->stats.rx_dropped                    = bp->rcv_discards;
-       bp->stats.tx_dropped                    = bp->xmt_discards;
-       bp->stats.multicast                             = bp->rcv_multicast_frames;
-       bp->stats.transmit_collision    = 0;    /* always zero (0) for FDDI */
+       bp->stats.gen.rx_packets = bp->rcv_total_frames;
+       bp->stats.gen.tx_packets = bp->xmt_total_frames;
+       bp->stats.gen.rx_bytes   = bp->rcv_total_bytes;
+       bp->stats.gen.tx_bytes   = bp->xmt_total_bytes;
+       bp->stats.gen.rx_errors  = bp->rcv_crc_errors +
+                                  bp->rcv_frame_status_errors +
+                                  bp->rcv_length_errors;
+       bp->stats.gen.tx_errors  = bp->xmt_length_errors;
+       bp->stats.gen.rx_dropped = bp->rcv_discards;
+       bp->stats.gen.tx_dropped = bp->xmt_discards;
+       bp->stats.gen.multicast  = bp->rcv_multicast_frames;
+       bp->stats.gen.collisions = 0;           /* always zero (0) for FDDI */
 
        /* Get FDDI SMT MIB objects */
 
@@ -1947,19 +1964,19 @@ static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev)
        return((struct net_device_stats *) &bp->stats);
        }
 
-\f
+
 /*
  * ==============================
  * = dfx_ctl_set_multicast_list =
  * ==============================
- *   
+ *
  * Overview:
  *   Enable/Disable LLC frame promiscuous mode reception
  *   on the adapter and/or update multicast address table.
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   dev - pointer to device information
  *
@@ -2068,19 +2085,19 @@ static void dfx_ctl_set_multicast_list(struct net_device *dev)
                }
        }
 
-\f
+
 /*
  * ===========================
  * = dfx_ctl_set_mac_address =
  * ===========================
- *   
+ *
  * Overview:
  *   Add node address override (unicast address) to adapter
  *   CAM and update dev_addr field in device table.
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   dev  - pointer to device information
  *   addr - pointer to sockaddr structure containing unicast address to add
@@ -2158,7 +2175,7 @@ static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr)
        return(0);                      /* always return zero */
        }
 
-\f
+
 /*
  * ======================
  * = dfx_ctl_update_cam =
@@ -2243,7 +2260,7 @@ static int dfx_ctl_update_cam(DFX_board_t *bp)
        return(DFX_K_SUCCESS);
        }
 
-\f
+
 /*
  * ==========================
  * = dfx_ctl_update_filters =
@@ -2252,10 +2269,10 @@ static int dfx_ctl_update_cam(DFX_board_t *bp)
  * Overview:
  *   Procedure to update adapter filters with desired
  *   filter settings.
- *  
+ *
  * Returns:
  *   Condition code
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -2309,18 +2326,18 @@ static int dfx_ctl_update_filters(DFX_board_t *bp)
        return(DFX_K_SUCCESS);
        }
 
-\f
+
 /*
  * ======================
  * = dfx_hw_dma_cmd_req =
  * ======================
- *   
+ *
  * Overview:
  *   Sends PDQ DMA command to adapter firmware
- *  
+ *
  * Returns:
  *   Condition code
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -2354,9 +2371,9 @@ static int dfx_hw_dma_cmd_req(DFX_board_t *bp)
        {
        int status;                     /* adapter status */
        int timeout_cnt;        /* used in for loops */
-       
+
        /* Make sure the adapter is in a state that we can issue the DMA command in */
-       
+
        status = dfx_hw_adap_state_rd(bp);
        if ((status == PI_STATE_K_RESET)                ||
                (status == PI_STATE_K_HALTED)           ||
@@ -2377,7 +2394,7 @@ static int dfx_hw_dma_cmd_req(DFX_board_t *bp)
        dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_RSP_PROD, bp->cmd_rsp_reg.lword);
 
        /* Put request buffer on the command request queue */
-       
+
        bp->descr_block_virt->cmd_req[bp->cmd_req_reg.index.prod].long_0 = (u32) (PI_XMT_DESCR_M_SOP |
                        PI_XMT_DESCR_M_EOP | (PI_CMD_REQ_K_SIZE_MAX << PI_XMT_DESCR_V_SEG_LEN));
        bp->descr_block_virt->cmd_req[bp->cmd_req_reg.index.prod].long_1 = bp->cmd_req_phys;
@@ -2399,7 +2416,7 @@ static int dfx_hw_dma_cmd_req(DFX_board_t *bp)
                        break;
                udelay(100);                    /* wait for 100 microseconds */
                }
-       if (timeout_cnt == 0) 
+       if (timeout_cnt == 0)
                return(DFX_K_HW_TIMEOUT);
 
        /* Bump (and wrap) the completion index and write out to register */
@@ -2419,7 +2436,7 @@ static int dfx_hw_dma_cmd_req(DFX_board_t *bp)
                        break;
                udelay(100);                    /* wait for 100 microseconds */
                }
-       if (timeout_cnt == 0) 
+       if (timeout_cnt == 0)
                return(DFX_K_HW_TIMEOUT);
 
        /* Bump (and wrap) the completion index and write out to register */
@@ -2430,18 +2447,18 @@ static int dfx_hw_dma_cmd_req(DFX_board_t *bp)
        return(DFX_K_SUCCESS);
        }
 
-\f
+
 /*
  * ========================
  * = dfx_hw_port_ctrl_req =
  * ========================
- *   
+ *
  * Overview:
  *   Sends PDQ port control command to adapter firmware
- *  
+ *
  * Returns:
  *   Host data register value in host_data if ptr is not NULL
- *       
+ *
  * Arguments:
  *   bp                        - pointer to board information
  *      command        - port control command
@@ -2477,7 +2494,7 @@ static int dfx_hw_port_ctrl_req(
        int                     timeout_cnt;    /* used in for loops */
 
        /* Set Command Error bit in command longword */
-       
+
        port_cmd = (PI_UINT32) (command | PI_PCTRL_M_CMD_ERROR);
 
        /* Issue port command to the adapter */
@@ -2500,12 +2517,12 @@ static int dfx_hw_port_ctrl_req(
                        break;
                udelay(100);                    /* wait for 100 microseconds */
                }
-       if (timeout_cnt == 0) 
+       if (timeout_cnt == 0)
                return(DFX_K_HW_TIMEOUT);
 
        /*
-        * If the address of host_data is non-zero, assume caller has supplied a  
-        * non NULL pointer, and return the contents of the HOST_DATA register in 
+        * If the address of host_data is non-zero, assume caller has supplied a
+        * non NULL pointer, and return the contents of the HOST_DATA register in
         * it.
         */
 
@@ -2514,18 +2531,18 @@ static int dfx_hw_port_ctrl_req(
        return(DFX_K_SUCCESS);
        }
 
-\f
+
 /*
  * =====================
  * = dfx_hw_adap_reset =
  * =====================
- *   
+ *
  * Overview:
  *   Resets adapter
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp   - pointer to board information
  *   type - type of reset to perform
@@ -2568,18 +2585,18 @@ static void dfx_hw_adap_reset(
        dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_RESET, 0);
        }
 
-\f
+
 /*
  * ========================
  * = dfx_hw_adap_state_rd =
  * ========================
- *   
+ *
  * Overview:
  *   Returns current adapter state
- *  
+ *
  * Returns:
  *   Adapter state per PDQ Port Specification
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -2604,18 +2621,18 @@ static int dfx_hw_adap_state_rd(DFX_board_t *bp)
        return((port_status & PI_PSTATUS_M_STATE) >> PI_PSTATUS_V_STATE);
        }
 
-\f
+
 /*
  * =====================
  * = dfx_hw_dma_uninit =
  * =====================
- *   
+ *
  * Overview:
  *   Brings adapter to DMA_UNAVAILABLE state
- *  
+ *
  * Returns:
  *   Condition code
- *       
+ *
  * Arguments:
  *   bp   - pointer to board information
  *   type - type of reset to perform
@@ -2652,38 +2669,38 @@ static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type)
                        break;
                udelay(100);                                    /* wait for 100 microseconds */
                }
-       if (timeout_cnt == 0) 
+       if (timeout_cnt == 0)
                return(DFX_K_HW_TIMEOUT);
        return(DFX_K_SUCCESS);
        }
-\f
+
 /*
  *     Align an sk_buff to a boundary power of 2
  *
  */
+
 static void my_skb_align(struct sk_buff *skb, int n)
 {
-       unsigned long x=(unsigned long)skb->data;       
+       unsigned long x = (unsigned long)skb->data;
        unsigned long v;
-       
-       v=(x+n-1)&~(n-1);       /* Where we want to be */
-       
-       skb_reserve(skb, v-x);
+
+       v = ALIGN(x, n);        /* Where we want to be */
+
+       skb_reserve(skb, v - x);
 }
 
-\f
+
 /*
  * ================
  * = dfx_rcv_init =
  * ================
- *   
+ *
  * Overview:
  *   Produces buffers to adapter LLC Host receive descriptor block
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *   get_buffers - non-zero if buffers to be allocated
@@ -2744,7 +2761,7 @@ static int dfx_rcv_init(DFX_board_t *bp, int get_buffers)
                         * align to 128 bytes for compatibility with
                         * the old EISA boards.
                         */
-                        
+
                        my_skb_align(newskb, 128);
                        bp->descr_block_virt->rcv_data[i + j].long_1 =
                                (u32)pci_map_single(bp->pci_dev, newskb->data,
@@ -2775,18 +2792,18 @@ static int dfx_rcv_init(DFX_board_t *bp, int get_buffers)
        return 0;
        }
 
-\f
+
 /*
  * =========================
  * = dfx_rcv_queue_process =
  * =========================
- *   
+ *
  * Overview:
  *   Process received LLC frames.
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -2860,7 +2877,7 @@ static void dfx_rcv_queue_process(
                                        newskb = dev_alloc_skb(NEW_SKB_SIZE);
                                        if (newskb){
                                                rx_in_place = 1;
-                                               
+
                                                my_skb_align(newskb, 128);
                                                skb = (struct sk_buff *)bp->p_rcv_buff_va[entry];
                                                pci_unmap_single(bp->pci_dev,
@@ -2894,7 +2911,7 @@ static void dfx_rcv_queue_process(
 
                                                memcpy(skb->data, p_buff + RCV_BUFF_K_PADDING, pkt_len+3);
                                        }
-                                       
+
                                        skb_reserve(skb,3);             /* adjust data field so that it points to FC byte */
                                        skb_put(skb, pkt_len);          /* pass up packet length, NOT including CRC */
                                        skb->dev = bp->dev;             /* pass up device pointer */
@@ -2925,18 +2942,18 @@ static void dfx_rcv_queue_process(
                }
        }
 
-\f
+
 /*
  * =====================
  * = dfx_xmt_queue_pkt =
  * =====================
- *   
+ *
  * Overview:
  *   Queues packets for transmission
- *  
+ *
  * Returns:
  *   Condition code
- *       
+ *
  * Arguments:
  *   skb - pointer to sk_buff to queue for transmission
  *   dev - pointer to device information
@@ -3000,7 +3017,7 @@ static int dfx_xmt_queue_pkt(
        unsigned long           flags;
 
        netif_stop_queue(dev);
-       
+
        /*
         * Verify that incoming transmit request is OK
         *
@@ -3012,7 +3029,7 @@ static int dfx_xmt_queue_pkt(
 
        if (!IN_RANGE(skb->len, FDDI_K_LLC_ZLEN, FDDI_K_LLC_LEN))
        {
-               printk("%s: Invalid packet length - %u bytes\n", 
+               printk("%s: Invalid packet length - %u bytes\n",
                        dev->name, skb->len);
                bp->xmt_length_errors++;                /* bump error counter */
                netif_wake_queue(dev);
@@ -3045,7 +3062,7 @@ static int dfx_xmt_queue_pkt(
                }
 
        spin_lock_irqsave(&bp->lock, flags);
-       
+
        /* Get the current producer and the next free xmt data descriptor */
 
        prod            = bp->rcv_xmt_reg.index.xmt_prod;
@@ -3147,18 +3164,18 @@ static int dfx_xmt_queue_pkt(
        return(0);                                                      /* packet queued to adapter */
        }
 
-\f
+
 /*
  * ================
  * = dfx_xmt_done =
  * ================
- *   
+ *
  * Overview:
  *   Processes all frames that have been transmitted.
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -3226,18 +3243,18 @@ static int dfx_xmt_done(DFX_board_t *bp)
        return freed;
        }
 
-\f
+
 /*
  * =================
  * = dfx_rcv_flush =
  * =================
- *   
+ *
  * Overview:
  *   Remove all skb's in the receive ring.
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -3279,14 +3296,14 @@ static inline void dfx_rcv_flush( DFX_board_t *bp )
  * =================
  * = dfx_xmt_flush =
  * =================
- *   
+ *
  * Overview:
  *   Processes all frames whether they've been transmitted
  *   or not.
- *  
+ *
  * Returns:
  *   None
- *       
+ *
  * Arguments:
  *   bp - pointer to board information
  *
@@ -3424,18 +3441,13 @@ static int __init dfx_init(void)
 {
        int rc_pci, rc_eisa;
 
-/* when a module, this is printed whether or not devices are found in probe */
-#ifdef MODULE
-       printk(version);
-#endif
-
-       rc_pci = pci_module_init(&dfx_driver);
+       rc_pci = pci_register_driver(&dfx_driver);
        if (rc_pci >= 0) dfx_have_pci = 1;
-       
+
        rc_eisa = dfx_eisa_init();
        if (rc_eisa >= 0) dfx_have_eisa = 1;
 
-       return ((rc_eisa < 0) ? 0 : rc_eisa)  + ((rc_pci < 0) ? 0 : rc_pci); 
+       return ((rc_eisa < 0) ? 0 : rc_eisa)  + ((rc_pci < 0) ? 0 : rc_pci);
 }
 
 static void __exit dfx_cleanup(void)
@@ -3444,14 +3456,17 @@ static void __exit dfx_cleanup(void)
                pci_unregister_driver(&dfx_driver);
        if (dfx_have_eisa)
                dfx_eisa_cleanup();
-               
-}      
+
+}
 
 module_init(dfx_init);
 module_exit(dfx_cleanup);
+MODULE_AUTHOR("Lawrence V. Stefani");
+MODULE_DESCRIPTION("DEC FDDIcontroller EISA/PCI (DEFEA/DEFPA) driver "
+                  DRV_VERSION " " DRV_RELDATE);
 MODULE_LICENSE("GPL");
 
-\f
+
 /*
  * Local variables:
  * kernel-compile-command: "gcc -D__KERNEL__ -I/root/linux/include -Wall -Wstrict-prototypes -O2 -pipe -fomit-frame-pointer -fno-strength-reduce -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -c defxx.c"