Skip to contentSkip to conversation

net: xilinx: axienet: Partial checksum offload improvements

PATCH Applied Sean Anderson 2 participants 6 messages Sep 9, 2024 – Sep 11, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover net: xilinx: axienet: Partial checksum offload improvements

Partial checksum offload is not always used when it could be. Enable it in more cases.

Changes in v2:
- Set RXCSUM in features
- Expand commit message with testing methodology

Sean Anderson (4):
net: xilinx: axienet: Remove unused checksum variables
net: xilinx: axienet: Enable NETIF_F_HW_CSUM for partial tx
checksumming
net: xilinx: axienet: Set RXCSUM in features
net: xilinx: axienet: Relax partial rx checksum checks

 drivers/net/ethernet/xilinx/xilinx_axienet.h  |  5 -----
 .../net/ethernet/xilinx/xilinx_axienet_main.c | 22 +++++--------------
 2 files changed, 5 insertions(+), 22 deletions(-)
Signature · 1 line
2.35.1.1320.gc452695387.dirty
#1 lore raw

PATCH v2 1/4 net: xilinx: axienet: Remove unused checksum variables

These variables are set but never used. Remove them.

---

(no changes since v1)

 drivers/net/ethernet/xilinx/xilinx_axienet.h      |  5 -----
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 12 ------------
 2 files changed, 17 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +0 -5
