From patchwork Mon Jan 3 15:08:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 105578 X-Patchwork-Delegate: thomas@monjalon.net 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 D86DEA04A3; Mon, 3 Jan 2022 16:08:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8DEFB4114A; Mon, 3 Jan 2022 16:08:48 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 4EB4741140 for ; Mon, 3 Jan 2022 16:08:46 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 203CYssE024887; Mon, 3 Jan 2022 07:08:44 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=mKGWMUszaF/3HqAKOR01CZWPOBfRBsNVTwEfZRNEXW0=; b=E+SEbs6us45ufBb4SUesjKOKPPdq7+Nq+QphIcW0F6UPswZDjq6VHVVhBXzf+CVYODrC 1lV6e/Ot4uLId4peBxL49Pn0HLpihTVn6iYtzNkz4rSlKSU7XdpnsUCxiE0ooeXL3pZk sscZvYv4qAK0ZQVIR6E5RQqqukt6C/IJJzfbfF/V5iAn56Rem4ikkXeqVFgFsdHUudIE AjYUbIouxxCs3pVvq/Nkj4spIdfNeQhKMNESMnTDnPseV4C+2UtBadjbCIp3fZF9qdU6 djt1UKU7iZ44DKOeAH5110rrlI1n4+oTX5wI/ayYbbM4laBYekiDqNfF5ymT5ylS8kJb WA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3dbmvswf9c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 03 Jan 2022 07:08:44 -0800 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, 3 Jan 2022 07:08:43 -0800 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, 3 Jan 2022 07:08:43 -0800 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id A6CD13F70A9; Mon, 3 Jan 2022 07:08:39 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , , , Akhil Goyal Subject: [PATCH 3/8] ethdev: add mbuf dynfield for incomplete IP reassembly Date: Mon, 3 Jan 2022 20:38:08 +0530 Message-ID: <20220103150813.1694888-4-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220103150813.1694888-1-gakhil@marvell.com> References: <20210823100259.1619886-1-gakhil@marvell.com> <20220103150813.1694888-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: zrpnrIphG8LezQAY7D3EiedDNxx590ES X-Proofpoint-GUID: zrpnrIphG8LezQAY7D3EiedDNxx590ES X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-03_06,2022-01-01_01,2021-12-02_01 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 Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf ol_flag (RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE) is added to show that the mbuf received is not reassembled properly. Now if this flag is set, application can retreive corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be upto application to either drop those fragments or wait for more time. Signed-off-by: Akhil Goyal --- lib/ethdev/ethdev_driver.h | 8 ++++++ lib/ethdev/rte_ethdev.c | 16 +++++++++++ lib/ethdev/rte_ethdev.h | 57 ++++++++++++++++++++++++++++++++++++++ lib/ethdev/version.map | 2 ++ lib/mbuf/rte_mbuf_core.h | 3 +- 5 files changed, 85 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 0ed53c14f3..9a0bab9a61 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -1671,6 +1671,14 @@ int rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue, uint32_t direction); +/** + * @internal + * Register mbuf dynamic field for IP reassembly incomplete case. + */ +__rte_internal +int +rte_eth_ip_reass_dynfield_register(void); + /* * Legacy ethdev API used internally by drivers. diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index ecc6c1fe37..d53ce4eaca 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6503,6 +6503,22 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id, (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf)); } +#define RTE_ETH_IP_REASS_DYNFIELD_NAME "rte_eth_ip_reass_dynfield" +int rte_eth_ip_reass_dynfield_offset = -1; + +int +rte_eth_ip_reass_dynfield_register(void) +{ + static const struct rte_mbuf_dynfield dynfield_desc = { + .name = RTE_ETH_IP_REASS_DYNFIELD_NAME, + .size = sizeof(rte_eth_ip_reass_dynfield_t), + .align = __alignof__(rte_eth_ip_reass_dynfield_t), + }; + rte_eth_ip_reass_dynfield_offset = + rte_mbuf_dynfield_register(&dynfield_desc); + return rte_eth_ip_reass_dynfield_offset; +} + RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); RTE_INIT(ethdev_init_telemetry) diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 891f9a6e06..c4024d2265 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -5245,6 +5245,63 @@ __rte_experimental int rte_eth_ip_reassembly_conf_set(uint16_t port_id, struct rte_eth_ip_reass_params *conf); +/** + * In case of IP reassembly offload failure, ol_flags in mbuf will be set + * with RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE and packets will be returned + * without alteration. The application can retrieve the attached fragments + * using mbuf dynamic field. + */ +typedef struct { + /** + * Next fragment packet. Application should fetch dynamic field of + * each fragment until a NULL is received and nb_frags is 0. + */ + struct rte_mbuf *next_frag; + /** Time spent(in ms) by HW in waiting for further fragments. */ + uint16_t time_spent; + /** Number of more fragments attached in mbuf dynamic fields. */ + uint16_t nb_frags; +} rte_eth_ip_reass_dynfield_t; + +extern int rte_eth_ip_reass_dynfield_offset; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get pointer to mbuf dynamic field for getting incomplete + * reassembled fragments. + * + * For performance reason, no check is done, + * the dynamic field may not be registered. + * @see rte_eth_ip_reass_dynfield_is_registered + * + * @param mbuf packet to access + * @return pointer to mbuf dynamic field + */ +__rte_experimental +static inline rte_eth_ip_reass_dynfield_t * +rte_eth_ip_reass_dynfield(struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, + rte_eth_ip_reass_dynfield_offset, + rte_eth_ip_reass_dynfield_t *); +} + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Check whether the dynamic field is registered. + * + * @return true if rte_eth_ip_reass_dynfield_register() has been called. + */ +__rte_experimental +static inline bool rte_eth_ip_reass_dynfield_is_registered(void) +{ + return rte_eth_ip_reass_dynfield_offset >= 0; +} + #include diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index f08fe72044..e824b776b1 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -259,6 +259,7 @@ EXPERIMENTAL { #added in 22.03 rte_eth_ip_reassembly_conf_set; + rte_eth_ip_reass_dynfield_offset; }; INTERNAL { @@ -282,6 +283,7 @@ INTERNAL { rte_eth_hairpin_queue_peer_bind; rte_eth_hairpin_queue_peer_unbind; rte_eth_hairpin_queue_peer_update; + rte_eth_ip_reass_dynfield_register; rte_eth_representor_id_get; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h index 321a419c71..2cd1f95ae4 100644 --- a/lib/mbuf/rte_mbuf_core.h +++ b/lib/mbuf/rte_mbuf_core.h @@ -233,10 +233,11 @@ extern "C" { #define PKT_RX_OUTER_L4_CKSUM_INVALID \ RTE_DEPRECATED(PKT_RX_OUTER_L4_CKSUM_INVALID) \ RTE_MBUF_F_RX_OUTER_L4_CKSUM_INVALID +#define RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE (1ULL << 23) /* add new RX flags here, don't forget to update RTE_MBUF_F_FIRST_FREE */ -#define RTE_MBUF_F_FIRST_FREE (1ULL << 23) +#define RTE_MBUF_F_FIRST_FREE (1ULL << 24) #define PKT_FIRST_FREE RTE_DEPRECATED(PKT_FIRST_FREE) RTE_MBUF_F_FIRST_FREE #define RTE_MBUF_F_LAST_FREE (1ULL << 40) #define PKT_LAST_FREE RTE_DEPRECATED(PKT_LAST_FREE) RTE_MBUF_F_LAST_FREE