Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6024038ybc; Wed, 27 Nov 2019 13:35:35 -0800 (PST) X-Google-Smtp-Source: APXvYqxTrkJGKbks2HoyCdRdXXC9SiKMEL8cLgEjgYJ4+hqltES/4WGywwjchTIVHvUilkRgpko7 X-Received: by 2002:a17:906:3606:: with SMTP id q6mr50183057ejb.307.1574890535114; Wed, 27 Nov 2019 13:35:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890535; cv=none; d=google.com; s=arc-20160816; b=gYKyhW0V0P6Desr1ddevBbdrM3gwWQFJ9EjBINDlqo9RTsn0vYLtK8l1cgngPe/9jP wLlXswO11lGn0btOHU6We4rAjTsOcpCqqHVcPc774e1L2D7JSTYcJoYzXwcLbSvgcTGq jS6zR/8+WuRxruwh0q3MWnFF3XZToCi+I1Wjn7CLS3ZdMRc+ByEMW0e1Sx8jLvB/vH23 uk4pju8uRPptrWKPQvamgNGv74qifIoRCiAzpaYLjR1JNuBMm39g7GYjEc72ui+Tll3O LOllzGvFATK/XNdSonhaJXmdkQI9CpwX00F2P4l87e+Uf/22auDKkuNxo9ey2TMfpoje /YxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fMmgWjkrU8WcbMuPk2/TJBWczykQYfpM77F7NCX3QFk=; b=SqMB/2L5lR790m+yQJLLJYLYbqJje+Hmrx5jELRkgupHH7XqWESmYyf+K+lyZ0EmPL emjMhe1eKj4lbDJ5kPXLp0TjOauMt5amJPmP8E+RwE0PaUw8nntryA//qf8azPIZ7eX9 JgWrLT1mmPGcP6LkTfVqIbJZpf2bomZXEBv90hqZ1vOumuz62UuBFXRBb5vHucvGJ7kY GnqBVuf8VmjZwxTm8HRVTCo2OeWM583waIE9TUIw2oT++J9YCQHkcEaf1/tn2p0ZQp7J kZKlLJEVXkqfyy/wLUovGiEwXSCeUVhRht0s1F2FospaEo6hvnbVCXdOrTS74VgXfVF/ BYJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l8xtkeL5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n9si665893ejc.119.2019.11.27.13.35.10; Wed, 27 Nov 2019 13:35:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l8xtkeL5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730943AbfK0UzV (ORCPT + 99 others); Wed, 27 Nov 2019 15:55:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:45710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730937AbfK0UzQ (ORCPT ); Wed, 27 Nov 2019 15:55:16 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B5232070B; Wed, 27 Nov 2019 20:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888115; bh=blL2aDoHMdLG65fkrbWhUYWBxVjCgv/p6v3dzAKgrRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l8xtkeL5mBBWqLctjXyfCJY9K0NZPBMLJLtPhoIguc9Ouhf6eOO4EBItB7FEIsS1+ Ul+1EW1469TtwmdZhmQeTtp2dTNrOWSMuuSI2sFK4bmxOCJHLzhg+CWE3OSxv17CRH cFjqlzlLnrwNyVX9M9m2T9g0o5Uiixb1Iv+ZsbLg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tariq Toukan , "David S. Miller" Subject: [PATCH 4.19 003/306] net/mlx4_en: Fix wrong limitation for number of TX rings Date: Wed, 27 Nov 2019 21:27:33 +0100 Message-Id: <20191127203115.010578056@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tariq Toukan [ Upstream commit 2744bf42680f64ebf2ee8a00354897857c073331 ] XDP_TX rings should not be limited by max_num_tx_rings_p_up. To make sure total number of TX rings never exceed MAX_TX_RINGS, add similar check in mlx4_en_alloc_tx_queue_per_tc(), where a new value is assigned for num_up. Fixes: 7e1dc5e926d5 ("net/mlx4_en: Limit the number of TX rings") Signed-off-by: Tariq Toukan Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 8 ++++---- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c @@ -1812,6 +1812,7 @@ static int mlx4_en_set_channels(struct n struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_port_profile new_prof; struct mlx4_en_priv *tmp; + int total_tx_count; int port_up = 0; int xdp_count; int err = 0; @@ -1826,13 +1827,12 @@ static int mlx4_en_set_channels(struct n mutex_lock(&mdev->state_lock); xdp_count = priv->tx_ring_num[TX_XDP] ? channel->rx_count : 0; - if (channel->tx_count * priv->prof->num_up + xdp_count > - priv->mdev->profile.max_num_tx_rings_p_up * priv->prof->num_up) { + total_tx_count = channel->tx_count * priv->prof->num_up + xdp_count; + if (total_tx_count > MAX_TX_RINGS) { err = -EINVAL; en_err(priv, "Total number of TX and XDP rings (%d) exceeds the maximum supported (%d)\n", - channel->tx_count * priv->prof->num_up + xdp_count, - MAX_TX_RINGS); + total_tx_count, MAX_TX_RINGS); goto out; } --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -92,6 +92,7 @@ int mlx4_en_alloc_tx_queue_per_tc(struct struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_port_profile new_prof; struct mlx4_en_priv *tmp; + int total_count; int port_up = 0; int err = 0; @@ -105,6 +106,14 @@ int mlx4_en_alloc_tx_queue_per_tc(struct MLX4_EN_NUM_UP_HIGH; new_prof.tx_ring_num[TX] = new_prof.num_tx_rings_p_up * new_prof.num_up; + total_count = new_prof.tx_ring_num[TX] + new_prof.tx_ring_num[TX_XDP]; + if (total_count > MAX_TX_RINGS) { + err = -EINVAL; + en_err(priv, + "Total number of TX and XDP rings (%d) exceeds the maximum supported (%d)\n", + total_count, MAX_TX_RINGS); + goto out; + } err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof, true); if (err) goto out;