Lines Matching +full:bottom +full:- +full:beta
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright 1998-2002 by Jes Sorensen, <jes@trained-monkey.org>.
13 * about the driver. Send mail to linux-acenic-help@sunsite.auc.dk to
55 #include <linux/dma-mapping.h>
90 #define ACE_IS_TIGON_I(ap) (ap->version == 1)
91 #define ACE_TX_RING_ENTRIES(ap) ap->tx_ring_entries
115 * to care - stinky!
163 #define BOARD_IDX_OVERFLOW -1
188 * the parts dealing with the i2c eeprom on the card ;-)
203 * trace=<val> - Firmware trace level. This requires special traced
205 * the driver - for debugging purposes only.
207 * link=<val> - Link state. Normally you want to use the default link
211 * 0x0001 - Force half duplex link.
212 * 0x0002 - Do not negotiate line speed with the other end.
213 * 0x0010 - 10Mbit/sec link.
214 * 0x0020 - 100Mbit/sec link.
215 * 0x0040 - 1000Mbit/sec link.
216 * 0x0100 - Do not negotiate flow control.
217 * 0x0200 - Enable RX flow control Y
218 * 0x0400 - Enable TX flow control Y (Tigon II NICs only).
226 * tx_coal_tick=<val> - number of coalescing clock ticks (us) allowed
231 * rx_coal_tick=<val> - number of coalescing clock ticks (us) allowed
236 * max_tx_desc=<val> - maximum number of transmit descriptors
239 * max_rx_desc=<val> - maximum number of receive descriptors
242 * tx_ratio=<val> - 7 bit value (0 - 63) specifying the split in 64th
248 * dis_pci_mem_inval=<val> - disable PCI memory write and invalidate
261 * - Proper multicast support.
262 * - NIC dump support.
263 * - More tuning parameters.
274 * of the main interrupt handler and do it in a bottom half handler
281 * RX_LOW_BUF_THRES - allocate buffers in the bottom half
282 * RX_PANIC_LOW_THRES - we are very low on buffers, allocate
284 * RX_RING_THRES - maximum number of buffers in the rx ring
285 * RX_MINI_THRES - maximum number of buffers in the mini ring
286 * RX_JUMBO_THRES - maximum number of buffers in the jumbo ring
295 * Note that running the skb reallocation in a bottom half opens up
298 * the reallocation while the bottom half is either running on another
318 * Threshold values for RX buffer allocation - the low water marks for
400 MODULE_AUTHOR("Jes Sorensen <jes@trained-monkey.org>");
421 …M_DESC(tx_ratio, "AceNIC/3C985/GA620 ratio of NIC memory used for TX/RX descriptors (range 0-63)");
425 "acenic.c: v0.92 08/05/2002 Jes Sorensen, linux-acenic@SunSITE.dk\n"
463 return -ENOMEM; in acenic_probe_one()
465 SET_NETDEV_DEV(dev, &pdev->dev); in acenic_probe_one()
468 ap->ndev = dev; in acenic_probe_one()
469 ap->pdev = pdev; in acenic_probe_one()
470 ap->name = pci_name(pdev); in acenic_probe_one()
472 dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; in acenic_probe_one()
473 dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX; in acenic_probe_one()
475 dev->watchdog_timeo = 5*HZ; in acenic_probe_one()
476 dev->min_mtu = 0; in acenic_probe_one()
477 dev->max_mtu = ACE_JUMBO_MTU; in acenic_probe_one()
479 dev->netdev_ops = &ace_netdev_ops; in acenic_probe_one()
480 dev->ethtool_ops = &ace_ethtool_ops; in acenic_probe_one()
496 pci_read_config_word(pdev, PCI_COMMAND, &ap->pci_command); in acenic_probe_one()
498 /* OpenFirmware on Mac's does not set this - DOH.. */ in acenic_probe_one()
499 if (!(ap->pci_command & PCI_COMMAND_MEMORY)) { in acenic_probe_one()
501 "access - was not enabled by BIOS/Firmware\n", in acenic_probe_one()
502 ap->name); in acenic_probe_one()
503 ap->pci_command = ap->pci_command | PCI_COMMAND_MEMORY; in acenic_probe_one()
504 pci_write_config_word(ap->pdev, PCI_COMMAND, in acenic_probe_one()
505 ap->pci_command); in acenic_probe_one()
509 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &ap->pci_latency); in acenic_probe_one()
510 if (ap->pci_latency <= 0x40) { in acenic_probe_one()
511 ap->pci_latency = 0x40; in acenic_probe_one()
512 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, ap->pci_latency); in acenic_probe_one()
516 * Remap the regs into kernel space - this is abuse of in acenic_probe_one()
517 * dev->base_addr since it was means for I/O port in acenic_probe_one()
520 dev->base_addr = pci_resource_start(pdev, 0); in acenic_probe_one()
521 ap->regs = ioremap(dev->base_addr, 0x4000); in acenic_probe_one()
522 if (!ap->regs) { in acenic_probe_one()
525 ap->name, boards_found); in acenic_probe_one()
529 switch(pdev->vendor) { in acenic_probe_one()
531 if (pdev->device == PCI_DEVICE_ID_FARALLON_PN9100T) { in acenic_probe_one()
532 printk(KERN_INFO "%s: Farallon PN9100-T ", in acenic_probe_one()
533 ap->name); in acenic_probe_one()
536 ap->name); in acenic_probe_one()
540 printk(KERN_INFO "%s: 3Com 3C985 ", ap->name); in acenic_probe_one()
543 printk(KERN_INFO "%s: NetGear GA620 ", ap->name); in acenic_probe_one()
546 if (pdev->device == PCI_DEVICE_ID_FARALLON_PN9000SX) { in acenic_probe_one()
547 printk(KERN_INFO "%s: Farallon PN9000-SX ", in acenic_probe_one()
548 ap->name); in acenic_probe_one()
553 printk(KERN_INFO "%s: SGI AceNIC ", ap->name); in acenic_probe_one()
556 printk(KERN_INFO "%s: Unknown AceNIC ", ap->name); in acenic_probe_one()
560 printk("Gigabit Ethernet at 0x%08lx, ", dev->base_addr); in acenic_probe_one()
561 printk("irq %d\n", pdev->irq); in acenic_probe_one()
564 if ((readl(&ap->regs->HostCtrl) >> 28) == 4) { in acenic_probe_one()
566 " support - NIC disabled\n", dev->name); in acenic_probe_one()
576 ap->board_idx = BOARD_IDX_OVERFLOW; in acenic_probe_one()
578 ap->board_idx = boards_found; in acenic_probe_one()
580 ap->board_idx = BOARD_IDX_STATIC; in acenic_probe_one()
590 ap->name = dev->name; in acenic_probe_one()
592 dev->features |= NETIF_F_HIGHDMA; in acenic_probe_one()
603 return -ENODEV; in acenic_probe_one()
610 struct ace_regs __iomem *regs = ap->regs; in acenic_remove_one()
615 writel(readl(®s->CpuCtrl) | CPU_HALT, ®s->CpuCtrl); in acenic_remove_one()
616 if (ap->version >= 2) in acenic_remove_one()
617 writel(readl(®s->CpuBCtrl) | CPU_HALT, ®s->CpuBCtrl); in acenic_remove_one()
622 writel(1, ®s->Mb0Lo); in acenic_remove_one()
623 readl(®s->CpuCtrl); /* flush */ in acenic_remove_one()
631 * Then release the RX buffers - jumbo buffers were in acenic_remove_one()
634 ace_sync_irq(dev->irq); in acenic_remove_one()
637 struct sk_buff *skb = ap->skb->rx_std_skbuff[i].skb; in acenic_remove_one()
643 ringp = &ap->skb->rx_std_skbuff[i]; in acenic_remove_one()
645 dma_unmap_page(&ap->pdev->dev, mapping, in acenic_remove_one()
648 ap->rx_std_ring[i].size = 0; in acenic_remove_one()
649 ap->skb->rx_std_skbuff[i].skb = NULL; in acenic_remove_one()
654 if (ap->version >= 2) { in acenic_remove_one()
656 struct sk_buff *skb = ap->skb->rx_mini_skbuff[i].skb; in acenic_remove_one()
662 ringp = &ap->skb->rx_mini_skbuff[i]; in acenic_remove_one()
664 dma_unmap_page(&ap->pdev->dev, mapping, in acenic_remove_one()
668 ap->rx_mini_ring[i].size = 0; in acenic_remove_one()
669 ap->skb->rx_mini_skbuff[i].skb = NULL; in acenic_remove_one()
676 struct sk_buff *skb = ap->skb->rx_jumbo_skbuff[i].skb; in acenic_remove_one()
681 ringp = &ap->skb->rx_jumbo_skbuff[i]; in acenic_remove_one()
683 dma_unmap_page(&ap->pdev->dev, mapping, in acenic_remove_one()
686 ap->rx_jumbo_ring[i].size = 0; in acenic_remove_one()
687 ap->skb->rx_jumbo_skbuff[i].skb = NULL; in acenic_remove_one()
708 if (ap->rx_std_ring != NULL) { in ace_free_descriptors()
714 dma_free_coherent(&ap->pdev->dev, size, ap->rx_std_ring, in ace_free_descriptors()
715 ap->rx_ring_base_dma); in ace_free_descriptors()
716 ap->rx_std_ring = NULL; in ace_free_descriptors()
717 ap->rx_jumbo_ring = NULL; in ace_free_descriptors()
718 ap->rx_mini_ring = NULL; in ace_free_descriptors()
719 ap->rx_return_ring = NULL; in ace_free_descriptors()
721 if (ap->evt_ring != NULL) { in ace_free_descriptors()
723 dma_free_coherent(&ap->pdev->dev, size, ap->evt_ring, in ace_free_descriptors()
724 ap->evt_ring_dma); in ace_free_descriptors()
725 ap->evt_ring = NULL; in ace_free_descriptors()
727 if (ap->tx_ring != NULL && !ACE_IS_TIGON_I(ap)) { in ace_free_descriptors()
729 dma_free_coherent(&ap->pdev->dev, size, ap->tx_ring, in ace_free_descriptors()
730 ap->tx_ring_dma); in ace_free_descriptors()
732 ap->tx_ring = NULL; in ace_free_descriptors()
734 if (ap->evt_prd != NULL) { in ace_free_descriptors()
735 dma_free_coherent(&ap->pdev->dev, sizeof(u32), in ace_free_descriptors()
736 (void *)ap->evt_prd, ap->evt_prd_dma); in ace_free_descriptors()
737 ap->evt_prd = NULL; in ace_free_descriptors()
739 if (ap->rx_ret_prd != NULL) { in ace_free_descriptors()
740 dma_free_coherent(&ap->pdev->dev, sizeof(u32), in ace_free_descriptors()
741 (void *)ap->rx_ret_prd, ap->rx_ret_prd_dma); in ace_free_descriptors()
742 ap->rx_ret_prd = NULL; in ace_free_descriptors()
744 if (ap->tx_csm != NULL) { in ace_free_descriptors()
745 dma_free_coherent(&ap->pdev->dev, sizeof(u32), in ace_free_descriptors()
746 (void *)ap->tx_csm, ap->tx_csm_dma); in ace_free_descriptors()
747 ap->tx_csm = NULL; in ace_free_descriptors()
763 ap->rx_std_ring = dma_alloc_coherent(&ap->pdev->dev, size, in ace_allocate_descriptors()
764 &ap->rx_ring_base_dma, GFP_KERNEL); in ace_allocate_descriptors()
765 if (ap->rx_std_ring == NULL) in ace_allocate_descriptors()
768 ap->rx_jumbo_ring = ap->rx_std_ring + RX_STD_RING_ENTRIES; in ace_allocate_descriptors()
769 ap->rx_mini_ring = ap->rx_jumbo_ring + RX_JUMBO_RING_ENTRIES; in ace_allocate_descriptors()
770 ap->rx_return_ring = ap->rx_mini_ring + RX_MINI_RING_ENTRIES; in ace_allocate_descriptors()
774 ap->evt_ring = dma_alloc_coherent(&ap->pdev->dev, size, in ace_allocate_descriptors()
775 &ap->evt_ring_dma, GFP_KERNEL); in ace_allocate_descriptors()
777 if (ap->evt_ring == NULL) in ace_allocate_descriptors()
782 * has to use PCI registers for this ;-( in ace_allocate_descriptors()
787 ap->tx_ring = dma_alloc_coherent(&ap->pdev->dev, size, in ace_allocate_descriptors()
788 &ap->tx_ring_dma, GFP_KERNEL); in ace_allocate_descriptors()
790 if (ap->tx_ring == NULL) in ace_allocate_descriptors()
794 ap->evt_prd = dma_alloc_coherent(&ap->pdev->dev, sizeof(u32), in ace_allocate_descriptors()
795 &ap->evt_prd_dma, GFP_KERNEL); in ace_allocate_descriptors()
796 if (ap->evt_prd == NULL) in ace_allocate_descriptors()
799 ap->rx_ret_prd = dma_alloc_coherent(&ap->pdev->dev, sizeof(u32), in ace_allocate_descriptors()
800 &ap->rx_ret_prd_dma, GFP_KERNEL); in ace_allocate_descriptors()
801 if (ap->rx_ret_prd == NULL) in ace_allocate_descriptors()
804 ap->tx_csm = dma_alloc_coherent(&ap->pdev->dev, sizeof(u32), in ace_allocate_descriptors()
805 &ap->tx_csm_dma, GFP_KERNEL); in ace_allocate_descriptors()
806 if (ap->tx_csm == NULL) in ace_allocate_descriptors()
830 if (ap->info) in ace_init_cleanup()
831 dma_free_coherent(&ap->pdev->dev, sizeof(struct ace_info), in ace_init_cleanup()
832 ap->info, ap->info_dma); in ace_init_cleanup()
833 kfree(ap->skb); in ace_init_cleanup()
834 kfree(ap->trace_buf); in ace_init_cleanup()
836 if (dev->irq) in ace_init_cleanup()
837 free_irq(dev->irq, dev); in ace_init_cleanup()
839 iounmap(ap->regs); in ace_init_cleanup()
850 idx = readl(®s->CmdPrd); in ace_issue_cmd()
852 writel(*(u32 *)(cmd), ®s->CmdRng[idx]); in ace_issue_cmd()
855 writel(idx, ®s->CmdPrd); in ace_issue_cmd()
874 regs = ap->regs; in ace_init()
876 board_idx = ap->board_idx; in ace_init()
879 * aman@sgi.com - its useful to do a NIC reset here to in ace_init()
883 writel(HW_RESET | (HW_RESET << 24), ®s->HostCtrl); in ace_init()
884 readl(®s->HostCtrl); /* PCI write posting */ in ace_init()
896 ®s->HostCtrl); in ace_init()
899 ®s->HostCtrl); in ace_init()
901 readl(®s->HostCtrl); /* PCI write posting */ in ace_init()
906 writel(readl(®s->CpuCtrl) | CPU_HALT, ®s->CpuCtrl); in ace_init()
907 readl(®s->CpuCtrl); /* PCI write posting */ in ace_init()
908 writel(0, ®s->Mb0Lo); in ace_init()
910 tig_ver = readl(®s->HostCtrl) >> 28; in ace_init()
917 tig_ver, ap->firmware_major, ap->firmware_minor, in ace_init()
918 ap->firmware_fix); in ace_init()
919 writel(0, ®s->LocalCtrl); in ace_init()
920 ap->version = 1; in ace_init()
921 ap->tx_ring_entries = TIGON_I_TX_RING_ENTRIES; in ace_init()
926 tig_ver, ap->firmware_major, ap->firmware_minor, in ace_init()
927 ap->firmware_fix); in ace_init()
928 writel(readl(®s->CpuBCtrl) | CPU_HALT, ®s->CpuBCtrl); in ace_init()
929 readl(®s->CpuBCtrl); /* PCI write posting */ in ace_init()
935 writel(SRAM_BANK_512K, ®s->LocalCtrl); in ace_init()
936 writel(SYNC_SRAM_TIMING, ®s->MiscCfg); in ace_init()
937 ap->version = 2; in ace_init()
938 ap->tx_ring_entries = MAX_TX_RING_ENTRIES; in ace_init()
943 ecode = -ENODEV; in ace_init()
956 ACE_WORD_SWAP_BD | ACE_NO_JUMBO_FRAG, ®s->ModeStat); in ace_init()
959 ACE_WORD_SWAP_BD | ACE_NO_JUMBO_FRAG, ®s->ModeStat); in ace_init()
961 readl(®s->ModeStat); /* PCI write posting */ in ace_init()
970 ecode = -EIO; in ace_init()
982 ecode = -EIO; in ace_init()
988 writel(mac1, ®s->MacAddrHi); in ace_init()
989 writel(mac2, ®s->MacAddrLo); in ace_init()
999 printk("MAC: %pM\n", dev->dev_addr); in ace_init()
1007 pdev = ap->pdev; in ace_init()
1022 pci_state = readl(®s->PciState); in ace_init()
1027 ap->pci_latency); in ace_init()
1037 * - that is what Alteon does for NT. in ace_init()
1040 if (ap->version >= 2) { in ace_init()
1047 if (ap->pci_command & PCI_COMMAND_INVALIDATE) { in ace_init()
1048 ap->pci_command &= ~PCI_COMMAND_INVALIDATE; in ace_init()
1050 ap->pci_command); in ace_init()
1054 } else if (ap->pci_command & PCI_COMMAND_INVALIDATE) { in ace_init()
1075 ap->pci_command &= ~PCI_COMMAND_INVALIDATE; in ace_init()
1077 ap->pci_command); in ace_init()
1085 * are. We use 64-byte maximum bursts, because if we in ace_init()
1088 * PCI controller will disconnect at 64-byte multiples. in ace_init()
1090 * Read-multiple will be properly enabled above, and when in ace_init()
1108 writel(tmp, ®s->PciState); in ace_init()
1115 * the PCI-PCI bridge if that applies). in ace_init()
1116 * -ggg in ace_init()
1122 if (!(ap->pci_command & PCI_COMMAND_FAST_BACK)) { in ace_init()
1124 ap->pci_command |= PCI_COMMAND_FAST_BACK; in ace_init()
1125 pci_write_config_word(pdev, PCI_COMMAND, ap->pci_command); in ace_init()
1132 if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { in ace_init()
1133 ecode = -ENODEV; in ace_init()
1142 if (!(info = dma_alloc_coherent(&ap->pdev->dev, sizeof(struct ace_info), in ace_init()
1143 &ap->info_dma, GFP_KERNEL))) { in ace_init()
1144 ecode = -EAGAIN; in ace_init()
1147 ap->info = info; in ace_init()
1152 if (!(ap->skb = kzalloc(sizeof(struct ace_skb), GFP_KERNEL))) { in ace_init()
1153 ecode = -EAGAIN; in ace_init()
1157 ecode = request_irq(pdev->irq, ace_interrupt, IRQF_SHARED, in ace_init()
1161 DRV_NAME, pdev->irq); in ace_init()
1164 dev->irq = pdev->irq; in ace_init()
1167 spin_lock_init(&ap->debug_lock); in ace_init()
1168 ap->last_tx = ACE_TX_RING_ENTRIES(ap) - 1; in ace_init()
1169 ap->last_std_rx = 0; in ace_init()
1170 ap->last_mini_rx = 0; in ace_init()
1177 ap->fw_running = 0; in ace_init()
1179 tmp_ptr = ap->info_dma; in ace_init()
1180 writel(tmp_ptr >> 32, ®s->InfoPtrHi); in ace_init()
1181 writel(tmp_ptr & 0xffffffff, ®s->InfoPtrLo); in ace_init()
1183 memset(ap->evt_ring, 0, EVT_RING_ENTRIES * sizeof(struct event)); in ace_init()
1185 set_aceaddr(&info->evt_ctrl.rngptr, ap->evt_ring_dma); in ace_init()
1186 info->evt_ctrl.flags = 0; in ace_init()
1188 *(ap->evt_prd) = 0; in ace_init()
1190 set_aceaddr(&info->evt_prd_ptr, ap->evt_prd_dma); in ace_init()
1191 writel(0, ®s->EvtCsm); in ace_init()
1193 set_aceaddr(&info->cmd_ctrl.rngptr, 0x100); in ace_init()
1194 info->cmd_ctrl.flags = 0; in ace_init()
1195 info->cmd_ctrl.max_len = 0; in ace_init()
1198 writel(0, ®s->CmdRng[i]); in ace_init()
1200 writel(0, ®s->CmdPrd); in ace_init()
1201 writel(0, ®s->CmdCsm); in ace_init()
1203 tmp_ptr = ap->info_dma; in ace_init()
1204 tmp_ptr += (unsigned long) &(((struct ace_info *)0)->s.stats); in ace_init()
1205 set_aceaddr(&info->stats2_ptr, (dma_addr_t) tmp_ptr); in ace_init()
1207 set_aceaddr(&info->rx_std_ctrl.rngptr, ap->rx_ring_base_dma); in ace_init()
1208 info->rx_std_ctrl.max_len = ACE_STD_BUFSIZE; in ace_init()
1209 info->rx_std_ctrl.flags = in ace_init()
1212 memset(ap->rx_std_ring, 0, in ace_init()
1216 ap->rx_std_ring[i].flags = BD_FLG_TCP_UDP_SUM; in ace_init()
1218 ap->rx_std_skbprd = 0; in ace_init()
1219 atomic_set(&ap->cur_rx_bufs, 0); in ace_init()
1221 set_aceaddr(&info->rx_jumbo_ctrl.rngptr, in ace_init()
1222 (ap->rx_ring_base_dma + in ace_init()
1224 info->rx_jumbo_ctrl.max_len = 0; in ace_init()
1225 info->rx_jumbo_ctrl.flags = in ace_init()
1228 memset(ap->rx_jumbo_ring, 0, in ace_init()
1232 ap->rx_jumbo_ring[i].flags = BD_FLG_TCP_UDP_SUM | BD_FLG_JUMBO; in ace_init()
1234 ap->rx_jumbo_skbprd = 0; in ace_init()
1235 atomic_set(&ap->cur_jumbo_bufs, 0); in ace_init()
1237 memset(ap->rx_mini_ring, 0, in ace_init()
1240 if (ap->version >= 2) { in ace_init()
1241 set_aceaddr(&info->rx_mini_ctrl.rngptr, in ace_init()
1242 (ap->rx_ring_base_dma + in ace_init()
1246 info->rx_mini_ctrl.max_len = ACE_MINI_SIZE; in ace_init()
1247 info->rx_mini_ctrl.flags = in ace_init()
1251 ap->rx_mini_ring[i].flags = in ace_init()
1254 set_aceaddr(&info->rx_mini_ctrl.rngptr, 0); in ace_init()
1255 info->rx_mini_ctrl.flags = RCB_FLG_RNG_DISABLE; in ace_init()
1256 info->rx_mini_ctrl.max_len = 0; in ace_init()
1259 ap->rx_mini_skbprd = 0; in ace_init()
1260 atomic_set(&ap->cur_mini_bufs, 0); in ace_init()
1262 set_aceaddr(&info->rx_return_ctrl.rngptr, in ace_init()
1263 (ap->rx_ring_base_dma + in ace_init()
1268 info->rx_return_ctrl.flags = 0; in ace_init()
1269 info->rx_return_ctrl.max_len = RX_RETURN_RING_ENTRIES; in ace_init()
1271 memset(ap->rx_return_ring, 0, in ace_init()
1274 set_aceaddr(&info->rx_ret_prd_ptr, ap->rx_ret_prd_dma); in ace_init()
1275 *(ap->rx_ret_prd) = 0; in ace_init()
1277 writel(TX_RING_BASE, ®s->WinBase); in ace_init()
1280 ap->tx_ring = (__force struct tx_desc *) regs->Window; in ace_init()
1283 writel(0, (__force void __iomem *)ap->tx_ring + i * 4); in ace_init()
1285 set_aceaddr(&info->tx_ctrl.rngptr, TX_RING_BASE); in ace_init()
1287 memset(ap->tx_ring, 0, in ace_init()
1290 set_aceaddr(&info->tx_ctrl.rngptr, ap->tx_ring_dma); in ace_init()
1293 info->tx_ctrl.max_len = ACE_TX_RING_ENTRIES(ap); in ace_init()
1297 * The Tigon I does not like having the TX ring in host memory ;-( in ace_init()
1304 info->tx_ctrl.flags = tmp; in ace_init()
1306 set_aceaddr(&info->tx_csm_ptr, ap->tx_csm_dma); in ace_init()
1312 writel(DMA_THRESH_16W, ®s->DmaReadCfg); in ace_init()
1313 writel(DMA_THRESH_16W, ®s->DmaWriteCfg); in ace_init()
1315 writel(DMA_THRESH_8W, ®s->DmaReadCfg); in ace_init()
1316 writel(DMA_THRESH_8W, ®s->DmaWriteCfg); in ace_init()
1319 writel(0, ®s->MaskInt); in ace_init()
1320 writel(1, ®s->IfIdx); in ace_init()
1326 writel(1, ®s->AssistState); in ace_init()
1329 writel(DEF_STAT, ®s->TuneStatTicks); in ace_init()
1330 writel(DEF_TRACE, ®s->TuneTrace); in ace_init()
1337 ap->name, ACE_MAX_MOD_PARMS); in ace_init()
1341 ®s->TuneTxCoalTicks); in ace_init()
1343 writel(max_tx_desc[board_idx], ®s->TuneMaxTxDesc); in ace_init()
1347 ®s->TuneRxCoalTicks); in ace_init()
1349 writel(max_rx_desc[board_idx], ®s->TuneMaxRxDesc); in ace_init()
1352 writel(trace[board_idx], ®s->TuneTrace); in ace_init()
1355 writel(tx_ratio[board_idx], ®s->TxBufRat); in ace_init()
1363 if(ap->version >= 2) in ace_init()
1376 ap->name); in ace_init()
1389 "forcing auto negotiation\n", ap->name); in ace_init()
1397 "negotiation\n", ap->name); in ace_init()
1400 if ((option & 0x400) && (ap->version >= 2)) { in ace_init()
1402 ap->name); in ace_init()
1407 ap->link = tmp; in ace_init()
1408 writel(tmp, ®s->TuneLink); in ace_init()
1409 if (ap->version >= 2) in ace_init()
1410 writel(tmp, ®s->TuneFastLink); in ace_init()
1412 writel(ap->firmware_start, ®s->Pc); in ace_init()
1414 writel(0, ®s->Mb0Lo); in ace_init()
1422 ap->cur_rx = 0; in ace_init()
1423 ap->tx_prd = *(ap->tx_csm) = ap->tx_ret_csm = 0; in ace_init()
1427 writel(0, ®s->RxRetCsm); in ace_init()
1435 writel(1, ®s->AssistState); /* enable DMA */ in ace_init()
1440 writel(readl(®s->CpuCtrl) & ~(CPU_HALT|CPU_TRACE), ®s->CpuCtrl); in ace_init()
1441 readl(®s->CpuCtrl); in ace_init()
1444 * Wait for the firmware to spin up - max 3 seconds. in ace_init()
1447 while (time_before(jiffies, myjif) && !ap->fw_running) in ace_init()
1450 if (!ap->fw_running) { in ace_init()
1451 printk(KERN_ERR "%s: Firmware NOT running!\n", ap->name); in ace_init()
1454 writel(readl(®s->CpuCtrl) | CPU_HALT, ®s->CpuCtrl); in ace_init()
1455 readl(®s->CpuCtrl); in ace_init()
1457 /* aman@sgi.com - account for badly behaving firmware/NIC: in ace_init()
1458 * - have observed that the NIC may continue to generate in ace_init()
1459 * interrupts for some reason; attempt to stop it - halt in ace_init()
1461 * - if we're a module, we'll fail to load if this was in ace_init()
1464 * gone and OOps! - so free_irq also in ace_init()
1466 if (ap->version >= 2) in ace_init()
1467 writel(readl(®s->CpuBCtrl) | CPU_HALT, in ace_init()
1468 ®s->CpuBCtrl); in ace_init()
1469 writel(0, ®s->Mb0Lo); in ace_init()
1470 readl(®s->Mb0Lo); in ace_init()
1472 ecode = -EBUSY; in ace_init()
1478 * firmware to wipe the ring without re-initializing it. in ace_init()
1480 if (!test_and_set_bit(0, &ap->std_refill_busy)) in ace_init()
1484 ap->name); in ace_init()
1485 if (ap->version >= 2) { in ace_init()
1486 if (!test_and_set_bit(0, &ap->mini_refill_busy)) in ace_init()
1490 "the RX mini ring\n", ap->name); in ace_init()
1503 struct ace_regs __iomem *regs = ap->regs; in ace_set_rxtx_parms()
1504 int board_idx = ap->board_idx; in ace_set_rxtx_parms()
1509 writel(DEF_TX_COAL, ®s->TuneTxCoalTicks); in ace_set_rxtx_parms()
1511 writel(DEF_TX_MAX_DESC, ®s->TuneMaxTxDesc); in ace_set_rxtx_parms()
1513 writel(DEF_RX_COAL, ®s->TuneRxCoalTicks); in ace_set_rxtx_parms()
1515 writel(DEF_RX_MAX_DESC, ®s->TuneMaxRxDesc); in ace_set_rxtx_parms()
1517 writel(DEF_TX_RATIO, ®s->TxBufRat); in ace_set_rxtx_parms()
1521 ®s->TuneTxCoalTicks); in ace_set_rxtx_parms()
1524 ®s->TuneMaxTxDesc); in ace_set_rxtx_parms()
1527 ®s->TuneRxCoalTicks); in ace_set_rxtx_parms()
1530 ®s->TuneMaxRxDesc); in ace_set_rxtx_parms()
1532 writel(DEF_JUMBO_TX_RATIO, ®s->TxBufRat); in ace_set_rxtx_parms()
1542 struct ace_regs __iomem *regs = ap->regs; in ace_watchdog()
1549 if (*ap->tx_csm != ap->tx_ret_csm) { in ace_watchdog()
1551 dev->name, (unsigned int)readl(®s->HostCtrl)); in ace_watchdog()
1555 dev->name); in ace_watchdog()
1566 struct net_device *dev = ap->ndev; in ace_bh_work()
1569 cur_size = atomic_read(&ap->cur_rx_bufs); in ace_bh_work()
1571 !test_and_set_bit(0, &ap->std_refill_busy)) { in ace_bh_work()
1575 ace_load_std_rx_ring(dev, RX_RING_SIZE - cur_size); in ace_bh_work()
1578 if (ap->version >= 2) { in ace_bh_work()
1579 cur_size = atomic_read(&ap->cur_mini_bufs); in ace_bh_work()
1581 !test_and_set_bit(0, &ap->mini_refill_busy)) { in ace_bh_work()
1586 ace_load_mini_rx_ring(dev, RX_MINI_SIZE - cur_size); in ace_bh_work()
1590 cur_size = atomic_read(&ap->cur_jumbo_bufs); in ace_bh_work()
1591 if (ap->jumbo && (cur_size < RX_LOW_JUMBO_THRES) && in ace_bh_work()
1592 !test_and_set_bit(0, &ap->jumbo_refill_busy)) { in ace_bh_work()
1596 ace_load_jumbo_rx_ring(dev, RX_JUMBO_SIZE - cur_size); in ace_bh_work()
1598 ap->bh_work_pending = 0; in ace_bh_work()
1608 if (!ap->trace_buf) in ace_dump_trace()
1609 if (!(ap->trace_buf = kmalloc(ACE_TRACE_SIZE, GFP_KERNEL))) in ace_dump_trace()
1625 struct ace_regs __iomem *regs = ap->regs; in ace_load_std_rx_ring()
1629 prefetchw(&ap->cur_rx_bufs); in ace_load_std_rx_ring()
1631 idx = ap->rx_std_skbprd; in ace_load_std_rx_ring()
1642 mapping = dma_map_page(&ap->pdev->dev, in ace_load_std_rx_ring()
1643 virt_to_page(skb->data), in ace_load_std_rx_ring()
1644 offset_in_page(skb->data), in ace_load_std_rx_ring()
1646 ap->skb->rx_std_skbuff[idx].skb = skb; in ace_load_std_rx_ring()
1647 dma_unmap_addr_set(&ap->skb->rx_std_skbuff[idx], in ace_load_std_rx_ring()
1650 rd = &ap->rx_std_ring[idx]; in ace_load_std_rx_ring()
1651 set_aceaddr(&rd->addr, mapping); in ace_load_std_rx_ring()
1652 rd->size = ACE_STD_BUFSIZE; in ace_load_std_rx_ring()
1653 rd->idx = idx; in ace_load_std_rx_ring()
1660 atomic_add(i, &ap->cur_rx_bufs); in ace_load_std_rx_ring()
1661 ap->rx_std_skbprd = idx; in ace_load_std_rx_ring()
1667 cmd.idx = ap->rx_std_skbprd; in ace_load_std_rx_ring()
1670 writel(idx, ®s->RxStdPrd); in ace_load_std_rx_ring()
1675 clear_bit(0, &ap->std_refill_busy); in ace_load_std_rx_ring()
1688 struct ace_regs __iomem *regs = ap->regs; in ace_load_mini_rx_ring()
1691 prefetchw(&ap->cur_mini_bufs); in ace_load_mini_rx_ring()
1693 idx = ap->rx_mini_skbprd; in ace_load_mini_rx_ring()
1703 mapping = dma_map_page(&ap->pdev->dev, in ace_load_mini_rx_ring()
1704 virt_to_page(skb->data), in ace_load_mini_rx_ring()
1705 offset_in_page(skb->data), in ace_load_mini_rx_ring()
1707 ap->skb->rx_mini_skbuff[idx].skb = skb; in ace_load_mini_rx_ring()
1708 dma_unmap_addr_set(&ap->skb->rx_mini_skbuff[idx], in ace_load_mini_rx_ring()
1711 rd = &ap->rx_mini_ring[idx]; in ace_load_mini_rx_ring()
1712 set_aceaddr(&rd->addr, mapping); in ace_load_mini_rx_ring()
1713 rd->size = ACE_MINI_BUFSIZE; in ace_load_mini_rx_ring()
1714 rd->idx = idx; in ace_load_mini_rx_ring()
1721 atomic_add(i, &ap->cur_mini_bufs); in ace_load_mini_rx_ring()
1723 ap->rx_mini_skbprd = idx; in ace_load_mini_rx_ring()
1725 writel(idx, ®s->RxMiniPrd); in ace_load_mini_rx_ring()
1729 clear_bit(0, &ap->mini_refill_busy); in ace_load_mini_rx_ring()
1745 struct ace_regs __iomem *regs = ap->regs; in ace_load_jumbo_rx_ring()
1748 idx = ap->rx_jumbo_skbprd; in ace_load_jumbo_rx_ring()
1759 mapping = dma_map_page(&ap->pdev->dev, in ace_load_jumbo_rx_ring()
1760 virt_to_page(skb->data), in ace_load_jumbo_rx_ring()
1761 offset_in_page(skb->data), in ace_load_jumbo_rx_ring()
1763 ap->skb->rx_jumbo_skbuff[idx].skb = skb; in ace_load_jumbo_rx_ring()
1764 dma_unmap_addr_set(&ap->skb->rx_jumbo_skbuff[idx], in ace_load_jumbo_rx_ring()
1767 rd = &ap->rx_jumbo_ring[idx]; in ace_load_jumbo_rx_ring()
1768 set_aceaddr(&rd->addr, mapping); in ace_load_jumbo_rx_ring()
1769 rd->size = ACE_JUMBO_BUFSIZE; in ace_load_jumbo_rx_ring()
1770 rd->idx = idx; in ace_load_jumbo_rx_ring()
1777 atomic_add(i, &ap->cur_jumbo_bufs); in ace_load_jumbo_rx_ring()
1778 ap->rx_jumbo_skbprd = idx; in ace_load_jumbo_rx_ring()
1784 cmd.idx = ap->rx_jumbo_skbprd; in ace_load_jumbo_rx_ring()
1787 writel(idx, ®s->RxJumboPrd); in ace_load_jumbo_rx_ring()
1792 clear_bit(0, &ap->jumbo_refill_busy); in ace_load_jumbo_rx_ring()
1814 switch (ap->evt_ring[evtcsm].evt) { in ace_handle_event()
1817 ap->name); in ace_handle_event()
1818 ap->fw_running = 1; in ace_handle_event()
1825 u16 code = ap->evt_ring[evtcsm].code; in ace_handle_event()
1829 u32 state = readl(&ap->regs->GigLnkState); in ace_handle_event()
1832 ap->name, in ace_handle_event()
1840 ap->name); in ace_handle_event()
1844 "UP\n", ap->name); in ace_handle_event()
1848 "state %02x\n", ap->name, code); in ace_handle_event()
1853 switch(ap->evt_ring[evtcsm].code) { in ace_handle_event()
1856 ap->name); in ace_handle_event()
1860 "error\n", ap->name); in ace_handle_event()
1864 ap->name); in ace_handle_event()
1868 ap->name, ap->evt_ring[evtcsm].code); in ace_handle_event()
1875 if (ap->skb->rx_jumbo_skbuff[i].skb) { in ace_handle_event()
1876 ap->rx_jumbo_ring[i].size = 0; in ace_handle_event()
1877 set_aceaddr(&ap->rx_jumbo_ring[i].addr, 0); in ace_handle_event()
1878 dev_kfree_skb(ap->skb->rx_jumbo_skbuff[i].skb); in ace_handle_event()
1879 ap->skb->rx_jumbo_skbuff[i].skb = NULL; in ace_handle_event()
1888 ace_issue_cmd(ap->regs, &cmd); in ace_handle_event()
1890 writel(0, &((ap->regs)->RxJumboPrd)); in ace_handle_event()
1894 ap->jumbo = 0; in ace_handle_event()
1895 ap->rx_jumbo_skbprd = 0; in ace_handle_event()
1897 ap->name); in ace_handle_event()
1898 clear_bit(0, &ap->jumbo_refill_busy); in ace_handle_event()
1903 ap->name, ap->evt_ring[evtcsm].evt); in ace_handle_event()
1920 prefetchw(&ap->cur_rx_bufs); in ace_rx_int()
1921 prefetchw(&ap->cur_mini_bufs); in ace_rx_int()
1936 retdesc = &ap->rx_return_ring[idx]; in ace_rx_int()
1937 skbidx = retdesc->idx; in ace_rx_int()
1938 bd_flags = retdesc->flags; in ace_rx_int()
1950 rip = &ap->skb->rx_std_skbuff[skbidx]; in ace_rx_int()
1955 rip = &ap->skb->rx_jumbo_skbuff[skbidx]; in ace_rx_int()
1957 atomic_dec(&ap->cur_jumbo_bufs); in ace_rx_int()
1960 rip = &ap->skb->rx_mini_skbuff[skbidx]; in ace_rx_int()
1966 "returned by NIC\n", dev->name, in ace_rx_int()
1967 retdesc->flags); in ace_rx_int()
1971 skb = rip->skb; in ace_rx_int()
1972 rip->skb = NULL; in ace_rx_int()
1973 dma_unmap_page(&ap->pdev->dev, dma_unmap_addr(rip, mapping), in ace_rx_int()
1975 skb_put(skb, retdesc->size); in ace_rx_int()
1980 csum = retdesc->tcp_udp_csum; in ace_rx_int()
1982 skb->protocol = eth_type_trans(skb, dev); in ace_rx_int()
1989 skb->csum = htons(csum); in ace_rx_int()
1990 skb->ip_summed = CHECKSUM_COMPLETE; in ace_rx_int()
1997 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), retdesc->vlan); in ace_rx_int()
2000 dev->stats.rx_packets++; in ace_rx_int()
2001 dev->stats.rx_bytes += retdesc->size; in ace_rx_int()
2006 atomic_sub(std_count, &ap->cur_rx_bufs); in ace_rx_int()
2008 atomic_sub(mini_count, &ap->cur_mini_bufs); in ace_rx_int()
2013 * the 12.3.x Firmware - my Tigon I NICs seem to disagree! in ace_rx_int()
2016 writel(idx, &ap->regs->RxRetCsm); in ace_rx_int()
2018 ap->cur_rx = idx; in ace_rx_int()
2036 info = ap->skb->tx_skbuff + idx; in ace_tx_int()
2037 skb = info->skb; in ace_tx_int()
2040 dma_unmap_page(&ap->pdev->dev, in ace_tx_int()
2048 dev->stats.tx_packets++; in ace_tx_int()
2049 dev->stats.tx_bytes += skb->len; in ace_tx_int()
2051 info->skb = NULL; in ace_tx_int()
2061 ap->tx_ret_csm = txcsm; in ace_tx_int()
2085 * Well, this dilemma exists in all lock-free devices. in ace_tx_int()
2088 * --ANK in ace_tx_int()
2097 struct ace_regs __iomem *regs = ap->regs; in ace_interrupt()
2107 if (!(readl(®s->HostCtrl) & IN_INT)) in ace_interrupt()
2112 * which happened _after_ rxretprd = *ap->rx_ret_prd; but before in ace_interrupt()
2113 * writel(0, ®s->Mb0Lo). in ace_interrupt()
2118 writel(0, ®s->Mb0Lo); in ace_interrupt()
2119 readl(®s->Mb0Lo); in ace_interrupt()
2125 * working on the other stuff - hey we don't need a spin lock in ace_interrupt()
2128 rxretprd = *ap->rx_ret_prd; in ace_interrupt()
2129 rxretcsm = ap->cur_rx; in ace_interrupt()
2134 txcsm = *ap->tx_csm; in ace_interrupt()
2135 idx = ap->tx_ret_csm; in ace_interrupt()
2145 if (!tx_ring_full(ap, txcsm, ap->tx_prd)) in ace_interrupt()
2149 evtcsm = readl(®s->EvtCsm); in ace_interrupt()
2150 evtprd = *ap->evt_prd; in ace_interrupt()
2154 writel(evtcsm, ®s->EvtCsm); in ace_interrupt()
2165 cur_size = atomic_read(&ap->cur_rx_bufs); in ace_interrupt()
2168 !test_and_set_bit(0, &ap->std_refill_busy)) { in ace_interrupt()
2173 RX_RING_SIZE - cur_size); in ace_interrupt()
2179 cur_size = atomic_read(&ap->cur_mini_bufs); in ace_interrupt()
2183 &ap->mini_refill_busy)) { in ace_interrupt()
2189 RX_MINI_SIZE - cur_size); in ace_interrupt()
2195 if (ap->jumbo) { in ace_interrupt()
2196 cur_size = atomic_read(&ap->cur_jumbo_bufs); in ace_interrupt()
2200 &ap->jumbo_refill_busy)){ in ace_interrupt()
2206 RX_JUMBO_SIZE - cur_size); in ace_interrupt()
2211 if (run_bh_work && !ap->bh_work_pending) { in ace_interrupt()
2212 ap->bh_work_pending = 1; in ace_interrupt()
2213 queue_work(system_bh_wq, &ap->ace_bh_work); in ace_interrupt()
2223 struct ace_regs __iomem *regs = ap->regs; in ace_open()
2226 if (!(ap->fw_running)) { in ace_open()
2227 printk(KERN_WARNING "%s: Firmware not running!\n", dev->name); in ace_open()
2228 return -EBUSY; in ace_open()
2231 writel(dev->mtu + ETH_HLEN + 4, ®s->IfMtu); in ace_open()
2243 if (ap->jumbo && in ace_open()
2244 !test_and_set_bit(0, &ap->jumbo_refill_busy)) in ace_open()
2247 if (dev->flags & IFF_PROMISC) { in ace_open()
2253 ap->promisc = 1; in ace_open()
2255 ap->promisc = 0; in ace_open()
2256 ap->mcast_all = 0; in ace_open()
2268 * Setup the bottom half rx ring refill handler in ace_open()
2270 INIT_WORK(&ap->ace_bh_work, ace_bh_work); in ace_open()
2278 struct ace_regs __iomem *regs = ap->regs; in ace_close()
2285 * is an absolute non-sense, by the way. It will be reset instantly in ace_close()
2291 if (ap->promisc) { in ace_close()
2296 ap->promisc = 0; in ace_close()
2304 cancel_work_sync(&ap->ace_bh_work); in ace_close()
2318 info = ap->skb->tx_skbuff + i; in ace_close()
2319 skb = info->skb; in ace_close()
2325 tx = (__force struct tx_desc __iomem *) &ap->tx_ring[i]; in ace_close()
2326 writel(0, &tx->addr.addrhi); in ace_close()
2327 writel(0, &tx->addr.addrlo); in ace_close()
2328 writel(0, &tx->flagsize); in ace_close()
2330 memset(ap->tx_ring + i, 0, in ace_close()
2332 dma_unmap_page(&ap->pdev->dev, in ace_close()
2340 info->skb = NULL; in ace_close()
2344 if (ap->jumbo) { in ace_close()
2365 mapping = dma_map_page(&ap->pdev->dev, virt_to_page(skb->data), in ace_map_tx_skb()
2366 offset_in_page(skb->data), skb->len, in ace_map_tx_skb()
2369 info = ap->skb->tx_skbuff + idx; in ace_map_tx_skb()
2370 info->skb = tail; in ace_map_tx_skb()
2372 dma_unmap_len_set(info, maplen, skb->len); in ace_map_tx_skb()
2387 writel(addr >> 32, &io->addr.addrhi); in ace_load_tx_bd()
2388 writel(addr & 0xffffffff, &io->addr.addrlo); in ace_load_tx_bd()
2389 writel(flagsize, &io->flagsize); in ace_load_tx_bd()
2390 writel(vlan_tag, &io->vlanres); in ace_load_tx_bd()
2392 desc->addr.addrhi = addr >> 32; in ace_load_tx_bd()
2393 desc->addr.addrlo = addr; in ace_load_tx_bd()
2394 desc->flagsize = flagsize; in ace_load_tx_bd()
2395 desc->vlanres = vlan_tag; in ace_load_tx_bd()
2404 struct ace_regs __iomem *regs = ap->regs; in ace_start_xmit()
2410 idx = ap->tx_prd; in ace_start_xmit()
2412 if (tx_ring_full(ap, ap->tx_ret_csm, idx)) in ace_start_xmit()
2415 if (!skb_shinfo(skb)->nr_frags) { in ace_start_xmit()
2420 flagsize = (skb->len << 16) | (BD_FLG_END); in ace_start_xmit()
2421 if (skb->ip_summed == CHECKSUM_PARTIAL) in ace_start_xmit()
2427 desc = ap->tx_ring + idx; in ace_start_xmit()
2431 if (tx_ring_full(ap, ap->tx_ret_csm, idx)) in ace_start_xmit()
2442 if (skb->ip_summed == CHECKSUM_PARTIAL) in ace_start_xmit()
2449 ace_load_tx_bd(ap, ap->tx_ring + idx, mapping, flagsize, vlan_tag); in ace_start_xmit()
2453 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { in ace_start_xmit()
2454 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in ace_start_xmit()
2457 info = ap->skb->tx_skbuff + idx; in ace_start_xmit()
2458 desc = ap->tx_ring + idx; in ace_start_xmit()
2460 mapping = skb_frag_dma_map(&ap->pdev->dev, frag, 0, in ace_start_xmit()
2465 if (skb->ip_summed == CHECKSUM_PARTIAL) in ace_start_xmit()
2469 if (i == skb_shinfo(skb)->nr_frags - 1) { in ace_start_xmit()
2471 if (tx_ring_full(ap, ap->tx_ret_csm, idx)) in ace_start_xmit()
2478 info->skb = skb; in ace_start_xmit()
2480 info->skb = NULL; in ace_start_xmit()
2489 ap->tx_prd = idx; in ace_start_xmit()
2496 * A TX-descriptor producer (an IRQ) might have gotten in ace_start_xmit()
2499 * re-test. in ace_start_xmit()
2501 if (!tx_ring_full(ap, ap->tx_ret_csm, idx)) in ace_start_xmit()
2509 * This race condition is unavoidable with lock-free drivers. in ace_start_xmit()
2512 * This happens ~1-4 times per 100000 packets, so that we can allow in ace_start_xmit()
2517 * in tx ring than it is necessary (see original non-SG driver). in ace_start_xmit()
2531 printk(KERN_WARNING "%s: Transmit ring stuck full\n", dev->name); in ace_start_xmit()
2539 struct ace_regs __iomem *regs = ap->regs; in ace_change_mtu()
2541 writel(new_mtu + ETH_HLEN + 4, ®s->IfMtu); in ace_change_mtu()
2542 WRITE_ONCE(dev->mtu, new_mtu); in ace_change_mtu()
2545 if (!(ap->jumbo)) { in ace_change_mtu()
2547 "support\n", dev->name); in ace_change_mtu()
2548 ap->jumbo = 1; in ace_change_mtu()
2549 if (!test_and_set_bit(0, &ap->jumbo_refill_busy)) in ace_change_mtu()
2554 while (test_and_set_bit(0, &ap->jumbo_refill_busy)); in ace_change_mtu()
2555 ace_sync_irq(dev->irq); in ace_change_mtu()
2557 if (ap->jumbo) { in ace_change_mtu()
2574 struct ace_regs __iomem *regs = ap->regs; in ace_get_link_ksettings()
2585 cmd->base.port = PORT_FIBRE; in ace_get_link_ksettings()
2587 link = readl(®s->GigLnkState); in ace_get_link_ksettings()
2589 cmd->base.speed = SPEED_1000; in ace_get_link_ksettings()
2591 link = readl(®s->FastLnkState); in ace_get_link_ksettings()
2593 cmd->base.speed = SPEED_100; in ace_get_link_ksettings()
2595 cmd->base.speed = SPEED_10; in ace_get_link_ksettings()
2597 cmd->base.speed = 0; in ace_get_link_ksettings()
2600 cmd->base.duplex = DUPLEX_FULL; in ace_get_link_ksettings()
2602 cmd->base.duplex = DUPLEX_HALF; in ace_get_link_ksettings()
2605 cmd->base.autoneg = AUTONEG_ENABLE; in ace_get_link_ksettings()
2607 cmd->base.autoneg = AUTONEG_DISABLE; in ace_get_link_ksettings()
2613 ecmd->trace = readl(®s->TuneTrace); in ace_get_link_ksettings()
2615 ecmd->txcoal = readl(®s->TuneTxCoalTicks); in ace_get_link_ksettings()
2616 ecmd->rxcoal = readl(®s->TuneRxCoalTicks); in ace_get_link_ksettings()
2619 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, in ace_get_link_ksettings()
2629 struct ace_regs __iomem *regs = ap->regs; in ace_set_link_ksettings()
2632 link = readl(®s->GigLnkState); in ace_set_link_ksettings()
2636 link = readl(®s->FastLnkState); in ace_set_link_ksettings()
2649 if (cmd->base.autoneg == AUTONEG_ENABLE) in ace_set_link_ksettings()
2651 if (cmd->base.speed != speed) { in ace_set_link_ksettings()
2653 switch (cmd->base.speed) { in ace_set_link_ksettings()
2666 if (cmd->base.duplex == DUPLEX_FULL) in ace_set_link_ksettings()
2669 if (link != ap->link) { in ace_set_link_ksettings()
2672 dev->name); in ace_set_link_ksettings()
2674 ap->link = link; in ace_set_link_ksettings()
2675 writel(link, ®s->TuneLink); in ace_set_link_ksettings()
2677 writel(link, ®s->TuneFastLink); in ace_set_link_ksettings()
2693 strscpy(info->driver, "acenic", sizeof(info->driver)); in ace_get_drvinfo()
2694 snprintf(info->fw_version, sizeof(info->version), "%i.%i.%i", in ace_get_drvinfo()
2695 ap->firmware_major, ap->firmware_minor, ap->firmware_fix); in ace_get_drvinfo()
2697 if (ap->pdev) in ace_get_drvinfo()
2698 strscpy(info->bus_info, pci_name(ap->pdev), in ace_get_drvinfo()
2699 sizeof(info->bus_info)); in ace_get_drvinfo()
2709 struct ace_regs __iomem *regs = ap->regs; in ace_set_mac_addr()
2715 return -EBUSY; in ace_set_mac_addr()
2717 eth_hw_addr_set(dev, addr->sa_data); in ace_set_mac_addr()
2719 da = (const u8 *)dev->dev_addr; in ace_set_mac_addr()
2721 writel(da[0] << 8 | da[1], ®s->MacAddrHi); in ace_set_mac_addr()
2723 ®s->MacAddrLo); in ace_set_mac_addr()
2737 struct ace_regs __iomem *regs = ap->regs; in ace_set_multicast_list()
2740 if ((dev->flags & IFF_ALLMULTI) && !(ap->mcast_all)) { in ace_set_multicast_list()
2745 ap->mcast_all = 1; in ace_set_multicast_list()
2746 } else if (ap->mcast_all) { in ace_set_multicast_list()
2751 ap->mcast_all = 0; in ace_set_multicast_list()
2754 if ((dev->flags & IFF_PROMISC) && !(ap->promisc)) { in ace_set_multicast_list()
2759 ap->promisc = 1; in ace_set_multicast_list()
2760 }else if (!(dev->flags & IFF_PROMISC) && (ap->promisc)) { in ace_set_multicast_list()
2765 ap->promisc = 0; in ace_set_multicast_list()
2774 if (!netdev_mc_empty(dev) && !ap->mcast_all) { in ace_set_multicast_list()
2779 }else if (!ap->mcast_all) { in ace_set_multicast_list()
2792 (struct ace_mac_stats __iomem *)ap->regs->Stats; in ace_get_stats()
2794 dev->stats.rx_missed_errors = readl(&mac_stats->drop_space); in ace_get_stats()
2795 dev->stats.multicast = readl(&mac_stats->kept_mc); in ace_get_stats()
2796 dev->stats.collisions = readl(&mac_stats->coll); in ace_get_stats()
2798 return &dev->stats; in ace_get_stats()
2812 tsize = min_t(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1), in ace_copy()
2814 tdest = (void __iomem *) ®s->Window + in ace_copy()
2815 (dest & (ACE_WINDOW_SIZE - 1)); in ace_copy()
2816 writel(dest & ~(ACE_WINDOW_SIZE - 1), ®s->WinBase); in ace_copy()
2818 /* Firmware is big-endian */ in ace_copy()
2823 size -= 4; in ace_copy()
2838 tsize = min_t(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1), in ace_clear()
2840 tdest = (void __iomem *) ®s->Window + in ace_clear()
2841 (dest & (ACE_WINDOW_SIZE - 1)); in ace_clear()
2842 writel(dest & ~(ACE_WINDOW_SIZE - 1), ®s->WinBase); in ace_clear()
2849 size -= tsize; in ace_clear()
2865 struct ace_regs __iomem *regs = ap->regs; in ace_load_firmware()
2870 if (!(readl(®s->CpuCtrl) & CPU_HALTED)) { in ace_load_firmware()
2872 "CPU is running!\n", ap->name); in ace_load_firmware()
2873 return -EFAULT; in ace_load_firmware()
2879 ret = request_firmware(&fw, fw_name, &ap->pdev->dev); in ace_load_firmware()
2882 ap->name, fw_name); in ace_load_firmware()
2886 fw_data = (void *)fw->data; in ace_load_firmware()
2893 ap->firmware_major = fw->data[0]; in ace_load_firmware()
2894 ap->firmware_minor = fw->data[1]; in ace_load_firmware()
2895 ap->firmware_fix = fw->data[2]; in ace_load_firmware()
2897 ap->firmware_start = be32_to_cpu(fw_data[1]); in ace_load_firmware()
2898 if (ap->firmware_start < 0x4000 || ap->firmware_start >= 0x80000) { in ace_load_firmware()
2900 ap->name, ap->firmware_start, fw_name); in ace_load_firmware()
2901 ret = -EINVAL; in ace_load_firmware()
2908 ap->name, load_addr, fw_name); in ace_load_firmware()
2909 ret = -EINVAL; in ace_load_firmware()
2917 ace_clear(regs, 0x2000, 0x80000-0x2000); in ace_load_firmware()
2918 ace_copy(regs, &fw_data[3], load_addr, fw->size-12); in ace_load_firmware()
2928 * Accessing the EEPROM is `interesting' to say the least - don't read
2931 * This is all about black magic and bit-banging the device .... I
2938 * code i2c readout code by beta testing all my hacks.
2944 readl(®s->LocalCtrl); in eeprom_start()
2946 local = readl(®s->LocalCtrl); in eeprom_start()
2948 writel(local, ®s->LocalCtrl); in eeprom_start()
2949 readl(®s->LocalCtrl); in eeprom_start()
2953 writel(local, ®s->LocalCtrl); in eeprom_start()
2954 readl(®s->LocalCtrl); in eeprom_start()
2958 writel(local, ®s->LocalCtrl); in eeprom_start()
2959 readl(®s->LocalCtrl); in eeprom_start()
2963 writel(local, ®s->LocalCtrl); in eeprom_start()
2964 readl(®s->LocalCtrl); in eeprom_start()
2975 local = readl(®s->LocalCtrl); in eeprom_prep()
2978 writel(local, ®s->LocalCtrl); in eeprom_prep()
2979 readl(®s->LocalCtrl); in eeprom_prep()
2988 writel(local, ®s->LocalCtrl); in eeprom_prep()
2989 readl(®s->LocalCtrl); in eeprom_prep()
2994 writel(local, ®s->LocalCtrl); in eeprom_prep()
2995 readl(®s->LocalCtrl); in eeprom_prep()
2999 writel(local, ®s->LocalCtrl); in eeprom_prep()
3000 readl(®s->LocalCtrl); in eeprom_prep()
3011 local = readl(®s->LocalCtrl); in eeprom_check_ack()
3013 writel(local, ®s->LocalCtrl); in eeprom_check_ack()
3014 readl(®s->LocalCtrl); in eeprom_check_ack()
3018 writel(local, ®s->LocalCtrl); in eeprom_check_ack()
3019 readl(®s->LocalCtrl); in eeprom_check_ack()
3023 state = (readl(®s->LocalCtrl) & EEPROM_DATA_IN) != 0; in eeprom_check_ack()
3026 writel(readl(®s->LocalCtrl) & ~EEPROM_CLK_OUT, ®s->LocalCtrl); in eeprom_check_ack()
3027 readl(®s->LocalCtrl); in eeprom_check_ack()
3039 local = readl(®s->LocalCtrl); in eeprom_stop()
3041 writel(local, ®s->LocalCtrl); in eeprom_stop()
3042 readl(®s->LocalCtrl); in eeprom_stop()
3046 writel(local, ®s->LocalCtrl); in eeprom_stop()
3047 readl(®s->LocalCtrl); in eeprom_stop()
3051 writel(local, ®s->LocalCtrl); in eeprom_stop()
3052 readl(®s->LocalCtrl); in eeprom_stop()
3056 writel(local, ®s->LocalCtrl); in eeprom_stop()
3057 readl(®s->LocalCtrl); in eeprom_stop()
3061 writel(local, ®s->LocalCtrl); in eeprom_stop()
3072 struct ace_regs __iomem *regs = ap->regs; in read_eeprom_byte()
3089 printk(KERN_ERR "%s: Unable to sync eeprom\n", ap->name); in read_eeprom_byte()
3090 result = -EIO; in read_eeprom_byte()
3098 ap->name); in read_eeprom_byte()
3099 result = -EIO; in read_eeprom_byte()
3107 ap->name); in read_eeprom_byte()
3108 result = -EIO; in read_eeprom_byte()
3117 ap->name); in read_eeprom_byte()
3118 result = -EIO; in read_eeprom_byte()
3123 local = readl(®s->LocalCtrl); in read_eeprom_byte()
3125 writel(local, ®s->LocalCtrl); in read_eeprom_byte()
3126 readl(®s->LocalCtrl); in read_eeprom_byte()
3130 writel(local, ®s->LocalCtrl); in read_eeprom_byte()
3131 readl(®s->LocalCtrl); in read_eeprom_byte()
3136 ((readl(®s->LocalCtrl) & EEPROM_DATA_IN) != 0); in read_eeprom_byte()
3139 local = readl(®s->LocalCtrl); in read_eeprom_byte()
3141 writel(local, ®s->LocalCtrl); in read_eeprom_byte()
3142 readl(®s->LocalCtrl); in read_eeprom_byte()
3147 writel(local, ®s->LocalCtrl); in read_eeprom_byte()
3148 readl(®s->LocalCtrl); in read_eeprom_byte()
3155 writel(local, ®s->LocalCtrl); in read_eeprom_byte()
3156 readl(®s->LocalCtrl); in read_eeprom_byte()
3159 writel(readl(®s->LocalCtrl) | EEPROM_CLK_OUT, ®s->LocalCtrl); in read_eeprom_byte()
3160 readl(®s->LocalCtrl); in read_eeprom_byte()
3162 writel(readl(®s->LocalCtrl) & ~EEPROM_CLK_OUT, ®s->LocalCtrl); in read_eeprom_byte()
3163 readl(®s->LocalCtrl); in read_eeprom_byte()
3174 ap->name, offset); in read_eeprom_byte()