checksum.h 899 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * akbar.hussain@lineo.com
  4. *
  5. * Licensed under the GPL-2 or later.
  6. */
  7. #ifndef _BFIN_CHECKSUM_H
  8. #define _BFIN_CHECKSUM_H
  9. /*
  10. * computes the checksum of the TCP/UDP pseudo-header
  11. * returns a 16-bit checksum, already complemented
  12. */
  13. static inline __wsum
  14. __csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
  15. __u8 proto, __wsum sum)
  16. {
  17. unsigned int carry;
  18. __asm__ ("%0 = %0 + %2;\n\t"
  19. "CC = AC0;\n\t"
  20. "%1 = CC;\n\t"
  21. "%0 = %0 + %1;\n\t"
  22. "%0 = %0 + %3;\n\t"
  23. "CC = AC0;\n\t"
  24. "%1 = CC;\n\t"
  25. "%0 = %0 + %1;\n\t"
  26. "%0 = %0 + %4;\n\t"
  27. "CC = AC0;\n\t"
  28. "%1 = CC;\n\t"
  29. "%0 = %0 + %1;\n\t"
  30. : "=d" (sum), "=&d" (carry)
  31. : "d" (daddr), "d" (saddr), "d" ((len + proto) << 8), "0"(sum)
  32. : "CC");
  33. return (sum);
  34. }
  35. #define csum_tcpudp_nofold __csum_tcpudp_nofold
  36. #include <asm-generic/checksum.h>
  37. #endif