Lines Matching +full:half +full:- +full:duplex +full:- +full:capable
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* D-Link DL2000-based Gigabit Ethernet Adapter Linux driver */
4 Copyright (c) 2001, 2002 by D-Link Corporation
6 Created 03-May-2001, base on Linux' sundance.c.
11 #include <linux/dma-mapping.h>
25 static int tx_flow=-1;
26 static int rx_flow=-1;
34 MODULE_DESCRIPTION ("D-Link DL2000-based Gigabit Ethernet Adapter");
54 void __iomem *ioaddr = np->ioaddr; in dl2k_enable_int()
108 int chip_idx = ent->driver_data; in rio_probe1()
118 irq = pdev->irq; in rio_probe1()
125 err = -ENOMEM; in rio_probe1()
130 SET_NETDEV_DEV(dev, &pdev->dev); in rio_probe1()
138 np->eeprom_addr = ioaddr; in rio_probe1()
146 np->ioaddr = ioaddr; in rio_probe1()
147 np->chip_id = chip_idx; in rio_probe1()
148 np->pdev = pdev; in rio_probe1()
149 spin_lock_init (&np->tx_lock); in rio_probe1()
150 spin_lock_init (&np->rx_lock); in rio_probe1()
153 np->an_enable = 1; in rio_probe1()
154 np->tx_coalesce = 1; in rio_probe1()
157 np->an_enable = 0; in rio_probe1()
161 np->an_enable = 2; in rio_probe1()
164 np->speed = 100; in rio_probe1()
165 np->full_duplex = 1; in rio_probe1()
168 np->speed = 100; in rio_probe1()
169 np->full_duplex = 0; in rio_probe1()
172 np->speed = 10; in rio_probe1()
173 np->full_duplex = 1; in rio_probe1()
176 np->speed = 10; in rio_probe1()
177 np->full_duplex = 0; in rio_probe1()
180 np->speed=1000; in rio_probe1()
181 np->full_duplex=1; in rio_probe1()
184 np->speed = 1000; in rio_probe1()
185 np->full_duplex = 0; in rio_probe1()
187 np->an_enable = 1; in rio_probe1()
191 np->jumbo = 1; in rio_probe1()
192 dev->mtu = MAX_JUMBO; in rio_probe1()
194 np->jumbo = 0; in rio_probe1()
196 dev->mtu = mtu[card_idx]; in rio_probe1()
198 np->vlan = (vlan[card_idx] > 0 && vlan[card_idx] < 4096) ? in rio_probe1()
201 np->rx_coalesce = rx_coalesce; in rio_probe1()
202 np->rx_timeout = rx_timeout; in rio_probe1()
203 np->coalesce = 1; in rio_probe1()
205 np->tx_flow = (tx_flow == 0) ? 0 : 1; in rio_probe1()
206 np->rx_flow = (rx_flow == 0) ? 0 : 1; in rio_probe1()
210 else if (tx_coalesce > TX_RING_SIZE-1) in rio_probe1()
211 tx_coalesce = TX_RING_SIZE - 1; in rio_probe1()
213 dev->netdev_ops = &netdev_ops; in rio_probe1()
214 dev->watchdog_timeo = TX_TIMEOUT; in rio_probe1()
215 dev->ethtool_ops = ðtool_ops; in rio_probe1()
217 dev->features = NETIF_F_IP_CSUM; in rio_probe1()
219 /* MTU range: 68 - 1536 or 8000 */ in rio_probe1()
220 dev->min_mtu = ETH_MIN_MTU; in rio_probe1()
221 dev->max_mtu = np->jumbo ? MAX_JUMBO : PACKET_SIZE; in rio_probe1()
225 ring_space = dma_alloc_coherent(&pdev->dev, TX_TOTAL_SIZE, &ring_dma, in rio_probe1()
229 np->tx_ring = ring_space; in rio_probe1()
230 np->tx_ring_dma = ring_dma; in rio_probe1()
232 ring_space = dma_alloc_coherent(&pdev->dev, RX_TOTAL_SIZE, &ring_dma, in rio_probe1()
236 np->rx_ring = ring_space; in rio_probe1()
237 np->rx_ring_dma = ring_dma; in rio_probe1()
248 np->phy_media = (dr16(ASICCtrl) & PhyMedia) ? 1 : 0; in rio_probe1()
249 np->link_status = 0; in rio_probe1()
251 if (np->phy_media) { in rio_probe1()
252 /* default Auto-Negotiation for fiber deivices */ in rio_probe1()
253 if (np->an_enable == 2) { in rio_probe1()
254 np->an_enable = 1; in rio_probe1()
257 /* Auto-Negotiation is mandatory for 1000BASE-T, in rio_probe1()
259 if (np->speed == 1000) in rio_probe1()
260 np->an_enable = 1; in rio_probe1()
270 dev->name, np->name, dev->dev_addr, irq); in rio_probe1()
274 if (np->coalesce) in rio_probe1()
278 np->rx_coalesce, np->rx_timeout*640); in rio_probe1()
279 if (np->vlan) in rio_probe1()
280 printk(KERN_INFO "vlan(id):\t%d\n", np->vlan); in rio_probe1()
284 dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, np->rx_ring, in rio_probe1()
285 np->rx_ring_dma); in rio_probe1()
287 dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, np->tx_ring, in rio_probe1()
288 np->tx_ring_dma); in rio_probe1()
291 pci_iounmap(pdev, np->ioaddr); in rio_probe1()
293 pci_iounmap(pdev, np->eeprom_addr); in rio_probe1()
309 np->phy_addr = 1; in find_miiphy()
311 for (i = 31; i >= 0; i--) { in find_miiphy()
314 np->phy_addr = i; in find_miiphy()
319 printk (KERN_ERR "%s: No MII PHY found!\n", dev->name); in find_miiphy()
320 return -ENODEV; in find_miiphy()
329 void __iomem *ioaddr = np->ioaddr; in parse_eeprom()
341 if (np->pdev->vendor == PCI_VENDOR_ID_DLINK) { /* D-Link Only */ in parse_eeprom()
343 crc = ~ether_crc_le (256 - 4, sromdata); in parse_eeprom()
344 if (psrom->crc != cpu_to_le32(crc)) { in parse_eeprom()
346 dev->name); in parse_eeprom()
347 return -1; in parse_eeprom()
352 eth_hw_addr_set(dev, psrom->mac_addr); in parse_eeprom()
354 if (np->chip_id == CHIP_IP1000A) { in parse_eeprom()
355 np->led_mode = psrom->led_mode; in parse_eeprom()
359 if (np->pdev->vendor != PCI_VENDOR_ID_DLINK) { in parse_eeprom()
371 return -1; in parse_eeprom()
378 case 2: /* Duplex Polarity */ in parse_eeprom()
379 np->duplex_polarity = psib[i]; in parse_eeprom()
383 np->wake_polarity = psib[i]; in parse_eeprom()
386 j = (next - i > 255) ? 255 : next - i; in parse_eeprom()
387 memcpy (np->name, &(psib[i]), j); in parse_eeprom()
396 return -1; in parse_eeprom()
407 void __iomem *ioaddr = np->ioaddr; in rio_set_led_mode()
410 if (np->chip_id != CHIP_IP1000A) in rio_set_led_mode()
416 if (np->led_mode & 0x01) in rio_set_led_mode()
418 if (np->led_mode & 0x02) in rio_set_led_mode()
420 if (np->led_mode & 0x08) in rio_set_led_mode()
428 return le64_to_cpu(desc->fraginfo) & DMA_BIT_MASK(48); in desc_to_dma()
439 skb = np->rx_skbuff[i]; in free_list()
441 dma_unmap_single(&np->pdev->dev, in free_list()
442 desc_to_dma(&np->rx_ring[i]), in free_list()
443 skb->len, DMA_FROM_DEVICE); in free_list()
445 np->rx_skbuff[i] = NULL; in free_list()
447 np->rx_ring[i].status = 0; in free_list()
448 np->rx_ring[i].fraginfo = 0; in free_list()
451 skb = np->tx_skbuff[i]; in free_list()
453 dma_unmap_single(&np->pdev->dev, in free_list()
454 desc_to_dma(&np->tx_ring[i]), in free_list()
455 skb->len, DMA_TO_DEVICE); in free_list()
457 np->tx_skbuff[i] = NULL; in free_list()
466 np->cur_rx = 0; in rio_reset_ring()
467 np->cur_tx = 0; in rio_reset_ring()
468 np->old_rx = 0; in rio_reset_ring()
469 np->old_tx = 0; in rio_reset_ring()
472 np->tx_ring[i].status = cpu_to_le64(TFDDone); in rio_reset_ring()
475 np->rx_ring[i].status = 0; in rio_reset_ring()
485 np->rx_buf_sz = (dev->mtu <= 1500 ? PACKET_SIZE : dev->mtu + 32); in alloc_list()
489 np->tx_skbuff[i] = NULL; in alloc_list()
490 np->tx_ring[i].next_desc = cpu_to_le64(np->tx_ring_dma + in alloc_list()
500 skb = netdev_alloc_skb_ip_align(dev, np->rx_buf_sz); in alloc_list()
501 np->rx_skbuff[i] = skb; in alloc_list()
504 return -ENOMEM; in alloc_list()
507 np->rx_ring[i].next_desc = cpu_to_le64(np->rx_ring_dma + in alloc_list()
511 np->rx_ring[i].fraginfo = in alloc_list()
512 cpu_to_le64(dma_map_single(&np->pdev->dev, skb->data, in alloc_list()
513 np->rx_buf_sz, DMA_FROM_DEVICE)); in alloc_list()
514 np->rx_ring[i].fraginfo |= cpu_to_le64((u64)np->rx_buf_sz << 48); in alloc_list()
523 void __iomem *ioaddr = np->ioaddr; in rio_hw_init()
537 if (np->chip_id == CHIP_IP1000A && in rio_hw_init()
538 (np->pdev->revision == 0x40 || np->pdev->revision == 0x41)) { in rio_hw_init()
540 mii_write(dev, np->phy_addr, 31, 0x0001); in rio_hw_init()
541 mii_write(dev, np->phy_addr, 27, 0x01e0); in rio_hw_init()
542 mii_write(dev, np->phy_addr, 31, 0x0002); in rio_hw_init()
543 mii_write(dev, np->phy_addr, 27, 0xeb8e); in rio_hw_init()
544 mii_write(dev, np->phy_addr, 31, 0x0000); in rio_hw_init()
545 mii_write(dev, np->phy_addr, 30, 0x005e); in rio_hw_init()
546 /* advertise 1000BASE-T half & full duplex, prefer MASTER */ in rio_hw_init()
547 mii_write(dev, np->phy_addr, MII_CTRL1000, 0x0700); in rio_hw_init()
550 if (np->phy_media) in rio_hw_init()
556 if (np->jumbo != 0) in rio_hw_init()
560 dw32(RFDListPtr0, np->rx_ring_dma); in rio_hw_init()
564 /* 16 or 32-bit access is required by TC9020 datasheet but 8-bit works in rio_hw_init()
565 * too. However, it doesn't work on IP1000A so we use 16-bit access. in rio_hw_init()
568 dw16(StationAddr0 + 2 * i, get_unaligned_le16(&dev->dev_addr[2 * i])); in rio_hw_init()
571 if (np->coalesce) { in rio_hw_init()
572 dw32(RxDMAIntCtrl, np->rx_coalesce | np->rx_timeout << 16); in rio_hw_init()
584 if (np->vlan) { in rio_hw_init()
588 dw16(VLANId, np->vlan); in rio_hw_init()
590 dw32(VLANTag, 0x8100 << 16 | np->vlan); in rio_hw_init()
600 macctrl |= (np->vlan) ? AutoVLANuntagging : 0; in rio_hw_init()
601 macctrl |= (np->full_duplex) ? DuplexSelect : 0; in rio_hw_init()
602 macctrl |= (np->tx_flow) ? TxFlowControlEnable : 0; in rio_hw_init()
603 macctrl |= (np->rx_flow) ? RxFlowControlEnable : 0; in rio_hw_init()
610 void __iomem *ioaddr = np->ioaddr; in rio_hw_stop()
622 const int irq = np->pdev->irq; in rio_open()
631 i = request_irq(irq, rio_interrupt, IRQF_SHARED, dev->name, dev); in rio_open()
638 timer_setup(&np->timer, rio_timer, 0); in rio_open()
639 np->timer.expires = jiffies + 1 * HZ; in rio_open()
640 add_timer(&np->timer); in rio_open()
652 struct net_device *dev = pci_get_drvdata(np->pdev); in rio_timer()
657 spin_lock_irqsave(&np->rx_lock, flags); in rio_timer()
659 if (np->cur_rx - np->old_rx >= RX_RING_SIZE) { in rio_timer()
661 /* Re-allocate skbuffs to fill the descriptor ring */ in rio_timer()
662 for (; np->cur_rx - np->old_rx > 0; np->old_rx++) { in rio_timer()
664 entry = np->old_rx % RX_RING_SIZE; in rio_timer()
665 /* Dropped packets don't need to re-allocate */ in rio_timer()
666 if (np->rx_skbuff[entry] == NULL) { in rio_timer()
668 np->rx_buf_sz); in rio_timer()
670 np->rx_ring[entry].fraginfo = 0; in rio_timer()
672 "%s: Still unable to re-allocate Rx skbuff.#%d\n", in rio_timer()
673 dev->name, entry); in rio_timer()
676 np->rx_skbuff[entry] = skb; in rio_timer()
677 np->rx_ring[entry].fraginfo = in rio_timer()
678 cpu_to_le64 (dma_map_single(&np->pdev->dev, skb->data, in rio_timer()
679 np->rx_buf_sz, DMA_FROM_DEVICE)); in rio_timer()
681 np->rx_ring[entry].fraginfo |= in rio_timer()
682 cpu_to_le64((u64)np->rx_buf_sz << 48); in rio_timer()
683 np->rx_ring[entry].status = 0; in rio_timer()
686 spin_unlock_irqrestore (&np->rx_lock, flags); in rio_timer()
687 np->timer.expires = jiffies + next_tick; in rio_timer()
688 add_timer(&np->timer); in rio_timer()
695 void __iomem *ioaddr = np->ioaddr; in rio_tx_timeout()
698 dev->name, dr32(TxStatus)); in rio_tx_timeout()
700 dev->if_port = 0; in rio_tx_timeout()
708 void __iomem *ioaddr = np->ioaddr; in start_xmit()
713 if (np->link_status == 0) { /* Link Down */ in start_xmit()
717 entry = np->cur_tx % TX_RING_SIZE; in start_xmit()
718 np->tx_skbuff[entry] = skb; in start_xmit()
719 txdesc = &np->tx_ring[entry]; in start_xmit()
722 if (skb->ip_summed == CHECKSUM_PARTIAL) { in start_xmit()
723 txdesc->status |= in start_xmit()
728 if (np->vlan) { in start_xmit()
730 ((u64)np->vlan << 32) | in start_xmit()
731 ((u64)skb->priority << 45); in start_xmit()
733 txdesc->fraginfo = cpu_to_le64 (dma_map_single(&np->pdev->dev, skb->data, in start_xmit()
734 skb->len, DMA_TO_DEVICE)); in start_xmit()
735 txdesc->fraginfo |= cpu_to_le64((u64)skb->len << 48); in start_xmit()
739 if (entry % np->tx_coalesce == 0 || np->speed == 10) in start_xmit()
740 txdesc->status = cpu_to_le64 (entry | tfc_vlan_tag | in start_xmit()
745 txdesc->status = cpu_to_le64 (entry | tfc_vlan_tag | in start_xmit()
753 np->cur_tx = (np->cur_tx + 1) % TX_RING_SIZE; in start_xmit()
754 if ((np->cur_tx - np->old_tx + TX_RING_SIZE) % TX_RING_SIZE in start_xmit()
755 < TX_QUEUE_LEN - 1 && np->speed != 10) { in start_xmit()
763 dw32(TFDListPtr0, np->tx_ring_dma + in start_xmit()
776 void __iomem *ioaddr = np->ioaddr; in rio_interrupt()
785 if (int_status == 0 || --cnt < 0) in rio_interrupt()
806 if (np->cur_tx != np->old_tx) in rio_interrupt()
815 int entry = np->old_tx % TX_RING_SIZE; in rio_free_tx()
819 spin_lock(&np->tx_lock); in rio_free_tx()
821 spin_lock_irqsave(&np->tx_lock, flag); in rio_free_tx()
824 while (entry != np->cur_tx) { in rio_free_tx()
827 if (!(np->tx_ring[entry].status & cpu_to_le64(TFDDone))) in rio_free_tx()
829 skb = np->tx_skbuff[entry]; in rio_free_tx()
830 dma_unmap_single(&np->pdev->dev, in rio_free_tx()
831 desc_to_dma(&np->tx_ring[entry]), skb->len, in rio_free_tx()
838 np->tx_skbuff[entry] = NULL; in rio_free_tx()
842 spin_unlock(&np->tx_lock); in rio_free_tx()
844 spin_unlock_irqrestore(&np->tx_lock, flag); in rio_free_tx()
845 np->old_tx = entry; in rio_free_tx()
851 ((np->cur_tx - np->old_tx + TX_RING_SIZE) % TX_RING_SIZE in rio_free_tx()
852 < TX_QUEUE_LEN - 1 || np->speed == 10)) { in rio_free_tx()
861 void __iomem *ioaddr = np->ioaddr; in tx_error()
867 dev->name, tx_status, frame_id); in tx_error()
868 dev->stats.tx_errors++; in tx_error()
871 dev->stats.tx_fifo_errors++; in tx_error()
877 for (i = 50; i > 0; i--) { in tx_error()
885 dw32(TFDListPtr0, np->tx_ring_dma + in tx_error()
886 np->old_tx * sizeof (struct netdev_desc)); in tx_error()
893 dev->stats.tx_fifo_errors++; in tx_error()
897 for (i = 50; i > 0; i--) { in tx_error()
907 dev->stats.collisions++; in tx_error()
916 int entry = np->cur_rx % RX_RING_SIZE; in receive_packet()
921 struct netdev_desc *desc = &np->rx_ring[entry]; in receive_packet()
925 if (!(desc->status & cpu_to_le64(RFDDone)) || in receive_packet()
926 !(desc->status & cpu_to_le64(FrameStart)) || in receive_packet()
927 !(desc->status & cpu_to_le64(FrameEnd))) in receive_packet()
931 frame_status = le64_to_cpu(desc->status); in receive_packet()
933 if (--cnt < 0) in receive_packet()
937 dev->stats.rx_errors++; in receive_packet()
939 dev->stats.rx_length_errors++; in receive_packet()
941 dev->stats.rx_crc_errors++; in receive_packet()
942 if (frame_status & RxAlignmentError && np->speed != 1000) in receive_packet()
943 dev->stats.rx_frame_errors++; in receive_packet()
945 dev->stats.rx_fifo_errors++; in receive_packet()
951 dma_unmap_single(&np->pdev->dev, in receive_packet()
953 np->rx_buf_sz, in receive_packet()
955 skb_put (skb = np->rx_skbuff[entry], pkt_len); in receive_packet()
956 np->rx_skbuff[entry] = NULL; in receive_packet()
958 dma_sync_single_for_cpu(&np->pdev->dev, in receive_packet()
960 np->rx_buf_sz, in receive_packet()
963 np->rx_skbuff[entry]->data, in receive_packet()
966 dma_sync_single_for_device(&np->pdev->dev, in receive_packet()
968 np->rx_buf_sz, in receive_packet()
971 skb->protocol = eth_type_trans (skb, dev); in receive_packet()
974 if (np->pdev->pci_rev_id >= 0x0c && in receive_packet()
976 skb->ip_summed = CHECKSUM_UNNECESSARY; in receive_packet()
983 spin_lock(&np->rx_lock); in receive_packet()
984 np->cur_rx = entry; in receive_packet()
985 /* Re-allocate skbuffs to fill the descriptor ring */ in receive_packet()
986 entry = np->old_rx; in receive_packet()
987 while (entry != np->cur_rx) { in receive_packet()
989 /* Dropped packets don't need to re-allocate */ in receive_packet()
990 if (np->rx_skbuff[entry] == NULL) { in receive_packet()
991 skb = netdev_alloc_skb_ip_align(dev, np->rx_buf_sz); in receive_packet()
993 np->rx_ring[entry].fraginfo = 0; in receive_packet()
996 "Unable to re-allocate Rx skbuff.#%d\n", in receive_packet()
997 dev->name, entry); in receive_packet()
1000 np->rx_skbuff[entry] = skb; in receive_packet()
1001 np->rx_ring[entry].fraginfo = in receive_packet()
1002 cpu_to_le64(dma_map_single(&np->pdev->dev, skb->data, in receive_packet()
1003 np->rx_buf_sz, DMA_FROM_DEVICE)); in receive_packet()
1005 np->rx_ring[entry].fraginfo |= in receive_packet()
1006 cpu_to_le64((u64)np->rx_buf_sz << 48); in receive_packet()
1007 np->rx_ring[entry].status = 0; in receive_packet()
1010 np->old_rx = entry; in receive_packet()
1011 spin_unlock(&np->rx_lock); in receive_packet()
1019 void __iomem *ioaddr = np->ioaddr; in rio_error()
1025 printk (KERN_INFO "%s: Link up\n", dev->name); in rio_error()
1026 if (np->phy_media) in rio_error()
1030 if (np->speed == 1000) in rio_error()
1031 np->tx_coalesce = tx_coalesce; in rio_error()
1033 np->tx_coalesce = 1; in rio_error()
1035 macctrl |= (np->vlan) ? AutoVLANuntagging : 0; in rio_error()
1036 macctrl |= (np->full_duplex) ? DuplexSelect : 0; in rio_error()
1037 macctrl |= (np->tx_flow) ? in rio_error()
1039 macctrl |= (np->rx_flow) ? in rio_error()
1042 np->link_status = 1; in rio_error()
1045 printk (KERN_INFO "%s: Link off\n", dev->name); in rio_error()
1046 np->link_status = 0; in rio_error()
1060 dev->name, int_status); in rio_error()
1071 void __iomem *ioaddr = np->ioaddr; in get_stats()
1080 dev->stats.rx_packets += dr32(FramesRcvOk); in get_stats()
1081 dev->stats.tx_packets += dr32(FramesXmtOk); in get_stats()
1082 dev->stats.rx_bytes += dr32(OctetRcvOk); in get_stats()
1083 dev->stats.tx_bytes += dr32(OctetXmtOk); in get_stats()
1085 dev->stats.multicast = dr32(McstFramesRcvdOk); in get_stats()
1086 dev->stats.collisions += dr32(SingleColFrames) in get_stats()
1091 dev->stats.tx_aborted_errors += stat_reg; in get_stats()
1092 dev->stats.tx_errors += stat_reg; in get_stats()
1095 dev->stats.tx_carrier_errors += stat_reg; in get_stats()
1096 dev->stats.tx_errors += stat_reg; in get_stats()
1126 return &dev->stats; in get_stats()
1133 void __iomem *ioaddr = np->ioaddr; in clear_stats()
1188 void __iomem *ioaddr = np->ioaddr; in set_multicast()
1193 /* RxFlowcontrol DA: 01-80-C2-00-00-01. Hash index=0x39 */ in set_multicast()
1195 if (dev->flags & IFF_PROMISC) { in set_multicast()
1198 } else if ((dev->flags & IFF_ALLMULTI) || in set_multicast()
1210 int crc = ether_crc_le(ETH_ALEN, ha->addr); in set_multicast()
1214 if (crc & (1 << (31 - bit))) in set_multicast()
1221 if (np->vlan) { in set_multicast()
1235 strscpy(info->driver, "dl2k", sizeof(info->driver)); in rio_get_drvinfo()
1236 strscpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info)); in rio_get_drvinfo()
1245 if (np->phy_media) { in rio_get_link_ksettings()
1249 cmd->base.port = PORT_FIBRE; in rio_get_link_ksettings()
1260 cmd->base.port = PORT_MII; in rio_get_link_ksettings()
1262 if (np->link_status) { in rio_get_link_ksettings()
1263 cmd->base.speed = np->speed; in rio_get_link_ksettings()
1264 cmd->base.duplex = np->full_duplex ? DUPLEX_FULL : DUPLEX_HALF; in rio_get_link_ksettings()
1266 cmd->base.speed = SPEED_UNKNOWN; in rio_get_link_ksettings()
1267 cmd->base.duplex = DUPLEX_UNKNOWN; in rio_get_link_ksettings()
1269 if (np->an_enable) in rio_get_link_ksettings()
1270 cmd->base.autoneg = AUTONEG_ENABLE; in rio_get_link_ksettings()
1272 cmd->base.autoneg = AUTONEG_DISABLE; in rio_get_link_ksettings()
1274 cmd->base.phy_address = np->phy_addr; in rio_get_link_ksettings()
1276 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, in rio_get_link_ksettings()
1278 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, in rio_get_link_ksettings()
1288 u32 speed = cmd->base.speed; in rio_set_link_ksettings()
1289 u8 duplex = cmd->base.duplex; in rio_set_link_ksettings() local
1292 if (cmd->base.autoneg == AUTONEG_ENABLE) { in rio_set_link_ksettings()
1293 if (np->an_enable) { in rio_set_link_ksettings()
1296 np->an_enable = 1; in rio_set_link_ksettings()
1301 np->an_enable = 0; in rio_set_link_ksettings()
1302 if (np->speed == 1000) { in rio_set_link_ksettings()
1304 duplex = DUPLEX_FULL; in rio_set_link_ksettings()
1305 …("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex.\n"); in rio_set_link_ksettings()
1309 np->speed = 10; in rio_set_link_ksettings()
1310 np->full_duplex = (duplex == DUPLEX_FULL); in rio_set_link_ksettings()
1313 np->speed = 100; in rio_set_link_ksettings()
1314 np->full_duplex = (duplex == DUPLEX_FULL); in rio_set_link_ksettings()
1318 return -EINVAL; in rio_set_link_ksettings()
1328 return np->link_status; in rio_get_link()
1345 phy_addr = np->phy_addr; in rio_ioctl()
1348 miidata->phy_id = phy_addr; in rio_ioctl()
1351 miidata->val_out = mii_read (dev, phy_addr, miidata->reg_num); in rio_ioctl()
1354 if (!capable(CAP_NET_ADMIN)) in rio_ioctl()
1355 return -EPERM; in rio_ioctl()
1356 mii_write (dev, phy_addr, miidata->reg_num, miidata->val_in); in rio_ioctl()
1359 return -EOPNOTSUPP; in rio_ioctl()
1370 void __iomem *ioaddr = np->eeprom_addr; in read_eeprom()
1374 while (i-- > 0) { in read_eeprom()
1391 void __iomem *ioaddr = np->ioaddr; in mii_sendbit()
1404 void __iomem *ioaddr = np->ioaddr; in mii_getbit()
1420 for (i = len - 1; i >= 0; i--) { in mii_send_bits()
1476 phy_addr = np->phy_addr; in mii_wait_link()
1483 } while (--wait > 0); in mii_wait_link()
1484 return -1; in mii_wait_link()
1497 phy_addr = np->phy_addr; in mii_get_media()
1500 if (np->an_enable) { in mii_get_media()
1502 /* Auto-Negotiation not completed */ in mii_get_media()
1503 return -1; in mii_get_media()
1510 np->speed = 1000; in mii_get_media()
1511 np->full_duplex = 1; in mii_get_media()
1512 printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n"); in mii_get_media()
1514 np->speed = 1000; in mii_get_media()
1515 np->full_duplex = 0; in mii_get_media()
1516 printk (KERN_INFO "Auto 1000 Mbps, Half duplex\n"); in mii_get_media()
1518 np->speed = 100; in mii_get_media()
1519 np->full_duplex = 1; in mii_get_media()
1520 printk (KERN_INFO "Auto 100 Mbps, Full duplex\n"); in mii_get_media()
1522 np->speed = 100; in mii_get_media()
1523 np->full_duplex = 0; in mii_get_media()
1524 printk (KERN_INFO "Auto 100 Mbps, Half duplex\n"); in mii_get_media()
1526 np->speed = 10; in mii_get_media()
1527 np->full_duplex = 1; in mii_get_media()
1528 printk (KERN_INFO "Auto 10 Mbps, Full duplex\n"); in mii_get_media()
1530 np->speed = 10; in mii_get_media()
1531 np->full_duplex = 0; in mii_get_media()
1532 printk (KERN_INFO "Auto 10 Mbps, Half duplex\n"); in mii_get_media()
1535 np->tx_flow &= 1; in mii_get_media()
1536 np->rx_flow &= 1; in mii_get_media()
1538 np->tx_flow = 0; in mii_get_media()
1539 np->rx_flow &= 1; in mii_get_media()
1555 printk (KERN_CONT "Full duplex\n"); in mii_get_media()
1557 printk (KERN_CONT "Half duplex\n"); in mii_get_media()
1560 if (np->tx_flow) in mii_get_media()
1564 if (np->rx_flow) in mii_get_media()
1582 phy_addr = np->phy_addr; in mii_set_media()
1585 if (np->an_enable) { in mii_set_media()
1637 if (np->speed == 100) { in mii_set_media()
1640 } else if (np->speed == 10) { in mii_set_media()
1643 if (np->full_duplex) { in mii_set_media()
1645 printk (KERN_CONT "Full duplex\n"); in mii_set_media()
1647 printk (KERN_CONT "Half duplex\n"); in mii_set_media()
1670 phy_addr = np->phy_addr; in mii_get_media_pcs()
1673 if (np->an_enable) { in mii_get_media_pcs()
1675 /* Auto-Negotiation not completed */ in mii_get_media_pcs()
1676 return -1; in mii_get_media_pcs()
1680 np->speed = 1000; in mii_get_media_pcs()
1682 printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n"); in mii_get_media_pcs()
1683 np->full_duplex = 1; in mii_get_media_pcs()
1685 printk (KERN_INFO "Auto 1000 Mbps, half duplex\n"); in mii_get_media_pcs()
1686 np->full_duplex = 0; in mii_get_media_pcs()
1689 np->tx_flow &= 1; in mii_get_media_pcs()
1690 np->rx_flow &= 1; in mii_get_media_pcs()
1692 np->tx_flow = 0; in mii_get_media_pcs()
1693 np->rx_flow &= 1; in mii_get_media_pcs()
1700 printk (KERN_CONT "Full duplex\n"); in mii_get_media_pcs()
1702 printk (KERN_CONT "Half duplex\n"); in mii_get_media_pcs()
1705 if (np->tx_flow) in mii_get_media_pcs()
1709 if (np->rx_flow) in mii_get_media_pcs()
1726 phy_addr = np->phy_addr; in mii_set_media_pcs()
1728 /* Auto-Negotiation? */ in mii_set_media_pcs()
1729 if (np->an_enable) { in mii_set_media_pcs()
1753 if (np->full_duplex) { in mii_set_media_pcs()
1755 printk (KERN_INFO "Manual full duplex\n"); in mii_set_media_pcs()
1758 printk (KERN_INFO "Manual half duplex\n"); in mii_set_media_pcs()
1774 struct pci_dev *pdev = np->pdev; in rio_close()
1780 free_irq(pdev->irq, dev); in rio_close()
1781 del_timer_sync (&np->timer); in rio_close()
1797 dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, np->rx_ring, in rio_remove1()
1798 np->rx_ring_dma); in rio_remove1()
1799 dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, np->tx_ring, in rio_remove1()
1800 np->tx_ring_dma); in rio_remove1()
1802 pci_iounmap(pdev, np->ioaddr); in rio_remove1()
1804 pci_iounmap(pdev, np->eeprom_addr); in rio_remove1()
1821 del_timer_sync(&np->timer); in rio_suspend()
1837 np->timer.expires = jiffies + 1 * HZ; in rio_resume()
1838 add_timer(&np->timer); in rio_resume()