[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D4111BB63@AcuExch.aculab.com>
Date: Wed, 9 Mar 2016 10:54:49 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Joe Perches' <joe@...ches.com>,
Alexander Duyck <aduyck@...antis.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"davem@...emloft.net" <davem@...emloft.net>
Subject: RE: [net-next PATCH] csum: Update csum_block_add to use rotate
instead of byteswap
From: Joe Perches
> Sent: 08 March 2016 23:26
...
> > +
> > + if (offset & 1)
> > + sum = (sum << 24) + (sum >> 8);
>
> Maybe use ror32(sum, 8);
>
> or maybe something like:
>
> {
> u32 sum;
>
> /* rotated csum2 of odd offset will be the right checksum */
> if (offset & 1)
> sum = ror32((__force u32)csum2, 8);
> else
> sum = (__force u32)csum2;
Or even:
sum = ror32((__force u32)csum2, (offset & 1) * 8);
to remove the conditional.
Assuming 'rotate by 0 bits' is valid.
If not add 16 to rotate by 16 or 24.
David
Powered by blists - more mailing lists