Received: by 10.192.165.156 with SMTP id m28csp60297imm; Tue, 10 Apr 2018 16:23:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/J3kzs1fubstgcQ10DCdXCiNzh8X9LniAZOEek9fVtkDpeDXvT7NyBi7OjE/wjWeW/SxXK X-Received: by 10.101.98.145 with SMTP id f17mr1620127pgv.398.1523402599975; Tue, 10 Apr 2018 16:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523402599; cv=none; d=google.com; s=arc-20160816; b=B+kWaJx1qJ3FqmTS6P0R5U7Ycz00tpPxashJIsk4PgTl9GxQNCtvNQqKeMFbFKfTTG KPWs/PkUR7KtFl/8n87ck9OjDa98ArXccpW/FDxK+EHmAb7NA1MQlsPrUUv3y0h3FnOV j2eSYaQO0UJfxfj5r5hfpO7dAVdQxNUZIFPo2fC6jzJ6BA5W4Lry4UIMUIisJmkZlh8H OQa4dGvvNW5cnIUoYW6EzxpJIgK3EGGTV11BLkHXc+jVuix/rbQ/fK+NJOp/1VHmXSKJ y+gYsDrQNG5lbo2QtapAYcFIR0e5XkKbeW+C4fxCnl0Lsqcfa6pi4ybUjhni6nSd52UO CkpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=pwq9imH/Xw/UtngZMSHAWxpWsAlzRytWo0IzHf56yXM=; b=gd3Skie1x+CcipjflMASz7XKuXuFc5Ga+eY+NAAv3lVZK/6ArVxnZIiunCRZgdI2P6 Wn0WVv0WR29wbjILGOMhb+NEKofQ19COW3wp5pCmyEYz5PXLdU/91ZXxy1vDD2wNxfm1 KGzUEDYbLVA/zClUAMz1aLh+yymEn7hcBA+Q8/4nxmV51nIVx6DfNMvNG9hVLafslECg AxjxwqfHmA4PII0HAkOYtDD5m/MvgSXF3ohPWNOwJZ9O46in8da6rVxkm+X/t3Y2riey sYBiXh5SjzWP9iIHKi2+o9o2vohd80RCVtrY8uGhC3jKD++aYIPuwp41QNb1faaJ2VLZ cX1A== ARC-Authentication-Results: i=1; mx.google.com; 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 q26si2492460pgd.280.2018.04.10.16.22.43; Tue, 10 Apr 2018 16:23:19 -0700 (PDT) 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; 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 S1754836AbeDJWbk (ORCPT + 99 others); Tue, 10 Apr 2018 18:31:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40442 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752802AbeDJWbg (ORCPT ); Tue, 10 Apr 2018 18:31:36 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EED76DE0; Tue, 10 Apr 2018 22:31:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Shemesh , Saeed Mahameed Subject: [PATCH 4.15 129/168] net/mlx5e: Verify coalescing parameters in range Date: Wed, 11 Apr 2018 00:24:31 +0200 Message-Id: <20180410212806.253071486@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Moshe Shemesh [ Upstream commit b392a2078b5e0094ff38aa0c9d2a31b3f607d4ef ] Add check of coalescing parameters received through ethtool are within range of values supported by the HW. Driver gets the coalescing rx/tx-usecs and rx/tx-frames as set by the users through ethtool. The ethtool support up to 32 bit value for each. However, mlx5 modify cq limits the coalescing time parameter to 12 bit and coalescing frames parameters to 16 bits. Return out of range error if user tries to set these parameters to higher values. Fixes: f62b8bb8f2d3 ('net/mlx5: Extend mlx5_core to support ConnectX-4 Ethernet functionality') Signed-off-by: Moshe Shemesh Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -492,6 +492,9 @@ static int mlx5e_get_coalesce(struct net return mlx5e_ethtool_get_coalesce(priv, coal); } +#define MLX5E_MAX_COAL_TIME MLX5_MAX_CQ_PERIOD +#define MLX5E_MAX_COAL_FRAMES MLX5_MAX_CQ_COUNT + static void mlx5e_set_priv_channels_coalesce(struct mlx5e_priv *priv, struct ethtool_coalesce *coal) { @@ -526,6 +529,20 @@ int mlx5e_ethtool_set_coalesce(struct ml if (!MLX5_CAP_GEN(mdev, cq_moderation)) return -EOPNOTSUPP; + if (coal->tx_coalesce_usecs > MLX5E_MAX_COAL_TIME || + coal->rx_coalesce_usecs > MLX5E_MAX_COAL_TIME) { + netdev_info(priv->netdev, "%s: maximum coalesce time supported is %lu usecs\n", + __func__, MLX5E_MAX_COAL_TIME); + return -ERANGE; + } + + if (coal->tx_max_coalesced_frames > MLX5E_MAX_COAL_FRAMES || + coal->rx_max_coalesced_frames > MLX5E_MAX_COAL_FRAMES) { + netdev_info(priv->netdev, "%s: maximum coalesced frames supported is %lu\n", + __func__, MLX5E_MAX_COAL_FRAMES); + return -ERANGE; + } + mutex_lock(&priv->state_lock); new_channels.params = priv->channels.params;