Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp2044186lqp; Tue, 16 Apr 2024 06:05:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWWhQU0lua6k1uQmZx78UFW8BmjLOV47xkzKjG9VROaFBCQuNDk4NorBLyWtPJSbeB+Y6wbuaD+eIXYAU6yL7LXH+Xb1N4apUkbGcii6Q== X-Google-Smtp-Source: AGHT+IGVGWWeXC535tMngNsMSdMu5nk/zDBOsAClA75L4bFJ08JlCB5zntDjEOl+Z2FcO1djiiRC X-Received: by 2002:a17:906:7145:b0:a52:8a8a:593a with SMTP id z5-20020a170906714500b00a528a8a593amr2856783ejj.2.1713272712423; Tue, 16 Apr 2024 06:05:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713272712; cv=pass; d=google.com; s=arc-20160816; b=I9lXCGNZcU22lT/w0h7NoPqpaFfkVIan9zGZGVBWFZ2TUSIrRgk+fB6ROQxWZ1SSfS S6H1ds9eQwEC2DxdEV45etkYL4aE4Sc7PSxOTLacVpQ736JipIdWD7Bhbw/5jXt2THFN 4ZLbPgHqkE2I2oumjqejQDgAUqL1iHalll7auswMl7WVlLRE0MqrJYOnMiqVjXjkOPoV KC4BO0AxEKB8OirqZXyBRb3zuMrzgJlsjksJfPfbZvOQzkUaPkAKMHr9p3l/22qWOYjR 5qFRJEzokCjB1/fDPchpbFQ0Cm9lQInxfs2uu+293Dd2antDcGmymRGJ7V1k4mIVdS78 KFkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=vnCQbLIpTOLEYHqzI8xr5fU/2pXfqerUVIbsOB5PJDY=; fh=0JA9dyQ5L6srAaYI2Tr5G0NIlUbjCltCW+s+2Cct3Ew=; b=wyN7NL/ty4/Duba6yMDjR5UTR2qCRTCjaR/i8vnh2YEf+fQST4u/nHmmQCijC/3C7X NJHo4PN3OnGCXqLXEkadB58sx8fqNkDmZZ7Q27xcJ8K7mkcCqSOE4UhMK2ygmy6npRYH Ah1n8zya+cqT7k3G8RAON5lYoFADlI6Hj49+SRoOtXVN3KYthhLjCWD9tM5ruo3hom1J 7IajMfC4lAgrukq3CYGjiFlU5l+QiP/+jcorCjwsmIQXFfvumxrMH5aj8jreFWyybNaq gi9YR/nVyyi7f0bQlzm8/pxlkcz6ZCOGiPsfVzjo2Jb3gvqJh6v8Z4mMyGMPzPMFB1Su d16Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Ss/kIJQt"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-146846-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146846-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j15-20020a170906278f00b00a519ff1982csi5652135ejc.1018.2024.04.16.06.05.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 06:05:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146846-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Ss/kIJQt"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-146846-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146846-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2B2A41F219E8 for ; Tue, 16 Apr 2024 13:05:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4071B12BF29; Tue, 16 Apr 2024 13:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ss/kIJQt" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 518E112BF15 for ; Tue, 16 Apr 2024 13:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713272705; cv=none; b=o36FM4kQwgQIEfy3S/jhF2ndZ5K8hUGeb4OMZ1Sy5cXCgtfNptkBn2eaYyaGnkcV5eVg9+aFF6AmJJRJBXizFrJE+Zfyy/CGBga2ATgSMYIlmfgSYcE0CWp/lDDzA4vtBg7gX+qN6/o1ftWPgpNViCpJ61jKi0BxA1q09hmPldE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713272705; c=relaxed/simple; bh=UEzTGUe3r7acXf8Yb95hdOs5Y9KDHJwibjjQOPb+gas=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kJ6Myv/x5CFUyw4nsRiIrkcNMHfdcZod+KXGkElDksL8UJe43qxfpZJK7cBTT7jdVsMBmqYzxgp5yARvcqB9fyeuCwoY85hF5knpiHWvGP0SExF8HnqvEr0zP8u6GjJm3epBbtq/ZX3CdCK5BjooDVf8GzmFokbcexhxn5bth0Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ss/kIJQt; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713272700; x=1744808700; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=UEzTGUe3r7acXf8Yb95hdOs5Y9KDHJwibjjQOPb+gas=; b=Ss/kIJQt0zdXtxEjiSitKwj7zdB5qFc5n3xjBi1ZGBBafSqJ7h6TrYDJ 3YXhT6bUedorDPCFBZXFfCPZIaPeIo8sjZiv9UHyZPt3DSdjGZ7GEKZsw OGEd/+jF3rSGT6SefuYmXieE2BkmGDM9VpDQW0Y+Z0tcWIdAeZT0oeGKE v8YogGoMKIRA0l90ziYopg22AwajqeKw6fhpd9m0jXyoP22+TtXM/N3cS mLe2isZCuErAhXmsj9/m9i5FdfFBka0cIPfNR6cIdXuLSOChrYR7AiWPl O0+nsDJFlFUp3sIXlpCpk65J14i8SiSPtaGBV+nqO9P4aEWW/9fW1/TJK g==; X-CSE-ConnectionGUID: C09H0YPgQVO8g29tx/zPrQ== X-CSE-MsgGUID: ODC00vwjQ+SX1JYJ1SMIng== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8569445" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8569445" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 06:04:59 -0700 X-CSE-ConnectionGUID: fDp3iuRyQJiH1ahnVv75ZQ== X-CSE-MsgGUID: KKXIiKUHRK6bNxue6PaYcQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22321830" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa009.fm.intel.com with ESMTP; 16 Apr 2024 06:04:55 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id DDBE332EA4; Tue, 16 Apr 2024 14:04:50 +0100 (IST) From: Larysa Zaremba To: Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Cc: Larysa Zaremba , alan.brady@intel.com, maciej.fijalkowski@intel.com, jesse.brandeburg@intel.com, Emil Tantilov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lukasz Czapnik , Michal Swiatkowski Subject: [PATCH iwl-net] ice: Interpret .set_channels() input differently Date: Tue, 16 Apr 2024 14:58:54 +0200 Message-ID: <20240416125856.1263314-1-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A bug occurs because a safety check guarding AF_XDP-related queues in ethnl_set_channels(), does not trigger. This happens, because kernel and ice driver interpret the ethtool command differently. How the bug occurs: 1. ethtool -l -> combined: 40 2. Attach AF_XDP to queue 30 3. ethtool -L rx 15 tx 15 combined number is not specified, so command becomes {rx_count = 15, tx_count = 15, combined_count = 40}. 4. ethnl_set_channels checks, if there are any AF_XDP of queues from the new (combined_count + rx_count) to the old one, so from 55 to 40, check does not trigger. 5. ice interprets `rx 15 tx 15` as 15 combined channels and deletes the queue that AF_XDP is attached to. Interpret the command in a way that is more consistent with ethtool manual [0] (--show-channels and --set-channels). Considering that in the ice driver only the difference between RX and TX queues forms dedicated channels, change the correct way to set number of channels to: ethtool -L combined 10 /* For symmetric queues */ ethtool -L combined 8 tx 2 rx 0 /* For asymmetric queues */ [0] https://man7.org/linux/man-pages/man8/ethtool.8.html Fixes: 87324e747fde ("ice: Implement ethtool ops for channels") Reviewed-by: Michal Swiatkowski Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice_ethtool.c | 22 ++++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index 78b833b3e1d7..d91f41f61bce 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -3593,7 +3593,6 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch) struct ice_pf *pf = vsi->back; int new_rx = 0, new_tx = 0; bool locked = false; - u32 curr_combined; int ret = 0; /* do not support changing channels in Safe Mode */ @@ -3615,22 +3614,13 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch) return -EOPNOTSUPP; } - curr_combined = ice_get_combined_cnt(vsi); + if (!ch->combined_count) { + netdev_err(dev, "Please specify at least 1 combined channel\n"); + return -EINVAL; + } - /* these checks are for cases where user didn't specify a particular - * value on cmd line but we get non-zero value anyway via - * get_channels(); look at ethtool.c in ethtool repository (the user - * space part), particularly, do_schannels() routine - */ - if (ch->rx_count == vsi->num_rxq - curr_combined) - ch->rx_count = 0; - if (ch->tx_count == vsi->num_txq - curr_combined) - ch->tx_count = 0; - if (ch->combined_count == curr_combined) - ch->combined_count = 0; - - if (!(ch->combined_count || (ch->rx_count && ch->tx_count))) { - netdev_err(dev, "Please specify at least 1 Rx and 1 Tx channel\n"); + if (ch->rx_count && ch->tx_count) { + netdev_err(dev, "Dedicated RX or TX channels cannot be used simultaneously\n"); return -EINVAL; } -- 2.43.0