From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E27ABA00C4 for ; Tue, 26 Jul 2022 08:41:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BBE0740DDD; Tue, 26 Jul 2022 08:41:27 +0200 (CEST) Received: from mail-ua1-f50.google.com (mail-ua1-f50.google.com [209.85.222.50]) by mails.dpdk.org (Postfix) with ESMTP id A8A8540695; Tue, 26 Jul 2022 08:41:26 +0200 (CEST) Received: by mail-ua1-f50.google.com with SMTP id c19so231619uat.6; Mon, 25 Jul 2022 23:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=loPPWPbi4aH69RmUDrs260ULDiyXEJzurcIGV953hzk=; b=EwLNx/Q9pyuQkIuJEcecNcQesPA6VYJeyiOajFGhRnfDXQpzKmfvlr2OB40E6w2IXJ QfKHdFOXDwW3J/VeZy6fiJXiq8immPHtwWUdd5QqhOI+zjB9NZB3bYvKU6pkktdDOmlw 82LrxgFrGkCDzgsFdZa3Q4YXXoG9Up9roX4Hqjve6B69+2502yNdqZro92FhsPPraf3D FlxDI7VSMUy6kIavUmxMBtTsY30DzVv69UObIv6f3APLrxbPtl7K9WmCJ2aGTg6fqsCr eOrJrj4aw/QhCiydfTZnjqQpP9zXqXohaykGkQ8LofeEHXG15nczTphMweJEeQzqw9jg Qrdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=loPPWPbi4aH69RmUDrs260ULDiyXEJzurcIGV953hzk=; b=rk5QyAIeK6kZjFIAT8yRlG1ZAE8xs58tZtzWSRRjfNPJAo9nwz5+P/xxk8TSa1jILs mHFx5w6tnQgNRxpO5qDV1EbNpL/5mL1gFG0NxHAAlQlcrrxJkbOkArJeEf7XSjSd6/bf XyNBkl9ka76E/7kkpEF1Cd7ZknHtSkedsK8poCSs1ROI4YjjIN6N+5bNQ9D24sLuwZeT +goMsfOZVQGUNDV6OYd4D3wSN63UsHTEfvQK6sp9t88Pl4tjsF7CzsdiXV/4Uw8yopkw xnjl2nS4bm/9X58eQ7IdjXLlpEKAKr0u2Lyj3YBGNi6tyyLkj/Mz9ntB4RNthVgwXCDr pyoA== X-Gm-Message-State: AJIora8NqgSPvpx8tXILk58vhrpvY7cIi2Mb7d5M1DL9VpgaA/Vic+zh Pxt75CeS+ZjST/aCOwwLZ8+BfnnNVnQBaVvkr50= X-Google-Smtp-Source: AGRyM1uP32h4MEoycWlHYRPDxw0U+B0/bl/5C4n4UIuYioXIKnCELtG/JSUT/1N2gzYM46wFn7vNOFvnamiSJ0ScNCY= X-Received: by 2002:ab0:7301:0:b0:380:ce4c:84b0 with SMTP id v1-20020ab07301000000b00380ce4c84b0mr4473828uao.69.1658817685988; Mon, 25 Jul 2022 23:41:25 -0700 (PDT) MIME-Version: 1.0 References: <20220726061741.21021-1-jun.qiu@jaguarmicro.com> In-Reply-To: <20220726061741.21021-1-jun.qiu@jaguarmicro.com> From: kumaraparameshwaran rathinavel Date: Tue, 26 Jul 2022 12:11:14 +0530 Message-ID: Subject: Re: [PATCH] gro: fix gro with tcp push flag To: Jun Qiu Cc: dev@dpdk.org, jiayu.hu@intel.com, stable@dpdk.org Content-Type: multipart/alternative; boundary="000000000000eba9f105e4af96d1" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org --000000000000eba9f105e4af96d1 Content-Type: text/plain; charset="UTF-8" On Tue, Jul 26, 2022 at 11:48 AM Jun Qiu wrote: > TCP data packets sometimes carry a PUSH flag. Currently, > only the packets that do not have PUSH flag can be GROed. > The packets that have a PUSH flag cannot be GROed, the packets > that cannot be processed by GRO are placed last. > In this case, the received packets may be out of order. > For example, there are two packets mbuf1 and mbuf2. mbuf1 > contains PUSH flag, mbuf2 does not contain PUSH flag. > After GRO processing, mbuf2 is sent for processing before mbuf1. > This out-of-order will affect TCP processing performance and > lead to unnecessary dup-ACK. > > Referring to the Linux kernel implementation, packets with PUSH > flag can also perform GRO. And if one of the packets containing > PUSH flag, the packets after GRO will carry PUSH flag. > > In case of smaller transfers in which the TCP segment size is not more than one MTU, it is a single TCP packet with PSH flag set, so in those cases we are introducing unwanted delay. I think the better approach would be if there are previous packets in the flow and the current packet received has PSH flag then coalesce with the previous packet, if lookup is failure and the current packet has PSH flag set then deliver it immediately. Fixes: 0d2cbe59b719 ("lib/gro: support TCP/IPv4") > Cc: stable@dpdk.org > > Signed-off-by: Jun Qiu > --- > lib/gro/gro_tcp4.c | 4 ++-- > lib/gro/gro_tcp4.h | 16 +++++++++++++--- > lib/gro/gro_vxlan_tcp4.c | 4 ++-- > 3 files changed, 17 insertions(+), 7 deletions(-) > > diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c > index 7498c66141..7849a2bd1d 100644 > --- a/lib/gro/gro_tcp4.c > +++ b/lib/gro/gro_tcp4.c > @@ -220,10 +220,10 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, > hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; > > /* > - * Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE > + * Don't process the packet which has FIN, SYN, RST, URG, ECE > * or CWR set. > */ > - if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG) > + if (tcp_hdr->tcp_flags & (~(RTE_TCP_ACK_FLAG | RTE_TCP_PSH_FLAG))) > return -1; > /* > * Don't process the packet whose payload length is less than or > diff --git a/lib/gro/gro_tcp4.h b/lib/gro/gro_tcp4.h > index 212f97a042..2974faf228 100644 > --- a/lib/gro/gro_tcp4.h > +++ b/lib/gro/gro_tcp4.h > @@ -210,7 +210,8 @@ merge_two_tcp4_packets(struct gro_tcp4_item *item, > uint16_t l2_offset) > { > struct rte_mbuf *pkt_head, *pkt_tail, *lastseg; > - uint16_t hdr_len, l2_len; > + struct rte_tcp_hdr *head_tcp_hdr, *tail_tcp_hdr; > + uint16_t hdr_len, l2_len, l3_offset; > > if (cmp > 0) { > pkt_head = item->firstseg; > @@ -221,13 +222,22 @@ merge_two_tcp4_packets(struct gro_tcp4_item *item, > } > > /* check if the IPv4 packet length is greater than the max value */ > - hdr_len = l2_offset + pkt_head->l2_len + pkt_head->l3_len + > - pkt_head->l4_len; > + l3_offset = l2_offset + pkt_head->l2_len + pkt_head->l3_len; > + hdr_len = l3_offset + pkt_head->l4_len; > l2_len = l2_offset > 0 ? pkt_head->outer_l2_len : pkt_head->l2_len; > if (unlikely(pkt_head->pkt_len - l2_len + pkt_tail->pkt_len - > hdr_len > MAX_IPV4_PKT_LENGTH)) > return 0; > > + /* merge push flag to pkt_head */ > + tail_tcp_hdr = rte_pktmbuf_mtod_offset(pkt_tail, > + struct rte_tcp_hdr *, l3_offset); > + if (tail_tcp_hdr->tcp_flags & RTE_TCP_PSH_FLAG) { > + head_tcp_hdr = rte_pktmbuf_mtod_offset(pkt_head, > + struct rte_tcp_hdr *, l3_offset); > + head_tcp_hdr->tcp_flags |= RTE_TCP_PSH_FLAG; > + } > + > /* remove the packet header for the tail packet */ > rte_pktmbuf_adj(pkt_tail, hdr_len); > > diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c > index 3be4deb7c7..884802af0b 100644 > --- a/lib/gro/gro_vxlan_tcp4.c > +++ b/lib/gro/gro_vxlan_tcp4.c > @@ -326,10 +326,10 @@ gro_vxlan_tcp4_reassemble(struct rte_mbuf *pkt, > tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); > > /* > - * Don't process the packet which has FIN, SYN, RST, PSH, URG, > + * Don't process the packet which has FIN, SYN, RST, URG, > * ECE or CWR set. > */ > - if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG) > + if (tcp_hdr->tcp_flags & (~(RTE_TCP_ACK_FLAG | RTE_TCP_PSH_FLAG))) > return -1; > > hdr_len = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len + > -- > 2.25.1 > > --000000000000eba9f105e4af96d1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Jul 26, 2022 at 11:48 AM Jun = Qiu <jun.qiu@jaguarmicro.com<= /a>> wrote:
T= CP data packets sometimes carry a PUSH flag. Currently,
only the packets that do not have PUSH flag can be GROed.
The packets that have a PUSH flag cannot be GROed, the packets
that cannot be processed by GRO are placed last.
In this case, the received packets may be out of order.
For example, there are two packets mbuf1 and mbuf2. mbuf1
contains PUSH flag, mbuf2 does not contain PUSH flag.
After GRO processing, mbuf2 is sent for processing before mbuf1.
This out-of-order will affect TCP processing performance and
lead to unnecessary dup-ACK.

