#include <asm/irq.h>
#endif
-#ifdef DEBUG
-#define enter(x) printk("Enter: %s, %s line %i\n",x,__FILE__,__LINE__)
-#define leave(x) printk("Leave: %s, %s line %i\n",x,__FILE__,__LINE__)
-#else
-#define enter(x) do {} while (0)
-#define leave(x) do {} while (0)
-#endif
-
-
MODULE_DESCRIPTION("Xircom Cardbus ethernet driver");
MODULE_AUTHOR("Arjan van de Ven <arjanv@redhat.com>");
MODULE_LICENSE("GPL");
};
-#ifdef DEBUG
+#if defined DEBUG && DEBUG > 1
static void print_binary(unsigned int number)
{
int i,i2;
if ((i&3)==0)
buffer[i2++]=' ';
}
- printk("%s\n",buffer);
+ pr_debug("%s\n",buffer);
}
#endif
struct xircom_private *private;
unsigned long flags;
unsigned short tmp16;
- enter("xircom_probe");
/* First do the PCI initialisation */
trigger_receive(private);
- leave("xircom_probe");
return 0;
reg_fail:
struct net_device *dev = pci_get_drvdata(pdev);
struct xircom_private *card = netdev_priv(dev);
- enter("xircom_remove");
pci_free_consistent(pdev,8192,card->rx_buffer,card->rx_dma_handle);
pci_free_consistent(pdev,8192,card->tx_buffer,card->tx_dma_handle);
unregister_netdev(dev);
free_netdev(dev);
pci_set_drvdata(pdev, NULL);
- leave("xircom_remove");
}
static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
unsigned int status;
int i;
- enter("xircom_interrupt\n");
-
spin_lock(&card->lock);
status = inl(card->io_port+CSR5);
-#ifdef DEBUG
+#if defined DEBUG && DEBUG > 1
print_binary(status);
- printk("tx status 0x%08x 0x%08x\n",
- card->tx_buffer[0], card->tx_buffer[4]);
- printk("rx status 0x%08x 0x%08x\n",
- card->rx_buffer[0], card->rx_buffer[4]);
+ pr_debug("tx status 0x%08x 0x%08x\n",
+ card->tx_buffer[0], card->tx_buffer[4]);
+ pr_debug("rx status 0x%08x 0x%08x\n",
+ card->rx_buffer[0], card->rx_buffer[4]);
#endif
/* Handle shared irq and hotplug */
if (status == 0 || status == 0xffffffff) {
for (i=0;i<NUMDESCRIPTORS;i++)
investigate_read_descriptor(dev,card,i,bufferoffsets[i]);
-
spin_unlock(&card->lock);
- leave("xircom_interrupt");
return IRQ_HANDLED;
}
unsigned long flags;
int nextdescriptor;
int desc;
- enter("xircom_start_xmit");
card = netdev_priv(dev);
spin_lock_irqsave(&card->lock,flags);
netif_stop_queue(dev);
}
card->transmit_used = nextdescriptor;
- leave("xircom-start_xmit - sent");
spin_unlock_irqrestore(&card->lock,flags);
return NETDEV_TX_OK;
}
-
-
/* Uh oh... no free descriptor... drop the packet */
netif_stop_queue(dev);
spin_unlock_irqrestore(&card->lock,flags);
{
struct xircom_private *xp = netdev_priv(dev);
int retval;
- enter("xircom_open");
+
pr_info("xircom cardbus adaptor found, registering as %s, using irq %i\n",
dev->name, dev->irq);
retval = request_irq(dev->irq, xircom_interrupt, IRQF_SHARED, dev->name, dev);
- if (retval) {
- leave("xircom_open - No IRQ");
+ if (retval)
return retval;
- }
xircom_up(xp);
xp->open = 1;
- leave("xircom_open");
+
return 0;
}
struct xircom_private *card;
unsigned long flags;
- enter("xircom_close");
card = netdev_priv(dev);
netif_stop_queue(dev); /* we don't want new packets */
card->open = 0;
free_irq(dev->irq,dev);
- leave("xircom_close");
-
return 0;
}
{
unsigned int val;
unsigned long flags;
- enter("initialize_card");
-
spin_lock_irqsave(&card->lock, flags);
deactivate_transmitter(card);
spin_unlock_irqrestore(&card->lock, flags);
-
- leave("initialize_card");
}
/*
static void trigger_transmit(struct xircom_private *card)
{
unsigned int val;
- enter("trigger_transmit");
val = 0;
outl(val, card->io_port + CSR1);
-
- leave("trigger_transmit");
}
/*
static void trigger_receive(struct xircom_private *card)
{
unsigned int val;
- enter("trigger_receive");
val = 0;
outl(val, card->io_port + CSR2);
-
- leave("trigger_receive");
}
/*
{
u32 address;
int i;
- enter("setup_descriptors");
-
BUG_ON(card->rx_buffer == NULL);
BUG_ON(card->tx_buffer == NULL);
/* wite the transmit descriptor ring to the card */
address = card->tx_dma_handle;
outl(address, card->io_port + CSR4); /* xmit descr list address */
-
- leave("setup_descriptors");
}
/*
static void remove_descriptors(struct xircom_private *card)
{
unsigned int val;
- enter("remove_descriptors");
val = 0;
outl(val, card->io_port + CSR3); /* Receive descriptor address */
outl(val, card->io_port + CSR4); /* Send descriptor address */
-
- leave("remove_descriptors");
}
/*
static int link_status_changed(struct xircom_private *card)
{
unsigned int val;
- enter("link_status_changed");
val = inl(card->io_port + CSR5); /* Status register */
- if ((val & (1 << 27)) == 0) { /* no change */
- leave("link_status_changed - nochange");
+ if ((val & (1 << 27)) == 0) /* no change */
return 0;
- }
/* clear the event by writing a 1 to the bit in the
status register. */
val = (1 << 27);
outl(val, card->io_port + CSR5);
- leave("link_status_changed - changed");
return 1;
}
static int transmit_active(struct xircom_private *card)
{
unsigned int val;
- enter("transmit_active");
val = inl(card->io_port + CSR5); /* Status register */
- if ((val & (7 << 20)) == 0) { /* transmitter disabled */
- leave("transmit_active - inactive");
+ if ((val & (7 << 20)) == 0) /* transmitter disabled */
return 0;
- }
- leave("transmit_active - active");
return 1;
}
static int receive_active(struct xircom_private *card)
{
unsigned int val;
- enter("receive_active");
-
val = inl(card->io_port + CSR5); /* Status register */
- if ((val & (7 << 17)) == 0) { /* receiver disabled */
- leave("receive_active - inactive");
+ if ((val & (7 << 17)) == 0) /* receiver disabled */
return 0;
- }
- leave("receive_active - active");
return 1;
}
{
unsigned int val;
int counter;
- enter("activate_receiver");
-
val = inl(card->io_port + CSR6); /* Operation mode */
if (counter <= 0)
pr_err("Receiver failed to re-activate\n");
}
-
- leave("activate_receiver");
}
/*
{
unsigned int val;
int counter;
- enter("deactivate_receiver");
val = inl(card->io_port + CSR6); /* Operation mode */
val = val & ~2; /* disable the receiver */
if (counter <= 0)
pr_err("Receiver failed to deactivate\n");
}
-
-
- leave("deactivate_receiver");
}
{
unsigned int val;
int counter;
- enter("activate_transmitter");
-
val = inl(card->io_port + CSR6); /* Operation mode */
if (counter <= 0)
pr_err("Transmitter failed to re-activate\n");
}
-
- leave("activate_transmitter");
}
/*
{
unsigned int val;
int counter;
- enter("deactivate_transmitter");
val = inl(card->io_port + CSR6); /* Operation mode */
val = val & ~2; /* disable the transmitter */
if (counter <= 0)
pr_err("Transmitter failed to deactivate\n");
}
-
-
- leave("deactivate_transmitter");
}
static void enable_transmit_interrupt(struct xircom_private *card)
{
unsigned int val;
- enter("enable_transmit_interrupt");
val = inl(card->io_port + CSR7); /* Interrupt enable register */
val |= 1; /* enable the transmit interrupt */
outl(val, card->io_port + CSR7);
-
- leave("enable_transmit_interrupt");
}
static void enable_receive_interrupt(struct xircom_private *card)
{
unsigned int val;
- enter("enable_receive_interrupt");
val = inl(card->io_port + CSR7); /* Interrupt enable register */
val = val | (1 << 6); /* enable the receive interrupt */
outl(val, card->io_port + CSR7);
-
- leave("enable_receive_interrupt");
}
/*
static void enable_link_interrupt(struct xircom_private *card)
{
unsigned int val;
- enter("enable_link_interrupt");
val = inl(card->io_port + CSR7); /* Interrupt enable register */
val = val | (1 << 27); /* enable the link status chage interrupt */
outl(val, card->io_port + CSR7);
-
- leave("enable_link_interrupt");
}
static void disable_all_interrupts(struct xircom_private *card)
{
unsigned int val;
- enter("enable_all_interrupts");
val = 0; /* disable all interrupts */
outl(val, card->io_port + CSR7);
-
- leave("disable_all_interrupts");
}
/*
static void enable_common_interrupts(struct xircom_private *card)
{
unsigned int val;
- enter("enable_link_interrupt");
val = inl(card->io_port + CSR7); /* Interrupt enable register */
val |= (1<<16); /* Normal Interrupt Summary */
val |= (1<<2); /* Transmit Buffer Unavailable */
val |= (1<<1); /* Transmit Process Stopped */
outl(val, card->io_port + CSR7);
-
- leave("enable_link_interrupt");
}
/*
static int enable_promisc(struct xircom_private *card)
{
unsigned int val;
- enter("enable_promisc");
val = inl(card->io_port + CSR6);
val = val | (1 << 6);
outl(val, card->io_port + CSR6);
- leave("enable_promisc");
return 1;
}
static int link_status(struct xircom_private *card)
{
unsigned int val;
- enter("link_status");
val = inb(card->io_port + CSR12);
/* If we get here -> no link at all */
- leave("link_status");
return 0;
}
unsigned long flags;
int i;
- enter("read_mac_address");
-
spin_lock_irqsave(&card->lock, flags);
outl(1 << 12, card->io_port + CSR9); /* enable boot rom access */
}
spin_unlock_irqrestore(&card->lock, flags);
pr_debug(" %pM\n", card->dev->dev_addr);
- leave("read_mac_address");
}
{
unsigned long flags;
- enter("transceiver_voodoo");
-
/* disable all powermanagement */
pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000);
spin_unlock_irqrestore(&card->lock, flags);
netif_start_queue(card->dev);
- leave("transceiver_voodoo");
}
unsigned long flags;
int i;
- enter("xircom_up");
-
/* disable all powermanagement */
pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000);
trigger_receive(card);
trigger_transmit(card);
netif_start_queue(card->dev);
- leave("xircom_up");
}
/* Bufferoffset is in BYTES */
{
int status;
- enter("investigate_read_descriptor");
status = le32_to_cpu(card->rx_buffer[4*descnr]);
if ((status > 0)) { /* packet received */
card->rx_buffer[4*descnr] = cpu_to_le32(0x80000000);
trigger_receive(card);
}
-
- leave("investigate_read_descriptor");
-
}
{
int status;
- enter("investigate_write_descriptor");
-
status = le32_to_cpu(card->tx_buffer[4*descnr]);
#if 0
if (status & 0x8000) { /* Major error */
dev->stats.tx_packets++;
}
- leave("investigate_write_descriptor");
-
}