// SPDX-License-Identifier: GPL-2.0 /* * csum_partial_copy - do IP checksumming and copy * * (C) Copyright 1996 Linus Torvalds * accelerated versions (and 21264 assembly versions ) contributed by * Rick Gorton <rick.gorton@alpha-processor.com> * * Don't look at this too closely - you'll go mad. The things * we do for performance..
*/
staticinlineunsignedshort from64to16(unsignedlong x)
{ /* Using extract instructions is a bit more efficient
than the original shift/bitmask version. */
/* Since the bits of tmp_v.sh[3] are going to always be zero,
we don't have to bother to add that in. */
out_v.ul = (unsignedlong) tmp_v.us[0] + (unsignedlong) tmp_v.us[1]
+ (unsignedlong) tmp_v.us[2];
/* Similarly, out_v.us[2] is always zero for the final add. */ return out_v.us[0] + out_v.us[1];
}
/* * Ok. This isn't fun, but this is the EASY case.
*/ staticinlineunsignedlong
csum_partial_cfu_aligned(constunsignedlong __user *src, unsignedlong *dst, long len)
{ unsignedlong checksum = ~0U; unsignedlong carry = 0;
while (len >= 0) { unsignedlong word; if (__get_word(ldq, word, src)) return 0;
checksum += carry;
src++;
checksum += word;
len -= 8;
carry = checksum < word;
*dst = word;
dst++;
}
len += 8;
checksum += carry; if (len) { unsignedlong word, tmp; if (__get_word(ldq, word, src)) return 0;
tmp = *dst;
mskql(word, len, word);
checksum += word;
mskqh(tmp, len, tmp);
carry = checksum < word;
*dst = word | tmp;
checksum += carry;
} return checksum;
}
/* * This is even less fun, but this is still reasonably * easy.
*/ staticinlineunsignedlong
csum_partial_cfu_dest_aligned(constunsignedlong __user *src, unsignedlong *dst, unsignedlong soff, long len)
{ unsignedlong first; unsignedlong word, carry; unsignedlong lastsrc = 7+len+(unsignedlong)src; unsignedlong checksum = ~0U;
if (__get_word(ldq_u, first,src)) return 0;
carry = 0; while (len >= 0) { unsignedlong second;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.