Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /****************************************************************************
0003  * Driver for Solarflare network controllers and boards
0004  * Copyright 2005-2006 Fen Systems Ltd.
0005  * Copyright 2006-2015 Solarflare Communications Inc.
0006  */
0007 
0008 #ifndef EFX_TX_H
0009 #define EFX_TX_H
0010 
0011 #include <linux/types.h>
0012 
0013 /* Driver internal tx-path related declarations. */
0014 /* What TXQ type will satisfy the checksum offloads required for this skb? */
0015 static inline unsigned int efx_tx_csum_type_skb(struct sk_buff *skb)
0016 {
0017     if (skb->ip_summed != CHECKSUM_PARTIAL)
0018         return 0; /* no checksum offload */
0019 
0020     if (skb->encapsulation &&
0021         skb_checksum_start_offset(skb) == skb_inner_transport_offset(skb)) {
0022         /* we only advertise features for IPv4 and IPv6 checksums on
0023          * encapsulated packets, so if the checksum is for the inner
0024          * packet, it must be one of them; no further checking required.
0025          */
0026 
0027         /* Do we also need to offload the outer header checksum? */
0028         if (skb_shinfo(skb)->gso_segs > 1 &&
0029             !(skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL) &&
0030             (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL_CSUM))
0031             return EFX_TXQ_TYPE_OUTER_CSUM | EFX_TXQ_TYPE_INNER_CSUM;
0032         return EFX_TXQ_TYPE_INNER_CSUM;
0033     }
0034 
0035     /* similarly, we only advertise features for IPv4 and IPv6 checksums,
0036      * so it must be one of them. No need for further checks.
0037      */
0038     return EFX_TXQ_TYPE_OUTER_CSUM;
0039 }
0040 #endif /* EFX_TX_H */