tx.h 1.4 KB

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