Skip to content

Commit 5f2f8d8

Browse files
ddvladkuba-moo
authored andcommitted
net/mlx5: HWS, Fix IP version decision
Unify the check for IP version when creating a definer. A given matcher is deemed to match on IPv6 if any of the higher order (>31) bits of source or destination address mask are set. A single packet cannot mix IP versions between source and destination addresses, so it makes no sense that they would be decided on independently. Signed-off-by: Vlad Dogaru <vdogaru@nvidia.com> Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com> Signed-off-by: Mark Bloch <mbloch@nvidia.com> Link: https://patch.msgid.link/20250422092540.182091-2-mbloch@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent b5cdb9b commit 5f2f8d8

File tree

1 file changed

+16
-22
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/steering/hws

1 file changed

+16
-22
lines changed

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/definer.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,9 @@ static int
509509
hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
510510
u32 *match_param)
511511
{
512-
bool is_s_ipv6, is_d_ipv6, smac_set, dmac_set;
513512
struct mlx5hws_definer_fc *fc = cd->fc;
514513
struct mlx5hws_definer_fc *curr_fc;
514+
bool is_ipv6, smac_set, dmac_set;
515515
u32 *s_ipv6, *d_ipv6;
516516

517517
if (HWS_IS_FLD_SET_SZ(match_param, outer_headers.l4_type, 0x2) ||
@@ -570,10 +570,10 @@ hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
570570
outer_headers.dst_ipv4_dst_ipv6.ipv6_layout);
571571

572572
/* Assume IPv6 is used if ipv6 bits are set */
573-
is_s_ipv6 = s_ipv6[0] || s_ipv6[1] || s_ipv6[2];
574-
is_d_ipv6 = d_ipv6[0] || d_ipv6[1] || d_ipv6[2];
573+
is_ipv6 = s_ipv6[0] || s_ipv6[1] || s_ipv6[2] ||
574+
d_ipv6[0] || d_ipv6[1] || d_ipv6[2];
575575

576-
if (is_s_ipv6) {
576+
if (is_ipv6) {
577577
/* Handle IPv6 source address */
578578
HWS_SET_HDR(fc, match_param, IPV6_SRC_127_96_O,
579579
outer_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_127_96,
@@ -587,13 +587,6 @@ hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
587587
HWS_SET_HDR(fc, match_param, IPV6_SRC_31_0_O,
588588
outer_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
589589
ipv6_src_outer.ipv6_address_31_0);
590-
} else {
591-
/* Handle IPv4 source address */
592-
HWS_SET_HDR(fc, match_param, IPV4_SRC_O,
593-
outer_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
594-
ipv4_src_dest_outer.source_address);
595-
}
596-
if (is_d_ipv6) {
597590
/* Handle IPv6 destination address */
598591
HWS_SET_HDR(fc, match_param, IPV6_DST_127_96_O,
599592
outer_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_127_96,
@@ -608,6 +601,10 @@ hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
608601
outer_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_31_0,
609602
ipv6_dst_outer.ipv6_address_31_0);
610603
} else {
604+
/* Handle IPv4 source address */
605+
HWS_SET_HDR(fc, match_param, IPV4_SRC_O,
606+
outer_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
607+
ipv4_src_dest_outer.source_address);
611608
/* Handle IPv4 destination address */
612609
HWS_SET_HDR(fc, match_param, IPV4_DST_O,
613610
outer_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_31_0,
@@ -665,9 +662,9 @@ static int
665662
hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
666663
u32 *match_param)
667664
{
668-
bool is_s_ipv6, is_d_ipv6, smac_set, dmac_set;
669665
struct mlx5hws_definer_fc *fc = cd->fc;
670666
struct mlx5hws_definer_fc *curr_fc;
667+
bool is_ipv6, smac_set, dmac_set;
671668
u32 *s_ipv6, *d_ipv6;
672669

673670
if (HWS_IS_FLD_SET_SZ(match_param, inner_headers.l4_type, 0x2) ||
@@ -728,10 +725,10 @@ hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
728725
inner_headers.dst_ipv4_dst_ipv6.ipv6_layout);
729726

730727
/* Assume IPv6 is used if ipv6 bits are set */
731-
is_s_ipv6 = s_ipv6[0] || s_ipv6[1] || s_ipv6[2];
732-
is_d_ipv6 = d_ipv6[0] || d_ipv6[1] || d_ipv6[2];
728+
is_ipv6 = s_ipv6[0] || s_ipv6[1] || s_ipv6[2] ||
729+
d_ipv6[0] || d_ipv6[1] || d_ipv6[2];
733730

734-
if (is_s_ipv6) {
731+
if (is_ipv6) {
735732
/* Handle IPv6 source address */
736733
HWS_SET_HDR(fc, match_param, IPV6_SRC_127_96_I,
737734
inner_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_127_96,
@@ -745,13 +742,6 @@ hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
745742
HWS_SET_HDR(fc, match_param, IPV6_SRC_31_0_I,
746743
inner_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
747744
ipv6_src_inner.ipv6_address_31_0);
748-
} else {
749-
/* Handle IPv4 source address */
750-
HWS_SET_HDR(fc, match_param, IPV4_SRC_I,
751-
inner_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
752-
ipv4_src_dest_inner.source_address);
753-
}
754-
if (is_d_ipv6) {
755745
/* Handle IPv6 destination address */
756746
HWS_SET_HDR(fc, match_param, IPV6_DST_127_96_I,
757747
inner_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_127_96,
@@ -766,6 +756,10 @@ hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
766756
inner_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_31_0,
767757
ipv6_dst_inner.ipv6_address_31_0);
768758
} else {
759+
/* Handle IPv4 source address */
760+
HWS_SET_HDR(fc, match_param, IPV4_SRC_I,
761+
inner_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
762+
ipv4_src_dest_inner.source_address);
769763
/* Handle IPv4 destination address */
770764
HWS_SET_HDR(fc, match_param, IPV4_DST_I,
771765
inner_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_31_0,

0 commit comments

Comments
 (0)