checksum.h 997 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * linux/arch/unicore32/include/asm/checksum.h
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * IP checksum routines
  13. */
  14. #ifndef __UNICORE_CHECKSUM_H__
  15. #define __UNICORE_CHECKSUM_H__
  16. /*
  17. * computes the checksum of the TCP/UDP pseudo-header
  18. * returns a 16-bit checksum, already complemented
  19. */
  20. static inline __wsum
  21. csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
  22. unsigned short proto, __wsum sum)
  23. {
  24. __asm__(
  25. "add.a %0, %1, %2\n"
  26. "addc.a %0, %0, %3\n"
  27. "addc.a %0, %0, %4 << #8\n"
  28. "addc.a %0, %0, %5\n"
  29. "addc %0, %0, #0\n"
  30. : "=&r"(sum)
  31. : "r" (sum), "r" (daddr), "r" (saddr), "r" (len), "Ir" (htons(proto))
  32. : "cc");
  33. return sum;
  34. }
  35. #define csum_tcpudp_nofold csum_tcpudp_nofold
  36. #include <asm-generic/checksum.h>
  37. #endif