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 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 { -- 2.25.1