index c301dd2ee083..b9d2d7319220 100644
@@ -527,8 +527,6 @@ struct skbuf_dma_descriptor {
  *		  supported, the maximum frame size would be 9k. Else it is
  *		  1522 bytes (assuming support for basic VLAN)
  * @rxmem:	Stores rx memory size for jumbo frame handling.
- * @csum_offload_on_tx_path:	Stores the checksum selection on TX side.
- * @csum_offload_on_rx_path:	Stores the checksum selection on RX side.
  * @coalesce_count_rx:	Store the irq coalesce on RX side.
  * @coalesce_usec_rx:	IRQ coalesce delay for RX
  * @coalesce_count_tx:	Store the irq coalesce on TX side.
@@ -606,9 +604,6 @@ struct axienet_local {
 	u32 max_frm_size;
 	u32 rxmem;
 
-	int csum_offload_on_tx_path;
-	int csum_offload_on_rx_path;
-
 	u32 coalesce_count_rx;
 	u32 coalesce_usec_rx;
 	u32 coalesce_count_tx;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0 -12
index fe6a0e2e463f..60ec430f3eb0 100644
@@ -2631,38 +2631,26 @@ static int axienet_probe(struct platform_device *pdev)
 	if (!ret) {
 		switch (value) {
 		case 1:
-			lp->csum_offload_on_tx_path =
-				XAE_FEATURE_PARTIAL_TX_CSUM;
 			lp->features |= XAE_FEATURE_PARTIAL_TX_CSUM;
 			/* Can checksum TCP/UDP over IPv4. */
 			ndev->features |= NETIF_F_IP_CSUM;
 			break;
 		case 2:
-			lp->csum_offload_on_tx_path =
-				XAE_FEATURE_FULL_TX_CSUM;
 			lp->features |= XAE_FEATURE_FULL_TX_CSUM;
 			/* Can checksum TCP/UDP over IPv4. */
 			ndev->features |= NETIF_F_IP_CSUM;
 			break;
-		default:
-			lp->csum_offload_on_tx_path = XAE_NO_CSUM_OFFLOAD;
 		}
 	}
 	ret = of_property_read_u32(pdev->dev.of_node, "xlnx,rxcsum", &value);
 	if (!ret) {
 		switch (value) {
 		case 1:
-			lp->csum_offload_on_rx_path =
-				XAE_FEATURE_PARTIAL_RX_CSUM;
 			lp->features |= XAE_FEATURE_PARTIAL_RX_CSUM;
 			break;
 		case 2:
-			lp->csum_offload_on_rx_path =
-				XAE_FEATURE_FULL_RX_CSUM;
 			lp->features |= XAE_FEATURE_FULL_RX_CSUM;
 			break;
-		default:
-			lp->csum_offload_on_rx_path = XAE_NO_CSUM_OFFLOAD;
 		}
 	}
 	/* For supporting jumbo frames, the Axi Ethernet hardware must have
Signature · 1 line
2.35.1.1320.gc452695387.dirty
#2 lore raw

PATCH v2 2/4 net: xilinx: axienet: Enable NETIF_F_HW_CSUM for partial tx checksumming

In reply to Sean Anderson

Partial tx chechsumming is completely generic and does not depend on the L3/L4 protocol. Signal this to the net subsystem by enabling the more-generic offload feature (instead of restricting ourselves to TCP/UDP over IPv4 checksumming only like is necessary with full checksumming).

---

(no changes since v1)

 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2 -2
index 60ec430f3eb0..74fade5a95c2 100644
@@ -2632,8 +2632,8 @@ static int axienet_probe(struct platform_device *pdev)
 		switch (value) {
 		case 1:
 			lp->features |= XAE_FEATURE_PARTIAL_TX_CSUM;
-			/* Can checksum TCP/UDP over IPv4. */
-			ndev->features |= NETIF_F_IP_CSUM;
+			/* Can checksum any contiguous range */
+			ndev->features |= NETIF_F_HW_CSUM;
 			break;
 		case 2:
 			lp->features |= XAE_FEATURE_FULL_TX_CSUM;
Signature · 1 line
2.35.1.1320.gc452695387.dirty
#3 lore raw

PATCH v2 3/4 net: xilinx: axienet: Set RXCSUM in features

In reply to Sean Anderson

When it is supported by hardware, we enable receive checksum offload unconditionally. Update features to reflect this.

---

Changes in v2:
- New

 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2 -0
index 74fade5a95c2..2f7ab0922aed 100644
@@ -2647,9 +2647,11 @@ static int axienet_probe(struct platform_device *pdev)
 		switch (value) {
 		case 1:
 			lp->features |= XAE_FEATURE_PARTIAL_RX_CSUM;
+			ndev->features |= NETIF_F_RXCSUM;
 			break;
 		case 2:
 			lp->features |= XAE_FEATURE_FULL_RX_CSUM;
+			ndev->features |= NETIF_F_RXCSUM;
 			break;
 		}
 	}
Signature · 1 line
2.35.1.1320.gc452695387.dirty
#4 lore raw

PATCH v2 4/4 net: xilinx: axienet: Relax partial rx checksum checks

In reply to Sean Anderson

The partial rx checksum feature computes a checksum over the entire packet, regardless of the L3 protocol. Remove the check for IPv4. Additionally, testing with csum.py (from kselftests) shows no anomalies with 64-byte packets, so we can remove that check as well.

---
Testing was performed with csum.py between two axienet netdevs. I also tested with a macb netdev, but I saw some errors due to 007e4ba3ee13 ("net: macb:
initialize checksum when using checksum offloading"). I also tested manually with a dpaa netdev, but I wasn't set up for ssh.

Changes in v2:
- Expand commit message with testing methodology

 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 -3
index 2f7ab0922aed..4185c5708742 100644
@@ -1188,9 +1188,7 @@ static int axienet_rx_poll(struct napi_struct *napi, int budget)
 				    csumstatus == XAE_IP_UDP_CSUM_VALIDATED) {
 					skb->ip_summed = CHECKSUM_UNNECESSARY;
 				}
-			} else if ((lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) != 0 &&
-				   skb->protocol == htons(ETH_P_IP) &&
-				   skb->len > 64) {
+			} else if (lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) {
 				skb->csum = be32_to_cpu(cur_p->app3 & 0xFFFF);
 				skb->ip_summed = CHECKSUM_COMPLETE;
 			}
Signature · 1 line
2.35.1.1320.gc452695387.dirty
#5 lore raw
In reply to Sean Anderson
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Mon, 9 Sep 2024 12:10:12 -0400 you wrote:

Partial checksum offload is not always used when it could be. Enable it in more cases.

Changes in v2:
- Set RXCSUM in features
- Expand commit message with testing methodology

[...]

Here is the summary with links:
- [net-next,v2,1/4] net: xilinx: axienet: Remove unused checksum variables

    https://git.kernel.org/netdev/net-next/c/b1e455cd864c
  - [net-next,v2,2/4] net: xilinx: axienet: Enable NETIF_F_HW_CSUM for partial tx checksumming
    https://git.kernel.org/netdev/net-next/c/dd28f4c0e81f
  - [net-next,v2,3/4] net: xilinx: axienet: Set RXCSUM in features
    https://git.kernel.org/netdev/net-next/c/06c069ff2f70
  - [net-next,v2,4/4] net: xilinx: axienet: Relax partial rx checksum checks
    https://git.kernel.org/netdev/net-next/c/736f0c7a8ec2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html