From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A70AEF36C39 for ; Mon, 20 Apr 2026 07:21:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5D3C860A68; Mon, 20 Apr 2026 07:21:00 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id joFICKa5jRzQ; Mon, 20 Apr 2026 07:20:59 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7510161034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1776669659; bh=ClvZ9benTKjETyOZ0inLJRRBMJYiuwXqm8O995zXYZQ=; h=Date:From:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Mzz3gGjD6Y4jH+eCkh3rQfpEFv9ashIJ8f5IsHh7aw2G03f4rO50+5s/RZgQKXjrv 8wgVIeDwWyJ71ETSl2t59nnh9FiAImtC95oQtxxlyILdeslb/FoxPrdAPwBzkLCYIG PL6r33pjMgNO+NbJ0yd2zbvcWnBbB5TjEpkBCYfzuvmUF2J8rZJhqeiLjLF1EuaefW SDL2fUUZM+jm7yQARwIXB/zlFoVXRN0KIsPJqdxWeO1Q0upgbjI1MppzpCi7iXeLFm +NUnKcU7EZCsqTA16jI136efKGR+31MnlIjD66RIJB1A9P1tTJbH67y/DZzgT3N2Fq oeyMEjCdLhozw== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id 7510161034; Mon, 20 Apr 2026 07:20:59 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists1.osuosl.org (Postfix) with ESMTP id B52EE259 for ; Mon, 20 Apr 2026 07:20:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id B31A9409F0 for ; Mon, 20 Apr 2026 07:20:58 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id S66InPKkxUIF for ; Mon, 20 Apr 2026 07:20:57 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2600:3c04:e001:324:0:1991:8:25; helo=tor.source.kernel.org; envelope-from=horms@kernel.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org B509D409D7 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B509D409D7 Received: from tor.source.kernel.org (tor.source.kernel.org [IPv6:2600:3c04:e001:324:0:1991:8:25]) by smtp4.osuosl.org (Postfix) with ESMTPS id B509D409D7 for ; Mon, 20 Apr 2026 07:20:57 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id D177160103; Mon, 20 Apr 2026 07:20:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C2C9C2BCB3; Mon, 20 Apr 2026 07:20:53 +0000 (UTC) Date: Mon, 20 Apr 2026 08:20:50 +0100 From: Simon Horman To: Maciej Fijalkowski Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, magnus.karlsson@intel.com, kuba@kernel.org, pabeni@redhat.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com Message-ID: <20260420072050.GP280379@horms.kernel.org> References: <20260416114046.642171-1-maciej.fijalkowski@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260416114046.642171-1-maciej.fijalkowski@intel.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776669655; bh=xDlIjLHGAoKn1DuIwoxmC7n5/0GRJIGPQDQkQQ26XZc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MwBbCURPXqrGD6Y9j2/rkAyKYBLYphz6v41HmH9c6GV+aaRSMss4KU8Q3FV+eqRa9 ZaDhMZVhnEQY6Krjb27xW9ttVH9l7L5S8vwUV86/2OxShpWcPfJBNw28pnJaKwU2IT OhC6cNZ5MSLAcaw9exOeYtEzW/W3VYFlo4LJVCj3BGRZww444U/4eDuOotLsIGi3mU uG4XO543jLui8+8Mp/8WDGFXUmEK4Njy4Pp3akJcrVaihWCslAP+4uQOQFsJKVEMUH X2+DIODPqdv1bos6WYTZMrDxZf1BTXzcC8m84zKAwSXHhHL/k2QuiOQ2gQxsi4UJ1U DqWLw8ACbUeUw== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=MwBbCURP Subject: Re: [Intel-wired-lan] [PATCH v2 iwl-net] i40e: keep q_vectors array in sync with channel count changes X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Thu, Apr 16, 2026 at 01:40:46PM +0200, Maciej Fijalkowski wrote: > For the main VSI, i40e_set_num_rings_in_vsi() always derives > num_q_vectors from pf->num_lan_msix. At the same time, ethtool -L stores > the user requested channel count in vsi->req_queue_pairs and the queue > setup path uses that value for the effective number of queue pairs. > > This leaves queue and vector counts out of sync after shrinking channel > count via ethtool -L. The active queue configuration is reduced, but the > VSI still keeps the full PF-sized q_vector topology. > > That mismatch breaks reconfiguration flows which rely on vector/NAPI > state matching the effective channel configuration. In particular, > toggling /sys/class/net//threaded after reducing the channel count > can hang, and later channel-count changes can fail because VSI reinit > does not rebuild q_vectors to match the new vector count. > > Fix this by making the main VSI num_q_vectors follow the effective > requested channel count, capped by the available MSI-X vectors. Update > i40e_vsi_reinit_setup() to rebuild q_vectors during VSI reinit so the > vector topology is refreshed together with the ring arrays when channel > count changes. > > Keep alloc_queue_pairs unchanged and based on pf->num_lan_qps so the VSI > retains its full queue capacity. > > Selftest napi_threaded.py was originally used when Jakub reported hang > on /sys/class/net//threaded toggle. In order to make it pass on > i40e, use persistent NAPI configuration for q_vector NAPIs so NAPI > identity and threaded settings survive q_vector reallocation across > channel-count changes. This is achieved by using netif_napi_add_config() > when configuring q_vectors. > > $ export NETIF=ens259f1np1 > $ sudo -E env PATH="$PATH" ./tools/testing/selftests/drivers/net/napi_threaded.py > TAP version 13 > 1..3 > ok 1 napi_threaded.napi_init > ok 2 napi_threaded.change_num_queues > ok 3 napi_threaded.enable_dev_threaded_disable_napi_threaded > Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0 > > Reported-by: Jakub Kicinski > Closes: https://lore.kernel.org/intel-wired-lan/20260316133100.6054a11f@kernel.org/ > Fixes: d2a69fefd756 ("i40e: Fix changing previously set num_queue_pairs for PFs") > Signed-off-by: Maciej Fijalkowski > --- > v2: > - NULL vsi->tx_rings in i40e_vsi_alloc_arrays() (Sashiko) Reviewed-by: Simon Horman > --- > drivers/net/ethernet/intel/i40e/i40e_main.c | 35 +++++++++++++++++---- > 1 file changed, 29 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c > index 926d001b2150..1d2a4181966f 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_main.c > +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c > @@ -11403,10 +11403,14 @@ static void i40e_service_timer(struct timer_list *t) > static int i40e_set_num_rings_in_vsi(struct i40e_vsi *vsi) > { > struct i40e_pf *pf = vsi->back; > + u16 qps; > > switch (vsi->type) { > case I40E_VSI_MAIN: > vsi->alloc_queue_pairs = pf->num_lan_qps; > + qps = vsi->req_queue_pairs ? > + min_t(u16, vsi->req_queue_pairs, pf->num_lan_qps) : nit: It looks all the variables involved here u16. So min() can be used instead of min_t(). > + pf->num_lan_qps; > if (!vsi->num_tx_desc) > vsi->num_tx_desc = ALIGN(I40E_DEFAULT_NUM_DESCRIPTORS, > I40E_REQ_DESCRIPTOR_MULTIPLE); > @@ -11414,7 +11418,8 @@ static int i40e_set_num_rings_in_vsi(struct i40e_vsi *vsi) > vsi->num_rx_desc = ALIGN(I40E_DEFAULT_NUM_DESCRIPTORS, > I40E_REQ_DESCRIPTOR_MULTIPLE); > if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) > - vsi->num_q_vectors = pf->num_lan_msix; > + vsi->num_q_vectors = max_t(int, 1, > + min_t(int, qps, pf->num_lan_msix)); nit: On the left side, all values seem to be either constants or u16. So I think you can use clamp() here, and simply assign the resulting value to num_q_vectors, which is an int. > else > vsi->num_q_vectors = 1; > ... > @@ -14265,12 +14272,27 @@ static struct i40e_vsi *i40e_vsi_reinit_setup(struct i40e_vsi *vsi) > > pf = vsi->back; > > + if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) { > + i40e_put_lump(pf->irq_pile, vsi->base_vector, vsi->idx); > + vsi->base_vector = 0; > + } > + > i40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx); > i40e_vsi_clear_rings(vsi); > > - i40e_vsi_free_arrays(vsi, false); > + i40e_vsi_free_q_vectors(vsi); > + i40e_vsi_free_arrays(vsi, true); nit: with this patch applied the free_vectors argument (the 2nd parameter) of i40e_vsi_free_arrays is always passed as true by callers. So I think that, as a follow-up, it can be removed. Similarly for i40e_vsi_alloc_arrays. > i40e_set_num_rings_in_vsi(vsi); > - ret = i40e_vsi_alloc_arrays(vsi, false); > + > + ret = i40e_vsi_alloc_arrays(vsi, true); > + if (ret) > + goto err_vsi; > + > + /* Rebuild q_vectors during VSI reinit because the effective channel > + * count may change num_q_vectors. Keep vector topology aligned with the > + * queue configuration after ethtool's .set_channels() callback. > + */ > + ret = i40e_vsi_setup_vectors(vsi); > if (ret) > goto err_vsi; > ...