From patchwork Mon May 24 13:14:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12276201 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C85E4C2B9F7 for ; Mon, 24 May 2021 13:14:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A93FE613BC for ; Mon, 24 May 2021 13:14:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232883AbhEXNQY (ORCPT ); Mon, 24 May 2021 09:16:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232661AbhEXNQQ (ORCPT ); Mon, 24 May 2021 09:16:16 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 170F6C06138C for ; Mon, 24 May 2021 06:14:47 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id l1so41735777ejb.6 for ; Mon, 24 May 2021 06:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1Wqlk+TZ8rZk9OYrKPRVyDZXufQCwM9t3DpuLMUaIGs=; b=s4e99W2Uc8hVXqKNuizngm6eXHlUOsbymM6PnK3wmWa/bqea1zbPB3eI8Aa7E3ytfb /8FfmTcchbi4N4aAdl/B0pyl1eqBxKjwhOJtLLHuzAFZxu7cgEgF2B8+54fGubKtZ4rd Zszvigaa8Ba4obhDSBLa3eL5UKQgZcu5mDQmLlCzXDt+gflDGaSZvGZ/06bWHJHhe/29 I3rroCp+vfU3kNL2P8+K6MueXhBxg1WpP9Ft++KDi26lPWGCzzMTQi5D+6meUa3rkV2h ybLzS5VmcA4Agnc/qVrFZR+64Wdory7Tmi3pKQkYK0CCiaF7ll2UCBz6lTBZ5VBSQkTK leVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1Wqlk+TZ8rZk9OYrKPRVyDZXufQCwM9t3DpuLMUaIGs=; b=oAGRZOhZ1UEKnoIFHjWtIkcTleEoI6h3V65AINBtKQf1xIgMRsehMxJlrqPXMxTi/7 pmwdJdSl5lyYFxKj5qHdGaKQ0mh/H493oSop5amL/SfEoquufpis+Ha7+xCjFq76RLjb 6DAgnW2xjhfWlo7fTPIBVrFrcWkxOwb2RTQmb9kuKUchHwBFtc0TJDhmO1z4mzfVIncr bhTocV71wbXfD0v6Y33lPGRxG7G8xAx9/zcahtAuVZwGdZG5BMPJM8dnqfRwPmQ91Km5 YC0FKSa2Qlg5XvkcKZ5zgLnTKQt8DaXNFfdST5BVZbujqIsLsj/CeXEauJf1w4T2Uhqz uu9w== X-Gm-Message-State: AOAM5328WH1zDcivL434RjWj722UaJHwS/VC6PZRBzRIubTfFwmU2oPL Dz8bsIp5tiuQVGfi63HcFnYs84oUAIo= X-Google-Smtp-Source: ABdhPJxd4kTxkqzTKcVbLtBaDo2dUKrTlrJ6OID1nUB0oDItMCY2m4PeZyey6cDzg0gV+xPKzdfRBQ== X-Received: by 2002:a17:906:5786:: with SMTP id k6mr22640101ejq.198.1621862085735; Mon, 24 May 2021 06:14:45 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id g13sm8009139ejz.24.2021.05.24.06.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 06:14:45 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 4/9] net: dsa: sja1105: don't assign the host port using dsa_upstream_port() Date: Mon, 24 May 2021 16:14:16 +0300 Message-Id: <20210524131421.1030789-5-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210524131421.1030789-1-olteanv@gmail.com> References: <20210524131421.1030789-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean If @port is unused, then dsa_upstream_port(ds, port) returns @port, which means we cannot assume the CPU port can be retrieved this way. The sja1105 switches support a single CPU port, so just iterate over the switch ports and stop at the first CPU port we see. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 5d5f6555dbac..4a81b1b1cef3 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -556,7 +556,7 @@ static int sja1105_init_general_params(struct sja1105_private *priv) * receieved on host_port itself would be dropped, except * by installing a temporary 'management route' */ - .host_port = dsa_upstream_port(priv->ds, 0), + .host_port = priv->ds->num_ports, /* Default to an invalid value */ .mirr_port = priv->ds->num_ports, /* Link-local traffic received on casc_port will be forwarded @@ -579,7 +579,16 @@ static int sja1105_init_general_params(struct sja1105_private *priv) .tpid = ETH_P_SJA1105, .tpid2 = ETH_P_SJA1105, }; + struct dsa_switch *ds = priv->ds; struct sja1105_table *table; + int port; + + for (port = 0; port < ds->num_ports; port++) { + if (dsa_is_cpu_port(ds, port)) { + default_general_params.host_port = port; + break; + } + } table = &priv->static_config.tables[BLK_IDX_GENERAL_PARAMS];