Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5920144iob; Tue, 10 May 2022 06:45:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsBQOtbO8q4poJngrMbIo3QrD7MzNflU9Lba1g+8XKpGp6cbg3eAA43WN7U+uG4xkkW6Fz X-Received: by 2002:a05:6638:4189:b0:32b:a06a:b007 with SMTP id az9-20020a056638418900b0032ba06ab007mr9983240jab.101.1652190315974; Tue, 10 May 2022 06:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652190315; cv=none; d=google.com; s=arc-20160816; b=jpYbudU03g+XgbrufUT9JLCb4Eq9JP73biQEuqSNjB6HENS8bmufcvdZ5FdIXqqOjx i5LV7kYsidIQESomT5RS8sx9HfTZWllDRF+cu0eO65w8sJvNxsjV0C0w4pznJKosiw8Q FIPNk4rEX0E5wS/3Hx4PVeBUqeOAdgWEjYuF1xMDs6DCTYN8ABx4SJqhl7qxo2C/Dyhl Mlw664q8z0XnyI5pehnD65NddhkCXbRnFYFVGbHYKzET4clpty4JJOFtenNBhM7HTrHd kMKTCGtR2wWzw2I/9lB9aBK9d7yfgNmK/esgqv7kVhmsVtrfgC1gNpcKLdkrOo2xJ8yv jRNQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=mCs9O3RJG01sw6qsZslsu692hG4UQ4nY/c7ZXZYpQ7k=; b=08qEJbw7R79CaB9L10U27bFywe9X0+SLnVv7XB+8hG98lKbq0WGtg9v216iA6BlIEs qKYDIVtS7hF8OQHj6cQCIVXF+nPOz4vCrM5bejqpIodjNX1bwmiaHDHRsmAb0FnKMmie Jo0RujMtjVrRk254J2FaxVcYiZOmXU3U2m2RnDEvLufI8dFJ5NPy+UmjU0X9WxgnWK7s lbBcyuDKVFwa/1gViT9rJZCdRUSOBtBX+wx5OQlAx+5CikJWQ/cIP7FxRHQ73RdRNlgh sIs5XuDyfdY1BDWHybJYUQS8vaWoZ/yV9jAT5AHip+dmO000FKB3adbBCd5FKzYJrYAc oslw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b="YA/qQ9JB"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o21-20020a056638269500b0032dbc671736si4581051jat.113.2022.05.10.06.45.01; Tue, 10 May 2022 06:45:15 -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=fail header.i=@nbd.name header.s=20160729 header.b="YA/qQ9JB"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239066AbiEJJol (ORCPT + 99 others); Tue, 10 May 2022 05:44:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232557AbiEJJok (ORCPT ); Tue, 10 May 2022 05:44:40 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F29BFE49; Tue, 10 May 2022 02:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=mCs9O3RJG01sw6qsZslsu692hG4UQ4nY/c7ZXZYpQ7k=; b=YA/qQ9JBLeM2/t9UBwl7vdtyKP fPVHEg/CLYnZKaPDVcnlMphhcN657ekRTJ5EvsJc4XP6wroRqsrh4D0TdYh71PLCDeP32jCRU/GK4 GEK0f7TrBABDVp/03sBk8odbSJHkMolZz+RgOLtmeLy+bASDC9ja//Hnt7T6tiyeUs5c=; Received: from [217.114.218.19] (helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1noMLu-0005SZ-MI; Tue, 10 May 2022 11:40:22 +0200 From: Felix Fietkau To: Sean Wang , Landen Chao , DENG Qingfang , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] net: dsa: tag_mtk: add padding for tx packets Date: Tue, 10 May 2022 11:40:13 +0200 Message-Id: <20220510094014.68440-1-nbd@nbd.name> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Padding for transmitted packets needs to account for the special tag. With not enough padding, garbage bytes are inserted by the switch at the end of small packets. Fixes: 5cd8985a1909 ("net-next: dsa: add Mediatek tag RX/TX handler") Signed-off-by: Felix Fietkau --- net/dsa/tag_mtk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index 415d8ece242a..1d1f9dbd9e93 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -25,6 +25,14 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb, u8 xmit_tpid; u8 *mtk_tag; + /* The Ethernet switch we are interfaced with needs packets to be at + * least 64 bytes (including FCS) otherwise their padding might be + * corrupted. With tags enabled, we need to make sure that packets are + * at least 68 bytes (including FCS and tag). + */ + if (__skb_put_padto(skb, ETH_ZLEN + MTK_HDR_LEN, false)) + return NULL; + /* Build the special tag after the MAC Source Address. If VLAN header * is present, it's required that VLAN header and special tag is * being combined. Only in this way we can allow the switch can parse -- 2.36.1