From f0c2dc8201d68aa9a48639c933adf9156ebc32d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Morten=20Br=C3=B8rup?= Date: Fri, 21 Jun 2019 12:55:06 +0200 Subject: [PATCH] net: move TCP flags from ethdev header MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit TCP flags were moved to the TCP header file from the Ethernet control header file, and the RTE prefix was added to their names. Missing TCP ECN flags were added. The ALL mask did not include TCP ECN flags, so it was renamed to reflect that it applies to N-tuple filtering only. Updated other files affected by the renaming accordingly. Signed-off-by: Morten Brørup Acked-by: Olivier Matz --- app/test-pmd/cmdline.c | 4 ++-- drivers/net/e1000/igb_ethdev.c | 32 ++++++++++++++++---------------- drivers/net/e1000/igb_flow.c | 4 ++-- drivers/net/ixgbe/ixgbe_flow.c | 4 ++-- lib/librte_ethdev/rte_eth_ctrl.h | 8 +------- lib/librte_gro/gro_tcp4.c | 2 +- lib/librte_gro/gro_vxlan_tcp4.c | 2 +- lib/librte_net/rte_tcp.h | 12 ++++++++++++ 8 files changed, 37 insertions(+), 31 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index d1e0d4402c..cbde5d2ae9 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -10080,7 +10080,7 @@ cmd_2tuple_filter_parsed(void *parsed_result, " when protocol is TCP.\n"); return; } - if (res->tcp_flags_value > TCP_FLAG_ALL) { + if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { printf("invalid TCP flags.\n"); return; } @@ -10238,7 +10238,7 @@ cmd_5tuple_filter_parsed(void *parsed_result, " when protocol is TCP.\n"); return; } - if (res->tcp_flags_value > TCP_FLAG_ALL) { + if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { printf("invalid TCP flags.\n"); return; } diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 4436f9d3cf..3ee28cfbcc 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -3707,7 +3707,7 @@ ntuple_filter_to_2tuple(struct rte_eth_ntuple_filter *filter, return -EINVAL; if (filter->priority > E1000_2TUPLE_MAX_PRI) return -EINVAL; /* filter index is out of range. */ - if (filter->tcp_flags > TCP_FLAG_ALL) + if (filter->tcp_flags > RTE_NTUPLE_TCP_FLAGS_MASK) return -EINVAL; /* flags is invalid. */ switch (filter->dst_port_mask) { @@ -3787,18 +3787,18 @@ igb_inject_2uple_filter(struct rte_eth_dev *dev, ttqf &= ~E1000_TTQF_MASK_ENABLE; /* tcp flags bits setting. */ - if (filter->filter_info.tcp_flags & TCP_FLAG_ALL) { - if (filter->filter_info.tcp_flags & TCP_URG_FLAG) + if (filter->filter_info.tcp_flags & RTE_NTUPLE_TCP_FLAGS_MASK) { + if (filter->filter_info.tcp_flags & RTE_TCP_URG_FLAG) imir_ext |= E1000_IMIREXT_CTRL_URG; - if (filter->filter_info.tcp_flags & TCP_ACK_FLAG) + if (filter->filter_info.tcp_flags & RTE_TCP_ACK_FLAG) imir_ext |= E1000_IMIREXT_CTRL_ACK; - if (filter->filter_info.tcp_flags & TCP_PSH_FLAG) + if (filter->filter_info.tcp_flags & RTE_TCP_PSH_FLAG) imir_ext |= E1000_IMIREXT_CTRL_PSH; - if (filter->filter_info.tcp_flags & TCP_RST_FLAG) + if (filter->filter_info.tcp_flags & RTE_TCP_RST_FLAG) imir_ext |= E1000_IMIREXT_CTRL_RST; - if (filter->filter_info.tcp_flags & TCP_SYN_FLAG) + if (filter->filter_info.tcp_flags & RTE_TCP_SYN_FLAG) imir_ext |= E1000_IMIREXT_CTRL_SYN; - if (filter->filter_info.tcp_flags & TCP_FIN_FLAG) + if (filter->filter_info.tcp_flags & RTE_TCP_FIN_FLAG) imir_ext |= E1000_IMIREXT_CTRL_FIN; } else { imir_ext |= E1000_IMIREXT_CTRL_BP; @@ -4193,7 +4193,7 @@ ntuple_filter_to_5tuple_82576(struct rte_eth_ntuple_filter *filter, return -EINVAL; if (filter->priority > E1000_2TUPLE_MAX_PRI) return -EINVAL; /* filter index is out of range. */ - if (filter->tcp_flags > TCP_FLAG_ALL) + if (filter->tcp_flags > RTE_NTUPLE_TCP_FLAGS_MASK) return -EINVAL; /* flags is invalid. */ switch (filter->dst_ip_mask) { @@ -4323,18 +4323,18 @@ igb_inject_5tuple_filter_82576(struct rte_eth_dev *dev, imir |= filter->filter_info.priority << E1000_IMIR_PRIORITY_SHIFT; /* tcp flags bits setting. */ - if (filter->filter_info.tcp_flags & TCP_FLAG_ALL) { - if (filter->filter_info.tcp_flags & TCP_URG_FLAG) + if (filter->filter_info.tcp_flags & RTE_NTUPLE_TCP_FLAGS_MASK) { + if (filter->filter_info.tcp_flags & RTE_TCP_URG_FLAG) imir_ext |= E1000_IMIREXT_CTRL_URG; - if (filter->filter_info.tcp_flags & TCP_ACK_FLAG) + if (filter->filter_info.tcp_flags & RTE_TCP_ACK_FLAG) imir_ext |= E1000_IMIREXT_CTRL_ACK; - if (filter->filter_info.tcp_flags & TCP_PSH_FLAG) + if (filter->filter_info.tcp_flags & RTE_TCP_PSH_FLAG) imir_ext |= E1000_IMIREXT_CTRL_PSH; - if (filter->filter_info.tcp_flags & TCP_RST_FLAG) + if (filter->filter_info.tcp_flags & RTE_TCP_RST_FLAG) imir_ext |= E1000_IMIREXT_CTRL_RST; - if (filter->filter_info.tcp_flags & TCP_SYN_FLAG) + if (filter->filter_info.tcp_flags & RTE_TCP_SYN_FLAG) imir_ext |= E1000_IMIREXT_CTRL_SYN; - if (filter->filter_info.tcp_flags & TCP_FIN_FLAG) + if (filter->filter_info.tcp_flags & RTE_TCP_FIN_FLAG) imir_ext |= E1000_IMIREXT_CTRL_FIN; } else { imir_ext |= E1000_IMIREXT_CTRL_BP; diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c index 9f002de0a5..4e0b38fcf1 100644 --- a/drivers/net/e1000/igb_flow.c +++ b/drivers/net/e1000/igb_flow.c @@ -866,13 +866,13 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, tcp_spec = item->spec; tcp_mask = item->mask; - if (!(tcp_spec->hdr.tcp_flags & TCP_SYN_FLAG) || + if (!(tcp_spec->hdr.tcp_flags & RTE_TCP_SYN_FLAG) || tcp_mask->hdr.src_port || tcp_mask->hdr.dst_port || tcp_mask->hdr.sent_seq || tcp_mask->hdr.recv_ack || tcp_mask->hdr.data_off || - tcp_mask->hdr.tcp_flags != TCP_SYN_FLAG || + tcp_mask->hdr.tcp_flags != RTE_TCP_SYN_FLAG || tcp_mask->hdr.rx_win || tcp_mask->hdr.cksum || tcp_mask->hdr.tcp_urp) { diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 2b8529f572..92377b81cb 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -1048,13 +1048,13 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr, tcp_spec = item->spec; tcp_mask = item->mask; - if (!(tcp_spec->hdr.tcp_flags & TCP_SYN_FLAG) || + if (!(tcp_spec->hdr.tcp_flags & RTE_TCP_SYN_FLAG) || tcp_mask->hdr.src_port || tcp_mask->hdr.dst_port || tcp_mask->hdr.sent_seq || tcp_mask->hdr.recv_ack || tcp_mask->hdr.data_off || - tcp_mask->hdr.tcp_flags != TCP_SYN_FLAG || + tcp_mask->hdr.tcp_flags != RTE_TCP_SYN_FLAG || tcp_mask->hdr.rx_win || tcp_mask->hdr.cksum || tcp_mask->hdr.tcp_urp) { diff --git a/lib/librte_ethdev/rte_eth_ctrl.h b/lib/librte_ethdev/rte_eth_ctrl.h index 85c1e372ae..be4b4af65b 100644 --- a/lib/librte_ethdev/rte_eth_ctrl.h +++ b/lib/librte_ethdev/rte_eth_ctrl.h @@ -149,13 +149,7 @@ struct rte_eth_syn_filter { RTE_NTUPLE_FLAGS_DST_PORT | \ RTE_NTUPLE_FLAGS_PROTO) -#define TCP_URG_FLAG 0x20 -#define TCP_ACK_FLAG 0x10 -#define TCP_PSH_FLAG 0x08 -#define TCP_RST_FLAG 0x04 -#define TCP_SYN_FLAG 0x02 -#define TCP_FIN_FLAG 0x01 -#define TCP_FLAG_ALL 0x3F +#define RTE_NTUPLE_TCP_FLAGS_MASK 0x3F /**< TCP flags filter can match. */ /** * A structure used to define the ntuple filter entry diff --git a/lib/librte_gro/gro_tcp4.c b/lib/librte_gro/gro_tcp4.c index 70d8c5d196..feb5855144 100644 --- a/lib/librte_gro/gro_tcp4.c +++ b/lib/librte_gro/gro_tcp4.c @@ -224,7 +224,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, * Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE * or CWR set. */ - if (tcp_hdr->tcp_flags != TCP_ACK_FLAG) + if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG) return -1; /* * Don't process the packet whose payload length is less than or diff --git a/lib/librte_gro/gro_vxlan_tcp4.c b/lib/librte_gro/gro_vxlan_tcp4.c index 5fa88071d8..f3b6e603b9 100644 --- a/lib/librte_gro/gro_vxlan_tcp4.c +++ b/lib/librte_gro/gro_vxlan_tcp4.c @@ -330,7 +330,7 @@ gro_vxlan_tcp4_reassemble(struct rte_mbuf *pkt, * Don't process the packet which has FIN, SYN, RST, PSH, URG, * ECE or CWR set. */ - if (tcp_hdr->tcp_flags != TCP_ACK_FLAG) + if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG) return -1; hdr_len = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len + diff --git a/lib/librte_net/rte_tcp.h b/lib/librte_net/rte_tcp.h index 4bcda55656..7d649a292a 100644 --- a/lib/librte_net/rte_tcp.h +++ b/lib/librte_net/rte_tcp.h @@ -35,6 +35,18 @@ struct rte_tcp_hdr { uint16_t tcp_urp; /**< TCP urgent pointer, if any. */ } __attribute__((__packed__)); +/** + * TCP Flags + */ +#define RTE_TCP_CWR_FLAG 0x80 /**< Congestion Window Reduced */ +#define RTE_TCP_ECE_FLAG 0x40 /**< ECN-Echo */ +#define RTE_TCP_URG_FLAG 0x20 /**< Urgent Pointer field significant */ +#define RTE_TCP_ACK_FLAG 0x10 /**< Acknowledgment field significant */ +#define RTE_TCP_PSH_FLAG 0x08 /**< Push Function */ +#define RTE_TCP_RST_FLAG 0x04 /**< Reset the connection */ +#define RTE_TCP_SYN_FLAG 0x02 /**< Synchronize sequence numbers */ +#define RTE_TCP_FIN_FLAG 0x01 /**< No more data from sender */ + #ifdef __cplusplus } #endif -- 2.20.1