* [net-next PATCH v2 01/10] net: ravb: Factor out checksum offload enable bits
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
@ 2024-10-15 13:36 ` Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 02/10] net: ravb: Disable IP header RX checksum offloading Paul Barker
` (9 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Paul Barker @ 2024-10-15 13:36 UTC (permalink / raw)
To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Paul Barker, Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
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.
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
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 41f88f8836f8..c8988c0c85a1 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;
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [net-next PATCH v2 02/10] net: ravb: Disable IP header RX checksum offloading
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 01/10] net: ravb: Factor out checksum offload enable bits Paul Barker
@ 2024-10-15 13:36 ` Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 03/10] net: ravb: Drop IP protocol check from RX csum verification Paul Barker
` (8 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Paul Barker @ 2024-10-15 13:36 UTC (permalink / raw)
To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Paul Barker, Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
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.
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
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 c8988c0c85a1..43db69d03684 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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [net-next PATCH v2 03/10] net: ravb: Drop IP protocol check from RX csum verification
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 01/10] net: ravb: Factor out checksum offload enable bits Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 02/10] net: ravb: Disable IP header RX checksum offloading Paul Barker
@ 2024-10-15 13:36 ` Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 04/10] net: ravb: Combine if conditions in RX csum validation Paul Barker
` (7 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Paul Barker @ 2024-10-15 13:36 UTC (permalink / raw)
To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Paul Barker, Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
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.
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
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 43db69d03684..4bc2532706c2 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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [net-next PATCH v2 04/10] net: ravb: Combine if conditions in RX csum validation
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
` (2 preceding siblings ...)
2024-10-15 13:36 ` [net-next PATCH v2 03/10] net: ravb: Drop IP protocol check from RX csum verification Paul Barker
@ 2024-10-15 13:36 ` Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 05/10] net: ravb: Simplify types " Paul Barker
` (6 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Paul Barker @ 2024-10-15 13:36 UTC (permalink / raw)
To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Paul Barker, Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
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.
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
drivers/net/ethernet/renesas/ravb_main.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 4bc2532706c2..2f584c353c78 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -750,7 +750,6 @@ 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;
/* The hardware checksum status is contained in sizeof(__sum16) * 2 = 4
@@ -766,21 +765,19 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb)
return;
if (skb_is_nonlinear(skb)) {
- last_frag = &shinfo->frags[shinfo->nr_frags - 1];
+ skb_frag_t *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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [net-next PATCH v2 05/10] net: ravb: Simplify types in RX csum validation
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
` (3 preceding siblings ...)
2024-10-15 13:36 ` [net-next PATCH v2 04/10] net: ravb: Combine if conditions in RX csum validation Paul Barker
@ 2024-10-15 13:36 ` Paul Barker
2024-10-15 15:23 ` Sergey Shtylyov
2024-10-15 13:36 ` [net-next PATCH v2 06/10] net: ravb: Disable IP header TX checksum offloading Paul Barker
` (5 subsequent siblings)
10 siblings, 1 reply; 15+ messages in thread
From: Paul Barker @ 2024-10-15 13:36 UTC (permalink / raw)
To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Paul Barker, Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
The hardware 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 <paul.barker.ct@bp.renesas.com>
---
drivers/net/ethernet/renesas/ravb_main.c | 26 +++++++++++-------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 2f584c353c78..ca8f785b96b4 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -749,11 +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;
- 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().
@@ -761,24 +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)) {
skb_frag_t *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));
+ 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 (!get_unaligned(--hw_csum))
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [net-next PATCH v2 05/10] net: ravb: Simplify types in RX csum validation
2024-10-15 13:36 ` [net-next PATCH v2 05/10] net: ravb: Simplify types " Paul Barker
@ 2024-10-15 15:23 ` Sergey Shtylyov
0 siblings, 0 replies; 15+ messages in thread
From: Sergey Shtylyov @ 2024-10-15 15:23 UTC (permalink / raw)
To: Paul Barker, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
On 10/15/24 4:36 PM, Paul Barker wrote:
> The hardware 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 <paul.barker.ct@bp.renesas.com>
[...]
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
MBR, Sergey
^ permalink raw reply [flat|nested] 15+ messages in thread
* [net-next PATCH v2 06/10] net: ravb: Disable IP header TX checksum offloading
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
` (4 preceding siblings ...)
2024-10-15 13:36 ` [net-next PATCH v2 05/10] net: ravb: Simplify types " Paul Barker
@ 2024-10-15 13:36 ` Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 07/10] net: ravb: Simplify UDP TX checksum offload Paul Barker
` (4 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Paul Barker @ 2024-10-15 13:36 UTC (permalink / raw)
To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Paul Barker, Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
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.
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
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,
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [net-next PATCH v2 07/10] net: ravb: Simplify UDP TX checksum offload
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
` (5 preceding siblings ...)
2024-10-15 13:36 ` [net-next PATCH v2 06/10] net: ravb: Disable IP header TX checksum offloading Paul Barker
@ 2024-10-15 13:36 ` Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 08/10] net: ravb: Enable IPv6 RX checksum offloading for GbEth Paul Barker
` (3 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Paul Barker @ 2024-10-15 13:36 UTC (permalink / raw)
To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Paul Barker, Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
The GbEth IP will pass through a zero UDP checksum without asserting any
error flags so we do not need to resort to software checksum calculation
in this case.
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
drivers/net/ethernet/renesas/ravb_main.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index ca8f785b96b4..80c0d36bffcb 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2075,20 +2075,11 @@ 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 */
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [net-next PATCH v2 08/10] net: ravb: Enable IPv6 RX checksum offloading for GbEth
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
` (6 preceding siblings ...)
2024-10-15 13:36 ` [net-next PATCH v2 07/10] net: ravb: Simplify UDP TX checksum offload Paul Barker
@ 2024-10-15 13:36 ` Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 09/10] net: ravb: Enable IPv6 TX checksum offload " Paul Barker
` (2 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Paul Barker @ 2024-10-15 13:36 UTC (permalink / raw)
To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Paul Barker, Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
The GbEth IP supports offloading IPv6 TCP, UDP & ICMPv6 checksums in the
RX path.
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
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 a5b4f4fe77b1..e1e55e677215 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
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [net-next PATCH v2 09/10] net: ravb: Enable IPv6 TX checksum offload for GbEth
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
` (7 preceding siblings ...)
2024-10-15 13:36 ` [net-next PATCH v2 08/10] net: ravb: Enable IPv6 RX checksum offloading for GbEth Paul Barker
@ 2024-10-15 13:36 ` Paul Barker
2024-10-15 15:47 ` Sergey Shtylyov
2024-10-15 13:36 ` [net-next PATCH v2 10/10] net: ravb: Add VLAN checksum support Paul Barker
2024-10-18 2:30 ` [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets patchwork-bot+netdevbpf
10 siblings, 1 reply; 15+ messages in thread
From: Paul Barker @ 2024-10-15 13:36 UTC (permalink / raw)
To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Paul Barker, Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
The GbEth IP supports offloading IPv6 TCP, UDP & ICMPv6 checksums in the
TX path.
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
drivers/net/ethernet/renesas/ravb.h | 2 +-
drivers/net/ethernet/renesas/ravb_main.c | 15 +++++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index e1e55e677215..d7b3810ce21b 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_TTCP6 | CSR1_TUDP6)
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 80c0d36bffcb..14b4462331b0 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2063,17 +2063,24 @@ 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);
+ u8 inner_protocol;
/* 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))
+ switch (ntohs(skb->protocol)) {
+ case ETH_P_IP:
+ inner_protocol = ip_hdr(skb)->protocol;
+ break;
+ case ETH_P_IPV6:
+ inner_protocol = ipv6_hdr(skb)->nexthdr;
+ break;
+ default:
return false;
+ }
- switch (ip->protocol) {
+ switch (inner_protocol) {
case IPPROTO_TCP:
case IPPROTO_UDP:
return true;
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [net-next PATCH v2 09/10] net: ravb: Enable IPv6 TX checksum offload for GbEth
2024-10-15 13:36 ` [net-next PATCH v2 09/10] net: ravb: Enable IPv6 TX checksum offload " Paul Barker
@ 2024-10-15 15:47 ` Sergey Shtylyov
0 siblings, 0 replies; 15+ messages in thread
From: Sergey Shtylyov @ 2024-10-15 15:47 UTC (permalink / raw)
To: Paul Barker, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
On 10/15/24 4:36 PM, Paul Barker wrote:
> The GbEth IP supports offloading IPv6 TCP, UDP & ICMPv6 checksums in the
> TX path.
>
> Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
[...]
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 15+ messages in thread
* [net-next PATCH v2 10/10] net: ravb: Add VLAN checksum support
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
` (8 preceding siblings ...)
2024-10-15 13:36 ` [net-next PATCH v2 09/10] net: ravb: Enable IPv6 TX checksum offload " Paul Barker
@ 2024-10-15 13:36 ` Paul Barker
2024-10-15 15:50 ` Sergey Shtylyov
2024-10-18 2:30 ` [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets patchwork-bot+netdevbpf
10 siblings, 1 reply; 15+ messages in thread
From: Paul Barker @ 2024-10-15 13:36 UTC (permalink / raw)
To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Paul Barker, Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
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 <paul.barker.ct@bp.renesas.com>
---
drivers/net/ethernet/renesas/ravb.h | 1 +
drivers/net/ethernet/renesas/ravb_main.c | 24 ++++++++++++++++++++----
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index d7b3810ce21b..7b48060c250b 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1055,6 +1055,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 14b4462331b0..bc56f1f4bec9 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2063,13 +2063,27 @@ static void ravb_tx_timeout_work(struct work_struct *work)
static bool ravb_can_tx_csum_gbeth(struct sk_buff *skb)
{
+ u16 net_protocol = ntohs(skb->protocol);
u8 inner_protocol;
- /* TODO: Need to add support for VLAN tag 802.1Q */
- if (skb_vlan_tag_present(skb))
- return false;
+ /* 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 (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 (ntohs(skb->protocol)) {
+ switch (net_protocol) {
case ETH_P_IP:
inner_protocol = ip_hdr(skb)->protocol;
break;
@@ -2772,6 +2786,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 +2929,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)
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [net-next PATCH v2 10/10] net: ravb: Add VLAN checksum support
2024-10-15 13:36 ` [net-next PATCH v2 10/10] net: ravb: Add VLAN checksum support Paul Barker
@ 2024-10-15 15:50 ` Sergey Shtylyov
0 siblings, 0 replies; 15+ messages in thread
From: Sergey Shtylyov @ 2024-10-15 15:50 UTC (permalink / raw)
To: Paul Barker, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Geert Uytterhoeven, Niklas Söderlund, Biju Das,
Claudiu Beznea, netdev, linux-renesas-soc, linux-kernel
On 10/15/24 4:36 PM, Paul Barker wrote:
> 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 <paul.barker.ct@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
` (9 preceding siblings ...)
2024-10-15 13:36 ` [net-next PATCH v2 10/10] net: ravb: Add VLAN checksum support Paul Barker
@ 2024-10-18 2:30 ` patchwork-bot+netdevbpf
10 siblings, 0 replies; 15+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-18 2:30 UTC (permalink / raw)
To: Paul Barker
Cc: s.shtylyov, davem, edumazet, kuba, pabeni, geert+renesas,
niklas.soderlund+renesas, biju.das.jz, claudiu.beznea.uj, netdev,
linux-renesas-soc, linux-kernel
Hello:
This series was applied to netdev/net-next.git (main)
by Andrew Lunn <andrew@lunn.ch>:
On Tue, 15 Oct 2024 14:36:24 +0100 you wrote:
> The GbEth IP found in Renesas RZ/G2L, RZ/G3S and related SoCs supports
> hardware checksum offload for packets in the following cases:
>
> - 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
>
> [...]
Here is the summary with links:
- [net-next,v2,01/10] net: ravb: Factor out checksum offload enable bits
https://git.kernel.org/netdev/net-next/c/8e3037924a36
- [net-next,v2,02/10] net: ravb: Disable IP header RX checksum offloading
https://git.kernel.org/netdev/net-next/c/c4e347a02b14
- [net-next,v2,03/10] net: ravb: Drop IP protocol check from RX csum verification
https://git.kernel.org/netdev/net-next/c/8d2109c1a515
- [net-next,v2,04/10] net: ravb: Combine if conditions in RX csum validation
https://git.kernel.org/netdev/net-next/c/5a2d973e3606
- [net-next,v2,05/10] net: ravb: Simplify types in RX csum validation
https://git.kernel.org/netdev/net-next/c/faacdbba0180
- [net-next,v2,06/10] net: ravb: Disable IP header TX checksum offloading
https://git.kernel.org/netdev/net-next/c/4574ba5b711d
- [net-next,v2,07/10] net: ravb: Simplify UDP TX checksum offload
https://git.kernel.org/netdev/net-next/c/e63b5fd02a00
- [net-next,v2,08/10] net: ravb: Enable IPv6 RX checksum offloading for GbEth
https://git.kernel.org/netdev/net-next/c/59cceae40c67
- [net-next,v2,09/10] net: ravb: Enable IPv6 TX checksum offload for GbEth
https://git.kernel.org/netdev/net-next/c/85c171509821
- [net-next,v2,10/10] net: ravb: Add VLAN checksum support
https://git.kernel.org/netdev/net-next/c/546875ccba93
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 15+ messages in thread