Lines Matching refs:sky2

326 	struct sky2_port *sky2 = netdev_priv(hw->dev[port]);  in sky2_phy_init()  local
329 if ( (sky2->flags & SKY2_FLAG_AUTO_SPEED) && in sky2_phy_init()
371 if ( (sky2->flags & SKY2_FLAG_AUTO_SPEED) && in sky2_phy_init()
416 if (sky2->flags & SKY2_FLAG_AUTO_SPEED) { in sky2_phy_init()
418 if (sky2->advertising & ADVERTISED_1000baseT_Full) in sky2_phy_init()
420 if (sky2->advertising & ADVERTISED_1000baseT_Half) in sky2_phy_init()
422 if (sky2->advertising & ADVERTISED_100baseT_Full) in sky2_phy_init()
424 if (sky2->advertising & ADVERTISED_100baseT_Half) in sky2_phy_init()
426 if (sky2->advertising & ADVERTISED_10baseT_Full) in sky2_phy_init()
428 if (sky2->advertising & ADVERTISED_10baseT_Half) in sky2_phy_init()
432 if (sky2->advertising & ADVERTISED_1000baseT_Full) in sky2_phy_init()
434 if (sky2->advertising & ADVERTISED_1000baseT_Half) in sky2_phy_init()
447 switch (sky2->speed) { in sky2_phy_init()
458 if (sky2->duplex == DUPLEX_FULL) { in sky2_phy_init()
461 } else if (sky2->speed < SPEED_1000) in sky2_phy_init()
462 sky2->flow_mode = FC_NONE; in sky2_phy_init()
465 if (sky2->flags & SKY2_FLAG_AUTO_PAUSE) { in sky2_phy_init()
467 adv |= copper_fc_adv[sky2->flow_mode]; in sky2_phy_init()
469 adv |= fiber_fc_adv[sky2->flow_mode]; in sky2_phy_init()
472 reg |= gm_fc_disable[sky2->flow_mode]; in sky2_phy_init()
475 if (sky2->flow_mode & FC_RX) in sky2_phy_init()
616 if (!(sky2->flags & SKY2_FLAG_AUTO_SPEED) || in sky2_phy_init()
617 sky2->speed == SPEED_100) { in sky2_phy_init()
685 if (sky2->flags & SKY2_FLAG_AUTO_SPEED) in sky2_phy_init()
771 static void sky2_set_ipg(struct sky2_port *sky2) in sky2_set_ipg() argument
775 reg = gma_read16(sky2->hw, sky2->port, GM_SERIAL_MODE); in sky2_set_ipg()
777 if (sky2->speed > SPEED_100) in sky2_set_ipg()
781 gma_write16(sky2->hw, sky2->port, GM_SERIAL_MODE, reg); in sky2_set_ipg()
785 static void sky2_enable_rx_tx(struct sky2_port *sky2) in sky2_enable_rx_tx() argument
787 struct sky2_hw *hw = sky2->hw; in sky2_enable_rx_tx()
788 unsigned port = sky2->port; in sky2_enable_rx_tx()
797 static void sky2_phy_reinit(struct sky2_port *sky2) in sky2_phy_reinit() argument
799 spin_lock_bh(&sky2->phy_lock); in sky2_phy_reinit()
800 sky2_phy_init(sky2->hw, sky2->port); in sky2_phy_reinit()
801 sky2_enable_rx_tx(sky2); in sky2_phy_reinit()
802 spin_unlock_bh(&sky2->phy_lock); in sky2_phy_reinit()
806 static void sky2_wol_init(struct sky2_port *sky2) in sky2_wol_init() argument
808 struct sky2_hw *hw = sky2->hw; in sky2_wol_init()
809 unsigned port = sky2->port; in sky2_wol_init()
823 save_mode = sky2->flow_mode; in sky2_wol_init()
824 ctrl = sky2->advertising; in sky2_wol_init()
826 sky2->advertising &= ~(ADVERTISED_1000baseT_Half|ADVERTISED_1000baseT_Full); in sky2_wol_init()
827 sky2->flow_mode = FC_NONE; in sky2_wol_init()
829 spin_lock_bh(&sky2->phy_lock); in sky2_wol_init()
832 spin_unlock_bh(&sky2->phy_lock); in sky2_wol_init()
834 sky2->flow_mode = save_mode; in sky2_wol_init()
835 sky2->advertising = ctrl; in sky2_wol_init()
844 sky2->netdev->dev_addr, ETH_ALEN); in sky2_wol_init()
849 if (sky2->wol & WAKE_PHY) in sky2_wol_init()
854 if (sky2->wol & WAKE_MAGIC) in sky2_wol_init()
898 struct sky2_port *sky2 = netdev_priv(hw->dev[port]); in sky2_mac_init() local
928 spin_lock_bh(&sky2->phy_lock); in sky2_mac_init()
931 spin_unlock_bh(&sky2->phy_lock); in sky2_mac_init()
1099 static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2, u16 *slot) in get_tx_le() argument
1101 struct sky2_tx_le *le = sky2->tx_le + *slot; in get_tx_le()
1103 *slot = RING_NEXT(*slot, sky2->tx_ring_size); in get_tx_le()
1108 static void tx_init(struct sky2_port *sky2) in tx_init() argument
1112 sky2->tx_prod = sky2->tx_cons = 0; in tx_init()
1113 sky2->tx_tcpsum = 0; in tx_init()
1114 sky2->tx_last_mss = 0; in tx_init()
1115 netdev_reset_queue(sky2->netdev); in tx_init()
1117 le = get_tx_le(sky2, &sky2->tx_prod); in tx_init()
1120 sky2->tx_last_upper = 0; in tx_init()
1132 static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) in sky2_next_rx() argument
1134 struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put; in sky2_next_rx()
1135 sky2->rx_put = RING_NEXT(sky2->rx_put, RX_LE_SIZE); in sky2_next_rx()
1140 static unsigned sky2_get_rx_threshold(struct sky2_port *sky2) in sky2_get_rx_threshold() argument
1145 size = roundup(sky2->netdev->mtu + ETH_HLEN + VLAN_HLEN, 8); in sky2_get_rx_threshold()
1151 static unsigned sky2_get_rx_data_size(struct sky2_port *sky2) in sky2_get_rx_data_size() argument
1157 size = roundup(sky2->netdev->mtu + ETH_HLEN + VLAN_HLEN, 8); in sky2_get_rx_data_size()
1159 sky2->rx_nfrags = size >> PAGE_SHIFT; in sky2_get_rx_data_size()
1160 BUG_ON(sky2->rx_nfrags > ARRAY_SIZE(re->frag_addr)); in sky2_get_rx_data_size()
1163 size -= sky2->rx_nfrags << PAGE_SHIFT; in sky2_get_rx_data_size()
1175 static void sky2_rx_add(struct sky2_port *sky2, u8 op, in sky2_rx_add() argument
1181 le = sky2_next_rx(sky2); in sky2_rx_add()
1186 le = sky2_next_rx(sky2); in sky2_rx_add()
1193 static void sky2_rx_submit(struct sky2_port *sky2, in sky2_rx_submit() argument
1198 sky2_rx_add(sky2, OP_PACKET, re->data_addr, sky2->rx_data_size); in sky2_rx_submit()
1201 sky2_rx_add(sky2, OP_BUFFER, re->frag_addr[i], PAGE_SIZE); in sky2_rx_submit()
1265 static void rx_set_checksum(struct sky2_port *sky2) in rx_set_checksum() argument
1267 struct sky2_rx_le *le = sky2_next_rx(sky2); in rx_set_checksum()
1273 sky2_write32(sky2->hw, in rx_set_checksum()
1274 Q_ADDR(rxqaddr[sky2->port], Q_CSR), in rx_set_checksum()
1275 (sky2->netdev->features & NETIF_F_RXCSUM) in rx_set_checksum()
1282 struct sky2_port *sky2 = netdev_priv(dev); in rx_set_rss() local
1283 struct sky2_hw *hw = sky2->hw; in rx_set_rss()
1289 sky2_write32(hw, SK_REG(sky2->port, RSS_CFG), HASH_ALL); in rx_set_rss()
1298 sky2_write32(hw, SK_REG(sky2->port, RSS_KEY + i * 4), in rx_set_rss()
1302 sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T), in rx_set_rss()
1305 sky2_write32(hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR), in rx_set_rss()
1308 sky2_write32(hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR), in rx_set_rss()
1322 static void sky2_rx_stop(struct sky2_port *sky2) in sky2_rx_stop() argument
1324 struct sky2_hw *hw = sky2->hw; in sky2_rx_stop()
1325 unsigned rxq = rxqaddr[sky2->port]; in sky2_rx_stop()
1336 netdev_warn(sky2->netdev, "receiver stop failed\n"); in sky2_rx_stop()
1345 static void sky2_rx_clean(struct sky2_port *sky2) in sky2_rx_clean() argument
1349 if (sky2->rx_le) in sky2_rx_clean()
1350 memset(sky2->rx_le, 0, RX_LE_BYTES); in sky2_rx_clean()
1352 for (i = 0; i < sky2->rx_pending; i++) { in sky2_rx_clean()
1353 struct rx_ring_info *re = sky2->rx_ring + i; in sky2_rx_clean()
1356 sky2_rx_unmap_skb(sky2->hw->pdev, re); in sky2_rx_clean()
1367 struct sky2_port *sky2 = netdev_priv(dev); in sky2_ioctl() local
1368 struct sky2_hw *hw = sky2->hw; in sky2_ioctl()
1382 spin_lock_bh(&sky2->phy_lock); in sky2_ioctl()
1383 err = __gm_phy_read(hw, sky2->port, data->reg_num & 0x1f, &val); in sky2_ioctl()
1384 spin_unlock_bh(&sky2->phy_lock); in sky2_ioctl()
1391 spin_lock_bh(&sky2->phy_lock); in sky2_ioctl()
1392 err = gm_phy_write(hw, sky2->port, data->reg_num & 0x1f, in sky2_ioctl()
1394 spin_unlock_bh(&sky2->phy_lock); in sky2_ioctl()
1404 struct sky2_port *sky2 = netdev_priv(dev); in sky2_vlan_mode() local
1405 struct sky2_hw *hw = sky2->hw; in sky2_vlan_mode()
1406 u16 port = sky2->port; in sky2_vlan_mode()
1439 static struct sk_buff *sky2_rx_alloc(struct sky2_port *sky2, gfp_t gfp) in sky2_rx_alloc() argument
1444 skb = __netdev_alloc_skb(sky2->netdev, in sky2_rx_alloc()
1445 sky2->rx_data_size + sky2_rx_pad(sky2->hw), in sky2_rx_alloc()
1450 if (sky2->hw->flags & SKY2_HW_RAM_BUFFER) { in sky2_rx_alloc()
1463 for (i = 0; i < sky2->rx_nfrags; i++) { in sky2_rx_alloc()
1478 static inline void sky2_rx_update(struct sky2_port *sky2, unsigned rxq) in sky2_rx_update() argument
1480 sky2_put_idx(sky2->hw, rxq, sky2->rx_put); in sky2_rx_update()
1483 static int sky2_alloc_rx_skbs(struct sky2_port *sky2) in sky2_alloc_rx_skbs() argument
1485 struct sky2_hw *hw = sky2->hw; in sky2_alloc_rx_skbs()
1488 sky2->rx_data_size = sky2_get_rx_data_size(sky2); in sky2_alloc_rx_skbs()
1491 for (i = 0; i < sky2->rx_pending; i++) { in sky2_alloc_rx_skbs()
1492 struct rx_ring_info *re = sky2->rx_ring + i; in sky2_alloc_rx_skbs()
1494 re->skb = sky2_rx_alloc(sky2, GFP_KERNEL); in sky2_alloc_rx_skbs()
1498 if (sky2_rx_map_skb(hw->pdev, re, sky2->rx_data_size)) { in sky2_alloc_rx_skbs()
1516 static void sky2_rx_start(struct sky2_port *sky2) in sky2_rx_start() argument
1518 struct sky2_hw *hw = sky2->hw; in sky2_rx_start()
1520 unsigned rxq = rxqaddr[sky2->port]; in sky2_rx_start()
1523 sky2->rx_put = sky2->rx_next = 0; in sky2_rx_start()
1537 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1); in sky2_rx_start()
1540 rx_set_checksum(sky2); in sky2_rx_start()
1543 rx_set_rss(sky2->netdev, sky2->netdev->features); in sky2_rx_start()
1546 for (i = 0; i < sky2->rx_pending; i++) { in sky2_rx_start()
1547 re = sky2->rx_ring + i; in sky2_rx_start()
1548 sky2_rx_submit(sky2, re); in sky2_rx_start()
1557 thresh = sky2_get_rx_threshold(sky2); in sky2_rx_start()
1559 sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T), RX_TRUNC_OFF); in sky2_rx_start()
1561 sky2_write16(hw, SK_REG(sky2->port, RX_GMF_TR_THR), thresh); in sky2_rx_start()
1562 sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T), RX_TRUNC_ON); in sky2_rx_start()
1566 sky2_rx_update(sky2, rxq); in sky2_rx_start()
1577 sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T), RX_MACSEC_FLUSH_OFF); in sky2_rx_start()
1582 sky2_write16(hw, SK_REG(sky2->port, RX_GMF_FL_CTRL), in sky2_rx_start()
1586 sky2_write32(hw, Q_ADDR(txqaddr[sky2->port], Q_TEST), in sky2_rx_start()
1591 static int sky2_alloc_buffers(struct sky2_port *sky2) in sky2_alloc_buffers() argument
1593 struct sky2_hw *hw = sky2->hw; in sky2_alloc_buffers()
1596 sky2->tx_le = dma_alloc_coherent(&hw->pdev->dev, in sky2_alloc_buffers()
1597 sky2->tx_ring_size * sizeof(struct sky2_tx_le), in sky2_alloc_buffers()
1598 &sky2->tx_le_map, GFP_KERNEL); in sky2_alloc_buffers()
1599 if (!sky2->tx_le) in sky2_alloc_buffers()
1602 sky2->tx_ring = kcalloc(sky2->tx_ring_size, sizeof(struct tx_ring_info), in sky2_alloc_buffers()
1604 if (!sky2->tx_ring) in sky2_alloc_buffers()
1607 sky2->rx_le = dma_alloc_coherent(&hw->pdev->dev, RX_LE_BYTES, in sky2_alloc_buffers()
1608 &sky2->rx_le_map, GFP_KERNEL); in sky2_alloc_buffers()
1609 if (!sky2->rx_le) in sky2_alloc_buffers()
1612 sky2->rx_ring = kcalloc(sky2->rx_pending, sizeof(struct rx_ring_info), in sky2_alloc_buffers()
1614 if (!sky2->rx_ring) in sky2_alloc_buffers()
1617 return sky2_alloc_rx_skbs(sky2); in sky2_alloc_buffers()
1622 static void sky2_free_buffers(struct sky2_port *sky2) in sky2_free_buffers() argument
1624 struct sky2_hw *hw = sky2->hw; in sky2_free_buffers()
1626 sky2_rx_clean(sky2); in sky2_free_buffers()
1628 if (sky2->rx_le) { in sky2_free_buffers()
1629 dma_free_coherent(&hw->pdev->dev, RX_LE_BYTES, sky2->rx_le, in sky2_free_buffers()
1630 sky2->rx_le_map); in sky2_free_buffers()
1631 sky2->rx_le = NULL; in sky2_free_buffers()
1633 if (sky2->tx_le) { in sky2_free_buffers()
1635 sky2->tx_ring_size * sizeof(struct sky2_tx_le), in sky2_free_buffers()
1636 sky2->tx_le, sky2->tx_le_map); in sky2_free_buffers()
1637 sky2->tx_le = NULL; in sky2_free_buffers()
1639 kfree(sky2->tx_ring); in sky2_free_buffers()
1640 kfree(sky2->rx_ring); in sky2_free_buffers()
1642 sky2->tx_ring = NULL; in sky2_free_buffers()
1643 sky2->rx_ring = NULL; in sky2_free_buffers()
1646 static void sky2_hw_up(struct sky2_port *sky2) in sky2_hw_up() argument
1648 struct sky2_hw *hw = sky2->hw; in sky2_hw_up()
1649 unsigned port = sky2->port; in sky2_hw_up()
1652 struct net_device *otherdev = hw->dev[sky2->port^1]; in sky2_hw_up()
1654 tx_init(sky2); in sky2_hw_up()
1676 netdev_dbg(sky2->netdev, "ram buffer %dK\n", ramsize); in sky2_hw_up()
1701 sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map, in sky2_hw_up()
1702 sky2->tx_ring_size - 1); in sky2_hw_up()
1704 sky2_vlan_mode(sky2->netdev, sky2->netdev->features); in sky2_hw_up()
1705 netdev_update_features(sky2->netdev); in sky2_hw_up()
1707 sky2_rx_start(sky2); in sky2_hw_up()
1736 struct sky2_port *sky2 = netdev_priv(dev); in sky2_open() local
1737 struct sky2_hw *hw = sky2->hw; in sky2_open()
1738 unsigned port = sky2->port; in sky2_open()
1744 err = sky2_alloc_buffers(sky2); in sky2_open()
1752 sky2_hw_up(sky2); in sky2_open()
1766 netif_info(sky2, ifup, dev, "enabling interface\n"); in sky2_open()
1771 sky2_free_buffers(sky2); in sky2_open()
1776 static inline int tx_inuse(const struct sky2_port *sky2) in tx_inuse() argument
1778 return (sky2->tx_prod - sky2->tx_cons) & (sky2->tx_ring_size - 1); in tx_inuse()
1782 static inline int tx_avail(const struct sky2_port *sky2) in tx_avail() argument
1784 return sky2->tx_pending - tx_inuse(sky2); in tx_avail()
1826 struct sky2_port *sky2 = netdev_priv(dev); in sky2_xmit_frame() local
1827 struct sky2_hw *hw = sky2->hw; in sky2_xmit_frame()
1837 if (unlikely(tx_avail(sky2) < tx_le_req(skb))) in sky2_xmit_frame()
1847 slot = sky2->tx_prod; in sky2_xmit_frame()
1848 netif_printk(sky2, tx_queued, KERN_DEBUG, dev, in sky2_xmit_frame()
1853 if (upper != sky2->tx_last_upper) { in sky2_xmit_frame()
1854 le = get_tx_le(sky2, &slot); in sky2_xmit_frame()
1856 sky2->tx_last_upper = upper; in sky2_xmit_frame()
1867 if (mss != sky2->tx_last_mss) { in sky2_xmit_frame()
1868 le = get_tx_le(sky2, &slot); in sky2_xmit_frame()
1875 sky2->tx_last_mss = mss; in sky2_xmit_frame()
1884 le = get_tx_le(sky2, &slot); in sky2_xmit_frame()
1909 if (tcpsum != sky2->tx_tcpsum) { in sky2_xmit_frame()
1910 sky2->tx_tcpsum = tcpsum; in sky2_xmit_frame()
1912 le = get_tx_le(sky2, &slot); in sky2_xmit_frame()
1921 re = sky2->tx_ring + slot; in sky2_xmit_frame()
1926 le = get_tx_le(sky2, &slot); in sky2_xmit_frame()
1943 if (upper != sky2->tx_last_upper) { in sky2_xmit_frame()
1944 le = get_tx_le(sky2, &slot); in sky2_xmit_frame()
1946 sky2->tx_last_upper = upper; in sky2_xmit_frame()
1950 re = sky2->tx_ring + slot; in sky2_xmit_frame()
1955 le = get_tx_le(sky2, &slot); in sky2_xmit_frame()
1965 sky2->tx_prod = slot; in sky2_xmit_frame()
1967 if (tx_avail(sky2) <= MAX_SKB_TX_LE) in sky2_xmit_frame()
1971 sky2_put_idx(hw, txqaddr[sky2->port], sky2->tx_prod); in sky2_xmit_frame()
1976 for (i = sky2->tx_prod; i != slot; i = RING_NEXT(i, sky2->tx_ring_size)) { in sky2_xmit_frame()
1977 re = sky2->tx_ring + i; in sky2_xmit_frame()
1999 static void sky2_tx_complete(struct sky2_port *sky2, u16 done) in sky2_tx_complete() argument
2001 struct net_device *dev = sky2->netdev; in sky2_tx_complete()
2005 BUG_ON(done >= sky2->tx_ring_size); in sky2_tx_complete()
2007 for (idx = sky2->tx_cons; idx != done; in sky2_tx_complete()
2008 idx = RING_NEXT(idx, sky2->tx_ring_size)) { in sky2_tx_complete()
2009 struct tx_ring_info *re = sky2->tx_ring + idx; in sky2_tx_complete()
2012 sky2_tx_unmap(sky2->hw->pdev, re); in sky2_tx_complete()
2015 netif_printk(sky2, tx_done, KERN_DEBUG, dev, in sky2_tx_complete()
2024 sky2->tx_next = RING_NEXT(idx, sky2->tx_ring_size); in sky2_tx_complete()
2028 sky2->tx_cons = idx; in sky2_tx_complete()
2033 u64_stats_update_begin(&sky2->tx_stats.syncp); in sky2_tx_complete()
2034 sky2->tx_stats.packets += pkts_compl; in sky2_tx_complete()
2035 sky2->tx_stats.bytes += bytes_compl; in sky2_tx_complete()
2036 u64_stats_update_end(&sky2->tx_stats.syncp); in sky2_tx_complete()
2063 static void sky2_hw_down(struct sky2_port *sky2) in sky2_hw_down() argument
2065 struct sky2_hw *hw = sky2->hw; in sky2_hw_down()
2066 unsigned port = sky2->port; in sky2_hw_down()
2098 sky2_rx_stop(sky2); in sky2_hw_down()
2100 spin_lock_bh(&sky2->phy_lock); in sky2_hw_down()
2102 spin_unlock_bh(&sky2->phy_lock); in sky2_hw_down()
2107 sky2_tx_complete(sky2, sky2->tx_prod); in sky2_hw_down()
2113 struct sky2_port *sky2 = netdev_priv(dev); in sky2_close() local
2114 struct sky2_hw *hw = sky2->hw; in sky2_close()
2117 if (!sky2->tx_le) in sky2_close()
2120 netif_info(sky2, ifdown, dev, "disabling interface\n"); in sky2_close()
2134 imask &= ~portirq_msk[sky2->port]; in sky2_close()
2142 sky2_hw_down(sky2); in sky2_close()
2144 sky2_free_buffers(sky2); in sky2_close()
2171 static void sky2_link_up(struct sky2_port *sky2) in sky2_link_up() argument
2173 struct sky2_hw *hw = sky2->hw; in sky2_link_up()
2174 unsigned port = sky2->port; in sky2_link_up()
2182 sky2_set_ipg(sky2); in sky2_link_up()
2184 sky2_enable_rx_tx(sky2); in sky2_link_up()
2188 netif_carrier_on(sky2->netdev); in sky2_link_up()
2196 netif_info(sky2, link, sky2->netdev, in sky2_link_up()
2198 sky2->speed, in sky2_link_up()
2199 sky2->duplex == DUPLEX_FULL ? "full" : "half", in sky2_link_up()
2200 fc_name[sky2->flow_status]); in sky2_link_up()
2203 static void sky2_link_down(struct sky2_port *sky2) in sky2_link_down() argument
2205 struct sky2_hw *hw = sky2->hw; in sky2_link_down()
2206 unsigned port = sky2->port; in sky2_link_down()
2215 netif_carrier_off(sky2->netdev); in sky2_link_down()
2220 netif_info(sky2, link, sky2->netdev, "Link is down\n"); in sky2_link_down()
2233 static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux) in sky2_autoneg_done() argument
2235 struct sky2_hw *hw = sky2->hw; in sky2_autoneg_done()
2236 unsigned port = sky2->port; in sky2_autoneg_done()
2242 netdev_err(sky2->netdev, "remote fault\n"); in sky2_autoneg_done()
2247 netdev_err(sky2->netdev, "speed/duplex mismatch\n"); in sky2_autoneg_done()
2251 sky2->speed = sky2_phy_speed(hw, aux); in sky2_autoneg_done()
2252 sky2->duplex = (aux & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF; in sky2_autoneg_done()
2272 sky2->flow_status = FC_NONE; in sky2_autoneg_done()
2275 sky2->flow_status = FC_BOTH; in sky2_autoneg_done()
2277 sky2->flow_status = FC_RX; in sky2_autoneg_done()
2280 sky2->flow_status = FC_TX; in sky2_autoneg_done()
2283 if (sky2->duplex == DUPLEX_HALF && sky2->speed < SPEED_1000 && in sky2_autoneg_done()
2285 sky2->flow_status = FC_NONE; in sky2_autoneg_done()
2287 if (sky2->flow_status & FC_TX) in sky2_autoneg_done()
2299 struct sky2_port *sky2 = netdev_priv(dev); in sky2_phy_intr() local
2305 spin_lock(&sky2->phy_lock); in sky2_phy_intr()
2309 netif_info(sky2, intr, sky2->netdev, "phy interrupt status 0x%x 0x%x\n", in sky2_phy_intr()
2313 if (sky2_autoneg_done(sky2, phystat) == 0 && in sky2_phy_intr()
2315 sky2_link_up(sky2); in sky2_phy_intr()
2320 sky2->speed = sky2_phy_speed(hw, phystat); in sky2_phy_intr()
2323 sky2->duplex = in sky2_phy_intr()
2328 sky2_link_up(sky2); in sky2_phy_intr()
2330 sky2_link_down(sky2); in sky2_phy_intr()
2333 spin_unlock(&sky2->phy_lock); in sky2_phy_intr()
2339 struct sky2_port *sky2 = netdev_priv(hw->dev[0]); in sky2_qlink_intr() local
2354 sky2_link_up(sky2); in sky2_qlink_intr()
2362 struct sky2_port *sky2 = netdev_priv(dev); in sky2_tx_timeout() local
2363 struct sky2_hw *hw = sky2->hw; in sky2_tx_timeout()
2365 netif_err(sky2, timer, dev, "tx timeout\n"); in sky2_tx_timeout()
2368 sky2->tx_cons, sky2->tx_prod, in sky2_tx_timeout()
2369 sky2_read16(hw, sky2->port == 0 ? STAT_TXA1_RIDX : STAT_TXA2_RIDX), in sky2_tx_timeout()
2370 sky2_read16(hw, Q_ADDR(txqaddr[sky2->port], Q_DONE))); in sky2_tx_timeout()
2378 struct sky2_port *sky2 = netdev_priv(dev); in sky2_change_mtu() local
2379 struct sky2_hw *hw = sky2->hw; in sky2_change_mtu()
2380 unsigned port = sky2->port; in sky2_change_mtu()
2406 sky2_rx_stop(sky2); in sky2_change_mtu()
2407 sky2_rx_clean(sky2); in sky2_change_mtu()
2413 if (sky2->speed > SPEED_100) in sky2_change_mtu()
2425 err = sky2_alloc_rx_skbs(sky2); in sky2_change_mtu()
2427 sky2_rx_start(sky2); in sky2_change_mtu()
2429 sky2_rx_clean(sky2); in sky2_change_mtu()
2458 static struct sk_buff *receive_copy(struct sky2_port *sky2, in receive_copy() argument
2464 skb = netdev_alloc_skb_ip_align(sky2->netdev, length); in receive_copy()
2466 dma_sync_single_for_cpu(&sky2->hw->pdev->dev, re->data_addr, in receive_copy()
2474 dma_sync_single_for_device(&sky2->hw->pdev->dev, in receive_copy()
2519 static struct sk_buff *receive_new(struct sky2_port *sky2, in receive_new() argument
2525 unsigned hdr_space = sky2->rx_data_size; in receive_new()
2527 nre.skb = sky2_rx_alloc(sky2, GFP_ATOMIC); in receive_new()
2531 if (sky2_rx_map_skb(sky2->hw->pdev, &nre, hdr_space)) in receive_new()
2535 sky2_rx_unmap_skb(sky2->hw->pdev, re); in receive_new()
2558 struct sky2_port *sky2 = netdev_priv(dev); in sky2_receive() local
2559 struct rx_ring_info *re = sky2->rx_ring + sky2->rx_next; in sky2_receive()
2563 netif_printk(sky2, rx_status, KERN_DEBUG, dev, in sky2_receive()
2565 sky2->rx_next, status, length); in sky2_receive()
2567 sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending; in sky2_receive()
2568 prefetch(sky2->rx_ring + sky2->rx_next); in sky2_receive()
2577 if (sky2->hw->chip_id == CHIP_ID_YUKON_FE_P && in sky2_receive()
2578 sky2->hw->chip_rev == CHIP_REV_YU_FE2_A0 && in sky2_receive()
2594 skb = receive_copy(sky2, re, length); in sky2_receive()
2596 skb = receive_new(sky2, re, length); in sky2_receive()
2601 sky2_rx_submit(sky2, re); in sky2_receive()
2609 netif_info(sky2, rx_err, dev, in sky2_receive()
2618 struct sky2_port *sky2 = netdev_priv(dev); in sky2_tx_done() local
2621 sky2_tx_complete(sky2, last); in sky2_tx_done()
2624 if (tx_avail(sky2) > MAX_SKB_TX_LE + 4) in sky2_tx_done()
2629 static inline void sky2_skb_rx(const struct sky2_port *sky2, in sky2_skb_rx() argument
2635 napi_gro_receive(&sky2->hw->napi, skb); in sky2_skb_rx()
2642 struct sky2_port *sky2 = netdev_priv(dev); in sky2_rx_done() local
2647 u64_stats_update_begin(&sky2->rx_stats.syncp); in sky2_rx_done()
2648 sky2->rx_stats.packets += packets; in sky2_rx_done()
2649 sky2->rx_stats.bytes += bytes; in sky2_rx_done()
2650 u64_stats_update_end(&sky2->rx_stats.syncp); in sky2_rx_done()
2652 sky2->last_rx = jiffies; in sky2_rx_done()
2656 static void sky2_rx_checksum(struct sky2_port *sky2, u32 status) in sky2_rx_checksum() argument
2659 BUG_ON(sky2->hw->flags & SKY2_HW_NEW_LE); in sky2_rx_checksum()
2667 struct sk_buff *skb = sky2->rx_ring[sky2->rx_next].skb; in sky2_rx_checksum()
2671 dev_notice(&sky2->hw->pdev->dev, in sky2_rx_checksum()
2673 sky2->netdev->name, status); in sky2_rx_checksum()
2679 sky2->netdev->features &= ~NETIF_F_RXCSUM; in sky2_rx_checksum()
2680 sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR), in sky2_rx_checksum()
2685 static void sky2_rx_tag(struct sky2_port *sky2, u16 length) in sky2_rx_tag() argument
2689 skb = sky2->rx_ring[sky2->rx_next].skb; in sky2_rx_tag()
2693 static void sky2_rx_hash(struct sky2_port *sky2, u32 status) in sky2_rx_hash() argument
2697 skb = sky2->rx_ring[sky2->rx_next].skb; in sky2_rx_hash()
2713 struct sky2_port *sky2; in sky2_status_intr() local
2729 sky2 = netdev_priv(dev); in sky2_status_intr()
2754 sky2_skb_rx(sky2, skb); in sky2_status_intr()
2762 sky2_rx_tag(sky2, length); in sky2_status_intr()
2766 sky2_rx_tag(sky2, length); in sky2_status_intr()
2770 sky2_rx_checksum(sky2, status); in sky2_status_intr()
2774 sky2_rx_hash(sky2, status); in sky2_status_intr()
2892 struct sky2_port *sky2 = netdev_priv(dev); in sky2_mac_intr() local
2895 netif_info(sky2, intr, dev, "mac interrupt status 0x%x\n", status); in sky2_mac_intr()
2929 struct sky2_port *sky2 = netdev_priv(dev); in sky2_rx_hung() local
2930 struct sky2_hw *hw = sky2->hw; in sky2_rx_hung()
2931 unsigned port = sky2->port; in sky2_rx_hung()
2939 if (sky2->check.last == sky2->last_rx && in sky2_rx_hung()
2940 ((mac_rp == sky2->check.mac_rp && in sky2_rx_hung()
2941 mac_lev != 0 && mac_lev >= sky2->check.mac_lev) || in sky2_rx_hung()
2943 (fifo_rp == sky2->check.fifo_rp && in sky2_rx_hung()
2944 fifo_lev != 0 && fifo_lev >= sky2->check.fifo_lev))) { in sky2_rx_hung()
2951 sky2->check.last = sky2->last_rx; in sky2_rx_hung()
2952 sky2->check.mac_rp = mac_rp; in sky2_rx_hung()
2953 sky2->check.mac_lev = mac_lev; in sky2_rx_hung()
2954 sky2->check.fifo_rp = fifo_rp; in sky2_rx_hung()
2955 sky2->check.fifo_lev = fifo_lev; in sky2_rx_hung()
3075 struct sky2_port *sky2 = netdev_priv(dev); in sky2_netpoll() local
3077 napi_schedule(&sky2->hw->napi); in sky2_netpoll()
3470 struct sky2_port *sky2 = netdev_priv(dev); in sky2_all_down() local
3477 sky2_hw_down(sky2); in sky2_all_down()
3488 struct sky2_port *sky2 = netdev_priv(dev); in sky2_all_up() local
3493 sky2_hw_up(sky2); in sky2_all_up()
3527 const struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_wol() local
3529 wol->supported = sky2_wol_supported(sky2->hw); in sky2_get_wol()
3530 wol->wolopts = sky2->wol; in sky2_get_wol()
3535 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_wol() local
3536 struct sky2_hw *hw = sky2->hw; in sky2_set_wol()
3540 if ((wol->wolopts & ~sky2_wol_supported(sky2->hw)) || in sky2_set_wol()
3544 sky2->wol = wol->wolopts; in sky2_set_wol()
3548 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_wol() local
3550 if (sky2->wol) in sky2_set_wol()
3578 struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_link_ksettings() local
3579 struct sky2_hw *hw = sky2->hw; in sky2_get_link_ksettings()
3586 cmd->base.speed = sky2->speed; in sky2_get_link_ksettings()
3594 advertising = sky2->advertising; in sky2_get_link_ksettings()
3595 cmd->base.autoneg = (sky2->flags & SKY2_FLAG_AUTO_SPEED) in sky2_get_link_ksettings()
3597 cmd->base.duplex = sky2->duplex; in sky2_get_link_ksettings()
3610 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_link_ksettings() local
3611 const struct sky2_hw *hw = sky2->hw; in sky2_set_link_ksettings()
3623 sky2->advertising = new_advertising | in sky2_set_link_ksettings()
3627 sky2->advertising = new_advertising | in sky2_set_link_ksettings()
3631 sky2->flags |= SKY2_FLAG_AUTO_SPEED; in sky2_set_link_ksettings()
3632 sky2->duplex = -1; in sky2_set_link_ksettings()
3633 sky2->speed = -1; in sky2_set_link_ksettings()
3671 sky2->speed = speed; in sky2_set_link_ksettings()
3672 sky2->duplex = cmd->base.duplex; in sky2_set_link_ksettings()
3673 sky2->flags &= ~SKY2_FLAG_AUTO_SPEED; in sky2_set_link_ksettings()
3677 sky2_phy_reinit(sky2); in sky2_set_link_ksettings()
3687 struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_drvinfo() local
3691 strscpy(info->bus_info, pci_name(sky2->hw->pdev), in sky2_get_drvinfo()
3741 struct sky2_port *sky2 = netdev_priv(netdev); in sky2_get_msglevel() local
3742 return sky2->msg_enable; in sky2_get_msglevel()
3747 struct sky2_port *sky2 = netdev_priv(dev); in sky2_nway_reset() local
3749 if (!netif_running(dev) || !(sky2->flags & SKY2_FLAG_AUTO_SPEED)) in sky2_nway_reset()
3752 sky2_phy_reinit(sky2); in sky2_nway_reset()
3758 static void sky2_phy_stats(struct sky2_port *sky2, u64 * data, unsigned count) in sky2_phy_stats() argument
3760 struct sky2_hw *hw = sky2->hw; in sky2_phy_stats()
3761 unsigned port = sky2->port; in sky2_phy_stats()
3773 struct sky2_port *sky2 = netdev_priv(netdev); in sky2_set_msglevel() local
3774 sky2->msg_enable = value; in sky2_set_msglevel()
3790 struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_ethtool_stats() local
3792 sky2_phy_stats(sky2, data, ARRAY_SIZE(sky2_stats)); in sky2_get_ethtool_stats()
3810 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_mac_address() local
3811 struct sky2_hw *hw = sky2->hw; in sky2_set_mac_address()
3812 unsigned port = sky2->port; in sky2_set_mac_address()
3843 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_multicast() local
3844 struct sky2_hw *hw = sky2->hw; in sky2_set_multicast()
3845 unsigned port = sky2->port; in sky2_set_multicast()
3852 rx_pause = (sky2->flow_status == FC_RX || sky2->flow_status == FC_BOTH); in sky2_set_multicast()
3889 struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_stats() local
3890 struct sky2_hw *hw = sky2->hw; in sky2_get_stats()
3891 unsigned port = sky2->port; in sky2_get_stats()
3896 start = u64_stats_fetch_begin(&sky2->rx_stats.syncp); in sky2_get_stats()
3897 _bytes = sky2->rx_stats.bytes; in sky2_get_stats()
3898 _packets = sky2->rx_stats.packets; in sky2_get_stats()
3899 } while (u64_stats_fetch_retry(&sky2->rx_stats.syncp, start)); in sky2_get_stats()
3905 start = u64_stats_fetch_begin(&sky2->tx_stats.syncp); in sky2_get_stats()
3906 _bytes = sky2->tx_stats.bytes; in sky2_get_stats()
3907 _packets = sky2->tx_stats.packets; in sky2_get_stats()
3908 } while (u64_stats_fetch_retry(&sky2->tx_stats.syncp, start)); in sky2_get_stats()
3932 static void sky2_led(struct sky2_port *sky2, enum led_mode mode) in sky2_led() argument
3934 struct sky2_hw *hw = sky2->hw; in sky2_led()
3935 unsigned port = sky2->port; in sky2_led()
3937 spin_lock_bh(&sky2->phy_lock); in sky2_led()
3985 spin_unlock_bh(&sky2->phy_lock); in sky2_led()
3992 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_phys_id() local
3998 sky2_led(sky2, MO_LED_NORM); in sky2_set_phys_id()
4001 sky2_led(sky2, MO_LED_ON); in sky2_set_phys_id()
4004 sky2_led(sky2, MO_LED_OFF); in sky2_set_phys_id()
4014 struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_pauseparam() local
4016 switch (sky2->flow_mode) { in sky2_get_pauseparam()
4030 ecmd->autoneg = (sky2->flags & SKY2_FLAG_AUTO_PAUSE) in sky2_get_pauseparam()
4037 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_pauseparam() local
4040 sky2->flags |= SKY2_FLAG_AUTO_PAUSE; in sky2_set_pauseparam()
4042 sky2->flags &= ~SKY2_FLAG_AUTO_PAUSE; in sky2_set_pauseparam()
4044 sky2->flow_mode = sky2_flow(ecmd->rx_pause, ecmd->tx_pause); in sky2_set_pauseparam()
4047 sky2_phy_reinit(sky2); in sky2_set_pauseparam()
4057 struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_coalesce() local
4058 struct sky2_hw *hw = sky2->hw; in sky2_get_coalesce()
4094 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_coalesce() local
4095 struct sky2_hw *hw = sky2->hw; in sky2_set_coalesce()
4103 if (ecmd->tx_max_coalesced_frames >= sky2->tx_ring_size-1) in sky2_set_coalesce()
4154 struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_ringparam() local
4159 ering->rx_pending = sky2->rx_pending; in sky2_get_ringparam()
4160 ering->tx_pending = sky2->tx_pending; in sky2_get_ringparam()
4168 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_ringparam() local
4178 sky2->rx_pending = ering->rx_pending; in sky2_set_ringparam()
4179 sky2->tx_pending = ering->tx_pending; in sky2_set_ringparam()
4180 sky2->tx_ring_size = roundup_ring_size(sky2->tx_pending); in sky2_set_ringparam()
4241 const struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_regs() local
4242 const void __iomem *io = sky2->hw->regs; in sky2_get_regs()
4251 else if (sky2_reg_access_ok(sky2->hw, b)) in sky2_get_regs()
4263 struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_eeprom_len() local
4264 struct sky2_hw *hw = sky2->hw; in sky2_get_eeprom_len()
4274 struct sky2_port *sky2 = netdev_priv(dev); in sky2_get_eeprom() local
4278 rc = pci_read_vpd_any(sky2->hw->pdev, eeprom->offset, eeprom->len, in sky2_get_eeprom()
4291 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_eeprom() local
4297 rc = pci_write_vpd_any(sky2->hw->pdev, eeprom->offset, eeprom->len, in sky2_set_eeprom()
4306 const struct sky2_port *sky2 = netdev_priv(dev); in sky2_fix_features() local
4307 const struct sky2_hw *hw = sky2->hw; in sky2_fix_features()
4320 (sky2->hw->flags & SKY2_HW_RSS_CHKSUM)) { in sky2_fix_features()
4330 struct sky2_port *sky2 = netdev_priv(dev); in sky2_set_features() local
4334 !(sky2->hw->flags & SKY2_HW_NEW_LE)) { in sky2_set_features()
4335 sky2_write32(sky2->hw, in sky2_set_features()
4336 Q_ADDR(rxqaddr[sky2->port], Q_CSR), in sky2_set_features()
4388 const struct sky2_port *sky2 = netdev_priv(dev); in sky2_debug_show() local
4389 struct sky2_hw *hw = sky2->hw; in sky2_debug_show()
4390 unsigned port = sky2->port; in sky2_debug_show()
4422 sky2->tx_cons, sky2->tx_prod, in sky2_debug_show()
4428 for (idx = sky2->tx_next; idx != sky2->tx_prod && idx < sky2->tx_ring_size; in sky2_debug_show()
4429 idx = RING_NEXT(idx, sky2->tx_ring_size)) { in sky2_debug_show()
4430 const struct sky2_tx_le *le = sky2->tx_le + idx; in sky2_debug_show()
4489 struct sky2_port *sky2 = netdev_priv(dev); in sky2_device_event() local
4496 if (sky2->debugfs) { in sky2_device_event()
4497 sky2->debugfs = debugfs_rename(sky2_debug, sky2->debugfs, in sky2_device_event()
4503 if (sky2->debugfs) { in sky2_device_event()
4505 debugfs_remove(sky2->debugfs); in sky2_device_event()
4506 sky2->debugfs = NULL; in sky2_device_event()
4511 sky2->debugfs = debugfs_create_file(dev->name, 0444, in sky2_device_event()
4514 if (IS_ERR(sky2->debugfs)) in sky2_device_event()
4515 sky2->debugfs = NULL; in sky2_device_event()
4593 struct sky2_port *sky2; in sky2_init_netdev() local
4594 struct net_device *dev = alloc_etherdev(sizeof(*sky2)); in sky2_init_netdev()
4606 sky2 = netdev_priv(dev); in sky2_init_netdev()
4607 sky2->netdev = dev; in sky2_init_netdev()
4608 sky2->hw = hw; in sky2_init_netdev()
4609 sky2->msg_enable = netif_msg_init(debug, default_msg); in sky2_init_netdev()
4611 u64_stats_init(&sky2->tx_stats.syncp); in sky2_init_netdev()
4612 u64_stats_init(&sky2->rx_stats.syncp); in sky2_init_netdev()
4615 sky2->flags = SKY2_FLAG_AUTO_SPEED | SKY2_FLAG_AUTO_PAUSE; in sky2_init_netdev()
4619 sky2->flow_mode = FC_BOTH; in sky2_init_netdev()
4621 sky2->duplex = -1; in sky2_init_netdev()
4622 sky2->speed = -1; in sky2_init_netdev()
4623 sky2->advertising = sky2_supported_modes(hw); in sky2_init_netdev()
4624 sky2->wol = wol; in sky2_init_netdev()
4626 spin_lock_init(&sky2->phy_lock); in sky2_init_netdev()
4628 sky2->tx_pending = TX_DEF_PENDING; in sky2_init_netdev()
4629 sky2->tx_ring_size = roundup_ring_size(TX_DEF_PENDING); in sky2_init_netdev()
4630 sky2->rx_pending = RX_DEF_PENDING; in sky2_init_netdev()
4634 sky2->port = port; in sky2_init_netdev()
4689 const struct sky2_port *sky2 = netdev_priv(dev); in sky2_show_addr() local
4691 netif_info(sky2, probe, dev, "addr %pM\n", dev->dev_addr); in sky2_show_addr()
5065 struct sky2_port *sky2 = netdev_priv(dev); in sky2_suspend() local
5067 if (sky2->wol) in sky2_suspend()
5068 sky2_wol_init(sky2); in sky2_suspend()