@@ -19,6 +19,7 @@ eth = Y
icmp = Y
ipv4 = Y
port_id = Y
+tcp = Y
udp = Y
[rte_flow actions]
@@ -166,6 +166,7 @@ enum {
};
enum {
+ PROT_L4_TCP = 1,
PROT_L4_UDP = 2,
PROT_L4_ICMP = 4
};
@@ -177,6 +178,7 @@ enum {
enum {
PROT_TUN_L4_OTHER = 0,
+ PROT_TUN_L4_TCP = 1,
PROT_TUN_L4_UDP = 2,
PROT_TUN_L4_ICMP = 4
};
@@ -1023,6 +1023,106 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev,
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);
+ {
+ const struct rte_flow_item_tcp *tcp_spec =
+ (const struct rte_flow_item_tcp *)elem[eidx].spec;
+ const struct rte_flow_item_tcp *tcp_mask =
+ (const struct rte_flow_item_tcp *)elem[eidx].mask;
+
+ if (tcp_spec == NULL || tcp_mask == NULL) {
+ if (any_count > 0 || fd->l4_prot != -1) {
+ fd->tunnel_l4_prot = PROT_TUN_L4_TCP;
+ key_def->inner_proto = 1;
+ } else {
+ fd->l4_prot = PROT_L4_TCP;
+ key_def->outer_proto = 1;
+ }
+ break;
+ }
+
+ if (tcp_mask->hdr.sent_seq != 0 ||
+ tcp_mask->hdr.recv_ack != 0 ||
+ tcp_mask->hdr.data_off != 0 ||
+ tcp_mask->hdr.tcp_flags != 0 ||
+ tcp_mask->hdr.rx_win != 0 ||
+ tcp_mask->hdr.cksum != 0 ||
+ tcp_mask->hdr.tcp_urp != 0) {
+ NT_LOG(ERR, FILTER,
+ "Requested TCP field not support by running SW version");
+ flow_nic_set_error(ERR_FAILED, error);
+ return -1;
+ }
+
+ if (tcp_mask->hdr.src_port || tcp_mask->hdr.dst_port) {
+ 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] = (ntohs(tcp_mask->hdr.src_port)
+ << 16) | ntohs(tcp_mask->hdr.dst_port);
+ sw_data[0] =
+ ((ntohs(tcp_spec->hdr.src_port) << 16) |
+ ntohs(tcp_spec->hdr.dst_port)) & 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] = (ntohs(tcp_spec->hdr.src_port)
+ << 16) | ntohs(tcp_spec->hdr.dst_port);
+ qw_data[1] = 0;
+ qw_data[2] = 0;
+ qw_data[3] = 0;
+
+ qw_mask[0] = (ntohs(tcp_mask->hdr.src_port)
+ << 16) | ntohs(tcp_mask->hdr.dst_port);
+ 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_TCP;
+ key_def->inner_proto = 1;
+
+ } else {
+ fd->l4_prot = PROT_L4_TCP;
+ key_def->outer_proto = 1;
+ }
+ }
+
+ break;
+
case RTE_FLOW_ITEM_TYPE_PORT_ID:
NT_LOG(DBG, FILTER, "Adap %i, Port %i: RTE_FLOW_ITEM_TYPE_PORT_ID",
dev->ndev->adapter_no, dev->port);
@@ -1055,6 +1155,10 @@ static void copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def
uint16_t rpl_ext_ptr, uint32_t flm_scrub __rte_unused, uint32_t priority)
{
switch (fd->l4_prot) {
+ case PROT_L4_TCP:
+ fh->flm_prot = 6;
+ break;
+
case PROT_L4_UDP:
fh->flm_prot = 17;
break;
@@ -1065,6 +1169,10 @@ static void copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def
default:
switch (fd->tunnel_l4_prot) {
+ case PROT_TUN_L4_TCP:
+ fh->flm_prot = 6;
+ break;
+
case PROT_TUN_L4_UDP:
fh->flm_prot = 17;
break;