diff options
Diffstat (limited to 'include/net/sctp/checksum.h')
-rw-r--r-- | include/net/sctp/checksum.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h index ba75c67cb992..b799fb21519a 100644 --- a/include/net/sctp/checksum.h +++ b/include/net/sctp/checksum.h | |||
@@ -46,9 +46,14 @@ | |||
46 | #include <net/sctp/sctp.h> | 46 | #include <net/sctp/sctp.h> |
47 | #include <linux/crc32c.h> | 47 | #include <linux/crc32c.h> |
48 | 48 | ||
49 | static inline __u32 sctp_start_cksum(__u8 *buffer, __u16 length) | 49 | static inline __be32 sctp_crc32c(__be32 crc, u8 *buffer, u16 length) |
50 | { | 50 | { |
51 | __u32 crc = ~(__u32) 0; | 51 | return (__force __be32)crc32c((__force u32)crc, buffer, length); |
52 | } | ||
53 | |||
54 | static inline __be32 sctp_start_cksum(__u8 *buffer, __u16 length) | ||
55 | { | ||
56 | __be32 crc = ~cpu_to_be32(0); | ||
52 | __u8 zero[sizeof(__u32)] = {0}; | 57 | __u8 zero[sizeof(__u32)] = {0}; |
53 | 58 | ||
54 | /* Optimize this routine to be SCTP specific, knowing how | 59 | /* Optimize this routine to be SCTP specific, knowing how |
@@ -56,23 +61,23 @@ static inline __u32 sctp_start_cksum(__u8 *buffer, __u16 length) | |||
56 | */ | 61 | */ |
57 | 62 | ||
58 | /* Calculate CRC up to the checksum. */ | 63 | /* Calculate CRC up to the checksum. */ |
59 | crc = crc32c(crc, buffer, sizeof(struct sctphdr) - sizeof(__u32)); | 64 | crc = sctp_crc32c(crc, buffer, sizeof(struct sctphdr) - sizeof(__u32)); |
60 | 65 | ||
61 | /* Skip checksum field of the header. */ | 66 | /* Skip checksum field of the header. */ |
62 | crc = crc32c(crc, zero, sizeof(__u32)); | 67 | crc = sctp_crc32c(crc, zero, sizeof(__u32)); |
63 | 68 | ||
64 | /* Calculate the rest of the CRC. */ | 69 | /* Calculate the rest of the CRC. */ |
65 | crc = crc32c(crc, &buffer[sizeof(struct sctphdr)], | 70 | crc = sctp_crc32c(crc, &buffer[sizeof(struct sctphdr)], |
66 | length - sizeof(struct sctphdr)); | 71 | length - sizeof(struct sctphdr)); |
67 | return crc; | 72 | return crc; |
68 | } | 73 | } |
69 | 74 | ||
70 | static inline __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32) | 75 | static inline __be32 sctp_update_cksum(__u8 *buffer, __u16 length, __be32 crc32) |
71 | { | 76 | { |
72 | return crc32c(crc32, buffer, length); | 77 | return sctp_crc32c(crc32, buffer, length); |
73 | } | 78 | } |
74 | 79 | ||
75 | static inline __u32 sctp_end_cksum(__u32 crc32) | 80 | static inline __be32 sctp_end_cksum(__be32 crc32) |
76 | { | 81 | { |
77 | return ntohl(~crc32); | 82 | return ~crc32; |
78 | } | 83 | } |