From: Tariq Toukan <tariqt@nvidia.com>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: Boris Pismenny <borisp@nvidia.com>,
netdev@vger.kernel.org, Tariq Toukan <ttoukan.linux@gmail.com>,
Moshe Shemesh <moshe@nvidia.com>,
Jay Vosburgh <j.vosburgh@gmail.com>,
Veaceslav Falico <vfalico@gmail.com>,
Andy Gospodarek <andy@greyhouse.net>,
John Fastabend <john.fastabend@gmail.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Jarod Wilson <jarod@redhat.com>, Ivan Vecera <ivecera@redhat.com>,
Tariq Toukan <tariqt@nvidia.com>
Subject: [PATCH net-next V2 2/8] net/bonding: Take IP hash logic into a helper
Date: Thu, 14 Jan 2021 20:01:29 +0200 [thread overview]
Message-ID: <20210114180135.11556-3-tariqt@nvidia.com> (raw)
In-Reply-To: <20210114180135.11556-1-tariqt@nvidia.com>
Hash logic on L3 will be used in a downstream patch for one more use
case.
Take it to a function for a better code reuse.
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Boris Pismenny <borisp@nvidia.com>
---
drivers/net/bonding/bond_main.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 5fe5232cc3f3..8bc7629a2805 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3539,6 +3539,16 @@ static bool bond_flow_dissect(struct bonding *bond, struct sk_buff *skb,
return true;
}
+static u32 bond_ip_hash(u32 hash, struct flow_keys *flow)
+{
+ hash ^= (__force u32)flow_get_u32_dst(flow) ^
+ (__force u32)flow_get_u32_src(flow);
+ hash ^= (hash >> 16);
+ hash ^= (hash >> 8);
+ /* discard lowest hash bit to deal with the common even ports pattern */
+ return hash >> 1;
+}
+
/**
* bond_xmit_hash - generate a hash value based on the xmit policy
* @bond: bonding device
@@ -3569,12 +3579,8 @@ u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb)
else
memcpy(&hash, &flow.ports.ports, sizeof(hash));
}
- hash ^= (__force u32)flow_get_u32_dst(&flow) ^
- (__force u32)flow_get_u32_src(&flow);
- hash ^= (hash >> 16);
- hash ^= (hash >> 8);
- return hash >> 1;
+ return bond_ip_hash(hash, &flow);
}
/*-------------------------- Device entry points ----------------------------*/
--
2.21.0
next prev parent reply other threads:[~2021-01-14 18:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 18:01 [PATCH net-next V2 0/8] TLS device offload for Bond Tariq Toukan
2021-01-14 18:01 ` [PATCH net-next V2 1/8] net: netdevice: Add operation ndo_sk_get_slave Tariq Toukan
2021-01-17 2:51 ` Jakub Kicinski
2021-01-17 10:55 ` Tariq Toukan
2021-01-14 18:01 ` Tariq Toukan [this message]
2021-01-14 18:01 ` [PATCH net-next V2 3/8] net/bonding: Implement ndo_sk_get_slave Tariq Toukan
2021-01-14 18:01 ` [PATCH net-next V2 4/8] net/bonding: Take update_features call out of XFRM funciton Tariq Toukan
2021-01-14 18:01 ` [PATCH net-next V2 5/8] net/bonding: Implement TLS TX device offload Tariq Toukan
2021-01-17 2:54 ` Jakub Kicinski
2021-01-17 11:04 ` Tariq Toukan
2021-01-14 18:01 ` [PATCH net-next V2 6/8] net/bonding: Declare TLS RX device offload support Tariq Toukan
2021-01-14 18:01 ` [PATCH net-next V2 7/8] net/tls: Device offload to use lowest netdevice in chain Tariq Toukan
2021-01-14 18:01 ` [PATCH net-next V2 8/8] net/tls: Except bond interface from some TLS checks Tariq Toukan
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=20210114180135.11556-3-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=andy@greyhouse.net \
--cc=borisp@nvidia.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=ivecera@redhat.com \
--cc=j.vosburgh@gmail.com \
--cc=jarod@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=ttoukan.linux@gmail.com \
--cc=vfalico@gmail.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).