From patchwork Mon Sep 30 16:08:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816645 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B444C35894; Mon, 30 Sep 2024 16:09:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712567; cv=none; b=Dpvch+3q26X7gwI9g1nNhmSGL68HaZr36jvlhL/Fo6Xz4q/btJhpfjAKlC/U2lZprOD/jSJU135MQpsKdw1W2iggV42wsZvBMT/SY4CtyxYSZofWjLNKkiesHacb/UHdomrndoAFeM0PKD3tNbsxN7C/6V2KZ7k7iighGQHaL8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712567; c=relaxed/simple; bh=MxfAjJYO4xjkhmFSR4yEM0PrB7kjlaIka8hz0EfTdeU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GpS+r88em+A/EmNbpzWMJqG++IV15i43KxrUoGLYIL1wP+1/GbmwRo3ainQnjjQldeiCRg6uLOL0XWE1O3uiSL+uJD949rh6bgQMyTp9GnkZzp7qsSovGYWJHjtQ/usKoTZU0ID+rOO1BVe9qW9KwEIw2eylayIA/4AeQLrG8pU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="220371949" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:24 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 794D84015251; Tue, 1 Oct 2024 01:09:02 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 01/11] net: ravb: Factor out checksum offload enable bits Date: Mon, 30 Sep 2024 17:08:35 +0100 Message-Id: <20240930160845.8520-2-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker Introduce new constants for the CSR1 (TX) and CSR2 (RX) checksum enable bits, removing the risk of inconsistency when we change which flags we enable. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb.h | 4 ++++ drivers/net/ethernet/renesas/ravb_main.c | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index a7de5cf6b317..4e1e0a754cd9 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -998,6 +998,8 @@ enum CSR1_BIT { CSR1_TDHD = 0x08000000, }; +#define CSR1_CSUM_ENABLE (CSR1_TIP4 | CSR1_TTCP4 | CSR1_TUDP4) + enum CSR2_BIT { CSR2_RIP4 = 0x00000001, CSR2_RTCP4 = 0x00000010, @@ -1012,6 +1014,8 @@ enum CSR2_BIT { CSR2_RDHD = 0x08000000, }; +#define CSR2_CSUM_ENABLE (CSR2_RIP4 | CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4) + #define DBAT_ENTRY_NUM 22 #define RX_QUEUE_OFFSET 4 #define NUM_RX_QUEUE 2 diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index d2a6518532f3..b53f6062a106 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -504,11 +504,10 @@ static void ravb_csum_init_gbeth(struct net_device *ndev) ndev->features &= ~NETIF_F_RXCSUM; } else { if (tx_enable) - ravb_write(ndev, CSR1_TIP4 | CSR1_TTCP4 | CSR1_TUDP4, CSR1); + ravb_write(ndev, CSR1_CSUM_ENABLE, CSR1); if (rx_enable) - ravb_write(ndev, CSR2_RIP4 | CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4, - CSR2); + ravb_write(ndev, CSR2_CSUM_ENABLE, CSR2); } done: @@ -2531,7 +2530,7 @@ static int ravb_set_features_gbeth(struct net_device *ndev, spin_lock_irqsave(&priv->lock, flags); if (changed & NETIF_F_RXCSUM) { if (features & NETIF_F_RXCSUM) - val = CSR2_RIP4 | CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4; + val = CSR2_CSUM_ENABLE; else val = 0; @@ -2542,7 +2541,7 @@ static int ravb_set_features_gbeth(struct net_device *ndev, if (changed & NETIF_F_HW_CSUM) { if (features & NETIF_F_HW_CSUM) - val = CSR1_TIP4 | CSR1_TTCP4 | CSR1_TUDP4; + val = CSR1_CSUM_ENABLE; else val = 0; From patchwork Mon Sep 30 16:08:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816658 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5084192D84; Mon, 30 Sep 2024 16:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712579; cv=none; b=ghA6Gy3nSBfMVfTGUnbzHcykybx85j1Uv7E6cwnSH8bYMtDl3j1S8mg/7O32SMo+w+K/8eJVvDh7mWepqaYqzn+QNIG8CXS5QHNxGTrvXKVIy2lcmys796rWh1HHVnyW0Qb/OE0tK9VPlKXyHauTkKRVpUlYl5nKbWugvTmJhJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712579; c=relaxed/simple; bh=sae72RfWlDAO3Nw+OnMZXDZzXG+S/tHXJC641DiN0Ek=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SO8mu1aYx+K5cRNpjuc3mM7jrSvhs4Di672Q/uFHz5/W89hCpzTGD1mF9E6HW9bfkhfsjIiZLpc5vkSu7DMKj/DdCZEWOwJGJPKpCswBKNgTJR7GGFSoa1VMJLSQHP4sUfumFjyu7XLqOoIPDtEPcRlxVFhcijTFUM8yMab5qLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="220371963" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:36 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 4AE2340156C4; Tue, 1 Oct 2024 01:09:07 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 02/11] net: ravb: Disable IP header RX checksum offloading Date: Mon, 30 Sep 2024 17:08:36 +0100 Message-Id: <20240930160845.8520-3-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker For IPv4 packets, the header checksum will always be checked in software in the RX path (inet_gro_receive() calls ip_fast_csum() unconditionally) so there is no advantage in asking the hardware to also calculate this checksum. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb.h | 2 +- drivers/net/ethernet/renesas/ravb_main.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index 4e1e0a754cd9..98496aa39f3d 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1014,7 +1014,7 @@ enum CSR2_BIT { CSR2_RDHD = 0x08000000, }; -#define CSR2_CSUM_ENABLE (CSR2_RIP4 | CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4) +#define CSR2_CSUM_ENABLE (CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4) #define DBAT_ENTRY_NUM 22 #define RX_QUEUE_OFFSET 4 diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index b53f6062a106..f1b487152555 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -749,13 +749,18 @@ static void ravb_get_tx_tstamp(struct net_device *ndev) static void ravb_rx_csum_gbeth(struct sk_buff *skb) { struct skb_shared_info *shinfo = skb_shinfo(skb); - __wsum csum_ip_hdr, csum_proto; + __wsum csum_proto; skb_frag_t *last_frag; u8 *hw_csum; /* The hardware checksum status is contained in sizeof(__sum16) * 2 = 4 - * bytes appended to packet data. First 2 bytes is ip header checksum - * and last 2 bytes is protocol checksum. + * bytes appended to packet data. + * + * For ipv4, the first 2 bytes are the ip header checksum status. We can + * ignore this as it will always be re-checked in inet_gro_receive(). + * + * The last 2 bytes are the protocol checksum status which will be zero + * if the checksum has been validated. */ if (unlikely(skb->len < sizeof(__sum16) * 2)) return; @@ -771,16 +776,13 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb) hw_csum -= sizeof(__sum16); csum_proto = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); - hw_csum -= sizeof(__sum16); - csum_ip_hdr = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); - if (skb_is_nonlinear(skb)) skb_frag_size_sub(last_frag, 2 * sizeof(__sum16)); else skb_trim(skb, skb->len - 2 * sizeof(__sum16)); /* TODO: IPV6 Rx checksum */ - if (skb->protocol == htons(ETH_P_IP) && !csum_ip_hdr && !csum_proto) + if (skb->protocol == htons(ETH_P_IP) && !csum_proto) skb->ip_summed = CHECKSUM_UNNECESSARY; } From patchwork Mon Sep 30 16:08:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816647 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAA2219309C; Mon, 30 Sep 2024 16:09:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712569; cv=none; b=Xz/DE/wnOLpS+0LFZ3HCrhw5aw9JeP+mO8nhUmLGKS2f9cEe7MgiIryCD224XHV5g1NgMmdsj/AoHU1nUF9KS0lnUIzsgyaaRPjQ0dUlPODpzHx68yapN6zBJDMEFchciY/3CT8SSG6pB0TDRuOqqu5TBdTGKUk14cR5e89qJIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712569; c=relaxed/simple; bh=GzmTAqGiA1JIN0S7y4kJ5+tKoxXPYz/HRSBLWMDxsG8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CWZ0UdSR7EbxUP8NK7G872OV0kp3rISjr2qvjZYeOPvzkHIc3PFTwO1GXK7gx5GqJBCWjoIWywp4tDKA7beOnTBt1eQmfYU0TNcYeoVDFa2GmPVgmh0NIgiFhTHR7FqFTB0Q53UfeC5Q3odSdh9PPlvOl8R5q7p/pwJHierCPfs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="220371951" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:24 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 21E8140156B5; Tue, 1 Oct 2024 01:09:11 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 03/11] net: ravb: Drop IP protocol check from RX csum verification Date: Mon, 30 Sep 2024 17:08:37 +0100 Message-Id: <20240930160845.8520-4-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker We do not need to confirm that the protocol is IPv4. If the hardware encounters an unsupported protocol, it will set the checksum value to 0xFFFF. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index f1b487152555..f3913c164161 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -781,8 +781,7 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb) else skb_trim(skb, skb->len - 2 * sizeof(__sum16)); - /* TODO: IPV6 Rx checksum */ - if (skb->protocol == htons(ETH_P_IP) && !csum_proto) + if (!csum_proto) skb->ip_summed = CHECKSUM_UNNECESSARY; } From patchwork Mon Sep 30 16:08:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816656 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73D56190667; Mon, 30 Sep 2024 16:09:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712577; cv=none; b=PRFByUj/IuLXJf4crcbTmfuqVkL9eIKJZV03d8v6/EQ80v/sqS0Z3Avj9z2xT8DQ5uLS1pHhhUF1a1gP0/FLDH/KvUpYHtJgabTZjr5hhOzsVJ05fxhPrUvfyQrxruMKqdT91JRUrML9k3vgIMjyNR6EGOStcZJtPJSG0rI3sY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712577; c=relaxed/simple; bh=k2BG4Wh6IclsjFlxRTyHQ9kTeZa9kLRDBXyfoMuI6GU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RYssiv6QAuclGGrHMx8Vw6Arcsg664lCKEcYb6CMyCjqBu5Ohf5odq0/5KAoB9oygSiYLDAtqiwK+KMLF10hHiUKJWU14aJftPdPs+LV4otct2bqV5nhkzg28xF0x5Ksnnmvav/SFb7Z1WZ+EnUlU3hPmg9srp31Qhsp8KSQf1o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="224347959" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:34 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id EB0034015135; Tue, 1 Oct 2024 01:09:16 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 04/11] net: ravb: Combine if conditions in RX csum validation Date: Mon, 30 Sep 2024 17:08:38 +0100 Message-Id: <20240930160845.8520-5-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker We can merge the two if conditions on skb_is_nonlinear(). Since skb_frag_size_sub() and skb_trim() do not free memory, it is still safe to access the trimmed bytes at the end of the packet after these calls. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index f3913c164161..1dd2152734b0 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -769,18 +769,15 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb) last_frag = &shinfo->frags[shinfo->nr_frags - 1]; hw_csum = skb_frag_address(last_frag) + skb_frag_size(last_frag); + skb_frag_size_sub(last_frag, 2 * sizeof(__sum16)); } else { hw_csum = skb_tail_pointer(skb); + skb_trim(skb, skb->len - 2 * sizeof(__sum16)); } hw_csum -= sizeof(__sum16); csum_proto = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); - if (skb_is_nonlinear(skb)) - skb_frag_size_sub(last_frag, 2 * sizeof(__sum16)); - else - skb_trim(skb, skb->len - 2 * sizeof(__sum16)); - if (!csum_proto) skb->ip_summed = CHECKSUM_UNNECESSARY; } From patchwork Mon Sep 30 16:08:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816646 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38EE6191F6B; Mon, 30 Sep 2024 16:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712569; cv=none; b=CM1dlI1gMVvuIRbkFY+YonBh8CiCZBZpT82rrZ88rJmQAuuO7ENzSugoyAUsveGYQQS/KCzSHvRJyhU0DLWsyJUb5WFdJ8DM+dhyhrD/Q8XYEE0cJBiEjTnI2Lr31quWCM1ULm9x753JNLBJ2IM914L8eu7mW8qCEaVS7neEMTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712569; c=relaxed/simple; bh=u4YF1e11CPAbUSMc2KCNJi1M7BvEl88Iop1muAvdQc0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E7RuPrQIfi5PuIVy5RcEbjWacgWqxvMU8EBIO5kwfA6pFRneGjxFHqw8W6TAuMM8a3wSY8Ebwmpy/hNenEg/0kqq5rSZ8u8o0BPiQ84oAOn8JjDqV+QF4nYe8fAwqj+2MIib/bqSyT/RxN1+av8AyzfjsoY6muS/s6SWAv6bqOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="224347950" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:25 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id B56394015141; Tue, 1 Oct 2024 01:09:21 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 05/11] net: ravb: Simplify types in RX csum validation Date: Mon, 30 Sep 2024 17:08:39 +0100 Message-Id: <20240930160845.8520-6-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker The HW checksum value is used as a 16-bit flag, it is zero when the checksum has been validated and non-zero otherwise. Therefore we don't need to treat this as an actual __wsum type or call csum_unfold(), we can just use a u16 pointer. Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb_main.c | 30 +++++++++++------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 1dd2152734b0..9350ca10ab22 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -749,12 +749,11 @@ static void ravb_get_tx_tstamp(struct net_device *ndev) static void ravb_rx_csum_gbeth(struct sk_buff *skb) { struct skb_shared_info *shinfo = skb_shinfo(skb); - __wsum csum_proto; - skb_frag_t *last_frag; - u8 *hw_csum; + size_t csum_len; + u16 *hw_csum; - /* The hardware checksum status is contained in sizeof(__sum16) * 2 = 4 - * bytes appended to packet data. + /* The hardware checksum status is contained in 4 bytes appended to + * packet data. * * For ipv4, the first 2 bytes are the ip header checksum status. We can * ignore this as it will always be re-checked in inet_gro_receive(). @@ -762,23 +761,22 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb) * The last 2 bytes are the protocol checksum status which will be zero * if the checksum has been validated. */ - if (unlikely(skb->len < sizeof(__sum16) * 2)) + csum_len = sizeof(*hw_csum) * 2; + if (unlikely(skb->len < csum_len)) return; if (skb_is_nonlinear(skb)) { - last_frag = &shinfo->frags[shinfo->nr_frags - 1]; - hw_csum = skb_frag_address(last_frag) + - skb_frag_size(last_frag); - skb_frag_size_sub(last_frag, 2 * sizeof(__sum16)); + skb_frag_t *last_frag = &shinfo->frags[shinfo->nr_frags - 1]; + + hw_csum = (u16 *)(skb_frag_address(last_frag) + + skb_frag_size(last_frag)); + skb_frag_size_sub(last_frag, csum_len); } else { - hw_csum = skb_tail_pointer(skb); - skb_trim(skb, skb->len - 2 * sizeof(__sum16)); + hw_csum = (u16 *)skb_tail_pointer(skb); + skb_trim(skb, skb->len - csum_len); } - hw_csum -= sizeof(__sum16); - csum_proto = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); - - if (!csum_proto) + if (!*--hw_csum) skb->ip_summed = CHECKSUM_UNNECESSARY; } From patchwork Mon Sep 30 16:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816659 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3334C19047D; Mon, 30 Sep 2024 16:09:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712583; cv=none; b=u5WBtdxZPfnx2l88Y1/Qrlt9tvPNqjoorzPcZuDxzVRn9fUSnGJvwE1x7NOwRqV4fn5gG7/ygp0ZC8PtRrIlXq4W5ivqOqp3qRdqztQj5BMRm0tpROBlcAyVpUSkpoCUfEmJbDsemsAggZAKByn35+dd8LDexlVOs+c1Pgcio4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712583; c=relaxed/simple; bh=9A8YkDTOwfteqY8P70Wmc2cQJanzyPRjU8BzLWsDmk0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MzNXzeuOWGWkiLaBudqN6blCqbkLDNTx6RKCTfzzW95f6Nc+f9ndzkj/ddBNgSE4dWjK9Q9f5+QMrmO3hWFguKdqBlp4/T4EdMldE6OcyRE750/e70rWTQKa1O6oLepvXdPNl5FcQotYIwbgGv3IxVWDsXSZRKYpz80FT6NaRXA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="224347970" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:41 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 7E7D94014DD7; Tue, 1 Oct 2024 01:09:26 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 06/11] net: ravb: Disable IP header TX checksum offloading Date: Mon, 30 Sep 2024 17:08:40 +0100 Message-Id: <20240930160845.8520-7-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker For IPv4 packets, the header checksum will always be calculated in software in the TX path (Documentation/networking/checksum-offloads.rst says "No offloading of the IP header checksum is performed; it is always done in software.") so there is no advantage in asking the hardware to also calculate this checksum. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index 98496aa39f3d..a5b4f4fe77b1 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -998,7 +998,7 @@ enum CSR1_BIT { CSR1_TDHD = 0x08000000, }; -#define CSR1_CSUM_ENABLE (CSR1_TIP4 | CSR1_TTCP4 | CSR1_TUDP4) +#define CSR1_CSUM_ENABLE (CSR1_TTCP4 | CSR1_TUDP4) enum CSR2_BIT { CSR2_RIP4 = 0x00000001, From patchwork Mon Sep 30 16:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816657 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D82C192D71; Mon, 30 Sep 2024 16:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712578; cv=none; b=Aw08/a6iZ+bRBfjaXEEwk9VguFNKHaqjUeYV45Ji2bOt/E5AfmrJvD/QLP3MxLi6+Ga48QKaq5aUmk8EY66S7qHU6h1EfuHHqyD1/AvvBVlF5ZgnPP4cm0Z6Ipk5+xRIsW5yVORWSodgiBG7JJRhoZpzFP/ZQPbVba1tNcY3luY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712578; c=relaxed/simple; bh=GAkTF+MVXTsBDvyOAjsGLZIHTuFjLwJ1GRQYar1BjnM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fv8Sq2Q+aOqjedYjxUS8Y0O5aN3gG23f7ChyPZFTie2km/UnUVUHFRMypaornir9X6oAp/l0M4YWcJTZ4ZzxkzZqqhMYAyNjavv7KFkVK1F2p2NnhEBsZSOoCyG8PUWp3z3pDRsjredZ1XjhCMMQSq3NWiMJkUrDhC9EK0cbz2Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="224347962" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:35 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 586474015141; Tue, 1 Oct 2024 01:09:31 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 07/11] net: ravb: Simplify UDP TX checksum offload Date: Mon, 30 Sep 2024 17:08:41 +0100 Message-Id: <20240930160845.8520-8-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker The GbEth IP will pass through a null UDP checksum without asserting any error flags so we do not need to resort to software checksum calculation in this case. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb_main.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 9350ca10ab22..ae0268f2eb04 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2075,20 +2075,12 @@ static bool ravb_can_tx_csum_gbeth(struct sk_buff *skb) switch (ip->protocol) { case IPPROTO_TCP: - break; case IPPROTO_UDP: - /* If the checksum value in the UDP header field is 0, TOE does - * not calculate checksum for UDP part of this frame as it is - * optional function as per standards. - */ - if (udp_hdr(skb)->check == 0) - return false; - break; + return true; + default: return false; } - - return true; } /* Packet transmit function for Ethernet AVB */ From patchwork Mon Sep 30 16:08:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816660 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 72BCE1922F4; Mon, 30 Sep 2024 16:09:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712591; cv=none; b=iwnqvaqxKP5F8yUuwH4p/xXE5MFkoOfDK2Pp5ZrEu78zR/wS4j7Nq1a/yH2lugQ4+rbcBUvbWitW3QMhq7vTHLRAhv1tUk5Oys10a1L9wUhwNt1y3MgpxKqOnCM1HFykfV2BwKg9amkgj+z6AjAA2FN5c1Xxf7ULO0djWDtXCmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712591; c=relaxed/simple; bh=NLRrnUgBL5yvzPIt2Dg9DD5t/P1ZIP0tT5LYkDscvYA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g9Oxd3895Zv4gVPv0kVfLp1UkwYNzFqZU6a8gxlXG6vV3HLSNl/cDB+uWgNVPYTH5yVkbuUS61hHdZmWQZ7ebH2Hu9j+DvChjq2B642xplTWqON4dXg4E7ZxUqs+qZOQQoqY6Af2vGOWh80JMpxZkyJBhG0MGZGZjBWQPN0GNZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="220371970" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:48 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 2F9224014DD8; Tue, 1 Oct 2024 01:09:35 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 08/11] net: ravb: Support ICMP TX checksum offload for GbEth Date: Mon, 30 Sep 2024 17:08:42 +0100 Message-Id: <20240930160845.8520-9-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker This aligns TX capabilities with RX capabilities. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb.h | 2 +- drivers/net/ethernet/renesas/ravb_main.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index a5b4f4fe77b1..ef24d9f26a2e 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -998,7 +998,7 @@ enum CSR1_BIT { CSR1_TDHD = 0x08000000, }; -#define CSR1_CSUM_ENABLE (CSR1_TTCP4 | CSR1_TUDP4) +#define CSR1_CSUM_ENABLE (CSR1_TTCP4 | CSR1_TUDP4 | CSR1_TICMP4) enum CSR2_BIT { CSR2_RIP4 = 0x00000001, diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index ae0268f2eb04..69d71fbf3e02 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2076,6 +2076,7 @@ static bool ravb_can_tx_csum_gbeth(struct sk_buff *skb) switch (ip->protocol) { case IPPROTO_TCP: case IPPROTO_UDP: + case IPPROTO_ICMP: return true; default: From patchwork Mon Sep 30 16:08:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816661 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB1BC199FB1; Mon, 30 Sep 2024 16:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712594; cv=none; b=OHti9gkkUx6CDqhmCzx90OWQ0hxT6qNoHj498wmP+CwnYxC29jiEKmPTtBb8cEUx3a4VJgyeF2HUf3XRwURE0dpOHP/U2Qc4nuft0XIDWDWcQ4cg5VBCAAXa3DTCAMrz0bdrBClx9C9H1B0gU4ah4OYhJrPi/TfNr9QuMb6Gp6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712594; c=relaxed/simple; bh=zuPKdxI4n5V+iSYVVdrOaVwyBjwxyXE62aB5w/gL6w4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LabvjkhHIPWKhDvuL2wb5mmqLjI8JvtG76Rms7I/ZVSm3wchwfOriLdKkj3ksGx9zX1Q2qC8+7eDIgN4y2cY4LM0/wZan2aVH6ZyIcjIpJDf5L3ODQindw02unHon2yWFkP8Q0Am7bMX3S353a63lHrC7zG0hkaZ3SUvts/POnA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="220371976" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:52 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 03E294015141; Tue, 1 Oct 2024 01:09:40 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 09/11] net: ravb: Enable IPv6 RX checksum offloading for GbEth Date: Mon, 30 Sep 2024 17:08:43 +0100 Message-Id: <20240930160845.8520-10-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker The GbEth IP supports offloading IPv6 TCP, UDP & ICMPv6 checksums. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index ef24d9f26a2e..8523b89ba1c6 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1014,7 +1014,8 @@ enum CSR2_BIT { CSR2_RDHD = 0x08000000, }; -#define CSR2_CSUM_ENABLE (CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4) +#define CSR2_CSUM_ENABLE (CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4 | \ + CSR2_RTCP6 | CSR2_RUDP6 | CSR2_RICMP6) #define DBAT_ENTRY_NUM 22 #define RX_QUEUE_OFFSET 4 From patchwork Mon Sep 30 16:08:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816662 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2156E1922F4; Mon, 30 Sep 2024 16:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712594; cv=none; b=jkCh3nvDxZkUbvkyYTeffR0FaXoUEKEKX4/mHhJ2ONlwPOqsiMr6pTgT7B5hDsW0o1AlregIr3XDFyyyKMfs7miJIv0XIiOFLbeoHRnzpR9ang775whO9o1MM2CSHcxnSNTcGWrMkhEjYLEGenIt+vxCwR+jXbzpe5xoX3WcMmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712594; c=relaxed/simple; bh=IZ9CPul3h+k6m4vAfdAx+DtxwAdYljmJ1DMBrJM62Nw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gg96PYx0aYfCv63YRNWHSqzL/X9PONzNqBkJpZfiBvmjpp+IEazx/Bg1DgHpHfWLHWUS+H7zuGvXkzI37nqikjgZb4WS3d7io3ZeDU+77YX17x9wfiE8GpRW4FOhCtlSicIaqFsdIMdosBMQ7+4c7gII22Rup7CXKmaiPb3guAg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="220371977" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:52 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id D862A4006371; Tue, 1 Oct 2024 01:09:45 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 10/11] net: ravb: Enable IPv6 TX checksum offload for GbEth Date: Mon, 30 Sep 2024 17:08:44 +0100 Message-Id: <20240930160845.8520-11-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker The GbEth IP supports offloading IPv6 TCP, UDP & ICMPv6 checksums. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb.h | 3 ++- drivers/net/ethernet/renesas/ravb_main.c | 31 ++++++++++++++---------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index 8523b89ba1c6..2cb6c4ef1330 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -998,7 +998,8 @@ enum CSR1_BIT { CSR1_TDHD = 0x08000000, }; -#define CSR1_CSUM_ENABLE (CSR1_TTCP4 | CSR1_TUDP4 | CSR1_TICMP4) +#define CSR1_CSUM_ENABLE (CSR1_TTCP4 | CSR1_TUDP4 | CSR1_TICMP4 | \ + CSR1_TTCP6 | CSR1_TUDP6 | CSR1_TICMP6) enum CSR2_BIT { CSR2_RIP4 = 0x00000001, diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 69d71fbf3e02..832132d44fb4 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2063,25 +2063,30 @@ static void ravb_tx_timeout_work(struct work_struct *work) static bool ravb_can_tx_csum_gbeth(struct sk_buff *skb) { - struct iphdr *ip = ip_hdr(skb); - /* TODO: Need to add support for VLAN tag 802.1Q */ if (skb_vlan_tag_present(skb)) return false; - /* TODO: Need to add hardware checksum for IPv6 */ - if (skb->protocol != htons(ETH_P_IP)) - return false; - - switch (ip->protocol) { - case IPPROTO_TCP: - case IPPROTO_UDP: - case IPPROTO_ICMP: - return true; + switch (ntohs(skb->protocol)) { + case ETH_P_IP: + switch (ip_hdr(skb)->protocol) { + case IPPROTO_TCP: + case IPPROTO_UDP: + case IPPROTO_ICMP: + return true; + } + break; - default: - return false; + case ETH_P_IPV6: + switch (ipv6_hdr(skb)->nexthdr) { + case IPPROTO_TCP: + case IPPROTO_UDP: + case IPPROTO_ICMPV6: + return true; + } } + + return false; } /* Packet transmit function for Ethernet AVB */ From patchwork Mon Sep 30 16:08:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13816663 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DD1E19B3C1; Mon, 30 Sep 2024 16:09:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712598; cv=none; b=o/RbgCBeasl4zx8hgmGA/kBHbdjQYaqbcj1I5KY0k0V88zJ+XXIkkfHGj6uJikyzNl9IoeWDBuFEpmReiGgWg10kuEdyV3wgqEuYiERxeV/ciLM3BcKtlKSorbNV3xo4uvAG9q4+2kvF/14DowGXkk/LiYyGG6zFpkXHPl5z7z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727712598; c=relaxed/simple; bh=0RR7Us/iLVVmyrygYAhgJANRosrqiUaP9lw1FvynpUg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GAA0Iuxo27buU+ifYtzfqCZ7Awzpkiiefq+3ueEIGGz5Rv9Ey5VsMPdzGai7ZJs6D1x+EoY/MGwokrT5Gbx1L5tLSOL9WT5LNTh1yhDhvylMQDm2ogOktWaGxulrZ+RGuvostphGAw+U92/zQ4vfN+srm6x7SDhVc1ZFCZPabo4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev; spf=fail smtp.mailfrom=pbarker.dev; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pbarker.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=pbarker.dev X-IronPort-AV: E=Sophos;i="6.11,166,1725289200"; d="scan'208";a="220371981" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 01 Oct 2024 01:09:55 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.43]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id AB3974014DD8; Tue, 1 Oct 2024 01:09:50 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 11/11] net: ravb: Add VLAN checksum support Date: Mon, 30 Sep 2024 17:08:45 +0100 Message-Id: <20240930160845.8520-12-paul@pbarker.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930160845.8520-1-paul@pbarker.dev> References: <20240930160845.8520-1-paul@pbarker.dev> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Paul Barker The GbEth IP supports offloading checksum calculation for VLAN-tagged packets, provided that the EtherType is 0x8100 and only one VLAN tag is present. Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb.h | 1 + drivers/net/ethernet/renesas/ravb_main.c | 27 +++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index 2cb6c4ef1330..bfa834afc03a 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1056,6 +1056,7 @@ struct ravb_hw_info { size_t gstrings_size; netdev_features_t net_hw_features; netdev_features_t net_features; + netdev_features_t vlan_features; int stats_len; u32 tccr_mask; u32 tx_max_frame_size; diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 832132d44fb4..eb7499d42a9b 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2063,11 +2063,30 @@ static void ravb_tx_timeout_work(struct work_struct *work) static bool ravb_can_tx_csum_gbeth(struct sk_buff *skb) { - /* TODO: Need to add support for VLAN tag 802.1Q */ - if (skb_vlan_tag_present(skb)) + u16 net_protocol = ntohs(skb->protocol); + + /* GbEth IP can calculate the checksum if: + * - there are zero or one VLAN headers with TPID=0x8100 + * - the network protocol is IPv4 or IPv6 + * - the transport protocol is TCP, UDP or ICMP + * - the packet is not fragmented + */ + + if (skb_vlan_tag_present(skb) && + (skb->vlan_proto != ETH_P_8021Q || net_protocol == ETH_P_8021Q)) return false; - switch (ntohs(skb->protocol)) { + if (net_protocol == ETH_P_8021Q) { + struct vlan_hdr vhdr, *vh; + + vh = skb_header_pointer(skb, ETH_HLEN, sizeof(vhdr), &vhdr); + if (!vh) + return false; + + net_protocol = ntohs(vh->h_vlan_encapsulated_proto); + } + + switch (net_protocol) { case ETH_P_IP: switch (ip_hdr(skb)->protocol) { case IPPROTO_TCP: @@ -2772,6 +2791,7 @@ static const struct ravb_hw_info gbeth_hw_info = { .gstrings_size = sizeof(ravb_gstrings_stats_gbeth), .net_hw_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM, .net_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM, + .vlan_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM, .stats_len = ARRAY_SIZE(ravb_gstrings_stats_gbeth), .tccr_mask = TCCR_TSRQ0, .tx_max_frame_size = 1522, @@ -2914,6 +2934,7 @@ static int ravb_probe(struct platform_device *pdev) ndev->features = info->net_features; ndev->hw_features = info->net_hw_features; + ndev->vlan_features = info->vlan_features; error = reset_control_deassert(rstc); if (error)