Referring to the Linux kernel implementation, packets with PUSH
flag can also perform GRO. And if one of the packets containing
PUSH flag, the packets after GRO will carry PUSH flag.



Fixes: 0d2cbe59b719 ("lib/gro: support TCP/IPv4")
Cc:
stable@dpdk.org

Signed-off-by: Jun Qiu <
jun.qiu@jaguarmicro.com>
---
=C2=A0lib/gro/gro_tcp4.c=C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 4 ++--
=C2=A0lib/gro/gro_tcp4.h=C2=A0 =C2=A0 =C2=A0 =C2=A0| 16 +++++++++++++--- =C2=A0lib/gro/gro_vxlan_tcp4.c |=C2=A0 4 ++--
=C2=A03 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c
index 7498c66141..7849a2bd1d 100644
--- a/lib/gro/gro_tcp4.c
+++ b/lib/gro/gro_tcp4.c
@@ -220,10 +220,10 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 hdr_len =3D pkt->l2_len + pkt->l3_len + p= kt->l4_len;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 /*
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Don't process the packet which has FIN, = SYN, RST, PSH, URG, ECE
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Don't process the packet which has FIN, = SYN, RST, URG, ECE
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* or CWR set.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (tcp_hdr->tcp_flags !=3D RTE_TCP_ACK_FLAG= )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (tcp_hdr->tcp_flags & (~(RTE_TCP_ACK_= FLAG | RTE_TCP_PSH_FLAG)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -1;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /*
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* Don't process the packet whose payl= oad length is less than or
diff --git a/lib/gro/gro_tcp4.h b/lib/gro/gro_tcp4.h
index 212f97a042..2974faf228 100644
--- a/lib/gro/gro_tcp4.h
+++ b/lib/gro/gro_tcp4.h
@@ -210,7 +210,8 @@ merge_two_tcp4_packets(struct gro_tcp4_item *item,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint16_t l2_offset)=
=C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 struct rte_mbuf *pkt_head, *pkt_tail, *lastseg;=
-=C2=A0 =C2=A0 =C2=A0 =C2=A0uint16_t hdr_len, l2_len;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct rte_tcp_hdr *head_tcp_hdr, *tail_tcp_hdr= ;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0uint16_t hdr_len, l2_len, l3_offset;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (cmp > 0) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pkt_head =3D item-&= gt;firstseg;
@@ -221,13 +222,22 @@ merge_two_tcp4_packets(struct gro_tcp4_item *item, =C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* check if the IPv4 packet length is greater t= han the max value */
-=C2=A0 =C2=A0 =C2=A0 =C2=A0hdr_len =3D l2_offset + pkt_head->l2_len + p= kt_head->l3_len +
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pkt_head->l4_len= ;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0l3_offset =3D l2_offset + pkt_head->l2_len += pkt_head->l3_len;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0hdr_len =3D l3_offset + pkt_head->l4_len; =C2=A0 =C2=A0 =C2=A0 =C2=A0 l2_len =3D l2_offset > 0 ? pkt_head->oute= r_l2_len : pkt_head->l2_len;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (unlikely(pkt_head->pkt_len - l2_len + pk= t_tail->pkt_len -
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hdr_len > MAX_IPV4_PKT_LENGTH)) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;

