Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: spacemit: Remove broken flow control support

The current flow control implementation doesn't handle autonegotiation
and ethtool operations properly. Remove it for now so we don't claim
support for something that doesn't really work. A better implementation
will be sent in future patches.

Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20260104-k1-ethernet-actually-remove-fc-v3-1-3871b055064c@iscas.ac.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vivian Wang and committed by
Jakub Kicinski
f6608679 48b27ea6

-110
-110
drivers/net/ethernet/spacemit/k1_emac.c
··· 46 46 #define EMAC_RX_FRAMES 64 47 47 #define EMAC_RX_COAL_TIMEOUT (600 * 312) 48 48 49 - #define DEFAULT_FC_PAUSE_TIME 0xffff 50 - #define DEFAULT_FC_FIFO_HIGH 1600 51 49 #define DEFAULT_TX_ALMOST_FULL 0x1f8 52 50 #define DEFAULT_TX_THRESHOLD 1518 53 51 #define DEFAULT_RX_THRESHOLD 12 ··· 130 132 u32 tx_delay; 131 133 u32 rx_delay; 132 134 133 - bool flow_control_autoneg; 134 - u8 flow_control; 135 - 136 135 /* Softirq-safe, hold while touching hardware statistics */ 137 136 spinlock_t stats_lock; 138 137 }; ··· 174 179 175 180 static void emac_set_mac_addr(struct emac_priv *priv, const unsigned char *addr) 176 181 { 177 - /* We use only one address, so set the same for flow control as well */ 178 182 emac_set_mac_addr_reg(priv, addr, MAC_ADDRESS1_HIGH); 179 - emac_set_mac_addr_reg(priv, addr, MAC_FC_SOURCE_ADDRESS_HIGH); 180 183 } 181 184 182 185 static void emac_reset_hw(struct emac_priv *priv) ··· 193 200 194 201 static void emac_init_hw(struct emac_priv *priv) 195 202 { 196 - /* Destination address for 802.3x Ethernet flow control */ 197 - u8 fc_dest_addr[ETH_ALEN] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01 }; 198 - 199 203 u32 rxirq = 0, dma = 0; 200 204 201 205 regmap_set_bits(priv->regmap_apmu, ··· 217 227 emac_wr(priv, MAC_TRANSMIT_PACKET_START_THRESHOLD, 218 228 DEFAULT_TX_THRESHOLD); 219 229 emac_wr(priv, MAC_RECEIVE_PACKET_START_THRESHOLD, DEFAULT_RX_THRESHOLD); 220 - 221 - /* Configure flow control (enabled in emac_adjust_link() later) */ 222 - emac_set_mac_addr_reg(priv, fc_dest_addr, MAC_FC_SOURCE_ADDRESS_HIGH); 223 - emac_wr(priv, MAC_FC_PAUSE_HIGH_THRESHOLD, DEFAULT_FC_FIFO_HIGH); 224 - emac_wr(priv, MAC_FC_HIGH_PAUSE_TIME, DEFAULT_FC_PAUSE_TIME); 225 - emac_wr(priv, MAC_FC_PAUSE_LOW_THRESHOLD, 0); 226 230 227 231 /* RX IRQ mitigation */ 228 232 rxirq = FIELD_PREP(MREGBIT_RECEIVE_IRQ_FRAME_COUNTER_MASK, ··· 1002 1018 return ret; 1003 1019 } 1004 1020 1005 - static void emac_set_tx_fc(struct emac_priv *priv, bool enable) 1006 - { 1007 - u32 val; 1008 - 1009 - val = emac_rd(priv, MAC_FC_CONTROL); 1010 - 1011 - FIELD_MODIFY(MREGBIT_FC_GENERATION_ENABLE, &val, enable); 1012 - FIELD_MODIFY(MREGBIT_AUTO_FC_GENERATION_ENABLE, &val, enable); 1013 - 1014 - emac_wr(priv, MAC_FC_CONTROL, val); 1015 - } 1016 - 1017 - static void emac_set_rx_fc(struct emac_priv *priv, bool enable) 1018 - { 1019 - u32 val = emac_rd(priv, MAC_FC_CONTROL); 1020 - 1021 - FIELD_MODIFY(MREGBIT_FC_DECODE_ENABLE, &val, enable); 1022 - 1023 - emac_wr(priv, MAC_FC_CONTROL, val); 1024 - } 1025 - 1026 - static void emac_set_fc(struct emac_priv *priv, u8 fc) 1027 - { 1028 - emac_set_tx_fc(priv, fc & FLOW_CTRL_TX); 1029 - emac_set_rx_fc(priv, fc & FLOW_CTRL_RX); 1030 - priv->flow_control = fc; 1031 - } 1032 - 1033 - static void emac_set_fc_autoneg(struct emac_priv *priv) 1034 - { 1035 - struct phy_device *phydev = priv->ndev->phydev; 1036 - u32 local_adv, remote_adv; 1037 - u8 fc; 1038 - 1039 - local_adv = linkmode_adv_to_lcl_adv_t(phydev->advertising); 1040 - 1041 - remote_adv = 0; 1042 - 1043 - if (phydev->pause) 1044 - remote_adv |= LPA_PAUSE_CAP; 1045 - 1046 - if (phydev->asym_pause) 1047 - remote_adv |= LPA_PAUSE_ASYM; 1048 - 1049 - fc = mii_resolve_flowctrl_fdx(local_adv, remote_adv); 1050 - 1051 - priv->flow_control_autoneg = true; 1052 - 1053 - emac_set_fc(priv, fc); 1054 - } 1055 - 1056 1021 /* 1057 1022 * Even though this MAC supports gigabit operation, it only provides 32-bit 1058 1023 * statistics counters. The most overflow-prone counters are the "bytes" ones, ··· 1358 1425 emac_rd(priv, MAC_GLOBAL_CONTROL + i * 4); 1359 1426 } 1360 1427 1361 - static void emac_get_pauseparam(struct net_device *dev, 1362 - struct ethtool_pauseparam *pause) 1363 - { 1364 - struct emac_priv *priv = netdev_priv(dev); 1365 - 1366 - pause->autoneg = priv->flow_control_autoneg; 1367 - pause->tx_pause = !!(priv->flow_control & FLOW_CTRL_TX); 1368 - pause->rx_pause = !!(priv->flow_control & FLOW_CTRL_RX); 1369 - } 1370 - 1371 - static int emac_set_pauseparam(struct net_device *dev, 1372 - struct ethtool_pauseparam *pause) 1373 - { 1374 - struct emac_priv *priv = netdev_priv(dev); 1375 - u8 fc = 0; 1376 - 1377 - if (!netif_running(dev)) 1378 - return -ENETDOWN; 1379 - 1380 - priv->flow_control_autoneg = pause->autoneg; 1381 - 1382 - if (pause->autoneg) { 1383 - emac_set_fc_autoneg(priv); 1384 - } else { 1385 - if (pause->tx_pause) 1386 - fc |= FLOW_CTRL_TX; 1387 - 1388 - if (pause->rx_pause) 1389 - fc |= FLOW_CTRL_RX; 1390 - 1391 - emac_set_fc(priv, fc); 1392 - } 1393 - 1394 - return 0; 1395 - } 1396 - 1397 1428 static void emac_get_drvinfo(struct net_device *dev, 1398 1429 struct ethtool_drvinfo *info) 1399 1430 { ··· 1531 1634 } 1532 1635 1533 1636 emac_wr(priv, MAC_GLOBAL_CONTROL, ctrl); 1534 - 1535 - emac_set_fc_autoneg(priv); 1536 1637 } 1537 1638 1538 1639 phy_print_status(phydev); ··· 1609 1714 ret = -ENODEV; 1610 1715 goto err_node_put; 1611 1716 } 1612 - 1613 - phy_support_asym_pause(phydev); 1614 1717 1615 1718 phydev->mac_managed_pm = true; 1616 1719 ··· 1779 1886 .get_sset_count = emac_get_sset_count, 1780 1887 .get_strings = emac_get_strings, 1781 1888 .get_ethtool_stats = emac_get_ethtool_stats, 1782 - 1783 - .get_pauseparam = emac_get_pauseparam, 1784 - .set_pauseparam = emac_set_pauseparam, 1785 1889 }; 1786 1890 1787 1891 static const struct net_device_ops emac_netdev_ops = {