/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ALPHA_CHECKSUM_H2#define _ALPHA_CHECKSUM_H34#include <linux/in6.h>56/*7* This is a version of ip_compute_csum() optimized for IP headers,8* which always checksum on 4 octet boundaries.9*/10extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);1112/*13* computes the checksum of the TCP/UDP pseudo-header14* returns a 16-bit checksum, already complemented15*/16__sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,17__u32 len, __u8 proto, __wsum sum);1819__wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,20__u32 len, __u8 proto, __wsum sum);2122/*23* computes the checksum of a memory block at buff, length len,24* and adds in "sum" (32-bit)25*26* returns a 32-bit number suitable for feeding into itself27* or csum_tcpudp_magic28*29* this function must be called with even lengths, except30* for the last fragment, which may be odd31*32* it's best to have buff aligned on a 32-bit boundary33*/34extern __wsum csum_partial(const void *buff, int len, __wsum sum);3536/*37* the same as csum_partial, but copies from src while it38* checksums39*40* here even more important to align src and dst on a 32-bit (or even41* better 64-bit) boundary42*/43#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER44#define _HAVE_ARCH_CSUM_AND_COPY45__wsum csum_and_copy_from_user(const void __user *src, void *dst, int len);4647__wsum csum_partial_copy_nocheck(const void *src, void *dst, int len);484950/*51* this routine is used for miscellaneous IP-like checksums, mainly52* in icmp.c53*/5455extern __sum16 ip_compute_csum(const void *buff, int len);5657/*58* Fold a partial checksum without adding pseudo headers59*/6061static inline __sum16 csum_fold(__wsum csum)62{63u32 sum = (__force u32)csum;64sum = (sum & 0xffff) + (sum >> 16);65sum = (sum & 0xffff) + (sum >> 16);66return (__force __sum16)~sum;67}6869#define _HAVE_ARCH_IPV6_CSUM70extern __sum16 csum_ipv6_magic(const struct in6_addr *saddr,71const struct in6_addr *daddr,72__u32 len, __u8 proto, __wsum sum);73#endif747576