mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 14:44:10 +08:00
Merge branch 'phy-microchip-ksz-9897-errata'
Enguerrand de Ribaucourt says: ==================== Handle new Microchip KSZ 9897 Errata These patches implement some suggested workarounds from the Microchip KSZ 9897 Errata [1]. [1] https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/Errata/KSZ9897R-Errata-DS80000758.pdf --- v7: - use dev_crit_once instead of dev_crit_ratelimited - add a comment to help users understand the consequences of half-duplex errors v6: https://lore.kernel.org/netdev/20240614094642.122464-1-enguerrand.de-ribaucourt@savoirfairelinux.com/ - remove KSZ9897 phy_id workaround (was a configuration issue) - use macros for checking link down in monitoring function - check if VLAN is enabled before monitoring resources v5: https://lore.kernel.org/all/20240604092304.314636-1-enguerrand.de-ribaucourt@savoirfairelinux.com/ - use macros for bitfields - rewrap comments - check ksz_pread* return values - fix spelling mistakes - remove KSZ9477 suspend/resume deletion patch v4: https://lore.kernel.org/all/20240531142430.678198-1-enguerrand.de-ribaucourt@savoirfairelinux.com/ - Rebase on net/main - Add Fixes: tags to the patches - reverse x-mas tree order - use pseudo phy_id instead of match_phy_device v3: https://lore.kernel.org/all/20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com/ ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
4ae2c67840
@ -427,6 +427,57 @@ void ksz9477_freeze_mib(struct ksz_device *dev, int port, bool freeze)
|
||||
mutex_unlock(&p->mib.cnt_mutex);
|
||||
}
|
||||
|
||||
int ksz9477_errata_monitor(struct ksz_device *dev, int port,
|
||||
u64 tx_late_col)
|
||||
{
|
||||
u32 pmavbc;
|
||||
u8 status;
|
||||
u16 pqm;
|
||||
int ret;
|
||||
|
||||
ret = ksz_pread8(dev, port, REG_PORT_STATUS_0, &status);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!(FIELD_GET(PORT_INTF_SPEED_MASK, status) == PORT_INTF_SPEED_NONE) &&
|
||||
!(status & PORT_INTF_FULL_DUPLEX)) {
|
||||
/* Errata DS80000754 recommends monitoring potential faults in
|
||||
* half-duplex mode. The switch might not be able to communicate anymore
|
||||
* in these states.
|
||||
* If you see this message, please read the errata-sheet for more information:
|
||||
* https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/Errata/KSZ9477S-Errata-DS80000754.pdf
|
||||
* To workaround this issue, half-duplex mode should be avoided.
|
||||
* A software reset could be implemented to recover from this state.
|
||||
*/
|
||||
dev_warn_once(dev->dev,
|
||||
"Half-duplex detected on port %d, transmission halt may occur\n",
|
||||
port);
|
||||
if (tx_late_col != 0) {
|
||||
/* Transmission halt with late collisions */
|
||||
dev_crit_once(dev->dev,
|
||||
"TX late collisions detected, transmission may be halted on port %d\n",
|
||||
port);
|
||||
}
|
||||
ret = ksz_read8(dev, REG_SW_LUE_CTRL_0, &status);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (status & SW_VLAN_ENABLE) {
|
||||
ret = ksz_pread16(dev, port, REG_PORT_QM_TX_CNT_0__4, &pqm);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = ksz_read32(dev, REG_PMAVBC, &pmavbc);
|
||||
if (ret)
|
||||
return ret;
|
||||
if ((FIELD_GET(PMAVBC_MASK, pmavbc) <= PMAVBC_MIN) ||
|
||||
(FIELD_GET(PORT_QM_TX_CNT_M, pqm) >= PORT_QM_TX_CNT_MAX)) {
|
||||
/* Transmission halt with Half-Duplex and VLAN */
|
||||
dev_crit_once(dev->dev,
|
||||
"resources out of limits, transmission may be halted\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ksz9477_port_init_cnt(struct ksz_device *dev, int port)
|
||||
{
|
||||
struct ksz_port_mib *mib = &dev->ports[port].mib;
|
||||
@ -1297,6 +1348,10 @@ int ksz9477_setup(struct dsa_switch *ds)
|
||||
/* Enable REG_SW_MTU__2 reg by setting SW_JUMBO_PACKET */
|
||||
ksz_cfg(dev, REG_SW_MAC_CTRL_1, SW_JUMBO_PACKET, true);
|
||||
|
||||
/* Use collision based back pressure mode. */
|
||||
ksz_cfg(dev, REG_SW_MAC_CTRL_1, SW_BACK_PRESSURE,
|
||||
SW_BACK_PRESSURE_COLLISION);
|
||||
|
||||
/* Now we can configure default MTU value */
|
||||
ret = regmap_update_bits(ksz_regmap_16(dev), REG_SW_MTU__2, REG_SW_MTU_MASK,
|
||||
VLAN_ETH_FRAME_LEN + ETH_FCS_LEN);
|
||||
|
@ -36,6 +36,8 @@ int ksz9477_port_mirror_add(struct ksz_device *dev, int port,
|
||||
bool ingress, struct netlink_ext_ack *extack);
|
||||
void ksz9477_port_mirror_del(struct ksz_device *dev, int port,
|
||||
struct dsa_mall_mirror_tc_entry *mirror);
|
||||
int ksz9477_errata_monitor(struct ksz_device *dev, int port,
|
||||
u64 tx_late_col);
|
||||
void ksz9477_get_caps(struct ksz_device *dev, int port,
|
||||
struct phylink_config *config);
|
||||
int ksz9477_fdb_dump(struct ksz_device *dev, int port,
|
||||
|
@ -247,6 +247,7 @@
|
||||
#define REG_SW_MAC_CTRL_1 0x0331
|
||||
|
||||
#define SW_BACK_PRESSURE BIT(5)
|
||||
#define SW_BACK_PRESSURE_COLLISION 0
|
||||
#define FAIR_FLOW_CTRL BIT(4)
|
||||
#define NO_EXC_COLLISION_DROP BIT(3)
|
||||
#define SW_JUMBO_PACKET BIT(2)
|
||||
@ -842,8 +843,8 @@
|
||||
|
||||
#define REG_PORT_STATUS_0 0x0030
|
||||
|
||||
#define PORT_INTF_SPEED_M 0x3
|
||||
#define PORT_INTF_SPEED_S 3
|
||||
#define PORT_INTF_SPEED_MASK GENMASK(4, 3)
|
||||
#define PORT_INTF_SPEED_NONE GENMASK(1, 0)
|
||||
#define PORT_INTF_FULL_DUPLEX BIT(2)
|
||||
#define PORT_TX_FLOW_CTRL BIT(1)
|
||||
#define PORT_RX_FLOW_CTRL BIT(0)
|
||||
@ -1167,6 +1168,11 @@
|
||||
#define PORT_RMII_CLK_SEL BIT(7)
|
||||
#define PORT_MII_SEL_EDGE BIT(5)
|
||||
|
||||
#define REG_PMAVBC 0x03AC
|
||||
|
||||
#define PMAVBC_MASK GENMASK(26, 16)
|
||||
#define PMAVBC_MIN 0x580
|
||||
|
||||
/* 4 - MAC */
|
||||
#define REG_PORT_MAC_CTRL_0 0x0400
|
||||
|
||||
@ -1494,6 +1500,7 @@
|
||||
|
||||
#define PORT_QM_TX_CNT_USED_S 0
|
||||
#define PORT_QM_TX_CNT_M (BIT(11) - 1)
|
||||
#define PORT_QM_TX_CNT_MAX 0x200
|
||||
|
||||
#define REG_PORT_QM_TX_CNT_1__4 0x0A14
|
||||
|
||||
|
@ -1382,6 +1382,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
|
||||
.tc_cbs_supported = true,
|
||||
.ops = &ksz9477_dev_ops,
|
||||
.phylink_mac_ops = &ksz9477_phylink_mac_ops,
|
||||
.phy_errata_9477 = true,
|
||||
.mib_names = ksz9477_mib_names,
|
||||
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
|
||||
.reg_mib_cnt = MIB_COUNTER_NUM,
|
||||
@ -1416,6 +1417,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
|
||||
.num_ipms = 8,
|
||||
.ops = &ksz9477_dev_ops,
|
||||
.phylink_mac_ops = &ksz9477_phylink_mac_ops,
|
||||
.phy_errata_9477 = true,
|
||||
.mib_names = ksz9477_mib_names,
|
||||
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
|
||||
.reg_mib_cnt = MIB_COUNTER_NUM,
|
||||
@ -1450,6 +1452,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
|
||||
.num_ipms = 8,
|
||||
.ops = &ksz9477_dev_ops,
|
||||
.phylink_mac_ops = &ksz9477_phylink_mac_ops,
|
||||
.phy_errata_9477 = true,
|
||||
.mib_names = ksz9477_mib_names,
|
||||
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
|
||||
.reg_mib_cnt = MIB_COUNTER_NUM,
|
||||
@ -1540,6 +1543,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
|
||||
.tc_cbs_supported = true,
|
||||
.ops = &ksz9477_dev_ops,
|
||||
.phylink_mac_ops = &ksz9477_phylink_mac_ops,
|
||||
.phy_errata_9477 = true,
|
||||
.mib_names = ksz9477_mib_names,
|
||||
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
|
||||
.reg_mib_cnt = MIB_COUNTER_NUM,
|
||||
@ -1820,6 +1824,7 @@ void ksz_r_mib_stats64(struct ksz_device *dev, int port)
|
||||
struct rtnl_link_stats64 *stats;
|
||||
struct ksz_stats_raw *raw;
|
||||
struct ksz_port_mib *mib;
|
||||
int ret;
|
||||
|
||||
mib = &dev->ports[port].mib;
|
||||
stats = &mib->stats64;
|
||||
@ -1861,6 +1866,12 @@ void ksz_r_mib_stats64(struct ksz_device *dev, int port)
|
||||
pstats->rx_pause_frames = raw->rx_pause;
|
||||
|
||||
spin_unlock(&mib->stats64_lock);
|
||||
|
||||
if (dev->info->phy_errata_9477) {
|
||||
ret = ksz9477_errata_monitor(dev, port, raw->tx_late_col);
|
||||
if (ret)
|
||||
dev_err(dev->dev, "Failed to monitor transmission halt\n");
|
||||
}
|
||||
}
|
||||
|
||||
void ksz88xx_r_mib_stats64(struct ksz_device *dev, int port)
|
||||
|
@ -66,6 +66,7 @@ struct ksz_chip_data {
|
||||
bool tc_cbs_supported;
|
||||
const struct ksz_dev_ops *ops;
|
||||
const struct phylink_mac_ops *phylink_mac_ops;
|
||||
bool phy_errata_9477;
|
||||
bool ksz87xx_eee_link_erratum;
|
||||
const struct ksz_mib_names *mib_names;
|
||||
int mib_cnt;
|
||||
|
@ -5607,6 +5607,7 @@ static struct mdio_device_id __maybe_unused micrel_tbl[] = {
|
||||
{ PHY_ID_KSZ8081, MICREL_PHY_ID_MASK },
|
||||
{ PHY_ID_KSZ8873MLL, MICREL_PHY_ID_MASK },
|
||||
{ PHY_ID_KSZ886X, MICREL_PHY_ID_MASK },
|
||||
{ PHY_ID_KSZ9477, MICREL_PHY_ID_MASK },
|
||||
{ PHY_ID_LAN8814, MICREL_PHY_ID_MASK },
|
||||
{ PHY_ID_LAN8804, MICREL_PHY_ID_MASK },
|
||||
{ PHY_ID_LAN8841, MICREL_PHY_ID_MASK },
|
||||
|
Loading…
Reference in New Issue
Block a user