net/mlx5: HWS, Fix IP version decision
[ Upstream commit 5f2f8d8b6800e4fc760c2eccec9b2bd2cacf80cf ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4e42f355c5
commit
b562ceee43
@@ -508,9 +508,9 @@ static int
|
||||
hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
|
||||
u32 *match_param)
|
||||
{
|
||||
bool is_s_ipv6, is_d_ipv6, smac_set, dmac_set;
|
||||
struct mlx5hws_definer_fc *fc = cd->fc;
|
||||
struct mlx5hws_definer_fc *curr_fc;
|
||||
bool is_ipv6, smac_set, dmac_set;
|
||||
u32 *s_ipv6, *d_ipv6;
|
||||
|
||||
if (HWS_IS_FLD_SET_SZ(match_param, outer_headers.l4_type, 0x2) ||
|
||||
@@ -572,10 +572,10 @@ hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
|
||||
outer_headers.dst_ipv4_dst_ipv6.ipv6_layout);
|
||||
|
||||
/* Assume IPv6 is used if ipv6 bits are set */
|
||||
is_s_ipv6 = s_ipv6[0] || s_ipv6[1] || s_ipv6[2];
|
||||
is_d_ipv6 = d_ipv6[0] || d_ipv6[1] || d_ipv6[2];
|
||||
is_ipv6 = s_ipv6[0] || s_ipv6[1] || s_ipv6[2] ||
|
||||
d_ipv6[0] || d_ipv6[1] || d_ipv6[2];
|
||||
|
||||
if (is_s_ipv6) {
|
||||
if (is_ipv6) {
|
||||
/* Handle IPv6 source address */
|
||||
HWS_SET_HDR(fc, match_param, IPV6_SRC_127_96_O,
|
||||
outer_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_127_96,
|
||||
@@ -589,13 +589,6 @@ hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
|
||||
HWS_SET_HDR(fc, match_param, IPV6_SRC_31_0_O,
|
||||
outer_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
|
||||
ipv6_src_outer.ipv6_address_31_0);
|
||||
} else {
|
||||
/* Handle IPv4 source address */
|
||||
HWS_SET_HDR(fc, match_param, IPV4_SRC_O,
|
||||
outer_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
|
||||
ipv4_src_dest_outer.source_address);
|
||||
}
|
||||
if (is_d_ipv6) {
|
||||
/* Handle IPv6 destination address */
|
||||
HWS_SET_HDR(fc, match_param, IPV6_DST_127_96_O,
|
||||
outer_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_127_96,
|
||||
@@ -610,6 +603,10 @@ hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
|
||||
outer_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_31_0,
|
||||
ipv6_dst_outer.ipv6_address_31_0);
|
||||
} else {
|
||||
/* Handle IPv4 source address */
|
||||
HWS_SET_HDR(fc, match_param, IPV4_SRC_O,
|
||||
outer_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
|
||||
ipv4_src_dest_outer.source_address);
|
||||
/* Handle IPv4 destination address */
|
||||
HWS_SET_HDR(fc, match_param, IPV4_DST_O,
|
||||
outer_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_31_0,
|
||||
@@ -667,9 +664,9 @@ static int
|
||||
hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
|
||||
u32 *match_param)
|
||||
{
|
||||
bool is_s_ipv6, is_d_ipv6, smac_set, dmac_set;
|
||||
struct mlx5hws_definer_fc *fc = cd->fc;
|
||||
struct mlx5hws_definer_fc *curr_fc;
|
||||
bool is_ipv6, smac_set, dmac_set;
|
||||
u32 *s_ipv6, *d_ipv6;
|
||||
|
||||
if (HWS_IS_FLD_SET_SZ(match_param, inner_headers.l4_type, 0x2) ||
|
||||
@@ -730,10 +727,10 @@ hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
|
||||
inner_headers.dst_ipv4_dst_ipv6.ipv6_layout);
|
||||
|
||||
/* Assume IPv6 is used if ipv6 bits are set */
|
||||
is_s_ipv6 = s_ipv6[0] || s_ipv6[1] || s_ipv6[2];
|
||||
is_d_ipv6 = d_ipv6[0] || d_ipv6[1] || d_ipv6[2];
|
||||
is_ipv6 = s_ipv6[0] || s_ipv6[1] || s_ipv6[2] ||
|
||||
d_ipv6[0] || d_ipv6[1] || d_ipv6[2];
|
||||
|
||||
if (is_s_ipv6) {
|
||||
if (is_ipv6) {
|
||||
/* Handle IPv6 source address */
|
||||
HWS_SET_HDR(fc, match_param, IPV6_SRC_127_96_I,
|
||||
inner_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_127_96,
|
||||
@@ -747,13 +744,6 @@ hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
|
||||
HWS_SET_HDR(fc, match_param, IPV6_SRC_31_0_I,
|
||||
inner_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
|
||||
ipv6_src_inner.ipv6_address_31_0);
|
||||
} else {
|
||||
/* Handle IPv4 source address */
|
||||
HWS_SET_HDR(fc, match_param, IPV4_SRC_I,
|
||||
inner_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
|
||||
ipv4_src_dest_inner.source_address);
|
||||
}
|
||||
if (is_d_ipv6) {
|
||||
/* Handle IPv6 destination address */
|
||||
HWS_SET_HDR(fc, match_param, IPV6_DST_127_96_I,
|
||||
inner_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_127_96,
|
||||
@@ -768,6 +758,10 @@ hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
|
||||
inner_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_31_0,
|
||||
ipv6_dst_inner.ipv6_address_31_0);
|
||||
} else {
|
||||
/* Handle IPv4 source address */
|
||||
HWS_SET_HDR(fc, match_param, IPV4_SRC_I,
|
||||
inner_headers.src_ipv4_src_ipv6.ipv6_simple_layout.ipv6_31_0,
|
||||
ipv4_src_dest_inner.source_address);
|
||||
/* Handle IPv4 destination address */
|
||||
HWS_SET_HDR(fc, match_param, IPV4_DST_I,
|
||||
inner_headers.dst_ipv4_dst_ipv6.ipv6_simple_layout.ipv6_31_0,
|
||||
|
||||
Reference in New Issue
Block a user