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 AFEB4A0350; Tue, 8 Feb 2022 21:11:37 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2E9141163; Tue, 8 Feb 2022 21:11:33 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id AA2DC41163 for ; Tue, 8 Feb 2022 21:11:32 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 218FEjPx017588; Tue, 8 Feb 2022 12:11:29 -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=H9bX4cBx+wJnn6Hw/7XMMDHqrctb0julNSRuHdnCDNY=; b=OkJonmK987/1mDxRgNzH0UY/eiraGcIsk5LtmB2G37WKkFxQmmFvEQPoeKExZHeAK/KK dS9c/LNExPXwh5jby9cGduFniVa0yOMWsRK6y1llWRrzs7r/XWcrUITo9zeJJD9zZFYy yZRsvJYlD8MAUHxSUKKrY3YOFc6G5hU7L7aKZ8W/wl1L2Mx2NvBue04y4wGtqXGlv7n5 Cs1TvGuofu4n/7+RtZNYzbVo3Km/4KYljqL7Fu3mQn7LgEHGLWovjBT6lcHMD2/ZDrn0 fUajj1AfYHXYuf3deNWXVFr5f4T2GRvup9WTEHRwr4+wYFuCtyOTMrvD9ATD+YQ964bF SA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3e3nuy2kfj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 12:11:29 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Feb 2022 12:11:27 -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; Tue, 8 Feb 2022 12:11:27 -0800 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id 650E63F7099; Tue, 8 Feb 2022 12:11:23 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , , , , , Akhil Goyal Subject: [PATCH v5 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly Date: Wed, 9 Feb 2022 01:41:10 +0530 Message-ID: <20220208201111.420971-3-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208201111.420971-1-gakhil@marvell.com> References: <20220204221334.3551574-1-gakhil@marvell.com> <20220208201111.420971-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 5F9voS8LcMeTuiX9g_TZOHUXUw6-yKqy X-Proofpoint-ORIG-GUID: 5F9voS8LcMeTuiX9g_TZOHUXUw6-yKqy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_06,2022-02-07_02,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 dynflag is added to show that the mbuf received is not reassembled properly. Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to 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 | 28 ++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++- lib/ethdev/version.map | 1 + lib/mbuf/rte_mbuf_dyn.h | 9 +++++++++ 5 files changed, 73 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 4acf75781d..81be991191 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -1707,6 +1707,14 @@ int rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue, uint32_t direction); +/** + * @internal + * Register mbuf dynamic field and flag for IP reassembly incomplete case. + */ +__rte_internal +int +rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag); + /* * Legacy ethdev API used internally by drivers. diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 6b37cffd07..a707f395c4 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6570,6 +6570,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id, (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf)); } +int +rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag_offset) +{ + static const struct rte_mbuf_dynfield field_desc = { + .name = RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME, + .size = sizeof(rte_eth_ip_reassembly_dynfield_t), + .align = __alignof__(rte_eth_ip_reassembly_dynfield_t), + }; + static const struct rte_mbuf_dynflag ip_reassembly_dynflag = { + .name = RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME, + }; + int offset; + + offset = rte_mbuf_dynfield_register(&field_desc); + if (offset < 0) + return -1; + if (field_offset != NULL) + *field_offset = offset; + + offset = rte_mbuf_dynflag_register(&ip_reassembly_dynflag); + if (offset < 0) + return -1; + if (flag_offset != NULL) + *flag_offset = offset; + + return 0; +} + 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 dd416fda37..b2c41ceb9a 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -5285,6 +5285,12 @@ int rte_eth_ip_reassembly_conf_get(uint16_t port_id, * configuration. The use of this API is mandatory to enable this feature and * should be called before rte_eth_dev_start(). * + * In datapath, PMD cannot guarantee that IP reassembly is always successful. + * Hence, PMD shall register mbuf dynamic field and dynamic flag using + * rte_eth_ip_reassembly_dynfield_register() to denote incomplete IP reassembly. + * If dynfield is not successfully registered, error will be returned and + * IP reassembly offload cannnot be used. + * * @param port_id * The port identifier of the device. * @param conf @@ -5294,13 +5300,33 @@ int rte_eth_ip_reassembly_conf_get(uint16_t port_id, * - (-ENODEV) if *port_id* invalid. * - (-EIO) if device is removed. * - (-EINVAL) if device is not configured or if device is already started or - * if *conf* passed is NULL. + * if *conf* passed is NULL or if mbuf dynfield is not registered + * successfully by the PMD. * - (0) on success. */ __rte_experimental int rte_eth_ip_reassembly_conf_set(uint16_t port_id, const struct rte_eth_ip_reassembly_params *conf); +/** + * In case of IP reassembly offload failure, packet will be updated with + * dynamic flag - RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME and packets + * will be returned without alteration. + * The application can retrieve the attached fragments using mbuf dynamic field + * RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME. + */ +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_reassembly_dynfield_t; + #include diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index e22c102818..b5499cd9b5 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -284,6 +284,7 @@ INTERNAL { rte_eth_hairpin_queue_peer_bind; rte_eth_hairpin_queue_peer_unbind; rte_eth_hairpin_queue_peer_update; + rte_eth_ip_reassembly_dynfield_register; rte_eth_representor_id_get; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; diff --git a/lib/mbuf/rte_mbuf_dyn.h b/lib/mbuf/rte_mbuf_dyn.h index 29abe8da53..1c948e996e 100644 --- a/lib/mbuf/rte_mbuf_dyn.h +++ b/lib/mbuf/rte_mbuf_dyn.h @@ -320,6 +320,15 @@ int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag); */ int rte_mbuf_dyn_tx_timestamp_register(int *field_offset, uint64_t *tx_flag); +/** + * For the PMDs which support IP reassembly of packets, PMD will updated the + * packet with RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME to denote that + * IP reassembly is incomplete and application can retrieve the packets back + * using RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME. + */ +#define RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME "rte_dynfield_ip_reassembly" +#define RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME "rte_dynflag_ip_reassembly_incomplete" + #ifdef __cplusplus } #endif -- 2.25.1