summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPuranjay Mohan <puranjay@kernel.org>2024-10-26 12:53:36 +0000
committerDaniel Borkmann <daniel@iogearbox.net>2024-10-30 15:29:59 +0100
commitdb71aae70e3e646d8ba4cb50e4bd4c281a91c804 (patch)
treed4e420584ef738a26224803b3c1d726af5f12e25 /arch
parent0ab7cd1f18648ab50c4685553ca92e8cdc4a42da (diff)
downloadlinux-stable-db71aae70e3e646d8ba4cb50e4bd4c281a91c804.tar.gz
linux-stable-db71aae70e3e646d8ba4cb50e4bd4c281a91c804.tar.bz2
linux-stable-db71aae70e3e646d8ba4cb50e4bd4c281a91c804.zip
net: checksum: Move from32to16() to generic header
from32to16() is used by lib/checksum.c and also by arch/parisc/lib/checksum.c. The next patch will use it in the bpf_csum_diff helper. Move from32to16() to the include/net/checksum.h as csum_from32to16() and remove other implementations. Signed-off-by: Puranjay Mohan <puranjay@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20241026125339.26459-2-puranjay@kernel.org
Diffstat (limited to 'arch')
-rw-r--r--arch/parisc/lib/checksum.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/arch/parisc/lib/checksum.c b/arch/parisc/lib/checksum.c
index 4818f3db84a5..59d8c15d81bd 100644
--- a/arch/parisc/lib/checksum.c
+++ b/arch/parisc/lib/checksum.c
@@ -25,15 +25,6 @@
: "=r"(_t) \
: "r"(_r), "0"(_t));
-static inline unsigned short from32to16(unsigned int x)
-{
- /* 32 bits --> 16 bits + carry */
- x = (x & 0xffff) + (x >> 16);
- /* 16 bits + carry --> 16 bits including carry */
- x = (x & 0xffff) + (x >> 16);
- return (unsigned short)x;
-}
-
static inline unsigned int do_csum(const unsigned char * buff, int len)
{
int odd, count;
@@ -85,7 +76,7 @@ static inline unsigned int do_csum(const unsigned char * buff, int len)
}
if (len & 1)
result += le16_to_cpu(*buff);
- result = from32to16(result);
+ result = csum_from32to16(result);
if (odd)
result = swab16(result);
out:
@@ -102,7 +93,7 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
{
unsigned int result = do_csum(buff, len);
addc(result, sum);
- return (__force __wsum)from32to16(result);
+ return (__force __wsum)csum_from32to16(result);
}
EXPORT_SYMBOL(csum_partial);