From patchwork Wed Mar 22 16:25:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Raczynski X-Patchwork-Id: 13184292 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25D5DC6FD1C for ; Wed, 22 Mar 2023 16:25:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229567AbjCVQZd (ORCPT ); Wed, 22 Mar 2023 12:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjCVQZc (ORCPT ); Wed, 22 Mar 2023 12:25:32 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9173A4A1EC for ; Wed, 22 Mar 2023 09:25:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679502331; x=1711038331; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=RP5Qs7W9H3ow0Nm3gOyqfSConsnZ70o3u1Ce8vNRzRk=; b=P5PtHisu4WxlwxB7gmb7wWIOCtHz12kB9OyVwPzX077qqsuDKchgcJ7H zJfD0B4xCpczngwKrj4dLGnToUjlK0aov0cMP3UEI0Vy6lt3Kfx8Np4TK 0gQOkrESkOVI7mMoAnXr046FtiGkjVyL4XEBBNwuULCvCkQpPwZridh5v p8Yi/X5mUFr47AHhgRmHGJOT77CHVSyU/9hPk4kvnYSQvH8yrTIGkk73m p4bX7Z0FKlx0mQeZFBr0pPegDXRs6c6eyxNt7gm2O6oLpL2ocy+GovOl4 EGKk0m6phBl2l2mALiUlbDFNkUnO01L+gjusXZKrex0BTM5QA5Z0tlyp2 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="404151266" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="404151266" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 09:25:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="825462707" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="825462707" Received: from nimitz.igk.intel.com ([10.102.21.231]) by fmsmga001.fm.intel.com with ESMTP; 22 Mar 2023 09:25:28 -0700 From: Piotr Raczynski To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, michal.swiatkowski@intel.com, shiraz.saleem@intel.com, jacob.e.keller@intel.com, sridhar.samudrala@intel.com, jesse.brandeburg@intel.com, aleksander.lobakin@intel.com, lukasz.czapnik@intel.com, Piotr Raczynski Subject: [PATCH net-next v2 0/8] ice: support dynamic interrupt allocation Date: Wed, 22 Mar 2023 17:25:22 +0100 Message-Id: <20230322162530.3317238-1-piotr.raczynski@intel.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Change history: v1 -> v2: - ice: refactor VF control VSI interrupt handling - move ice_get_vf_ctrl_vsi to ice_lib.c (ice_vf_lib.c depends on CONFIG_PCI_IOV) 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 | 36 +- 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 | 377 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_irq.h | 25 ++ drivers/net/ethernet/intel/ice/ice_lib.c | 321 ++-------------- drivers/net/ethernet/intel/ice/ice_lib.h | 7 +- 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_xsk.c | 5 +- 14 files changed, 553 insertions(+), 617 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_irq.c create mode 100644 drivers/net/ethernet/intel/ice/ice_irq.h