From patchwork Tue Feb 8 22:20:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 107050 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 D200EA034F; Tue, 8 Feb 2022 23:23:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 51DCD4114F; Tue, 8 Feb 2022 23:23:27 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 991CF4114D for ; Tue, 8 Feb 2022 23:23:26 +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 218GEVPc010584; Tue, 8 Feb 2022 14:23:21 -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=FqzXIVPQ413PCGCG5fRWV6SaIMERUYpd3IicJVjcUag=; b=AnghiOp4A05O8pvYwCtzicRZtHqdcPBfC1o98mgqia4P8UNJZmSX/6ntg0YPjFXrzcc8 2D5PnJY0gOVkm5Q2DzlSJMa739fvi91RPjH6T/VZdem38FWoGLrW1wQaYFVGZ/zYudBY 6b0xNGEf/yCtQ/bWKh4iFIGUYf9GUixV0CvTobT75235D/ziFlO9M/eW471GjpXEhps6 ZFQ/DHBW1MxVxkFBFhVaI+twgqPqMM8Kxpo7PvFiaq7DvR5nNbEo1Yox/ZOiAb2j+xpG mmRfK/N8z1fn44JYA1z6OaP9/F/+wHPeTM+axmfUG5J/vUiGaGd1kg6Zanbz1HckVmVd BQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3e3mhskrd4-18 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 14:23:21 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Feb 2022 14:20:37 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Feb 2022 14:20:37 -0800 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id A83AE3F70A0; Tue, 8 Feb 2022 14:20:33 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , , , , , Akhil Goyal Subject: [PATCH v6 1/3] ethdev: introduce IP reassembly offload Date: Wed, 9 Feb 2022 03:50:25 +0530 Message-ID: <20220208222027.1364292-2-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208222027.1364292-1-gakhil@marvell.com> References: <20220208201111.420971-1-gakhil@marvell.com> <20220208222027.1364292-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: DSG6Yhedl3F0HWGLaiMcTES8dDWS1oqT X-Proofpoint-GUID: DSG6Yhedl3F0HWGLaiMcTES8dDWS1oqT 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_07,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 IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles. Hence, a new offload feature is exposed in eth_dev ops for devices which can attempt IP reassembly of packets in hardware. - rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set. - rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before rte_eth_dev_start()). - rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD. Now when the offload is enabled using rte_eth_ip_reassembly_conf_set(), the resulting reassembled IP packet would be a typical segmented mbuf in case of success. And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags can be updated by the PMD. This is updated in a subsequent patch. Signed-off-by: Akhil Goyal Reviewed-by: Ferruh Yigit --- doc/guides/nics/features.rst | 13 ++++ doc/guides/nics/features/default.ini | 1 + doc/guides/rel_notes/release_22_03.rst | 6 ++ lib/ethdev/ethdev_driver.h | 55 ++++++++++++++ lib/ethdev/rte_ethdev.c | 96 ++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 100 +++++++++++++++++++++++++ lib/ethdev/version.map | 5 ++ 7 files changed, 276 insertions(+) diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst index 27be2d2576..e6112e16f4 100644 --- a/doc/guides/nics/features.rst +++ b/doc/guides/nics/features.rst @@ -602,6 +602,19 @@ Supports inner packet L4 checksum. ``tx_offload_capa,tx_queue_offload_capa:RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM``. +.. _nic_features_ip_reassembly: + +IP reassembly +------------- + +Supports IP reassembly in hardware. + +* **[provides] eth_dev_ops**: ``ip_reassembly_capability_get``, + ``ip_reassembly_conf_get``, ``ip_reassembly_conf_set``. +* **[related] API**: ``rte_eth_ip_reassembly_capability_get()``, + ``rte_eth_ip_reassembly_conf_get()``, ``rte_eth_ip_reassembly_conf_set()``. + + .. _nic_features_shared_rx_queue: Shared Rx queue diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index c96a52b58e..22750dfacb 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -52,6 +52,7 @@ Timestamp offload = MACsec offload = Inner L3 checksum = Inner L4 checksum = +IP reassembly = Packet type parsing = Timesync = Rx descriptor status = diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index 746f50e84f..03ec8d6faa 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added IP reassembly Ethernet offload API, to get and set config.** + + Added IP reassembly offload APIs which provide functions to query IP + reassembly capabilities, to set configuration and to get currently set + reassembly configuration. + * **Updated Cisco enic driver.** * Added rte_flow support for matching GENEVE packets. diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index d95605a355..4acf75781d 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -990,6 +990,54 @@ typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev, typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev, uint64_t *features); +/** + * @internal + * Get IP reassembly offload capability of a PMD. + * + * @param dev + * Port (ethdev) handle + * + * @param[out] conf + * IP reassembly capability supported by the PMD + * + * @return + * Negative errno value on error, zero otherwise + */ +typedef int (*eth_ip_reassembly_capability_get_t)(struct rte_eth_dev *dev, + struct rte_eth_ip_reassembly_params *capa); + +/** + * @internal + * Get IP reassembly offload configuration parameters set in PMD. + * + * @param dev + * Port (ethdev) handle + * + * @param[out] conf + * Configuration parameters for IP reassembly. + * + * @return + * Negative errno value on error, zero otherwise + */ +typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev, + struct rte_eth_ip_reassembly_params *conf); + +/** + * @internal + * Set configuration parameters for enabling IP reassembly offload in hardware. + * + * @param dev + * Port (ethdev) handle + * + * @param[in] conf + * Configuration parameters for IP reassembly. + * + * @return + * Negative errno value on error, zero otherwise + */ +typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev, + const struct rte_eth_ip_reassembly_params *conf); + /** * @internal A structure containing the functions exported by an Ethernet driver. */ @@ -1186,6 +1234,13 @@ struct eth_dev_ops { * kinds of metadata to the PMD */ eth_rx_metadata_negotiate_t rx_metadata_negotiate; + + /** Get IP reassembly capability */ + eth_ip_reassembly_capability_get_t ip_reassembly_capability_get; + /** Get IP reassembly configuration */ + eth_ip_reassembly_conf_get_t ip_reassembly_conf_get; + /** Set IP reassembly configuration */ + eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; }; /** diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 29e21ad580..6b37cffd07 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6474,6 +6474,102 @@ rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) (*dev->dev_ops->rx_metadata_negotiate)(dev, features)); } +int +rte_eth_ip_reassembly_capability_get(uint16_t port_id, + struct rte_eth_ip_reassembly_params *reassembly_capa) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + if (dev->data->dev_configured == 0) { + RTE_ETHDEV_LOG(ERR, + "Device with port_id=%u is not configured.\n" + "Cannot get IP reassembly capability\n", + port_id); + return -EINVAL; + } + + if (reassembly_capa == NULL) { + RTE_ETHDEV_LOG(ERR, "Cannot get reassembly capability to NULL"); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->ip_reassembly_capability_get, + -ENOTSUP); + memset(reassembly_capa, 0, sizeof(struct rte_eth_ip_reassembly_params)); + + return eth_err(port_id, (*dev->dev_ops->ip_reassembly_capability_get) + (dev, reassembly_capa)); +} + +int +rte_eth_ip_reassembly_conf_get(uint16_t port_id, + struct rte_eth_ip_reassembly_params *conf) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + if (dev->data->dev_configured == 0) { + RTE_ETHDEV_LOG(ERR, + "Device with port_id=%u is not configured.\n" + "Cannot get IP reassembly configuration\n", + port_id); + return -EINVAL; + } + + if (conf == NULL) { + RTE_ETHDEV_LOG(ERR, "Cannot get reassembly info to NULL"); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->ip_reassembly_conf_get, + -ENOTSUP); + memset(conf, 0, sizeof(struct rte_eth_ip_reassembly_params)); + return eth_err(port_id, + (*dev->dev_ops->ip_reassembly_conf_get)(dev, conf)); +} + +int +rte_eth_ip_reassembly_conf_set(uint16_t port_id, + const struct rte_eth_ip_reassembly_params *conf) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + if (dev->data->dev_configured == 0) { + RTE_ETHDEV_LOG(ERR, + "Device with port_id=%u is not configured.\n" + "Cannot set IP reassembly configuration", + port_id); + return -EINVAL; + } + + if (dev->data->dev_started != 0) { + RTE_ETHDEV_LOG(ERR, + "Device with port_id=%u started,\n" + "cannot configure IP reassembly params.\n", + port_id); + return -EINVAL; + } + + if (conf == NULL) { + RTE_ETHDEV_LOG(ERR, + "Invalid IP reassembly configuration (NULL)\n"); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->ip_reassembly_conf_set, + -ENOTSUP); + return eth_err(port_id, + (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf)); +} + 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 147cc1ced3..0215f9d854 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -5202,6 +5202,106 @@ int rte_eth_representor_info_get(uint16_t port_id, __rte_experimental int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features); +/* Flag to offload IP reassembly for IPv4 packets. */ +#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0)) +/* Flag to offload IP reassembly for IPv6 packets. */ +#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1)) +/** + * A structure used to get/set IP reassembly configuration. It is also used + * to get the maximum capability values that a PMD can support. + * + * If rte_eth_ip_reassembly_capability_get() returns 0, IP reassembly can be + * enabled using rte_eth_ip_reassembly_conf_set() and params values lower than + * capability params can be set in the PMD. + */ +struct rte_eth_ip_reassembly_params { + /** Maximum time in ms which PMD can wait for other fragments. */ + uint32_t timeout_ms; + /** Maximum number of fragments that can be reassembled. */ + uint16_t max_frags; + /** + * Flags to enable reassembly of packet types - + * RTE_ETH_DEV_REASSEMBLY_F_xxx. + */ + uint16_t flags; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get IP reassembly capabilities supported by the PMD. This is the first API + * to be called for enabling the IP reassembly offload feature. PMD will return + * the maximum values of parameters that PMD can support and user can call + * rte_eth_ip_reassembly_conf_set() with param values lower than capability. + * + * @param port_id + * The port identifier of the device. + * @param capa + * A pointer to rte_eth_ip_reassembly_params structure. + * @return + * - (-ENOTSUP) if offload configuration is not supported by device. + * - (-ENODEV) if *port_id* invalid. + * - (-EIO) if device is removed. + * - (-EINVAL) if device is not configured or *capa* passed is NULL. + * - (0) on success. + */ +__rte_experimental +int rte_eth_ip_reassembly_capability_get(uint16_t port_id, + struct rte_eth_ip_reassembly_params *capa); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get IP reassembly configuration parameters currently set in PMD. + * The API will return error if the configuration is not already + * set using rte_eth_ip_reassembly_conf_set() before calling this API or if + * the device is not configured. + * + * @param port_id + * The port identifier of the device. + * @param conf + * A pointer to rte_eth_ip_reassembly_params structure. + * @return + * - (-ENOTSUP) if offload configuration is not supported by device. + * - (-ENODEV) if *port_id* invalid. + * - (-EIO) if device is removed. + * - (-EINVAL) if device is not configured or if *conf* passed is NULL or if + * configuration is not set using rte_eth_ip_reassembly_conf_set(). + * - (0) on success. + */ +__rte_experimental +int rte_eth_ip_reassembly_conf_get(uint16_t port_id, + struct rte_eth_ip_reassembly_params *conf); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Set IP reassembly configuration parameters if the PMD supports IP reassembly + * offload. User should first call rte_eth_ip_reassembly_capability_get() to + * check the maximum values supported by the PMD before setting the + * configuration. The use of this API is mandatory to enable this feature and + * should be called before rte_eth_dev_start(). + * + * @param port_id + * The port identifier of the device. + * @param conf + * A pointer to rte_eth_ip_reassembly_params structure. + * @return + * - (-ENOTSUP) if offload configuration is not supported by device. + * - (-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. + * - (0) on success. + */ +__rte_experimental +int rte_eth_ip_reassembly_conf_set(uint16_t port_id, + const struct rte_eth_ip_reassembly_params *conf); + + #include /** diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index c2fb0669a4..e22c102818 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -256,6 +256,11 @@ EXPERIMENTAL { rte_flow_flex_item_create; rte_flow_flex_item_release; rte_flow_pick_transfer_proxy; + + # added in 22.03 + rte_eth_ip_reassembly_capability_get; + rte_eth_ip_reassembly_conf_get; + rte_eth_ip_reassembly_conf_set; }; INTERNAL { From patchwork Tue Feb 8 22:20:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 107051 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 2C0F9A034F; Tue, 8 Feb 2022 23:23:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C1D641155; Tue, 8 Feb 2022 23:23:29 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 4256A4114D for ; Tue, 8 Feb 2022 23:23:27 +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 218GEVPd010584; Tue, 8 Feb 2022 14:23:23 -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=acjppp582L9DIHEQ6vIFBS0VDVJnXZg9g9uI2RDrwPU=; b=fGK3KZbFcZAwGzasrzL5IMRLxFNNFypSy1ezt/CcOtmmRXCjgM/0AmAFG4dTn7GQdQlG nLQ5IIDlrmosxMzkXhTEOjQDKBpoW4YdpqBSaZ9uQK37PxpQ8Skdx8AdtLpt+CSo0b0p /2uKYSjjdL92hcdRlVQj+M1pgAGll73zL449hxCCvVb5bb81P6RaW045BwVFsLDrZTME bF01f3fSc5Ed0rpDNXZrscJIQhPrv9EuZH0mn/u3guJmwHC3LyM4qRCI/ZXFH1qGhvgY 1779o8o27/pwWgQrhFW7EvjtB2SqJWalFnT/HM6+MOuOjMKbs5xzWi6lrYPwNUW8d0xt YA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3e3mhskrd4-19 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 14:23:22 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Feb 2022 14:20:42 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Feb 2022 14:20:42 -0800 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id 280813F7098; Tue, 8 Feb 2022 14:20:37 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , , , , , Akhil Goyal Subject: [PATCH v6 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly Date: Wed, 9 Feb 2022 03:50:26 +0530 Message-ID: <20220208222027.1364292-3-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208222027.1364292-1-gakhil@marvell.com> References: <20220208201111.420971-1-gakhil@marvell.com> <20220208222027.1364292-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: ibpEJl9EUTct-GKhk2dXTd8880o9oGux X-Proofpoint-GUID: ibpEJl9EUTct-GKhk2dXTd8880o9oGux 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_07,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 Reviewed-by: Ferruh Yigit --- 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 0215f9d854..eba9c2f402 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 cannot 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 From patchwork Tue Feb 8 22:20:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 107052 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 BCC11A034F; Tue, 8 Feb 2022 23:23:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 529BB41165; Tue, 8 Feb 2022 23:23:31 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id EB7564114D for ; Tue, 8 Feb 2022 23:23:27 +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 218GEVPe010584; Tue, 8 Feb 2022 14:23:23 -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=Y91JbL2ycKkspb0Z6edtGZ/tPPUbo/lsQwgrEhVN9mE=; b=FcB++VKOgxwnf+SqqxPPNKubi8JtTm8EyUxDdj/YifsJ1zg4gn4u/fp2R01OXXMRCpDz GGchuIYWRpILt1jo8dgHC3G5LEXmgL9b1ika3pKi4ZrcKzNZ0SlhAKzxI+zAspvq7qTm pveulqpWK2t/WlSsBQnU+Mbse/hxjd4/6sQi0Vrgr6yNt7gyBI+/NPzEnZbD39J2kkZb 2+aKiJ2Zqe2j/+LCGtRgjDiCuA9p79KlKZtktiHZqEmm2TgbNjtFW3RbHqllu0cA8k1o zHSF4juY9bHGXlu1ghx4F5Cz9s7sXfOELGw90SD7qQ2yoURiAs2Y9BI5Rj+laoRfJsBO hg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3e3mhskrd4-20 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 14:23:23 -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 14:20:46 -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 14:20:46 -0800 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id 9D8C33F709B; Tue, 8 Feb 2022 14:20:42 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , , , , , Akhil Goyal Subject: [PATCH v6 3/3] security: add IPsec option for IP reassembly Date: Wed, 9 Feb 2022 03:50:27 +0530 Message-ID: <20220208222027.1364292-4-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208222027.1364292-1-gakhil@marvell.com> References: <20220208201111.420971-1-gakhil@marvell.com> <20220208222027.1364292-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: StbGKcvHepZEJ4dC-qqtiqzVNWA4EdRm X-Proofpoint-GUID: StbGKcvHepZEJ4dC-qqtiqzVNWA4EdRm 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_07,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 A new option is added in IPsec to enable and attempt reassembly of inbound IP packets. Signed-off-by: Akhil Goyal --- devtools/libabigail.abignore | 5 +++++ lib/security/rte_security.h | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/devtools/libabigail.abignore b/devtools/libabigail.abignore index 4b676f317d..5be41b8805 100644 --- a/devtools/libabigail.abignore +++ b/devtools/libabigail.abignore @@ -11,3 +11,8 @@ ; Ignore generated PMD information strings [suppress_variable] name_regexp = _pmd_info$ + +; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options +[suppress_type] + name = rte_security_ipsec_sa_options + has_data_member_inserted_between = {offset_of(reserved_opts), end} diff --git a/lib/security/rte_security.h b/lib/security/rte_security.h index 1228b6c8b1..b080d10c2c 100644 --- a/lib/security/rte_security.h +++ b/lib/security/rte_security.h @@ -264,6 +264,19 @@ struct rte_security_ipsec_sa_options { */ uint32_t l4_csum_enable : 1; + /** Enable IP reassembly on inline inbound 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 user has successfully set IP reassembly config params + * using rte_eth_ip_reassembly_conf_set() for the inline Ethernet + * device. PMD need to register mbuf dynamic fields using + * rte_eth_ip_reassembly_dynfield_register() and security session + * creation would fail if dynfield is not registered successfully. + * * 0: Disable IP reassembly of packets (default). + */ + uint32_t ip_reassembly_en : 1; + /** Reserved bit fields for future extension * * User should ensure reserved_opts is cleared as it may change in @@ -271,7 +284,7 @@ struct rte_security_ipsec_sa_options { * * Note: Reduce number of bits in reserved_opts for every new option. */ - uint32_t reserved_opts : 18; + uint32_t reserved_opts : 17; }; /** IPSec security association direction */