From patchwork Mon Oct 30 09:26:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 159574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2080262vqb; Mon, 30 Oct 2023 02:27:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3rvqRWg7hfta+ITWEQ0tLzIUGQ1oCqCi+TzaNi0MbWpZxQDy2R7Fez/W77PU77/iQsEvL X-Received: by 2002:a05:6358:7e47:b0:168:df47:20bc with SMTP id p7-20020a0563587e4700b00168df4720bcmr10890346rwm.25.1698658034049; Mon, 30 Oct 2023 02:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698658034; cv=none; d=google.com; s=arc-20160816; b=UoaXqXm9Dg6we2KVDUevLPPpbbUZ19Y8Ozmm56qdUuYBcZZ5xoyN0Ixn+U9hGYOD2i nZEK7WC+V++w7BAGpRewmErGTHxhr4wsZw/FG3LdxPqyKsocxkgU/Pjc8SRO6ju0p16G xHTMNihDPfrLeKsZauz6Hd7mDivneVcd5VFtLwN6DuLAkmwhBqnhfB1JLcPybwH1pYl+ xgV87fNDAbVC17W9YyLx11OfNYwYy4WD7on8kzuX5qC79OiwM8Yv4mX1gdJibeOH5+aZ jUSVXJHd4IY2ES9iM8hKPseWNrGeNLzwi4AZC6TSC8T0IMPzCrvEBtP4PsNLQTmZGk38 HiNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=/S93wdJSw/AzX9CKKdyBARwqyDwptUmDMX/QD6LKCe4=; fh=keuXzro17w1EX7MbkvFc3mwOPfStnOmeFHd6JYQGOsk=; b=fNiHCTaJUqLQMi35XZbNanuyf4V0AH26HZchfYRJlLZbipH4rb0XDhKgIIsWT7b54p 1k36s1WwyiMAba5WrzADchtO7bVC0zO0Fd/4m6US5Y7JGUuWK/UTOOgNvIb87QLed1tS mGa7c/YhhaGRGHENfGva8bFkDxKUCwsxw3MJWSOkKnCTnL7Q1WPJdCgHfg5CTt07S7Ru 4vnLZaMkmD3sXvUZOtCA3Q1RVbNwCObIDbbtEfeEDuplOFsWTixrTG+INC0vVAAt5K69 WaOIEoG5qYIACozbpTube6up4I3hyStWdNCe7EtLrmZv3NTr2hsWyIz0/xKGQbi6cZFz 8Opw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oamF0bF3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id i3-20020a639d03000000b005b9022ddeb9si4631873pgd.501.2023.10.30.02.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 02:27:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oamF0bF3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D5E908067E09; Mon, 30 Oct 2023 02:27:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232340AbjJ3J07 (ORCPT + 31 others); Mon, 30 Oct 2023 05:26:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232073AbjJ3J06 (ORCPT ); Mon, 30 Oct 2023 05:26:58 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06F14C6 for ; Mon, 30 Oct 2023 02:26:56 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-507bd64814fso5862139e87.1 for ; Mon, 30 Oct 2023 02:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698658014; x=1699262814; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=/S93wdJSw/AzX9CKKdyBARwqyDwptUmDMX/QD6LKCe4=; b=oamF0bF34fDhS6xoumno2H3pWQk139BtFvEQ2etV86T6zSNi6o/xnv/azmQ4cHdngG 4CePOABtIWfKhWgcAufIU5VjJnJVP+PxokTYq83bcYQqoFMgqLc+zjqrXu+ApCRWfVue qY5X090L0cSgIVJAYD6Yfk6/jh+5lmI4bhLW0R4Nz5U2/LSbbi2zX2ltvqwe3BZ/g6xM CF4dKIgFM1vBryybR4G9+XMe0GpRMBTrXapJzJVBdFO50hzLpX+NlA/xms2lsQU/QRMM FHViMpz5sCPiRV+q+bst2MiVxi7a60uSsBlGFhtztH2mfWoKRyztLuoWEktumq5IxDax pr9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698658014; x=1699262814; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/S93wdJSw/AzX9CKKdyBARwqyDwptUmDMX/QD6LKCe4=; b=HxTZTWPYIZAu7Jgmq0g9mQwSy1wByXuNqxstotJRQKKiXMcBmt2HiYFNgdYEufGnOj K3u+e9DRNxhE4KHb2RXFyyeE9aQPPXc4ofTPuF6bsB+Ykni6Du1fZw1KKFw0egZiNORR 1yLM5Cfz7svzD48Wz7H3kulrHRYbouUczFJ3FMjjuNh34wMzwAgCZXlYmqFpehNWvtNR 2hZPq3hokS6leWzv69DzunQ3i3sJMmjOBWaZoRN7l/ZeEyq8cV9bbPKcKL6Si9x6tZ7S vXjdkvr6n6NZlgFG3MPS0gaQXJweSbFK4fviIUOMU4V8ZVacHhhCvrJD2BaWznGOFWke cTiA== X-Gm-Message-State: AOJu0YwZ621j8jMJ+GIgDkBAeED4yUaoA85lv0LDenIIR0PM8pu4ilX+ EwhVt0qR9Nd4HCLcPZMnGl43BSXer/+YmZTEWz4= X-Received: by 2002:ac2:5e24:0:b0:504:7e90:e05b with SMTP id o4-20020ac25e24000000b005047e90e05bmr6081095lfg.14.1698658013974; Mon, 30 Oct 2023 02:26:53 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id d34-20020a0565123d2200b0050915816a16sm811912lfv.145.2023.10.30.02.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 02:26:53 -0700 (PDT) From: Linus Walleij Date: Mon, 30 Oct 2023 10:26:50 +0100 Subject: [PATCH net v2] net: dsa: tag_rtl4_a: Bump min packet size MIME-Version: 1.0 Message-Id: <20231030-fix-rtl8366rb-v2-1-e66e1ef7dbd2@linaro.org> X-B4-Tracking: v=1; b=H4sIANl2P2UC/3WNTQqDMBCFryKzbkoSmVi76j2Ki2imOiBJmYi0S O7e4L7L9/e9AzIJU4Z7c4DQzplTrMJeGpgWH2dSHKoGq21rtO3Uiz9KtvXWOiejog7tGLDXZvJ QN2+hWjh5T4i0wVDNhfOW5Ht+7OaM/uB2o4wK6DD0GrFF/1g5eknXJDMMpZQf+nuJXbAAAAA= To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 30 Oct 2023 02:27:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781172046794056817 X-GMAIL-MSGID: 1781172046794056817 It was reported that the "LuCI" web UI was not working properly with a device using the RTL8366RB switch. Disabling the egress port tagging code made the switch work again, but this is not a good solution as we want to be able to direct traffic to a certain port. It turns out that packets between 1496 and 1500 bytes are dropped unless padded out to 1518 bytes. If we pad the ethernet frames to a minimum of ETH_FRAME_LEN + FCS (1518 bytes) everything starts working fine. 1496 is the size of a normal data frame minus the internal DSA tag. The number is intuitive, the explanation evades me. As we completely lack datasheet or any insight into how this switch works, this trial-and-error solution is the best we can do. FWIW this bug may very well be the reason why Realteks code drops are not using CPU tagging. The vendor routers using this switch are all hardwired to disable CPU tagging and all packets are pushed to all ports on TX. This is also the case in the old OpenWrt driver, derived from the vendor code drops. I have tested smaller sizes, only 1518 or bigger padding works. Modifying the MTU on the switch (one setting affecting all ports) has no effect. Before this patch: PING 192.168.1.1 (192.168.1.1) 1470(1498) bytes of data. ^C --- 192.168.1.1 ping statistics --- 2 packets transmitted, 0 received, 100% packet loss, time 1048ms PING 192.168.1.1 (192.168.1.1) 1472(1500) bytes of data. ^C --- 192.168.1.1 ping statistics --- 12 packets transmitted, 0 received, 100% packet loss, time 11267ms After this patch: PING 192.168.1.1 (192.168.1.1) 1470(1498) bytes of data. 1478 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.533 ms 1478 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.630 ms PING 192.168.1.1 (192.168.1.1) 1472(1500) bytes of data. 1480 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.527 ms 1480 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.562 ms Also LuCI starts working with the 1500 bytes frames it produces from the HTTP server. Fixes: 9eb8bc593a5e ("net: dsa: tag_rtl4_a: fix egress tags") Signed-off-by: Linus Walleij --- Changes in v2: - Pad packages >= 1496 bytes after some further tests - Use more to-the-point description - Provide ping results in the commit message - Link to v1: https://lore.kernel.org/r/20231027-fix-rtl8366rb-v1-1-d565d905535a@linaro.org --- net/dsa/tag_rtl4_a.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- base-commit: d9e164e4199bc465b3540d5fe3ffc8a9a4fc6157 change-id: 20231027-fix-rtl8366rb-e752bd5901ca Best regards, diff --git a/net/dsa/tag_rtl4_a.c b/net/dsa/tag_rtl4_a.c index c327314b95e3..3292bc49b158 100644 --- a/net/dsa/tag_rtl4_a.c +++ b/net/dsa/tag_rtl4_a.c @@ -45,6 +45,16 @@ static struct sk_buff *rtl4a_tag_xmit(struct sk_buff *skb, if (unlikely(__skb_put_padto(skb, ETH_ZLEN, false))) return NULL; + /* Packets over 1496 bytes get dropped unless they get padded + * out to 1518 bytes. 1496 is ETH_DATA_LEN - tag which is hardly + * a coinicidence, and 1518 is ETH_FRAME_LEN + FCS so we define + * the threshold size and padding like this. + */ + if (skb->len >= (ETH_DATA_LEN - RTL4_A_HDR_LEN)) { + if (unlikely(__skb_put_padto(skb, ETH_FRAME_LEN + ETH_FCS_LEN, false))) + return NULL; + } + netdev_dbg(dev, "add realtek tag to package to port %d\n", dp->index); skb_push(skb, RTL4_A_HDR_LEN);