netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xin Long <lucien.xin@gmail.com>
To: network dev <netdev@vger.kernel.org>
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Davide Caratti <dcaratti@redhat.com>,
	davem@davemloft.net, Jakub Kicinski <kuba@kernel.org>,
	Alexander Duyck <alexander.duyck@gmail.com>
Subject: [PATCH net-next 2/3] net: add CSUM_T_IP_GENERIC csum_type
Date: Thu, 21 Jan 2021 16:45:37 +0800	[thread overview]
Message-ID: <bb59ed7c9c438bf076da3a956bb24fddf80978f7.1611218673.git.lucien.xin@gmail.com> (raw)
In-Reply-To: <0fa4f7f04222e0c4e7bd27cbd86ffe22148f6476.1611218673.git.lucien.xin@gmail.com>
In-Reply-To: <cover.1611218673.git.lucien.xin@gmail.com>

This patch is to extend csum_type field to 2 bits, and introduce
CSUM_T_IP_GENERIC csum type, and add the support for this in
skb_csum_hwoffload_help(), just like CSUM_T_SCTP_CRC.

Note here it moves dst_pending_confirm field below ndisc_nodetype
to avoid a memory hole.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/linux/skbuff.h |  5 +++--
 net/core/dev.c         | 17 +++++++++++++----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 67b0a01..d5011fb 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -224,6 +224,7 @@
 
 #define CSUM_T_INET		0
 #define CSUM_T_SCTP_CRC		1
+#define CSUM_T_IP_GENERIC	2
 
 /* Maximum value in skb->csum_level */
 #define SKB_MAX_CSUM_LEVEL	3
@@ -839,11 +840,11 @@ struct sk_buff {
 	__u8			vlan_present:1;
 	__u8			csum_complete_sw:1;
 	__u8			csum_level:2;
-	__u8			csum_type:1;
-	__u8			dst_pending_confirm:1;
+	__u8			csum_type:2;
 #ifdef CONFIG_IPV6_NDISC_NODETYPE
 	__u8			ndisc_nodetype:2;
 #endif
+	__u8			dst_pending_confirm:1;
 
 	__u8			ipvs_property:1;
 	__u8			inner_protocol_type:1;
diff --git a/net/core/dev.c b/net/core/dev.c
index 3241de2..6d48af2 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3617,11 +3617,20 @@ static struct sk_buff *validate_xmit_vlan(struct sk_buff *skb,
 int skb_csum_hwoffload_help(struct sk_buff *skb,
 			    const netdev_features_t features)
 {
-	if (unlikely(skb_csum_is_sctp(skb)))
-		return !!(features & NETIF_F_SCTP_CRC) ? 0 :
-			skb_crc32c_csum_help(skb);
+	if (likely(!skb->csum_type))
+		return !!(features & NETIF_F_CSUM_MASK) ? 0 :
+		       skb_checksum_help(skb);
 
-	return !!(features & NETIF_F_CSUM_MASK) ? 0 : skb_checksum_help(skb);
+	if (skb_csum_is_sctp(skb)) {
+		return !!(features & NETIF_F_SCTP_CRC) ? 0 :
+		       skb_crc32c_csum_help(skb);
+	} else if (skb->csum_type == CSUM_T_IP_GENERIC) {
+		return !!(features & NETIF_F_HW_CSUM) ? 0 :
+		       skb_checksum_help(skb);
+	} else {
+		pr_warn("Wrong csum type: %d\n", skb->csum_type);
+		return 1;
+	}
 }
 EXPORT_SYMBOL(skb_csum_hwoffload_help);
 
-- 
2.1.0


  reply	other threads:[~2021-01-21 19:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21  8:45 [PATCH net-next 0/3] net: add support for ip generic checksum offload for gre Xin Long
2021-01-21  8:45 ` [PATCH net-next 1/3] net: rename csum_not_inet to csum_type Xin Long
2021-01-21  8:45   ` Xin Long [this message]
2021-01-21  8:45     ` [PATCH net-next 3/3] ip_gre: add csum offload support for gre header Xin Long
2021-01-21 18:13     ` [PATCH net-next 2/3] net: add CSUM_T_IP_GENERIC csum_type Alexander Duyck
2021-01-22  3:18       ` Xin Long
2021-01-22 16:17         ` Alexander Duyck
2021-01-22  2:50   ` [PATCH net-next 1/3] net: rename csum_not_inet to csum_type Jakub Kicinski
2021-01-22  3:08     ` Xin Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bb59ed7c9c438bf076da3a956bb24fddf80978f7.1611218673.git.lucien.xin@gmail.com \
    --to=lucien.xin@gmail.com \
    --cc=alexander.duyck@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dcaratti@redhat.com \
    --cc=kuba@kernel.org \
    --cc=marcelo.leitner@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).