From patchwork Wed Oct 5 23:18:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, YuanX" X-Patchwork-Id: 117390 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru 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 B1A2FA0543; Wed, 5 Oct 2022 17:31:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A4E2542670; Wed, 5 Oct 2022 17:31:42 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 47C1740E2D for ; Wed, 5 Oct 2022 17:31:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664983900; x=1696519900; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IWcBgbYa7Ua1pvMqgmhBoER1sHcxzR5rdNNbmxW9rVI=; b=IONWWerik+VKBxaD3eQkPxKXq4toKMeyUAzymW5CoaiM4UIOv4vUhqab jLHSNodTbbdd7N+WApmHwUbOJ4KMduvJBAC48Rn3Y36/ZIvAQJ57dy3TA Wn0o0PSuyItuL/A0fGEcvdTT2LL52CurrtmC9xv0rEo6GrG/BDV5sVbEY UHpcJJiNY3ffeShcIMsyDE1SxKWn+s2LEgu0oLIE9JWTUKAzabd8Gb3EA M4Lc9lyS2vHfvJmB5FzRQWqtIoX85YOlZQIgL6BL8ZbhVvKMMyOrMysPP znyqHUnZrPmMA5mxwSnUTSmohCQuIcAxJghD1Ts3jhnjNJ5EaFH2a/aG3 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10491"; a="365110082" X-IronPort-AV: E=Sophos;i="5.95,161,1661842800"; d="scan'208";a="365110082" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 08:31:38 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10491"; a="869434589" X-IronPort-AV: E=Sophos;i="5.95,161,1661842800"; d="scan'208";a="869434589" Received: from unknown (HELO localhost.localdomain) ([10.239.252.55]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 08:31:32 -0700 From: Yuan Wang To: dev@dpdk.org, Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ray Kinsella Cc: ferruh.yigit@xilinx.com, xiaoyun.li@intel.com, aman.deep.singh@intel.com, yuying.zhang@intel.com, qi.z.zhang@intel.com, qiming.yang@intel.com, jerinjacobk@gmail.com, viacheslavo@nvidia.com, stephen@networkplumber.org, xuan.ding@intel.com, hpothula@marvell.com, yaqi.tang@intel.com, Yuan Wang , Wenxuan Wu Subject: [PATCH v8 1/4] ethdev: introduce protocol header API Date: Thu, 6 Oct 2022 07:18:33 +0800 Message-Id: <20221005231836.215112-2-yuanx.wang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221005231836.215112-1-yuanx.wang@intel.com> References: <20220812181552.2908067-1-yuanx.wang@intel.com> <20221005231836.215112-1-yuanx.wang@intel.com> MIME-Version: 1.0 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 Add a new ethdev API to retrieve supported protocol headers of a PMD, which helps to configure protocol header based buffer split. Signed-off-by: Yuan Wang Signed-off-by: Xuan Ding Signed-off-by: Wenxuan Wu Reviewed-by: Andrew Rybchenko --- doc/guides/rel_notes/release_22_11.rst | 5 ++++ lib/ethdev/ethdev_driver.h | 15 ++++++++++++ lib/ethdev/rte_ethdev.c | 33 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++ lib/ethdev/version.map | 1 + 5 files changed, 84 insertions(+) diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index ac67e7e710..141fd9442b 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -123,6 +123,11 @@ New Features into single event containing ``rte_event_vector`` whose event type is ``RTE_EVENT_TYPE_CRYPTODEV_VECTOR``. +* **Added protocol header based buffer split.** + + * Added ``rte_eth_buffer_split_get_supported_hdr_ptypes()``, to get supported + header protocols of a PMD to split. + Removed Items ------------- diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 8cd8eb8685..791b264610 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -1055,6 +1055,18 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev, typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev, const struct rte_eth_ip_reassembly_params *conf); +/** + * @internal + * Get supported header protocols of a PMD to split. + * + * @param dev + * Ethdev handle of port. + * + * @return + * An array pointer to store supported protocol headers. + */ +typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t)(struct rte_eth_dev *dev); + /** * @internal * Dump private info from device to a file. @@ -1302,6 +1314,9 @@ struct eth_dev_ops { /** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; + /** Get supported header ptypes to split */ + eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; + /** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump; diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 2821770e2d..ee3b490889 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6045,6 +6045,39 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file)); } +int +rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num) +{ + int i, j; + struct rte_eth_dev *dev; + const uint32_t *all_types; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + if (ptypes == NULL && num > 0) { + RTE_ETHDEV_LOG(ERR, + "Cannot get ethdev port %u supported header protocol types to NULL when array size is non zero\n", + port_id); + return -EINVAL; + } + + if (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get == NULL) + return -ENOTSUP; + all_types = (*dev->dev_ops->buffer_split_supported_hdr_ptypes_get)(dev); + + if (all_types == NULL) + return 0; + + for (i = 0, j = 0; all_types[i] != RTE_PTYPE_UNKNOWN; ++i) { + if (j < num) + ptypes[j] = all_types[i]; + j++; + } + + return j; +} + 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 a21f58b9cd..c51c1f3fa0 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -6025,6 +6025,36 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, return rte_eth_tx_buffer_flush(port_id, queue_id, buffer); } +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get supported header protocols to split on Rx. + * + * When a packet type is announced to be split, it *must* be supported by + * the PMD. For instance, if eth-ipv4, eth-ipv4-udp is announced, the PMD must + * return the following packet types for these packets: + * - Ether/IPv4 -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 + * - Ether/IPv4/UDP -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP + * + * @param port_id + * The port identifier of the device. + * @param[out] ptypes + * An array pointer to store supported protocol headers, allocated by caller. + * These ptypes are composed with RTE_PTYPE_*. + * @param num + * Size of the array pointed by param ptypes. + * @return + * - (>=0) Number of supported ptypes. If the number of types exceeds num, + * only num entries will be filled into the ptypes array, but the full + * count of supported ptypes will be returned. + * - (-ENOTSUP) if header protocol is not supported by device. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if bad parameter. + */ +__rte_experimental +int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); + #ifdef __cplusplus } #endif diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 3def7bfd24..87f06d4ea6 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -288,6 +288,7 @@ EXPERIMENTAL { # added in 22.11 rte_flow_async_action_handle_query; + rte_eth_buffer_split_get_supported_hdr_ptypes; }; INTERNAL {