* 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.
*/
/* 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.08"
+#define DRV_RELDATE "2005/06/14"
static char version[] __devinitdata =
- "defxx.c:v1.06 2003/08/04 Lawrence V. Stefani and others\n";
-
-#define DRV_NAME "defxx"
+ DRV_NAME ": " DRV_VERSION " " DRV_RELDATE
+ " Lawrence V. Stefani and others\n";
#define DYNAMIC_BUFFERS 1
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);
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,
+ struct pt_regs *regs);
static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev);
static void dfx_ctl_set_multicast_list(struct net_device *dev);
*/
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;
}
}
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, DRV_NAME)) {
- printk (KERN_ERR "%s: Cannot reserve I/O resource 0x%x @ 0x%lx, aborting\n",
- DRV_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;
}
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;
}
if (err)
goto err_out_kfree;
+ printk("%s: registered as %s\n", print_name, dev->name);
return 0;
err_out_kfree:
*
* Arguments:
* dev - pointer to device information
+ * print_name - printable device name
*
* Functional Description:
* This function allocates additional resources such as the host memory
* 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 */
/* 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);
- }
+ }
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);
- }
+ }
memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16));
/*
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
(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 */
/* 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
/*
/* 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, SA_SHIRQ, dev->name, dev);
if (ret) {
printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq);
return ret;
* =================
* = dfx_interrupt =
* =================
- *
+ *
* Overview:
* Interrupt processing routine
- *
+ *
* Returns:
- * None
- *
+ * Whether a valid interrupt was seen.
+ *
* Arguments:
* irq - interrupt vector
* dev_id - pointer to device information
* 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
* 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 pt_regs *regs)
+{
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));
- 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);
+ } else {
+ u8 status;
- /* Call interrupt service routine for this adapter */
+ dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status);
+ if (!(status & PI_CONFIG_STAT_0_M_PEND))
+ return IRQ_NONE;
+
+ 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);
}
+ return IRQ_HANDLED;
+}
+
\f
/*
* =====================
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 */
+ v = ALIGN(x, n); /* Where we want to be */
- skb_reserve(skb, v-x);
+ skb_reserve(skb, v - x);
}
\f
{
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);
if (rc_pci >= 0) dfx_have_pci = 1;
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