Commit bb4644b1 authored by Heiko Carstens's avatar Heiko Carstens Committed by Vasily Gorbik

s390/checksum: rewrite csum_tcpudp_nofold()

Rewrite csum_tcpudp_nofold() so that the generated code will not
contain branches. The old implementation was also optimized for
machines which came with "add logical with carry" instructions,
however the compiler doesn't generate them anymore. This is most
likely because those instructions are slower.

However with the old code the compiler generates a lot of branches,
which isn't too helpful usually. Therefore rewrite the code.

In a tight loop this doesn't make any difference since the branch
prediction unit does its job.
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent b064904c
...@@ -73,25 +73,17 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) ...@@ -73,25 +73,17 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
* computes the checksum of the TCP/UDP pseudo-header * computes the checksum of the TCP/UDP pseudo-header
* returns a 32-bit checksum * returns a 32-bit checksum
*/ */
static inline __wsum static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len, __u8 proto, __u8 proto, __wsum sum)
__wsum sum)
{ {
__u32 csum = (__force __u32)sum; __u64 csum = (__force __u64)sum;
csum += (__force __u32)saddr; csum += (__force __u32)saddr;
if (csum < (__force __u32)saddr)
csum++;
csum += (__force __u32)daddr; csum += (__force __u32)daddr;
if (csum < (__force __u32)daddr) csum += len;
csum++; csum += proto;
csum += (csum >> 32) | (csum << 32);
csum += len + proto; return (__force __wsum)(csum >> 32);
if (csum < len + proto)
csum++;
return (__force __wsum)csum;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment