From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samu Nuutamo Subject: Regression: mv88e6xxx packet loss after 4.18's PHYLINK merge Date: Mon, 14 Jan 2019 13:34:44 +0200 Message-ID: <20190114113444.GB16632@samu-ThinkPad-T480s> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" To: netdev@vger.kernel.org Return-path: Received: from mail-lj1-f194.google.com ([209.85.208.194]:33120 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726542AbfANLet (ORCPT ); Mon, 14 Jan 2019 06:34:49 -0500 Received: by mail-lj1-f194.google.com with SMTP id v1-v6so18714256ljd.0 for ; Mon, 14 Jan 2019 03:34:48 -0800 (PST) Content-Disposition: inline Sender: netdev-owner@vger.kernel.org List-ID: Hi, We have an imx6q-b450v3 board that has one of the switch ports configured as a fixed link. After upgrading the kernel to version 4.18 the link has experienced a small amount of packet loss, around 0.15%. The issue was bisected to a commit: aab9c4067d23 net: dsa: Plug in PHYLINK support After enabling debug we could see that the new phylink code causes the link to reset once every second: [ 309.992368] mv88e6085 gpio-0:00 enembc: phylink_mac_config: mode=fixed//100Mbps/Full adv=00000,00000208 pause=10 link=1 an=1 [ 309.998451] mv88e6085 gpio-0:00: p5: Force link down [ 309.998869] mv88e6085 gpio-0:00: p5: Speed set to 100 Mbps [ 309.999280] mv88e6085 gpio-0:00: p5: Force full duplex [ 309.999895] mv88e6085 gpio-0:00: p5: Force link up [ 311.032400] mv88e6085 gpio-0:00 enembc: phylink_mac_config: mode=fixed//100Mbps/Full adv=00000,00000208 pause=10 link=1 an=1 [ 311.038248] mv88e6085 gpio-0:00: p5: Force link down [ 311.038660] mv88e6085 gpio-0:00: p5: Speed set to 100 Mbps [ 311.039069] mv88e6085 gpio-0:00: p5: Force full duplex [ 311.039678] mv88e6085 gpio-0:00: p5: Force link up [ 312.072328] mv88e6085 gpio-0:00 enembc: phylink_mac_config: mode=fixed//100Mbps/Full adv=00000,00000208 pause=10 link=1 an=1 [ 312.077603] mv88e6085 gpio-0:00: p5: Force link down [ 312.078010] mv88e6085 gpio-0:00: p5: Speed set to 100 Mbps [ 312.078417] mv88e6085 gpio-0:00: p5: Force full duplex [ 312.079026] mv88e6085 gpio-0:00: p5: Force link up It's probably not a coincidence that the link downtime comes out as 0.15% matching the packet loss percentage. I patched the driver code so that the reset is skipped if the link state is already set: --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -532,6 +532,17 @@ static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, if (!chip->info->ops->port_set_link) return 0; + if (chip->info->ops->port_link_state) { + struct phylink_link_state state; + + err = chip->info->ops->port_link_state(chip, port, &state); + + if (!err && link == state.link) { + dev_dbg(chip->dev, "link state already set\n"); + return 0; + } + } + /* Port's MAC control must not be changed unless the link is down */ err = chip->info->ops->port_set_link(chip, port, 0); if (err) The patched version did not have any packet loss, but it's probably not the correct way of fixing the issue. Best regards, Samu Nuutamo