1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */ 2*4882a593Smuzhiyun /**************************************************************************** 3*4882a593Smuzhiyun * Driver for Solarflare network controllers and boards 4*4882a593Smuzhiyun * Copyright 2005-2006 Fen Systems Ltd. 5*4882a593Smuzhiyun * Copyright 2006-2015 Solarflare Communications Inc. 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef EFX_TX_H 9*4882a593Smuzhiyun #define EFX_TX_H 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #include <linux/types.h> 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun /* Driver internal tx-path related declarations. */ 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun unsigned int efx_tx_limit_len(struct efx_tx_queue *tx_queue, 16*4882a593Smuzhiyun dma_addr_t dma_addr, unsigned int len); 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun u8 *efx_tx_get_copy_buffer_limited(struct efx_tx_queue *tx_queue, 19*4882a593Smuzhiyun struct efx_tx_buffer *buffer, size_t len); 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun /* What TXQ type will satisfy the checksum offloads required for this skb? */ efx_tx_csum_type_skb(struct sk_buff * skb)22*4882a593Smuzhiyunstatic inline unsigned int efx_tx_csum_type_skb(struct sk_buff *skb) 23*4882a593Smuzhiyun { 24*4882a593Smuzhiyun if (skb->ip_summed != CHECKSUM_PARTIAL) 25*4882a593Smuzhiyun return 0; /* no checksum offload */ 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun if (skb->encapsulation && 28*4882a593Smuzhiyun skb_checksum_start_offset(skb) == skb_inner_transport_offset(skb)) { 29*4882a593Smuzhiyun /* we only advertise features for IPv4 and IPv6 checksums on 30*4882a593Smuzhiyun * encapsulated packets, so if the checksum is for the inner 31*4882a593Smuzhiyun * packet, it must be one of them; no further checking required. 32*4882a593Smuzhiyun */ 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun /* Do we also need to offload the outer header checksum? */ 35*4882a593Smuzhiyun if (skb_shinfo(skb)->gso_segs > 1 && 36*4882a593Smuzhiyun !(skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL) && 37*4882a593Smuzhiyun (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL_CSUM)) 38*4882a593Smuzhiyun return EFX_TXQ_TYPE_OUTER_CSUM | EFX_TXQ_TYPE_INNER_CSUM; 39*4882a593Smuzhiyun return EFX_TXQ_TYPE_INNER_CSUM; 40*4882a593Smuzhiyun } 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun /* similarly, we only advertise features for IPv4 and IPv6 checksums, 43*4882a593Smuzhiyun * so it must be one of them. No need for further checks. 44*4882a593Smuzhiyun */ 45*4882a593Smuzhiyun return EFX_TXQ_TYPE_OUTER_CSUM; 46*4882a593Smuzhiyun } 47*4882a593Smuzhiyun #endif /* EFX_TX_H */ 48