From patchwork Tue Nov 7 22:58:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Keller X-Patchwork-Id: 1861344 X-Patchwork-Delegate: anthony.l.nguyen@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=wFDIh7MW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SQ3Ys2MD5z1yQl for ; Wed, 8 Nov 2023 09:59:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 4F5A3417A7; Tue, 7 Nov 2023 22:59:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 4F5A3417A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1699397951; bh=4uVbTbrGsMIpArPUGDnAyu1wmgPXDOaQ899TpIAwgVU=; h=From:To:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Cc:From; b=wFDIh7MWJrEYsFiXQrcM21kAX8iaMK0J1KbikKivI2CnG2Q8atJDpDQAy6b6SGrFD 8EScboLMFiQoJePkEQTspkO1d3JmHlV3VWO+s2SYn1zHSEoOBI3Q8MkrXdBh2v0mRX hSCFnYKuhQxfGoVwMBb6m/S4Bq828BPL+Ko1k0WV3mDWxs49yivSo14dZ7xVxUbKj2 Il5yZQJLO+BtNgyImUq/4ItYhEwMEixzMCIl8V5MJiEzQ5brwz6vIhyy9xvwJgA4t1 3W5TjQfe6Z8OOTitmE3OyYZNZw3axqA60TAHYE1BioOi+Lclf+FWSDl4Eupm6ZeQoS 3LymwlntDuhNA== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oj1soqW642lD; Tue, 7 Nov 2023 22:59:10 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 358C3417A9; Tue, 7 Nov 2023 22:59:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 358C3417A9 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 4EF741BF215 for ; Tue, 7 Nov 2023 22:59:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 2676560D53 for ; Tue, 7 Nov 2023 22:59:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2676560D53 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lr9DTF9QiEtO for ; Tue, 7 Nov 2023 22:59:06 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by smtp3.osuosl.org (Postfix) with ESMTPS id 75D5C60B1D for ; Tue, 7 Nov 2023 22:59:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 75D5C60B1D X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="8293328" X-IronPort-AV: E=Sophos;i="6.03,284,1694761200"; d="scan'208";a="8293328" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2023 14:59:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="1094310946" X-IronPort-AV: E=Sophos;i="6.03,284,1694761200"; d="scan'208";a="1094310946" Received: from jekeller-desk.amr.corp.intel.com (HELO jekeller-desk.jekeller.internal) ([10.166.241.1]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2023 14:59:03 -0800 From: Jacob Keller To: Intel Wired LAN Date: Tue, 7 Nov 2023 14:58:59 -0800 Message-ID: <20231107225859.1042860-1-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699397947; x=1730933947; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=htYZvsoC1ixlFPNciHtNSNWjM7gM/EjRWTomSwyROCw=; b=PTRzSf3d1Q4Z7ojSSgUGLnCGXen9HPpyYYonSp80uzS7N/Oi63g6ELjt iC41GYYvFilXwhHioaZoa+bV81Zam2XjE/Os8ewIwV04WnxshTQqaaTHz /RNgEBwOio21+TIXT2+3bRUvX+yRuIhSBPTmLwf+2HkFbLppjfTrtW5qi m5rrTlKhXOFjQ0oNgUxPPTrVum3cXMthwkk4XAuvf2+42gZmkO5HtZe/M C4MvXf869F9gTYB8z6O7GFaeT2yQ9bdhBd4AxYHUqaahgb34scJrwUVMd RgTVts2ZjrKyGq2vOVMp3XM8XKY+OYvBlO9vcvz+deY2HxlUPQCCANoTB A==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=PTRzSf3d Subject: [Intel-wired-lan] [PATCH iwl-net] iavf: validate tx_coalesce_usecs even if rx_coalesce_usecs is zero X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jacob Keller , Przemek Kitszel , Anthony Nguyen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" In __iavf_set_coalesce, the driver checks both ec->rx_coalesce_usecs and ec->tx_coalesce_usecs for validity. It does this via a chain if if/else-if blocks. If every single branch of the series of if statements exited, this would be fine. However, the rx_coalesce_usecs is checked against zero to print an informative message if use_adaptive_rx_coalesce is enabled. If this check is true, it short circuits the entire chain of statements, preventing validation of the tx_coalesce_usecs field. For example, the following ethtool command would allow programming a tx-usecs value outside the expected range: $ ethtool -C ens260f0v2 rx-usecs 0 tx-usecs 15000 adaptive-rx off adaptive-tx-off As far as I can tell from code review, the result is the tx-usecs value getting bitwise truncated to fit the ITR register mask, incorrectly programming the Tx ITR value. In addition, since commit e792779e6b63 ("iavf: Prevent changing static ITR values if adaptive moderation is on") the iavf driver actually rejects any change to the tx_coalesce_usecs or rx_coalesce_usecs when use_adaptive_tx_coalesce or use_adaptive_rx_coalesce is enabled. This check happens later in iavf_set_itr_per_queue(). The end result is that the existing check for adaptive-rx is irrelevant. Fix this error by removing the unnecessary and redundant checks for use_adaptive_rx_coalesce and use_adaptive_tx_coalesce, preventing the short curcuit and ensuring that both the Tx and Rx ITR values are validated. Fixes: 65e87c0398f5 ("i40evf: support queue-specific settings for interrupt moderation") Signed-off-by: Jacob Keller Reviewed-by: Przemek Kitszel --- drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) base-commit: 21e5fd91eadd2d98429abcfc9e584ffb0bccd38f diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c index 6f236d1a6444..ee1702854451 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c +++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c @@ -827,16 +827,10 @@ static int __iavf_set_coalesce(struct net_device *netdev, struct iavf_adapter *adapter = netdev_priv(netdev); int i; - if (ec->rx_coalesce_usecs == 0) { - if (ec->use_adaptive_rx_coalesce) - netif_info(adapter, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n"); - } else if ((ec->rx_coalesce_usecs < IAVF_MIN_ITR) || - (ec->rx_coalesce_usecs > IAVF_MAX_ITR)) { + if ((ec->rx_coalesce_usecs < IAVF_MIN_ITR) || + (ec->rx_coalesce_usecs > IAVF_MAX_ITR)) { netif_info(adapter, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n"); return -EINVAL; - } else if (ec->tx_coalesce_usecs == 0) { - if (ec->use_adaptive_tx_coalesce) - netif_info(adapter, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n"); } else if ((ec->tx_coalesce_usecs < IAVF_MIN_ITR) || (ec->tx_coalesce_usecs > IAVF_MAX_ITR)) { netif_info(adapter, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n");