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