Lines Matching +full:revision +full:- +full:id2

1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Copyright 1996-1999 Thomas Bogendoerfer [ pcnet32.c ]
28 Revision History:
30 Initial Revision.
73 #include <linux/dma-mapping.h>
101 void __iomem *mmio = lp->mmio; in amd8111e_read_phy()
114 } while (--repeat && (reg_val & PHY_CMD_ACTIVE)); in amd8111e_read_phy()
122 return -EINVAL; in amd8111e_read_phy()
131 void __iomem *mmio = lp->mmio; in amd8111e_write_phy()
144 } while (--repeat && (reg_val & PHY_CMD_ACTIVE)); in amd8111e_write_phy()
152 return -EINVAL; in amd8111e_write_phy()
185 advert = amd8111e_mdio_read(dev, lp->ext_phy_addr, MII_ADVERTISE); in amd8111e_set_ext_phy()
187 switch (lp->ext_phy_option) { in amd8111e_set_ext_phy()
208 amd8111e_mdio_write(dev, lp->ext_phy_addr, MII_ADVERTISE, tmp); in amd8111e_set_ext_phy()
210 bmcr = amd8111e_mdio_read(dev, lp->ext_phy_addr, MII_BMCR); in amd8111e_set_ext_phy()
212 amd8111e_mdio_write(dev, lp->ext_phy_addr, MII_BMCR, bmcr); in amd8111e_set_ext_phy()
216 /* This function will unmap skb->data space and will free
227 if (lp->tx_skbuff[i]) { in amd8111e_free_skbs()
228 dma_unmap_single(&lp->pci_dev->dev, in amd8111e_free_skbs()
229 lp->tx_dma_addr[i], in amd8111e_free_skbs()
230 lp->tx_skbuff[i]->len, DMA_TO_DEVICE); in amd8111e_free_skbs()
231 dev_kfree_skb(lp->tx_skbuff[i]); in amd8111e_free_skbs()
232 lp->tx_skbuff[i] = NULL; in amd8111e_free_skbs()
233 lp->tx_dma_addr[i] = 0; in amd8111e_free_skbs()
238 rx_skbuff = lp->rx_skbuff[i]; in amd8111e_free_skbs()
240 dma_unmap_single(&lp->pci_dev->dev, in amd8111e_free_skbs()
241 lp->rx_dma_addr[i], in amd8111e_free_skbs()
242 lp->rx_buff_len - 2, DMA_FROM_DEVICE); in amd8111e_free_skbs()
243 dev_kfree_skb(lp->rx_skbuff[i]); in amd8111e_free_skbs()
244 lp->rx_skbuff[i] = NULL; in amd8111e_free_skbs()
245 lp->rx_dma_addr[i] = 0; in amd8111e_free_skbs()
258 unsigned int mtu = dev->mtu; in amd8111e_set_rx_buff_len()
264 lp->rx_buff_len = mtu + ETH_HLEN + 10; in amd8111e_set_rx_buff_len()
265 lp->options |= OPTION_JUMBO_ENABLE; in amd8111e_set_rx_buff_len()
267 lp->rx_buff_len = PKT_BUFF_SZ; in amd8111e_set_rx_buff_len()
268 lp->options &= ~OPTION_JUMBO_ENABLE; in amd8111e_set_rx_buff_len()
282 lp->rx_idx = lp->tx_idx = 0; in amd8111e_init_ring()
283 lp->tx_complete_idx = 0; in amd8111e_init_ring()
284 lp->tx_ring_idx = 0; in amd8111e_init_ring()
287 if (lp->opened) in amd8111e_init_ring()
293 lp->tx_ring = dma_alloc_coherent(&lp->pci_dev->dev, in amd8111e_init_ring()
295 &lp->tx_ring_dma_addr, GFP_ATOMIC); in amd8111e_init_ring()
296 if (!lp->tx_ring) in amd8111e_init_ring()
299 lp->rx_ring = dma_alloc_coherent(&lp->pci_dev->dev, in amd8111e_init_ring()
301 &lp->rx_ring_dma_addr, GFP_ATOMIC); in amd8111e_init_ring()
302 if (!lp->rx_ring) in amd8111e_init_ring()
312 lp->rx_skbuff[i] = netdev_alloc_skb(dev, lp->rx_buff_len); in amd8111e_init_ring()
313 if (!lp->rx_skbuff[i]) { in amd8111e_init_ring()
315 for (--i; i >= 0; i--) in amd8111e_init_ring()
316 dev_kfree_skb(lp->rx_skbuff[i]); in amd8111e_init_ring()
319 skb_reserve(lp->rx_skbuff[i], 2); in amd8111e_init_ring()
323 lp->rx_dma_addr[i] = dma_map_single(&lp->pci_dev->dev, in amd8111e_init_ring()
324 lp->rx_skbuff[i]->data, in amd8111e_init_ring()
325 lp->rx_buff_len - 2, in amd8111e_init_ring()
328 lp->rx_ring[i].buff_phy_addr = cpu_to_le32(lp->rx_dma_addr[i]); in amd8111e_init_ring()
329 lp->rx_ring[i].buff_count = cpu_to_le16(lp->rx_buff_len-2); in amd8111e_init_ring()
331 lp->rx_ring[i].rx_flags = cpu_to_le16(OWN_BIT); in amd8111e_init_ring()
336 lp->tx_ring[i].buff_phy_addr = 0; in amd8111e_init_ring()
337 lp->tx_ring[i].tx_flags = 0; in amd8111e_init_ring()
338 lp->tx_ring[i].buff_count = 0; in amd8111e_init_ring()
345 dma_free_coherent(&lp->pci_dev->dev, in amd8111e_init_ring()
347 lp->rx_ring, lp->rx_ring_dma_addr); in amd8111e_init_ring()
351 dma_free_coherent(&lp->pci_dev->dev, in amd8111e_init_ring()
353 lp->tx_ring, lp->tx_ring_dma_addr); in amd8111e_init_ring()
356 return -ENOMEM; in amd8111e_init_ring()
368 void __iomem *mmio = lp->mmio; in amd8111e_set_coalesce()
369 struct amd8111e_coalesce_conf *coal_conf = &lp->coal_conf; in amd8111e_set_coalesce()
375 timeout = coal_conf->rx_timeout; in amd8111e_set_coalesce()
376 event_count = coal_conf->rx_event_count; in amd8111e_set_coalesce()
379 return -EINVAL; in amd8111e_set_coalesce()
388 timeout = coal_conf->tx_timeout; in amd8111e_set_coalesce()
389 event_count = coal_conf->tx_event_count; in amd8111e_set_coalesce()
392 return -EINVAL; in amd8111e_set_coalesce()
424 void __iomem *mmio = lp->mmio; in amd8111e_restart()
431 return -ENOMEM; in amd8111e_restart()
452 writel((u32)lp->tx_ring_dma_addr, mmio + XMT_RING_BASE_ADDR0); in amd8111e_restart()
453 writel((u32)lp->rx_ring_dma_addr, mmio + RCV_RING_BASE_ADDR0); in amd8111e_restart()
460 writew((u32)(DEFAULT_IPG-IFS1_DELTA), mmio + IFS1); in amd8111e_restart()
462 if (lp->options & OPTION_JUMBO_ENABLE) { in amd8111e_restart()
480 writeb(dev->dev_addr[i], mmio + PADR + i); in amd8111e_restart()
483 if (lp->options & OPTION_INTR_COAL_ENABLE) { in amd8111e_restart()
502 void __iomem *mmio = lp->mmio; in amd8111e_init_hw_default()
509 writew( 0x8100 | lp->ext_phy_addr, mmio + AUTOPOLL0); in amd8111e_init_hw_default()
573 if (lp->options & OPTION_JUMBO_ENABLE) in amd8111e_init_hw_default()
594 writel(INTREN, lp->mmio + CMD0); in amd8111e_disable_interrupt()
597 intr0 = readl(lp->mmio + INT0); in amd8111e_disable_interrupt()
598 writel(intr0, lp->mmio + INT0); in amd8111e_disable_interrupt()
601 readl(lp->mmio + INT0); in amd8111e_disable_interrupt()
608 writel(RUN, lp->mmio + CMD0); in amd8111e_stop_chip()
611 readl(lp->mmio + CMD0); in amd8111e_stop_chip()
618 if (lp->rx_ring) { in amd8111e_free_ring()
619 dma_free_coherent(&lp->pci_dev->dev, in amd8111e_free_ring()
621 lp->rx_ring, lp->rx_ring_dma_addr); in amd8111e_free_ring()
622 lp->rx_ring = NULL; in amd8111e_free_ring()
625 if (lp->tx_ring) { in amd8111e_free_ring()
626 dma_free_coherent(&lp->pci_dev->dev, in amd8111e_free_ring()
628 lp->tx_ring, lp->tx_ring_dma_addr); in amd8111e_free_ring()
630 lp->tx_ring = NULL; in amd8111e_free_ring()
645 while (lp->tx_complete_idx != lp->tx_idx) { in amd8111e_tx()
646 tx_index = lp->tx_complete_idx & TX_RING_DR_MOD_MASK; in amd8111e_tx()
647 status = le16_to_cpu(lp->tx_ring[tx_index].tx_flags); in amd8111e_tx()
652 lp->tx_ring[tx_index].buff_phy_addr = 0; in amd8111e_tx()
655 if (lp->tx_skbuff[tx_index]) { in amd8111e_tx()
656 dma_unmap_single(&lp->pci_dev->dev, in amd8111e_tx()
657 lp->tx_dma_addr[tx_index], in amd8111e_tx()
658 lp->tx_skbuff[tx_index]->len, in amd8111e_tx()
660 dev_consume_skb_irq(lp->tx_skbuff[tx_index]); in amd8111e_tx()
661 lp->tx_skbuff[tx_index] = NULL; in amd8111e_tx()
662 lp->tx_dma_addr[tx_index] = 0; in amd8111e_tx()
664 lp->tx_complete_idx++; in amd8111e_tx()
666 lp->coal_conf.tx_packets++; in amd8111e_tx()
667 lp->coal_conf.tx_bytes += in amd8111e_tx()
668 le16_to_cpu(lp->tx_ring[tx_index].buff_count); in amd8111e_tx()
671 lp->tx_complete_idx > lp->tx_idx - NUM_TX_BUFFERS + 2) { in amd8111e_tx()
673 /* lp->tx_full = 0; */ in amd8111e_tx()
684 struct net_device *dev = lp->amd8111e_net_dev; in amd8111e_rx_poll()
685 int rx_index = lp->rx_idx & RX_RING_DR_MOD_MASK; in amd8111e_rx_poll()
686 void __iomem *mmio = lp->mmio; in amd8111e_rx_poll()
696 status = le16_to_cpu(lp->rx_ring[rx_index].rx_flags); in amd8111e_rx_poll()
702 * full-sized * buffers it's possible for a in amd8111e_rx_poll()
708 lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; in amd8111e_rx_poll()
714 lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; in amd8111e_rx_poll()
717 pkt_len = le16_to_cpu(lp->rx_ring[rx_index].msg_count) - 4; in amd8111e_rx_poll()
723 min_pkt_len = MIN_PKT_LEN - 4; in amd8111e_rx_poll()
729 lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; in amd8111e_rx_poll()
730 lp->drv_rx_errors++; in amd8111e_rx_poll()
733 new_skb = netdev_alloc_skb(dev, lp->rx_buff_len); in amd8111e_rx_poll()
738 lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; in amd8111e_rx_poll()
739 lp->drv_rx_errors++; in amd8111e_rx_poll()
744 skb = lp->rx_skbuff[rx_index]; in amd8111e_rx_poll()
745 dma_unmap_single(&lp->pci_dev->dev, lp->rx_dma_addr[rx_index], in amd8111e_rx_poll()
746 lp->rx_buff_len - 2, DMA_FROM_DEVICE); in amd8111e_rx_poll()
748 lp->rx_skbuff[rx_index] = new_skb; in amd8111e_rx_poll()
749 lp->rx_dma_addr[rx_index] = dma_map_single(&lp->pci_dev->dev, in amd8111e_rx_poll()
750 new_skb->data, in amd8111e_rx_poll()
751 lp->rx_buff_len - 2, in amd8111e_rx_poll()
754 skb->protocol = eth_type_trans(skb, dev); in amd8111e_rx_poll()
758 u16 vlan_tag = le16_to_cpu(lp->rx_ring[rx_index].tag_ctrl_info); in amd8111e_rx_poll()
764 lp->coal_conf.rx_packets++; in amd8111e_rx_poll()
765 lp->coal_conf.rx_bytes += pkt_len; in amd8111e_rx_poll()
769 lp->rx_ring[rx_index].buff_phy_addr in amd8111e_rx_poll()
770 = cpu_to_le32(lp->rx_dma_addr[rx_index]); in amd8111e_rx_poll()
771 lp->rx_ring[rx_index].buff_count = in amd8111e_rx_poll()
772 cpu_to_le16(lp->rx_buff_len-2); in amd8111e_rx_poll()
774 lp->rx_ring[rx_index].rx_flags |= cpu_to_le16(OWN_BIT); in amd8111e_rx_poll()
775 rx_index = (++lp->rx_idx) & RX_RING_DR_MOD_MASK; in amd8111e_rx_poll()
782 spin_lock_irqsave(&lp->lock, flags); in amd8111e_rx_poll()
785 spin_unlock_irqrestore(&lp->lock, flags); in amd8111e_rx_poll()
798 status0 = readl(lp->mmio + STAT0); in amd8111e_link_change()
802 lp->link_config.autoneg = AUTONEG_ENABLE; in amd8111e_link_change()
804 lp->link_config.autoneg = AUTONEG_DISABLE; in amd8111e_link_change()
807 lp->link_config.duplex = DUPLEX_FULL; in amd8111e_link_change()
809 lp->link_config.duplex = DUPLEX_HALF; in amd8111e_link_change()
812 lp->link_config.speed = SPEED_10; in amd8111e_link_change()
814 lp->link_config.speed = SPEED_100; in amd8111e_link_change()
817 (lp->link_config.speed == SPEED_100) ? in amd8111e_link_change()
819 (lp->link_config.duplex == DUPLEX_FULL) ? in amd8111e_link_change()
824 lp->link_config.speed = SPEED_INVALID; in amd8111e_link_change()
825 lp->link_config.duplex = DUPLEX_INVALID; in amd8111e_link_change()
826 lp->link_config.autoneg = AUTONEG_INVALID; in amd8111e_link_change()
846 while (--repeat && (status & MIB_CMD_ACTIVE)); in amd8111e_read_mib()
858 void __iomem *mmio = lp->mmio; in amd8111e_get_stats()
860 struct net_device_stats *new_stats = &dev->stats; in amd8111e_get_stats()
862 if (!lp->opened) in amd8111e_get_stats()
864 spin_lock_irqsave(&lp->lock, flags); in amd8111e_get_stats()
867 new_stats->rx_packets = amd8111e_read_mib(mmio, rcv_broadcast_pkts)+ in amd8111e_get_stats()
872 new_stats->tx_packets = amd8111e_read_mib(mmio, xmt_packets); in amd8111e_get_stats()
875 new_stats->rx_bytes = amd8111e_read_mib(mmio, rcv_octets); in amd8111e_get_stats()
878 new_stats->tx_bytes = amd8111e_read_mib(mmio, xmt_octets); in amd8111e_get_stats()
882 new_stats->rx_errors = amd8111e_read_mib(mmio, rcv_undersize_pkts)+ in amd8111e_get_stats()
888 lp->drv_rx_errors; in amd8111e_get_stats()
891 new_stats->tx_errors = amd8111e_read_mib(mmio, xmt_underrun_pkts); in amd8111e_get_stats()
894 new_stats->rx_dropped = amd8111e_read_mib(mmio, rcv_miss_pkts); in amd8111e_get_stats()
897 new_stats->tx_dropped = amd8111e_read_mib(mmio, xmt_underrun_pkts); in amd8111e_get_stats()
900 new_stats->multicast = amd8111e_read_mib(mmio, rcv_multicast_pkts); in amd8111e_get_stats()
903 new_stats->collisions = amd8111e_read_mib(mmio, xmt_collisions); in amd8111e_get_stats()
906 new_stats->rx_length_errors = in amd8111e_get_stats()
911 new_stats->rx_over_errors = amd8111e_read_mib(mmio, rcv_miss_pkts); in amd8111e_get_stats()
914 new_stats->rx_crc_errors = amd8111e_read_mib(mmio, rcv_fcs_errors); in amd8111e_get_stats()
917 new_stats->rx_frame_errors = in amd8111e_get_stats()
921 new_stats->rx_fifo_errors = amd8111e_read_mib(mmio, rcv_miss_pkts); in amd8111e_get_stats()
924 new_stats->rx_missed_errors = amd8111e_read_mib(mmio, rcv_miss_pkts); in amd8111e_get_stats()
927 new_stats->tx_aborted_errors = in amd8111e_get_stats()
931 new_stats->tx_carrier_errors = in amd8111e_get_stats()
935 new_stats->tx_fifo_errors = amd8111e_read_mib(mmio, xmt_underrun_pkts); in amd8111e_get_stats()
938 new_stats->tx_window_errors = in amd8111e_get_stats()
944 spin_unlock_irqrestore(&lp->lock, flags); in amd8111e_get_stats()
955 struct amd8111e_coalesce_conf *coal_conf = &lp->coal_conf; in amd8111e_calc_coalesce()
963 tx_pkt_rate = coal_conf->tx_packets - coal_conf->tx_prev_packets; in amd8111e_calc_coalesce()
964 coal_conf->tx_prev_packets = coal_conf->tx_packets; in amd8111e_calc_coalesce()
966 tx_data_rate = coal_conf->tx_bytes - coal_conf->tx_prev_bytes; in amd8111e_calc_coalesce()
967 coal_conf->tx_prev_bytes = coal_conf->tx_bytes; in amd8111e_calc_coalesce()
969 rx_pkt_rate = coal_conf->rx_packets - coal_conf->rx_prev_packets; in amd8111e_calc_coalesce()
970 coal_conf->rx_prev_packets = coal_conf->rx_packets; in amd8111e_calc_coalesce()
972 rx_data_rate = coal_conf->rx_bytes - coal_conf->rx_prev_bytes; in amd8111e_calc_coalesce()
973 coal_conf->rx_prev_bytes = coal_conf->rx_bytes; in amd8111e_calc_coalesce()
976 if (coal_conf->rx_coal_type != NO_COALESCE) { in amd8111e_calc_coalesce()
978 coal_conf->rx_timeout = 0x0; in amd8111e_calc_coalesce()
979 coal_conf->rx_event_count = 0; in amd8111e_calc_coalesce()
981 coal_conf->rx_coal_type = NO_COALESCE; in amd8111e_calc_coalesce()
987 if (coal_conf->rx_coal_type != NO_COALESCE) { in amd8111e_calc_coalesce()
989 coal_conf->rx_timeout = 0; in amd8111e_calc_coalesce()
990 coal_conf->rx_event_count = 0; in amd8111e_calc_coalesce()
992 coal_conf->rx_coal_type = NO_COALESCE; in amd8111e_calc_coalesce()
997 if (coal_conf->rx_coal_type != LOW_COALESCE) { in amd8111e_calc_coalesce()
998 coal_conf->rx_timeout = 1; in amd8111e_calc_coalesce()
999 coal_conf->rx_event_count = 4; in amd8111e_calc_coalesce()
1001 coal_conf->rx_coal_type = LOW_COALESCE; in amd8111e_calc_coalesce()
1005 if (coal_conf->rx_coal_type != MEDIUM_COALESCE) { in amd8111e_calc_coalesce()
1006 coal_conf->rx_timeout = 1; in amd8111e_calc_coalesce()
1007 coal_conf->rx_event_count = 4; in amd8111e_calc_coalesce()
1009 coal_conf->rx_coal_type = MEDIUM_COALESCE; in amd8111e_calc_coalesce()
1014 if (coal_conf->rx_coal_type != HIGH_COALESCE) { in amd8111e_calc_coalesce()
1015 coal_conf->rx_timeout = 2; in amd8111e_calc_coalesce()
1016 coal_conf->rx_event_count = 3; in amd8111e_calc_coalesce()
1018 coal_conf->rx_coal_type = HIGH_COALESCE; in amd8111e_calc_coalesce()
1024 if (coal_conf->tx_coal_type != NO_COALESCE) { in amd8111e_calc_coalesce()
1026 coal_conf->tx_timeout = 0x0; in amd8111e_calc_coalesce()
1027 coal_conf->tx_event_count = 0; in amd8111e_calc_coalesce()
1029 coal_conf->tx_coal_type = NO_COALESCE; in amd8111e_calc_coalesce()
1036 if (coal_conf->tx_coal_type != NO_COALESCE) { in amd8111e_calc_coalesce()
1038 coal_conf->tx_timeout = 0; in amd8111e_calc_coalesce()
1039 coal_conf->tx_event_count = 0; in amd8111e_calc_coalesce()
1041 coal_conf->tx_coal_type = NO_COALESCE; in amd8111e_calc_coalesce()
1046 if (coal_conf->tx_coal_type != LOW_COALESCE) { in amd8111e_calc_coalesce()
1047 coal_conf->tx_timeout = 1; in amd8111e_calc_coalesce()
1048 coal_conf->tx_event_count = 2; in amd8111e_calc_coalesce()
1050 coal_conf->tx_coal_type = LOW_COALESCE; in amd8111e_calc_coalesce()
1055 if (coal_conf->tx_coal_type != MEDIUM_COALESCE) { in amd8111e_calc_coalesce()
1056 coal_conf->tx_timeout = 2; in amd8111e_calc_coalesce()
1057 coal_conf->tx_event_count = 5; in amd8111e_calc_coalesce()
1059 coal_conf->tx_coal_type = MEDIUM_COALESCE; in amd8111e_calc_coalesce()
1062 if (coal_conf->tx_coal_type != HIGH_COALESCE) { in amd8111e_calc_coalesce()
1063 coal_conf->tx_timeout = 4; in amd8111e_calc_coalesce()
1064 coal_conf->tx_event_count = 8; in amd8111e_calc_coalesce()
1066 coal_conf->tx_coal_type = HIGH_COALESCE; in amd8111e_calc_coalesce()
1082 void __iomem *mmio = lp->mmio; in amd8111e_interrupt()
1089 spin_lock(&lp->lock); in amd8111e_interrupt()
1110 if (napi_schedule_prep(&lp->napi)) { in amd8111e_interrupt()
1114 __napi_schedule(&lp->napi); in amd8111e_interrupt()
1137 spin_unlock(&lp->lock); in amd8111e_interrupt()
1162 napi_disable(&lp->napi); in amd8111e_close()
1164 spin_lock_irq(&lp->lock); in amd8111e_close()
1170 amd8111e_free_skbs(lp->amd8111e_net_dev); in amd8111e_close()
1172 netif_carrier_off(lp->amd8111e_net_dev); in amd8111e_close()
1175 if (lp->options & OPTION_DYN_IPG_ENABLE) in amd8111e_close()
1176 del_timer_sync(&lp->ipg_data.ipg_timer); in amd8111e_close()
1178 spin_unlock_irq(&lp->lock); in amd8111e_close()
1179 free_irq(dev->irq, dev); in amd8111e_close()
1184 lp->opened = 0; in amd8111e_close()
1195 if (dev->irq == 0 || request_irq(dev->irq, amd8111e_interrupt, in amd8111e_open()
1196 IRQF_SHARED, dev->name, dev)) in amd8111e_open()
1197 return -EAGAIN; in amd8111e_open()
1199 napi_enable(&lp->napi); in amd8111e_open()
1201 spin_lock_irq(&lp->lock); in amd8111e_open()
1206 spin_unlock_irq(&lp->lock); in amd8111e_open()
1207 napi_disable(&lp->napi); in amd8111e_open()
1208 if (dev->irq) in amd8111e_open()
1209 free_irq(dev->irq, dev); in amd8111e_open()
1210 return -ENOMEM; in amd8111e_open()
1213 if (lp->options & OPTION_DYN_IPG_ENABLE) { in amd8111e_open()
1214 add_timer(&lp->ipg_data.ipg_timer); in amd8111e_open()
1218 lp->opened = 1; in amd8111e_open()
1220 spin_unlock_irq(&lp->lock); in amd8111e_open()
1232 int tx_index = lp->tx_idx & TX_BUFF_MOD_MASK; in amd8111e_tx_queue_avail()
1233 if (lp->tx_skbuff[tx_index]) in amd8111e_tx_queue_avail()
1234 return -1; in amd8111e_tx_queue_avail()
1252 spin_lock_irqsave(&lp->lock, flags); in amd8111e_start_xmit()
1254 tx_index = lp->tx_idx & TX_RING_DR_MOD_MASK; in amd8111e_start_xmit()
1256 lp->tx_ring[tx_index].buff_count = cpu_to_le16(skb->len); in amd8111e_start_xmit()
1258 lp->tx_skbuff[tx_index] = skb; in amd8111e_start_xmit()
1259 lp->tx_ring[tx_index].tx_flags = 0; in amd8111e_start_xmit()
1263 lp->tx_ring[tx_index].tag_ctrl_cmd |= in amd8111e_start_xmit()
1265 lp->tx_ring[tx_index].tag_ctrl_info = in amd8111e_start_xmit()
1270 lp->tx_dma_addr[tx_index] = in amd8111e_start_xmit()
1271 dma_map_single(&lp->pci_dev->dev, skb->data, skb->len, in amd8111e_start_xmit()
1273 lp->tx_ring[tx_index].buff_phy_addr = in amd8111e_start_xmit()
1274 cpu_to_le32(lp->tx_dma_addr[tx_index]); in amd8111e_start_xmit()
1278 lp->tx_ring[tx_index].tx_flags |= in amd8111e_start_xmit()
1281 lp->tx_idx++; in amd8111e_start_xmit()
1284 writel(VAL1 | TDMD0, lp->mmio + CMD0); in amd8111e_start_xmit()
1285 writel(VAL2 | RDMD0, lp->mmio + CMD0); in amd8111e_start_xmit()
1290 spin_unlock_irqrestore(&lp->lock, flags); in amd8111e_start_xmit()
1296 void __iomem *mmio = lp->mmio; in amd8111e_read_regs()
1314 /* This function sets promiscuos mode, all-multi mode or the multicast address
1324 if (dev->flags & IFF_PROMISC) { in amd8111e_set_multicast_list()
1325 writel(VAL2 | PROM, lp->mmio + CMD2); in amd8111e_set_multicast_list()
1329 writel(PROM, lp->mmio + CMD2); in amd8111e_set_multicast_list()
1330 if (dev->flags & IFF_ALLMULTI || in amd8111e_set_multicast_list()
1334 lp->options |= OPTION_MULTICAST_ENABLE; in amd8111e_set_multicast_list()
1335 amd8111e_writeq(*(u64 *)mc_filter, lp->mmio + LADRF); in amd8111e_set_multicast_list()
1341 lp->options &= ~OPTION_MULTICAST_ENABLE; in amd8111e_set_multicast_list()
1342 amd8111e_writeq(*(u64 *)mc_filter, lp->mmio + LADRF); in amd8111e_set_multicast_list()
1344 writel(PROM, lp->mmio + CMD2); in amd8111e_set_multicast_list()
1348 lp->options |= OPTION_MULTICAST_ENABLE; in amd8111e_set_multicast_list()
1351 bit_num = (ether_crc_le(ETH_ALEN, ha->addr) >> 26) & 0x3f; in amd8111e_set_multicast_list()
1354 amd8111e_writeq(*(u64 *)mc_filter, lp->mmio + LADRF); in amd8111e_set_multicast_list()
1357 readl(lp->mmio + CMD2); in amd8111e_set_multicast_list()
1365 struct pci_dev *pci_dev = lp->pci_dev; in amd8111e_get_drvinfo()
1366 strscpy(info->driver, MODULE_NAME, sizeof(info->driver)); in amd8111e_get_drvinfo()
1367 snprintf(info->fw_version, sizeof(info->fw_version), in amd8111e_get_drvinfo()
1369 strscpy(info->bus_info, pci_name(pci_dev), sizeof(info->bus_info)); in amd8111e_get_drvinfo()
1380 regs->version = 0; in amd8111e_get_regs()
1388 spin_lock_irq(&lp->lock); in amd8111e_get_link_ksettings()
1389 mii_ethtool_get_link_ksettings(&lp->mii_if, cmd); in amd8111e_get_link_ksettings()
1390 spin_unlock_irq(&lp->lock); in amd8111e_get_link_ksettings()
1399 spin_lock_irq(&lp->lock); in amd8111e_set_link_ksettings()
1400 res = mii_ethtool_set_link_ksettings(&lp->mii_if, cmd); in amd8111e_set_link_ksettings()
1401 spin_unlock_irq(&lp->lock); in amd8111e_set_link_ksettings()
1408 return mii_nway_restart(&lp->mii_if); in amd8111e_nway_reset()
1414 return mii_link_ok(&lp->mii_if); in amd8111e_get_link()
1420 wol_info->supported = WAKE_MAGIC|WAKE_PHY; in amd8111e_get_wol()
1421 if (lp->options & OPTION_WOL_ENABLE) in amd8111e_get_wol()
1422 wol_info->wolopts = WAKE_MAGIC; in amd8111e_get_wol()
1428 if (wol_info->wolopts & ~(WAKE_MAGIC|WAKE_PHY)) in amd8111e_set_wol()
1429 return -EINVAL; in amd8111e_set_wol()
1430 spin_lock_irq(&lp->lock); in amd8111e_set_wol()
1431 if (wol_info->wolopts & WAKE_MAGIC) in amd8111e_set_wol()
1432 lp->options |= in amd8111e_set_wol()
1434 else if (wol_info->wolopts & WAKE_PHY) in amd8111e_set_wol()
1435 lp->options |= in amd8111e_set_wol()
1438 lp->options &= ~OPTION_WOL_ENABLE; in amd8111e_set_wol()
1439 spin_unlock_irq(&lp->lock); in amd8111e_set_wol()
1468 data->phy_id = lp->ext_phy_addr; in amd8111e_ioctl()
1473 spin_lock_irq(&lp->lock); in amd8111e_ioctl()
1474 err = amd8111e_read_phy(lp, data->phy_id, in amd8111e_ioctl()
1475 data->reg_num & PHY_REG_ADDR_MASK, &mii_regval); in amd8111e_ioctl()
1476 spin_unlock_irq(&lp->lock); in amd8111e_ioctl()
1478 data->val_out = mii_regval; in amd8111e_ioctl()
1483 spin_lock_irq(&lp->lock); in amd8111e_ioctl()
1484 err = amd8111e_write_phy(lp, data->phy_id, in amd8111e_ioctl()
1485 data->reg_num & PHY_REG_ADDR_MASK, data->val_in); in amd8111e_ioctl()
1486 spin_unlock_irq(&lp->lock); in amd8111e_ioctl()
1494 return -EOPNOTSUPP; in amd8111e_ioctl()
1502 eth_hw_addr_set(dev, addr->sa_data); in amd8111e_set_mac_address()
1503 spin_lock_irq(&lp->lock); in amd8111e_set_mac_address()
1506 writeb(dev->dev_addr[i], lp->mmio + PADR + i); in amd8111e_set_mac_address()
1508 spin_unlock_irq(&lp->lock); in amd8111e_set_mac_address()
1525 WRITE_ONCE(dev->mtu, new_mtu); in amd8111e_change_mtu()
1529 spin_lock_irq(&lp->lock); in amd8111e_change_mtu()
1532 writel(RUN, lp->mmio + CMD0); in amd8111e_change_mtu()
1534 WRITE_ONCE(dev->mtu, new_mtu); in amd8111e_change_mtu()
1537 spin_unlock_irq(&lp->lock); in amd8111e_change_mtu()
1545 writel(VAL1 | MPPLBA, lp->mmio + CMD3); in amd8111e_enable_magicpkt()
1546 writel(VAL0 | MPEN_SW, lp->mmio + CMD7); in amd8111e_enable_magicpkt()
1549 readl(lp->mmio + CMD7); in amd8111e_enable_magicpkt()
1556 /* Adapter is already stopped/suspended/interrupt-disabled */ in amd8111e_enable_link_change()
1557 writel(VAL0 | LCMODE_SW, lp->mmio + CMD7); in amd8111e_enable_link_change()
1560 readl(lp->mmio + CMD7); in amd8111e_enable_link_change()
1576 spin_lock_irq(&lp->lock); in amd8111e_tx_timeout()
1578 spin_unlock_irq(&lp->lock); in amd8111e_tx_timeout()
1592 spin_lock_irq(&lp->lock); in amd8111e_suspend()
1594 spin_unlock_irq(&lp->lock); in amd8111e_suspend()
1599 spin_lock_irq(&lp->lock); in amd8111e_suspend()
1600 if (lp->options & OPTION_DYN_IPG_ENABLE) in amd8111e_suspend()
1601 del_timer_sync(&lp->ipg_data.ipg_timer); in amd8111e_suspend()
1603 spin_unlock_irq(&lp->lock); in amd8111e_suspend()
1605 if (lp->options & OPTION_WOL_ENABLE) { in amd8111e_suspend()
1607 if (lp->options & OPTION_WAKE_MAGIC_ENABLE) in amd8111e_suspend()
1609 if (lp->options & OPTION_WAKE_PHY_ENABLE) in amd8111e_suspend()
1631 spin_lock_irq(&lp->lock); in amd8111e_resume()
1634 if (lp->options & OPTION_DYN_IPG_ENABLE) in amd8111e_resume()
1635 mod_timer(&lp->ipg_data.ipg_timer, in amd8111e_resume()
1637 spin_unlock_irq(&lp->lock); in amd8111e_resume()
1645 struct ipg_info *ipg_data = &lp->ipg_data; in amd8111e_config_ipg()
1646 void __iomem *mmio = lp->mmio; in amd8111e_config_ipg()
1647 unsigned int prev_col_cnt = ipg_data->col_cnt; in amd8111e_config_ipg()
1651 if (lp->link_config.duplex == DUPLEX_FULL) { in amd8111e_config_ipg()
1652 ipg_data->ipg = DEFAULT_IPG; in amd8111e_config_ipg()
1656 if (ipg_data->ipg_state == SSTATE) { in amd8111e_config_ipg()
1658 if (ipg_data->timer_tick == IPG_STABLE_TIME) { in amd8111e_config_ipg()
1660 ipg_data->timer_tick = 0; in amd8111e_config_ipg()
1661 ipg_data->ipg = MIN_IPG - IPG_STEP; in amd8111e_config_ipg()
1662 ipg_data->current_ipg = MIN_IPG; in amd8111e_config_ipg()
1663 ipg_data->diff_col_cnt = 0xFFFFFFFF; in amd8111e_config_ipg()
1664 ipg_data->ipg_state = CSTATE; in amd8111e_config_ipg()
1667 ipg_data->timer_tick++; in amd8111e_config_ipg()
1670 if (ipg_data->ipg_state == CSTATE) { in amd8111e_config_ipg()
1674 total_col_cnt = ipg_data->col_cnt = in amd8111e_config_ipg()
1677 if ((total_col_cnt - prev_col_cnt) < in amd8111e_config_ipg()
1678 (ipg_data->diff_col_cnt)) { in amd8111e_config_ipg()
1680 ipg_data->diff_col_cnt = in amd8111e_config_ipg()
1681 total_col_cnt - prev_col_cnt; in amd8111e_config_ipg()
1683 ipg_data->ipg = ipg_data->current_ipg; in amd8111e_config_ipg()
1686 ipg_data->current_ipg += IPG_STEP; in amd8111e_config_ipg()
1688 if (ipg_data->current_ipg <= MAX_IPG) in amd8111e_config_ipg()
1689 tmp_ipg = ipg_data->current_ipg; in amd8111e_config_ipg()
1691 tmp_ipg = ipg_data->ipg; in amd8111e_config_ipg()
1692 ipg_data->ipg_state = SSTATE; in amd8111e_config_ipg()
1695 writew((u32)(tmp_ipg - IFS1_DELTA), mmio + IFS1); in amd8111e_config_ipg()
1697 mod_timer(&lp->ipg_data.ipg_timer, jiffies + IPG_CONVERGE_JIFFIES); in amd8111e_config_ipg()
1707 for (i = 0x1e; i >= 0; i--) { in amd8111e_probe_ext_phy()
1708 u32 id1, id2; in amd8111e_probe_ext_phy() local
1712 if (amd8111e_read_phy(lp, i, MII_PHYSID2, &id2)) in amd8111e_probe_ext_phy()
1714 lp->ext_phy_id = (id1 << 16) | id2; in amd8111e_probe_ext_phy()
1715 lp->ext_phy_addr = i; in amd8111e_probe_ext_phy()
1718 lp->ext_phy_id = 0; in amd8111e_probe_ext_phy()
1719 lp->ext_phy_addr = 1; in amd8111e_probe_ext_phy()
1749 dev_err(&pdev->dev, "Cannot enable new PCI device\n"); in amd8111e_probe_one()
1754 dev_err(&pdev->dev, "Cannot find PCI base address\n"); in amd8111e_probe_one()
1755 err = -ENODEV; in amd8111e_probe_one()
1761 dev_err(&pdev->dev, "Cannot obtain PCI resources\n"); in amd8111e_probe_one()
1767 /* Find power-management capability. */ in amd8111e_probe_one()
1768 if (!pdev->pm_cap) { in amd8111e_probe_one()
1769 dev_err(&pdev->dev, "No Power Management capability\n"); in amd8111e_probe_one()
1770 err = -ENODEV; in amd8111e_probe_one()
1775 if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) < 0) { in amd8111e_probe_one()
1776 dev_err(&pdev->dev, "DMA not supported\n"); in amd8111e_probe_one()
1777 err = -ENODEV; in amd8111e_probe_one()
1786 err = -ENOMEM; in amd8111e_probe_one()
1790 SET_NETDEV_DEV(dev, &pdev->dev); in amd8111e_probe_one()
1793 dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX; in amd8111e_probe_one()
1797 lp->pci_dev = pdev; in amd8111e_probe_one()
1798 lp->amd8111e_net_dev = dev; in amd8111e_probe_one()
1800 spin_lock_init(&lp->lock); in amd8111e_probe_one()
1802 lp->mmio = devm_ioremap(&pdev->dev, reg_addr, reg_len); in amd8111e_probe_one()
1803 if (!lp->mmio) { in amd8111e_probe_one()
1804 dev_err(&pdev->dev, "Cannot map device registers\n"); in amd8111e_probe_one()
1805 err = -ENOMEM; in amd8111e_probe_one()
1811 addr[i] = readb(lp->mmio + PADR + i); in amd8111e_probe_one()
1815 lp->ext_phy_option = speed_duplex[card_idx]; in amd8111e_probe_one()
1817 lp->options |= OPTION_INTR_COAL_ENABLE; in amd8111e_probe_one()
1819 lp->options |= OPTION_DYN_IPG_ENABLE; in amd8111e_probe_one()
1823 dev->netdev_ops = &amd8111e_netdev_ops; in amd8111e_probe_one()
1824 dev->ethtool_ops = &ops; in amd8111e_probe_one()
1825 dev->irq = pdev->irq; in amd8111e_probe_one()
1826 dev->watchdog_timeo = AMD8111E_TX_TIMEOUT; in amd8111e_probe_one()
1827 dev->min_mtu = AMD8111E_MIN_MTU; in amd8111e_probe_one()
1828 dev->max_mtu = AMD8111E_MAX_MTU; in amd8111e_probe_one()
1829 netif_napi_add_weight(dev, &lp->napi, amd8111e_rx_poll, 32); in amd8111e_probe_one()
1835 lp->mii_if.dev = dev; in amd8111e_probe_one()
1836 lp->mii_if.mdio_read = amd8111e_mdio_read; in amd8111e_probe_one()
1837 lp->mii_if.mdio_write = amd8111e_mdio_write; in amd8111e_probe_one()
1838 lp->mii_if.phy_id = lp->ext_phy_addr; in amd8111e_probe_one()
1846 dev_err(&pdev->dev, "Cannot register net device\n"); in amd8111e_probe_one()
1853 if (lp->options & OPTION_DYN_IPG_ENABLE) { in amd8111e_probe_one()
1854 timer_setup(&lp->ipg_data.ipg_timer, amd8111e_config_ipg, 0); in amd8111e_probe_one()
1855 lp->ipg_data.ipg_timer.expires = jiffies + in amd8111e_probe_one()
1857 lp->ipg_data.ipg = DEFAULT_IPG; in amd8111e_probe_one()
1858 lp->ipg_data.ipg_state = CSTATE; in amd8111e_probe_one()
1862 chip_version = (readl(lp->mmio + CHIPID) & 0xf0000000) >> 28; in amd8111e_probe_one()
1863 dev_info(&pdev->dev, "[ Rev %x ] PCI 10/100BaseT Ethernet %pM\n", in amd8111e_probe_one()
1864 chip_version, dev->dev_addr); in amd8111e_probe_one()
1865 if (lp->ext_phy_id) in amd8111e_probe_one()
1866 dev_info(&pdev->dev, "Found MII PHY ID 0x%08x at address 0x%02x\n", in amd8111e_probe_one()
1867 lp->ext_phy_id, lp->ext_phy_addr); in amd8111e_probe_one()
1869 dev_info(&pdev->dev, "Couldn't detect MII PHY, assuming address 0x01\n"); in amd8111e_probe_one()