@@ -105,25 +105,25 @@ static void mlx5e_del_eth_addr_from_flow_table(struct mlx5e_priv *priv,
105
105
{
106
106
void * ft = priv -> ft .main ;
107
107
108
- if (ai -> tt_vec & ( 1 << MLX5E_TT_IPV6_TCP ))
108
+ if (ai -> tt_vec & BIT ( MLX5E_TT_IPV6_TCP ))
109
109
mlx5_del_flow_table_entry (ft , ai -> ft_ix [MLX5E_TT_IPV6_TCP ]);
110
110
111
- if (ai -> tt_vec & ( 1 << MLX5E_TT_IPV4_TCP ))
111
+ if (ai -> tt_vec & BIT ( MLX5E_TT_IPV4_TCP ))
112
112
mlx5_del_flow_table_entry (ft , ai -> ft_ix [MLX5E_TT_IPV4_TCP ]);
113
113
114
- if (ai -> tt_vec & ( 1 << MLX5E_TT_IPV6_UDP ))
114
+ if (ai -> tt_vec & BIT ( MLX5E_TT_IPV6_UDP ))
115
115
mlx5_del_flow_table_entry (ft , ai -> ft_ix [MLX5E_TT_IPV6_UDP ]);
116
116
117
- if (ai -> tt_vec & ( 1 << MLX5E_TT_IPV4_UDP ))
117
+ if (ai -> tt_vec & BIT ( MLX5E_TT_IPV4_UDP ))
118
118
mlx5_del_flow_table_entry (ft , ai -> ft_ix [MLX5E_TT_IPV4_UDP ]);
119
119
120
- if (ai -> tt_vec & ( 1 << MLX5E_TT_IPV6 ))
120
+ if (ai -> tt_vec & BIT ( MLX5E_TT_IPV6 ))
121
121
mlx5_del_flow_table_entry (ft , ai -> ft_ix [MLX5E_TT_IPV6 ]);
122
122
123
- if (ai -> tt_vec & ( 1 << MLX5E_TT_IPV4 ))
123
+ if (ai -> tt_vec & BIT ( MLX5E_TT_IPV4 ))
124
124
mlx5_del_flow_table_entry (ft , ai -> ft_ix [MLX5E_TT_IPV4 ]);
125
125
126
- if (ai -> tt_vec & ( 1 << MLX5E_TT_ANY ))
126
+ if (ai -> tt_vec & BIT ( MLX5E_TT_ANY ))
127
127
mlx5_del_flow_table_entry (ft , ai -> ft_ix [MLX5E_TT_ANY ]);
128
128
}
129
129
@@ -156,33 +156,33 @@ static u32 mlx5e_get_tt_vec(struct mlx5e_eth_addr_info *ai, int type)
156
156
switch (eth_addr_type ) {
157
157
case MLX5E_UC :
158
158
ret =
159
- ( 1 << MLX5E_TT_IPV4_TCP ) |
160
- ( 1 << MLX5E_TT_IPV6_TCP ) |
161
- ( 1 << MLX5E_TT_IPV4_UDP ) |
162
- ( 1 << MLX5E_TT_IPV6_UDP ) |
163
- ( 1 << MLX5E_TT_IPV4 ) |
164
- ( 1 << MLX5E_TT_IPV6 ) |
165
- ( 1 << MLX5E_TT_ANY ) |
159
+ BIT ( MLX5E_TT_IPV4_TCP ) |
160
+ BIT ( MLX5E_TT_IPV6_TCP ) |
161
+ BIT ( MLX5E_TT_IPV4_UDP ) |
162
+ BIT ( MLX5E_TT_IPV6_UDP ) |
163
+ BIT ( MLX5E_TT_IPV4 ) |
164
+ BIT ( MLX5E_TT_IPV6 ) |
165
+ BIT ( MLX5E_TT_ANY ) |
166
166
0 ;
167
167
break ;
168
168
169
169
case MLX5E_MC_IPV4 :
170
170
ret =
171
- ( 1 << MLX5E_TT_IPV4_UDP ) |
172
- ( 1 << MLX5E_TT_IPV4 ) |
171
+ BIT ( MLX5E_TT_IPV4_UDP ) |
172
+ BIT ( MLX5E_TT_IPV4 ) |
173
173
0 ;
174
174
break ;
175
175
176
176
case MLX5E_MC_IPV6 :
177
177
ret =
178
- ( 1 << MLX5E_TT_IPV6_UDP ) |
179
- ( 1 << MLX5E_TT_IPV6 ) |
178
+ BIT ( MLX5E_TT_IPV6_UDP ) |
179
+ BIT ( MLX5E_TT_IPV6 ) |
180
180
0 ;
181
181
break ;
182
182
183
183
case MLX5E_MC_OTHER :
184
184
ret =
185
- ( 1 << MLX5E_TT_ANY ) |
185
+ BIT ( MLX5E_TT_ANY ) |
186
186
0 ;
187
187
break ;
188
188
}
@@ -191,23 +191,23 @@ static u32 mlx5e_get_tt_vec(struct mlx5e_eth_addr_info *ai, int type)
191
191
192
192
case MLX5E_ALLMULTI :
193
193
ret =
194
- ( 1 << MLX5E_TT_IPV4_UDP ) |
195
- ( 1 << MLX5E_TT_IPV6_UDP ) |
196
- ( 1 << MLX5E_TT_IPV4 ) |
197
- ( 1 << MLX5E_TT_IPV6 ) |
198
- ( 1 << MLX5E_TT_ANY ) |
194
+ BIT ( MLX5E_TT_IPV4_UDP ) |
195
+ BIT ( MLX5E_TT_IPV6_UDP ) |
196
+ BIT ( MLX5E_TT_IPV4 ) |
197
+ BIT ( MLX5E_TT_IPV6 ) |
198
+ BIT ( MLX5E_TT_ANY ) |
199
199
0 ;
200
200
break ;
201
201
202
202
default : /* MLX5E_PROMISC */
203
203
ret =
204
- ( 1 << MLX5E_TT_IPV4_TCP ) |
205
- ( 1 << MLX5E_TT_IPV6_TCP ) |
206
- ( 1 << MLX5E_TT_IPV4_UDP ) |
207
- ( 1 << MLX5E_TT_IPV6_UDP ) |
208
- ( 1 << MLX5E_TT_IPV4 ) |
209
- ( 1 << MLX5E_TT_IPV6 ) |
210
- ( 1 << MLX5E_TT_ANY ) |
204
+ BIT ( MLX5E_TT_IPV4_TCP ) |
205
+ BIT ( MLX5E_TT_IPV6_TCP ) |
206
+ BIT ( MLX5E_TT_IPV4_UDP ) |
207
+ BIT ( MLX5E_TT_IPV6_UDP ) |
208
+ BIT ( MLX5E_TT_IPV4 ) |
209
+ BIT ( MLX5E_TT_IPV6 ) |
210
+ BIT ( MLX5E_TT_ANY ) |
211
211
0 ;
212
212
break ;
213
213
}
@@ -226,6 +226,7 @@ static int __mlx5e_add_eth_addr_rule(struct mlx5e_priv *priv,
226
226
u8 * match_criteria_dmac ;
227
227
void * ft = priv -> ft .main ;
228
228
u32 * tirn = priv -> tirn ;
229
+ u32 * ft_ix ;
229
230
u32 tt_vec ;
230
231
int err ;
231
232
@@ -261,122 +262,127 @@ static int __mlx5e_add_eth_addr_rule(struct mlx5e_priv *priv,
261
262
262
263
tt_vec = mlx5e_get_tt_vec (ai , type );
263
264
264
- if (tt_vec & (1 << MLX5E_TT_ANY )) {
265
+ ft_ix = & ai -> ft_ix [MLX5E_TT_ANY ];
266
+ if (tt_vec & BIT (MLX5E_TT_ANY )) {
265
267
MLX5_SET (dest_format_struct , dest , destination_id ,
266
268
tirn [MLX5E_TT_ANY ]);
267
269
err = mlx5_add_flow_table_entry (ft , match_criteria_enable ,
268
270
match_criteria , flow_context ,
269
- & ai -> ft_ix [MLX5E_TT_ANY ]);
270
- if (err ) {
271
- mlx5e_del_eth_addr_from_flow_table (priv , ai );
272
- return err ;
273
- }
274
- ai -> tt_vec |= (1 << MLX5E_TT_ANY );
271
+ ft_ix );
272
+ if (err )
273
+ goto err_del_ai ;
274
+
275
+ ai -> tt_vec |= BIT (MLX5E_TT_ANY );
275
276
}
276
277
277
278
match_criteria_enable = MLX5_MATCH_OUTER_HEADERS ;
278
279
MLX5_SET_TO_ONES (fte_match_param , match_criteria ,
279
280
outer_headers .ethertype );
280
281
281
- if (tt_vec & (1 << MLX5E_TT_IPV4 )) {
282
+ ft_ix = & ai -> ft_ix [MLX5E_TT_IPV4 ];
283
+ if (tt_vec & BIT (MLX5E_TT_IPV4 )) {
282
284
MLX5_SET (fte_match_param , match_value , outer_headers .ethertype ,
283
285
ETH_P_IP );
284
286
MLX5_SET (dest_format_struct , dest , destination_id ,
285
287
tirn [MLX5E_TT_IPV4 ]);
286
288
err = mlx5_add_flow_table_entry (ft , match_criteria_enable ,
287
289
match_criteria , flow_context ,
288
- & ai -> ft_ix [MLX5E_TT_IPV4 ]);
289
- if (err ) {
290
- mlx5e_del_eth_addr_from_flow_table (priv , ai );
291
- return err ;
292
- }
293
- ai -> tt_vec |= (1 << MLX5E_TT_IPV4 );
290
+ ft_ix );
291
+ if (err )
292
+ goto err_del_ai ;
293
+
294
+ ai -> tt_vec |= BIT (MLX5E_TT_IPV4 );
294
295
}
295
296
296
- if (tt_vec & (1 << MLX5E_TT_IPV6 )) {
297
+ ft_ix = & ai -> ft_ix [MLX5E_TT_IPV6 ];
298
+ if (tt_vec & BIT (MLX5E_TT_IPV6 )) {
297
299
MLX5_SET (fte_match_param , match_value , outer_headers .ethertype ,
298
300
ETH_P_IPV6 );
299
301
MLX5_SET (dest_format_struct , dest , destination_id ,
300
302
tirn [MLX5E_TT_IPV6 ]);
301
303
err = mlx5_add_flow_table_entry (ft , match_criteria_enable ,
302
304
match_criteria , flow_context ,
303
- & ai -> ft_ix [MLX5E_TT_IPV6 ]);
304
- if (err ) {
305
- mlx5e_del_eth_addr_from_flow_table (priv , ai );
306
- return err ;
307
- }
308
- ai -> tt_vec |= (1 << MLX5E_TT_IPV6 );
305
+ ft_ix );
306
+ if (err )
307
+ goto err_del_ai ;
308
+
309
+ ai -> tt_vec |= BIT (MLX5E_TT_IPV6 );
309
310
}
310
311
311
312
MLX5_SET_TO_ONES (fte_match_param , match_criteria ,
312
313
outer_headers .ip_protocol );
313
314
MLX5_SET (fte_match_param , match_value , outer_headers .ip_protocol ,
314
315
IPPROTO_UDP );
315
316
316
- if (tt_vec & (1 << MLX5E_TT_IPV4_UDP )) {
317
+ ft_ix = & ai -> ft_ix [MLX5E_TT_IPV4_UDP ];
318
+ if (tt_vec & BIT (MLX5E_TT_IPV4_UDP )) {
317
319
MLX5_SET (fte_match_param , match_value , outer_headers .ethertype ,
318
320
ETH_P_IP );
319
321
MLX5_SET (dest_format_struct , dest , destination_id ,
320
322
tirn [MLX5E_TT_IPV4_UDP ]);
321
323
err = mlx5_add_flow_table_entry (ft , match_criteria_enable ,
322
324
match_criteria , flow_context ,
323
- & ai -> ft_ix [MLX5E_TT_IPV4_UDP ]);
324
- if (err ) {
325
- mlx5e_del_eth_addr_from_flow_table (priv , ai );
326
- return err ;
327
- }
328
- ai -> tt_vec |= (1 << MLX5E_TT_IPV4_UDP );
325
+ ft_ix );
326
+ if (err )
327
+ goto err_del_ai ;
328
+
329
+ ai -> tt_vec |= BIT (MLX5E_TT_IPV4_UDP );
329
330
}
330
331
331
- if (tt_vec & (1 << MLX5E_TT_IPV6_UDP )) {
332
+ ft_ix = & ai -> ft_ix [MLX5E_TT_IPV6_UDP ];
333
+ if (tt_vec & BIT (MLX5E_TT_IPV6_UDP )) {
332
334
MLX5_SET (fte_match_param , match_value , outer_headers .ethertype ,
333
335
ETH_P_IPV6 );
334
336
MLX5_SET (dest_format_struct , dest , destination_id ,
335
337
tirn [MLX5E_TT_IPV6_UDP ]);
336
338
err = mlx5_add_flow_table_entry (ft , match_criteria_enable ,
337
339
match_criteria , flow_context ,
338
- & ai -> ft_ix [MLX5E_TT_IPV6_UDP ]);
339
- if (err ) {
340
- mlx5e_del_eth_addr_from_flow_table (priv , ai );
341
- return err ;
342
- }
343
- ai -> tt_vec |= (1 << MLX5E_TT_IPV6_UDP );
340
+ ft_ix );
341
+ if (err )
342
+ goto err_del_ai ;
343
+
344
+ ai -> tt_vec |= BIT (MLX5E_TT_IPV6_UDP );
344
345
}
345
346
346
347
MLX5_SET (fte_match_param , match_value , outer_headers .ip_protocol ,
347
348
IPPROTO_TCP );
348
349
349
- if (tt_vec & (1 << MLX5E_TT_IPV4_TCP )) {
350
+ ft_ix = & ai -> ft_ix [MLX5E_TT_IPV4_TCP ];
351
+ if (tt_vec & BIT (MLX5E_TT_IPV4_TCP )) {
350
352
MLX5_SET (fte_match_param , match_value , outer_headers .ethertype ,
351
353
ETH_P_IP );
352
354
MLX5_SET (dest_format_struct , dest , destination_id ,
353
355
tirn [MLX5E_TT_IPV4_TCP ]);
354
356
err = mlx5_add_flow_table_entry (ft , match_criteria_enable ,
355
357
match_criteria , flow_context ,
356
- & ai -> ft_ix [MLX5E_TT_IPV4_TCP ]);
357
- if (err ) {
358
- mlx5e_del_eth_addr_from_flow_table (priv , ai );
359
- return err ;
360
- }
361
- ai -> tt_vec |= (1 << MLX5E_TT_IPV4_TCP );
358
+ ft_ix );
359
+ if (err )
360
+ goto err_del_ai ;
361
+
362
+ ai -> tt_vec |= BIT (MLX5E_TT_IPV4_TCP );
362
363
}
363
364
364
- if (tt_vec & (1 << MLX5E_TT_IPV6_TCP )) {
365
+ ft_ix = & ai -> ft_ix [MLX5E_TT_IPV6_TCP ];
366
+ if (tt_vec & BIT (MLX5E_TT_IPV6_TCP )) {
365
367
MLX5_SET (fte_match_param , match_value , outer_headers .ethertype ,
366
368
ETH_P_IPV6 );
367
369
MLX5_SET (dest_format_struct , dest , destination_id ,
368
370
tirn [MLX5E_TT_IPV6_TCP ]);
369
371
err = mlx5_add_flow_table_entry (ft , match_criteria_enable ,
370
372
match_criteria , flow_context ,
371
- & ai -> ft_ix [MLX5E_TT_IPV6_TCP ]);
372
- if (err ) {
373
- mlx5e_del_eth_addr_from_flow_table (priv , ai );
374
- return err ;
375
- }
376
- ai -> tt_vec |= (1 << MLX5E_TT_IPV6_TCP );
373
+ ft_ix );
374
+ if (err )
375
+ goto err_del_ai ;
376
+
377
+ ai -> tt_vec |= BIT (MLX5E_TT_IPV6_TCP );
377
378
}
378
379
379
380
return 0 ;
381
+
382
+ err_del_ai :
383
+ mlx5e_del_eth_addr_from_flow_table (priv , ai );
384
+
385
+ return err ;
380
386
}
381
387
382
388
static int mlx5e_add_eth_addr_rule (struct mlx5e_priv * priv ,
0 commit comments