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 544A642C3A; Tue, 6 Jun 2023 06:35:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D7AD940A84; Tue, 6 Jun 2023 06:35:38 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 3B97A406B7 for ; Tue, 6 Jun 2023 06:35:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686026137; x=1717562137; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=IR6SMDYxoxBgHsjNd59VBYeQjKqCC15IBatQ6Kao3ps=; b=WS6r46crLSuZwM6n5OpykCkaWQiA8lTo7b2PuNVTQDs5eJq3LWnKY4WS tM8CI4pZkjheXxYXcFAn4MP1IlTnSNb6R2Uy/khspAisP5hQreXgOQMyg 4X0PCNqJosLPwxkRMJQTKSeOZ7IJeuK8G60U/bdROEgEw8UgILxqkQAvK m7aMmTb0E1WMzY+5WYr/AHq3Dors7pcUd1Wg0jwuIy/JmpQby+aO+elx3 cnioKM+ZJBQMUwC4OOh+MJ6hw41UsrJgddzAUwY4eMq2c0LdGDe++WlYK 8pcrODfLw/ViEQsY48ZX7ntaDflwg6mR4Xo/J+mEw3OFBaXWUf2A/HY7U Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10732"; a="359874751" X-IronPort-AV: E=Sophos;i="6.00,219,1681196400"; d="scan'208";a="359874751" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2023 21:35:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10732"; a="778831324" X-IronPort-AV: E=Sophos;i="6.00,219,1681196400"; d="scan'208";a="778831324" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga004.fm.intel.com with ESMTP; 05 Jun 2023 21:35:35 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 5 Jun 2023 21:35:35 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Mon, 5 Jun 2023 21:35:35 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Mon, 5 Jun 2023 21:35:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SxcF2EWL3fYfVZ4HJ//BDxA7EXISRIoV391wab7qMFKA1uerteUIzeFEW3NQC9nolZRDiDwfXcHxi9t/L8VIsNAyVAcQUWLlUXx41BBW/cUsKESO30mUUGLelxoszlCc2I/WRdcOj9hDoetEfsiHIhN+8FZIIrKq4eNah1E302cu+m9/VlcT19we4FkViUJR0TGBt9pOR70Qd5RYdV3ZuEUTr3H2Y7RxvjRZhNRkwggT131Gw1tPfKmv2h43ey089aj3z57qg92pvGx5oTPcV+hJOhCQQOq0G/t2R2jx+WQ46TetOJLDsAgHUrGSE3TcmzIJHgC2xlq9sii+hFEoTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TQCmHFtUyYxM+LBV9fdlJIExb77E7+k3BhB7TXyc5Fk=; b=gbjfndVqKi1hgfooceUSooVun4mwrO2GIUMCvAX3VUqj62CoPN3yU26rIBpC5KE3JJILR21wnX4wPxvE/v5Xg2TThQoBrdJu9N6itzuOqYZHaXYIO4OZ7t/WyP+S+bSMeCDmLRw2t2qbd1DATqjyEfPnFT/wnAj/YpKid6f66t9cOeUXEtBaMHNSGCMSc88ThvDAwXJLCYa68KXSvljUc+nAdfc+kmSqgmzKvdh73+ljTseGozh4oWuTeeX7U5ASNbepX4U7xzZgh7EreSbfp8sUo2XkoHD4dsjRvBJeYsCk2RYQ79uAD3wD+VqJSa8KPxvScPqLUSbC8fP+IeWimw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from CY5PR11MB6487.namprd11.prod.outlook.com (2603:10b6:930:31::17) by PH7PR11MB6032.namprd11.prod.outlook.com (2603:10b6:510:1d3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 04:35:32 +0000 Received: from CY5PR11MB6487.namprd11.prod.outlook.com ([fe80::bde0:dbff:51b5:4025]) by CY5PR11MB6487.namprd11.prod.outlook.com ([fe80::bde0:dbff:51b5:4025%4]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 04:35:31 +0000 From: "Hu, Jiayu" To: Kumara Parameshwaran CC: "dev@dpdk.org" Subject: RE: [PATCH v3] gro : ipv6 changes to support GRO for TCP/ipv6 Thread-Topic: [PATCH v3] gro : ipv6 changes to support GRO for TCP/ipv6 Thread-Index: AQHZlRxQGVA16G3GkE2NUx4szpRgCK99KZsw Date: Tue, 6 Jun 2023 04:35:31 +0000 Message-ID: References: <20221020181425.48006-1-kumaraparmesh92@gmail.com> <20230602063423.30312-1-kumaraparamesh92@gmail.com> In-Reply-To: <20230602063423.30312-1-kumaraparamesh92@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CY5PR11MB6487:EE_|PH7PR11MB6032:EE_ x-ms-office365-filtering-correlation-id: a5d7f9a0-0313-4175-94a6-08db66477643 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: p9qmtLHeI7jPhZGEJq2+CJBKcTqaZ5g74pb+0kuxzg9cHY7ZJFL/FvL3UIV3YNI2OCrQyw4b8inxYbF10h1VA1Fy9Bj1mv2B3htPlVyu/fSlQ1s4y9529ZXMWUks5lY+0J64OBgYUCg+mI6497/wmlnsnlmFoNErCZL7BHtzveKF0sbYH8zz/lYr19VjgVQ5emHruJZtIrlnP7yrD2wWjgKL3B9vDHu1esMvg+N+mtZZrPdjjjSBokxGg0CaoWwgRPbAFiEfrGtr1GSywx7iE3/6xQJqBgu0qIwFFinPS8mcvUgjJNs670Vkm5Se+F9uxpvK0oNQqs3Vcy/yXHUEDHWUwQLj0C+i2FNKxEta4aQgCMCEF8ez9VP/cRbU8GLZRmKfMGAgRq5gBDH8fd8DuMwQJdmxm5ammo7p5KSRFIRjMLqbBPzAaGgdryFhMGzIWhAk6rdI6xmJXuklnzTS3f0iZPz9pD3xkC7NnDlbjBiAsKFnrWyD9AR9X/9ZsUpNfGigmuedj504fY36NiToIfjQNAKIBl0U/aV944tQYB5RHidNLvk1y6kjPk3R4OAxCGLw1GStUvIFhA/gKaGzwBe7a+Y0yu59//ApaP8tWE9mb6mDF5rJjv2F8ssdTXu1 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY5PR11MB6487.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(366004)(376002)(346002)(396003)(136003)(451199021)(6506007)(26005)(53546011)(9686003)(83380400001)(122000001)(33656002)(38070700005)(86362001)(38100700002)(82960400001)(186003)(55016003)(5660300002)(52536014)(2906002)(478600001)(316002)(41300700001)(76116006)(66946007)(64756008)(66446008)(6916009)(4326008)(66476007)(66556008)(8936002)(8676002)(71200400001)(7696005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?DLubBpLG4fBexxcp4hwYFp9rHznbe36ZziLxrInGdd/ohjzTOz+4fbTzaDIQ?= =?us-ascii?Q?fE8IgiIM4RZzgjZ1uGUpfMp3o+/uW7NVop7i/oF0Jia6LwUvi6NCAclXDQ+n?= =?us-ascii?Q?cAeO3p5j0BeNJaJSTIxWWZJroBhhmtuCj+K8nnmBEkQ0Ht/W2JRhDiRM/+Wj?= =?us-ascii?Q?2CF2IA69Q57W+4FT2WXU1HC2sySwJQd53BRCvZnOtWJBgrvQx1MJ/RnQ3Kdz?= =?us-ascii?Q?RgqLBq+dz0LbcyzFhCYaJLOsxRIe8o92ka2ycTdv8czJlKhaHaQBDjHgIUb6?= =?us-ascii?Q?rM6oIidhSoR/UHsrblsbBYHjPkey8Y+MMMu+bh8B/TnF22Kf/Tptjt43wqzr?= =?us-ascii?Q?zYPBF+bdO8xWubs+Hv7yyvjNBnbXq/wal04YhhjxxemBhOXXP/+xzDqSCBgT?= =?us-ascii?Q?3XZgQ5zwkXDauJopUabVcLHd11GWOLlSiMNhb8ioYROUkU2zjjLGi2DLlAsF?= =?us-ascii?Q?I/zcxafC2Drhezzke5MW+DWRfdv1P8eFm5krquDDLq7bHyPdIfPysKMB+TFt?= =?us-ascii?Q?BXOA0qfmw0B4LaVcTa+1oKUPvfB02K7O5E6UTY9LTphmm1Hqp+dRyY8eLGoU?= =?us-ascii?Q?q1hycUn6zmXsX4wCMdr7W19FxIBIx6du4WsVTiwP5PtQZJhuGeNbVZROGDYv?= =?us-ascii?Q?+LVHxAdk0ijuMixsGZ9CldbqyfpdU/7+U85NVCZhcMPXOjUuMua9UsyywJdd?= =?us-ascii?Q?492bmkQTIqPIubW8j4QcEk6PcwQHpFayiO9eHWUAKmKVz5tXYdTA6zZrED72?= =?us-ascii?Q?9UDPnH+hRqpmtCmpfyPwppyxeTfl2cBanoRsfLhVLjgGfX9QhEafi4f48ndo?= =?us-ascii?Q?8AWSwml9UU9xFJ8F18g21Kh/RoikybIN+G+RlFIUY7DabIMxvRtNQ+SPXdrM?= =?us-ascii?Q?CU6Q0d5Pf6xonyL8OPXJQxw/7JTDwIJwJ/qrxq9X7trdvBuRWRHaN4E/sNsx?= =?us-ascii?Q?+urLhcy/gzEyNPDsB7/xXmiOg/bHZjcvcdXwxRVEYBWAZAj8fTftt/4pjrcG?= =?us-ascii?Q?97Q9Kyg4MEUqkQQsedMctQkKD/xjr4oSiQ61Cs0MbESxlWinXfNLBMUHIjbL?= =?us-ascii?Q?fvyeyjF3UWRO5HYMoIpgap/FiQU9vzLl4yJjbSjMx8F3Z5iEj31au3DWP6Ho?= =?us-ascii?Q?WRntbF16iniUKGmC5RHrLwdCoaPj9z5RPDPKBcrpOLSUGmk3bA5vDSPzpD1h?= =?us-ascii?Q?C04q2FGVjvlO+A44E/MzkO3YYVoGU6HvMI7JU7gO7202W9gVukgwHBU1S+Zk?= =?us-ascii?Q?6sRPRZifASgnStUKwqg+WKT4HIz5F/MlnvaYVYfaGtoXH/qpizrwjLVdYByr?= =?us-ascii?Q?glkrLGKZ4ozWn8mW8L4yxNC+zTCSlf4jPhT+qPyOh33gj7VANH61bidqD5/d?= =?us-ascii?Q?+D85CgfGbfN1qCZpSWdmr9vafS29Kl3v+x61RkJn6oVEBunlhoL+9q/PZ977?= =?us-ascii?Q?QBiRrMFt2zWpX8E6A0pxgaSg7NH900q7LY3vZffn93Vsp8SJtGLo3GFa0wlc?= =?us-ascii?Q?NBJrJJTXE2d/gqPhbFstSYHoi1wFwebnyoM2GubtzJ4IZE5eTZI8SD9BSBBL?= =?us-ascii?Q?us0HPWaTtL5RGseZ8hLU1LN+iJt9el5SfAVRqvih?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY5PR11MB6487.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5d7f9a0-0313-4175-94a6-08db66477643 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2023 04:35:31.5605 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zYqsRJDoWwZmxElRTg8ryDYHPxZQGww89iyWquYWyBXQwF9E7MgGB9R/PXtdQd+RO5mWcxVug6TIeYXrpvfpew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6032 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Kumara, The v3 patch is not complete and it seems to be a patch based on v2. In addition, did you test the code for tcp4 and tcp6 after your change? For others, please see replies inline. Thanks, Jiayu > -----Original Message----- > From: Kumara Parameshwaran > Sent: Friday, June 2, 2023 2:34 PM > To: Hu, Jiayu > Cc: dev@dpdk.org; Kumara Parameshwaran > > Subject: [PATCH v3] gro : ipv6 changes to support GRO for TCP/ipv6 >=20 > The patch adds GRO support for TCP/ipv6 packets. This does not include th= e > support for vxlan, udp ipv6 packets. >=20 > Signed-off-by: Kumara Parameshwaran > --- > v1: > * Changes to support GRO for TCP/ipv6 packets. This does not > include > vxlan changes. > * The GRO is performed only for ipv6 packets that does not contain > extension headers. > * The logic for the TCP coalescing remains the same, in ipv6 header > the source address, destination address, flow label, version fields > are expected to be the same. > * Re-organised the code to reuse certain tcp functions for both ipv4 > and > ipv6 flows. > v2: > * Fix comments in gro_tcp6.h header file. >=20 > v3: > * Adderess review comments to fix code duplication for v4 and v6 >=20 > lib/gro/gro_tcp.c | 160 ++++++++++++++++++++++++ > lib/gro/gro_tcp.h | 63 ++++++++++ > lib/gro/gro_tcp4.c | 255 ++++++++++++--------------------------- > lib/gro/gro_tcp4.h | 18 +-- > lib/gro/gro_tcp6.c | 243 ++++++++++--------------------------- > lib/gro/gro_tcp6.h | 31 +++-- > lib/gro/gro_vxlan_tcp4.c | 18 +-- > lib/gro/meson.build | 1 + > 8 files changed, 396 insertions(+), 393 deletions(-) create mode 100644 > lib/gro/gro_tcp.c >=20 > diff --git a/lib/gro/gro_tcp.c b/lib/gro/gro_tcp.c new file mode 100644 i= ndex > 0000000000..6a5aaada58 > --- /dev/null > +++ b/lib/gro/gro_tcp.c > @@ -0,0 +1,160 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2017 Intel Corporation > + */ > +#include > +#include > +#include > + > +#include "gro_tcp.h" > + > +static inline uint32_t > +find_an_empty_item(struct gro_tcp_item *items, > + uint32_t table_size) > +{ > + uint32_t i; > + > + for (i =3D 0; i < table_size; i++) > + if (items[i].firstseg =3D=3D NULL) > + return i; > + return INVALID_ARRAY_INDEX; > +} > + > +uint32_t > +insert_new_tcp_item(struct rte_mbuf *pkt, > + struct gro_tcp_item *items, > + uint32_t *item_num, > + uint32_t table_size, > + uint64_t start_time, > + uint32_t prev_idx, > + uint32_t sent_seq, > + uint16_t ip_id, > + uint8_t is_atomic) > +{ > + uint32_t item_idx; > + > + item_idx =3D find_an_empty_item(items, table_size); > + if (item_idx =3D=3D INVALID_ARRAY_INDEX) > + return INVALID_ARRAY_INDEX; > + > + items[item_idx].firstseg =3D pkt; > + items[item_idx].lastseg =3D rte_pktmbuf_lastseg(pkt); > + items[item_idx].start_time =3D start_time; > + items[item_idx].next_pkt_idx =3D INVALID_ARRAY_INDEX; > + items[item_idx].sent_seq =3D sent_seq; > + items[item_idx].ip_id =3D ip_id; > + items[item_idx].nb_merged =3D 1; > + items[item_idx].is_atomic =3D is_atomic; > + (*item_num) +=3D 1; > + > + /* if the previous packet exists, chain them together. */ > + if (prev_idx !=3D INVALID_ARRAY_INDEX) { > + items[item_idx].next_pkt_idx =3D > + items[prev_idx].next_pkt_idx; > + items[prev_idx].next_pkt_idx =3D item_idx; > + } > + > + return item_idx; > +} > + > +uint32_t > +delete_tcp_item(struct gro_tcp_item *items, uint32_t item_idx, > + uint32_t *item_num, > + uint32_t prev_item_idx) > +{ > + uint32_t next_idx =3D items[item_idx].next_pkt_idx; > + > + /* NULL indicates an empty item */ > + items[item_idx].firstseg =3D NULL; > + (*item_num) -=3D 1; > + if (prev_item_idx !=3D INVALID_ARRAY_INDEX) > + items[prev_item_idx].next_pkt_idx =3D next_idx; > + > + return next_idx; > +} > + > +int32_t > +gro_tcp_reassemble(struct rte_mbuf *pkt, > + void *tbl, > + void *key, > + int32_t tcp_dl, > + struct gro_tcp_flow_ops *ops, > + struct gro_tcp_item *items, > + uint32_t *item_num, > + uint32_t table_size, > + uint16_t ip_id, > + uint8_t is_atomic, > + uint64_t start_time) In general, TCP4 and TCP6 share struct gro_tcp_item and have private flow s= tructures, i.e., struct gro_tcp4/6_flow, and I like this abstraction. IMO, the code pr= ocessing struct gro_tcp_item should be implemented as common functions shared by gro_tcp4.c and gro_tcp6.c. The code processing struct gro_tcp4/6_flow is tc= p4 and tcp6 dependent and no need to abstract and share. In gro_tcp_reassemble(), it uses callback functions defined in struct gro_t= cp_flow_ops to provide the different operations on struct gro_tcp4/6_flow. I don't thin= k it's necessary for abstraction purpose as gro_tcp4/6_flows_ops implementations are alike a= nd it also introduces extra cost on function calls. The gro_tcp_reassemble() has two parts: the common part to process struct g= ro_tcp_item and the private part to process struct gro_tcp4/6_flow. I think a better wa= y is to remove gro_tcp_reassemble() and struct gro_tcp_flow_ops, and implement the common = part as an internal function in gro_tcp.c/gro_tcp.h, and make both gro_tcp4/6_reass= emble() implement own private part and invoke the common function to process struct= gro_tcp_item. With this change, there is no callback cost anymore and tcp4/6 can share th= e common function. > +{ > + uint32_t item_idx; > + uint32_t cur_idx; > + uint32_t prev_idx; > + struct rte_tcp_hdr *tcp_hdr; > + int cmp; > + uint32_t sent_seq; > + > + tcp_hdr =3D rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, pkt- > >l2_len + pkt->l3_len); > + /* > + * Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE > + * or CWR set. > + */ > + if (tcp_hdr->tcp_flags !=3D RTE_TCP_ACK_FLAG) > + return -1; > + sent_seq =3D rte_be_to_cpu_32(tcp_hdr->sent_seq); > + > + ops->tcp_flow_key_init(key, tcp_hdr); > + > + item_idx =3D ops->tcp_flow_lookup(tbl, key); > + if (item_idx =3D=3D INVALID_ARRAY_INDEX) { > + item_idx =3D insert_new_tcp_item(pkt, items, item_num, > table_size, start_time, > + > INVALID_ARRAY_INDEX, sent_seq, ip_id, > + is_atomic); > + if (item_idx =3D=3D INVALID_ARRAY_INDEX) > + return -1; > + if (ops->tcp_flow_insert(tbl, key, item_idx) =3D=3D > + INVALID_ARRAY_INDEX) { > + /* > + * Fail to insert a new flow, so delete the > + * stored packet. > + */ > + delete_tcp_item(items, item_idx, item_num, > INVALID_ARRAY_INDEX); > + return -1; > + } > + return 0; > + } > + /* > + * Check all packets in the flow and try to find a neighbor for > + * the input packet. > + */ > + cur_idx =3D item_idx; > + prev_idx =3D cur_idx; > + do { > + cmp =3D check_seq_option(&items[cur_idx], tcp_hdr, > + sent_seq, ip_id, pkt->l4_len, tcp_dl, 0, > + is_atomic); > + if (cmp) { > + if (merge_two_tcp_packets(&items[cur_idx], > + pkt, cmp, sent_seq, ip_id, 0)) > + return 1; > + /* > + * Fail to merge the two packets, as the packet > + * length is greater than the max value. Store > + * the packet into the flow. > + */ > + if (insert_new_tcp_item(pkt, items, item_num, > table_size, start_time, cur_idx, > + sent_seq, ip_id, is_atomic) =3D=3D > + INVALID_ARRAY_INDEX) > + return -1; > + return 0; > + } > + prev_idx =3D cur_idx; > + cur_idx =3D items[cur_idx].next_pkt_idx; > + } while (cur_idx !=3D INVALID_ARRAY_INDEX); > + > + /* Fail to find a neighbor, so store the packet into the flow. */ > + if (insert_new_tcp_item(pkt, items, item_num, table_size, start_time, > prev_idx, sent_seq, > + ip_id, is_atomic) =3D=3D INVALID_ARRAY_INDEX) > + return -1; > + > + return 0; > + > +} > diff --git a/lib/gro/gro_tcp.h b/lib/gro/gro_tcp.h index > c5d248a022..202f485c18 100644 > --- a/lib/gro/gro_tcp.h > +++ b/lib/gro/gro_tcp.h > @@ -1,6 +1,8 @@ > #ifndef _GRO_TCP_H_ > #define _GRO_TCP_H_ >=20 > +#define INVALID_ARRAY_INDEX 0xffffffffUL > + > #include >=20 > /* > @@ -14,6 +16,31 @@ > #define INVALID_TCP_HDRLEN(len) \ > (((len) < sizeof(struct rte_tcp_hdr)) || ((len) > MAX_TCP_HLEN)) >=20 > +struct gro_tcp_flow { > + struct rte_ether_addr eth_saddr; > + struct rte_ether_addr eth_daddr; > + uint32_t recv_ack; > + uint16_t src_port; > + uint16_t dst_port; > +}; > + > +#define ASSIGN_TCP_FLOW_KEY(k1, k2) \ > + rte_ether_addr_copy(&(k1->eth_saddr), &(k2->eth_saddr)); \ > + rte_ether_addr_copy(&(k1->eth_daddr), &(k2->eth_daddr)); \ > + k2->recv_ack =3D k1->recv_ack; \ > + k2->src_port =3D k1->src_port; \ > + k2->dst_port =3D k1->dst_port; For multiline macro, it's better to use do{...}while(0) to avoid unexpected= errors in the future. > + > +typedef uint32_t (*gro_tcp_flow_lookup)(void *table, void *key); > +typedef uint32_t (*gro_tcp_flow_insert)(void *table, void *key, > +uint32_t item_idx); typedef void (*gro_tcp_flow_key_init)(void *key, > +struct rte_tcp_hdr *tcp_hdr); > + > +struct gro_tcp_flow_ops { > + gro_tcp_flow_lookup tcp_flow_lookup; > + gro_tcp_flow_insert tcp_flow_insert; > + gro_tcp_flow_key_init tcp_flow_key_init; }; > + > struct gro_tcp_item { > /* > * The first MBUF segment of the packet. If the value @@ -44,6 > +71,36 @@ struct gro_tcp_item { > uint8_t is_atomic; > }; >=20 > +uint32_t > +insert_new_tcp_item(struct rte_mbuf *pkt, > + struct gro_tcp_item *items, > + uint32_t *item_num, > + uint32_t table_size, > + uint64_t start_time, > + uint32_t prev_idx, > + uint32_t sent_seq, > + uint16_t ip_id, > + uint8_t is_atomic); > + > +uint32_t > +delete_tcp_item(struct gro_tcp_item *items, > + uint32_t item_idx, > + uint32_t *item_num, > + uint32_t prev_item_idx); > + > +int32_t > +gro_tcp_reassemble(struct rte_mbuf *pkt, > + void *tbl, > + void *key, > + int32_t tcp_dl, > + struct gro_tcp_flow_ops *ops, > + struct gro_tcp_item *items, > + uint32_t *item_num, > + uint32_t table_size, > + uint16_t ip_id, > + uint8_t is_atomic, > + uint64_t start_time); > + > /* > * Merge two TCP packets without updating checksums. > * If cmp is larger than 0, append the new packet to the @@ -152,4 +209,= 10 > @@ check_seq_option(struct gro_tcp_item *item, > return 0; > } >=20 > +static inline int > +is_same_tcp_flow(struct gro_tcp_flow *k1, struct gro_tcp_flow *k2) { > + return (!memcmp(k1, k2, sizeof(struct gro_tcp_flow))); } > + > #endif