+=C2=A0 =C2=A0 =C2=A0 =C2=A0/* merge push flag to pkt_head */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0tail_tcp_hdr =3D rte_pktmbuf_mtod_offset(pkt_ta= il,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct rte_tcp_hdr *, l3_offset);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (tail_tcp_hdr->tcp_flags & RTE_TCP_PS= H_FLAG) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0head_tcp_hdr =3D rt= e_pktmbuf_mtod_offset(pkt_head,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct rt= e_tcp_hdr *, l3_offset);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0head_tcp_hdr->tc= p_flags |=3D RTE_TCP_PSH_FLAG;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* remove the packet header for the tail packet= */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 rte_pktmbuf_adj(pkt_tail, hdr_len);

diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c
index 3be4deb7c7..884802af0b 100644
--- a/lib/gro/gro_vxlan_tcp4.c
+++ b/lib/gro/gro_vxlan_tcp4.c
@@ -326,10 +326,10 @@ gro_vxlan_tcp4_reassemble(struct rte_mbuf *pkt,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 tcp_hdr =3D (struct rte_tcp_hdr *)((char *)ipv4= _hdr + pkt->l3_len);

=C2=A0 =C2=A0 =C2=A0 =C2=A0 /*
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Don't process the packet which has FIN, = SYN, RST, PSH, URG,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Don't process the packet which has FIN, = SYN, RST, URG,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* ECE or CWR set.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (tcp_hdr->tcp_flags !=3D RTE_TCP_ACK_FLAG= )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (tcp_hdr->tcp_flags & (~(RTE_TCP_ACK_= FLAG | RTE_TCP_PSH_FLAG)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -1;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 hdr_len =3D pkt->outer_l2_len + pkt->oute= r_l3_len + pkt->l2_len +
--
2.25.1

--000000000000eba9f105e4af96d1--