From patchwork Mon Aug 23 10:02:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 97223 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5AC4EA0C56; Mon, 23 Aug 2021 12:03:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C552640687; Mon, 23 Aug 2021 12:03:10 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 9CD294014D for ; Mon, 23 Aug 2021 12:03:08 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17N4YSKF012617; Mon, 23 Aug 2021 03:03:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=cGHVcIWppkiUL6KQCgC48e/YdGwMrBJd/hQ5EdCugdY=; b=JlcasTOIMUHbOv88tCaTMGPuXe3AtNBlDkwEy25RQ1y0Ya5pVigUBpzRldHTWj+us6S5 1hc4NyfYIUIA/3d5uVLZ6rfv6cULBF7dK/v4yg00BN0706w6Ihe2Qtv0TBpVlpmTuv7I 218Yn9q/oas+aHFltPZfYJ5wl5WWAG0fXl1hHIego2XdEyGHegSoLXK1Ziqco2qHlWVH 12bu7NFv6yhummITN31LmzczqAqxMyQqzLc6981nc7PEE+rUjOQ8UUdUmGmb7esO7dZ9 CB0y1hZHwlN2d00Kyi8TQ6/yLyH9+4mWE2rGF0iveAiJ2Izj/Ir+d2p/yxF9zL2iIF40 oA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 3am4s0h02n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 23 Aug 2021 03:03:07 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 23 Aug 2021 03:03:06 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 23 Aug 2021 03:03:06 -0700 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id B15983F7044; Mon, 23 Aug 2021 03:03:02 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , Akhil Goyal Date: Mon, 23 Aug 2021 15:32:59 +0530 Message-ID: <20210823100259.1619886-1-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-GUID: ztQtmJKbiLSNEeJLAJzV---ZguszLVjn X-Proofpoint-ORIG-GUID: ztQtmJKbiLSNEeJLAJzV---ZguszLVjn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-08-23_02,2021-08-23_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH] RFC: ethdev: add reassembly offload 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 Sender: "dev" Reassembly is a costly operation if it is done in software, however, if it is offloaded to HW, it can considerably save application cycles. The operation becomes even more costlier if IP fragmants are encrypted. To resolve above two issues, a new offload DEV_RX_OFFLOAD_REASSEMBLY is introduced in ethdev for devices which can attempt reassembly of packets in hardware. rte_eth_dev_info is added with the reassembly capabilities which a device can support. Now, if IP fragments are encrypted, reassembly can also be attempted while doing inline IPsec processing. This is controlled by a flag in rte_security_ipsec_sa_options to enable reassembly of encrypted IP fragments in the inline path. The resulting reassembled packet would be a typical segmented mbuf in case of success. And if reassembly of fragments is failed or is incomplete (if fragments do not come before the reass_timeout), the mbuf is updated with an ol_flag PKT_RX_REASSEMBLY_INCOMPLETE and mbuf is returned as is. Now application may decide the fate of the packet to wait more for fragments to come or drop. Signed-off-by: Akhil Goyal --- lib/ethdev/rte_ethdev.c | 1 + lib/ethdev/rte_ethdev.h | 18 +++++++++++++++++- lib/mbuf/rte_mbuf_core.h | 3 ++- lib/security/rte_security.h | 10 ++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 9d95cd11e1..1ab3a093cf 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -119,6 +119,7 @@ static const struct { RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER), RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND), RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME), + RTE_RX_OFFLOAD_BIT2STR(REASSEMBLY), RTE_RX_OFFLOAD_BIT2STR(SCATTER), RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP), RTE_RX_OFFLOAD_BIT2STR(SECURITY), diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index d2b27c351f..e89a4dc1eb 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -1360,6 +1360,7 @@ struct rte_eth_conf { #define DEV_RX_OFFLOAD_VLAN_FILTER 0x00000200 #define DEV_RX_OFFLOAD_VLAN_EXTEND 0x00000400 #define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800 +#define DEV_RX_OFFLOAD_REASSEMBLY 0x00001000 #define DEV_RX_OFFLOAD_SCATTER 0x00002000 /** * Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME @@ -1477,6 +1478,20 @@ struct rte_eth_dev_portconf { */ #define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID (UINT16_MAX) +/** + * Reassembly capabilities that a device can support. + * The device which can support reassembly offload should set + * DEV_RX_OFFLOAD_REASSEMBLY + */ +struct rte_eth_reass_capa { + /** Maximum time in ns that a fragment can wait for further fragments */ + uint64_t reass_timeout; + /** Maximum number of fragments that device can reassemble */ + uint16_t max_frags; + /** Reserved for future capabilities */ + uint16_t reserved[3]; +}; + /** * Ethernet device associated switch information */ @@ -1582,8 +1597,9 @@ struct rte_eth_dev_info { * embedded managed interconnect/switch. */ struct rte_eth_switch_info switch_info; + /* Reassembly capabilities of a device for reassembly offload */ + struct rte_eth_reass_capa reass_capa; - uint64_t reserved_64s[2]; /**< Reserved for future fields */ void *reserved_ptrs[2]; /**< Reserved for future fields */ }; diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h index bb38d7f581..cea25c87f7 100644 --- a/lib/mbuf/rte_mbuf_core.h +++ b/lib/mbuf/rte_mbuf_core.h @@ -200,10 +200,11 @@ extern "C" { #define PKT_RX_OUTER_L4_CKSUM_BAD (1ULL << 21) #define PKT_RX_OUTER_L4_CKSUM_GOOD (1ULL << 22) #define PKT_RX_OUTER_L4_CKSUM_INVALID ((1ULL << 21) | (1ULL << 22)) +#define PKT_RX_REASSEMBLY_INCOMPLETE (1ULL << 23) /* add new RX flags here, don't forget to update PKT_FIRST_FREE */ -#define PKT_FIRST_FREE (1ULL << 23) +#define PKT_FIRST_FREE (1ULL << 24) #define PKT_LAST_FREE (1ULL << 40) /* add new TX flags here, don't forget to update PKT_LAST_FREE */ diff --git a/lib/security/rte_security.h b/lib/security/rte_security.h index 88d31de0a6..364eeb5cd4 100644 --- a/lib/security/rte_security.h +++ b/lib/security/rte_security.h @@ -181,6 +181,16 @@ struct rte_security_ipsec_sa_options { * * 0: Disable per session security statistics collection for this SA. */ uint32_t stats : 1; + + /** Enable reassembly on incoming packets. + * + * * 1: Enable driver to try reassembly of encrypted IP packets for + * this SA, if supported by the driver. This feature will work + * only if rx_offload DEV_RX_OFFLOAD_REASSEMBLY is set in + * inline ethernet device. + * * 0: Disable reassembly of packets (default). + */ + uint32_t reass_en : 1; }; /** IPSec security association direction */