@@ -1425,15 +1425,31 @@ static int mlx5_ib_dealloc_pd(struct ib_pd *pd)
1425
1425
return 0 ;
1426
1426
}
1427
1427
1428
- static bool outer_header_zero (u32 * match_criteria )
1428
+ enum {
1429
+ MATCH_CRITERIA_ENABLE_OUTER_BIT ,
1430
+ MATCH_CRITERIA_ENABLE_MISC_BIT ,
1431
+ MATCH_CRITERIA_ENABLE_INNER_BIT
1432
+ };
1433
+
1434
+ #define HEADER_IS_ZERO (match_criteria , headers ) \
1435
+ !(memchr_inv(MLX5_ADDR_OF(fte_match_param, match_criteria, headers), \
1436
+ 0, MLX5_FLD_SZ_BYTES(fte_match_param, headers))) \
1437
+
1438
+ static u8 get_match_criteria_enable (u32 * match_criteria )
1429
1439
{
1430
- int size = MLX5_ST_SZ_BYTES (fte_match_param );
1431
- char * outer_headers_c = MLX5_ADDR_OF (fte_match_param , match_criteria ,
1432
- outer_headers );
1440
+ u8 match_criteria_enable ;
1441
+
1442
+ match_criteria_enable =
1443
+ (!HEADER_IS_ZERO (match_criteria , outer_headers )) <<
1444
+ MATCH_CRITERIA_ENABLE_OUTER_BIT ;
1445
+ match_criteria_enable |=
1446
+ (!HEADER_IS_ZERO (match_criteria , misc_parameters )) <<
1447
+ MATCH_CRITERIA_ENABLE_MISC_BIT ;
1448
+ match_criteria_enable |=
1449
+ (!HEADER_IS_ZERO (match_criteria , inner_headers )) <<
1450
+ MATCH_CRITERIA_ENABLE_INNER_BIT ;
1433
1451
1434
- return outer_headers_c [0 ] == 0 && !memcmp (outer_headers_c ,
1435
- outer_headers_c + 1 ,
1436
- size - 1 );
1452
+ return match_criteria_enable ;
1437
1453
}
1438
1454
1439
1455
static void set_proto (void * outer_c , void * outer_v , u8 mask , u8 val )
@@ -1453,7 +1469,7 @@ static void set_tos(void *outer_c, void *outer_v, u8 mask, u8 val)
1453
1469
#define LAST_ETH_FIELD vlan_tag
1454
1470
#define LAST_IB_FIELD sl
1455
1471
#define LAST_IPV4_FIELD tos
1456
- #define LAST_IPV6_FIELD dst_ip
1472
+ #define LAST_IPV6_FIELD traffic_class
1457
1473
#define LAST_TCP_UDP_FIELD src_port
1458
1474
1459
1475
/* Field is the last supported field */
@@ -1471,6 +1487,11 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v,
1471
1487
outer_headers );
1472
1488
void * outer_headers_v = MLX5_ADDR_OF (fte_match_param , match_v ,
1473
1489
outer_headers );
1490
+ void * misc_params_c = MLX5_ADDR_OF (fte_match_param , match_c ,
1491
+ misc_parameters );
1492
+ void * misc_params_v = MLX5_ADDR_OF (fte_match_param , match_v ,
1493
+ misc_parameters );
1494
+
1474
1495
switch (ib_spec -> type ) {
1475
1496
case IB_FLOW_SPEC_ETH :
1476
1497
if (FIELDS_NOT_SUPPORTED (ib_spec -> eth .mask , LAST_ETH_FIELD ))
@@ -1570,6 +1591,21 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v,
1570
1591
dst_ipv4_dst_ipv6 .ipv6_layout .ipv6 ),
1571
1592
& ib_spec -> ipv6 .val .dst_ip ,
1572
1593
sizeof (ib_spec -> ipv6 .val .dst_ip ));
1594
+
1595
+ set_tos (outer_headers_c , outer_headers_v ,
1596
+ ib_spec -> ipv6 .mask .traffic_class ,
1597
+ ib_spec -> ipv6 .val .traffic_class );
1598
+
1599
+ set_proto (outer_headers_c , outer_headers_v ,
1600
+ ib_spec -> ipv6 .mask .next_hdr ,
1601
+ ib_spec -> ipv6 .val .next_hdr );
1602
+
1603
+ MLX5_SET (fte_match_set_misc , misc_params_c ,
1604
+ outer_ipv6_flow_label ,
1605
+ ntohl (ib_spec -> ipv6 .mask .flow_label ));
1606
+ MLX5_SET (fte_match_set_misc , misc_params_v ,
1607
+ outer_ipv6_flow_label ,
1608
+ ntohl (ib_spec -> ipv6 .val .flow_label ));
1573
1609
break ;
1574
1610
case IB_FLOW_SPEC_TCP :
1575
1611
if (FIELDS_NOT_SUPPORTED (ib_spec -> tcp_udp .mask ,
@@ -1817,9 +1853,7 @@ static struct mlx5_ib_flow_handler *create_flow_rule(struct mlx5_ib_dev *dev,
1817
1853
ib_flow += ((union ib_flow_spec * )ib_flow )-> size ;
1818
1854
}
1819
1855
1820
- /* Outer header support only */
1821
- spec -> match_criteria_enable = (!outer_header_zero (spec -> match_criteria ))
1822
- << 0 ;
1856
+ spec -> match_criteria_enable = get_match_criteria_enable (spec -> match_criteria );
1823
1857
action = dst ? MLX5_FLOW_CONTEXT_ACTION_FWD_DEST :
1824
1858
MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO ;
1825
1859
handler -> rule = mlx5_add_flow_rule (ft , spec ,
0 commit comments