From: Danylo Vodopianov <dvo-...@napatech.com>

Add possibility to use
* RTE_FLOW_ITEM_TYPE_IPV6
* RTE_FLOW_ITEM_TYPE_ICMP6

Signed-off-by: Danylo Vodopianov <dvo-...@napatech.com>
---
 doc/guides/nics/features/ntnic.ini            |   2 +
 drivers/net/ntnic/include/hw_mod_backend.h    |   2 +
 drivers/net/ntnic/nthw/flow_api/flow_api.c    |  27 ++
 .../profile_inline/flow_api_profile_inline.c  | 273 ++++++++++++++++++
 4 files changed, 304 insertions(+)

diff --git a/doc/guides/nics/features/ntnic.ini 
b/doc/guides/nics/features/ntnic.ini
index 6691b6dce2..320d3c7e0b 100644
--- a/doc/guides/nics/features/ntnic.ini
+++ b/doc/guides/nics/features/ntnic.ini
@@ -17,7 +17,9 @@ x86-64               = Y
 any                  = Y
 eth                  = Y
 icmp                 = Y
+icmp6                = Y
 ipv4                 = Y
+ipv6                 = Y
 port_id              = Y
 sctp                 = Y
 tcp                  = Y
diff --git a/drivers/net/ntnic/include/hw_mod_backend.h 
b/drivers/net/ntnic/include/hw_mod_backend.h
index f1c57fa9fc..4f381bc0ef 100644
--- a/drivers/net/ntnic/include/hw_mod_backend.h
+++ b/drivers/net/ntnic/include/hw_mod_backend.h
@@ -164,6 +164,7 @@ enum {
 
 enum {
        PROT_L3_IPV4 = 1,
+       PROT_L3_IPV6 = 2
 };
 
 enum {
@@ -176,6 +177,7 @@ enum {
 enum {
        PROT_TUN_L3_OTHER = 0,
        PROT_TUN_L3_IPV4 = 1,
+       PROT_TUN_L3_IPV6 = 2
 };
 
 enum {
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c 
b/drivers/net/ntnic/nthw/flow_api/flow_api.c
index 6800a8d834..2aee2ee973 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_api.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c
@@ -47,6 +47,33 @@ static const struct {
 } err_msg[] = {
        /* 00 */ { "Operation successfully completed" },
        /* 01 */ { "Operation failed" },
+       /* 02 */ { "Memory allocation failed" },
+       /* 03 */ { "Too many output destinations" },
+       /* 04 */ { "Too many output queues for RSS" },
+       /* 05 */ { "The VLAN TPID specified is not supported" },
+       /* 06 */ { "The VxLan Push header specified is not accepted" },
+       /* 07 */ { "While interpreting VxLan Pop action, could not find a 
destination port" },
+       /* 08 */ { "Failed in creating a HW-internal VTEP port" },
+       /* 09 */ { "Too many VLAN tag matches" },
+       /* 10 */ { "IPv6 invalid header specified" },
+       /* 11 */ { "Too many tunnel ports. HW limit reached" },
+       /* 12 */ { "Unknown or unsupported flow match element received" },
+       /* 13 */ { "Match failed because of HW limitations" },
+       /* 14 */ { "Match failed because of HW resource limitations" },
+       /* 15 */ { "Match failed because of too complex element definitions" },
+       /* 16 */ { "Action failed. To too many output destinations" },
+       /* 17 */ { "Action Output failed, due to HW resource exhaustion" },
+       /* 18 */ { "Push Tunnel Header action cannot output to multiple 
destination queues" },
+       /* 19 */ { "Inline action HW resource exhaustion" },
+       /* 20 */ { "Action retransmit/recirculate HW resource exhaustion" },
+       /* 21 */ { "Flow counter HW resource exhaustion" },
+       /* 22 */ { "Internal HW resource exhaustion to handle Actions" },
+       /* 23 */ { "Internal HW QSL compare failed" },
+       /* 24 */ { "Internal CAT CFN reuse failed" },
+       /* 25 */ { "Match variations too complex" },
+       /* 26 */ { "Match failed because of CAM/TCAM full" },
+       /* 27 */ { "Internal creation of a tunnel end point port failed" },
+       /* 28 */ { "Unknown or unsupported flow action received" },
        /* 29 */ { "Removing flow failed" },
 };
 
diff --git 
a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c 
b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index 9460325cf6..0b0b9f2033 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -538,6 +538,22 @@ static int interpret_flow_elements(const struct 
flow_eth_dev *dev,
                }
                break;
 
+               case RTE_FLOW_ITEM_TYPE_IPV6: {
+                       const struct rte_flow_item_ipv6 *ipv6_spec =
+                               (const struct rte_flow_item_ipv6 
*)elem[eidx].spec;
+                       const struct rte_flow_item_ipv6 *ipv6_mask =
+                               (const struct rte_flow_item_ipv6 
*)elem[eidx].mask;
+
+                       if (ipv6_spec != NULL && ipv6_mask != NULL) {
+                               if (is_non_zero(&ipv6_spec->hdr.src_addr, 16))
+                                       qw_reserved_ipv6 += 1;
+
+                               if (is_non_zero(&ipv6_spec->hdr.dst_addr, 16))
+                                       qw_reserved_ipv6 += 1;
+                       }
+               }
+               break;
+
                default:
                        break;
                }
@@ -922,6 +938,164 @@ static int interpret_flow_elements(const struct 
flow_eth_dev *dev,
 
                        break;
 
+               case RTE_FLOW_ITEM_TYPE_IPV6:
+                       NT_LOG(DBG, FILTER, "Adap %i, Port %i: 
RTE_FLOW_ITEM_TYPE_IPV6",
+                               dev->ndev->adapter_no, dev->port);
+                       {
+                               const struct rte_flow_item_ipv6 *ipv6_spec =
+                                       (const struct rte_flow_item_ipv6 
*)elem[eidx].spec;
+                               const struct rte_flow_item_ipv6 *ipv6_mask =
+                                       (const struct rte_flow_item_ipv6 
*)elem[eidx].mask;
+
+                               if (ipv6_spec == NULL || ipv6_mask == NULL) {
+                                       if (any_count > 0 || fd->l3_prot != -1)
+                                               fd->tunnel_l3_prot = 
PROT_TUN_L3_IPV6;
+                                       else
+                                               fd->l3_prot = PROT_L3_IPV6;
+                                       break;
+                               }
+
+                               fd->l3_prot = PROT_L3_IPV6;
+                               if (ipv6_mask->hdr.vtc_flow != 0 ||
+                                       ipv6_mask->hdr.payload_len != 0 ||
+                                       ipv6_mask->hdr.hop_limits != 0) {
+                                       NT_LOG(ERR, FILTER,
+                                               "Requested IPv6 field not 
support by running SW version");
+                                       flow_nic_set_error(ERR_FAILED, error);
+                                       return -1;
+                               }
+
+                               if (is_non_zero(&ipv6_spec->hdr.src_addr, 16)) {
+                                       if (qw_counter >= 2) {
+                                               NT_LOG(ERR, FILTER,
+                                                       "Key size too big. Out 
of QW resources.");
+                                               flow_nic_set_error(ERR_FAILED, 
error);
+                                               return -1;
+                                       }
+
+                                       uint32_t *qw_data = &packet_data[2 + 4 
- qw_counter * 4];
+                                       uint32_t *qw_mask = &packet_mask[2 + 4 
- qw_counter * 4];
+
+                                       memcpy(&qw_data[0], 
&ipv6_spec->hdr.src_addr, 16);
+                                       memcpy(&qw_mask[0], 
&ipv6_mask->hdr.src_addr, 16);
+
+                                       qw_data[0] = ntohl(qw_data[0]);
+                                       qw_data[1] = ntohl(qw_data[1]);
+                                       qw_data[2] = ntohl(qw_data[2]);
+                                       qw_data[3] = ntohl(qw_data[3]);
+
+                                       qw_mask[0] = ntohl(qw_mask[0]);
+                                       qw_mask[1] = ntohl(qw_mask[1]);
+                                       qw_mask[2] = ntohl(qw_mask[2]);
+                                       qw_mask[3] = ntohl(qw_mask[3]);
+
+                                       qw_data[0] &= qw_mask[0];
+                                       qw_data[1] &= qw_mask[1];
+                                       qw_data[2] &= qw_mask[2];
+                                       qw_data[3] &= qw_mask[3];
+
+                                       km_add_match_elem(&fd->km, &qw_data[0], 
&qw_mask[0], 4,
+                                               any_count > 0 ? DYN_TUN_L3 : 
DYN_L3, 8);
+                                       set_key_def_qw(key_def, qw_counter, 
any_count > 0
+                                               ? DYN_TUN_L3 : DYN_L3, 8);
+                                       qw_counter += 1;
+                               }
+
+                               if (is_non_zero(&ipv6_spec->hdr.dst_addr, 16)) {
+                                       if (qw_counter >= 2) {
+                                               NT_LOG(ERR, FILTER,
+                                                       "Key size too big. Out 
of QW resources.");
+                                               flow_nic_set_error(ERR_FAILED, 
error);
+                                               return -1;
+                                       }
+
+                                       uint32_t *qw_data = &packet_data[2 + 4 
- qw_counter * 4];
+                                       uint32_t *qw_mask = &packet_mask[2 + 4 
- qw_counter * 4];
+
+                                       memcpy(&qw_data[0], 
&ipv6_spec->hdr.dst_addr, 16);
+                                       memcpy(&qw_mask[0], 
&ipv6_mask->hdr.dst_addr, 16);
+
+                                       qw_data[0] = ntohl(qw_data[0]);
+                                       qw_data[1] = ntohl(qw_data[1]);
+                                       qw_data[2] = ntohl(qw_data[2]);
+                                       qw_data[3] = ntohl(qw_data[3]);
+
+                                       qw_mask[0] = ntohl(qw_mask[0]);
+                                       qw_mask[1] = ntohl(qw_mask[1]);
+                                       qw_mask[2] = ntohl(qw_mask[2]);
+                                       qw_mask[3] = ntohl(qw_mask[3]);
+
+                                       qw_data[0] &= qw_mask[0];
+                                       qw_data[1] &= qw_mask[1];
+                                       qw_data[2] &= qw_mask[2];
+                                       qw_data[3] &= qw_mask[3];
+
+                                       km_add_match_elem(&fd->km, &qw_data[0], 
&qw_mask[0], 4,
+                                               any_count > 0 ? DYN_TUN_L3 : 
DYN_L3, 24);
+                                       set_key_def_qw(key_def, qw_counter, 
any_count > 0
+                                               ? DYN_TUN_L3 : DYN_L3, 24);
+                                       qw_counter += 1;
+                               }
+
+                               if (ipv6_mask->hdr.proto != 0) {
+                                       if (sw_counter < 2) {
+                                               uint32_t *sw_data = 
&packet_data[1 - sw_counter];
+                                               uint32_t *sw_mask = 
&packet_mask[1 - sw_counter];
+
+                                               sw_mask[0] = 
ipv6_mask->hdr.proto << 8;
+                                               sw_data[0] = 
ipv6_spec->hdr.proto << 8 & sw_mask[0];
+
+                                               km_add_match_elem(&fd->km, 
&sw_data[0], &sw_mask[0],
+                                                       1, any_count > 0 ? 
DYN_TUN_L3 : DYN_L3, 4);
+                                               set_key_def_sw(key_def, 
sw_counter, any_count > 0
+                                                       ? DYN_TUN_L3 : DYN_L3, 
4);
+                                               sw_counter += 1;
+
+                                       } else if (qw_counter < 2 && qw_free > 
0) {
+                                               uint32_t *qw_data =
+                                                       &packet_data[2 + 4 - 
qw_counter * 4];
+                                               uint32_t *qw_mask =
+                                                       &packet_mask[2 + 4 - 
qw_counter * 4];
+
+                                               qw_data[0] = 0;
+                                               qw_data[1] = 
ipv6_mask->hdr.proto << 8;
+                                               qw_data[2] = 0;
+                                               qw_data[3] = 0;
+
+                                               qw_mask[0] = 0;
+                                               qw_mask[1] = 
ipv6_spec->hdr.proto << 8;
+                                               qw_mask[2] = 0;
+                                               qw_mask[3] = 0;
+
+                                               qw_data[0] &= qw_mask[0];
+                                               qw_data[1] &= qw_mask[1];
+                                               qw_data[2] &= qw_mask[2];
+                                               qw_data[3] &= qw_mask[3];
+
+                                               km_add_match_elem(&fd->km, 
&qw_data[0], &qw_mask[0],
+                                                       4, any_count > 0 ? 
DYN_TUN_L3 : DYN_L3, 0);
+                                               set_key_def_qw(key_def, 
qw_counter, any_count > 0
+                                                       ? DYN_TUN_L3 : DYN_L3, 
0);
+                                               qw_counter += 1;
+                                               qw_free -= 1;
+
+                                       } else {
+                                               NT_LOG(ERR, FILTER,
+                                                       "Key size too big. Out 
of SW-QW resources.");
+                                               flow_nic_set_error(ERR_FAILED, 
error);
+                                               return -1;
+                                       }
+                               }
+
+                               if (any_count > 0 || fd->l3_prot != -1)
+                                       fd->tunnel_l3_prot = PROT_TUN_L3_IPV6;
+
+                               else
+                                       fd->l3_prot = PROT_L3_IPV6;
+                       }
+
+                       break;
+
                case RTE_FLOW_ITEM_TYPE_UDP:
                        NT_LOG(DBG, FILTER, "Adap %i, Port %i: 
RTE_FLOW_ITEM_TYPE_UDP",
                                dev->ndev->adapter_no, dev->port);
@@ -1212,6 +1386,105 @@ static int interpret_flow_elements(const struct 
flow_eth_dev *dev,
 
                        break;
 
+               case RTE_FLOW_ITEM_TYPE_ICMP6:
+                       NT_LOG(DBG, FILTER, "Adap %i, Port %i: 
RTE_FLOW_ITEM_TYPE_ICMP6",
+                               dev->ndev->adapter_no, dev->port);
+                       {
+                               const struct rte_flow_item_icmp6 *icmp_spec =
+                                       (const struct rte_flow_item_icmp6 
*)elem[eidx].spec;
+                               const struct rte_flow_item_icmp6 *icmp_mask =
+                                       (const struct rte_flow_item_icmp6 
*)elem[eidx].mask;
+
+                               if (icmp_spec == NULL || icmp_mask == NULL) {
+                                       if (any_count > 0 || fd->l4_prot != -1) 
{
+                                               fd->tunnel_l4_prot = 
PROT_TUN_L4_ICMP;
+                                               fd->tunnel_ip_prot = 58;
+                                               key_def->inner_proto = 1;
+                                       } else {
+                                               fd->l4_prot = PROT_L4_ICMP;
+                                               fd->ip_prot = 58;
+                                               key_def->outer_proto = 1;
+                                       }
+                                       break;
+                               }
+
+                               if (icmp_mask->checksum != 0) {
+                                       NT_LOG(ERR, FILTER,
+                                               "Requested ICMP6 field not 
supported by running SW version");
+                                       flow_nic_set_error(ERR_FAILED, error);
+                                       return -1;
+                               }
+
+                               if (icmp_mask->type || icmp_mask->code) {
+                                       if (sw_counter < 2) {
+                                               uint32_t *sw_data = 
&packet_data[1 - sw_counter];
+                                               uint32_t *sw_mask = 
&packet_mask[1 - sw_counter];
+
+                                               sw_mask[0] = icmp_mask->type << 
24 |
+                                                       icmp_mask->code << 16;
+                                               sw_data[0] = icmp_spec->type << 
24 |
+                                                       icmp_spec->code << 16;
+                                               sw_data[0] &= sw_mask[0];
+
+                                               km_add_match_elem(&fd->km, 
&sw_data[0], &sw_mask[0],
+                                                       1, any_count > 0 ? 
DYN_TUN_L4 : DYN_L4, 0);
+
+                                               set_key_def_sw(key_def, 
sw_counter, any_count > 0
+                                                       ? DYN_TUN_L4 : DYN_L4, 
0);
+                                               sw_counter += 1;
+
+                                       } else if (qw_counter < 2 && qw_free > 
0) {
+                                               uint32_t *qw_data =
+                                                       &packet_data[2 + 4 - 
qw_counter * 4];
+                                               uint32_t *qw_mask =
+                                                       &packet_mask[2 + 4 - 
qw_counter * 4];
+
+                                               qw_data[0] = icmp_spec->type << 
24 |
+                                                       icmp_spec->code << 16;
+                                               qw_data[1] = 0;
+                                               qw_data[2] = 0;
+                                               qw_data[3] = 0;
+
+                                               qw_mask[0] = icmp_mask->type << 
24 |
+                                                       icmp_mask->code << 16;
+                                               qw_mask[1] = 0;
+                                               qw_mask[2] = 0;
+                                               qw_mask[3] = 0;
+
+                                               qw_data[0] &= qw_mask[0];
+                                               qw_data[1] &= qw_mask[1];
+                                               qw_data[2] &= qw_mask[2];
+                                               qw_data[3] &= qw_mask[3];
+
+                                               km_add_match_elem(&fd->km, 
&qw_data[0], &qw_mask[0],
+                                                       4, any_count > 0 ? 
DYN_TUN_L4 : DYN_L4, 0);
+                                               set_key_def_qw(key_def, 
qw_counter, any_count > 0
+                                                       ? DYN_TUN_L4 : DYN_L4, 
0);
+                                               qw_counter += 1;
+                                               qw_free -= 1;
+
+                                       } else {
+                                               NT_LOG(ERR, FILTER,
+                                                       "Key size too big. Out 
of SW-QW resources.");
+                                               flow_nic_set_error(ERR_FAILED, 
error);
+                                               return -1;
+                                       }
+                               }
+
+                               if (any_count > 0 || fd->l4_prot != -1) {
+                                       fd->tunnel_l4_prot = PROT_TUN_L4_ICMP;
+                                       fd->tunnel_ip_prot = 58;
+                                       key_def->inner_proto = 1;
+
+                               } else {
+                                       fd->l4_prot = PROT_L4_ICMP;
+                                       fd->ip_prot = 58;
+                                       key_def->outer_proto = 1;
+                               }
+                       }
+
+                       break;
+
                case RTE_FLOW_ITEM_TYPE_TCP:
                        NT_LOG(DBG, FILTER, "Adap %i, Port %i: 
RTE_FLOW_ITEM_TYPE_TCP",
                                dev->ndev->adapter_no, dev->port);
-- 
2.45.0

Reply via email to