40 #include <linux/kernel.h>
41 #include <linux/module.h>
42 #include <linux/string.h>
44 #include <linux/ptrace.h>
45 #include <linux/errno.h>
47 #include <linux/slab.h>
49 #include <linux/pci.h>
51 #include <linux/hdlc.h>
54 #include <linux/if_arp.h>
55 #include <linux/netdevice.h>
59 #include <linux/bitops.h>
60 #include <asm/processor.h>
63 #include <asm/uaccess.h>
66 #define DRIVER_MAJOR_VERSION 1
67 #define DRIVER_MINOR_VERSION 34
68 #define DRIVER_SUB_VERSION 0
70 #define DRIVER_VERSION ((DRIVER_MAJOR_VERSION << 8) + DRIVER_MINOR_VERSION)
78 static int LMC_PKT_BUF_SZ = 1542;
98 static irqreturn_t lmc_interrupt(
int irq,
void *dev_instance);
102 static int lmc_ifdown(
struct net_device *
const);
103 static void lmc_watchdog(
unsigned long data);
165 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
186 if (new_type == old_type)
198 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
216 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
253 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
276 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
298 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
312 lmc_running_reset (dev);
316 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
328 sizeof(lmcEventLogBuf)))
353 netif_stop_queue(dev);
407 for(i = 0; i < 5; i++){
422 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
478 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
511 printk(
"%s: Starting load of data Len: %d at 0x%p == 0x%p\n", dev->
name, xc.
len, xc.
data, data);
568 printk(
KERN_DEBUG "%s: Waited %d for the Xilinx to clear it's memory\n", dev->
name, 500000-timeout);
570 for(pos = 0; pos < xc.
len; pos++){
579 printk(
KERN_WARNING "%s Bad data in xilinx programming data at %d, got %d wanted 0 or 1\n", dev->
name, pos, data[pos]);
609 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
622 netif_wake_queue(dev);
640 static void lmc_watchdog (
unsigned long data)
652 if(sc->
check != 0xBEAFCAFE){
653 printk(
"LMC: Corrupt net_device struct, breaking out\n");
654 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
694 lmc_running_reset (dev);
787 sc->
ictl.
ticks = 0x0000ffff - (ticks & 0x0000ffff);
795 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
801 static int lmc_attach(
struct net_device *dev,
unsigned short encoding,
802 unsigned short parity)
810 .ndo_open = lmc_open,
811 .ndo_stop = lmc_close,
815 .ndo_tx_timeout = lmc_driver_timeout,
816 .ndo_get_stats = lmc_get_stats,
827 static int cards_found;
860 dev_to_hdlc(dev)->xmit = lmc_start_xmit;
861 dev_to_hdlc(dev)->attach = lmc_attach;
868 sc->
check = 0xBEAFCAFE;
871 pci_set_drvdata(pdev, dev);
956 " Subsystem ID = 0x%04x\n",
957 dev->
name, AdapModelNum, subdevice);
977 pci_set_drvdata(pdev,
NULL);
991 struct net_device *dev = pci_get_drvdata(pdev);
999 pci_set_drvdata(pdev,
NULL);
1032 lmc_trace(dev,
"lmc_open irq failed out");
1068 netif_start_queue(dev);
1107 sc->
timer.function = lmc_watchdog;
1119 static void lmc_running_reset (
struct net_device *dev)
1136 netif_wake_queue(dev);
1175 static int lmc_ifdown (
struct net_device *dev)
1185 netif_stop_queue(dev);
1223 dev_kfree_skb(sc->
lmc_txq[i]);
1229 netif_wake_queue(dev);
1240 static irqreturn_t lmc_interrupt (
int irq,
void *dev_instance)
1265 goto lmc_int_fail_out;
1293 lmc_running_reset (dev);
1311 while ((badtx < sc->lmc_next_tx)) {
1319 if (stat & 0x80000000)
1333 if (stat & 0x8000) {
1359 printk (
"%s: out of sync pointer\n", dev->
name);
1364 netif_wake_queue(dev);
1383 error = csr>>23 & 0x7;
1432 unsigned long flags;
1453 netif_wake_queue(dev);
1459 netif_wake_queue(dev);
1465 netif_wake_queue(dev);
1472 netif_stop_queue(dev);
1480 netif_stop_queue(dev);
1487 if (entry == LMC_TXDESCS - 1)
1508 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
1520 unsigned int next_rx;
1522 int localLengthErrCnt = 0;
1540 if ((stat & 0x0300) != 0x0300) {
1541 if ((stat & 0x0000ffff) != 0x7fff) {
1548 if (stat & 0x00000008) {
1555 if (stat & 0x00000004) {
1561 if (len > LMC_PKT_BUF_SZ) {
1563 localLengthErrCnt++;
1567 if (len < sc->lmc_crcSize + 2) {
1570 localLengthErrCnt++;
1574 if(stat & 0x00004000){
1588 nsb = dev_alloc_skb (LMC_PKT_BUF_SZ + 2);
1621 skb_reset_mac_header(skb);
1629 nsb = dev_alloc_skb (LMC_PKT_BUF_SZ + 2);
1648 goto skip_out_of_mem;
1652 nsb = dev_alloc_skb(len);
1654 goto give_it_anyways;
1656 skb_copy_from_linear_data(skb,
skb_put(nsb, len), len);
1659 skb_reset_mac_header(nsb);
1672 if (rx_work_limit < 0)
1690 if (rxIntLoopCnt == 0)
1694 if ((sc->
lmc_rxring[i].status & LMC_RDES_OWN_BIT)
1717 unsigned long flags;
1725 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
1734 .id_table = lmc_pci_tbl,
1735 .probe = lmc_init_one,
1744 int command = (0xf6 << 10) | (devaddr << 5) | regno;
1753 for (i = 15; i >= 0; i--)
1755 int dataval = (command & (1 <<
i)) ? 0x20000 : 0;
1767 for (i = 19; i > 0; i--)
1772 retval = (retval << 1) | ((
LMC_CSR_READ (sc, csr_9) & 0x80000) ? 1 : 0);
1780 return (retval >> 1) & 0xffff;
1786 int command = (0x5002 << 16) | (devaddr << 23) | (regno << 18) | data;
1797 if (command & (1 << i))
1826 static void lmc_softreset (
lmc_softc_t *
const sc)
1851 skb = dev_alloc_skb (LMC_PKT_BUF_SZ + 2);
1897 dev_kfree_skb(sc->
lmc_txq[i]);
2060 sc->
lmc_csrs.csr_busmode = csr_base + 0 * csr_size;
2061 sc->
lmc_csrs.csr_txpoll = csr_base + 1 * csr_size;
2062 sc->
lmc_csrs.csr_rxpoll = csr_base + 2 * csr_size;
2063 sc->
lmc_csrs.csr_rxlist = csr_base + 3 * csr_size;
2064 sc->
lmc_csrs.csr_txlist = csr_base + 4 * csr_size;
2065 sc->
lmc_csrs.csr_status = csr_base + 5 * csr_size;
2066 sc->
lmc_csrs.csr_command = csr_base + 6 * csr_size;
2067 sc->
lmc_csrs.csr_intr = csr_base + 7 * csr_size;
2068 sc->
lmc_csrs.csr_missed_frames = csr_base + 8 * csr_size;
2069 sc->
lmc_csrs.csr_9 = csr_base + 9 * csr_size;
2070 sc->
lmc_csrs.csr_10 = csr_base + 10 * csr_size;
2071 sc->
lmc_csrs.csr_11 = csr_base + 11 * csr_size;
2072 sc->
lmc_csrs.csr_12 = csr_base + 12 * csr_size;
2073 sc->
lmc_csrs.csr_13 = csr_base + 13 * csr_size;
2074 sc->
lmc_csrs.csr_14 = csr_base + 14 * csr_size;
2075 sc->
lmc_csrs.csr_15 = csr_base + 15 * csr_size;
2079 static void lmc_driver_timeout(
struct net_device *dev)
2083 unsigned long flags;
2085 lmc_trace(dev,
"lmc_driver_timeout in");
2106 lmc_running_reset (dev);
2128 spin_unlock_irqrestore(&sc->
lmc_lock, flags);
2130 lmc_trace(dev,
"lmc_driver_timout out");