From patchwork Fri Feb 4 22:13:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 106877 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 0DC30A04A4; Fri, 4 Feb 2022 23:13:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 21E354069F; Fri, 4 Feb 2022 23:13:55 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 34EB240696 for ; Fri, 4 Feb 2022 23:13:53 +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 214Ein7l025459; Fri, 4 Feb 2022 14:13:48 -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=x2cFlt76sq2vjygeAaDP+seDni4xBLGT7nRHKJnRIiE=; b=JwfBOPmougsPmggdGnLE2OUUp5N1z89cae8qd0bq1FS+V5eJplTMoe0qdhA5BUhFsOXK nexi2MTa7SdtKLarYAnWlIfgWvCrcu/E/0Hld9ERiupJT4P45G9/nmdbodXhTCTxWaIN ptQ/DJIrgiz3pCKaqPomSnrXWCj+z7yrHMfAr+37B9BmZBB9GZIPE+TEj24c28R1bMY+ nsKSVsj2vdwRrxUisWkr33acDsh+ovaqdUpDZ5/FZkRzje9+ViRkKiLTq0Q0AKypwmix Bu8wuJAg+mO4e18Gxz8HJXDXZudT/zLaKyRSVL4/enCU6xv411+xInLQZD71AJrIFqUV Aw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3e0tp1bmpt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 14:13:47 -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; Fri, 4 Feb 2022 14:13: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; Fri, 4 Feb 2022 14:13:46 -0800 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id 4A2863F7069; Fri, 4 Feb 2022 14:13:42 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , , , , , Akhil Goyal Subject: [PATCH v4 1/3] ethdev: introduce IP reassembly offload Date: Sat, 5 Feb 2022 03:43:32 +0530 Message-ID: <20220204221334.3551574-2-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220204221334.3551574-1-gakhil@marvell.com> References: <20220130175935.1947730-1-gakhil@marvell.com> <20220204221334.3551574-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: SHcd81gyCSlbY5-SAQlo4oxn5uFpE8KG X-Proofpoint-GUID: SHcd81gyCSlbY5-SAQlo4oxn5uFpE8KG 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-04_07,2022-02-03_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 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 Change-Id: Ic20bb3af1ed599e8f2f3665d2d6c47b2e420e509 --- doc/guides/nics/features.rst | 13 +++++ lib/ethdev/ethdev_driver.h | 55 +++++++++++++++++++++ lib/ethdev/rte_ethdev.c | 93 ++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 91 +++++++++++++++++++++++++++++++++++ lib/ethdev/version.map | 5 ++ 5 files changed, 257 insertions(+) diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst index 27be2d2576..e6e0bbe9d8 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_reassemly_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/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index d95605a355..8fe77f283f 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_reass_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_reass_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_reass_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..88ca4ce867 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6474,6 +6474,99 @@ 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_reass_params *reass_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=%"PRIu16" is not configured.\n", + port_id); + return -EINVAL; + } + + if (reass_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(reass_capa, 0, sizeof(struct rte_eth_ip_reass_params)); + + return eth_err(port_id, (*dev->dev_ops->ip_reassembly_capability_get) + (dev, reass_capa)); +} + +int +rte_eth_ip_reassembly_conf_get(uint16_t port_id, + struct rte_eth_ip_reass_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=%"PRIu16" is not configured.\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_reass_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_reass_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=%"PRIu16" is not configured.\n", + port_id); + return -EINVAL; + } + + if (dev->data->dev_started != 0) { + RTE_ETHDEV_LOG(ERR, + "Device with port_id=%"PRIu16" 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..ecc5cd50b9 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -1794,6 +1794,29 @@ enum rte_eth_representor_type { RTE_ETH_REPRESENTOR_PF, /**< representor of Physical Function. */ }; +/* 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/capability. + * + * 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 can be set in the PMD. + */ +struct rte_eth_ip_reass_params { + /** Maximum time in ms which PMD can wait for other fragments. */ + uint32_t reass_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; +}; + /** * A structure used to retrieve the contextual information of * an Ethernet device, such as the controlling driver of the @@ -5202,6 +5225,74 @@ 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); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get IP reassembly capabilities supported by the PMD, + * + * @param port_id + * The port identifier of the device. + * @param conf + * A pointer to rte_eth_ip_reass_params structure. + * @return + * - (-ENOTSUP) if offload configuration is not supported by device. + * - (-ENODEV) if *port_id* invalid. + * - (-EIO) if device is removed. + * - (0) on success. + */ +__rte_experimental +int rte_eth_ip_reassembly_capability_get(uint16_t port_id, + struct rte_eth_ip_reass_params *conf); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get IP reassembly configuration parameters currently set in PMD, + * if device Rx offload flag (RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY) is + * enabled and the PMD supports IP reassembly offload. + * + * @param port_id + * The port identifier of the device. + * @param conf + * A pointer to rte_eth_ip_reass_params structure. + * @return + * - (-ENOTSUP) if offload configuration is not supported by device. + * - (-EINVAL) if offload is not enabled in rte_eth_conf. + * - (-ENODEV) if *port_id* invalid. + * - (-EIO) if device is removed. + * - (0) on success. + */ +__rte_experimental +int rte_eth_ip_reassembly_conf_get(uint16_t port_id, + struct rte_eth_ip_reass_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_reass_params structure. + * @return + * - (-ENOTSUP) if offload configuration is not supported by device. + * - (-ENODEV) if *port_id* invalid. + * - (-EIO) if device is removed. + * - (0) on success. + */ +__rte_experimental +int rte_eth_ip_reassembly_conf_set(uint16_t port_id, + const struct rte_eth_ip_reass_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 Fri Feb 4 22:13:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 106878 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 5639DA04A4; Fri, 4 Feb 2022 23:14:00 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D56940696; Fri, 4 Feb 2022 23:13:58 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 6103C40E09 for ; Fri, 4 Feb 2022 23:13:56 +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 214CxpCi013944; Fri, 4 Feb 2022 14:13:53 -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=83IMnorgxRfUCc+16R73TckfC72O6Kx5oO/yF5/if4E=; b=dfAZjlxlLvhcApu36Iy+9PJEOW0iWYLLL642s13gX7WxHdWDHL4QnlZuOYZ2h8GkvPWR E6jlK3jSF63MIQUARstnUsZKRju/5toWcMc1mY65SdHRLxifRt1L005PCB5ZU/lhPQeh VbW56xA6yWRgA2DUePFcDSIf1h5h2fMC7Ga2D0kcO4mR8GuVxC7wDnuZ3KVCMD2a5sOL VLOk/ITnmOU9LjFsk6YXbkmZ/4gDe1/2m46wNdig6wcjUVemr9UK665xn9Mk1m8uNE3/ POR5yoYcVYu0NKG/IdTyf8GqWsTjnXullRCzMfMK8HiW55XuQh9lnnwD7SWI56UqNsf0 iA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3e0jvrnnha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 14:13:52 -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; Fri, 4 Feb 2022 14:13:50 -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; Fri, 4 Feb 2022 14:13:50 -0800 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id BF2583F706C; Fri, 4 Feb 2022 14:13:46 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , , , , , Akhil Goyal Subject: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly Date: Sat, 5 Feb 2022 03:43:33 +0530 Message-ID: <20220204221334.3551574-3-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220204221334.3551574-1-gakhil@marvell.com> References: <20220130175935.1947730-1-gakhil@marvell.com> <20220204221334.3551574-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: t3UJA11QMbPjhRjzgOScS83AksbNqNsV X-Proofpoint-ORIG-GUID: t3UJA11QMbPjhRjzgOScS83AksbNqNsV 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-04_07,2022-02-03_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 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 Change-Id: I118847cd6269da7e6313ac4e0d970d790dfef1ff --- lib/ethdev/ethdev_driver.h | 8 ++++++++ lib/ethdev/rte_ethdev.c | 28 ++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 17 +++++++++++++++++ lib/ethdev/version.map | 1 + lib/mbuf/rte_mbuf_dyn.h | 9 +++++++++ 5 files changed, 63 insertions(+) diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 8fe77f283f..6cfb266f7d 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_reass_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 88ca4ce867..48367dbec1 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6567,6 +6567,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id, (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf)); } +int +rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag_offset) +{ + static const struct rte_mbuf_dynfield field_desc = { + .name = RTE_MBUF_DYNFIELD_IP_REASS_NAME, + .size = sizeof(rte_eth_ip_reass_dynfield_t), + .align = __alignof__(rte_eth_ip_reass_dynfield_t), + }; + static const struct rte_mbuf_dynflag ip_reass_dynflag = { + .name = RTE_MBUF_DYNFLAG_IP_REASS_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_reass_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 ecc5cd50b9..ce35023c40 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -5292,6 +5292,23 @@ __rte_experimental int rte_eth_ip_reassembly_conf_set(uint16_t port_id, const struct rte_eth_ip_reass_params *conf); +/** + * In case of IP reassembly offload failure, ol_flags in mbuf will be + * updated with dynamic flag 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; + #include diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index e22c102818..d6de8d402e 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_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_dyn.h b/lib/mbuf/rte_mbuf_dyn.h index 29abe8da53..299638513b 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_REASS_INCOMPLETE_NAME to denote that + * IP reassembly is incomplete and application can retrieve the packets back + * using RTE_MBUF_DYNFIELD_IP_REASS_NAME. + */ +#define RTE_MBUF_DYNFIELD_IP_REASS_NAME "rte_eth_ip_reass_dynfield" +#define RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME "rte_eth_ip_reass_incomplete_dynflag" + #ifdef __cplusplus } #endif From patchwork Fri Feb 4 22:13:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 106879 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 C3B84A04A4; Fri, 4 Feb 2022 23:14:05 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 04E3040E50; Fri, 4 Feb 2022 23:14:02 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 0CCD44068F for ; Fri, 4 Feb 2022 23:13:59 +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 214Lv2qA017598; Fri, 4 Feb 2022 14:13:57 -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=aBdWkgoWpxSiIHRzunw1jEgQWmfGhUw0/i0HI7EsDUc=; b=QrMMNxXUsPBuEe/G/GlZWc6YlstyC54kDQrkR90t+YCiPz+nxgDxc5JyWWkCLFc1tf9i lNiyQD1hwvj5f6Hu+mt3wiMfMu4rvtbqpKlsgjB3SLEAb/gxZgogR+TiagOFjEFGHyq2 E0LVlWBWE295edJzmWP3TlQ17OZnRy1omiJu+4Hu9ESpjHbsNI2V2RcTA172rJacFa/m r4eMaefDaG3+MhlMo6sE+WEQP5VMVQHT6hZzsx0fx09gNyoYp1fVWMCAT7n8u9n0KfXr uMmGJv4EBXDQwNi5zfbz89+1+TU0Dm7lOsXZyTAog3UpsqJiL0zUCgBUTliR/1PpMgPr XQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3e0jvrnnk1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 14:13:57 -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; Fri, 4 Feb 2022 14:13:55 -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; Fri, 4 Feb 2022 14:13:55 -0800 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id 3F3AA3F7069; Fri, 4 Feb 2022 14:13:51 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , , , , , Akhil Goyal Subject: [PATCH v4 3/3] security: add IPsec option for IP reassembly Date: Sat, 5 Feb 2022 03:43:34 +0530 Message-ID: <20220204221334.3551574-4-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220204221334.3551574-1-gakhil@marvell.com> References: <20220130175935.1947730-1-gakhil@marvell.com> <20220204221334.3551574-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: Od6mhOQk9hOOZWMElaCo63H_InAVjwvX X-Proofpoint-ORIG-GUID: Od6mhOQk9hOOZWMElaCo63H_InAVjwvX 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-04_07,2022-02-03_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 A new option is added in IPsec to enable and attempt reassembly of inbound packets. Signed-off-by: Akhil Goyal Change-Id: I6f66f0b5a659550976a32629130594070cb16cb1 --- devtools/libabigail.abignore | 14 ++++++++++++++ lib/security/rte_security.h | 12 +++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/devtools/libabigail.abignore b/devtools/libabigail.abignore index 4b676f317d..3bd39042e8 100644 --- a/devtools/libabigail.abignore +++ b/devtools/libabigail.abignore @@ -11,3 +11,17 @@ ; 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_ipsec_sa_prm + name = rte_security_ipsec_sa_options + has_data_member_inserted_between = {offset_of(reserved_opts), end} + +[suppress_type] + name = rte_security_capability + has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)} + +[suppress_type] + name = rte_security_session_conf + has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)} diff --git a/lib/security/rte_security.h b/lib/security/rte_security.h index 1228b6c8b1..168b837a82 100644 --- a/lib/security/rte_security.h +++ b/lib/security/rte_security.h @@ -264,6 +264,16 @@ struct rte_security_ipsec_sa_options { */ uint32_t l4_csum_enable : 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 RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY is set in + * inline Ethernet device. + * * 0: Disable reassembly of packets (default). + */ + uint32_t reass_en : 1; + /** Reserved bit fields for future extension * * User should ensure reserved_opts is cleared as it may change in @@ -271,7 +281,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 */