diff mbox series

[net-next,1/6] net: add inline function skb_csum_is_sctp

Message ID 34c9f5b8c31610687925d9db1f151d5bc87deba7.1610777159.git.lucien.xin@gmail.com (mailing list archive)
State Accepted
Commit fa82117010430aff2ce86400f7328f55a31b48a6
Delegated to: Netdev Maintainers
Headers show
Series net: support SCTP CRC csum offload for tunneling packets in some drivers | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 21 maintainers not CCed: pabeni@redhat.com daniel@iogearbox.net willemb@google.com pablo@netfilter.org nogikh@google.com bjorn.topel@intel.com andriin@fb.com jakub@cloudflare.com edumazet@google.com ast@kernel.org ap420073@gmail.com rdunlap@infradead.org drivers@pensando.io xiyou.wangcong@gmail.com jiri@mellanox.com elver@google.com decui@microsoft.com snelson@pensando.io jonathan.lemon@gmail.com herbert@gondor.apana.org.au steffen.klassert@secunet.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 8831 this patch: 8831
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 9242 this patch: 9242
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Xin Long Jan. 16, 2021, 6:13 a.m. UTC
This patch is to define a inline function skb_csum_is_sctp(), and
also replace all places where it checks if it's a SCTP CSUM skb.
This function would be used later in many networking drivers in
the following patches.

Suggested-by: Alexander Duyck <alexander.duyck@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 2 +-
 include/linux/skbuff.h                           | 5 +++++
 net/core/dev.c                                   | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

Comments

Alexander Duyck Jan. 19, 2021, 10:23 p.m. UTC | #1
On Fri, Jan 15, 2021 at 10:13 PM Xin Long <lucien.xin@gmail.com> wrote:
>
> This patch is to define a inline function skb_csum_is_sctp(), and
> also replace all places where it checks if it's a SCTP CSUM skb.
> This function would be used later in many networking drivers in
> the following patches.
>
> Suggested-by: Alexander Duyck <alexander.duyck@gmail.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

One minor nit. If you had to resubmit this I might move the ionic
driver code into a separate patch. However It can probably be accepted
as is.

Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>

> ---
>  drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 2 +-
>  include/linux/skbuff.h                           | 5 +++++
>  net/core/dev.c                                   | 2 +-
>  3 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> index ac4cd5d..162a1ff 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> @@ -979,7 +979,7 @@ static int ionic_tx_calc_csum(struct ionic_queue *q, struct sk_buff *skb)
>                 stats->vlan_inserted++;
>         }
>
> -       if (skb->csum_not_inet)
> +       if (skb_csum_is_sctp(skb))
>                 stats->crc32_csum++;
>         else
>                 stats->csum++;
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index c9568cf..46f901a 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -4621,6 +4621,11 @@ static inline void skb_reset_redirect(struct sk_buff *skb)
>  #endif
>  }
>
> +static inline bool skb_csum_is_sctp(struct sk_buff *skb)
> +{
> +       return skb->csum_not_inet;
> +}
> +
>  static inline void skb_set_kcov_handle(struct sk_buff *skb,
>                                        const u64 kcov_handle)
>  {
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 0a31d4e..bbd306f 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -3617,7 +3617,7 @@ 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_not_inet))
> +       if (unlikely(skb_csum_is_sctp(skb)))
>                 return !!(features & NETIF_F_SCTP_CRC) ? 0 :
>                         skb_crc32c_csum_help(skb);
>
> --
> 2.1.0
>
Shannon Nelson Jan. 19, 2021, 11:35 p.m. UTC | #2
On 1/19/21 2:23 PM, Alexander Duyck wrote:
> On Fri, Jan 15, 2021 at 10:13 PM Xin Long <lucien.xin@gmail.com> wrote:
>> This patch is to define a inline function skb_csum_is_sctp(), and
>> also replace all places where it checks if it's a SCTP CSUM skb.
>> This function would be used later in many networking drivers in
>> the following patches.
>>
>> Suggested-by: Alexander Duyck <alexander.duyck@gmail.com>
>> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> One minor nit. If you had to resubmit this I might move the ionic
> driver code into a separate patch. However It can probably be accepted
> as is.
>
> Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>

Alex has a good point - if you repost, please split out the ionic bits 
to a separate patch.

Either way, for ionic:
Acked-by: Shannon Nelson <snelson@pensando.io>


>> ---
>>   drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 2 +-
>>   include/linux/skbuff.h                           | 5 +++++
>>   net/core/dev.c                                   | 2 +-
>>   3 files changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
>> index ac4cd5d..162a1ff 100644
>> --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
>> +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
>> @@ -979,7 +979,7 @@ static int ionic_tx_calc_csum(struct ionic_queue *q, struct sk_buff *skb)
>>                  stats->vlan_inserted++;
>>          }
>>
>> -       if (skb->csum_not_inet)
>> +       if (skb_csum_is_sctp(skb))
>>                  stats->crc32_csum++;
>>          else
>>                  stats->csum++;
>> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
>> index c9568cf..46f901a 100644
>> --- a/include/linux/skbuff.h
>> +++ b/include/linux/skbuff.h
>> @@ -4621,6 +4621,11 @@ static inline void skb_reset_redirect(struct sk_buff *skb)
>>   #endif
>>   }
>>
>> +static inline bool skb_csum_is_sctp(struct sk_buff *skb)
>> +{
>> +       return skb->csum_not_inet;
>> +}
>> +
>>   static inline void skb_set_kcov_handle(struct sk_buff *skb,
>>                                         const u64 kcov_handle)
>>   {
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index 0a31d4e..bbd306f 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -3617,7 +3617,7 @@ 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_not_inet))
>> +       if (unlikely(skb_csum_is_sctp(skb)))
>>                  return !!(features & NETIF_F_SCTP_CRC) ? 0 :
>>                          skb_crc32c_csum_help(skb);
>>
>> --
>> 2.1.0
>>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index ac4cd5d..162a1ff 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -979,7 +979,7 @@  static int ionic_tx_calc_csum(struct ionic_queue *q, struct sk_buff *skb)
 		stats->vlan_inserted++;
 	}
 
-	if (skb->csum_not_inet)
+	if (skb_csum_is_sctp(skb))
 		stats->crc32_csum++;
 	else
 		stats->csum++;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c9568cf..46f901a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -4621,6 +4621,11 @@  static inline void skb_reset_redirect(struct sk_buff *skb)
 #endif
 }
 
+static inline bool skb_csum_is_sctp(struct sk_buff *skb)
+{
+	return skb->csum_not_inet;
+}
+
 static inline void skb_set_kcov_handle(struct sk_buff *skb,
 				       const u64 kcov_handle)
 {
diff --git a/net/core/dev.c b/net/core/dev.c
index 0a31d4e..bbd306f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3617,7 +3617,7 @@  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_not_inet))
+	if (unlikely(skb_csum_is_sctp(skb)))
 		return !!(features & NETIF_F_SCTP_CRC) ? 0 :
 			skb_crc32c_csum_help(skb);