> -----Original Message-----
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of Daniel
> Feferman
> Sent: Tuesday, August 7, 2018 8:10 PM
> To: lng-odp@lists.linaro.org
> Subject: [lng-odp] odph_chksum vs odp_chksum_ones_comp16
> 
> Hi All,
> 
> I was using odph_chksum on odp v16. Now, it seems that this function is
> discontinued and v19 uses odp_chksum_ones_comp16. However, my results
> seem to be a lot different from previously, is there any modification on it?
> My application was load balancing based on the hash output, the former
> (odph_chksum) is balancing so much better than the newest one
> (odp_chksum_ones_comp16).
> 
> Best,
> Daniel

The difference is that ones complement function does not swap bits in the end 
(which needs to be done e.g. for IP checksum). The idea is that you can use it 
as a building block for a (UDP/TCP/IP) checksum function, which may need to 
calculate checksum over segmented data:

sum = 0;
sum += odp_chksum_ones_comp16(buf[0], len[0]);
sum += odp_chksum_ones_comp16(buf[1], len[1]);
sum += odp_chksum_ones_comp16(buf[2], len[2]);
chksum = ~sum;

If you use it for generating a hash for load balancing, have you considered 
using e.g. odp_hash_crc32(), odp_hash_crc32c() or other CRC 
(odp_hash_crc_gen64()) instead. Those should give better spread of output bits 
than a sum (especially when input data does not vary much).

-Petri

Reply via email to