From: Or Gerlitz <ogerlitz@mellanox.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: "David S. Miller" <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Matan Barak <matanb@mellanox.com>,
Amir Vadai <amirv@mellanox.com>,
Saeed Mahameed <saeedm@mellanox.com>,
Shani Michaeli <shanim@mellanox.com>
Subject: Re: [PATCH net-next 7/8] net: Add calaulation of non folded IPV6 pseudo header checksum
Date: Thu, 30 Oct 2014 18:54:20 +0200 [thread overview]
Message-ID: <54526D3C.2040604@mellanox.com> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1C9E2497@AcuExch.aculab.com>
On 10/30/2014 6:39 PM, David Laight wrote:
> From: Or Gerlitz [mailto:ogerlitz@mellanox.com]
>> On 10/30/2014 6:25 PM, David Laight wrote:
>>>>> +static inline __wsum csum_ipv6_magic_nofold(const struct in6_addr *saddr,
>>>>> + const struct in6_addr *daddr,
>>>>> + __u32 len, unsigned short proto,
>>>>> + __wsum sum)
>>>>> +{
>>>>> + __wsum res = sum;
>>>>> +
>>>>> + res = csum_add(res, (__force __wsum)saddr->in6_u.u6_addr32[0]);
>>>>> + res = csum_add(res, (__force __wsum)saddr->in6_u.u6_addr32[1]);
>>>>> + res = csum_add(res, (__force __wsum)saddr->in6_u.u6_addr32[2]);
>>>>> + res = csum_add(res, (__force __wsum)saddr->in6_u.u6_addr32[3]);
>>>>> + res = csum_add(res, (__force __wsum)daddr->in6_u.u6_addr32[0]);
>>>>> + res = csum_add(res, (__force __wsum)daddr->in6_u.u6_addr32[1]);
>>>>> + res = csum_add(res, (__force __wsum)daddr->in6_u.u6_addr32[2]);
>>>>> + res = csum_add(res, (__force __wsum)daddr->in6_u.u6_addr32[3]);
>>> That probably generates a very long dependency chain.
>>>
>> Could you clarify this comment a bit?
> csum_add() probably generates a 32bit 'add with carry' instruction.
> So the above generates 8 instructions that have to be executed in series
> (dependencies on the register and the carry flag).
>
> On a 64bit cpu there are other options, eg adding 32bit values into
> several 64bit registers, then adding those together and finally
> collapsing the value to 32 then 16 bits.
>
> Maybe __wsum does end up being 64bit (not looked), but gcc won't
> generate a 'tree' of additions, it will still generate a dependency chain.
>
> Hopefully the software 'checksum a buffer' function is written to
> avoid these problems.
OK, talking to Matan, hecame up with this super-quick (compile tested
only) alternative, is
this what you were advocating for?
Or.
diff --git a/include/net/ip6_checksum.h b/include/net/ip6_checksum.h
index c45d690..cadffdc 100644
--- a/include/net/ip6_checksum.h
+++ b/include/net/ip6_checksum.h
@@ -46,6 +46,19 @@ static inline __wsum csum_ipv6_magic_nofold(const
struct in6_addr *saddr,
__u32 len, unsigned short
proto,
__wsum sum)
{
+ sum = csum_partial(saddr, sizeof(saddr->in6_u.u6_addr32), sum);
+ sum = csum_partial(saddr, sizeof(daddr->in6_u.u6_addr32), sum);
+ sum = csum_add(sum, (__force __wsum)htonl(len));
+ sum = csum_add(sum, (__force __wsum)htons(proto));
+
+ return sum;
+}
next prev parent reply other threads:[~2014-10-30 16:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-30 16:06 [PATCH net-next 0/8] Mellanox ethernet driver update Oct-30-2014 Or Gerlitz
2014-10-30 16:06 ` [PATCH net-next 1/8] net/mlx4_core: Prevent VF from changing port configuration Or Gerlitz
2014-10-30 16:06 ` [PATCH net-next 2/8] net/mlx4_core: Protect port type setting by mutex Or Gerlitz
2014-10-30 16:06 ` [PATCH net-next 3/8] net/mlx4_en: Remove RX buffers alignment to IP_ALIGN Or Gerlitz
2014-10-30 16:06 ` [PATCH net-next 4/8] net/mlx4_en: Add __GFP_COLD gfp flags in alloc_pages Or Gerlitz
2014-10-30 17:15 ` Eric Dumazet
2014-10-30 22:49 ` Or Gerlitz
2014-10-30 16:06 ` [PATCH net-next 5/8] net/mlx4_en: Remove redundant code from RX/GRO path Or Gerlitz
2014-10-30 19:00 ` Eric Dumazet
2014-10-30 23:25 ` Or Gerlitz
2014-10-31 3:19 ` Eric Dumazet
2014-10-31 14:00 ` Or Gerlitz
2014-10-31 15:46 ` Eric Dumazet
2014-11-02 14:09 ` Or Gerlitz
2014-11-02 14:28 ` Eric Dumazet
2014-10-30 16:06 ` [PATCH net-next 6/8] net/mlx4_core: Add retrieval of CONFIG_DEV parameters Or Gerlitz
2014-10-30 16:06 ` [PATCH net-next 7/8] net: Add calaulation of non folded IPV6 pseudo header checksum Or Gerlitz
2014-10-30 16:25 ` David Laight
2014-10-30 16:32 ` Or Gerlitz
2014-10-30 16:39 ` David Laight
2014-10-30 16:54 ` Or Gerlitz [this message]
2014-10-30 16:55 ` Or Gerlitz
2014-10-30 17:09 ` David Laight
2014-10-30 16:06 ` [PATCH net-next 8/8] net/mlx4_en: Extend checksum offloading by CHECKSUM COMPLETE Or Gerlitz
2014-10-30 18:22 ` Eric Dumazet
2014-10-30 21:20 ` Jerry Chu
2014-10-30 23:28 ` Or Gerlitz
2014-10-30 23:53 ` Jerry Chu
2014-10-30 23:59 ` Tom Herbert
2014-10-31 13:57 ` Or Gerlitz
2014-10-31 0:38 ` Yann Ylavic
2014-10-31 13:52 ` Or Gerlitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54526D3C.2040604@mellanox.com \
--to=ogerlitz@mellanox.com \
--cc=David.Laight@ACULAB.COM \
--cc=amirv@mellanox.com \
--cc=davem@davemloft.net \
--cc=matanb@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=shanim@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).