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 9C7FDA0543; Mon, 13 Jun 2022 12:49:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77B12410DD; Mon, 13 Jun 2022 12:49:04 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id E51FD4069C for ; Mon, 13 Jun 2022 12:49:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655117343; x=1686653343; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1JjaoW+ZvoVoZzYl6honTnADjv1U+nxGt2JOOtZrK3I=; b=cnHo3254OtSEdcYiCzLFgkCDgQUo7NfNvDZhjDwDWxfaH4Y1rHxv+po3 EydEvTFdcN7se2hT376UiGAaxm51+470yAaSkWxlpHnzJTHXK3KAMYHhO /oW+ljGmHMCjHsmy9lADJc7+LXHwJnGQew0MEcjup5LFqWcrMEOFTwv9l 3f6uiXV9t2/iIuDHPcZZAD+S3JG7LQWPeDE76i3zPGVNrq5zMbQXwWVPy D5Fhy7pONyBuvfSpIy63qL7sg/nhG6VycKZSQNZX6tn+70a4tBhKrRDcJ /e5rxfZgmRSwm5Q4GA7yDZalZjPc9GSMbVREbmrVyJWqNCydkHecf+WoE g==; X-IronPort-AV: E=McAfee;i="6400,9594,10376"; a="258076128" X-IronPort-AV: E=Sophos;i="5.91,297,1647327600"; d="scan'208";a="258076128" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2022 03:49:02 -0700 X-IronPort-AV: E=Sophos;i="5.91,297,1647327600"; d="scan'208";a="617442805" Received: from unknown (HELO localhost.localdomain) ([10.239.251.3]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2022 03:48:58 -0700 From: wenxuanx.wu@intel.com To: thomas@monjalon.net, andrew.rybchenko@oktetlabs.ru, xiaoyun.li@intel.com, ferruh.yigit@xilinx.com, aman.deep.singh@intel.com, dev@dpdk.org, yuying.zhang@intel.com, qi.z.zhang@intel.com, jerinjacobk@gmail.com Cc: stephen@networkplumber.org, Wenxuan Wu Subject: [PATCH v9 1/4] ethdev: introduce protocol header API Date: Mon, 13 Jun 2022 10:25:47 +0000 Message-Id: <20220613102550.241759-2-wenxuanx.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220613102550.241759-1-wenxuanx.wu@intel.com> References: <20220303060136.36427-1-xuan.ding@intel.com> <20220613102550.241759-1-wenxuanx.wu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Wenxuan Wu This patch added new ethdev API to retrieve supported protocol header mask of a PMD, which helps to configure protocol header based buffer split. Signed-off-by: Wenxuan Wu --- doc/guides/rel_notes/release_22_07.rst | 2 ++ lib/ethdev/ethdev_driver.h | 18 +++++++++++++++ lib/ethdev/rte_ethdev.c | 31 +++++++++++++++++--------- lib/ethdev/rte_ethdev.h | 22 ++++++++++++++++++ lib/ethdev/version.map | 3 +++ 5 files changed, 65 insertions(+), 11 deletions(-) diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index 42a5f2d990..a9b8ed3494 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -54,7 +54,9 @@ New Features This section is a comment. Do not overwrite or remove it. Also, make sure to start the actual text at the margin. ======================================================= +* **Added new ethdev API for PMD to get buffer split supported protocol types.** + Added ``rte_eth_supported_hdrs_get()``, to get supported header protocol mask of a PMD to split. Removed Items ------------- diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 69d9dc21d8..7b19842582 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -1054,6 +1054,21 @@ 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 protocol flags of a PMD to split. + * + * @param dev + * ethdev handle of port. + * + * @param[out] ptype mask + * supported ptype mask of a PMD. + * + * @return + * Negative errno value on error, zero on success. + */ +typedef int (*eth_buffer_split_hdr_ptype_get_t)(struct rte_eth_dev *dev, uint32_t *ptype); + /** * @internal * Dump private info from device to a file. @@ -1281,6 +1296,9 @@ struct eth_dev_ops { /** Set IP reassembly configuration */ eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; + /** Get supported ptypes to split */ + eth_buffer_split_hdr_ptype_get_t hdrs_supported_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 29a3d80466..e1f2a0ffe3 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -1636,9 +1636,10 @@ rte_eth_dev_is_removed(uint16_t port_id) } static int -rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, - uint16_t n_seg, uint32_t *mbp_buf_size, - const struct rte_eth_dev_info *dev_info) +rte_eth_rx_queue_check_split(uint16_t port_id, + const struct rte_eth_rxseg_split *rx_seg, + int16_t n_seg, uint32_t *mbp_buf_size, + const struct rte_eth_dev_info *dev_info) { const struct rte_eth_rxseg_capa *seg_capa = &dev_info->rx_seg_capa; struct rte_mempool *mp_first; @@ -1694,13 +1695,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, } offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM; *mbp_buf_size = rte_pktmbuf_data_room_size(mpl); - length = length != 0 ? length : *mbp_buf_size; - if (*mbp_buf_size < length + offset) { - RTE_ETHDEV_LOG(ERR, - "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n", - mpl->name, *mbp_buf_size, - length + offset, length, offset); - return -EINVAL; + } } return 0; @@ -1779,7 +1774,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, n_seg = rx_conf->rx_nseg; if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) { - ret = rte_eth_rx_queue_check_split(rx_seg, n_seg, + ret = rte_eth_rx_queue_check_split(port_id, rx_seg, n_seg, &mbp_buf_size, &dev_info); if (ret != 0) @@ -5844,6 +5839,20 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id, (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf)); } +int +rte_eth_supported_hdrs_get(uint16_t port_id, uint32_t *ptypes) +{ + struct rte_eth_dev *dev; + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->hdrs_supported_ptypes_get, + -ENOTSUP); + + return eth_err(port_id, + (*dev->dev_ops->hdrs_supported_ptypes_get)(dev, ptypes)); +} + int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) { diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 04cff8ee10..72cac1518e 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -6152,6 +6152,28 @@ 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 supported by PMD. + * The API will return error if the device is not valid. + * + * @param port_id + * The port identifier of the device. + * @param ptype + * Supported protocol headers of driver. + * @return + * - (-ENOTSUP) if header protocol is not supported by device. + * - (-ENODEV) if *port_id* invalid. + * - (-EIO) if device is removed. + * - (0) on success. + */ +__rte_experimental +int rte_eth_supported_hdrs_get(uint16_t port_id, + uint32_t *ptype); + #ifdef __cplusplus } #endif diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 20391ab29e..7705c0364a 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -279,6 +279,9 @@ EXPERIMENTAL { rte_flow_async_action_handle_create; rte_flow_async_action_handle_destroy; rte_flow_async_action_handle_update; + + # added in 22.07 + rte_eth_supported_hdrs_get; }; INTERNAL { -- 2.25.1