diff options
author | Maor Gottlieb <maorg@mellanox.com> | 2016-08-30 09:58:36 -0400 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-10-07 16:54:19 -0400 |
commit | 466fa6d2e36408f697f9ff766f82003ef424bad1 (patch) | |
tree | 0345eca070d55dab02786f00f040b37ed7192d92 | |
parent | ca0d47538528be18cbf45e3cce09862ddf37a3cf (diff) |
IB/mlx5: Add support of more IPv6 fields to flow steering
Add support to receive Traffic Class, specific IPv6 protocol
or IPv6 flow label.
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r-- | drivers/infiniband/hw/mlx5/main.c | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index fbc0e42ef450..98844c1db555 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c | |||
@@ -1425,15 +1425,31 @@ static int mlx5_ib_dealloc_pd(struct ib_pd *pd) | |||
1425 | return 0; | 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); | 1440 | u8 match_criteria_enable; |
1431 | char *outer_headers_c = MLX5_ADDR_OF(fte_match_param, match_criteria, | 1441 | |
1432 | outer_headers); | 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, | 1452 | return match_criteria_enable; |
1435 | outer_headers_c + 1, | ||
1436 | size - 1); | ||
1437 | } | 1453 | } |
1438 | 1454 | ||
1439 | static void set_proto(void *outer_c, void *outer_v, u8 mask, u8 val) | 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 | #define LAST_ETH_FIELD vlan_tag | 1469 | #define LAST_ETH_FIELD vlan_tag |
1454 | #define LAST_IB_FIELD sl | 1470 | #define LAST_IB_FIELD sl |
1455 | #define LAST_IPV4_FIELD tos | 1471 | #define LAST_IPV4_FIELD tos |
1456 | #define LAST_IPV6_FIELD dst_ip | 1472 | #define LAST_IPV6_FIELD traffic_class |
1457 | #define LAST_TCP_UDP_FIELD src_port | 1473 | #define LAST_TCP_UDP_FIELD src_port |
1458 | 1474 | ||
1459 | /* Field is the last supported field */ | 1475 | /* Field is the last supported field */ |
@@ -1471,6 +1487,11 @@ static int parse_flow_attr(u32 *match_c, u32 *match_v, | |||
1471 | outer_headers); | 1487 | outer_headers); |
1472 | void *outer_headers_v = MLX5_ADDR_OF(fte_match_param, match_v, | 1488 | void *outer_headers_v = MLX5_ADDR_OF(fte_match_param, match_v, |
1473 | outer_headers); | 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 | switch (ib_spec->type) { | 1495 | switch (ib_spec->type) { |
1475 | case IB_FLOW_SPEC_ETH: | 1496 | case IB_FLOW_SPEC_ETH: |
1476 | if (FIELDS_NOT_SUPPORTED(ib_spec->eth.mask, LAST_ETH_FIELD)) | 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 | dst_ipv4_dst_ipv6.ipv6_layout.ipv6), | 1591 | dst_ipv4_dst_ipv6.ipv6_layout.ipv6), |
1571 | &ib_spec->ipv6.val.dst_ip, | 1592 | &ib_spec->ipv6.val.dst_ip, |
1572 | sizeof(ib_spec->ipv6.val.dst_ip)); | 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 | break; | 1609 | break; |
1574 | case IB_FLOW_SPEC_TCP: | 1610 | case IB_FLOW_SPEC_TCP: |
1575 | if (FIELDS_NOT_SUPPORTED(ib_spec->tcp_udp.mask, | 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 | ib_flow += ((union ib_flow_spec *)ib_flow)->size; | 1853 | ib_flow += ((union ib_flow_spec *)ib_flow)->size; |
1818 | } | 1854 | } |
1819 | 1855 | ||
1820 | /* Outer header support only */ | 1856 | spec->match_criteria_enable = get_match_criteria_enable(spec->match_criteria); |
1821 | spec->match_criteria_enable = (!outer_header_zero(spec->match_criteria)) | ||
1822 | << 0; | ||
1823 | action = dst ? MLX5_FLOW_CONTEXT_ACTION_FWD_DEST : | 1857 | action = dst ? MLX5_FLOW_CONTEXT_ACTION_FWD_DEST : |
1824 | MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO; | 1858 | MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO; |
1825 | handler->rule = mlx5_add_flow_rule(ft, spec, | 1859 | handler->rule = mlx5_add_flow_rule(ft, spec, |