Lines Matching refs:mac

216 	struct mtk_mac *mac = container_of(config, struct mtk_mac,  in mtk_mac_config()  local
218 struct mtk_eth *eth = mac->hw; in mtk_mac_config()
224 mac->interface != state->interface) { in mtk_mac_config()
228 if (mac->id) in mtk_mac_config()
230 if (!MTK_HAS_CAPS(mac->hw->soc->caps, in mtk_mac_config()
242 err = mtk_gmac_rgmii_path_setup(eth, mac->id); in mtk_mac_config()
251 err = mtk_gmac_sgmii_path_setup(eth, mac->id); in mtk_mac_config()
258 err = mtk_gmac_gephy_path_setup(eth, mac->id); in mtk_mac_config()
268 if (!mac->id && state->interface != PHY_INTERFACE_MODE_SGMII && in mtk_mac_config()
270 MTK_HAS_CAPS(mac->hw->soc->caps, MTK_GMAC1_TRGMII)) { in mtk_mac_config()
271 if (MTK_HAS_CAPS(mac->hw->soc->caps, in mtk_mac_config()
273 if (mt7621_gmac0_rgmii_adjust(mac->hw, in mtk_mac_config()
277 mtk_gmac0_rgmii_adjust(mac->hw, in mtk_mac_config()
283 mtk_w32(mac->hw, in mtk_mac_config()
288 mtk_m32(mac->hw, 0, RXC_RST | RXC_DQSISEL, in mtk_mac_config()
290 mtk_m32(mac->hw, RXC_RST, 0, TRGMII_RCK_CTRL); in mtk_mac_config()
304 if (mac->id) in mtk_mac_config()
314 val &= ~SYSCFG0_GE_MODE(SYSCFG0_GE_MASK, mac->id); in mtk_mac_config()
315 val |= SYSCFG0_GE_MODE(ge_mode, mac->id); in mtk_mac_config()
318 mac->interface = state->interface; in mtk_mac_config()
335 0 : mac->id; in mtk_mac_config()
356 mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); in mtk_mac_config()
363 mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id)); in mtk_mac_config()
369 mac->id, phy_modes(state->interface)); in mtk_mac_config()
374 mac->id, phy_modes(state->interface), err); in mtk_mac_config()
380 struct mtk_mac *mac = container_of(config, struct mtk_mac, in mtk_mac_pcs_get_state() local
382 u32 pmsr = mtk_r32(mac->hw, MTK_MAC_MSR(mac->id)); in mtk_mac_pcs_get_state()
411 struct mtk_mac *mac = container_of(config, struct mtk_mac, in mtk_mac_an_restart() local
414 mtk_sgmii_restart_an(mac->hw, mac->id); in mtk_mac_an_restart()
420 struct mtk_mac *mac = container_of(config, struct mtk_mac, in mtk_mac_link_down() local
422 u32 mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); in mtk_mac_link_down()
425 mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id)); in mtk_mac_link_down()
433 struct mtk_mac *mac = container_of(config, struct mtk_mac, in mtk_mac_link_up() local
435 u32 mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); in mtk_mac_link_up()
463 mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id)); in mtk_mac_link_up()
470 struct mtk_mac *mac = container_of(config, struct mtk_mac, in mtk_validate() local
477 !(MTK_HAS_CAPS(mac->hw->soc->caps, MTK_RGMII) && in mtk_validate()
479 !(MTK_HAS_CAPS(mac->hw->soc->caps, MTK_TRGMII) && in mtk_validate()
480 !mac->id && state->interface == PHY_INTERFACE_MODE_TRGMII) && in mtk_validate()
481 !(MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SGMII) && in mtk_validate()
524 if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SGMII)) { in mtk_validate()
529 if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_RGMII)) { in mtk_validate()
534 if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_GEPHY)) { in mtk_validate()
652 struct mtk_mac *mac = netdev_priv(dev); in mtk_set_mac_address() local
653 struct mtk_eth *eth = mac->hw; in mtk_set_mac_address()
659 if (unlikely(test_bit(MTK_RESETTING, &mac->hw->state))) in mtk_set_mac_address()
662 spin_lock_bh(&mac->hw->page_lock); in mtk_set_mac_address()
664 mtk_w32(mac->hw, (macaddr[0] << 8) | macaddr[1], in mtk_set_mac_address()
666 mtk_w32(mac->hw, (macaddr[2] << 24) | (macaddr[3] << 16) | in mtk_set_mac_address()
670 mtk_w32(mac->hw, (macaddr[0] << 8) | macaddr[1], in mtk_set_mac_address()
671 MTK_GDMA_MAC_ADRH(mac->id)); in mtk_set_mac_address()
672 mtk_w32(mac->hw, (macaddr[2] << 24) | (macaddr[3] << 16) | in mtk_set_mac_address()
674 MTK_GDMA_MAC_ADRL(mac->id)); in mtk_set_mac_address()
676 spin_unlock_bh(&mac->hw->page_lock); in mtk_set_mac_address()
681 void mtk_stats_update_mac(struct mtk_mac *mac) in mtk_stats_update_mac() argument
683 struct mtk_hw_stats *hw_stats = mac->hw_stats; in mtk_stats_update_mac()
684 struct mtk_eth *eth = mac->hw; in mtk_stats_update_mac()
689 hw_stats->tx_packets += mtk_r32(mac->hw, MT7628_SDM_TPCNT); in mtk_stats_update_mac()
690 hw_stats->tx_bytes += mtk_r32(mac->hw, MT7628_SDM_TBCNT); in mtk_stats_update_mac()
691 hw_stats->rx_packets += mtk_r32(mac->hw, MT7628_SDM_RPCNT); in mtk_stats_update_mac()
692 hw_stats->rx_bytes += mtk_r32(mac->hw, MT7628_SDM_RBCNT); in mtk_stats_update_mac()
694 mtk_r32(mac->hw, MT7628_SDM_CS_ERR); in mtk_stats_update_mac()
699 hw_stats->rx_bytes += mtk_r32(mac->hw, in mtk_stats_update_mac()
701 stats = mtk_r32(mac->hw, MTK_GDM1_RX_GBCNT_H + offs); in mtk_stats_update_mac()
705 mtk_r32(mac->hw, MTK_GDM1_RX_GPCNT + offs); in mtk_stats_update_mac()
707 mtk_r32(mac->hw, MTK_GDM1_RX_OERCNT + offs); in mtk_stats_update_mac()
709 mtk_r32(mac->hw, MTK_GDM1_RX_FERCNT + offs); in mtk_stats_update_mac()
711 mtk_r32(mac->hw, MTK_GDM1_RX_SERCNT + offs); in mtk_stats_update_mac()
713 mtk_r32(mac->hw, MTK_GDM1_RX_LENCNT + offs); in mtk_stats_update_mac()
715 mtk_r32(mac->hw, MTK_GDM1_RX_CERCNT + offs); in mtk_stats_update_mac()
717 mtk_r32(mac->hw, MTK_GDM1_RX_FCCNT + offs); in mtk_stats_update_mac()
719 mtk_r32(mac->hw, MTK_GDM1_TX_SKIPCNT + offs); in mtk_stats_update_mac()
721 mtk_r32(mac->hw, MTK_GDM1_TX_COLCNT + offs); in mtk_stats_update_mac()
723 mtk_r32(mac->hw, MTK_GDM1_TX_GBCNT_L + offs); in mtk_stats_update_mac()
724 stats = mtk_r32(mac->hw, MTK_GDM1_TX_GBCNT_H + offs); in mtk_stats_update_mac()
728 mtk_r32(mac->hw, MTK_GDM1_TX_GPCNT + offs); in mtk_stats_update_mac()
739 if (!eth->mac[i] || !eth->mac[i]->hw_stats) in mtk_stats_update()
741 if (spin_trylock(&eth->mac[i]->hw_stats->stats_lock)) { in mtk_stats_update()
742 mtk_stats_update_mac(eth->mac[i]); in mtk_stats_update()
743 spin_unlock(&eth->mac[i]->hw_stats->stats_lock); in mtk_stats_update()
751 struct mtk_mac *mac = netdev_priv(dev); in mtk_get_stats64() local
752 struct mtk_hw_stats *hw_stats = mac->hw_stats; in mtk_get_stats64()
757 mtk_stats_update_mac(mac); in mtk_get_stats64()
956 struct mtk_mac *mac = netdev_priv(dev); in mtk_tx_map() local
957 struct mtk_eth *eth = mac->hw; in mtk_tx_map()
973 fport = (mac->id + 1) << TX_DMA_FPORT_SHIFT; in mtk_tx_map()
997 itx_buf->flags |= (!mac->id) ? MTK_TX_FLAGS_FPORT0 : in mtk_tx_map()
1052 tx_buf->flags |= (!mac->id) ? MTK_TX_FLAGS_FPORT0 : in mtk_tx_map()
1163 struct mtk_mac *mac = netdev_priv(dev); in mtk_start_xmit() local
1164 struct mtk_eth *eth = mac->hw; in mtk_start_xmit()
1276 int mac; in mtk_poll_rx() local
1292 mac = 0; in mtk_poll_rx()
1294 mac = ((trxd.rxd4 >> RX_DMA_FPORT_SHIFT) & in mtk_poll_rx()
1297 if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT || in mtk_poll_rx()
1298 !eth->netdev[mac])) in mtk_poll_rx()
1301 netdev = eth->netdev[mac]; in mtk_poll_rx()
1407 int mac = 0; in mtk_poll_tx_qdma() local
1415 mac = 1; in mtk_poll_tx_qdma()
1422 bytes[mac] += skb->len; in mtk_poll_tx_qdma()
1423 done[mac]++; in mtk_poll_tx_qdma()
1905 static int mtk_hwlro_get_ip_cnt(struct mtk_mac *mac) in mtk_hwlro_get_ip_cnt() argument
1911 if (mac->hwlro_ip[i]) in mtk_hwlro_get_ip_cnt()
1923 struct mtk_mac *mac = netdev_priv(dev); in mtk_hwlro_add_ipaddr() local
1924 struct mtk_eth *eth = mac->hw; in mtk_hwlro_add_ipaddr()
1932 mac->hwlro_ip[fsp->location] = htonl(fsp->h_u.tcp_ip4_spec.ip4dst); in mtk_hwlro_add_ipaddr()
1933 hwlro_idx = (mac->id * MTK_MAX_LRO_IP_CNT) + fsp->location; in mtk_hwlro_add_ipaddr()
1935 mac->hwlro_ip_cnt = mtk_hwlro_get_ip_cnt(mac); in mtk_hwlro_add_ipaddr()
1937 mtk_hwlro_val_ipaddr(eth, hwlro_idx, mac->hwlro_ip[fsp->location]); in mtk_hwlro_add_ipaddr()
1947 struct mtk_mac *mac = netdev_priv(dev); in mtk_hwlro_del_ipaddr() local
1948 struct mtk_eth *eth = mac->hw; in mtk_hwlro_del_ipaddr()
1954 mac->hwlro_ip[fsp->location] = 0; in mtk_hwlro_del_ipaddr()
1955 hwlro_idx = (mac->id * MTK_MAX_LRO_IP_CNT) + fsp->location; in mtk_hwlro_del_ipaddr()
1957 mac->hwlro_ip_cnt = mtk_hwlro_get_ip_cnt(mac); in mtk_hwlro_del_ipaddr()
1966 struct mtk_mac *mac = netdev_priv(dev); in mtk_hwlro_netdev_disable() local
1967 struct mtk_eth *eth = mac->hw; in mtk_hwlro_netdev_disable()
1971 mac->hwlro_ip[i] = 0; in mtk_hwlro_netdev_disable()
1972 hwlro_idx = (mac->id * MTK_MAX_LRO_IP_CNT) + i; in mtk_hwlro_netdev_disable()
1977 mac->hwlro_ip_cnt = 0; in mtk_hwlro_netdev_disable()
1983 struct mtk_mac *mac = netdev_priv(dev); in mtk_hwlro_get_fdir_entry() local
1989 fsp->h_u.tcp_ip4_spec.ip4dst = ntohl(mac->hwlro_ip[fsp->location]); in mtk_hwlro_get_fdir_entry()
2008 struct mtk_mac *mac = netdev_priv(dev); in mtk_hwlro_get_fdir_all() local
2013 if (mac->hwlro_ip[i]) { in mtk_hwlro_get_fdir_all()
2028 struct mtk_mac *mac = netdev_priv(dev); in mtk_fix_features() local
2029 int ip_cnt = mtk_hwlro_get_ip_cnt(mac); in mtk_fix_features()
2159 struct mtk_mac *mac = netdev_priv(dev); in mtk_tx_timeout() local
2160 struct mtk_eth *eth = mac->hw; in mtk_tx_timeout()
2162 eth->netdev[mac->id]->stats.tx_errors++; in mtk_tx_timeout()
2213 struct mtk_mac *mac = netdev_priv(dev); in mtk_poll_controller() local
2214 struct mtk_eth *eth = mac->hw; in mtk_poll_controller()
2286 struct mtk_mac *mac = netdev_priv(dev); in mtk_open() local
2287 struct mtk_eth *eth = mac->hw; in mtk_open()
2290 err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0); in mtk_open()
2320 phylink_start(mac->phylink); in mtk_open()
2350 struct mtk_mac *mac = netdev_priv(dev); in mtk_stop() local
2351 struct mtk_eth *eth = mac->hw; in mtk_stop()
2353 phylink_stop(mac->phylink); in mtk_stop()
2357 phylink_disconnect_phy(mac->phylink); in mtk_stop()
2587 struct mtk_mac *mac = netdev_priv(dev); in mtk_init() local
2588 struct mtk_eth *eth = mac->hw; in mtk_init()
2591 ret = of_get_ethdev_address(mac->of_node, dev); in mtk_init()
2604 struct mtk_mac *mac = netdev_priv(dev); in mtk_uninit() local
2605 struct mtk_eth *eth = mac->hw; in mtk_uninit()
2607 phylink_disconnect_phy(mac->phylink); in mtk_uninit()
2615 struct mtk_mac *mac = netdev_priv(dev); in mtk_change_mtu() local
2616 struct mtk_eth *eth = mac->hw; in mtk_change_mtu()
2620 mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); in mtk_change_mtu()
2633 mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id)); in mtk_change_mtu()
2643 struct mtk_mac *mac = netdev_priv(dev); in mtk_do_ioctl() local
2649 return phylink_mii_ioctl(mac->phylink, ifr, cmd); in mtk_do_ioctl()
2747 struct mtk_mac *mac = netdev_priv(ndev); in mtk_get_link_ksettings() local
2749 if (unlikely(test_bit(MTK_RESETTING, &mac->hw->state))) in mtk_get_link_ksettings()
2752 return phylink_ethtool_ksettings_get(mac->phylink, cmd); in mtk_get_link_ksettings()
2758 struct mtk_mac *mac = netdev_priv(ndev); in mtk_set_link_ksettings() local
2760 if (unlikely(test_bit(MTK_RESETTING, &mac->hw->state))) in mtk_set_link_ksettings()
2763 return phylink_ethtool_ksettings_set(mac->phylink, cmd); in mtk_set_link_ksettings()
2769 struct mtk_mac *mac = netdev_priv(dev); in mtk_get_drvinfo() local
2771 strlcpy(info->driver, mac->hw->dev->driver->name, sizeof(info->driver)); in mtk_get_drvinfo()
2772 strlcpy(info->bus_info, dev_name(mac->hw->dev), sizeof(info->bus_info)); in mtk_get_drvinfo()
2778 struct mtk_mac *mac = netdev_priv(dev); in mtk_get_msglevel() local
2780 return mac->hw->msg_enable; in mtk_get_msglevel()
2785 struct mtk_mac *mac = netdev_priv(dev); in mtk_set_msglevel() local
2787 mac->hw->msg_enable = value; in mtk_set_msglevel()
2792 struct mtk_mac *mac = netdev_priv(dev); in mtk_nway_reset() local
2794 if (unlikely(test_bit(MTK_RESETTING, &mac->hw->state))) in mtk_nway_reset()
2797 if (!mac->phylink) in mtk_nway_reset()
2800 return phylink_ethtool_nway_reset(mac->phylink); in mtk_nway_reset()
2830 struct mtk_mac *mac = netdev_priv(dev); in mtk_get_ethtool_stats() local
2831 struct mtk_hw_stats *hwstats = mac->hw_stats; in mtk_get_ethtool_stats()
2836 if (unlikely(test_bit(MTK_RESETTING, &mac->hw->state))) in mtk_get_ethtool_stats()
2841 mtk_stats_update_mac(mac); in mtk_get_ethtool_stats()
2871 struct mtk_mac *mac = netdev_priv(dev); in mtk_get_rxnfc() local
2873 cmd->rule_cnt = mac->hwlro_ip_cnt; in mtk_get_rxnfc()
2953 struct mtk_mac *mac; in mtk_add_mac() local
2972 eth->netdev[id] = alloc_etherdev(sizeof(*mac)); in mtk_add_mac()
2977 mac = netdev_priv(eth->netdev[id]); in mtk_add_mac()
2978 eth->mac[id] = mac; in mtk_add_mac()
2979 mac->id = id; in mtk_add_mac()
2980 mac->hw = eth; in mtk_add_mac()
2981 mac->of_node = np; in mtk_add_mac()
2983 memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip)); in mtk_add_mac()
2984 mac->hwlro_ip_cnt = 0; in mtk_add_mac()
2986 mac->hw_stats = devm_kzalloc(eth->dev, in mtk_add_mac()
2987 sizeof(*mac->hw_stats), in mtk_add_mac()
2989 if (!mac->hw_stats) { in mtk_add_mac()
2994 spin_lock_init(&mac->hw_stats->stats_lock); in mtk_add_mac()
2995 u64_stats_init(&mac->hw_stats->syncp); in mtk_add_mac()
2996 mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET; in mtk_add_mac()
3006 mac->interface = PHY_INTERFACE_MODE_NA; in mtk_add_mac()
3007 mac->mode = MLO_AN_PHY; in mtk_add_mac()
3008 mac->speed = SPEED_UNKNOWN; in mtk_add_mac()
3010 mac->phylink_config.dev = &eth->netdev[id]->dev; in mtk_add_mac()
3011 mac->phylink_config.type = PHYLINK_NETDEV; in mtk_add_mac()
3013 phylink = phylink_create(&mac->phylink_config, in mtk_add_mac()
3014 of_fwnode_handle(mac->of_node), in mtk_add_mac()
3021 mac->phylink = phylink; in mtk_add_mac()
3260 struct mtk_mac *mac; in mtk_remove() local
3268 mac = netdev_priv(eth->netdev[i]); in mtk_remove()
3269 phylink_disconnect_phy(mac->phylink); in mtk_remove()