Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3179408imw; Mon, 11 Jul 2022 03:40:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s60pp0rm4CsIfip/ILNe/iTNp65os1CbXeshIO7Bfb62bIQqpHbsM4MEKE+lRUrIhy99JW X-Received: by 2002:a17:903:228b:b0:16b:edb1:a609 with SMTP id b11-20020a170903228b00b0016bedb1a609mr17556179plh.77.1657536042509; Mon, 11 Jul 2022 03:40:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657536042; cv=none; d=google.com; s=arc-20160816; b=yFleQAmPl61qp+CyYBBPlWjoEMzJX/OOCB1oxclAnXO/deuFnr69xef4lsgx4vUWXm w37fE37Z9Ior60Nyb+xzIYzLVjqCqTqf6HX+DtqRVLfApxnWCdfFNEvMO7Rr1xHCpJDu 1Cv+kq/7Pe/pkv2jHT2LKhwIOlEKxbflf+rfUEWia2QZCuKErDfaTlRHJQczyuzts91u 4ryTxYXLiMPPehvDUaWqrnQIIOaGF9Iq5UUMSlJv+rUm0hcpFMrtcIextgI5vb++pg9x YEqun98zopPXoLczdEi0C8dDinpxCgrNiqwPTRhtDCJnsjM+SBzPcwAQE9bTDSk6IMQA Wb/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oAKoPMe/PnQFSCICQ/psnfINwQRMnxQmBUlCRzHMQXM=; b=UqDAM++ocLLJ29+xan7AfjuTYbVeFvaQgjfThOuaAwRD73EqP3evl+9GRxEU8hYHl5 7tQIqXOEk2R8imiC7nbDexb5zzrOwXBSIQhhHFpn4bkSJN9CWrtUfLcr/bUQFw6dgm1/ UsgaG0L+e2VgrNvArNwKb5wb7v+dbFuM68nmRyOgYhdgyWEwLnvAahMYJFvjRvfYJP9x umKcLmk/6fXx2X0Uzx5c8b91WdN/eGpplu2s+Rkbok8y8RE39EhatuyLpeD0rP9v5zXc hFMLBNr6TIfRXQo9ZBuBGgdWy+9yRIQqUs7CRg++IiPMi3p3hJRxs63Z410B/T9EGXRe lmUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MaxrDC+B; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a170902690800b0016c0569c012si8165159plk.588.2022.07.11.03.40.30; Mon, 11 Jul 2022 03:40:42 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=MaxrDC+B; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232272AbiGKJ24 (ORCPT + 99 others); Mon, 11 Jul 2022 05:28:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232461AbiGKJ2T (ORCPT ); Mon, 11 Jul 2022 05:28:19 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A22166AF1; Mon, 11 Jul 2022 02:15:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id C600FCE1260; Mon, 11 Jul 2022 09:15:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D75CDC34115; Mon, 11 Jul 2022 09:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657530952; bh=/sbOSX3Pnsxhpi+1YjZXiP7EM8K6cK3NsOE1FwYeRFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MaxrDC+BrL36d47/jbDs+ajZ3SSgeCtpAxmOsv5D/XVui+7Yow35ffNB9wcrb2fYm 6ovIl5UIcleIAnBs703pFpZ8Dd6RiwFbHDoHvXzvbnfBag5nnTNRFpaon6nJVzl+mF vdYQJS/zXee0m5uZP8Cy2vx+3SAJVK1FXBZ++yPY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Marangi , Jakub Kicinski Subject: [PATCH 5.18 044/112] net: dsa: qca8k: reset cpu port on MTU change Date: Mon, 11 Jul 2022 11:06:44 +0200 Message-Id: <20220711090550.823175937@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090549.543317027@linuxfoundation.org> References: <20220711090549.543317027@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Christian Marangi commit 386228c694bf1e7a7688e44412cb33500b0ac585 upstream. It was discovered that the Documentation lacks of a fundamental detail on how to correctly change the MAX_FRAME_SIZE of the switch. In fact if the MAX_FRAME_SIZE is changed while the cpu port is on, the switch panics and cease to send any packet. This cause the mgmt ethernet system to not receive any packet (the slow fallback still works) and makes the device not reachable. To recover from this a switch reset is required. To correctly handle this, turn off the cpu ports before changing the MAX_FRAME_SIZE and turn on again after the value is applied. Fixes: f58d2598cf70 ("net: dsa: qca8k: implement the port MTU callbacks") Cc: stable@vger.kernel.org Signed-off-by: Christian Marangi Link: https://lore.kernel.org/r/20220621151122.10220-1-ansuelsmth@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/qca8k.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -2372,7 +2372,7 @@ static int qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu) { struct qca8k_priv *priv = ds->priv; - int i, mtu = 0; + int ret, i, mtu = 0; priv->port_mtu[port] = new_mtu; @@ -2380,8 +2380,27 @@ qca8k_port_change_mtu(struct dsa_switch if (priv->port_mtu[i] > mtu) mtu = priv->port_mtu[i]; + /* To change the MAX_FRAME_SIZE the cpu ports must be off or + * the switch panics. + * Turn off both cpu ports before applying the new value to prevent + * this. + */ + if (priv->port_sts[0].enabled) + qca8k_port_set_status(priv, 0, 0); + + if (priv->port_sts[6].enabled) + qca8k_port_set_status(priv, 6, 0); + /* Include L2 header / FCS length */ - return qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, mtu + ETH_HLEN + ETH_FCS_LEN); + ret = qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, mtu + ETH_HLEN + ETH_FCS_LEN); + + if (priv->port_sts[0].enabled) + qca8k_port_set_status(priv, 0, 1); + + if (priv->port_sts[6].enabled) + qca8k_port_set_status(priv, 6, 1); + + return ret; } static int