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 DFFBDA00C3 for ; Wed, 23 Feb 2022 17:07:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA67F41226; Wed, 23 Feb 2022 17:07:30 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) by mails.dpdk.org (Postfix) with ESMTP id 4EF1841C2E for ; Wed, 23 Feb 2022 17:07:29 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UT3v0JoS5Cf/6WMh8W+eHNERvgzAX6ym9fNg6XZPaf4dyb1szWtbfFZyyaA9PaiB8GOrKYI0EQnH7IWjl7HpudlLPRRXbHkgF7jju+3yf4LmqELPJTKK51ewud9P1Hiwr0N6EcWDUPD94B/06kp/iTlDFZg47WpYLNcjkSTs18svpHiYD+lT4UcIZtWRXciWqyjUeeL27HWEes0dIXC+zNSXRP0t0qc1M91dW1qB5IfJRl0OXqYQaQIkAQsEPExyHUiy8lNn1JY49F+/i6qABOtmZnK+3PSWQh0Fyfci/HhmZDHd/6Uz0T2GECyOO1jTc2pvTbK9aD/krgwKtXKnCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mKe886ftdBRryhxYQcXOGrvF1keoTSfji3a2oogCbHA=; b=iyTl7wE3Ww3azjeKommgVh68Hzd3nuUfiFddpc3KfkYGuST9uO62ynvukAp2KR/lLcjSlbC7g19X8Opt6rnXvdrBOckAdkKUXFwqGsIvXAPdGgz7l8H8Cb5b89ONy1D80NXVjJGdZDXrOAcfKhj3ViRoK3LvjQTEaBLcF/o8GC2k4pC79b5RTs2Sp4BI4FsH9lRaAG8YnE2zsGUmUkHYHsI164IjlIrMsbSXRaMjXAvkCXeU9g+S1jAw23ZDcQ8CZwVmQ48Lepmh2IuGLPUf6x8B+30HapzdM3pSDqyatPbbz+m82OOFW+5DdTq9lfM3wTvfXxVDcAFk882ozZQ/eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mKe886ftdBRryhxYQcXOGrvF1keoTSfji3a2oogCbHA=; b=P1gBYta5n1DgqdRX3yanOr7FC+EIkEBVEvfbIr+M340OEJXZ2bxJeVwY7AFoeF9iOeG7Mk2Z/qxkXbUXqNWmS7lBVVsDiIV2HSce+6ekI44ZtMPQcbxJYKzkPANEFE2lPGhrL81AB4gR+rg+ZISxFQiJvQF4dhaFQCJaUBADHlsbbWi5FmQ9FWexnzptY/fs1VGu7BPuzvWjb9Q/SyqHNfbAltyS2cFqKMYe6+9G+uSSTXGRXeu6iUbgiB4ur41VSAIRyxTm1Xo7p2ZUZeESa4eVFVSoLqpr++7co5pB16YxGHZ06AIamrFMnKi8y3UcQZRoWunr2NVjdhqGylqyOA== Received: from MWHPR2201CA0039.namprd22.prod.outlook.com (2603:10b6:301:16::13) by BYAPR12MB2822.namprd12.prod.outlook.com (2603:10b6:a03:9a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.24; Wed, 23 Feb 2022 16:07:27 +0000 Received: from CO1NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:301:16:cafe::e3) by MWHPR2201CA0039.outlook.office365.com (2603:10b6:301:16::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.17 via Frontend Transport; Wed, 23 Feb 2022 16:07:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by CO1NAM11FT014.mail.protection.outlook.com (10.13.175.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5017.22 via Frontend Transport; Wed, 23 Feb 2022 16:07:26 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 23 Feb 2022 16:07:26 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Wed, 23 Feb 2022 08:07:24 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9 via Frontend Transport; Wed, 23 Feb 2022 08:07:23 -0800 From: Michael Baum To: CC: Matan Azrad , Viacheslav Ovsiienko Subject: [PATCH 20.11 v2 3/5] net/mlx5: fix MPRQ stride devargs adjustment Date: Wed, 23 Feb 2022 18:07:11 +0200 Message-ID: <20220223160713.2992784-4-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220223160713.2992784-1-michaelba@nvidia.com> References: <20220223160713.2992784-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e299e691-da55-4d75-860c-08d9f6e695f4 X-MS-TrafficTypeDiagnostic: BYAPR12MB2822:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ixh+eE0w7jeR74uLlQKpgB7i8K7LSgy7wwyzpdCGhMY4sOdip/+pkkA/0Zoem3oZucVjpV80/RmgwMfj+l+ab5O6N7FhvKVCnJXrrQPLdKMuZ4cwtruRfvH2y8ilLRv+oiy32z6T5WF+0YkqGvLP8JGw2Ah+9bAm+aIIssUijexA3g1LkJ0YpOPJigsSIKD7maWux5sqywA+L6qOfnUrAmEQkHMdKgh6TA6aHeMNZdbiUYcIbdrovMnn3VBmXpp+XLgSw4386Cmy3WZLpupB33mpFEhJWnTEFmL+J2XvDy3Xd2MB4PvwmBax7VGQMVQxFOjRL4MtwQ76yNwJulz2WyJgtes8Yr4cmTamTVsmEUaBIKfF8RSm6xXRUU2kjBCcb5VoHe9lCtfvaSK2KDIur4Z09UxmXed4IrS7BmOk0wq+yBS4hdKVZ+ejwsmfl438M8HEvkQO2tUlDwCr8DrjCTTbUbtNaHVbOhE7u8fbKyo8y2LrtyBUTTLSJdtRAsWWjigcoSF/iwIU3/1zPPwFc5Lg6m+UVqK47+SQY6h6/O6czywpQEmUI+b7bY6pNTHdDV+NiYrfrtz6HZAKuB77DQx6rx+6Ni++z43R5LBedw16RmwZZUm4fw72xaBx5qti9xCL9Pb/7EKgByMOcrvMXRWI+pup37PKpR2PsISLvuu1/EMKzsxT38POWfrzbUICLSNuVWiF0C+8HIqjw7BZvgIOm4xmHrXqZlq+ovGsUqY= X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(4326008)(81166007)(316002)(1076003)(70586007)(8676002)(508600001)(2616005)(107886003)(186003)(26005)(6286002)(82310400004)(70206006)(356005)(86362001)(40460700003)(7696005)(30864003)(5660300002)(55016003)(8936002)(47076005)(36860700001)(36756003)(426003)(6916009)(54906003)(2906002)(336012)(83380400001)(6666004)(36900700001)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2022 16:07:26.6970 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e299e691-da55-4d75-860c-08d9f6e695f4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2822 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit 34776af600df4475799ad8004e76d0eb77c163ff ] In Multi-Packet RQ creation, the user can choose the number of strides and their size in bytes. The user updates it using specific devargs for both of these parameters. The above two parameters determine the size of the WQE which is actually their product of multiplication. If the user selects values that are not in the supported range, the PMD changes them to default values. However, apart from the range limitations for each parameter individually there is also a minimum value on their multiplication. When the user selects values that their multiplication are lower than minimum value, no adjustment is made and the creation of the WQE fails. This patch adds an adjustment in these cases as well. When the user selects values whose multiplication is lower than the minimum, they are replaced with the default values. Fixes: ecb160456aed ("net/mlx5: add device parameter for MPRQ stride size") Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 48 ++----- drivers/net/mlx5/mlx5.h | 4 + drivers/net/mlx5/mlx5_rxq.c | 209 +++++++++++++++++++++---------- 3 files changed, 154 insertions(+), 107 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 6393cc5007..602dc671ef 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -758,10 +758,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, unsigned int mpls_en = 0; unsigned int swp = 0; unsigned int mprq = 0; - unsigned int mprq_min_stride_size_n = 0; - unsigned int mprq_max_stride_size_n = 0; - unsigned int mprq_min_stride_num_n = 0; - unsigned int mprq_max_stride_num_n = 0; struct rte_ether_addr mac; char name[RTE_ETH_NAME_MAX_LEN]; int own_domain_id = 0; @@ -934,13 +930,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mprq_caps.supported_qpts); DRV_LOG(DEBUG, "device supports Multi-Packet RQ"); mprq = 1; - mprq_min_stride_size_n = + config->mprq.log_min_stride_size = mprq_caps.min_single_stride_log_num_of_bytes; - mprq_max_stride_size_n = + config->mprq.log_max_stride_size = mprq_caps.max_single_stride_log_num_of_bytes; - mprq_min_stride_num_n = + config->mprq.log_min_stride_num = mprq_caps.min_single_wqe_log_num_of_strides; - mprq_max_stride_num_n = + config->mprq.log_max_stride_num = mprq_caps.max_single_wqe_log_num_of_strides; } #endif @@ -1178,12 +1174,17 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, config->mps == MLX5_MPW_ENHANCED ? "enhanced " : config->mps == MLX5_MPW ? "legacy " : "", config->mps != MLX5_MPW_DISABLED ? "enabled" : "disabled"); + config->mprq.log_min_stride_wqe_size = + MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE; + config->mprq.log_stride_num = MLX5_MPRQ_DEFAULT_LOG_STRIDE_NUM; if (config->devx) { err = mlx5_devx_cmd_query_hca_attr(sh->ctx, &config->hca_attr); if (err) { err = -err; goto error; } + config->mprq.log_min_stride_wqe_size = + config->hca_attr.log_min_stride_wqe_sz; sh->rq_ts_format = config->hca_attr.rq_ts_format; sh->sq_ts_format = config->hca_attr.sq_ts_format; sh->qp_ts_format = config->hca_attr.qp_ts_format; @@ -1382,36 +1383,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, config->hw_fcs_strip = 0; DRV_LOG(DEBUG, "FCS stripping configuration is %ssupported", (config->hw_fcs_strip ? "" : "not ")); - if (config->mprq.enabled && mprq) { - if (config->mprq.log_stride_num && - (config->mprq.log_stride_num > mprq_max_stride_num_n || - config->mprq.log_stride_num < mprq_min_stride_num_n)) { - config->mprq.log_stride_num = - RTE_MIN(RTE_MAX(MLX5_MPRQ_DEFAULT_LOG_STRIDE_NUM, - mprq_min_stride_num_n), - mprq_max_stride_num_n); - DRV_LOG(WARNING, - "the number of strides" - " for Multi-Packet RQ is out of range," - " setting default value (%u)", - 1 << config->mprq.log_stride_num); - } - if (config->mprq.log_stride_size && - (config->mprq.log_stride_size > mprq_max_stride_size_n || - config->mprq.log_stride_size < mprq_min_stride_size_n)) { - config->mprq.log_stride_size = - RTE_MIN(RTE_MAX(MLX5_MPRQ_DEFAULT_LOG_STRIDE_SIZE, - mprq_min_stride_size_n), - mprq_max_stride_size_n); - DRV_LOG(WARNING, - "the size of a stride" - " for Multi-Packet RQ is out of range," - " setting default value (%u)", - 1 << config->mprq.log_stride_size); - } - config->mprq.log_min_stride_size = mprq_min_stride_size_n; - config->mprq.log_max_stride_size = mprq_max_stride_size_n; - } else if (config->mprq.enabled && !mprq) { + if (config->mprq.enabled && !mprq) { DRV_LOG(WARNING, "Multi-Packet RQ isn't supported"); config->mprq.enabled = 0; } diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 071e8c6caf..d5016545b0 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -232,6 +232,10 @@ struct mlx5_dev_config { unsigned int log_stride_size; /* Log size of a stride. */ unsigned int log_min_stride_size; /* Log min size of a stride.*/ unsigned int log_max_stride_size; /* Log max size of a stride.*/ + unsigned int log_min_stride_num; /* Log min num of strides. */ + unsigned int log_max_stride_num; /* Log max num of strides. */ + unsigned int log_min_stride_wqe_size; + /* Log min WQE size, (size of single stride)*(num of strides).*/ unsigned int max_memcpy_len; /* Maximum packet size to memcpy Rx packets. */ unsigned int min_rxqs_num; diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index b83a2f2d60..4a263a5803 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1380,6 +1380,127 @@ mlx5_max_lro_msg_size_adjust(struct rte_eth_dev *dev, uint16_t idx, priv->max_lro_msg_size * MLX5_LRO_SEG_CHUNK_SIZE); } +/** + * Prepare both size and number of stride for Multi-Packet RQ. + * + * @param dev + * Pointer to Ethernet device. + * @param idx + * RX queue index. + * @param desc + * Number of descriptors to configure in queue. + * @param rx_seg_en + * Indicator if Rx segment enables, if so Multi-Packet RQ doesn't enable. + * @param min_mbuf_size + * Non scatter min mbuf size, max_rx_pktlen plus overhead. + * @param actual_log_stride_num + * Log number of strides to configure for this queue. + * @param actual_log_stride_size + * Log stride size to configure for this queue. + * + * @return + * 0 if Multi-Packet RQ is supported, otherwise -1. + */ +static int +mlx5_mprq_prepare(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, + bool rx_seg_en, uint32_t min_mbuf_size, + uint32_t *actual_log_stride_num, + uint32_t *actual_log_stride_size) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_dev_config *config = &priv->config; + uint32_t log_min_stride_num = config->mprq.log_min_stride_num; + uint32_t log_max_stride_num = config->mprq.log_max_stride_num; + uint32_t log_def_stride_num = + RTE_MIN(RTE_MAX(MLX5_MPRQ_DEFAULT_LOG_STRIDE_NUM, + log_min_stride_num), + log_max_stride_num); + uint32_t log_min_stride_size = config->mprq.log_min_stride_size; + uint32_t log_max_stride_size = config->mprq.log_max_stride_size; + uint32_t log_def_stride_size = + RTE_MIN(RTE_MAX(MLX5_MPRQ_DEFAULT_LOG_STRIDE_SIZE, + log_min_stride_size), + log_max_stride_size); + uint32_t log_stride_wqe_size; + + if (mlx5_check_mprq_support(dev) != 1 || rx_seg_en) + goto unsupport; + /* Checks if chosen number of strides is in supported range. */ + if (config->mprq.log_stride_num > log_max_stride_num || + config->mprq.log_stride_num < log_min_stride_num) { + *actual_log_stride_num = log_def_stride_num; + DRV_LOG(WARNING, + "Port %u Rx queue %u number of strides for Multi-Packet RQ is out of range, setting default value (%u)", + dev->data->port_id, idx, RTE_BIT32(log_def_stride_num)); + } else { + *actual_log_stride_num = config->mprq.log_stride_num; + } + if (config->mprq.log_stride_size) { + /* Checks if chosen size of stride is in supported range. */ + if (config->mprq.log_stride_size > log_max_stride_size || + config->mprq.log_stride_size < log_min_stride_size) { + *actual_log_stride_size = log_def_stride_size; + DRV_LOG(WARNING, + "Port %u Rx queue %u size of a stride for Multi-Packet RQ is out of range, setting default value (%u)", + dev->data->port_id, idx, + RTE_BIT32(log_def_stride_size)); + } else { + *actual_log_stride_size = config->mprq.log_stride_size; + } + } else { + if (min_mbuf_size <= RTE_BIT32(log_max_stride_size)) + *actual_log_stride_size = log2above(min_mbuf_size); + else + goto unsupport; + } + log_stride_wqe_size = *actual_log_stride_num + *actual_log_stride_size; + /* Check if WQE buffer size is supported by hardware. */ + if (log_stride_wqe_size < config->mprq.log_min_stride_wqe_size) { + *actual_log_stride_num = log_def_stride_num; + *actual_log_stride_size = log_def_stride_size; + DRV_LOG(WARNING, + "Port %u Rx queue %u size of WQE buffer for Multi-Packet RQ is too small, setting default values (stride_num_n=%u, stride_size_n=%u)", + dev->data->port_id, idx, RTE_BIT32(log_def_stride_num), + RTE_BIT32(log_def_stride_size)); + log_stride_wqe_size = log_def_stride_num + log_def_stride_size; + } + MLX5_ASSERT(log_stride_wqe_size >= + config->mprq.log_min_stride_wqe_size); + if (desc <= RTE_BIT32(*actual_log_stride_num)) + goto unsupport; + if (min_mbuf_size > RTE_BIT32(log_stride_wqe_size)) { + DRV_LOG(WARNING, "Port %u Rx queue %u " + "Multi-Packet RQ is unsupported, WQE buffer size (%u) " + "is smaller than min mbuf size (%u)", + dev->data->port_id, idx, RTE_BIT32(log_stride_wqe_size), + min_mbuf_size); + goto unsupport; + } + DRV_LOG(DEBUG, "Port %u Rx queue %u " + "Multi-Packet RQ is enabled strd_num_n = %u, strd_sz_n = %u", + dev->data->port_id, idx, RTE_BIT32(*actual_log_stride_num), + RTE_BIT32(*actual_log_stride_size)); + return 0; +unsupport: + if (config->mprq.enabled) + DRV_LOG(WARNING, + "Port %u MPRQ is requested but cannot be enabled\n" + " (requested: pkt_sz = %u, desc_num = %u," + " rxq_num = %u, stride_sz = %u, stride_num = %u\n" + " supported: min_rxqs_num = %u, min_buf_wqe_sz = %u" + " min_stride_sz = %u, max_stride_sz = %u).\n" + "Rx segment is %senable.", + dev->data->port_id, min_mbuf_size, desc, priv->rxqs_n, + RTE_BIT32(config->mprq.log_stride_size), + RTE_BIT32(config->mprq.log_stride_num), + config->mprq.min_rxqs_num, + RTE_BIT32(config->mprq.log_min_stride_wqe_size), + RTE_BIT32(config->mprq.log_min_stride_size), + RTE_BIT32(config->mprq.log_max_stride_size), + rx_seg_en ? "" : "not "); + return -1; +} + /** * Create a DPDK Rx queue. * @@ -1414,33 +1535,28 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, RTE_PKTMBUF_HEADROOM; unsigned int max_lro_size = 0; unsigned int first_mb_free_size = mb_len - RTE_PKTMBUF_HEADROOM; - const int mprq_en = mlx5_check_mprq_support(dev) > 0 && n_seg == 1 && - !rx_seg[0].offset && !rx_seg[0].length; - unsigned int log_mprq_stride_nums = config->mprq.log_stride_num ? - config->mprq.log_stride_num : MLX5_MPRQ_DEFAULT_LOG_STRIDE_NUM; - unsigned int log_mprq_stride_size = non_scatter_min_mbuf_size <= - RTE_BIT32(config->mprq.log_max_stride_size) ? - log2above(non_scatter_min_mbuf_size) : - MLX5_MPRQ_DEFAULT_LOG_STRIDE_SIZE; - unsigned int mprq_stride_cap = (config->mprq.log_stride_num ? - RTE_BIT32(config->mprq.log_stride_num) : - RTE_BIT32(log_mprq_stride_nums)) * - (config->mprq.log_stride_size ? - RTE_BIT32(config->mprq.log_stride_size) : - RTE_BIT32(log_mprq_stride_size)); + uint32_t mprq_log_actual_stride_num = 0; + uint32_t mprq_log_actual_stride_size = 0; + bool rx_seg_en = n_seg != 1 || rx_seg[0].offset || rx_seg[0].length; + const int mprq_en = !mlx5_mprq_prepare(dev, idx, desc, rx_seg_en, + non_scatter_min_mbuf_size, + &mprq_log_actual_stride_num, + &mprq_log_actual_stride_size); /* * Always allocate extra slots, even if eventually * the vector Rx will not be used. */ uint16_t desc_n = desc + config->rx_vec_en * MLX5_VPMD_DESCS_PER_LOOP; + size_t alloc_size = sizeof(*tmpl) + desc_n * sizeof(struct rte_mbuf *); const struct rte_eth_rxseg_split *qs_seg = rx_seg; unsigned int tail_len; - tmpl = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, - sizeof(*tmpl) + desc_n * sizeof(struct rte_mbuf *) + - (!!mprq_en) * - (desc >> log_mprq_stride_nums) * sizeof(struct mlx5_mprq_buf *), - 0, socket); + if (mprq_en) { + /* Trim the number of descs needed. */ + desc >>= mprq_log_actual_stride_num; + alloc_size += desc * sizeof(struct mlx5_mprq_buf *); + } + tmpl = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, alloc_size, 0, socket); if (!tmpl) { rte_errno = ENOMEM; return NULL; @@ -1529,30 +1645,11 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, tmpl->socket = socket; if (dev->data->dev_conf.intr_conf.rxq) tmpl->irq = 1; - /* - * This Rx queue can be configured as a Multi-Packet RQ if all of the - * following conditions are met: - * - MPRQ is enabled. - * - The number of descs is more than the number of strides. - * - max_rx_pkt_len plus overhead is less than the max size - * of a stride or log_mprq_stride_size is specified by a user. - * Need to make sure that there are enough strides to encap - * the maximum packet size in case log_mprq_stride_size is set. - * Otherwise, enable Rx scatter if necessary. - */ - if (mprq_en && desc > RTE_BIT32(log_mprq_stride_nums) && - (non_scatter_min_mbuf_size <= - RTE_BIT32(config->mprq.log_max_stride_size) || - (config->mprq.log_stride_size && - non_scatter_min_mbuf_size <= mprq_stride_cap))) { + if (mprq_en) { /* TODO: Rx scatter isn't supported yet. */ tmpl->rxq.sges_n = 0; - /* Trim the number of descs needed. */ - desc >>= log_mprq_stride_nums; - tmpl->rxq.log_strd_num = config->mprq.log_stride_num ? - config->mprq.log_stride_num : log_mprq_stride_nums; - tmpl->rxq.log_strd_sz = config->mprq.log_stride_size ? - config->mprq.log_stride_size : log_mprq_stride_size; + tmpl->rxq.log_strd_num = mprq_log_actual_stride_num; + tmpl->rxq.log_strd_sz = mprq_log_actual_stride_size; tmpl->rxq.strd_shift_en = MLX5_MPRQ_TWO_BYTE_SHIFT; tmpl->rxq.strd_scatter_en = !!(offloads & DEV_RX_OFFLOAD_SCATTER); @@ -1561,11 +1658,6 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, max_lro_size = RTE_MIN(max_rx_pkt_len, RTE_BIT32(tmpl->rxq.log_strd_num) * RTE_BIT32(tmpl->rxq.log_strd_sz)); - DRV_LOG(DEBUG, - "port %u Rx queue %u: Multi-Packet RQ is enabled" - " strd_num_n = %u, strd_sz_n = %u", - dev->data->port_id, idx, - tmpl->rxq.log_strd_num, tmpl->rxq.log_strd_sz); } else if (tmpl->rxq.rxseg_n == 1) { MLX5_ASSERT(max_rx_pkt_len <= first_mb_free_size); tmpl->rxq.sges_n = 0; @@ -1599,24 +1691,6 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, tmpl->rxq.sges_n = sges_n; max_lro_size = max_rx_pkt_len; } - if (config->mprq.enabled && !mlx5_rxq_mprq_enabled(&tmpl->rxq)) - DRV_LOG(WARNING, - "port %u MPRQ is requested but cannot be enabled\n" - " (requested: pkt_sz = %u, desc_num = %u," - " rxq_num = %u, stride_sz = %u, stride_num = %u\n" - " supported: min_rxqs_num = %u," - " min_stride_sz = %u, max_stride_sz = %u).", - dev->data->port_id, non_scatter_min_mbuf_size, - desc, priv->rxqs_n, - config->mprq.log_stride_size ? - RTE_BIT32(config->mprq.log_stride_size) : - RTE_BIT32(log_mprq_stride_size), - config->mprq.log_stride_num ? - RTE_BIT32(config->mprq.log_stride_num) : - RTE_BIT32(log_mprq_stride_nums), - config->mprq.min_rxqs_num, - RTE_BIT32(config->mprq.log_min_stride_size), - RTE_BIT32(config->mprq.log_max_stride_size)); DRV_LOG(DEBUG, "port %u maximum number of segments per packet: %u", dev->data->port_id, 1 << tmpl->rxq.sges_n); if (desc % (1 << tmpl->rxq.sges_n)) { @@ -1674,17 +1748,14 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, dev->data->port_id, tmpl->rxq.crc_present ? "disabled" : "enabled", tmpl->rxq.crc_present << 2); - /* Save port ID. */ tmpl->rxq.rss_hash = !!priv->rss_conf.rss_hf && (!!(dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS)); tmpl->rxq.port_id = dev->data->port_id; tmpl->priv = priv; tmpl->rxq.mp = rx_seg[0].mp; tmpl->rxq.elts_n = log2above(desc); - tmpl->rxq.rq_repl_thresh = - MLX5_VPMD_RXQ_RPLNSH_THRESH(desc_n); - tmpl->rxq.elts = - (struct rte_mbuf *(*)[desc_n])(tmpl + 1); + tmpl->rxq.rq_repl_thresh = MLX5_VPMD_RXQ_RPLNSH_THRESH(desc_n); + tmpl->rxq.elts = (struct rte_mbuf *(*)[desc_n])(tmpl + 1); tmpl->rxq.mprq_bufs = (struct mlx5_mprq_buf *(*)[desc])(*tmpl->rxq.elts + desc_n); #ifndef RTE_ARCH_64 -- 2.25.1