From patchwork Tue May 9 17:00:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13236024 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.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 4A99617FE0 for ; Tue, 9 May 2023 17:05:45 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C9B38690 for ; Tue, 9 May 2023 10:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683651923; x=1715187923; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=nxx7pTMZH1NpcEmdVucpZcEaisqTuVBSIkMyDyPa5fY=; b=RaaDPoUKfLUS68jbvznR7uGs9k9aN1KwjvkXPriDYIsuG1j6I8yGPazv n5qsfV8BqYFsl67/QyROb+4rVcjREjojmFCLIfZ+praetPSRD8QVj/1NH 6Trgy8e8bsZzKEZ7znX3weK2DF66GXPfDCt1lyRdqDycUojFv+i3OmPrQ oHs9mEqtwDf/ICGh/5Do6yUPjTRMZckK6IYRNWIWIpFgm2BNF9iB0MfVO dOsP/M3qO1YlsUVelU2luxZPWNWCwSYgr69tTzOU6Hpong5jOH+4s0V8X B8A1IHdf1heq/grl5ZAW1VclrPBt8S8GMOgy/92RuzkNq7kIanHeKD7Fh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10705"; a="350023280" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="350023280" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 10:04:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10705"; a="649409428" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="649409428" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orsmga003.jf.intel.com with ESMTP; 09 May 2023 10:04:12 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: Tony Nguyen , piotr.raczynski@intel.com Subject: [PATCH net-next 0/8][pull request] ice: support dynamic interrupt allocation Date: Tue, 9 May 2023 10:00:40 -0700 Message-Id: <20230509170048.2235678-1-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.38.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Piotr Raczynski says: This patchset reimplements MSIX interrupt allocation logic to allow dynamic interrupt allocation after MSIX has been initially enabled. This allows current and future features to allocate and free interrupts as needed and will help to drastically decrease number of initially preallocated interrupts (even down to the API hard limit of 1). Although this patchset does not change behavior in terms of actual number of allocated interrupts during probe, it will be subject to change. First few patches prepares to introduce dynamic allocation by moving interrupt allocation code to separate file and update allocation API used in the driver to the currently preferred one. Due to the current contract between ice and irdma driver which is directly accessing msix entries allocated by ice driver, even after moving away from older pci_enable_msix_range function, still keep msix_entries array for irdma use. Next patches refactors and removes redundant code from SRIOV related logic as it also make it easier to move away from static allocation scheme. Last patches actually enables dynamic allocation of MSIX interrupts. First, introduce functions to allocate and free interrupts individually. This sets ground for the rest of the changes even if that patch still allocates the interrupts from the preallocated pool. Since this patch starts to keep interrupt details in ice_q_vector structure we can get rid of functions that calculates base vector number and register offset for the interrupt as it is equal to the interrupt index. Only keep separate register offset functions for the VF VSIs. Next, replace homegrown interrupt tracker with much simpler xarray based approach. As new API always allocate interrupts one by one, also track interrupts in the same manner. Lastly, extend the interrupt tracker to deal both with preallocated and dynamically allocated vectors and use pci_msix_alloc_irq_at and pci_msix_free_irq functions. Since not all architecture supports dynamic allocation, check it before trying to allocate a new interrupt. As previously mentioned, this patchset does not change number of initially allocated interrupts during init phase but now it can and will likely be changed. Patch 1-3 -> move code around and use newer API Patch 4-5 -> refactor and remove redundant SRIOV code Patch 6 -> allocate every interrupt individually Patch 7 -> replace homegrown interrupt tracker with xarray Patch 8 -> allow dynamic interrupt allocation The following are changes since commit 94e86ef1b801d213dfb8543633dec86abb1a457d: net: phy: dp83869: support mii mode when rgmii strap cfg is used and are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue 100GbE Piotr Raczynski (8): ice: move interrupt related code to separate file ice: use pci_irq_vector helper function ice: use preferred MSIX allocation api ice: refactor VF control VSI interrupt handling ice: remove redundant SRIOV code ice: add individual interrupt allocation ice: track interrupt vectors with xarray ice: add dynamic interrupt allocation drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 24 +- drivers/net/ethernet/intel/ice/ice_arfs.c | 5 +- drivers/net/ethernet/intel/ice/ice_base.c | 41 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_idc.c | 54 ++- drivers/net/ethernet/intel/ice/ice_irq.c | 378 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_irq.h | 25 ++ drivers/net/ethernet/intel/ice/ice_lib.c | 288 +------------- drivers/net/ethernet/intel/ice/ice_lib.h | 5 - drivers/net/ethernet/intel/ice/ice_main.c | 268 ++----------- drivers/net/ethernet/intel/ice/ice_ptp.c | 2 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 43 +-- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 32 ++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 7 + drivers/net/ethernet/intel/ice/ice_xsk.c | 5 +- 16 files changed, 560 insertions(+), 620 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_irq.c create mode 100644 drivers/net/ethernet/intel/ice/ice_irq.h