Skip to content

Commit 21fa419

Browse files
Emeel HakimBrian Maly
authored andcommitted
net/mlx5: Consider VLAN interface in MACsec TX steering rules
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 <[email protected]> Reviewed-by: Subbaraya Sundeep <[email protected]> Signed-off-by: David S. Miller <[email protected]> Orabug: 35383105 (cherry picked from commit 765f974) cherry-pick-repo=kernel/git/torvalds/linux.git unmodified-from-upstream: 765f974 Signed-off-by: Mikhael Goikhman <[email protected]> Signed-off-by: Qing Huang <[email protected]> Reviewed-by: Devesh Sharma <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent fdee412 commit 21fa419

File tree

1 file changed

+7
-0
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en_accel

1 file changed

+7
-0
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <net/macsec.h>
55
#include <linux/netdevice.h>
66
#include <linux/mlx5/qp.h>
7+
#include <linux/if_vlan.h>
78
#include "fs_core.h"
89
#include "en/fs.h"
910
#include "en_accel/macsec_fs.h"
@@ -508,6 +509,8 @@ static void macsec_fs_tx_del_rule(struct mlx5e_macsec_fs *macsec_fs,
508509
macsec_fs_tx_ft_put(macsec_fs);
509510
}
510511

512+
#define MLX5_REFORMAT_PARAM_ADD_MACSEC_OFFSET_4_BYTES 1
513+
511514
static union mlx5e_macsec_rule *
512515
macsec_fs_tx_add_rule(struct mlx5e_macsec_fs *macsec_fs,
513516
const struct macsec_context *macsec_ctx,
@@ -553,6 +556,10 @@ macsec_fs_tx_add_rule(struct mlx5e_macsec_fs *macsec_fs,
553556
reformat_params.type = MLX5_REFORMAT_TYPE_ADD_MACSEC;
554557
reformat_params.size = reformat_size;
555558
reformat_params.data = reformatbf;
559+
560+
if (is_vlan_dev(macsec_ctx->netdev))
561+
reformat_params.param_0 = MLX5_REFORMAT_PARAM_ADD_MACSEC_OFFSET_4_BYTES;
562+
556563
flow_act.pkt_reformat = mlx5_packet_reformat_alloc(macsec_fs->mdev,
557564
&reformat_params,
558565
MLX5_FLOW_NAMESPACE_EGRESS_MACSEC);

0 commit comments

Comments
 (0)