Lines Matching +full:my +full:- +full:dma +full:- +full:window

1 /* hamachi.c: A Packet Engines GNIC-II Gigabit Ethernet driver for Linux. */
3 Written 1998-2000 by Donald Becker.
18 This driver is for the Packet Engines GNIC-II PCI Gigabit Ethernet
23 [link no longer provides useful info -jgarzik]
34 /* A few user-configurable values. */
42 /* Default values selected by testing on a dual processor PIII-450 */
53 /* Set the copy breakpoint for the copy-only-tiny-frames scheme.
54 -Setting to > 1518 causes all frames to be copied
55 -Setting to 0 disables copies
69 - The lower 4 bits are reserved for the media type.
70 - The next three bits may be set to one of the following:
76 - The next bit can be used to force half-duplex. This is a bad
77 idea since no known implementations implement half-duplex, and,
78 in general, half-duplex for gigabit ethernet is a bad idea.
79 0x00000080 : Force half-duplex
80 Default is full-duplex.
81 - In the original driver, the ninth bit could be used to force
82 full-duplex. Maintain that for compatibility
83 0x00000200 : Force full-duplex
86 static int options[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
87 static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
93 * 23 - 16 15 - 8 7 - 0
96 * ---------------------------------
99 * max_gap : The maximum inter-packet gap in units of 8.192 us
103 static int rx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
104 static int tx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
112 There are no ill effects from too-large receive rings, except for
116 easily. Also, things appear to work a bit better in back-to-back
129 /* play with 64-bit addrlen; seems to be a teensy bit slower --pw */
133 * RX_CHECKSUM turns on card-generated receive checksum generation for
215 Gigabit Ethernet chip. The only PCA currently supported is the GNIC-II 64-bit
218 II. Board-specific settings
228 The Hamachi uses a typical descriptor based bus-master architecture.
230 This driver uses two statically allocated fixed-size descriptor lists
234 This driver uses a zero-copy receive and transmit scheme similar my other
237 open() time and passes the skb->data field to the Hamachi as receive data
243 The RX_COPYBREAK value is chosen to trade-off the memory wasted by
244 using a full-sized skbuff for small frames vs. the copying costs of larger
252 The Rx and Tx descriptor structure are straight-forward, with no historical
264 This driver is very similar to my other network drivers.
265 The driver runs as two independent, single-threaded flows of control. One
266 is the send-packet routine, which enforces single-threaded use by the
267 dev->tbusy flag. The other thread is the interrupt handler, which is single
270 The send packet thread has partial control over the Tx ring and 'dev->tbusy'
273 the 'hmp->tx_full' flag.
277 empty by incrementing the dirty_tx mark. Iff the 'hmp->tx_full' flag is set, it
282 Thanks to Kim Stearns of Packet Engines for providing a pair of GNIC-II boards.
296 to help avoid some stall conditions -- this needs further research.
310 the new buffer or the function returns non-zero which should case the
314 End-to-end flow control should now be fully active and the interrupt
330 peer-to-peer connection would hang under high load. I believe the Rx
334 slot isn't in use -- hypothetically, the card might be searching the
340 02/09/1999 EPK Added Michel Mueller's TxDMA Interrupt and Tx-timeout
343 02/09/1999 EPK Added code to check/reset dev->tbusy in hamachi_interrupt.
363 re-structuring I would like to do.
366 parameters on a dual P3-450 setup yielded the new default interrupt
371 nicely with non-linux machines.
375 -It seems that enabling PCI performance commands for descriptors
377 performance impact for any of my tests. (ttcp, netpipe, netperf) I will
380 -Increasing the PCI_LATENCY_TIMER to 130
386 -adjusted boguscnt in hamachi_rx() to depend on interrupt
389 -Selected a set of interrupt parameters based on some extensive testing.
394 -Consider borrowing from the acenic driver code to check PCI_COMMAND for
398 -fix the reset procedure. It doesn't quite work.
425 {0x1318, 0x0911, 0xffff, 0, "Hamachi GNIC-II", hamachi_timer, 0},
450 /* Offsets to the MII-mode registers. */
499 unsigned int default_port:4; /* Last dev->if_port value. */
511 MODULE_DESCRIPTION("Packet Engines 'Hamachi' GNIC-II Gigabit Ethernet driver");
529 MODULE_PARM_DESC(max_interrupt_work, "GNIC-II maximum events handled per interrupt");
530 MODULE_PARM_DESC(mtu, "GNIC-II MTU (all boards)");
531 MODULE_PARM_DESC(debug, "GNIC-II debug level (0-7)");
532 MODULE_PARM_DESC(min_rx_pkt, "GNIC-II minimum Rx packets processed between interrupts");
533 MODULE_PARM_DESC(max_rx_gap, "GNIC-II maximum Rx inter-packet gap in 8.192 microsecond units");
534 MODULE_PARM_DESC(max_rx_latency, "GNIC-II time between Rx interrupts in 8.192 microsecond units");
535 MODULE_PARM_DESC(min_tx_pkt, "GNIC-II minimum Tx packets processed between interrupts");
536 MODULE_PARM_DESC(max_tx_gap, "GNIC-II maximum Tx inter-packet gap in 8.192 microsecond units");
537 MODULE_PARM_DESC(max_tx_latency, "GNIC-II time between Tx interrupts in 8.192 microsecond units");
538 MODULE_PARM_DESC(rx_copybreak, "GNIC-II copy breakpoint for copy-only-tiny-frames");
539 MODULE_PARM_DESC(rx_params, "GNIC-II min_rx_pkt+max_rx_gap+max_rx_latency");
540 MODULE_PARM_DESC(tx_params, "GNIC-II min_tx_pkt+max_tx_gap+max_tx_latency");
541 MODULE_PARM_DESC(options, "GNIC-II Bits 0-3: media type, bits 4-6: as force32, bit 7: half duplex, …
542 MODULE_PARM_DESC(full_duplex, "GNIC-II full duplex setting(s) (1)");
543 MODULE_PARM_DESC(force32, "GNIC-II: Bit 0: 32 bit PCI, bit 1: disable parity, bit 2: 64 bit PCI (al…
586 int chip_id = ent->driver_data; in hamachi_init_one()
594 int ret = -ENOMEM; in hamachi_init_one()
605 ret = -EIO; in hamachi_init_one()
620 irq = pdev->irq; in hamachi_init_one()
629 SET_NETDEV_DEV(dev, &pdev->dev); in hamachi_init_one()
643 spin_lock_init(&hmp->lock); in hamachi_init_one()
645 hmp->mii_if.dev = dev; in hamachi_init_one()
646 hmp->mii_if.mdio_read = mdio_read; in hamachi_init_one()
647 hmp->mii_if.mdio_write = mdio_write; in hamachi_init_one()
648 hmp->mii_if.phy_id_mask = 0x1f; in hamachi_init_one()
649 hmp->mii_if.reg_num_mask = 0x1f; in hamachi_init_one()
651 ring_space = dma_alloc_coherent(&pdev->dev, TX_TOTAL_SIZE, &ring_dma, in hamachi_init_one()
655 hmp->tx_ring = ring_space; in hamachi_init_one()
656 hmp->tx_ring_dma = ring_dma; in hamachi_init_one()
658 ring_space = dma_alloc_coherent(&pdev->dev, RX_TOTAL_SIZE, &ring_dma, in hamachi_init_one()
662 hmp->rx_ring = ring_space; in hamachi_init_one()
663 hmp->rx_ring_dma = ring_dma; in hamachi_init_one()
667 if (dev->mem_start) in hamachi_init_one()
668 option = dev->mem_start; in hamachi_init_one()
690 hmp->base = ioaddr; in hamachi_init_one()
693 hmp->chip_id = chip_id; in hamachi_init_one()
694 hmp->pci_dev = pdev; in hamachi_init_one()
698 hmp->option = option; in hamachi_init_one()
700 hmp->mii_if.full_duplex = 1; in hamachi_init_one()
702 hmp->mii_if.full_duplex = 0; in hamachi_init_one()
703 hmp->default_port = option & 15; in hamachi_init_one()
704 if (hmp->default_port) in hamachi_init_one()
705 hmp->mii_if.force_media = 1; in hamachi_init_one()
708 hmp->mii_if.full_duplex = 1; in hamachi_init_one()
711 if (hmp->mii_if.full_duplex || (option & 0x080)) in hamachi_init_one()
712 hmp->duplex_lock = 1; in hamachi_init_one()
722 rx_int_var = card_idx < MAX_UNITS ? rx_params[card_idx] : -1; in hamachi_init_one()
723 tx_int_var = card_idx < MAX_UNITS ? tx_params[card_idx] : -1; in hamachi_init_one()
724 hmp->rx_int_var = rx_int_var >= 0 ? rx_int_var : in hamachi_init_one()
726 hmp->tx_int_var = tx_int_var >= 0 ? tx_int_var : in hamachi_init_one()
730 /* The Hamachi-specific entries in the device structure. */ in hamachi_init_one()
731 dev->netdev_ops = &hamachi_netdev_ops; in hamachi_init_one()
732 dev->ethtool_ops = (chip_tbl[hmp->chip_id].flags & CanHaveMII) ? in hamachi_init_one()
734 dev->watchdog_timeo = TX_TIMEOUT; in hamachi_init_one()
736 dev->mtu = mtu; in hamachi_init_one()
745 dev->name, chip_tbl[chip_id].name, readl(ioaddr + ChipRev), in hamachi_init_one()
746 ioaddr, dev->dev_addr, irq); in hamachi_init_one()
748 printk(KERN_INFO "%s: %d-bit %d Mhz PCI bus (%d), Virtual Jumpers " in hamachi_init_one()
750 dev->name, readw(ioaddr + MiscStatus) & 1 ? 64 : 32, in hamachi_init_one()
754 if (chip_tbl[hmp->chip_id].flags & CanHaveMII) { in hamachi_init_one()
760 hmp->phys[phy_idx++] = phy; in hamachi_init_one()
761 hmp->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE); in hamachi_init_one()
764 dev->name, phy, mii_status, hmp->mii_if.advertising); in hamachi_init_one()
767 hmp->mii_cnt = phy_idx; in hamachi_init_one()
768 if (hmp->mii_cnt > 0) in hamachi_init_one()
769 hmp->mii_if.phy_id = hmp->phys[0]; in hamachi_init_one()
771 memset(&hmp->mii_if, 0, sizeof(hmp->mii_if)); in hamachi_init_one()
782 dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, hmp->rx_ring, in hamachi_init_one()
783 hmp->rx_ring_dma); in hamachi_init_one()
785 dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, hmp->tx_ring, in hamachi_init_one()
786 hmp->tx_ring_dma); in hamachi_init_one()
801 /* We should check busy first - per docs -KDU */ in read_eeprom()
802 while ((readb(ioaddr + EECmdStatus) & 0x40) && --bogus_cnt > 0); in read_eeprom()
806 while ((readb(ioaddr + EECmdStatus) & 0x40) && --bogus_cnt > 0); in read_eeprom()
809 (int)readb(ioaddr + EECmdStatus), 1000- bogus_cnt); in read_eeprom()
820 void __iomem *ioaddr = hmp->base; in mdio_read()
823 /* We should check busy first - per docs -KDU */ in mdio_read()
824 for (i = 10000; i >= 0; i--) in mdio_read()
829 for (i = 10000; i >= 0; i--) in mdio_read()
838 void __iomem *ioaddr = hmp->base; in mdio_write()
841 /* We should check busy first - per docs -KDU */ in mdio_write()
842 for (i = 10000; i >= 0; i--) in mdio_write()
849 for (i = 10000; i >= 0; i--) in mdio_write()
858 void __iomem *ioaddr = hmp->base; in hamachi_open()
863 i = request_irq(hmp->pci_dev->irq, hamachi_interrupt, IRQF_SHARED, in hamachi_open()
864 dev->name, dev); in hamachi_open()
872 writel(hmp->rx_ring_dma, ioaddr + RxPtr); in hamachi_open()
873 writel(hmp->rx_ring_dma >> 32, ioaddr + RxPtr + 4); in hamachi_open()
874 writel(hmp->tx_ring_dma, ioaddr + TxPtr); in hamachi_open()
875 writel(hmp->tx_ring_dma >> 32, ioaddr + TxPtr + 4); in hamachi_open()
877 writel(hmp->rx_ring_dma, ioaddr + RxPtr); in hamachi_open()
878 writel(hmp->tx_ring_dma, ioaddr + TxPtr); in hamachi_open()
882 * documentation does. -KDU in hamachi_open()
885 writeb(dev->dev_addr[i], ioaddr + StationAddr + i); in hamachi_open()
911 dev->name); in hamachi_open()
917 if (dev->if_port == 0) in hamachi_open()
918 dev->if_port = hmp->default_port; in hamachi_open()
922 /* If someone didn't choose a duplex, default to full-duplex */ in hamachi_open()
923 if (hmp->duplex_lock != 1) in hamachi_open()
924 hmp->mii_if.full_duplex = 1; in hamachi_open()
932 /* WHAT?!?!? Why isn't this documented somewhere? -KDU */ in hamachi_open()
934 /* Why do we enable receives/transmits here? -KDU */ in hamachi_open()
938 writew(MAX_FRAME_SIZE, ioaddr + MaxFrameSize); /* dev->mtu+14 ??? */ in hamachi_open()
948 rx_int_var = hmp->rx_int_var; in hamachi_open()
949 tx_int_var = hmp->tx_int_var; in hamachi_open()
970 writew(0x0000, ioaddr + EventStatus); /* Clear non-interrupting events */ in hamachi_open()
972 /* Configure and start the DMA channels. */ in hamachi_open()
985 dev->name, readw(ioaddr + RxStatus), readw(ioaddr + TxStatus)); in hamachi_open()
988 timer_setup(&hmp->timer, hamachi_timer, 0); in hamachi_open()
989 hmp->timer.expires = RUN_AT((24*HZ)/10); /* 2.4 sec. */ in hamachi_open()
990 add_timer(&hmp->timer); in hamachi_open()
1001 for (; hmp->cur_tx - hmp->dirty_tx > 0; hmp->dirty_tx++) { in hamachi_tx()
1002 int entry = hmp->dirty_tx % TX_RING_SIZE; in hamachi_tx()
1005 if (hmp->tx_ring[entry].status_n_length & cpu_to_le32(DescOwn)) in hamachi_tx()
1008 skb = hmp->tx_skbuff[entry]; in hamachi_tx()
1010 dma_unmap_single(&hmp->pci_dev->dev, in hamachi_tx()
1011 leXX_to_cpu(hmp->tx_ring[entry].addr), in hamachi_tx()
1012 skb->len, DMA_TO_DEVICE); in hamachi_tx()
1014 hmp->tx_skbuff[entry] = NULL; in hamachi_tx()
1016 hmp->tx_ring[entry].status_n_length = 0; in hamachi_tx()
1017 if (entry >= TX_RING_SIZE-1) in hamachi_tx()
1018 hmp->tx_ring[TX_RING_SIZE-1].status_n_length |= in hamachi_tx()
1020 dev->stats.tx_packets++; in hamachi_tx()
1029 struct net_device *dev = hmp->mii_if.dev; in hamachi_timer()
1030 void __iomem *ioaddr = hmp->base; in hamachi_timer()
1035 "%4.4x.\n", dev->name, readw(ioaddr + ANStatus), in hamachi_timer()
1038 "%4.4x %4.4x %4.4x.\n", dev->name, in hamachi_timer()
1047 hmp->timer.expires = RUN_AT(next_tick); in hamachi_timer()
1048 add_timer(&hmp->timer); in hamachi_timer()
1055 void __iomem *ioaddr = hmp->base; in hamachi_tx_timeout()
1058 " resetting...\n", dev->name, (int)readw(ioaddr + TxStatus)); in hamachi_tx_timeout()
1061 printk(KERN_DEBUG " Rx ring %p: ", hmp->rx_ring); in hamachi_tx_timeout()
1064 le32_to_cpu(hmp->rx_ring[i].status_n_length)); in hamachi_tx_timeout()
1066 printk(KERN_DEBUG" Tx ring %p: ", hmp->tx_ring); in hamachi_tx_timeout()
1069 le32_to_cpu(hmp->tx_ring[i].status_n_length)); in hamachi_tx_timeout()
1076 dev->if_port = 0; in hamachi_tx_timeout()
1077 /* The right way to do Reset. -KDU in hamachi_tx_timeout()
1078 * -Clear OWN bit in all Rx/Tx descriptors in hamachi_tx_timeout()
1079 * -Wait 50 uS for channels to go idle in hamachi_tx_timeout()
1080 * -Turn off MAC receiver in hamachi_tx_timeout()
1081 * -Issue Reset in hamachi_tx_timeout()
1085 hmp->rx_ring[i].status_n_length &= cpu_to_le32(~DescOwn); in hamachi_tx_timeout()
1088 * re-init the hardware. in hamachi_tx_timeout()
1093 if (i >= TX_RING_SIZE - 1) in hamachi_tx_timeout()
1094 hmp->tx_ring[i].status_n_length = in hamachi_tx_timeout()
1096 (hmp->tx_ring[i].status_n_length & in hamachi_tx_timeout()
1099 hmp->tx_ring[i].status_n_length &= cpu_to_le32(0x0000ffff); in hamachi_tx_timeout()
1100 skb = hmp->tx_skbuff[i]; in hamachi_tx_timeout()
1102 dma_unmap_single(&hmp->pci_dev->dev, in hamachi_tx_timeout()
1103 leXX_to_cpu(hmp->tx_ring[i].addr), in hamachi_tx_timeout()
1104 skb->len, DMA_TO_DEVICE); in hamachi_tx_timeout()
1106 hmp->tx_skbuff[i] = NULL; in hamachi_tx_timeout()
1115 hmp->tx_full = 0; in hamachi_tx_timeout()
1116 hmp->cur_rx = hmp->cur_tx = 0; in hamachi_tx_timeout()
1117 hmp->dirty_rx = hmp->dirty_tx = 0; in hamachi_tx_timeout()
1119 * ring of buffers is in tact. -KDU in hamachi_tx_timeout()
1122 struct sk_buff *skb = hmp->rx_skbuff[i]; in hamachi_tx_timeout()
1125 dma_unmap_single(&hmp->pci_dev->dev, in hamachi_tx_timeout()
1126 leXX_to_cpu(hmp->rx_ring[i].addr), in hamachi_tx_timeout()
1127 hmp->rx_buf_sz, DMA_FROM_DEVICE); in hamachi_tx_timeout()
1129 hmp->rx_skbuff[i] = NULL; in hamachi_tx_timeout()
1136 skb = netdev_alloc_skb_ip_align(dev, hmp->rx_buf_sz); in hamachi_tx_timeout()
1137 hmp->rx_skbuff[i] = skb; in hamachi_tx_timeout()
1141 hmp->rx_ring[i].addr = cpu_to_leXX(dma_map_single(&hmp->pci_dev->dev, in hamachi_tx_timeout()
1142 skb->data, in hamachi_tx_timeout()
1143 hmp->rx_buf_sz, in hamachi_tx_timeout()
1145 hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn | in hamachi_tx_timeout()
1146 DescEndPacket | DescIntr | (hmp->rx_buf_sz - 2)); in hamachi_tx_timeout()
1148 hmp->dirty_rx = (unsigned int)(i - RX_RING_SIZE); in hamachi_tx_timeout()
1150 hmp->rx_ring[RX_RING_SIZE-1].status_n_length |= cpu_to_le32(DescEndRing); in hamachi_tx_timeout()
1154 dev->stats.tx_errors++; in hamachi_tx_timeout()
1171 hmp->tx_full = 0; in hamachi_init_ring()
1172 hmp->cur_rx = hmp->cur_tx = 0; in hamachi_init_ring()
1173 hmp->dirty_rx = hmp->dirty_tx = 0; in hamachi_init_ring()
1178 * card. -KDU in hamachi_init_ring()
1180 hmp->rx_buf_sz = (dev->mtu <= 1492 ? PKT_BUF_SZ : in hamachi_init_ring()
1181 (((dev->mtu+26+7) & ~7) + 16)); in hamachi_init_ring()
1185 hmp->rx_ring[i].status_n_length = 0; in hamachi_init_ring()
1186 hmp->rx_skbuff[i] = NULL; in hamachi_init_ring()
1190 struct sk_buff *skb = netdev_alloc_skb(dev, hmp->rx_buf_sz + 2); in hamachi_init_ring()
1191 hmp->rx_skbuff[i] = skb; in hamachi_init_ring()
1195 hmp->rx_ring[i].addr = cpu_to_leXX(dma_map_single(&hmp->pci_dev->dev, in hamachi_init_ring()
1196 skb->data, in hamachi_init_ring()
1197 hmp->rx_buf_sz, in hamachi_init_ring()
1199 /* -2 because it doesn't REALLY have that first 2 bytes -KDU */ in hamachi_init_ring()
1200 hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn | in hamachi_init_ring()
1201 DescEndPacket | DescIntr | (hmp->rx_buf_sz -2)); in hamachi_init_ring()
1203 hmp->dirty_rx = (unsigned int)(i - RX_RING_SIZE); in hamachi_init_ring()
1204 hmp->rx_ring[RX_RING_SIZE-1].status_n_length |= cpu_to_le32(DescEndRing); in hamachi_init_ring()
1207 hmp->tx_skbuff[i] = NULL; in hamachi_init_ring()
1208 hmp->tx_ring[i].status_n_length = 0; in hamachi_init_ring()
1211 hmp->tx_ring[TX_RING_SIZE-1].status_n_length |= cpu_to_le32(DescEndRing); in hamachi_init_ring()
1223 add another skbuff. if we return non-zero the scheduler in hamachi_start_xmit()
1227 if (hmp->tx_full) { in hamachi_start_xmit()
1228 /* We should NEVER reach this point -KDU */ in hamachi_start_xmit()
1229 printk(KERN_WARNING "%s: Hamachi transmit queue full at slot %d.\n",dev->name, hmp->cur_tx); in hamachi_start_xmit()
1231 /* Wake the potentially-idle transmit channel. */ in hamachi_start_xmit()
1232 /* If we don't need to read status, DON'T -KDU */ in hamachi_start_xmit()
1233 status=readw(hmp->base + TxStatus); in hamachi_start_xmit()
1235 writew(0x0001, hmp->base + TxCmd); in hamachi_start_xmit()
1243 entry = hmp->cur_tx % TX_RING_SIZE; in hamachi_start_xmit()
1245 hmp->tx_skbuff[entry] = skb; in hamachi_start_xmit()
1247 hmp->tx_ring[entry].addr = cpu_to_leXX(dma_map_single(&hmp->pci_dev->dev, in hamachi_start_xmit()
1248 skb->data, in hamachi_start_xmit()
1249 skb->len, in hamachi_start_xmit()
1259 mitigating interrupt frequency with the tx_min_pkt parameter. -KDU in hamachi_start_xmit()
1261 if (entry >= TX_RING_SIZE-1) /* Wrap ring */ in hamachi_start_xmit()
1262 hmp->tx_ring[entry].status_n_length = cpu_to_le32(DescOwn | in hamachi_start_xmit()
1263 DescEndPacket | DescEndRing | DescIntr | skb->len); in hamachi_start_xmit()
1265 hmp->tx_ring[entry].status_n_length = cpu_to_le32(DescOwn | in hamachi_start_xmit()
1266 DescEndPacket | DescIntr | skb->len); in hamachi_start_xmit()
1267 hmp->cur_tx++; in hamachi_start_xmit()
1269 /* Non-x86 Todo: explicitly flush cache lines here. */ in hamachi_start_xmit()
1271 /* Wake the potentially-idle transmit channel. */ in hamachi_start_xmit()
1272 /* If we don't need to read status, DON'T -KDU */ in hamachi_start_xmit()
1273 status=readw(hmp->base + TxStatus); in hamachi_start_xmit()
1275 writew(0x0001, hmp->base + TxCmd); in hamachi_start_xmit()
1284 * routine should IMMEDIATELY get a chance to be re-queued. -KDU in hamachi_start_xmit()
1286 if ((hmp->cur_tx - hmp->dirty_tx) < (TX_RING_SIZE - 4)) in hamachi_start_xmit()
1289 hmp->tx_full = 1; in hamachi_start_xmit()
1295 dev->name, hmp->cur_tx, entry); in hamachi_start_xmit()
1306 void __iomem *ioaddr = hmp->base; in hamachi_interrupt()
1317 spin_lock(&hmp->lock); in hamachi_interrupt()
1324 dev->name, intr_status); in hamachi_interrupt()
1339 if (hmp->tx_full){ in hamachi_interrupt()
1340 for (; hmp->cur_tx - hmp->dirty_tx > 0; hmp->dirty_tx++){ in hamachi_interrupt()
1341 int entry = hmp->dirty_tx % TX_RING_SIZE; in hamachi_interrupt()
1344 if (hmp->tx_ring[entry].status_n_length & cpu_to_le32(DescOwn)) in hamachi_interrupt()
1346 skb = hmp->tx_skbuff[entry]; in hamachi_interrupt()
1349 dma_unmap_single(&hmp->pci_dev->dev, in hamachi_interrupt()
1350 leXX_to_cpu(hmp->tx_ring[entry].addr), in hamachi_interrupt()
1351 skb->len, in hamachi_interrupt()
1354 hmp->tx_skbuff[entry] = NULL; in hamachi_interrupt()
1356 hmp->tx_ring[entry].status_n_length = 0; in hamachi_interrupt()
1357 if (entry >= TX_RING_SIZE-1) in hamachi_interrupt()
1358 hmp->tx_ring[TX_RING_SIZE-1].status_n_length |= in hamachi_interrupt()
1360 dev->stats.tx_packets++; in hamachi_interrupt()
1362 if (hmp->cur_tx - hmp->dirty_tx < TX_RING_SIZE - 4){ in hamachi_interrupt()
1364 hmp->tx_full = 0; in hamachi_interrupt()
1379 if (--boguscnt < 0) { in hamachi_interrupt()
1381 dev->name, intr_status); in hamachi_interrupt()
1388 dev->name, readl(ioaddr + IntrStatus)); in hamachi_interrupt()
1394 if (dev->start == 0 && --stopit < 0) { in hamachi_interrupt()
1396 dev->name); in hamachi_interrupt()
1402 spin_unlock(&hmp->lock); in hamachi_interrupt()
1411 int entry = hmp->cur_rx % RX_RING_SIZE; in hamachi_rx()
1412 int boguscnt = (hmp->dirty_rx + RX_RING_SIZE) - hmp->cur_rx; in hamachi_rx()
1416 entry, hmp->rx_ring[entry].status_n_length); in hamachi_rx()
1421 struct hamachi_desc *desc = &(hmp->rx_ring[entry]); in hamachi_rx()
1422 u32 desc_status = le32_to_cpu(desc->status_n_length); in hamachi_rx()
1429 dma_sync_single_for_cpu(&hmp->pci_dev->dev, in hamachi_rx()
1430 leXX_to_cpu(desc->addr), in hamachi_rx()
1431 hmp->rx_buf_sz, DMA_FROM_DEVICE); in hamachi_rx()
1432 buf_addr = (u8 *) hmp->rx_skbuff[entry]->data; in hamachi_rx()
1433 frame_status = get_unaligned_le32(&(buf_addr[data_size - 12])); in hamachi_rx()
1437 if (--boguscnt < 0) in hamachi_rx()
1442 dev->name, hmp->cur_rx, data_size, desc_status); in hamachi_rx()
1444 dev->name, desc, &hmp->rx_ring[hmp->cur_rx % RX_RING_SIZE]); in hamachi_rx()
1445 printk(KERN_WARNING "%s: Oversized Ethernet frame -- next status %x/%x last status %x.\n", in hamachi_rx()
1446 dev->name, in hamachi_rx()
1447 le32_to_cpu(hmp->rx_ring[(hmp->cur_rx+1) % RX_RING_SIZE].status_n_length) & 0xffff0000, in hamachi_rx()
1448 le32_to_cpu(hmp->rx_ring[(hmp->cur_rx+1) % RX_RING_SIZE].status_n_length) & 0x0000ffff, in hamachi_rx()
1449 le32_to_cpu(hmp->rx_ring[(hmp->cur_rx-1) % RX_RING_SIZE].status_n_length)); in hamachi_rx()
1450 dev->stats.rx_length_errors++; in hamachi_rx()
1457 dev->stats.rx_errors++; in hamachi_rx()
1459 dev->stats.rx_length_errors++; in hamachi_rx()
1461 dev->stats.rx_frame_errors++; in hamachi_rx()
1463 dev->stats.rx_crc_errors++; in hamachi_rx()
1465 dev->stats.rx_dropped++; in hamachi_rx()
1469 u16 pkt_len = (frame_status & 0x07ff) - 4; in hamachi_rx()
1471 u32 pfck = *(u32 *) &buf_addr[data_size - 8]; in hamachi_rx()
1482 dev->name, in hamachi_rx()
1483 *(s32*)&(buf_addr[data_size - 20]), in hamachi_rx()
1484 *(s32*)&(buf_addr[data_size - 16]), in hamachi_rx()
1485 *(s32*)&(buf_addr[data_size - 12]), in hamachi_rx()
1486 *(s32*)&(buf_addr[data_size - 8]), in hamachi_rx()
1487 *(s32*)&(buf_addr[data_size - 4])); in hamachi_rx()
1490 to a minimally-sized skbuff. */ in hamachi_rx()
1494 printk(KERN_ERR "%s: rx_copybreak non-zero " in hamachi_rx()
1495 "not good with RX_CHECKSUM\n", dev->name); in hamachi_rx()
1498 dma_sync_single_for_cpu(&hmp->pci_dev->dev, in hamachi_rx()
1499 leXX_to_cpu(hmp->rx_ring[entry].addr), in hamachi_rx()
1500 hmp->rx_buf_sz, in hamachi_rx()
1505 hmp->rx_skbuff[entry]->data, pkt_len); in hamachi_rx()
1508 skb_put_data(skb, hmp->rx_ring_dma in hamachi_rx()
1511 dma_sync_single_for_device(&hmp->pci_dev->dev, in hamachi_rx()
1512 leXX_to_cpu(hmp->rx_ring[entry].addr), in hamachi_rx()
1513 hmp->rx_buf_sz, in hamachi_rx()
1516 dma_unmap_single(&hmp->pci_dev->dev, in hamachi_rx()
1517 leXX_to_cpu(hmp->rx_ring[entry].addr), in hamachi_rx()
1518 hmp->rx_buf_sz, in hamachi_rx()
1520 skb_put(skb = hmp->rx_skbuff[entry], pkt_len); in hamachi_rx()
1521 hmp->rx_skbuff[entry] = NULL; in hamachi_rx()
1523 skb->protocol = eth_type_trans(skb, dev); in hamachi_rx()
1529 struct iphdr *ih = (struct iphdr *) skb->data; in hamachi_rx()
1534 if (ntohs(ih->tot_len) >= 46){ in hamachi_rx()
1536 if (!(ih->frag_off & cpu_to_be16(IP_MF|IP_OFFSET))) { in hamachi_rx()
1537 u32 inv = *(u32 *) &buf_addr[data_size - 16]; in hamachi_rx()
1538 u32 *p = (u32 *) &buf_addr[data_size - 20]; in hamachi_rx()
1543 --p; in hamachi_rx()
1546 p_r1 = *(p-1); in hamachi_rx()
1568 skb->csum = ntohs(pfck & 0xffff); in hamachi_rx()
1569 if (skb->csum > crc) in hamachi_rx()
1570 skb->csum -= crc; in hamachi_rx()
1572 skb->csum += (~crc & 0xffff); in hamachi_rx()
1577 skb->ip_summed = CHECKSUM_COMPLETE; in hamachi_rx()
1584 dev->stats.rx_packets++; in hamachi_rx()
1586 entry = (++hmp->cur_rx) % RX_RING_SIZE; in hamachi_rx()
1590 for (; hmp->cur_rx - hmp->dirty_rx > 0; hmp->dirty_rx++) { in hamachi_rx()
1593 entry = hmp->dirty_rx % RX_RING_SIZE; in hamachi_rx()
1594 desc = &(hmp->rx_ring[entry]); in hamachi_rx()
1595 if (hmp->rx_skbuff[entry] == NULL) { in hamachi_rx()
1596 struct sk_buff *skb = netdev_alloc_skb(dev, hmp->rx_buf_sz + 2); in hamachi_rx()
1598 hmp->rx_skbuff[entry] = skb; in hamachi_rx()
1602 desc->addr = cpu_to_leXX(dma_map_single(&hmp->pci_dev->dev, in hamachi_rx()
1603 skb->data, in hamachi_rx()
1604 hmp->rx_buf_sz, in hamachi_rx()
1607 desc->status_n_length = cpu_to_le32(hmp->rx_buf_sz); in hamachi_rx()
1608 if (entry >= RX_RING_SIZE-1) in hamachi_rx()
1609 desc->status_n_length |= cpu_to_le32(DescOwn | in hamachi_rx()
1612 desc->status_n_length |= cpu_to_le32(DescOwn | in hamachi_rx()
1617 /* If we don't need to check status, don't. -KDU */ in hamachi_rx()
1618 if (readw(hmp->base + RxStatus) & 0x0002) in hamachi_rx()
1619 writew(0x0001, hmp->base + RxCmd); in hamachi_rx()
1629 void __iomem *ioaddr = hmp->base; in hamachi_error()
1635 dev->name, readw(ioaddr + 0x0E0), readw(ioaddr + 0x0E2), in hamachi_error()
1652 dev->name, intr_status); in hamachi_error()
1655 dev->stats.tx_fifo_errors++; in hamachi_error()
1657 dev->stats.rx_fifo_errors++; in hamachi_error()
1663 void __iomem *ioaddr = hmp->base; in hamachi_close()
1671 dev->name, readw(ioaddr + TxStatus), in hamachi_close()
1674 dev->name, hmp->cur_tx, hmp->dirty_tx, hmp->cur_rx, hmp->dirty_rx); in hamachi_close()
1687 (int)hmp->tx_ring_dma); in hamachi_close()
1690 readl(ioaddr + TxCurPtr) == (long)&hmp->tx_ring[i] ? '>' : ' ', in hamachi_close()
1691 i, hmp->tx_ring[i].status_n_length, hmp->tx_ring[i].addr); in hamachi_close()
1693 (int)hmp->rx_ring_dma); in hamachi_close()
1696 readl(ioaddr + RxCurPtr) == (long)&hmp->rx_ring[i] ? '>' : ' ', in hamachi_close()
1697 i, hmp->rx_ring[i].status_n_length, hmp->rx_ring[i].addr); in hamachi_close()
1699 if (*(u8*)hmp->rx_skbuff[i]->data != 0x69) { in hamachi_close()
1701 hmp->rx_skbuff[i]->data; in hamachi_close()
1713 free_irq(hmp->pci_dev->irq, dev); in hamachi_close()
1715 del_timer_sync(&hmp->timer); in hamachi_close()
1719 skb = hmp->rx_skbuff[i]; in hamachi_close()
1720 hmp->rx_ring[i].status_n_length = 0; in hamachi_close()
1722 dma_unmap_single(&hmp->pci_dev->dev, in hamachi_close()
1723 leXX_to_cpu(hmp->rx_ring[i].addr), in hamachi_close()
1724 hmp->rx_buf_sz, DMA_FROM_DEVICE); in hamachi_close()
1726 hmp->rx_skbuff[i] = NULL; in hamachi_close()
1728 hmp->rx_ring[i].addr = cpu_to_leXX(0xBADF00D0); /* An invalid address. */ in hamachi_close()
1731 skb = hmp->tx_skbuff[i]; in hamachi_close()
1733 dma_unmap_single(&hmp->pci_dev->dev, in hamachi_close()
1734 leXX_to_cpu(hmp->tx_ring[i].addr), in hamachi_close()
1735 skb->len, DMA_TO_DEVICE); in hamachi_close()
1737 hmp->tx_skbuff[i] = NULL; in hamachi_close()
1749 void __iomem *ioaddr = hmp->base; in hamachi_get_stats()
1752 the vulnerability window is very small and statistics are in hamachi_get_stats()
1753 non-critical. */ in hamachi_get_stats()
1759 /* dev->stats.tx_packets = readl(ioaddr + 0x000); */ in hamachi_get_stats()
1762 dev->stats.rx_bytes = readl(ioaddr + 0x330); in hamachi_get_stats()
1764 dev->stats.tx_bytes = readl(ioaddr + 0x3B0); in hamachi_get_stats()
1766 dev->stats.multicast = readl(ioaddr + 0x320); in hamachi_get_stats()
1769 dev->stats.rx_length_errors = readl(ioaddr + 0x368); in hamachi_get_stats()
1771 dev->stats.rx_over_errors = readl(ioaddr + 0x35C); in hamachi_get_stats()
1773 dev->stats.rx_crc_errors = readl(ioaddr + 0x360); in hamachi_get_stats()
1775 dev->stats.rx_frame_errors = readl(ioaddr + 0x364); in hamachi_get_stats()
1777 dev->stats.rx_missed_errors = readl(ioaddr + 0x36C); in hamachi_get_stats()
1779 return &dev->stats; in hamachi_get_stats()
1785 void __iomem *ioaddr = hmp->base; in set_rx_mode()
1787 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ in set_rx_mode()
1789 } else if ((netdev_mc_count(dev) > 63) || (dev->flags & IFF_ALLMULTI)) { in set_rx_mode()
1797 writel(*(u32 *)(ha->addr), ioaddr + 0x100 + i*8); in set_rx_mode()
1798 writel(0x20000 | (*(u16 *)&ha->addr[4]), in set_rx_mode()
1806 } else { /* Normal, unicast/broadcast-only mode. */ in set_rx_mode()
1814 return -EINVAL; in check_if_running()
1822 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in hamachi_get_drvinfo()
1823 strscpy(info->version, DRV_VERSION, sizeof(info->version)); in hamachi_get_drvinfo()
1824 strscpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); in hamachi_get_drvinfo()
1831 spin_lock_irq(&np->lock); in hamachi_get_link_ksettings()
1832 mii_ethtool_get_link_ksettings(&np->mii_if, cmd); in hamachi_get_link_ksettings()
1833 spin_unlock_irq(&np->lock); in hamachi_get_link_ksettings()
1842 spin_lock_irq(&np->lock); in hamachi_set_link_ksettings()
1843 res = mii_ethtool_set_link_ksettings(&np->mii_if, cmd); in hamachi_set_link_ksettings()
1844 spin_unlock_irq(&np->lock); in hamachi_set_link_ksettings()
1851 return mii_nway_restart(&np->mii_if); in hamachi_nway_reset()
1857 return mii_link_ok(&np->mii_if); in hamachi_get_link()
1879 u32 *d = (u32 *)&rq->ifr_ifru; in hamachi_siocdevprivate()
1882 return -EINVAL; in hamachi_siocdevprivate()
1885 return -EOPNOTSUPP; in hamachi_siocdevprivate()
1888 * things. -KDU in hamachi_siocdevprivate()
1893 return -EPERM; in hamachi_siocdevprivate()
1894 writel(d[0], np->base + TxIntrCtrl); in hamachi_siocdevprivate()
1895 writel(d[1], np->base + RxIntrCtrl); in hamachi_siocdevprivate()
1896 printk(KERN_NOTICE "%s: tx %08x, rx %08x intr\n", dev->name, in hamachi_siocdevprivate()
1897 (u32)readl(np->base + TxIntrCtrl), in hamachi_siocdevprivate()
1898 (u32)readl(np->base + RxIntrCtrl)); in hamachi_siocdevprivate()
1910 return -EINVAL; in hamachi_ioctl()
1912 spin_lock_irq(&np->lock); in hamachi_ioctl()
1913 rc = generic_mii_ioctl(&np->mii_if, data, cmd, NULL); in hamachi_ioctl()
1914 spin_unlock_irq(&np->lock); in hamachi_ioctl()
1927 dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, hmp->rx_ring, in hamachi_remove_one()
1928 hmp->rx_ring_dma); in hamachi_remove_one()
1929 dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, hmp->tx_ring, in hamachi_remove_one()
1930 hmp->tx_ring_dma); in hamachi_remove_one()
1932 iounmap(hmp->base); in hamachi_remove_one()