From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: Gavin Li <gavinl@nvidia.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>, <roopa@nvidia.com>,
<eng.alaamohamedsoliman.am@gmail.com>, <bigeasy@linutronix.de>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Roi Dayan <roid@nvidia.com>, Maor Dickman <maord@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>
Subject: Re: [PATCH net-next v1 2/3] net/mlx5e: Add helper for encap_info_equal for tunnels with options
Date: Tue, 14 Feb 2023 16:01:41 +0100 [thread overview]
Message-ID: <611a9a70-0f6e-cba5-dcb3-3412e6e9956f@intel.com> (raw)
In-Reply-To: <20230214134137.225999-3-gavinl@nvidia.com>
From: Gavin Li <gavinl@nvidia.com>
Date: Tue, 14 Feb 2023 15:41:36 +0200
(dropping non-existent nikolay@nvidia.com)
> For tunnels with options, eg, geneve and vxlan with gbp, they share the
> same way to compare the headers and options. Extract the code as a common
> function for them
>
> Change-Id: I3ea697293c8d5d66c0c20080dbde88f60bcbd62f
> Signed-off-by: Gavin Li <gavinl@nvidia.com>
> Reviewed-by: Roi Dayan <roid@nvidia.com>
> Reviewed-by: Maor Dickman <maord@nvidia.com>
> Acked-by: Saeed Mahameed <saeedm@nvidia.com>
[...]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
> index 780224fd67a1..4df9d27a63ad 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
> @@ -571,6 +571,35 @@ bool mlx5e_tc_tun_encap_info_equal_generic(struct mlx5e_encap_key *a,
> a->tc_tunnel->tunnel_type == b->tc_tunnel->tunnel_type;
> }
>
> +bool mlx5e_tc_tun_encap_info_equal_options(struct mlx5e_encap_key *a,
> + struct mlx5e_encap_key *b,
> + __be16 tun_flags)
> +{
> + struct ip_tunnel_info *a_info;
> + struct ip_tunnel_info *b_info;
> + bool a_has_opts, b_has_opts;
> +
> + if (!mlx5e_tc_tun_encap_info_equal_generic(a, b))
> + return false;
> +
> + a_has_opts = !!(a->ip_tun_key->tun_flags & tun_flags);
> + b_has_opts = !!(b->ip_tun_key->tun_flags & tun_flags);
> +
> + /* keys are equal when both don't have any options attached */
> + if (!a_has_opts && !b_has_opts)
> + return true;
> +
> + if (a_has_opts != b_has_opts)
> + return false;
> +
> + /* options stored in memory next to ip_tunnel_info struct */
> + a_info = container_of(a->ip_tun_key, struct ip_tunnel_info, key);
> + b_info = container_of(b->ip_tun_key, struct ip_tunnel_info, key);
> +
> + return a_info->options_len == b_info->options_len &&
> + memcmp(a_info + 1, b_info + 1, a_info->options_len) == 0;
1. memcmp() is not aligned to the first expr (off-by-one to the right).
2. `!expr` is preferred over `expr == 0`.
> +}
> +
> static int cmp_decap_info(struct mlx5e_decap_key *a,
> struct mlx5e_decap_key *b)
> {
[...]
Thanks,
Olek
next prev parent reply other threads:[~2023-02-14 15:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-14 13:41 [PATCH net-next v1 0/3] net/mlx5e: Add GBP VxLAN HW offload support Gavin Li
2023-02-14 13:41 ` [PATCH net-next v1 1/3] vxlan: Expose helper vxlan_build_gbp_hdr Gavin Li
2023-02-14 14:56 ` Alexander Lobakin
2023-02-15 8:26 ` Gavin Li
2023-02-14 13:41 ` [PATCH net-next v1 2/3] net/mlx5e: Add helper for encap_info_equal for tunnels with options Gavin Li
2023-02-14 15:01 ` Alexander Lobakin [this message]
2023-02-15 2:54 ` Gavin Li
2023-02-15 16:56 ` Alexander Lobakin
2023-02-20 11:31 ` Gavin Li
2023-02-14 13:41 ` [PATCH net-next v1 3/3] net/mlx5e: TC, Add support for VxLAN GBP encap/decap flows offload Gavin Li
2023-02-14 15:26 ` Alexander Lobakin
2023-02-15 2:50 ` Gavin Li
2023-02-15 16:53 ` Alexander Lobakin
2023-02-15 3:36 ` Gavin Li
2023-02-15 8:30 ` Gavin Li
2023-02-15 17:01 ` Alexander Lobakin
2023-02-16 8:40 ` Gavin Li
2023-02-16 15:19 ` Alexander Lobakin
2023-02-17 2:43 ` Gavin Li
2023-02-15 16:57 ` Alexander Lobakin
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=611a9a70-0f6e-cba5-dcb3-3412e6e9956f@intel.com \
--to=alexandr.lobakin@intel.com \
--cc=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eng.alaamohamedsoliman.am@gmail.com \
--cc=gavinl@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maord@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=roid@nvidia.com \
--cc=roopa@nvidia.com \
--cc=saeedm@nvidia.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
all inboxes | Powered by JetHome®