From patchwork Fri Dec 2 16:05:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 28959 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp944666wrr; Fri, 2 Dec 2022 08:12:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7bfpvzpbi836ElRbdx6tkdUJliu/8DBX1BOtcvbbc/J5CEVvTLPpUS8Wghnd8cgAdWDBy4 X-Received: by 2002:a17:906:a387:b0:78d:946e:f65d with SMTP id k7-20020a170906a38700b0078d946ef65dmr61177264ejz.365.1669997557117; Fri, 02 Dec 2022 08:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669997557; cv=none; d=google.com; s=arc-20160816; b=I6EA/9U7lOGfZjYX4Ji6ywBbX40t0y8yldSGIw4/9LmnGYXqkQgCxBqpSvuLqdAo+J M3FlMuESHvOMpT3UycuH/CTj7ZboUm+omz+NQH/RsoIa6c2ykJQbcPKRcS+5lOQvcjxj IBRR4jdhpHHjHPT07OQ9LD6rAuQHkc0yCaD/a6V6Z1ObolhfR53HFZv9dxEjamQsHsMM iLMHI8Ry50zhYv/X06VEJ9duIHfHSedVnV0Bh9i7KvWwNhUyoZBzqgunhCBU0wM6nS0H 945fT+c46RyLP0Zdr+kxCOLJQ/aghzi81xbZBgltq5XVhgjqaBNiQHErZRXynD2pvpW4 lw2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=GybL0yUpp9pOoowt+kFewhH7LzmykOI9ffKB9mjaRS0=; b=jemdec4Fj9pGq5TgddoC1DxtRsOL8GN+jFSF+9ugMcccXAV+MY535u6UfUy3Gb00rJ eKlqoIl9bgny9lJad4VhVcpIrXTqKCd1uhXeukduuuzZlmPN2S5GaPieuQmy4ZrE4rb9 Tnq6VXmF9mwNdaUkN7VcIxGt9zBTAxRueksCsljgKrM1cfR/dwpaoklRazIeq7y93LAv EIonoRQ3ssKUj6hvTlE9PqMMf1dVOXBtAxNT1ccmFg+qJfoJZeJCQ6FiXt8FKSSrMmqy JBcpaRlEcr0mOsPB6+fVc1ksPLVhq+SwYJzzau6ScV0pTSYtG4ESmsXaK1VjKaCNm71M r8mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=wVVCLd43; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga35-20020a1709070c2300b0078daf101aa1si6635027ejc.813.2022.12.02.08.12.12; Fri, 02 Dec 2022 08:12:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=wVVCLd43; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232839AbiLBQFu (ORCPT + 99 others); Fri, 2 Dec 2022 11:05:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232923AbiLBQFe (ORCPT ); Fri, 2 Dec 2022 11:05:34 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66E8328E04; Fri, 2 Dec 2022 08:05:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669997133; x=1701533133; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=auYuIXEr7sx+3hy79Ef3stkh0y1WDVS5g/H3HFAPPmQ=; b=wVVCLd431u+/Vtx6x4cHOGztQAwXnfH80CdcDkHry548rd9fPyp/2l4q 9yWe49hiCVMZuXIiqfVQPdbAWL+spz/o2K767v2UjbQh1PArQYeBmZXDM lHXEFbi0+sNiHY5HQWkrmFf1lFJsmZU7tPWKVZMRQIJre9C9hm5HEqPMZ 2FJ/sMGActbRNFX0OmSTL1u3MMfiAjjP326PKJSaK/3TY5ESg3NDq7kcD ln5vQDytl/nlnCcxuqkri8ZDqLpic4bHdL9B30ZhGXRSXBQaOF/lN+2uu kwxukvchOAFLl5vUOW1xjVBGSDwv2QNoaaTK/nPVn5jeG4yw72pMfg1UQ A==; X-IronPort-AV: E=Sophos;i="5.96,212,1665471600"; d="scan'208";a="186280993" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Dec 2022 09:05:32 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) 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 09:05:32 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 2 Dec 2022 09:05:31 -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 1/2] dsa: lan9303: Add port_max_mtu API Date: Fri, 2 Dec 2022 10:05:28 -0600 Message-ID: <20221202160529.30010-2-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202160529.30010-1-jerry.ray@microchip.com> References: <20221202160529.30010-1-jerry.ray@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751119358483996008?= X-GMAIL-MSGID: =?utf-8?q?1751119358483996008?= 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 93c2a3c549cb..ed8f83f3a654 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1328,6 +1328,25 @@ static int lan9303_port_mdb_del(struct dsa_switch *ds, int port, return 0; } +/* 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 = dsa_port_to_master(dsa_to_port(ds, port)); + struct lan9303 *chip = 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; + else + return 1518; +} + static const struct dsa_switch_ops lan9303_switch_ops = { .get_tag_protocol = lan9303_get_tag_protocol, .setup = lan9303_setup, @@ -1348,6 +1367,7 @@ static const struct dsa_switch_ops lan9303_switch_ops = { .port_fdb_dump = lan9303_port_fdb_dump, .port_mdb_add = lan9303_port_mdb_add, .port_mdb_del = lan9303_port_mdb_del, + .port_max_mtu = lan9303_port_max_mtu, }; static int lan9303_register_switch(struct lan9303 *chip) From patchwork Fri Dec 2 16:05:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 28960 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp946869wrr; Fri, 2 Dec 2022 08:16:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf7zJH+1WQGhH72qfuFcT70cZKeoADSY3/IIM8o/au0Ihn4/AoOf7fmduMkiueiYD/AVg7zw X-Received: by 2002:a17:906:bf2:b0:7ac:a2b7:6c97 with SMTP id z18-20020a1709060bf200b007aca2b76c97mr58838026ejg.497.1669997814486; Fri, 02 Dec 2022 08:16:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669997814; cv=none; d=google.com; s=arc-20160816; b=GpDwuu46olqA7+VyC9w43gb1foFVltid+EsAVf8IgZ+d+iT9X7kPUfrwUMCJ5diGVA R+RJkpFboHLCKzBHF9CS3rDJgz3ed0CvB5UT2c2B9NOn1nQb3tnbDN1VYSDlp5/KC7Xh CUUt5oJEX1fZLb7IcM9VKEtpfs+XZVxnUVQeexKfKrvWFF+Qyc5Okymq9kvRgkp6Wo9k cd6zZBpRm/LSJbsa6srO3swZS7Klyx4aevztaVEL0UlKz7tsXUpYA8HioJDeL8BM/26A RLcZIQJDxlGqWzs1F84KocXtqTHAA3akMZVmiz/HolQuHhXV4Me8OzMYgsHgmSJ8jK21 ryTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=42nkeY+Wp+DFpc5slG9Dbj26RNeA7l5zZiva5gftsdM=; b=Xwzf4UuOFpYyO1Mk+yycnJ+NKGTm7TjDqwqexPUMYTfIBPk1/A/ouN19FcXq5T4dt0 xm4xHOMSflogTd6IuwjiN8T95aRJOe+0I3dRTmK0lebbDZNPdczWHYEBcuPSpq6sGb9Z fOegLMW1xhVKp1NSKhbvVR349FvRuh/j/ZZxNHq+A+BcoiInlXrCBI4F/bTK54p1CXiG bM1/FGfHP2OECpuPxRzm0GSVOKRKyXKbrZHsqJ4TIvdnF9wlIrIf5R6cx9bIbwOOMA6R j1EmaGoBXJex6aj7giT2SDp8ewkNPQp5kh9Dsv4jc3d/GDvm2slisHykFQ6ojWHxDV0k kBLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ZOav4ixf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg3-20020a1709072cc300b007c0b79e51casi2705028ejc.726.2022.12.02.08.16.28; Fri, 02 Dec 2022 08:16:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ZOav4ixf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233791AbiLBQGP (ORCPT + 99 others); Fri, 2 Dec 2022 11:06:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233762AbiLBQGJ (ORCPT ); Fri, 2 Dec 2022 11:06:09 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2869F8AADE; Fri, 2 Dec 2022 08:05:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669997159; x=1701533159; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=c9PfDjNuPB6YaUdPal786fGIVEEfoGwJh+78D3mIp2k=; b=ZOav4ixfGlPD5nILboRc7/EDAFQJ+oB02YBWR+cEGoTS/poaruOrLJmp FWm85L7ncHUEMgZ8v7gKD1CoEAMelfcddSSFrUWitWXVTZrp3moC/uRAu dDY6R7bHdL4UuCwvx21CaoeX51OwIabOGUpLSB5xPjchLEOHp/aXasCn9 S1piF2Kag+utEEXiXvhpJyPqT/IupjC4SLv35njxPzOEAm3T2HBpIcf1g kdd5SgYPSO5tvilcLPP/MBQmd7m6XiwMW2bOdf9oJyFssavjITxo0ijZQ cpw/NL7S3XPGIXagtcYVoP2RtciATUUD+Y+7jze2WaguqKrC6C81zmQ4T w==; X-IronPort-AV: E=Sophos;i="5.96,212,1665471600"; d="scan'208";a="189775667" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Dec 2022 09:05:33 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) 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 09:05:33 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 2 Dec 2022 09:05:32 -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 2/2] dsa: lan9303: Move to PHYLINK Date: Fri, 2 Dec 2022 10:05:29 -0600 Message-ID: <20221202160529.30010-3-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202160529.30010-1-jerry.ray@microchip.com> References: <20221202160529.30010-1-jerry.ray@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751119495160222709?= X-GMAIL-MSGID: =?utf-8?q?1751119628535828625?= 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 ed8f83f3a654..b9b3f1b69063 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1096,42 +1096,6 @@ static int lan9303_phy_write(struct dsa_switch *ds, int phy, int regnum, return chip->ops->phy_write(chip, phy, regnum, val); } -static void lan9303_adjust_link(struct dsa_switch *ds, int port, - struct phy_device *phydev) -{ - struct lan9303 *chip = ds->priv; - int ctl; - - if (!phy_is_pseudo_fixed_link(phydev)) - return; - - ctl = lan9303_phy_read(ds, port, MII_BMCR); - - ctl &= ~BMCR_ANENABLE; - - if (phydev->speed == SPEED_100) - ctl |= BMCR_SPEED100; - else if (phydev->speed == SPEED_10) - ctl &= ~BMCR_SPEED100; - else - dev_err(ds->dev, "unsupported speed: %d\n", phydev->speed); - - if (phydev->duplex == DUPLEX_FULL) - ctl |= BMCR_FULLDPLX; - else - ctl &= ~BMCR_FULLDPLX; - - lan9303_phy_write(ds, port, MII_BMCR, ctl); - - if (port == chip->phy_addr_base) { - /* Virtual Phy: Remove Turbo 200Mbit mode */ - lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl); - - ctl &= ~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) { @@ -1328,6 +1292,41 @@ static int lan9303_port_mdb_del(struct dsa_switch *ds, int port, return 0; } +static void lan9303_phylink_get_caps(struct dsa_switch *ds, int port, + struct phylink_config *config) +{ + struct lan9303 *chip = ds->priv; + + dev_dbg(chip->dev, "%s(%d) entered.", __func__, port); + + config->mac_capabilities = 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 = 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 @@ -1353,7 +1352,7 @@ static const struct dsa_switch_ops lan9303_switch_ops = { .get_strings = lan9303_get_strings, .phy_read = lan9303_phy_read, .phy_write = lan9303_phy_write, - .adjust_link = lan9303_adjust_link, + .phylink_get_caps = lan9303_phylink_get_caps, .get_ethtool_stats = lan9303_get_ethtool_stats, .get_sset_count = lan9303_get_sset_count, .port_enable = lan9303_port_enable,