Lines Matching +full:pme +full:- +full:active +full:- +full:high
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright(c) 2006 - 2007 Atheros Corporation. All rights reserved.
4 * Copyright(c) 2007 - 2008 Chris Snook <csnook@redhat.com>
7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
12 #include <linux/dma-mapping.h>
47 * atl2_pci_tbl - PCI Device ID Table
59 * atl2_sw_init - Initialize general software structures (struct atl2_adapter)
68 struct atl2_hw *hw = &adapter->hw; in atl2_sw_init()
69 struct pci_dev *pdev = adapter->pdev; in atl2_sw_init()
72 hw->vendor_id = pdev->vendor; in atl2_sw_init()
73 hw->device_id = pdev->device; in atl2_sw_init()
74 hw->subsystem_vendor_id = pdev->subsystem_vendor; in atl2_sw_init()
75 hw->subsystem_id = pdev->subsystem_device; in atl2_sw_init()
76 hw->revision_id = pdev->revision; in atl2_sw_init()
78 pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word); in atl2_sw_init()
80 adapter->wol = 0; in atl2_sw_init()
81 adapter->ict = 50000; /* ~100ms */ in atl2_sw_init()
82 adapter->link_speed = SPEED_0; /* hardware init */ in atl2_sw_init()
83 adapter->link_duplex = FULL_DUPLEX; in atl2_sw_init()
85 hw->phy_configured = false; in atl2_sw_init()
86 hw->preamble_len = 7; in atl2_sw_init()
87 hw->ipgt = 0x60; in atl2_sw_init()
88 hw->min_ifg = 0x50; in atl2_sw_init()
89 hw->ipgr1 = 0x40; in atl2_sw_init()
90 hw->ipgr2 = 0x60; in atl2_sw_init()
91 hw->retry_buf = 2; in atl2_sw_init()
92 hw->max_retry = 0xf; in atl2_sw_init()
93 hw->lcol = 0x37; in atl2_sw_init()
94 hw->jam_ipg = 7; in atl2_sw_init()
95 hw->fc_rxd_hi = 0; in atl2_sw_init()
96 hw->fc_rxd_lo = 0; in atl2_sw_init()
97 hw->max_frame_size = adapter->netdev->mtu; in atl2_sw_init()
99 spin_lock_init(&adapter->stats_lock); in atl2_sw_init()
101 set_bit(__ATL2_DOWN, &adapter->flags); in atl2_sw_init()
107 * atl2_set_multi - Multicast and Promiscuous mode set
113 * promiscuous mode, and all-multi behavior.
118 struct atl2_hw *hw = &adapter->hw; in atl2_set_multi()
126 if (netdev->flags & IFF_PROMISC) { in atl2_set_multi()
128 } else if (netdev->flags & IFF_ALLMULTI) { in atl2_set_multi()
142 hash_value = atl2_hash_mc_addr(hw, ha->addr); in atl2_set_multi()
150 adapter->txd_write_ptr = 0; in init_ring_ptrs()
151 atomic_set(&adapter->txd_read_ptr, 0); in init_ring_ptrs()
153 adapter->rxd_read_ptr = 0; in init_ring_ptrs()
154 adapter->rxd_write_ptr = 0; in init_ring_ptrs()
156 atomic_set(&adapter->txs_write_ptr, 0); in init_ring_ptrs()
157 adapter->txs_next_clear = 0; in init_ring_ptrs()
161 * atl2_configure - Configure Transmit&Receive Unit after Reset
168 struct atl2_hw *hw = &adapter->hw; in atl2_configure()
172 ATL2_WRITE_REG(&adapter->hw, REG_ISR, 0xffffffff); in atl2_configure()
175 value = (((u32)hw->mac_addr[2]) << 24) | in atl2_configure()
176 (((u32)hw->mac_addr[3]) << 16) | in atl2_configure()
177 (((u32)hw->mac_addr[4]) << 8) | in atl2_configure()
178 (((u32)hw->mac_addr[5])); in atl2_configure()
180 value = (((u32)hw->mac_addr[0]) << 8) | in atl2_configure()
181 (((u32)hw->mac_addr[1])); in atl2_configure()
186 (u32)((adapter->ring_dma & 0xffffffff00000000ULL) >> 32)); in atl2_configure()
190 (u32)(adapter->txd_dma & 0x00000000ffffffffULL)); in atl2_configure()
192 (u32)(adapter->txs_dma & 0x00000000ffffffffULL)); in atl2_configure()
194 (u32)(adapter->rxd_dma & 0x00000000ffffffffULL)); in atl2_configure()
197 ATL2_WRITE_REGW(hw, REG_TXD_MEM_SIZE, (u16)(adapter->txd_ring_size/4)); in atl2_configure()
198 ATL2_WRITE_REGW(hw, REG_TXS_MEM_SIZE, (u16)adapter->txs_ring_size); in atl2_configure()
199 ATL2_WRITE_REGW(hw, REG_RXD_BUF_NUM, (u16)adapter->rxd_ring_size); in atl2_configure()
208 value = (((u32)hw->ipgt & MAC_IPG_IFG_IPGT_MASK) << in atl2_configure()
210 (((u32)hw->min_ifg & MAC_IPG_IFG_MIFG_MASK) << in atl2_configure()
212 (((u32)hw->ipgr1 & MAC_IPG_IFG_IPGR1_MASK) << in atl2_configure()
214 (((u32)hw->ipgr2 & MAC_IPG_IFG_IPGR2_MASK) << in atl2_configure()
218 /* config Half-Duplex Control */ in atl2_configure()
219 value = ((u32)hw->lcol & MAC_HALF_DUPLX_CTRL_LCOL_MASK) | in atl2_configure()
220 (((u32)hw->max_retry & MAC_HALF_DUPLX_CTRL_RETRY_MASK) << in atl2_configure()
224 (((u32)hw->jam_ipg & MAC_HALF_DUPLX_CTRL_JAMIPG_MASK) << in atl2_configure()
229 ATL2_WRITE_REGW(hw, REG_IRQ_MODU_TIMER_INIT, adapter->imt); in atl2_configure()
233 ATL2_WRITE_REGW(hw, REG_CMBDISDMA_TIMER, adapter->ict); in atl2_configure()
236 ATL2_WRITE_REG(hw, REG_MTU, adapter->netdev->mtu + in atl2_configure()
243 ATL2_WRITE_REGW(hw, REG_PAUSE_ON_TH, hw->fc_rxd_hi); in atl2_configure()
244 ATL2_WRITE_REGW(hw, REG_PAUSE_OFF_TH, hw->fc_rxd_lo); in atl2_configure()
247 ATL2_WRITE_REGW(hw, REG_MB_TXD_WR_IDX, (u16)adapter->txd_write_ptr); in atl2_configure()
248 ATL2_WRITE_REGW(hw, REG_MB_RXD_RD_IDX, (u16)adapter->rxd_read_ptr); in atl2_configure()
254 value = ATL2_READ_REG(&adapter->hw, REG_ISR); in atl2_configure()
261 ATL2_WRITE_REG(&adapter->hw, REG_ISR, 0x3fffffff); in atl2_configure()
262 ATL2_WRITE_REG(&adapter->hw, REG_ISR, 0); in atl2_configure()
267 * atl2_setup_ring_resources - allocate Tx / RX descriptor resources
274 struct pci_dev *pdev = adapter->pdev; in atl2_setup_ring_resources()
279 adapter->ring_size = size = in atl2_setup_ring_resources()
280 adapter->txd_ring_size * 1 + 7 + /* dword align */ in atl2_setup_ring_resources()
281 adapter->txs_ring_size * 4 + 7 + /* dword align */ in atl2_setup_ring_resources()
282 adapter->rxd_ring_size * 1536 + 127; /* 128bytes align */ in atl2_setup_ring_resources()
284 adapter->ring_vir_addr = dma_alloc_coherent(&pdev->dev, size, in atl2_setup_ring_resources()
285 &adapter->ring_dma, GFP_KERNEL); in atl2_setup_ring_resources()
286 if (!adapter->ring_vir_addr) in atl2_setup_ring_resources()
287 return -ENOMEM; in atl2_setup_ring_resources()
290 adapter->txd_dma = adapter->ring_dma ; in atl2_setup_ring_resources()
291 offset = (adapter->txd_dma & 0x7) ? (8 - (adapter->txd_dma & 0x7)) : 0; in atl2_setup_ring_resources()
292 adapter->txd_dma += offset; in atl2_setup_ring_resources()
293 adapter->txd_ring = adapter->ring_vir_addr + offset; in atl2_setup_ring_resources()
296 adapter->txs_dma = adapter->txd_dma + adapter->txd_ring_size; in atl2_setup_ring_resources()
297 offset = (adapter->txs_dma & 0x7) ? (8 - (adapter->txs_dma & 0x7)) : 0; in atl2_setup_ring_resources()
298 adapter->txs_dma += offset; in atl2_setup_ring_resources()
299 adapter->txs_ring = (struct tx_pkt_status *) in atl2_setup_ring_resources()
300 (((u8 *)adapter->txd_ring) + (adapter->txd_ring_size + offset)); in atl2_setup_ring_resources()
303 adapter->rxd_dma = adapter->txs_dma + adapter->txs_ring_size * 4; in atl2_setup_ring_resources()
304 offset = (adapter->rxd_dma & 127) ? in atl2_setup_ring_resources()
305 (128 - (adapter->rxd_dma & 127)) : 0; in atl2_setup_ring_resources()
307 offset -= 8; in atl2_setup_ring_resources()
309 offset += (128 - 8); in atl2_setup_ring_resources()
311 adapter->rxd_dma += offset; in atl2_setup_ring_resources()
312 adapter->rxd_ring = (struct rx_desc *) (((u8 *)adapter->txs_ring) + in atl2_setup_ring_resources()
313 (adapter->txs_ring_size * 4 + offset)); in atl2_setup_ring_resources()
323 * atl2_irq_enable - Enable default interrupt generation settings
328 ATL2_WRITE_REG(&adapter->hw, REG_IMR, IMR_NORMAL_MASK); in atl2_irq_enable()
329 ATL2_WRITE_FLUSH(&adapter->hw); in atl2_irq_enable()
333 * atl2_irq_disable - Mask off interrupt generation on the NIC
338 ATL2_WRITE_REG(&adapter->hw, REG_IMR, 0); in atl2_irq_disable()
339 ATL2_WRITE_FLUSH(&adapter->hw); in atl2_irq_disable()
340 synchronize_irq(adapter->pdev->irq); in atl2_irq_disable()
362 ctrl = ATL2_READ_REG(&adapter->hw, REG_MAC_CTRL); in atl2_vlan_mode()
364 ATL2_WRITE_REG(&adapter->hw, REG_MAC_CTRL, ctrl); in atl2_vlan_mode()
371 atl2_vlan_mode(adapter->netdev, adapter->netdev->features); in atl2_restore_vlan()
392 netdev_features_t changed = netdev->features ^ features; in atl2_set_features()
402 struct net_device *netdev = adapter->netdev; in atl2_intr_rx()
407 rxd = adapter->rxd_ring+adapter->rxd_write_ptr; in atl2_intr_rx()
408 if (!rxd->status.update) in atl2_intr_rx()
412 rxd->status.update = 0; in atl2_intr_rx()
414 if (rxd->status.ok && rxd->status.pkt_size >= 60) { in atl2_intr_rx()
415 int rx_size = (int)(rxd->status.pkt_size - 4); in atl2_intr_rx()
421 * free one and mark stats->rx_dropped++. in atl2_intr_rx()
423 netdev->stats.rx_dropped++; in atl2_intr_rx()
426 memcpy(skb->data, rxd->packet, rx_size); in atl2_intr_rx()
428 skb->protocol = eth_type_trans(skb, netdev); in atl2_intr_rx()
429 if (rxd->status.vlan) { in atl2_intr_rx()
430 u16 vlan_tag = (rxd->status.vtag>>4) | in atl2_intr_rx()
431 ((rxd->status.vtag&7) << 13) | in atl2_intr_rx()
432 ((rxd->status.vtag&8) << 9); in atl2_intr_rx()
437 netdev->stats.rx_bytes += rx_size; in atl2_intr_rx()
438 netdev->stats.rx_packets++; in atl2_intr_rx()
440 netdev->stats.rx_errors++; in atl2_intr_rx()
442 if (rxd->status.ok && rxd->status.pkt_size <= 60) in atl2_intr_rx()
443 netdev->stats.rx_length_errors++; in atl2_intr_rx()
444 if (rxd->status.mcast) in atl2_intr_rx()
445 netdev->stats.multicast++; in atl2_intr_rx()
446 if (rxd->status.crc) in atl2_intr_rx()
447 netdev->stats.rx_crc_errors++; in atl2_intr_rx()
448 if (rxd->status.align) in atl2_intr_rx()
449 netdev->stats.rx_frame_errors++; in atl2_intr_rx()
453 if (++adapter->rxd_write_ptr == adapter->rxd_ring_size) in atl2_intr_rx()
454 adapter->rxd_write_ptr = 0; in atl2_intr_rx()
458 adapter->rxd_read_ptr = adapter->rxd_write_ptr; in atl2_intr_rx()
459 ATL2_WRITE_REGW(&adapter->hw, REG_MB_RXD_RD_IDX, adapter->rxd_read_ptr); in atl2_intr_rx()
464 struct net_device *netdev = adapter->netdev; in atl2_intr_tx()
472 txs_write_ptr = (u32) atomic_read(&adapter->txs_write_ptr); in atl2_intr_tx()
473 txs = adapter->txs_ring + txs_write_ptr; in atl2_intr_tx()
474 if (!txs->update) in atl2_intr_tx()
478 txs->update = 0; in atl2_intr_tx()
480 if (++txs_write_ptr == adapter->txs_ring_size) in atl2_intr_tx()
482 atomic_set(&adapter->txs_write_ptr, (int)txs_write_ptr); in atl2_intr_tx()
484 txd_read_ptr = (u32) atomic_read(&adapter->txd_read_ptr); in atl2_intr_tx()
486 (((u8 *)adapter->txd_ring) + txd_read_ptr); in atl2_intr_tx()
488 if (txph->pkt_size != txs->pkt_size) { in atl2_intr_tx()
493 adapter->netdev->name, in atl2_intr_tx()
498 txs = adapter->txs_ring + txs_write_ptr; in atl2_intr_tx()
500 "txs-behind:0x%08x\n", in atl2_intr_tx()
503 txs = adapter->txs_ring + in atl2_intr_tx()
504 (adapter->txs_ring_size + in atl2_intr_tx()
505 txs_write_ptr - 2); in atl2_intr_tx()
507 txs = adapter->txs_ring + (txs_write_ptr - 2); in atl2_intr_tx()
510 "txs-before:0x%08x\n", in atl2_intr_tx()
516 txd_read_ptr += (((u32)(txph->pkt_size) + 7) & ~3); in atl2_intr_tx()
517 if (txd_read_ptr >= adapter->txd_ring_size) in atl2_intr_tx()
518 txd_read_ptr -= adapter->txd_ring_size; in atl2_intr_tx()
520 atomic_set(&adapter->txd_read_ptr, (int)txd_read_ptr); in atl2_intr_tx()
523 if (txs->ok) { in atl2_intr_tx()
524 netdev->stats.tx_bytes += txs->pkt_size; in atl2_intr_tx()
525 netdev->stats.tx_packets++; in atl2_intr_tx()
528 netdev->stats.tx_errors++; in atl2_intr_tx()
530 if (txs->defer) in atl2_intr_tx()
531 netdev->stats.collisions++; in atl2_intr_tx()
532 if (txs->abort_col) in atl2_intr_tx()
533 netdev->stats.tx_aborted_errors++; in atl2_intr_tx()
534 if (txs->late_col) in atl2_intr_tx()
535 netdev->stats.tx_window_errors++; in atl2_intr_tx()
536 if (txs->underrun) in atl2_intr_tx()
537 netdev->stats.tx_fifo_errors++; in atl2_intr_tx()
541 if (netif_queue_stopped(adapter->netdev) && in atl2_intr_tx()
542 netif_carrier_ok(adapter->netdev)) in atl2_intr_tx()
543 netif_wake_queue(adapter->netdev); in atl2_intr_tx()
549 struct net_device *netdev = adapter->netdev; in atl2_check_for_link()
552 spin_lock(&adapter->stats_lock); in atl2_check_for_link()
553 atl2_read_phy_reg(&adapter->hw, MII_BMSR, &phy_data); in atl2_check_for_link()
554 atl2_read_phy_reg(&adapter->hw, MII_BMSR, &phy_data); in atl2_check_for_link()
555 spin_unlock(&adapter->stats_lock); in atl2_check_for_link()
561 atl2_driver_name, netdev->name); in atl2_check_for_link()
562 adapter->link_speed = SPEED_0; in atl2_check_for_link()
567 schedule_work(&adapter->link_chg_task); in atl2_check_for_link()
573 spin_lock(&adapter->stats_lock); in atl2_clear_phy_int()
574 atl2_read_phy_reg(&adapter->hw, 19, &phy_data); in atl2_clear_phy_int()
575 spin_unlock(&adapter->stats_lock); in atl2_clear_phy_int()
579 * atl2_intr - Interrupt Handler
586 struct atl2_hw *hw = &adapter->hw; in atl2_intr()
602 if (netif_running(adapter->netdev)) { /* reset MAC */ in atl2_intr()
606 schedule_work(&adapter->reset_task); in atl2_intr()
616 schedule_work(&adapter->reset_task); in atl2_intr()
622 adapter->netdev->stats.tx_carrier_errors++; in atl2_intr()
634 /* re-enable Interrupt */ in atl2_intr()
635 ATL2_WRITE_REG(&adapter->hw, REG_ISR, 0); in atl2_intr()
641 struct net_device *netdev = adapter->netdev; in atl2_request_irq()
645 adapter->have_msi = true; in atl2_request_irq()
646 err = pci_enable_msi(adapter->pdev); in atl2_request_irq()
648 adapter->have_msi = false; in atl2_request_irq()
650 if (adapter->have_msi) in atl2_request_irq()
653 return request_irq(adapter->pdev->irq, atl2_intr, flags, netdev->name, in atl2_request_irq()
658 * atl2_free_ring_resources - Free Tx / RX descriptor Resources
665 struct pci_dev *pdev = adapter->pdev; in atl2_free_ring_resources()
666 dma_free_coherent(&pdev->dev, adapter->ring_size, in atl2_free_ring_resources()
667 adapter->ring_vir_addr, adapter->ring_dma); in atl2_free_ring_resources()
671 * atl2_open - Called when a network interface is made active
677 * active by the system (IFF_UP). At this point all resources needed
689 if (test_bit(__ATL2_TESTING, &adapter->flags)) in atl2_open()
690 return -EBUSY; in atl2_open()
697 err = atl2_init_hw(&adapter->hw); in atl2_open()
699 err = -EIO; in atl2_open()
710 err = -EIO; in atl2_open()
718 clear_bit(__ATL2_DOWN, &adapter->flags); in atl2_open()
720 mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 4*HZ)); in atl2_open()
722 val = ATL2_READ_REG(&adapter->hw, REG_MASTER_CTRL); in atl2_open()
723 ATL2_WRITE_REG(&adapter->hw, REG_MASTER_CTRL, in atl2_open()
734 atl2_reset_hw(&adapter->hw); in atl2_open()
741 struct net_device *netdev = adapter->netdev; in atl2_down()
745 set_bit(__ATL2_DOWN, &adapter->flags); in atl2_down()
750 atl2_reset_hw(&adapter->hw); in atl2_down()
755 del_timer_sync(&adapter->watchdog_timer); in atl2_down()
756 del_timer_sync(&adapter->phy_config_timer); in atl2_down()
757 clear_bit(0, &adapter->cfg_phy); in atl2_down()
760 adapter->link_speed = SPEED_0; in atl2_down()
761 adapter->link_duplex = -1; in atl2_down()
766 struct net_device *netdev = adapter->netdev; in atl2_free_irq()
768 free_irq(adapter->pdev->irq, netdev); in atl2_free_irq()
771 if (adapter->have_msi) in atl2_free_irq()
772 pci_disable_msi(adapter->pdev); in atl2_free_irq()
777 * atl2_close - Disables a network interface
782 * The close entry point is called when an interface is de-activated
791 WARN_ON(test_bit(__ATL2_RESETTING, &adapter->flags)); in atl2_close()
802 u32 txs_write_ptr = (u32) atomic_read(&adapter->txs_write_ptr); in TxsFreeUnit()
804 return (adapter->txs_next_clear >= txs_write_ptr) ? in TxsFreeUnit()
805 (int) (adapter->txs_ring_size - adapter->txs_next_clear + in TxsFreeUnit()
806 txs_write_ptr - 1) : in TxsFreeUnit()
807 (int) (txs_write_ptr - adapter->txs_next_clear - 1); in TxsFreeUnit()
812 u32 txd_read_ptr = (u32)atomic_read(&adapter->txd_read_ptr); in TxdFreeBytes()
814 return (adapter->txd_write_ptr >= txd_read_ptr) ? in TxdFreeBytes()
815 (int) (adapter->txd_ring_size - adapter->txd_write_ptr + in TxdFreeBytes()
816 txd_read_ptr - 1) : in TxdFreeBytes()
817 (int) (txd_read_ptr - adapter->txd_write_ptr - 1); in TxdFreeBytes()
829 if (test_bit(__ATL2_DOWN, &adapter->flags)) { in atl2_xmit_frame()
834 if (unlikely(skb->len <= 0)) { in atl2_xmit_frame()
842 if (skb->len + sizeof(struct tx_pkt_header) + 4 > txbuf_unused || in atl2_xmit_frame()
849 offset = adapter->txd_write_ptr; in atl2_xmit_frame()
851 txph = (struct tx_pkt_header *) (((u8 *)adapter->txd_ring) + offset); in atl2_xmit_frame()
854 txph->pkt_size = skb->len; in atl2_xmit_frame()
857 if (offset >= adapter->txd_ring_size) in atl2_xmit_frame()
858 offset -= adapter->txd_ring_size; in atl2_xmit_frame()
859 copy_len = adapter->txd_ring_size - offset; in atl2_xmit_frame()
860 if (copy_len >= skb->len) { in atl2_xmit_frame()
861 memcpy(((u8 *)adapter->txd_ring) + offset, skb->data, skb->len); in atl2_xmit_frame()
862 offset += ((u32)(skb->len + 3) & ~3); in atl2_xmit_frame()
864 memcpy(((u8 *)adapter->txd_ring)+offset, skb->data, copy_len); in atl2_xmit_frame()
865 memcpy((u8 *)adapter->txd_ring, skb->data+copy_len, in atl2_xmit_frame()
866 skb->len-copy_len); in atl2_xmit_frame()
867 offset = ((u32)(skb->len-copy_len + 3) & ~3); in atl2_xmit_frame()
875 txph->ins_vlan = 1; in atl2_xmit_frame()
876 txph->vlan = vlan_tag; in atl2_xmit_frame()
879 if (offset >= adapter->txd_ring_size) in atl2_xmit_frame()
880 offset -= adapter->txd_ring_size; in atl2_xmit_frame()
881 adapter->txd_write_ptr = offset; in atl2_xmit_frame()
884 adapter->txs_ring[adapter->txs_next_clear].update = 0; in atl2_xmit_frame()
885 if (++adapter->txs_next_clear == adapter->txs_ring_size) in atl2_xmit_frame()
886 adapter->txs_next_clear = 0; in atl2_xmit_frame()
888 ATL2_WRITE_REGW(&adapter->hw, REG_MB_TXD_WR_IDX, in atl2_xmit_frame()
889 (adapter->txd_write_ptr >> 2)); in atl2_xmit_frame()
896 * atl2_change_mtu - Change the Maximum Transfer Unit
905 struct atl2_hw *hw = &adapter->hw; in atl2_change_mtu()
908 WRITE_ONCE(netdev->mtu, new_mtu); in atl2_change_mtu()
909 hw->max_frame_size = new_mtu; in atl2_change_mtu()
917 * atl2_set_mac - Change the Ethernet Address of the NIC
928 if (!is_valid_ether_addr(addr->sa_data)) in atl2_set_mac()
929 return -EADDRNOTAVAIL; in atl2_set_mac()
932 return -EBUSY; in atl2_set_mac()
934 eth_hw_addr_set(netdev, addr->sa_data); in atl2_set_mac()
935 memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len); in atl2_set_mac()
937 atl2_set_mac_addr(&adapter->hw); in atl2_set_mac()
950 data->phy_id = 0; in atl2_mii_ioctl()
953 spin_lock_irqsave(&adapter->stats_lock, flags); in atl2_mii_ioctl()
954 if (atl2_read_phy_reg(&adapter->hw, in atl2_mii_ioctl()
955 data->reg_num & 0x1F, &data->val_out)) { in atl2_mii_ioctl()
956 spin_unlock_irqrestore(&adapter->stats_lock, flags); in atl2_mii_ioctl()
957 return -EIO; in atl2_mii_ioctl()
959 spin_unlock_irqrestore(&adapter->stats_lock, flags); in atl2_mii_ioctl()
962 if (data->reg_num & ~(0x1F)) in atl2_mii_ioctl()
963 return -EFAULT; in atl2_mii_ioctl()
964 spin_lock_irqsave(&adapter->stats_lock, flags); in atl2_mii_ioctl()
965 if (atl2_write_phy_reg(&adapter->hw, data->reg_num, in atl2_mii_ioctl()
966 data->val_in)) { in atl2_mii_ioctl()
967 spin_unlock_irqrestore(&adapter->stats_lock, flags); in atl2_mii_ioctl()
968 return -EIO; in atl2_mii_ioctl()
970 spin_unlock_irqrestore(&adapter->stats_lock, flags); in atl2_mii_ioctl()
973 return -EOPNOTSUPP; in atl2_mii_ioctl()
990 return -EOPNOTSUPP; in atl2_ioctl()
995 * atl2_tx_timeout - Respond to a Tx Hang
1004 schedule_work(&adapter->reset_task); in atl2_tx_timeout()
1008 * atl2_watchdog - Timer Call-back
1015 if (!test_bit(__ATL2_DOWN, &adapter->flags)) { in atl2_watchdog()
1019 spin_lock_irqsave(&adapter->stats_lock, flags); in atl2_watchdog()
1020 drop_rxd = ATL2_READ_REG(&adapter->hw, REG_STS_RXD_OV); in atl2_watchdog()
1021 drop_rxs = ATL2_READ_REG(&adapter->hw, REG_STS_RXS_OV); in atl2_watchdog()
1022 spin_unlock_irqrestore(&adapter->stats_lock, flags); in atl2_watchdog()
1024 adapter->netdev->stats.rx_over_errors += drop_rxd + drop_rxs; in atl2_watchdog()
1027 mod_timer(&adapter->watchdog_timer, in atl2_watchdog()
1033 * atl2_phy_config - Timer Call-back
1040 struct atl2_hw *hw = &adapter->hw; in atl2_phy_config()
1043 spin_lock_irqsave(&adapter->stats_lock, flags); in atl2_phy_config()
1044 atl2_write_phy_reg(hw, MII_ADVERTISE, hw->mii_autoneg_adv_reg); in atl2_phy_config()
1047 spin_unlock_irqrestore(&adapter->stats_lock, flags); in atl2_phy_config()
1048 clear_bit(0, &adapter->cfg_phy); in atl2_phy_config()
1053 struct net_device *netdev = adapter->netdev; in atl2_up()
1059 err = atl2_init_hw(&adapter->hw); in atl2_up()
1061 err = -EIO; in atl2_up()
1071 err = -EIO; in atl2_up()
1075 clear_bit(__ATL2_DOWN, &adapter->flags); in atl2_up()
1077 val = ATL2_READ_REG(&adapter->hw, REG_MASTER_CTRL); in atl2_up()
1078 ATL2_WRITE_REG(&adapter->hw, REG_MASTER_CTRL, val | in atl2_up()
1089 while (test_and_set_bit(__ATL2_RESETTING, &adapter->flags)) in atl2_reinit_locked()
1093 clear_bit(__ATL2_RESETTING, &adapter->flags); in atl2_reinit_locked()
1107 struct atl2_hw *hw = &adapter->hw; in atl2_setup_mac_ctrl()
1108 struct net_device *netdev = adapter->netdev; in atl2_setup_mac_ctrl()
1114 if (FULL_DUPLEX == adapter->link_duplex) in atl2_setup_mac_ctrl()
1124 value |= (((u32)adapter->hw.preamble_len & MAC_CTRL_PRMLEN_MASK) << in atl2_setup_mac_ctrl()
1128 __atl2_vlan_mode(netdev->features, &value); in atl2_setup_mac_ctrl()
1132 if (netdev->flags & IFF_PROMISC) in atl2_setup_mac_ctrl()
1134 else if (netdev->flags & IFF_ALLMULTI) in atl2_setup_mac_ctrl()
1138 value |= (((u32)(adapter->hw.retry_buf & in atl2_setup_mac_ctrl()
1146 struct atl2_hw *hw = &adapter->hw; in atl2_check_link()
1147 struct net_device *netdev = adapter->netdev; in atl2_check_link()
1162 adapter->link_speed = SPEED_0; in atl2_check_link()
1173 switch (hw->MediaType) { in atl2_check_link()
1193 if (adapter->link_speed != speed || in atl2_check_link()
1194 adapter->link_duplex != duplex) { in atl2_check_link()
1195 adapter->link_speed = speed; in atl2_check_link()
1196 adapter->link_duplex = duplex; in atl2_check_link()
1199 atl2_driver_name, netdev->name, in atl2_check_link()
1200 adapter->link_speed, in atl2_check_link()
1201 adapter->link_duplex == FULL_DUPLEX ? in atl2_check_link()
1205 if (!netif_carrier_ok(netdev)) { /* Link down -> Up */ in atl2_check_link()
1220 adapter->link_speed = SPEED_0; in atl2_check_link()
1225 /* auto-neg, insert timer to re-config phy in atl2_check_link()
1227 if (!test_bit(__ATL2_DOWN, &adapter->flags)) { in atl2_check_link()
1228 if (!test_and_set_bit(0, &adapter->cfg_phy)) in atl2_check_link()
1229 mod_timer(&adapter->phy_config_timer, in atl2_check_link()
1237 * atl2_link_chg_task - deal with link change event Out of interrupt context
1247 spin_lock_irqsave(&adapter->stats_lock, flags); in atl2_link_chg_task()
1249 spin_unlock_irqrestore(&adapter->stats_lock, flags); in atl2_link_chg_task()
1269 * some motherboards BIOS(PXE/EFI) driver may set PME in atl2_setup_pcicmd()
1279 disable_irq(netdev->irq); in atl2_poll_controller()
1280 atl2_intr(netdev->irq, netdev); in atl2_poll_controller()
1281 enable_irq(netdev->irq); in atl2_poll_controller()
1304 * atl2_probe - Device Initialization Routine
1328 * atl2 is a shared-high-32-bit device, so we're stuck with 32-bit DMA in atl2_probe()
1329 * until the kernel has the proper infrastructure to support 64-bit DMA in atl2_probe()
1332 if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) && in atl2_probe()
1333 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) { in atl2_probe()
1335 err = -EIO; in atl2_probe()
1345 /* Enables bus-mastering on the device and calls in atl2_probe()
1351 err = -ENOMEM; in atl2_probe()
1355 SET_NETDEV_DEV(netdev, &pdev->dev); in atl2_probe()
1359 adapter->netdev = netdev; in atl2_probe()
1360 adapter->pdev = pdev; in atl2_probe()
1361 adapter->hw.back = adapter; in atl2_probe()
1366 adapter->hw.mem_rang = (u32)mmio_len; in atl2_probe()
1367 adapter->hw.hw_addr = ioremap(mmio_start, mmio_len); in atl2_probe()
1368 if (!adapter->hw.hw_addr) { in atl2_probe()
1369 err = -EIO; in atl2_probe()
1375 netdev->netdev_ops = &atl2_netdev_ops; in atl2_probe()
1376 netdev->ethtool_ops = &atl2_ethtool_ops; in atl2_probe()
1377 netdev->watchdog_timeo = 5 * HZ; in atl2_probe()
1378 netdev->min_mtu = 40; in atl2_probe()
1379 netdev->max_mtu = ETH_DATA_LEN + VLAN_HLEN; in atl2_probe()
1380 strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name)); in atl2_probe()
1382 netdev->mem_start = mmio_start; in atl2_probe()
1383 netdev->mem_end = mmio_start + mmio_len; in atl2_probe()
1384 adapter->bd_number = cards_found; in atl2_probe()
1385 adapter->pci_using_64 = false; in atl2_probe()
1392 netdev->hw_features = NETIF_F_HW_VLAN_CTAG_RX; in atl2_probe()
1393 netdev->features |= (NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX); in atl2_probe()
1396 atl2_phy_init(&adapter->hw); in atl2_probe()
1401 if (atl2_reset_hw(&adapter->hw)) { in atl2_probe()
1402 err = -EIO; in atl2_probe()
1407 atl2_read_mac_addr(&adapter->hw); in atl2_probe()
1408 eth_hw_addr_set(netdev, adapter->hw.mac_addr); in atl2_probe()
1409 if (!is_valid_ether_addr(netdev->dev_addr)) { in atl2_probe()
1410 err = -EIO; in atl2_probe()
1416 timer_setup(&adapter->watchdog_timer, atl2_watchdog, 0); in atl2_probe()
1418 timer_setup(&adapter->phy_config_timer, atl2_phy_config, 0); in atl2_probe()
1420 INIT_WORK(&adapter->reset_task, atl2_reset_task); in atl2_probe()
1421 INIT_WORK(&adapter->link_chg_task, atl2_link_chg_task); in atl2_probe()
1423 strcpy(netdev->name, "eth%d"); /* ?? */ in atl2_probe()
1440 iounmap(adapter->hw.hw_addr); in atl2_probe()
1452 * atl2_remove - Device Removal Routine
1457 * Hot-Plug event, or because the driver is going to be removed from
1461 * BIOS-set value, as in atl1 -- CHS */
1469 set_bit(__ATL2_DOWN, &adapter->flags); in atl2_remove()
1471 del_timer_sync(&adapter->watchdog_timer); in atl2_remove()
1472 del_timer_sync(&adapter->phy_config_timer); in atl2_remove()
1473 cancel_work_sync(&adapter->reset_task); in atl2_remove()
1474 cancel_work_sync(&adapter->link_chg_task); in atl2_remove()
1478 atl2_force_ps(&adapter->hw); in atl2_remove()
1480 iounmap(adapter->hw.hw_addr); in atl2_remove()
1492 struct atl2_hw *hw = &adapter->hw; in atl2_suspend()
1495 u32 wufc = adapter->wol; in atl2_suspend()
1504 WARN_ON(test_bit(__ATL2_RESETTING, &adapter->flags)); in atl2_suspend()
1541 if (FULL_DUPLEX == adapter->link_duplex) in atl2_suspend()
1544 ctrl |= (((u32)adapter->hw.preamble_len & in atl2_suspend()
1546 ctrl |= (((u32)(adapter->hw.retry_buf & in atl2_suspend()
1582 hw->phy_configured = false; /* re-init PHY when resume */ in atl2_suspend()
1602 hw->phy_configured = false; /* re-init PHY when resume */ in atl2_suspend()
1636 ATL2_READ_REG(&adapter->hw, REG_WOL_CTRL); /* clear WOL status */ in atl2_resume()
1641 ATL2_WRITE_REG(&adapter->hw, REG_WOL_CTRL, 0); in atl2_resume()
1649 atl2_reset_hw(&adapter->hw); in atl2_resume()
1682 struct atl2_adapter *adapter = hw->back; in atl2_read_pci_cfg()
1683 pci_read_config_word(adapter->pdev, reg, value); in atl2_read_pci_cfg()
1688 struct atl2_adapter *adapter = hw->back; in atl2_write_pci_cfg()
1689 pci_write_config_word(adapter->pdev, reg, *value); in atl2_write_pci_cfg()
1696 struct atl2_hw *hw = &adapter->hw; in atl2_get_link_ksettings()
1708 advertising |= hw->autoneg_advertised; in atl2_get_link_ksettings()
1710 cmd->base.port = PORT_TP; in atl2_get_link_ksettings()
1711 cmd->base.phy_address = 0; in atl2_get_link_ksettings()
1713 if (adapter->link_speed != SPEED_0) { in atl2_get_link_ksettings()
1714 cmd->base.speed = adapter->link_speed; in atl2_get_link_ksettings()
1715 if (adapter->link_duplex == FULL_DUPLEX) in atl2_get_link_ksettings()
1716 cmd->base.duplex = DUPLEX_FULL; in atl2_get_link_ksettings()
1718 cmd->base.duplex = DUPLEX_HALF; in atl2_get_link_ksettings()
1720 cmd->base.speed = SPEED_UNKNOWN; in atl2_get_link_ksettings()
1721 cmd->base.duplex = DUPLEX_UNKNOWN; in atl2_get_link_ksettings()
1724 cmd->base.autoneg = AUTONEG_ENABLE; in atl2_get_link_ksettings()
1726 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, in atl2_get_link_ksettings()
1728 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, in atl2_get_link_ksettings()
1738 struct atl2_hw *hw = &adapter->hw; in atl2_set_link_ksettings()
1742 cmd->link_modes.advertising); in atl2_set_link_ksettings()
1744 while (test_and_set_bit(__ATL2_RESETTING, &adapter->flags)) in atl2_set_link_ksettings()
1747 if (cmd->base.autoneg == AUTONEG_ENABLE) { in atl2_set_link_ksettings()
1754 hw->MediaType = MEDIA_TYPE_AUTO_SENSOR; in atl2_set_link_ksettings()
1755 hw->autoneg_advertised = MY_ADV_MASK; in atl2_set_link_ksettings()
1757 hw->MediaType = MEDIA_TYPE_100M_FULL; in atl2_set_link_ksettings()
1758 hw->autoneg_advertised = ADVERTISE_100_FULL; in atl2_set_link_ksettings()
1760 hw->MediaType = MEDIA_TYPE_100M_HALF; in atl2_set_link_ksettings()
1761 hw->autoneg_advertised = ADVERTISE_100_HALF; in atl2_set_link_ksettings()
1763 hw->MediaType = MEDIA_TYPE_10M_FULL; in atl2_set_link_ksettings()
1764 hw->autoneg_advertised = ADVERTISE_10_FULL; in atl2_set_link_ksettings()
1766 hw->MediaType = MEDIA_TYPE_10M_HALF; in atl2_set_link_ksettings()
1767 hw->autoneg_advertised = ADVERTISE_10_HALF; in atl2_set_link_ksettings()
1769 clear_bit(__ATL2_RESETTING, &adapter->flags); in atl2_set_link_ksettings()
1770 return -EINVAL; in atl2_set_link_ksettings()
1772 advertising = hw->autoneg_advertised | in atl2_set_link_ksettings()
1775 clear_bit(__ATL2_RESETTING, &adapter->flags); in atl2_set_link_ksettings()
1776 return -EINVAL; in atl2_set_link_ksettings()
1780 if (netif_running(adapter->netdev)) { in atl2_set_link_ksettings()
1784 atl2_reset_hw(&adapter->hw); in atl2_set_link_ksettings()
1786 clear_bit(__ATL2_RESETTING, &adapter->flags); in atl2_set_link_ksettings()
1812 struct atl2_hw *hw = &adapter->hw; in atl2_get_regs()
1818 regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id; in atl2_get_regs()
1870 if (!atl2_check_eeprom_exist(&adapter->hw)) in atl2_get_eeprom_len()
1880 struct atl2_hw *hw = &adapter->hw; in atl2_get_eeprom()
1886 if (eeprom->len == 0) in atl2_get_eeprom()
1887 return -EINVAL; in atl2_get_eeprom()
1890 return -EINVAL; in atl2_get_eeprom()
1892 eeprom->magic = hw->vendor_id | (hw->device_id << 16); in atl2_get_eeprom()
1894 first_dword = eeprom->offset >> 2; in atl2_get_eeprom()
1895 last_dword = (eeprom->offset + eeprom->len - 1) >> 2; in atl2_get_eeprom()
1897 eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32), in atl2_get_eeprom()
1900 return -ENOMEM; in atl2_get_eeprom()
1903 if (!atl2_read_eeprom(hw, i*4, &(eeprom_buff[i-first_dword]))) { in atl2_get_eeprom()
1904 ret_val = -EIO; in atl2_get_eeprom()
1909 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 3), in atl2_get_eeprom()
1910 eeprom->len); in atl2_get_eeprom()
1921 struct atl2_hw *hw = &adapter->hw; in atl2_set_eeprom()
1927 if (eeprom->len == 0) in atl2_set_eeprom()
1928 return -EOPNOTSUPP; in atl2_set_eeprom()
1930 if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16))) in atl2_set_eeprom()
1931 return -EFAULT; in atl2_set_eeprom()
1935 first_dword = eeprom->offset >> 2; in atl2_set_eeprom()
1936 last_dword = (eeprom->offset + eeprom->len - 1) >> 2; in atl2_set_eeprom()
1939 return -ENOMEM; in atl2_set_eeprom()
1943 if (eeprom->offset & 3) { in atl2_set_eeprom()
1947 ret_val = -EIO; in atl2_set_eeprom()
1952 if (((eeprom->offset + eeprom->len) & 3)) { in atl2_set_eeprom()
1958 &(eeprom_buff[last_dword - first_dword]))) { in atl2_set_eeprom()
1959 ret_val = -EIO; in atl2_set_eeprom()
1964 /* Device's eeprom is always little-endian, word addressable */ in atl2_set_eeprom()
1965 memcpy(ptr, bytes, eeprom->len); in atl2_set_eeprom()
1967 for (i = 0; i < last_dword - first_dword + 1; i++) { in atl2_set_eeprom()
1969 ret_val = -EIO; in atl2_set_eeprom()
1983 strscpy(drvinfo->driver, atl2_driver_name, sizeof(drvinfo->driver)); in atl2_get_drvinfo()
1984 strscpy(drvinfo->fw_version, "L2", sizeof(drvinfo->fw_version)); in atl2_get_drvinfo()
1985 strscpy(drvinfo->bus_info, pci_name(adapter->pdev), in atl2_get_drvinfo()
1986 sizeof(drvinfo->bus_info)); in atl2_get_drvinfo()
1994 wol->supported = WAKE_MAGIC; in atl2_get_wol()
1995 wol->wolopts = 0; in atl2_get_wol()
1997 if (adapter->wol & ATLX_WUFC_EX) in atl2_get_wol()
1998 wol->wolopts |= WAKE_UCAST; in atl2_get_wol()
1999 if (adapter->wol & ATLX_WUFC_MC) in atl2_get_wol()
2000 wol->wolopts |= WAKE_MCAST; in atl2_get_wol()
2001 if (adapter->wol & ATLX_WUFC_BC) in atl2_get_wol()
2002 wol->wolopts |= WAKE_BCAST; in atl2_get_wol()
2003 if (adapter->wol & ATLX_WUFC_MAG) in atl2_get_wol()
2004 wol->wolopts |= WAKE_MAGIC; in atl2_get_wol()
2005 if (adapter->wol & ATLX_WUFC_LNKC) in atl2_get_wol()
2006 wol->wolopts |= WAKE_PHY; in atl2_get_wol()
2013 if (wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE)) in atl2_set_wol()
2014 return -EOPNOTSUPP; in atl2_set_wol()
2016 if (wol->wolopts & (WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)) in atl2_set_wol()
2017 return -EOPNOTSUPP; in atl2_set_wol()
2020 adapter->wol = 0; in atl2_set_wol()
2022 if (wol->wolopts & WAKE_MAGIC) in atl2_set_wol()
2023 adapter->wol |= ATLX_WUFC_MAG; in atl2_set_wol()
2024 if (wol->wolopts & WAKE_PHY) in atl2_set_wol()
2025 adapter->wol |= ATLX_WUFC_LNKC; in atl2_set_wol()
2063 * hw - Struct containing variables accessed by shared code
2091 * the current PCI configuration. The global reset bit is self- in atl2_reset_hw()
2181 if (is_valid_ether_addr(hw->perm_mac_addr)) in get_permanent_address()
2219 memcpy(hw->perm_mac_addr, EthAddr, ETH_ALEN); in get_permanent_address()
2254 memcpy(hw->perm_mac_addr, EthAddr, ETH_ALEN); in get_permanent_address()
2257 /* maybe MAC-address is from BIOS */ in get_permanent_address()
2264 memcpy(hw->perm_mac_addr, EthAddr, ETH_ALEN); in get_permanent_address()
2274 * hw - Struct containing variables accessed by shared code
2281 hw->perm_mac_addr[0] = 0x00; in atl2_read_mac_addr()
2282 hw->perm_mac_addr[1] = 0x13; in atl2_read_mac_addr()
2283 hw->perm_mac_addr[2] = 0x74; in atl2_read_mac_addr()
2284 hw->perm_mac_addr[3] = 0x00; in atl2_read_mac_addr()
2285 hw->perm_mac_addr[4] = 0x5c; in atl2_read_mac_addr()
2286 hw->perm_mac_addr[5] = 0x38; in atl2_read_mac_addr()
2289 memcpy(hw->mac_addr, hw->perm_mac_addr, ETH_ALEN); in atl2_read_mac_addr()
2297 * hw - Struct containing variables accessed by shared code
2298 * mc_addr - the multicast address to hash
2316 value |= (((crc32 >> i) & 1) << (31 - i)); in atl2_hash_mc_addr()
2324 * hw - Struct containing variables accessed by shared code
2325 * hash_value - Multicast address hash value
2332 /* The HASH Table is a register array of 2 32-bit registers. in atl2_hash_set()
2351 * atl2_init_pcie - init PCIE module
2365 if (hw->flash_vendor >= ARRAY_SIZE(flash_table)) in atl2_init_flash_opcode()
2366 hw->flash_vendor = 0; /* ATMEL */ in atl2_init_flash_opcode()
2370 flash_table[hw->flash_vendor].cmdPROGRAM); in atl2_init_flash_opcode()
2372 flash_table[hw->flash_vendor].cmdSECTOR_ERASE); in atl2_init_flash_opcode()
2374 flash_table[hw->flash_vendor].cmdCHIP_ERASE); in atl2_init_flash_opcode()
2376 flash_table[hw->flash_vendor].cmdRDID); in atl2_init_flash_opcode()
2378 flash_table[hw->flash_vendor].cmdWREN); in atl2_init_flash_opcode()
2380 flash_table[hw->flash_vendor].cmdRDSR); in atl2_init_flash_opcode()
2382 flash_table[hw->flash_vendor].cmdWRSR); in atl2_init_flash_opcode()
2384 flash_table[hw->flash_vendor].cmdREAD); in atl2_init_flash_opcode()
2390 * hw - Struct containing variables accessed by shared code
2392 * post-reset uninitialized state. Initializes multicast table,
2417 * hw - Struct containing variables accessed by shared code
2418 * speed - Speed of the connection
2419 * duplex - Duplex setting of the connection
2456 * hw - Struct containing variables accessed by shared code
2457 * reg_addr - address of the PHY register to read
2490 * hw - Struct containing variables accessed by shared code
2491 * reg_addr - address of the PHY register to write
2492 * data - data to write to the PHY
2526 * hw - Struct containing variables accessed by shared code
2532 /* Read the MII Auto-Neg Advertisement Register (Address 4). */ in atl2_phy_setup_autoneg_adv()
2542 /* First we clear all the 10/100 mb speed bits in the Auto-Neg in atl2_phy_setup_autoneg_adv()
2544 * the 1000Base-T Control Register (Address 9). */ in atl2_phy_setup_autoneg_adv()
2549 switch (hw->MediaType) { in atl2_phy_setup_autoneg_adv()
2556 hw->autoneg_advertised = in atl2_phy_setup_autoneg_adv()
2564 hw->autoneg_advertised = ADVERTISE_100_FULL; in atl2_phy_setup_autoneg_adv()
2568 hw->autoneg_advertised = ADVERTISE_100_HALF; in atl2_phy_setup_autoneg_adv()
2572 hw->autoneg_advertised = ADVERTISE_10_FULL; in atl2_phy_setup_autoneg_adv()
2576 hw->autoneg_advertised = ADVERTISE_10_HALF; in atl2_phy_setup_autoneg_adv()
2583 hw->mii_autoneg_adv_reg = mii_autoneg_adv_reg; in atl2_phy_setup_autoneg_adv()
2591 * hw - Struct containing variables accessed by shared code
2626 if (hw->phy_configured) in atl2_phy_init()
2656 /* SW.Reset & En-Auto-Neg to restart Auto-Neg */ in atl2_phy_init()
2661 hw->phy_configured = true; in atl2_phy_init()
2669 /* 00-0B-6A-F6-00-DC in atl2_set_mac_addr()
2672 value = (((u32)hw->mac_addr[2]) << 24) | in atl2_set_mac_addr()
2673 (((u32)hw->mac_addr[3]) << 16) | in atl2_set_mac_addr()
2674 (((u32)hw->mac_addr[4]) << 8) | in atl2_set_mac_addr()
2675 (((u32)hw->mac_addr[5])); in atl2_set_mac_addr()
2678 value = (((u32)hw->mac_addr[0]) << 8) | in atl2_set_mac_addr()
2679 (((u32)hw->mac_addr[1])); in atl2_set_mac_addr()
2700 /* FIXME: This doesn't look right. -- CHS */
2751 #define OPTION_UNSET -1
2761 /* Module Parameters are always initialized to -1, so that the driver
2773 MODULE_PARM(X, "1-" __MODULE_STRING(ATL2_MAX_NIC) "i"); \
2785 * Valid Range: 64-2048
2795 * Valid Range: 16-512
2806 * Valid Range: 0-5
2807 * - 0 - auto-negotiate at all supported speeds
2808 * - 1 - only link at 1000Mbps Full Duplex
2809 * - 2 - only link at 100Mbps Full Duplex
2810 * - 3 - only link at 100Mbps Half Duplex
2811 * - 4 - only link at 10Mbps Full Duplex
2812 * - 5 - only link at 10Mbps Half Duplex
2819 * Valid Range: 10-65535
2829 * Valid Range: 0-2
2830 * 0 - Atmel
2831 * 1 - SST
2832 * 2 - ST
2867 *value = opt->def; in atl2_validate_option()
2871 switch (opt->type) { in atl2_validate_option()
2875 printk(KERN_INFO "%s Enabled\n", opt->name); in atl2_validate_option()
2878 printk(KERN_INFO "%s Disabled\n", opt->name); in atl2_validate_option()
2883 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { in atl2_validate_option()
2884 printk(KERN_INFO "%s set to %i\n", opt->name, *value); in atl2_validate_option()
2889 for (i = 0; i < opt->arg.l.nr; i++) { in atl2_validate_option()
2890 ent = &opt->arg.l.p[i]; in atl2_validate_option()
2891 if (*value == ent->i) { in atl2_validate_option()
2892 if (ent->str[0] != '\0') in atl2_validate_option()
2893 printk(KERN_INFO "%s\n", ent->str); in atl2_validate_option()
2903 opt->name, *value, opt->err); in atl2_validate_option()
2904 *value = opt->def; in atl2_validate_option()
2905 return -1; in atl2_validate_option()
2909 * atl2_check_options - Range Checking for Command Line Parameters
2921 int bd = adapter->bd_number; in atl2_check_options()
2943 adapter->txd_ring_size = ((u32) val) * 1024; in atl2_check_options()
2946 adapter->txd_ring_size = ((u32)opt.def) * 1024; in atl2_check_options()
2949 adapter->txs_ring_size = adapter->txd_ring_size / 128; in atl2_check_options()
2950 if (adapter->txs_ring_size > 160) in atl2_check_options()
2951 adapter->txs_ring_size = 160; in atl2_check_options()
2965 adapter->rxd_ring_size = (u32)val; in atl2_check_options()
2970 adapter->rxd_ring_size = (u32)opt.def; in atl2_check_options()
2973 adapter->hw.fc_rxd_hi = (adapter->rxd_ring_size / 8) * 7; in atl2_check_options()
2974 adapter->hw.fc_rxd_lo = (ATL2_MIN_RXD_COUNT / 8) > in atl2_check_options()
2975 (adapter->rxd_ring_size / 12) ? (ATL2_MIN_RXD_COUNT / 8) : in atl2_check_options()
2976 (adapter->rxd_ring_size / 12); in atl2_check_options()
2990 adapter->imt = (u16) val; in atl2_check_options()
2993 adapter->imt = (u16)(opt.def); in atl2_check_options()
3007 adapter->hw.flash_vendor = (u8) val; in atl2_check_options()
3010 adapter->hw.flash_vendor = (u8)(opt.def); in atl2_check_options()
3024 adapter->hw.MediaType = (u16) val; in atl2_check_options()
3027 adapter->hw.MediaType = (u16)(opt.def); in atl2_check_options()