From: Emeel Hakim <ehakim@nvidia.com>
To: <davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>,
<edumazet@google.com>, <sd@queasysnail.net>
Cc: <netdev@vger.kernel.org>, <leon@kernel.org>,
Emeel Hakim <ehakim@nvidia.com>
Subject: [PATCH net-next v3 3/4] net/mlx5: Consider VLAN interface in MACsec TX steering rules
Date: Thu, 30 Mar 2023 16:57:14 +0300 [thread overview]
Message-ID: <20230330135715.23652-4-ehakim@nvidia.com> (raw)
In-Reply-To: <20230330135715.23652-1-ehakim@nvidia.com>
Offloading MACsec when its configured over VLAN with current MACsec
TX steering rules will wrongly insert MACsec sec tag after inserting
the VLAN header leading to a ETHERNET | SECTAG | VLAN packet when
ETHERNET | VLAN | SECTAG is configured.
The above issue is due to adding the SECTAG by HW which is a later
stage compared to the VLAN header insertion stage.
Detect such a case and adjust TX steering rules to insert the
SECTAG in the correct place by using reformat_param_0 field in
the packet reformat to indicate the offset of SECTAG from end of
the MAC header to account for VLANs in granularity of 4Bytes.
Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c
index 5b658a5588c6..daaaaf344f77 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c
@@ -4,6 +4,7 @@
#include <net/macsec.h>
#include <linux/netdevice.h>
#include <linux/mlx5/qp.h>
+#include <linux/if_vlan.h>
#include "fs_core.h"
#include "en/fs.h"
#include "en_accel/macsec_fs.h"
@@ -510,6 +511,8 @@ static void macsec_fs_tx_del_rule(struct mlx5e_macsec_fs *macsec_fs,
macsec_fs_tx_ft_put(macsec_fs);
}
+#define MLX5_REFORMAT_PARAM_ADD_MACSEC_OFFSET_4_BYTES 1
+
static union mlx5e_macsec_rule *
macsec_fs_tx_add_rule(struct mlx5e_macsec_fs *macsec_fs,
const struct macsec_context *macsec_ctx,
@@ -555,6 +558,10 @@ macsec_fs_tx_add_rule(struct mlx5e_macsec_fs *macsec_fs,
reformat_params.type = MLX5_REFORMAT_TYPE_ADD_MACSEC;
reformat_params.size = reformat_size;
reformat_params.data = reformatbf;
+
+ if (is_vlan_dev(macsec_ctx->netdev))
+ reformat_params.param_0 = MLX5_REFORMAT_PARAM_ADD_MACSEC_OFFSET_4_BYTES;
+
flow_act.pkt_reformat = mlx5_packet_reformat_alloc(macsec_fs->mdev,
&reformat_params,
MLX5_FLOW_NAMESPACE_EGRESS_MACSEC);
--
2.21.3
next prev parent reply other threads:[~2023-03-30 13:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 13:57 [PATCH net-next v3 0/4] Support MACsec VLAN Emeel Hakim
2023-03-30 13:57 ` [PATCH net-next v3 1/4] vlan: Add MACsec offload operations for VLAN interface Emeel Hakim
2023-03-31 13:49 ` Simon Horman
2023-04-05 9:37 ` Sabrina Dubroca
2023-04-05 9:43 ` Emeel Hakim
[not found] ` <CA+sq2Cew_NiVcLBzxVF=C8htuNPSzHeEe48s6uD9smqKeUA9gQ@mail.gmail.com>
[not found] ` <CO1PR18MB46666401C2A9138BB6144BC8A1909@CO1PR18MB4666.namprd18.prod.outlook.com>
2023-04-05 13:47 ` [EXT] Fwd: " Subbaraya Sundeep Bhatta
2023-04-07 9:04 ` Emeel Hakim
2023-03-30 13:57 ` [PATCH net-next v3 2/4] net/mlx5: Support MACsec over VLAN Emeel Hakim
2023-03-31 13:48 ` Simon Horman
2023-03-30 13:57 ` Emeel Hakim [this message]
2023-03-31 13:49 ` [PATCH net-next v3 3/4] net/mlx5: Consider VLAN interface in MACsec TX steering rules Simon Horman
2023-03-30 13:57 ` [PATCH net-next v3 4/4] macsec: Add MACsec rx_handler change support Emeel Hakim
2023-03-31 13:50 ` Simon Horman
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=20230330135715.23652-4-ehakim@nvidia.com \
--to=ehakim@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
/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).