checksum.h 961 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (C) 2008 Michal Simek <monstr@monstr.eu>
  3. * Copyright (C) 2006 Atmark Techno, Inc.
  4. *
  5. * This file is subject to the terms and conditions of the GNU General Public
  6. * License. See the file "COPYING" in the main directory of this archive
  7. * for more details.
  8. */
  9. #ifndef _ASM_MICROBLAZE_CHECKSUM_H
  10. #define _ASM_MICROBLAZE_CHECKSUM_H
  11. /*
  12. * computes the checksum of the TCP/UDP pseudo-header
  13. * returns a 16-bit checksum, already complemented
  14. */
  15. #define csum_tcpudp_nofold csum_tcpudp_nofold
  16. static inline __wsum
  17. csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
  18. unsigned short proto, __wsum sum)
  19. {
  20. __asm__("add %0, %0, %1\n\t"
  21. "addc %0, %0, %2\n\t"
  22. "addc %0, %0, %3\n\t"
  23. "addc %0, %0, r0\n\t"
  24. : "+&d" (sum)
  25. : "d" (saddr), "d" (daddr),
  26. #ifdef __MICROBLAZEEL__
  27. "d" ((len + proto) << 8)
  28. #else
  29. "d" (len + proto)
  30. #endif
  31. );
  32. return sum;
  33. }
  34. #include <asm-generic/checksum.h>
  35. #endif /* _ASM_MICROBLAZE_CHECKSUM_H */