[PATCH 1/2] net: Allow csum_sub() to be provided in arch

From: Christophe Leroy
Date: Fri Feb 11 2022 - 05:25:18 EST


In the same spirit as commit 07064c6e022b ("net: Allow csum_add to be
provided in arch"), allow csum_sub() to be provided by arch.

The generic implementation of csum_sub() call csum_add() with the
complement of the addendum.

Some architectures can do it directly.

This will also avoid getting several copies of csum_sub() outlined
when building with -Os.

Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
---
include/net/checksum.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/net/checksum.h b/include/net/checksum.h
index 9badcd5532ef..735d98724145 100644
--- a/include/net/checksum.h
+++ b/include/net/checksum.h
@@ -62,10 +62,12 @@ static inline __wsum csum_add(__wsum csum, __wsum addend)
}
#endif

+#ifndef HAVE_ARCH_CSUM_SUB
static inline __wsum csum_sub(__wsum csum, __wsum addend)
{
return csum_add(csum, ~addend);
}
+#endif

static inline __sum16 csum16_add(__sum16 csum, __be16 addend)
{
--
2.34.1