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: 13509163 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E468914F6D for ; Tue, 2 Jan 2024 16:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="iIhsfSoz" 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: romain.gantois@bootlin.com X-Patchwork-Delegate: kuba@kernel.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(-)