{"id":2223919,"url":"http://patchwork.ozlabs.org/api/patches/2223919/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20260416114046.642171-1-maciej.fijalkowski@intel.com/","project":{"id":46,"url":"http://patchwork.ozlabs.org/api/projects/46/?format=json","name":"Intel Wired Ethernet development","link_name":"intel-wired-lan","list_id":"intel-wired-lan.osuosl.org","list_email":"intel-wired-lan@osuosl.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260416114046.642171-1-maciej.fijalkowski@intel.com>","list_archive_url":null,"date":"2026-04-16T11:40:46","name":"[v2,iwl-net] i40e: keep q_vectors array in sync with channel count changes","commit_ref":null,"pull_url":null,"state":"under-review","archived":false,"hash":"966eee09dc93d70ce546932ba2548af8f23570b9","submitter":{"id":77750,"url":"http://patchwork.ozlabs.org/api/people/77750/?format=json","name":"Maciej Fijalkowski","email":"maciej.fijalkowski@intel.com"},"delegate":{"id":109701,"url":"http://patchwork.ozlabs.org/api/users/109701/?format=json","username":"anguy11","first_name":"Anthony","last_name":"Nguyen","email":"anthony.l.nguyen@intel.com"},"mbox":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20260416114046.642171-1-maciej.fijalkowski@intel.com/mbox/","series":[{"id":500139,"url":"http://patchwork.ozlabs.org/api/series/500139/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=500139","date":"2026-04-16T11:40:46","name":"[v2,iwl-net] i40e: keep q_vectors array in sync with channel count changes","version":2,"mbox":"http://patchwork.ozlabs.org/series/500139/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223919/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223919/checks/","tags":{},"related":[],"headers":{"Return-Path":"<intel-wired-lan-bounces@osuosl.org>","X-Original-To":["incoming@patchwork.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256\n header.s=default header.b=efc82skf;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org\n (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org;\n envelope-from=intel-wired-lan-bounces@osuosl.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fxGLh1gyTz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 21:41:32 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby smtp3.osuosl.org (Postfix) with ESMTP id 80CD86070A;\n\tThu, 16 Apr 2026 11:41:30 +0000 (UTC)","from smtp3.osuosl.org ([127.0.0.1])\n by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id hb44vOCPzeOw; Thu, 16 Apr 2026 11:41:28 +0000 (UTC)","from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142])\n\tby smtp3.osuosl.org (Postfix) with ESMTP id 342FB606ED;\n\tThu, 16 Apr 2026 11:41:28 +0000 (UTC)","from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133])\n by lists1.osuosl.org (Postfix) with ESMTP id C4E83775\n for <intel-wired-lan@lists.osuosl.org>; Thu, 16 Apr 2026 11:41:26 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n by smtp2.osuosl.org (Postfix) with ESMTP id C2890401F1\n for <intel-wired-lan@lists.osuosl.org>; Thu, 16 Apr 2026 11:41:26 +0000 (UTC)","from smtp2.osuosl.org ([127.0.0.1])\n by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id eJYiznHC06OJ for <intel-wired-lan@lists.osuosl.org>;\n Thu, 16 Apr 2026 11:41:26 +0000 (UTC)","from mgamail.intel.com (mgamail.intel.com [198.175.65.9])\n by smtp2.osuosl.org (Postfix) with ESMTPS id BE9D440090\n for <intel-wired-lan@lists.osuosl.org>; Thu, 16 Apr 2026 11:41:25 +0000 (UTC)","from fmviesa003.fm.intel.com ([10.60.135.143])\n by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 16 Apr 2026 04:41:25 -0700","from boxer.igk.intel.com ([10.102.20.173])\n by fmviesa003.fm.intel.com with ESMTP; 16 Apr 2026 04:41:22 -0700"],"X-Virus-Scanned":["amavis at osuosl.org","amavis at osuosl.org"],"X-Comment":"SPF check N/A for local connections - client-ip=140.211.166.142;\n helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org;\n receiver=<UNKNOWN> ","DKIM-Filter":["OpenDKIM Filter v2.11.0 smtp3.osuosl.org 342FB606ED","OpenDKIM Filter v2.11.0 smtp2.osuosl.org BE9D440090"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org;\n\ts=default; t=1776339688;\n\tbh=3ptfaCSm6aZm5Znb81Ir3ZJG89qd3UmPh7vq0Bz/wus=;\n\th=From:To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive:\n\t List-Post:List-Help:List-Subscribe:From;\n\tb=efc82skf44aQBnrKXn97R+YJKEMB/yUUVyJqAVAJ7izZRz/rj8AeSTP7mtkV+Ynwo\n\t p+dHJHny1RtdLq7W1f6mAbHBhhrU76RhYm4PttzLtgUyObV1UhTTFBSd5/3TmiWefd\n\t y9VMVGOFgxZbWAjVURvMWKGjvXB12txHQqpdFs0xu69d5v2oXPJ86K7aEe51W3410t\n\t vYpLwRr9ZzfhqH0xqpzlearAKsUrOOyrYA18h4PBYg0DJC/qZtUGEzYe+fg49kp+jC\n\t 2QOovKAXGZxqY8VvcIEvPS6pzal4sw/Ji0LZ69x5jpmqtqlvYky2mtbt9u3LmOguKa\n\t 1WY4CmJ2QiClA==","Received-SPF":"Pass (mailfrom) identity=mailfrom; client-ip=198.175.65.9;\n helo=mgamail.intel.com; envelope-from=maciej.fijalkowski@intel.com;\n receiver=<UNKNOWN>","DMARC-Filter":"OpenDMARC Filter v1.4.2 smtp2.osuosl.org BE9D440090","X-CSE-ConnectionGUID":["ZCzfBvwBR9+ncO3mxy9WtQ==","jQpeRK5QSQyLp0VQSae5vQ=="],"X-CSE-MsgGUID":["7fv4R7LnSUyPGCcNjTAjsg==","Hetdm5XdReep7vSmta5tYw=="],"X-IronPort-AV":["E=McAfee;i=\"6800,10657,11760\"; a=\"99984334\"","E=Sophos;i=\"6.23,181,1770624000\"; d=\"scan'208\";a=\"99984334\""],"X-ExtLoop1":"1","From":"Maciej Fijalkowski <maciej.fijalkowski@intel.com>","To":"intel-wired-lan@lists.osuosl.org","Cc":"netdev@vger.kernel.org, magnus.karlsson@intel.com, kuba@kernel.org,\n pabeni@redhat.com, horms@kernel.org, przemyslaw.kitszel@intel.com,\n jacob.e.keller@intel.com, Maciej Fijalkowski <maciej.fijalkowski@intel.com>","Date":"Thu, 16 Apr 2026 13:40:46 +0200","Message-Id":"<20260416114046.642171-1-maciej.fijalkowski@intel.com>","X-Mailer":"git-send-email 2.38.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Mailman-Original-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1776339686; x=1807875686;\n h=from:to:cc:subject:date:message-id:mime-version:\n content-transfer-encoding;\n bh=SEVguGURdvBzlg9sicK+07chxq4Cf+/TxqcmgIxpUXA=;\n b=D08frBC1Oz95JME017ycWq1EZDuH8/BuUTT3/euvbpB9vGuosfn5azuM\n 1V5m2nEp6YoYGE/72KazEi9QEW178USLD7buwOkqnBbSHZiAewFBBHkGd\n jzkl97I3SLytRUapfz7mFHVnWWGCNK28twjeL4PeiMP+SzjBfWvWuKONx\n xGbMUmKVGvb6UMvLc7vmSSNUZ3UspH0IIKYVhTg2ypbgvesFdsXLHCmf3\n 8PtCskznsXQqzEFfSq4j3vHMCGqKfsqxdCqu2Gqa+J3f0a5jrtrtTVYy2\n qM7qy+GENb+f59k6yH1at0pUMxaaSPDLA8AkQsaQnbajnE+lo8+iocyKV\n w==;","X-Mailman-Original-Authentication-Results":["smtp2.osuosl.org;\n dmarc=pass (p=none dis=none)\n header.from=intel.com","smtp2.osuosl.org;\n dkim=pass (2048-bit key,\n unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=D08frBC1"],"Subject":"[Intel-wired-lan] [PATCH v2 iwl-net] i40e: keep q_vectors array in\n 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\n <intel-wired-lan.osuosl.org>","List-Unsubscribe":"<https://lists.osuosl.org/mailman/options/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>","List-Archive":"<http://lists.osuosl.org/pipermail/intel-wired-lan/>","List-Post":"<mailto:intel-wired-lan@osuosl.org>","List-Help":"<mailto:intel-wired-lan-request@osuosl.org?subject=help>","List-Subscribe":"<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>","Errors-To":"intel-wired-lan-bounces@osuosl.org","Sender":"\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"},"content":"For the main VSI, i40e_set_num_rings_in_vsi() always derives\nnum_q_vectors from pf->num_lan_msix. At the same time, ethtool -L stores\nthe user requested channel count in vsi->req_queue_pairs and the queue\nsetup path uses that value for the effective number of queue pairs.\n\nThis leaves queue and vector counts out of sync after shrinking channel\ncount via ethtool -L. The active queue configuration is reduced, but the\nVSI still keeps the full PF-sized q_vector topology.\n\nThat mismatch breaks reconfiguration flows which rely on vector/NAPI\nstate matching the effective channel configuration. In particular,\ntoggling /sys/class/net/<dev>/threaded after reducing the channel count\ncan hang, and later channel-count changes can fail because VSI reinit\ndoes not rebuild q_vectors to match the new vector count.\n\nFix this by making the main VSI num_q_vectors follow the effective\nrequested channel count, capped by the available MSI-X vectors. Update\ni40e_vsi_reinit_setup() to rebuild q_vectors during VSI reinit so the\nvector topology is refreshed together with the ring arrays when channel\ncount changes.\n\nKeep alloc_queue_pairs unchanged and based on pf->num_lan_qps so the VSI\nretains its full queue capacity.\n\nSelftest napi_threaded.py was originally used when Jakub reported hang\non /sys/class/net/<dev>/threaded toggle. In order to make it pass on\ni40e, use persistent NAPI configuration for q_vector NAPIs so NAPI\nidentity and threaded settings survive q_vector reallocation across\nchannel-count changes. This is achieved by using netif_napi_add_config()\nwhen configuring q_vectors.\n\n$ export NETIF=ens259f1np1\n$ sudo -E env PATH=\"$PATH\" ./tools/testing/selftests/drivers/net/napi_threaded.py\nTAP version 13\n1..3\nok 1 napi_threaded.napi_init\nok 2 napi_threaded.change_num_queues\nok 3 napi_threaded.enable_dev_threaded_disable_napi_threaded\nTotals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0\n\nReported-by: Jakub Kicinski <kuba@kernel.org>\nCloses: https://lore.kernel.org/intel-wired-lan/20260316133100.6054a11f@kernel.org/\nFixes: d2a69fefd756 (\"i40e: Fix changing previously set num_queue_pairs for PFs\")\nSigned-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>\n---\nv2:\n- NULL vsi->tx_rings in i40e_vsi_alloc_arrays() (Sashiko)\n---\n drivers/net/ethernet/intel/i40e/i40e_main.c | 35 +++++++++++++++++----\n 1 file changed, 29 insertions(+), 6 deletions(-)","diff":"diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c\nindex 926d001b2150..1d2a4181966f 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_main.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c\n@@ -11403,10 +11403,14 @@ static void i40e_service_timer(struct timer_list *t)\n static int i40e_set_num_rings_in_vsi(struct i40e_vsi *vsi)\n {\n \tstruct i40e_pf *pf = vsi->back;\n+\tu16 qps;\n \n \tswitch (vsi->type) {\n \tcase I40E_VSI_MAIN:\n \t\tvsi->alloc_queue_pairs = pf->num_lan_qps;\n+\t\tqps = vsi->req_queue_pairs ?\n+\t\t      min_t(u16, vsi->req_queue_pairs, pf->num_lan_qps) :\n+\t\t      pf->num_lan_qps;\n \t\tif (!vsi->num_tx_desc)\n \t\t\tvsi->num_tx_desc = ALIGN(I40E_DEFAULT_NUM_DESCRIPTORS,\n \t\t\t\t\t\t I40E_REQ_DESCRIPTOR_MULTIPLE);\n@@ -11414,7 +11418,8 @@ static int i40e_set_num_rings_in_vsi(struct i40e_vsi *vsi)\n \t\t\tvsi->num_rx_desc = ALIGN(I40E_DEFAULT_NUM_DESCRIPTORS,\n \t\t\t\t\t\t I40E_REQ_DESCRIPTOR_MULTIPLE);\n \t\tif (test_bit(I40E_FLAG_MSIX_ENA, pf->flags))\n-\t\t\tvsi->num_q_vectors = pf->num_lan_msix;\n+\t\t\tvsi->num_q_vectors = max_t(int, 1,\n+\t\t\t\t\t\t   min_t(int, qps, pf->num_lan_msix));\n \t\telse\n \t\t\tvsi->num_q_vectors = 1;\n \n@@ -11503,6 +11508,7 @@ static int i40e_vsi_alloc_arrays(struct i40e_vsi *vsi, bool alloc_qvectors)\n \n err_vectors:\n \tkfree(vsi->tx_rings);\n+\tvsi->tx_rings = NULL;\n \treturn ret;\n }\n \n@@ -12043,7 +12049,8 @@ static int i40e_vsi_alloc_q_vector(struct i40e_vsi *vsi, int v_idx)\n \tcpumask_copy(&q_vector->affinity_mask, cpu_possible_mask);\n \n \tif (vsi->netdev)\n-\t\tnetif_napi_add(vsi->netdev, &q_vector->napi, i40e_napi_poll);\n+\t\tnetif_napi_add_config(vsi->netdev, &q_vector->napi,\n+\t\t\t\t      i40e_napi_poll, v_idx);\n \n \t/* tie q_vector and vsi together */\n \tvsi->q_vectors[v_idx] = q_vector;\n@@ -14265,12 +14272,27 @@ static struct i40e_vsi *i40e_vsi_reinit_setup(struct i40e_vsi *vsi)\n \n \tpf = vsi->back;\n \n+\tif (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) {\n+\t\ti40e_put_lump(pf->irq_pile, vsi->base_vector, vsi->idx);\n+\t\tvsi->base_vector = 0;\n+\t}\n+\n \ti40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx);\n \ti40e_vsi_clear_rings(vsi);\n \n-\ti40e_vsi_free_arrays(vsi, false);\n+\ti40e_vsi_free_q_vectors(vsi);\n+\ti40e_vsi_free_arrays(vsi, true);\n \ti40e_set_num_rings_in_vsi(vsi);\n-\tret = i40e_vsi_alloc_arrays(vsi, false);\n+\n+\tret = i40e_vsi_alloc_arrays(vsi, true);\n+\tif (ret)\n+\t\tgoto err_vsi;\n+\n+\t/* Rebuild q_vectors during VSI reinit because the effective channel\n+\t * count may change num_q_vectors. Keep vector topology aligned with the\n+\t * queue configuration after ethtool's .set_channels() callback.\n+\t */\n+\tret = i40e_vsi_setup_vectors(vsi);\n \tif (ret)\n \t\tgoto err_vsi;\n \n@@ -14282,7 +14304,7 @@ static struct i40e_vsi *i40e_vsi_reinit_setup(struct i40e_vsi *vsi)\n \t\tdev_info(&pf->pdev->dev,\n \t\t\t \"failed to get tracking for %d queues for VSI %d err %d\\n\",\n \t\t\t alloc_queue_pairs, vsi->seid, ret);\n-\t\tgoto err_vsi;\n+\t\tgoto err_lump;\n \t}\n \tvsi->base_queue = ret;\n \n@@ -14306,7 +14328,6 @@ static struct i40e_vsi *i40e_vsi_reinit_setup(struct i40e_vsi *vsi)\n \treturn vsi;\n \n err_rings:\n-\ti40e_vsi_free_q_vectors(vsi);\n \tif (vsi->netdev_registered) {\n \t\tvsi->netdev_registered = false;\n \t\tunregister_netdev(vsi->netdev);\n@@ -14316,6 +14337,8 @@ static struct i40e_vsi *i40e_vsi_reinit_setup(struct i40e_vsi *vsi)\n \tif (vsi->type == I40E_VSI_MAIN)\n \t\ti40e_devlink_destroy_port(pf);\n \ti40e_aq_delete_element(&pf->hw, vsi->seid, NULL);\n+err_lump:\n+\ti40e_vsi_free_q_vectors(vsi);\n err_vsi:\n \ti40e_vsi_clear(vsi);\n \treturn NULL;\n","prefixes":["v2","iwl-net"]}