From patchwork Tue Jan 2 16:27:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13509165 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95A90C47074 for ; Tue, 2 Jan 2024 16:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=1IOl4k7SZ6q9GGQLU/9iR+TkHG1pTgYFHv2TdSa4B9s=; b=3vaG2PN8tgIMtC uwl/2gspRw4n/REFfK5PphiRb3j/eMshm1vy7TtQNHGAyEQcJEpZbCWiEMfNGhG/9boTkknb16cCb oNoa1bNHfV5Y/yEuzE+9Vm+fdlKcNBq3wgY+kT/7sqpH038GbNPrO0qV6bXuetbKYz+9rWn6ZFHyx J1zCGnK7eKrp0XHB6BsEms15VMdpnwO/0FcY6weVLDJGPmHZZ4aeQv95N79x9yxPuovdwzyzSC9AT TmwB79pOxhDGgCJBBIOiM2tbcVabaDdq4t+OdmHNpoAFT4xpFEgiHETQWXsWAD7jGQHG1+48SZbOz 4Sw4HlcuZ3MtL4eJORww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rKhbv-008USm-1v; Tue, 02 Jan 2024 16:27:23 +0000 Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rKhbq-008UQ3-1p for linux-arm-kernel@lists.infradead.org; Tue, 02 Jan 2024 16:27:20 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 19E3FFF803; Tue, 2 Jan 2024 16:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1704212833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=gLgXTYLMRFh5L6uQq7gtyiAMhfzlrw+4m0P+XM+V4bE=; b=iIhsfSozLrvkaMJkCwKo+qGR96+mrWY+qLGfFxmQsvyAV3MS8+ME+dgePuIgqtfwxRNXvA Y5VqYfI2kRbxuteas5TfOpA4dXnVfz6vVIMVRaYzFotx8QUB0L+ZZ79+weBuN+BWNmsMEZ XCl4l2SqR3l4dEM/qqkLM4kSlp5rLP8/UH464lN7Qu9N1gZwEKKbZA6kCKu61S8Lq/bQ9W fCUUo7Z0RbpdIhsZlvjr0AtWLYg7O/MZLHyc/Owz6EvN7LFo670izzNzsMV/GVwDcWryCz FiUfbLjpqAVDRCzUNg+mF1S2MLjWPKbgGyNOm04SvuAh4A/rlkZWceMmOSyEkQ== From: Romain Gantois To: Alexandre Torgue , Jose Abreu Cc: Romain Gantois , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Miquel Raynal , Maxime Chevallier , Sylvain Girard , Vladimir Oltean , Andrew Lunn , Pascal EBERHARD , Richard Tresidder , Linus Walleij , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH net v2 0/1] Prevent DSA tags from breaking COE Date: Tue, 2 Jan 2024 17:27:14 +0100 Message-ID: <20240102162718.268271-1-romain.gantois@bootlin.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240102_082718_756228_D96A8768 X-CRM114-Status: GOOD ( 14.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello everyone, This is the second version of my proposed fix for the stmmac checksum offloading issue that has recently been reported. significant changes in v2: - replaced the stmmac_link_up-based fix with an ethertype check in the TX and RX hotpaths. The Checksum Offloading Engine of some stmmac cores (e.g. DWMAC1000) computes an incorrect checksum when presented with DSA-tagged packets. This causes all TCP/UDP transfers to break when the stmmac device is connected to the CPU port of a DSA switch. I ran some tests using different tagging protocols with DSA_LOOP, and all of the protocols that set a custom ethertype field in the MAC header caused the checksum offload engine to ignore the tagged packets. On TX, this caused packets to egress with incorrect checksums. On RX, these packets were similarly ignored by the COE, yet the stmmac driver set CHECKSUM_UNNECESSARY, wrongly assuming that their checksums had been verified in hardware. Version 2 of this patch series fixes this issue by checking ethertype fields in both the TX and RX hotpaths of the stmmac driver. On TX, if a non-IP ethertype is detected, the packet is checksummed in software. On RX, the same condition causes stmmac to avoid setting CHECKSUM_UNNECESSARY. To measure the performance degradation to the TX/RX hotpaths, I did some iperf3 runs with 512-byte unfragmented UDP packets. measured degradation on TX: -670 pps (-2.9%) on RX: -485 pps (-1.7%) original performances on TX: 22kpps on RX: 27kpps The performance hit on the RX path can be partly explained by the fact that the stmmac driver doesn't set CHECKSUM_UNNECESSARY anymore. The slightly higher TX degradation is harder to explain but I should note that the external PHYs used in my setup have been causing performance issues on TX, which could be affecting the results. Best Regards, Romain Romain Gantois (1): net: stmmac: Prevent DSA tags from breaking COE on stmmac .../net/ethernet/stmicro/stmmac/stmmac_main.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)