Skip to content

Commit e465550

Browse files
maorgottliebSaeed Mahameed
authored andcommitted
net/mlx5: Lag, set match mask according to the traffic type bitmap
Set the related bits in the match definer mask according to the TT mapping. This mask will be used to create the match definers. Signed-off-by: Maor Gottlieb <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 1065e00 commit e465550

File tree

1 file changed

+182
-0
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/lag

1 file changed

+182
-0
lines changed

drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,188 @@
44
#include <linux/netdevice.h>
55
#include "lag.h"
66

7+
static int mlx5_lag_set_definer_inner(u32 *match_definer_mask,
8+
enum mlx5_traffic_types tt)
9+
{
10+
int format_id;
11+
u8 *ipv6;
12+
13+
switch (tt) {
14+
case MLX5_TT_IPV4_UDP:
15+
case MLX5_TT_IPV4_TCP:
16+
format_id = 23;
17+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
18+
inner_l4_sport);
19+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
20+
inner_l4_dport);
21+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
22+
inner_ip_src_addr);
23+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
24+
inner_ip_dest_addr);
25+
break;
26+
case MLX5_TT_IPV4:
27+
format_id = 23;
28+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
29+
inner_l3_type);
30+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
31+
inner_dmac_47_16);
32+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
33+
inner_dmac_15_0);
34+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
35+
inner_smac_47_16);
36+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
37+
inner_smac_15_0);
38+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
39+
inner_ip_src_addr);
40+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
41+
inner_ip_dest_addr);
42+
break;
43+
case MLX5_TT_IPV6_TCP:
44+
case MLX5_TT_IPV6_UDP:
45+
format_id = 31;
46+
MLX5_SET_TO_ONES(match_definer_format_31, match_definer_mask,
47+
inner_l4_sport);
48+
MLX5_SET_TO_ONES(match_definer_format_31, match_definer_mask,
49+
inner_l4_dport);
50+
ipv6 = MLX5_ADDR_OF(match_definer_format_31, match_definer_mask,
51+
inner_ip_dest_addr);
52+
memset(ipv6, 0xff, 16);
53+
ipv6 = MLX5_ADDR_OF(match_definer_format_31, match_definer_mask,
54+
inner_ip_src_addr);
55+
memset(ipv6, 0xff, 16);
56+
break;
57+
case MLX5_TT_IPV6:
58+
format_id = 32;
59+
ipv6 = MLX5_ADDR_OF(match_definer_format_32, match_definer_mask,
60+
inner_ip_dest_addr);
61+
memset(ipv6, 0xff, 16);
62+
ipv6 = MLX5_ADDR_OF(match_definer_format_32, match_definer_mask,
63+
inner_ip_src_addr);
64+
memset(ipv6, 0xff, 16);
65+
MLX5_SET_TO_ONES(match_definer_format_32, match_definer_mask,
66+
inner_dmac_47_16);
67+
MLX5_SET_TO_ONES(match_definer_format_32, match_definer_mask,
68+
inner_dmac_15_0);
69+
MLX5_SET_TO_ONES(match_definer_format_32, match_definer_mask,
70+
inner_smac_47_16);
71+
MLX5_SET_TO_ONES(match_definer_format_32, match_definer_mask,
72+
inner_smac_15_0);
73+
break;
74+
default:
75+
format_id = 23;
76+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
77+
inner_l3_type);
78+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
79+
inner_dmac_47_16);
80+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
81+
inner_dmac_15_0);
82+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
83+
inner_smac_47_16);
84+
MLX5_SET_TO_ONES(match_definer_format_23, match_definer_mask,
85+
inner_smac_15_0);
86+
break;
87+
}
88+
89+
return format_id;
90+
}
91+
92+
static int mlx5_lag_set_definer(u32 *match_definer_mask,
93+
enum mlx5_traffic_types tt, bool tunnel,
94+
enum netdev_lag_hash hash)
95+
{
96+
int format_id;
97+
u8 *ipv6;
98+
99+
if (tunnel)
100+
return mlx5_lag_set_definer_inner(match_definer_mask, tt);
101+
102+
switch (tt) {
103+
case MLX5_TT_IPV4_UDP:
104+
case MLX5_TT_IPV4_TCP:
105+
format_id = 22;
106+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
107+
outer_l4_sport);
108+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
109+
outer_l4_dport);
110+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
111+
outer_ip_src_addr);
112+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
113+
outer_ip_dest_addr);
114+
break;
115+
case MLX5_TT_IPV4:
116+
format_id = 22;
117+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
118+
outer_l3_type);
119+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
120+
outer_dmac_47_16);
121+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
122+
outer_dmac_15_0);
123+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
124+
outer_smac_47_16);
125+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
126+
outer_smac_15_0);
127+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
128+
outer_ip_src_addr);
129+
MLX5_SET_TO_ONES(match_definer_format_22, match_definer_mask,
130+
outer_ip_dest_addr);
131+
break;
132+
case MLX5_TT_IPV6_TCP:
133+
case MLX5_TT_IPV6_UDP:
134+
format_id = 29;
135+
MLX5_SET_TO_ONES(match_definer_format_29, match_definer_mask,
136+
outer_l4_sport);
137+
MLX5_SET_TO_ONES(match_definer_format_29, match_definer_mask,
138+
outer_l4_dport);
139+
ipv6 = MLX5_ADDR_OF(match_definer_format_29, match_definer_mask,
140+
outer_ip_dest_addr);
141+
memset(ipv6, 0xff, 16);
142+
ipv6 = MLX5_ADDR_OF(match_definer_format_29, match_definer_mask,
143+
outer_ip_src_addr);
144+
memset(ipv6, 0xff, 16);
145+
break;
146+
case MLX5_TT_IPV6:
147+
format_id = 30;
148+
ipv6 = MLX5_ADDR_OF(match_definer_format_30, match_definer_mask,
149+
outer_ip_dest_addr);
150+
memset(ipv6, 0xff, 16);
151+
ipv6 = MLX5_ADDR_OF(match_definer_format_30, match_definer_mask,
152+
outer_ip_src_addr);
153+
memset(ipv6, 0xff, 16);
154+
MLX5_SET_TO_ONES(match_definer_format_30, match_definer_mask,
155+
outer_dmac_47_16);
156+
MLX5_SET_TO_ONES(match_definer_format_30, match_definer_mask,
157+
outer_dmac_15_0);
158+
MLX5_SET_TO_ONES(match_definer_format_30, match_definer_mask,
159+
outer_smac_47_16);
160+
MLX5_SET_TO_ONES(match_definer_format_30, match_definer_mask,
161+
outer_smac_15_0);
162+
break;
163+
default:
164+
format_id = 0;
165+
MLX5_SET_TO_ONES(match_definer_format_0, match_definer_mask,
166+
outer_smac_47_16);
167+
MLX5_SET_TO_ONES(match_definer_format_0, match_definer_mask,
168+
outer_smac_15_0);
169+
170+
if (hash == NETDEV_LAG_HASH_VLAN_SRCMAC) {
171+
MLX5_SET_TO_ONES(match_definer_format_0,
172+
match_definer_mask,
173+
outer_first_vlan_vid);
174+
break;
175+
}
176+
177+
MLX5_SET_TO_ONES(match_definer_format_0, match_definer_mask,
178+
outer_ethertype);
179+
MLX5_SET_TO_ONES(match_definer_format_0, match_definer_mask,
180+
outer_dmac_47_16);
181+
MLX5_SET_TO_ONES(match_definer_format_0, match_definer_mask,
182+
outer_dmac_15_0);
183+
break;
184+
}
185+
186+
return format_id;
187+
}
188+
7189
static void set_tt_map(struct mlx5_lag_port_sel *port_sel,
8190
enum netdev_lag_hash hash)
9191
{

0 commit comments

Comments
 (0)