From nobody Mon Jun 22 15:21:54 2026 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 1271AC433EF for ; Tue, 22 Mar 2022 02:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235412AbiCVCR0 (ORCPT ); Mon, 21 Mar 2022 22:17:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235335AbiCVCRS (ORCPT ); Mon, 21 Mar 2022 22:17:18 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D31042CC90; Mon, 21 Mar 2022 19:14:36 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id d7so23031059wrb.7; Mon, 21 Mar 2022 19:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hyvJRbfKxlg2y69YT+CiBgV+yqgpLzyV8qlpvq+PDbg=; b=fPlYrW3lEWxPGhExEY0FPOc+5597vX5Ze1AMtuGnNwSiMwMFKaoWT2AtTcT1ZUC5AN ey92qTFeO/is6kH4Afx2mFCZtlpRjuhyZj1E5/O1UUQPXC0lIVEg/BMmn2mBlmygWbQB +4O0JzeEPDLwU/JorvEiRUj7SISTOfQ/e7NtIZZETXbHVipc3ltwP8PL55MKMb2GSitx Me+V5HqnvQUk6As5AgMfixBwlVrFJWcjanu33Tl075Ox9VVvYoLoMbwfx/PhoTzRcLXh HD9/QCZdbxD5pZnnC1VbxCXkOKL7NmZkm/w1bQ1b+LCWJ6NtvXhkuC+j3lKljvyhJyYe HwtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hyvJRbfKxlg2y69YT+CiBgV+yqgpLzyV8qlpvq+PDbg=; b=wbBdeTRqf6qVMo9MIqMMGhOCgK99RbVujvR8JLuXGem2MUsDrvaAkETIdvOBEE833S CmuHxjDMDfovhMkrZJVnjjiHhsz3I2Szlflh02TxRL7tOC+cdk/ny4Epa6po+vib+Gdq i6OgSfs4CGDMtqgo59zCUb1Ou+OzVWfiislL/fhvKx2dieLey1Ffyj1fd24CwKCL/k7N 47RFog5rSI4OVW6TGEwg0OFQL173KA6f5rT047WF/Olsfzxr8H2PvRdSA5Cb5c4nCB9b z5iz7YRRDvihFoIBGYJpra18sx0p5fUk1nrkLF4qEt+TYIZ6Ao1UEkckyH1/gnZDSQ5j sYiQ== X-Gm-Message-State: AOAM533oc/RT8ngglPBtofGLsfJkrJRZgcIjXBKTMC7icYViYkWQoazD ++gkemaqVOqDwIPDHZCyB6Y= X-Google-Smtp-Source: ABdhPJyKPXinkzLhE2TVWtg7EdI6mzLiLuaTWKaStQnXXZdWD5dyEEy+WChDd/GGWQEbarYtSxSjIg== X-Received: by 2002:a5d:6c69:0:b0:203:78af:48b2 with SMTP id r9-20020a5d6c69000000b0020378af48b2mr19914900wrz.123.1647915275224; Mon, 21 Mar 2022 19:14:35 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-69-170.ip85.fastwebnet.it. [93.42.69.170]) by smtp.googlemail.com with ESMTPSA id m2-20020a056000024200b00205718e3a3csm177968wrz.2.2022.03.21.19.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 19:14:34 -0700 (PDT) From: Ansuel Smith To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ansuel Smith Subject: [net-next PATCH 1/4] drivers: net: dsa: qca8k: drop MTU tracking from qca8k_priv Date: Tue, 22 Mar 2022 02:45:03 +0100 Message-Id: <20220322014506.27872-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220322014506.27872-1-ansuelsmth@gmail.com> References: <20220322014506.27872-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Drop the MTU array from qca8k_priv and use slave net dev to get the max MTU across all user port. CPU port can be skipped as DSA already make sure CPU port are set to the max MTU across all ports. Signed-off-by: Ansuel Smith --- drivers/net/dsa/qca8k.c | 38 +++++++++++++++++++++++--------------- drivers/net/dsa/qca8k.h | 1 - 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index d3ed0a7f8077..4366d87b4bbd 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -2367,13 +2367,31 @@ static int qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu) { struct qca8k_priv *priv =3D ds->priv; - int i, mtu =3D 0; + struct dsa_port *dp; + int mtu =3D new_mtu; =20 - priv->port_mtu[port] =3D new_mtu; + /* We have only have a general MTU setting. So check + * every port and set the max across all port. + */ + list_for_each_entry(dp, &ds->dst->ports, list) { + /* We can ignore cpu port, DSA will itself chose + * the max MTU across all port + */ + if (!dsa_port_is_user(dp)) + continue; =20 - for (i =3D 0; i < QCA8K_NUM_PORTS; i++) - if (priv->port_mtu[i] > mtu) - mtu =3D priv->port_mtu[i]; + if (dp->index =3D=3D port) + continue; + + /* Address init phase where not every port have + * a slave device + */ + if (!dp->slave) + continue; + + if (mtu < dp->slave->mtu) + mtu =3D dp->slave->mtu; + } =20 /* Include L2 header / FCS length */ return qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, mtu + ETH_HLEN + ETH_FCS_L= EN); @@ -3033,16 +3051,6 @@ qca8k_setup(struct dsa_switch *ds) QCA8K_PORT_HOL_CTRL1_WRED_EN, mask); } - - /* Set initial MTU for every port. - * We have only have a general MTU setting. So track - * every port and set the max across all port. - * Set per port MTU to 1500 as the MTU change function - * will add the overhead and if its set to 1518 then it - * will apply the overhead again and we will end up with - * MTU of 1536 instead of 1518 - */ - priv->port_mtu[i] =3D ETH_DATA_LEN; } =20 /* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */ diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h index f375627174c8..562d75997e55 100644 --- a/drivers/net/dsa/qca8k.h +++ b/drivers/net/dsa/qca8k.h @@ -398,7 +398,6 @@ struct qca8k_priv { struct device *dev; struct dsa_switch_ops ops; struct gpio_desc *reset_gpio; - unsigned int port_mtu[QCA8K_NUM_PORTS]; struct net_device *mgmt_master; /* Track if mdio/mib Ethernet is availabl= e */ struct qca8k_mgmt_eth_data mgmt_eth_data; struct qca8k_mib_eth_data mib_eth_data; --=20 2.34.1 From nobody Mon Jun 22 15:21:54 2026 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 DB95BC433EF for ; Tue, 22 Mar 2022 02:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235378AbiCVCRX (ORCPT ); Mon, 21 Mar 2022 22:17:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235328AbiCVCRS (ORCPT ); Mon, 21 Mar 2022 22:17:18 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D94D62CCA8; Mon, 21 Mar 2022 19:14:37 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id n35so7949907wms.5; Mon, 21 Mar 2022 19:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pQbf7iGYZbf1aURiBPER2SslgHTAcNmDZn6J10o+zx8=; b=QgjoZXxW9XjeJx6tl7jhthMRCN1yYSuJTVOXtqzVquvaPAH7PV6ReENpXpJR1N/+E5 xOT+DSg8iutJnstH/tbQ3do6ODVMEOlbvnWitx0w2QeLk2w3atiXl6uRyJ2ip88Aakay sB+TU5Z3wos/Lp4sLWa6/5N1CQ+PBJod7eruIbW16p2ICFjmZdM1hEb0QzEanWlui5+x bSraMhWJKN8Kw/Y3XXOJJfIyu+ylVayaa1tRotEm4Dpw19RSTqTiXyzbgKe644Ylh7pI nzfkQqlNsLw7n8KxFfxzirldF1re656/R3AnHOxSVDMap75JN/8Q88vpYeyHZ9y9fUtj d8YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pQbf7iGYZbf1aURiBPER2SslgHTAcNmDZn6J10o+zx8=; b=3fuw+/4coEZOPrnJZV0Y6CUc2izrLpHWw02KDpzAwLAJ1K6aDMuAF8fCtL3s4FFEX6 A8cMUj6U0e4W/irNRIlBBABe+lK5vdzqnAbSk1WnjxeDnuifZlg2bXcTfLZ+7OtHOQ+x guUY3e3LuCi663/veDDz04WvtvK6/VzxoIDS++KrA34YoTeQ/SPVPkv/z1L6naguA02n 6nSfahThkWxIUZbnH5fznOxn8XZp7WyWp9LsuL68d74T3B6x/sQz3tMtl6Bn6KCTTCnn dfLR55hlfFjROMdpg1uqKCJt5WcFHLg7Um4bZfTw4E/0/JbHGdS6QdIqEhkNR9uj1ZIF yCTA== X-Gm-Message-State: AOAM5315cBhoGBRusRvPi+if9/S3NbveL4HnVJxJ+mKODtIWrRsdlvbf xJsQCU39ylbyMniUd5RoswM= X-Google-Smtp-Source: ABdhPJxkutwPB2uel9GTM0z0PMGhFRA5Hs+vtTTJs07jpj9cMnEY7AqD/3joAw+ZAX8rVmVlodX4Og== X-Received: by 2002:a05:600c:1c1e:b0:38c:b393:b355 with SMTP id j30-20020a05600c1c1e00b0038cb393b355mr1579417wms.92.1647915276351; Mon, 21 Mar 2022 19:14:36 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-69-170.ip85.fastwebnet.it. [93.42.69.170]) by smtp.googlemail.com with ESMTPSA id m2-20020a056000024200b00205718e3a3csm177968wrz.2.2022.03.21.19.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 19:14:35 -0700 (PDT) From: Ansuel Smith To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ansuel Smith Subject: [net-next PATCH 2/4] drivers: net: dsa: qca8k: drop port_sts from qca8k_priv Date: Tue, 22 Mar 2022 02:45:04 +0100 Message-Id: <20220322014506.27872-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220322014506.27872-1-ansuelsmth@gmail.com> References: <20220322014506.27872-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Port_sts is a thing of the past for this driver. It was something present on the initial implementation of this driver and parts of the original struct were dropped over time. Using an array of int to store if a port is enabled or not to handle PM operation seems overkill. Switch and use a simple u8 to store the port status where each bit correspond to a port. (bit is set port is enabled, bit is not set, port is disabled) Also add some comments to better describe why we need to track port status. Signed-off-by: Ansuel Smith --- drivers/net/dsa/qca8k.c | 15 +++++++++------ drivers/net/dsa/qca8k.h | 9 ++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 4366d87b4bbd..33cedae6875c 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -2346,7 +2346,7 @@ qca8k_port_enable(struct dsa_switch *ds, int port, struct qca8k_priv *priv =3D (struct qca8k_priv *)ds->priv; =20 qca8k_port_set_status(priv, port, 1); - priv->port_sts[port].enabled =3D 1; + priv->port_enabled_map |=3D BIT(port); =20 if (dsa_is_user_port(ds, port)) phy_support_asym_pause(phy); @@ -2360,7 +2360,7 @@ qca8k_port_disable(struct dsa_switch *ds, int port) struct qca8k_priv *priv =3D (struct qca8k_priv *)ds->priv; =20 qca8k_port_set_status(priv, port, 0); - priv->port_sts[port].enabled =3D 0; + priv->port_enabled_map &=3D ~BIT(port); } =20 static int @@ -3251,13 +3251,16 @@ static void qca8k_sw_shutdown(struct mdio_device *m= diodev) static void qca8k_set_pm(struct qca8k_priv *priv, int enable) { - int i; + int port; =20 - for (i =3D 0; i < QCA8K_NUM_PORTS; i++) { - if (!priv->port_sts[i].enabled) + for (port =3D 0; port < QCA8K_NUM_PORTS; port++) { + /* Do not enable on resume if the port was + * disabled before. + */ + if (!(priv->port_enabled_map & BIT(port))) continue; =20 - qca8k_port_set_status(priv, i, enable); + qca8k_port_set_status(priv, port, enable); } } =20 diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h index 562d75997e55..12d8d090298b 100644 --- a/drivers/net/dsa/qca8k.h +++ b/drivers/net/dsa/qca8k.h @@ -324,10 +324,6 @@ enum qca8k_mid_cmd { QCA8K_MIB_CAST =3D 3, }; =20 -struct ar8xxx_port_status { - int enabled; -}; - struct qca8k_match_data { u8 id; bool reduced_package; @@ -388,11 +384,14 @@ struct qca8k_priv { u8 mirror_rx; u8 mirror_tx; u8 lag_hash_mode; + /* Each bit correspond to a port. This switch can support a max of 7 port. + * Bit 1: port enabled. Bit 0: port disabled. + */ + u8 port_enabled_map; bool legacy_phy_port_mapping; struct qca8k_ports_config ports_config; struct regmap *regmap; struct mii_bus *bus; - struct ar8xxx_port_status port_sts[QCA8K_NUM_PORTS]; struct dsa_switch *ds; struct mutex reg_mutex; struct device *dev; --=20 2.34.1 From nobody Mon Jun 22 15:21:54 2026 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 B2483C433FE for ; Tue, 22 Mar 2022 02:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235435AbiCVCRc (ORCPT ); Mon, 21 Mar 2022 22:17:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235353AbiCVCRT (ORCPT ); Mon, 21 Mar 2022 22:17:19 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D833F2FE7B; Mon, 21 Mar 2022 19:14:38 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id r7so9569623wmq.2; Mon, 21 Mar 2022 19:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z3EHoLJoSdzFCxSSo9kxKkBKm6UfZf/in6VghFV4gQE=; b=d9clNh88Xr03OWNXSryyPsUu7GQexZqKUYuDy/oH/5eye9sCkvxSTnxCg3Ol5ZrH0V pXdUT84HdORYPMiPPK8m7MpX0GoFTDL+tqCxgEEOZEHS24MQiUhEY0rcELziUuzLS7aj /+p3Xwjss4+n9IcCEAARwlGHIxf/eqBt/KupOJwmaQseT/9Iiq2ij7eARuysk/yCDIpt Bid025XDDvLy/7A+G8Fw3CFy5F/rEn/6IwLTIPEfSpNTsYL7GfoQrudnm4GRVk60L8JL n4ZoMc5DvmczW5CmedvcToy/d68qoeiKFbGopQpYmet95AUVfoHQLb/QHvK8VKcJBauQ 7Hwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z3EHoLJoSdzFCxSSo9kxKkBKm6UfZf/in6VghFV4gQE=; b=2AszPburtKXoccoI0PP6lHYAshio+Jtf/NTMnOUjeIss1xIxkSo/qY+rkyxXK/XTHf CfOikAOlF8Uea7AmXOYdkfMMMiTOasDhzHUWMbO7T9VzGTo1084239ntQV7HwypQSXo7 90oUzbNPnv5X7zxp3yspW/AkhNmaTztGvS9kKcoZaL0UcF7HOCFbudnWNeUgzOjZyksO bBduMTsRlDJWV9Y/NknaRyK4oKNenQHXy6QkyVp85r7LdvDJgEF/7NPe3rXce/mpBp25 ZMjAdRq0jh8jY13OVdBGRmIH3lltif+dSDYo6kV4OLJozp+Rga3GMC4iiNmi7A7qyeFa J/4Q== X-Gm-Message-State: AOAM530uTNIV1GkI97/Z+eGybjQb8aeZTlAlFTNWCUNcACRgjk3/q5R5 yOjJZKYGQjIPfY5Gbfl8AuQ= X-Google-Smtp-Source: ABdhPJyd1cR6WcigOKTNAosO0LAEfPzN5vrG4Cw1QMVgbLX5MGTk/apdZEzwzn5uHBe4EMw90yVi2Q== X-Received: by 2002:a1c:f211:0:b0:381:6c60:742f with SMTP id s17-20020a1cf211000000b003816c60742fmr1654204wmc.130.1647915277340; Mon, 21 Mar 2022 19:14:37 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-69-170.ip85.fastwebnet.it. [93.42.69.170]) by smtp.googlemail.com with ESMTPSA id m2-20020a056000024200b00205718e3a3csm177968wrz.2.2022.03.21.19.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 19:14:37 -0700 (PDT) From: Ansuel Smith To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ansuel Smith Subject: [net-next PATCH 3/4] drivers: net: dsa: qca8k: rework and simplify mdiobus logic Date: Tue, 22 Mar 2022 02:45:05 +0100 Message-Id: <20220322014506.27872-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220322014506.27872-1-ansuelsmth@gmail.com> References: <20220322014506.27872-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In an attempt to reduce qca8k_priv space, rework and simplify mdiobus logic. We now declare a mdiobus instead of relying on DSA phy_read/write even if a mdio node is not present. This is all to make the qca8k ops static and not switch specific. With a legacy implementation where port doesn't have a phy map declared in the dts with a mdio node, we declare a 'qca8k-legacy' mdiobus. The conversion logic is used as legacy read and write ops are used instead of the internal one. While at it also improve the bus id to support multiple switch. Also drop the legacy_phy_port_mapping as we now declare mdiobus with ops that already address the workaround. Signed-off-by: Ansuel Smith --- drivers/net/dsa/qca8k.c | 101 ++++++++++++++-------------------------- drivers/net/dsa/qca8k.h | 1 - 2 files changed, 34 insertions(+), 68 deletions(-) diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 33cedae6875c..c837444d37f6 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -1287,87 +1287,71 @@ qca8k_internal_mdio_read(struct mii_bus *slave_bus,= int phy, int regnum) if (ret >=3D 0) return ret; =20 - return qca8k_mdio_read(priv, phy, regnum); + ret =3D qca8k_mdio_read(priv, phy, regnum); + + if (ret < 0) + return 0xffff; + + return ret; } =20 static int -qca8k_phy_write(struct dsa_switch *ds, int port, int regnum, u16 data) +qca8k_legacy_mdio_write(struct mii_bus *slave_bus, int port, int regnum, u= 16 data) { - struct qca8k_priv *priv =3D ds->priv; - int ret; - - /* Check if the legacy mapping should be used and the - * port is not correctly mapped to the right PHY in the - * devicetree - */ - if (priv->legacy_phy_port_mapping) - port =3D qca8k_port_to_phy(port) % PHY_MAX_ADDR; - - /* Use mdio Ethernet when available, fallback to legacy one on error */ - ret =3D qca8k_phy_eth_command(priv, false, port, regnum, 0); - if (!ret) - return ret; + port =3D qca8k_port_to_phy(port) % PHY_MAX_ADDR; =20 - return qca8k_mdio_write(priv, port, regnum, data); + return qca8k_internal_mdio_write(slave_bus, port, regnum, data); } =20 static int -qca8k_phy_read(struct dsa_switch *ds, int port, int regnum) +qca8k_legacy_mdio_read(struct mii_bus *slave_bus, int port, int regnum) { - struct qca8k_priv *priv =3D ds->priv; - int ret; - - /* Check if the legacy mapping should be used and the - * port is not correctly mapped to the right PHY in the - * devicetree - */ - if (priv->legacy_phy_port_mapping) - port =3D qca8k_port_to_phy(port) % PHY_MAX_ADDR; - - /* Use mdio Ethernet when available, fallback to legacy one on error */ - ret =3D qca8k_phy_eth_command(priv, true, port, regnum, 0); - if (ret >=3D 0) - return ret; - - ret =3D qca8k_mdio_read(priv, port, regnum); - - if (ret < 0) - return 0xffff; + port =3D qca8k_port_to_phy(port) % PHY_MAX_ADDR; =20 - return ret; + return qca8k_internal_mdio_read(slave_bus, port, regnum); } =20 static int -qca8k_mdio_register(struct qca8k_priv *priv, struct device_node *mdio) +qca8k_mdio_register(struct qca8k_priv *priv) { struct dsa_switch *ds =3D priv->ds; + struct device_node *mdio; struct mii_bus *bus; =20 bus =3D devm_mdiobus_alloc(ds->dev); - if (!bus) return -ENOMEM; =20 bus->priv =3D (void *)priv; - bus->name =3D "qca8k slave mii"; - bus->read =3D qca8k_internal_mdio_read; - bus->write =3D qca8k_internal_mdio_write; - snprintf(bus->id, MII_BUS_ID_SIZE, "qca8k-%d", - ds->index); - + snprintf(bus->id, MII_BUS_ID_SIZE, "qca8k-%d.%d", + ds->dst->index, ds->index); bus->parent =3D ds->dev; bus->phy_mask =3D ~ds->phys_mii_mask; - ds->slave_mii_bus =3D bus; =20 - return devm_of_mdiobus_register(priv->dev, bus, mdio); + /* Check if the devicetree declare the port:phy mapping */ + mdio =3D of_get_child_by_name(priv->dev->of_node, "mdio"); + if (of_device_is_available(mdio)) { + bus->name =3D "qca8k slave mii"; + bus->read =3D qca8k_internal_mdio_read; + bus->write =3D qca8k_internal_mdio_write; + return devm_of_mdiobus_register(priv->dev, bus, mdio); + } + + /* If a mapping can't be found the legacy mapping is used, + * using the qca8k_port_to_phy function + */ + bus->name =3D "qca8k-legacy slave mii"; + bus->read =3D qca8k_legacy_mdio_read; + bus->write =3D qca8k_legacy_mdio_write; + return devm_mdiobus_register(priv->dev, bus); } =20 static int qca8k_setup_mdio_bus(struct qca8k_priv *priv) { u32 internal_mdio_mask =3D 0, external_mdio_mask =3D 0, reg; - struct device_node *ports, *port, *mdio; + struct device_node *ports, *port; phy_interface_t mode; int err; =20 @@ -1429,24 +1413,7 @@ qca8k_setup_mdio_bus(struct qca8k_priv *priv) QCA8K_MDIO_MASTER_EN); } =20 - /* Check if the devicetree declare the port:phy mapping */ - mdio =3D of_get_child_by_name(priv->dev->of_node, "mdio"); - if (of_device_is_available(mdio)) { - err =3D qca8k_mdio_register(priv, mdio); - if (err) - of_node_put(mdio); - - return err; - } - - /* If a mapping can't be found the legacy mapping is used, - * using the qca8k_port_to_phy function - */ - priv->legacy_phy_port_mapping =3D true; - priv->ops.phy_read =3D qca8k_phy_read; - priv->ops.phy_write =3D qca8k_phy_write; - - return 0; + return qca8k_mdio_register(priv); } =20 static int diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h index 12d8d090298b..8bbe36f135b5 100644 --- a/drivers/net/dsa/qca8k.h +++ b/drivers/net/dsa/qca8k.h @@ -388,7 +388,6 @@ struct qca8k_priv { * Bit 1: port enabled. Bit 0: port disabled. */ u8 port_enabled_map; - bool legacy_phy_port_mapping; struct qca8k_ports_config ports_config; struct regmap *regmap; struct mii_bus *bus; --=20 2.34.1 From nobody Mon Jun 22 15:21:54 2026 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 C6351C433F5 for ; Tue, 22 Mar 2022 02:16:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235335AbiCVCRg (ORCPT ); Mon, 21 Mar 2022 22:17:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235370AbiCVCRW (ORCPT ); Mon, 21 Mar 2022 22:17:22 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCEB8245B5; Mon, 21 Mar 2022 19:14:39 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id h4so5070524wrc.13; Mon, 21 Mar 2022 19:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4e4qPKq8sPq7QTzJDHmma/b/Tofj4GtIBeiWbSSZTeU=; b=YNZ5DgH6/1NoZacr7qT+3PEBFsjWiYDKBXmU7Asw57xhxohy6dB4I7hzagd9h5XpN6 u72wALuNNgpg0bmdLZGl+YSLdHR5Isye4A9yBDQs1NT8XJINE9fL+qEVXfwzb2UTQmlt qUdfk0sDQKJocGUWvGTtFA/QHZ0sYMBVMv6G6M/lJFe16BELEBpK51ESljWmHZEeWgH9 NocZx6981JPByVBQFQ5ZJxWSeS9i6V3+Q7Ldvs3CpMJ27Q17ihZECAcvFNrfq8pGQPum bPbpKUubJJq2F+q3f9SGPZ9e/Hd0lEIM9zg5yGEW+DTp0xGkUT+rzR9eWehdeWJXNTFO JPEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4e4qPKq8sPq7QTzJDHmma/b/Tofj4GtIBeiWbSSZTeU=; b=p8Eoj+mazcNajT8VutL3XrjSNxXdbNk76AbQcu3dhq8JzNGuttfGBAD0eJtKj0BCGE I8fkM8pTmXnauLzoID0PmClbW+kQA0VueZv+sotvtD9L4hjpGoHGCscRvH+U51WYo6R5 8PdFEODPcly9qvXWiJed0rlmdvJceFzyk7IYs7gIkwGOpwdj13pxdGgRUvShbhcjTQeg 3RhdW+q0uOEhK0XyN8f24C/Kv1nayTh0zyscEfKPBuXfmPH4Ic+lrJWyHKS0c5AccIxU crcawVi2OrkImsy39QtMuxs8DS1cFMqVry8/9NTAvxsj1P7VM06CDGShA0l8/S2lnxsT ZIpQ== X-Gm-Message-State: AOAM533USzFgNnYCuDKaQ2w9kIg7Yt1PjFzC6odH8PVbtDtYNU77RtXZ uBEntJ9Qp1xX+tsovRuhjZM= X-Google-Smtp-Source: ABdhPJwVqBIAkIhwQPknJL4WIrRPIV67cJTRB6J0Dl+eIow16WwcWdXgO9Mv1abtugRBvKjBOyMTMQ== X-Received: by 2002:a5d:4491:0:b0:203:f63a:e89b with SMTP id j17-20020a5d4491000000b00203f63ae89bmr14937568wrq.342.1647915278309; Mon, 21 Mar 2022 19:14:38 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-69-170.ip85.fastwebnet.it. [93.42.69.170]) by smtp.googlemail.com with ESMTPSA id m2-20020a056000024200b00205718e3a3csm177968wrz.2.2022.03.21.19.14.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 19:14:38 -0700 (PDT) From: Ansuel Smith To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ansuel Smith Subject: [net-next PATCH 4/4] drivers: net: dsa: qca8k: drop dsa_switch_ops from qca8k_priv Date: Tue, 22 Mar 2022 02:45:06 +0100 Message-Id: <20220322014506.27872-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220322014506.27872-1-ansuelsmth@gmail.com> References: <20220322014506.27872-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Now that dsa_switch_ops is not switch specific anymore, we can drop it from qca8k_priv and use the static ops directly for the dsa_switch pointer. Signed-off-by: Ansuel Smith --- drivers/net/dsa/qca8k.c | 3 +-- drivers/net/dsa/qca8k.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index c837444d37f6..38567080e7b3 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -3177,8 +3177,7 @@ qca8k_sw_probe(struct mdio_device *mdiodev) priv->ds->dev =3D &mdiodev->dev; priv->ds->num_ports =3D QCA8K_NUM_PORTS; priv->ds->priv =3D priv; - priv->ops =3D qca8k_switch_ops; - priv->ds->ops =3D &priv->ops; + priv->ds->ops =3D &qca8k_switch_ops; mutex_init(&priv->reg_mutex); dev_set_drvdata(&mdiodev->dev, priv); =20 diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h index 8bbe36f135b5..04408e11402a 100644 --- a/drivers/net/dsa/qca8k.h +++ b/drivers/net/dsa/qca8k.h @@ -394,7 +394,6 @@ struct qca8k_priv { struct dsa_switch *ds; struct mutex reg_mutex; struct device *dev; - struct dsa_switch_ops ops; struct gpio_desc *reset_gpio; struct net_device *mgmt_master; /* Track if mdio/mib Ethernet is availabl= e */ struct qca8k_mgmt_eth_data mgmt_eth_data; --=20 2.34.1