Define TCP flags in rte_tcp.h instead of in rte_eth_ctrl.h
diff mbox series

Message ID 1561114506-3449-1-git-send-email-mb@smartsharesystems.com
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • Define TCP flags in rte_tcp.h instead of in rte_eth_ctrl.h
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Morten Brørup June 21, 2019, 10:55 a.m. UTC
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 <mb@smartsharesystems.com>
---
 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(-)

Comments

Olivier Matz July 1, 2019, 1:11 p.m. UTC | #1
On Fri, Jun 21, 2019 at 12:55:06PM +0200, Morten Brørup wrote:
> 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 <mb@smartsharesystems.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>
Ferruh Yigit July 2, 2019, 6:42 p.m. UTC | #2
On 7/1/2019 2:11 PM, Olivier Matz wrote:
> On Fri, Jun 21, 2019 at 12:55:06PM +0200, Morten Brørup wrote:
>> 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 <mb@smartsharesystems.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
> 

Applied to dpdk-next-net/master, thanks.

Patch
diff mbox series

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index d1e0d44..cbde5d2 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 4436f9d..3ee28cf 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 9f002de..4e0b38f 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 2b8529f..92377b8 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 85c1e37..be4b4af 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 70d8c5d..feb5855 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 5fa8807..f3b6e60 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 4bcda55..7d649a2 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