Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2056417imm; Thu, 24 May 2018 05:11:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrkZr+OtjwNEjb8chsYvzd8zh14bu4rwYmr+UHFwVYpDiH6p80JBcohw3KR8h6D0tOaGkOC X-Received: by 2002:a17:902:ba93:: with SMTP id k19-v6mr6941587pls.379.1527163871115; Thu, 24 May 2018 05:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527163871; cv=none; d=google.com; s=arc-20160816; b=rCY3d8dHoaH43NLIOXNEvYijjeKs+kyGi7C6lf27kBygSqRAbK/s/iRPmNjpwMAJNd LFjyoKRcDf7avVY4d3qWI0A3aTEODA/mU5G5dV1Sd/Mf0ckmnFlZ7DUOJ/T9nSGE1xhT l9YbqkGiqQDtdXZ+V2u3PqmBSk6L4u447xi2vDB3CMk56nwkUM5rLvZjLBsfJUBpXTIu sGMfpVgTa8Ozghb5In2W62LflHFHa0O8NKaxdUogp73rX78nj6p/t5QeZgMrhbJQfdMz EGP+Ao0Kf+7PxEOegwonvc+j/FlX3UGRjS/zSSiwzEnEvQUcUYVHqs0NHaqs4r/Ek28m QUCA== 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:dkim-signature :arc-authentication-results; bh=K4gfc8QDThRcqW/J9bzMVoUnVRcVrSWRzfhivSIAoDg=; b=WikP+o7kNZKdBWO1HvCMcy5VSu20ToZHEVSVHzyp1iWCD/KaAzQxNbcRIntWt57hZI culrEwfW8ZMpZlFGZJJcPCA4Nu917pqy86zn21l3oUpx8d5y0fUYCMKeUKxfIieIkCnb 3iBsqwUdHlsO4zrA8RQJ8UpgN+a2qS0Sddr/UstRR5RXFaxdf6e2Mf33go7i9DBE19uW /6dXJbETBWf5TfFc69x5gjuVQi3PYIqgqWpIb8pbAQ32mCbt48F/0e9b5pcPkxPyyLg1 gj4cJkQoeYfY5Oq0/d7Y0doFUFs2EffJ9HM7u/4FEcJdbajgJ3Zn1oyK+Na16ifwMpal 3ONA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gRV3PFKW; 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 k82-v6si21791721pfj.302.2018.05.24.05.10.50; Thu, 24 May 2018 05:11:11 -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; dkim=pass header.i=@kernel.org header.s=default header.b=gRV3PFKW; 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 S969567AbeEXMIo (ORCPT + 99 others); Thu, 24 May 2018 08:08:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:55014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966353AbeEXJnh (ORCPT ); Thu, 24 May 2018 05:43:37 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 1EE372089F; Thu, 24 May 2018 09:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155016; bh=lRRLu9beSxMMmyoZ8rsCJcnbnLeXPFEcGrm2F8OXaZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gRV3PFKW6WGNoVjkh4fBzN0JlQm6rthGYwoLcdeQYtyu0EV3PmefqJRB++YQjvD96 2dh8LL624fyGT2xqKqwgMcitrp/xdVivNtfxy4jIMh7EQWxpiGrbrHKl3pkZRJUH/+ UlWow8iNoHCAI6WFQEPP3nycuzTEDF3wN4MY1/vo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Shemesh , Tariq Toukan , "David S. Miller" Subject: [PATCH 4.4 07/92] net/mlx4_en: Verify coalescing parameters are in range Date: Thu, 24 May 2018 11:37:44 +0200 Message-Id: <20180524093159.933798620@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Moshe Shemesh [ Upstream commit 6ad4e91c6d796b38a7f0e724db1de28eeb122bad ] 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, mlx4 modify cq limits the coalescing time parameter and coalescing frames parameters to 16 bits. Return out of range error if user tries to set these parameters to higher values. Change type of sample-interval and adaptive_rx_coal parameters in mlx4 driver to u32 as the ethtool holds them as u32 and these parameters are not limited due to mlx4 HW. Fixes: c27a02cd94d6 ('mlx4_en: Add driver for Mellanox ConnectX 10GbE NIC') Signed-off-by: Moshe Shemesh 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 | 16 ++++++++++++++++ drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c @@ -967,6 +967,22 @@ static int mlx4_en_set_coalesce(struct n if (!coal->tx_max_coalesced_frames_irq) return -EINVAL; + if (coal->tx_coalesce_usecs > MLX4_EN_MAX_COAL_TIME || + coal->rx_coalesce_usecs > MLX4_EN_MAX_COAL_TIME || + coal->rx_coalesce_usecs_low > MLX4_EN_MAX_COAL_TIME || + coal->rx_coalesce_usecs_high > MLX4_EN_MAX_COAL_TIME) { + netdev_info(dev, "%s: maximum coalesce time supported is %d usecs\n", + __func__, MLX4_EN_MAX_COAL_TIME); + return -ERANGE; + } + + if (coal->tx_max_coalesced_frames > MLX4_EN_MAX_COAL_PKTS || + coal->rx_max_coalesced_frames > MLX4_EN_MAX_COAL_PKTS) { + netdev_info(dev, "%s: maximum coalesced frames supported is %d\n", + __func__, MLX4_EN_MAX_COAL_PKTS); + return -ERANGE; + } + priv->rx_frames = (coal->rx_max_coalesced_frames == MLX4_EN_AUTO_CONF) ? MLX4_EN_RX_COAL_TARGET : --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -140,6 +140,9 @@ enum { #define MLX4_EN_TX_COAL_PKTS 16 #define MLX4_EN_TX_COAL_TIME 0x10 +#define MLX4_EN_MAX_COAL_PKTS U16_MAX +#define MLX4_EN_MAX_COAL_TIME U16_MAX + #define MLX4_EN_RX_RATE_LOW 400000 #define MLX4_EN_RX_COAL_TIME_LOW 0 #define MLX4_EN_RX_RATE_HIGH 450000 @@ -518,8 +521,8 @@ struct mlx4_en_priv { u16 rx_usecs_low; u32 pkt_rate_high; u16 rx_usecs_high; - u16 sample_interval; - u16 adaptive_rx_coal; + u32 sample_interval; + u32 adaptive_rx_coal; u32 msg_enable; u32 loopback_ok; u32 validate_loopback;