From nobody Tue May 7 08:23:10 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01BB3C47088 for ; Fri, 2 Dec 2022 19:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234313AbiLBTSM (ORCPT ); Fri, 2 Dec 2022 14:18:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234723AbiLBTSH (ORCPT ); Fri, 2 Dec 2022 14:18:07 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECA925A6CA; Fri, 2 Dec 2022 11:18:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670008685; x=1701544685; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=A5PoAKCak51gwau3gk4Z68MLvJ/ijOTtPKUqHzhQ844=; b=2QRH/GowTDrHf5fyPHK9sRAEbX9QelkRfbb0/PdeM+1Wf86C6WmBNnPM JF8hxoL5K66D/qL15qmtPVRdlAZ9fRwZCy5Xkiw2n/ixg8T1qagHIfH/4 buiqrUMD6gHqMc/DN/9A/GfKEZeu/ZKLByulw/Fgls5EolpKUtq5C0lkR xqhUxB0sUphFyWqoVhEU8VzQj8FMzQJazU8Jz+om+HofVXQB6fDCJ4B2P JlrAKi5ccRvnlGyg1y7Px92Qg0XijcLNMHEbSAfOCOwtLOrX9dZWui8M6 OX/2YMueIc+q4E4XanisoJtyKPwb+3sn4VaurGvEgtpuyekbiGQL2mG2J Q==; X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="189805240" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Dec 2022 12:18:04 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 2 Dec 2022 12:17:51 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 2 Dec 2022 12:17:50 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , , , , Jerry Ray Subject: [PATCH net-next v2 1/2] dsa: lan9303: Add port_max_mtu API Date: Fri, 2 Dec 2022 13:17:48 -0600 Message-ID: <20221202191749.27437-2-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202191749.27437-1-jerry.ray@microchip.com> References: <20221202191749.27437-1-jerry.ray@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Adding in support for reporting the max mtu for a given port. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 80f07bd20593..baa336bb9d15 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1279,6 +1279,25 @@ static int lan9303_port_mdb_del(struct dsa_switch *d= s, int port, return 0; } =20 +/* For non-cpu ports, the max frame size is 1518. + * The CPU port supports a max frame size of 1522. + * There is a JUMBO flag to make the max size 2048, but this driver + * presently does not support using it. + */ +static int lan9303_port_max_mtu(struct dsa_switch *ds, int port) +{ + struct net_device *p =3D dsa_port_to_master(dsa_to_port(ds, port)); + struct lan9303 *chip =3D ds->priv; + + dev_dbg(chip->dev, "%s(%d) entered. NET max_mtu is %d", + __func__, port, p->max_mtu); + + if (dsa_port_is_cpu(dsa_to_port(ds, port))) + return 1522 - ETH_HLEN - ETH_FCS_LEN; + else + return 1518 - ETH_HLEN - ETH_FCS_LEN; +} + static const struct dsa_switch_ops lan9303_switch_ops =3D { .get_tag_protocol =3D lan9303_get_tag_protocol, .setup =3D lan9303_setup, @@ -1299,6 +1318,7 @@ static const struct dsa_switch_ops lan9303_switch_ops= =3D { .port_fdb_dump =3D lan9303_port_fdb_dump, .port_mdb_add =3D lan9303_port_mdb_add, .port_mdb_del =3D lan9303_port_mdb_del, + .port_max_mtu =3D lan9303_port_max_mtu, }; =20 static int lan9303_register_switch(struct lan9303 *chip) --=20 2.17.1 From nobody Tue May 7 08:23:10 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EDD5C4332F for ; Fri, 2 Dec 2022 19:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234359AbiLBTST (ORCPT ); Fri, 2 Dec 2022 14:18:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234728AbiLBTSJ (ORCPT ); Fri, 2 Dec 2022 14:18:09 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21EF64387C; Fri, 2 Dec 2022 11:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670008686; x=1701544686; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=vToaefq740Jb/L0Na2JLNjqwlt32ey3lu/CBPuLRBfs=; b=iBxcCO9dkGAgfyO+lud+QWl6OvrWA6A1xTEJIvUC88Atq7UHkWaHnTrz X8m4KShzge7rjRLayROyCHlipakNyulCZwQVLhIIl20mSJqFt2ZeFKCen +EWn+JtJY0x9961jFBVDBo57GrWCrh87SItUyxDWdN8tOEf/209UtwqhR 9saNmwv1hRle4QXEo8pMyiDozYXEukp89Np2n28hDJNUQsmZVQ67VHtKF YlapF+vohXtvJXq8LapF4tUy6FxKrBFFysynGWgL+eMGqN0MZ1YnEtdl1 D2s/rdBI6f75Fo+PFgfHY/eLETCUOGkhqdYxt4xqBItLNqPROFrQ59weW w==; X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="189805242" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Dec 2022 12:18:04 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 2 Dec 2022 12:17:52 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 2 Dec 2022 12:17:51 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , , , , Jerry Ray Subject: [PATCH net-next v2 2/2] dsa: lan9303: Move to PHYLINK Date: Fri, 2 Dec 2022 13:17:49 -0600 Message-ID: <20221202191749.27437-3-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202191749.27437-1-jerry.ray@microchip.com> References: <20221202191749.27437-1-jerry.ray@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch replaces the .adjust_link api with the .phylink_get_caps api. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 73 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index baa336bb9d15..2baf6ae7e0a0 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1047,42 +1047,6 @@ static int lan9303_phy_write(struct dsa_switch *ds, = int phy, int regnum, return chip->ops->phy_write(chip, phy, regnum, val); } =20 -static void lan9303_adjust_link(struct dsa_switch *ds, int port, - struct phy_device *phydev) -{ - struct lan9303 *chip =3D ds->priv; - int ctl; - - if (!phy_is_pseudo_fixed_link(phydev)) - return; - - ctl =3D lan9303_phy_read(ds, port, MII_BMCR); - - ctl &=3D ~BMCR_ANENABLE; - - if (phydev->speed =3D=3D SPEED_100) - ctl |=3D BMCR_SPEED100; - else if (phydev->speed =3D=3D SPEED_10) - ctl &=3D ~BMCR_SPEED100; - else - dev_err(ds->dev, "unsupported speed: %d\n", phydev->speed); - - if (phydev->duplex =3D=3D DUPLEX_FULL) - ctl |=3D BMCR_FULLDPLX; - else - ctl &=3D ~BMCR_FULLDPLX; - - lan9303_phy_write(ds, port, MII_BMCR, ctl); - - if (port =3D=3D chip->phy_addr_base) { - /* Virtual Phy: Remove Turbo 200Mbit mode */ - lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl); - - ctl &=3D ~LAN9303_VIRT_SPECIAL_TURBO; - regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl); - } -} - static int lan9303_port_enable(struct dsa_switch *ds, int port, struct phy_device *phy) { @@ -1279,6 +1243,41 @@ static int lan9303_port_mdb_del(struct dsa_switch *d= s, int port, return 0; } =20 +static void lan9303_phylink_get_caps(struct dsa_switch *ds, int port, + struct phylink_config *config) +{ + struct lan9303 *chip =3D ds->priv; + + dev_dbg(chip->dev, "%s(%d) entered.", __func__, port); + + config->mac_capabilities =3D MAC_10 | MAC_100 | MAC_ASYM_PAUSE | + MAC_SYM_PAUSE; + + if (dsa_port_is_cpu(dsa_to_port(ds, port))) { + /* cpu port */ + phy_interface_empty(config->supported_interfaces); + __set_bit(PHY_INTERFACE_MODE_RMII, + config->supported_interfaces); + __set_bit(PHY_INTERFACE_MODE_MII, + config->supported_interfaces); + } else { + /* internal ports */ + __set_bit(PHY_INTERFACE_MODE_INTERNAL, + config->supported_interfaces); + /* Compatibility for phylib's default interface type when the + * phy-mode property is absent + */ + __set_bit(PHY_INTERFACE_MODE_GMII, + config->supported_interfaces); + } + + /* This driver does not make use of the speed, duplex, pause or the + * advertisement in its mac_config, so it is safe to mark this driver + * as non-legacy. + */ + config->legacy_pre_march2020 =3D false; +} + /* For non-cpu ports, the max frame size is 1518. * The CPU port supports a max frame size of 1522. * There is a JUMBO flag to make the max size 2048, but this driver @@ -1304,7 +1303,7 @@ static const struct dsa_switch_ops lan9303_switch_ops= =3D { .get_strings =3D lan9303_get_strings, .phy_read =3D lan9303_phy_read, .phy_write =3D lan9303_phy_write, - .adjust_link =3D lan9303_adjust_link, + .phylink_get_caps =3D lan9303_phylink_get_caps, .get_ethtool_stats =3D lan9303_get_ethtool_stats, .get_sset_count =3D lan9303_get_sset_count, .port_enable =3D lan9303_port_enable, --=20 2.17.1