From patchwork Tue Feb 13 07:35:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 13554587 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 6CEDC17597 for ; Tue, 13 Feb 2024 07:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707809456; cv=none; b=lH5sebd2sqDkHPUYm2kkCq5VMTpuxDLsWEMFUsjzpfezPn2kMDwZNo99SRQGpMn6eG+EQ/KjUg4VJcvtzFAmTndS2rVFvlAH8N+LDpofMbkEhnRHdDYLnGLUhRCqedmXC/FWDp2L/l5q5H9OEaRbja9ZSpICQanSAE1KYQJdyrc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707809456; c=relaxed/simple; bh=61Mo6QaT8OzNzAcQmarA5ZDcUMtcu+/FPMbOsc3yk+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hfpuovhZqWnXaszwJ2EjlWj5IJdR/mul69B5Q6jnLB+RdxVvvvNeL/PvFQC9EgqOkoARyAIkTxq2ZvokeE3TMuVlrvWCwkeS22+VapiJ+IEOzl+Zdk/W98qF3DZSHSyIrGeEUl8aaR5i24ilhpATkFI2b+np8oBZE2Yfi8qf/a0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AmCBU9lr; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AmCBU9lr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707809455; x=1739345455; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=61Mo6QaT8OzNzAcQmarA5ZDcUMtcu+/FPMbOsc3yk+E=; b=AmCBU9lr3xxExTtHE1sp262Umayxs2yypJwDg6uhzhQfKFib0uxO4Wpx csA0Pa+BsnUH/23+tUpJZ0Z0X8Qu/rqYrV4Cxu8elP8T592dZlWdmJr6I qA2sONiF8zwtIdd19wjFsFEX5K+VzFhlsoB+76R+nwpv5Yk8Mf32lTHZA 5wYKsh6UVAgYu7nsVbs1M5pAWm3kXm/6skA6JkpHEV1TGruF5qbOeQMND uybuImO16wR/7GrxF51V3xtcwnCSNoYjXRVe7luG3xwnbwrrUi4vLTc5R DINRiwke7AkeVkFqMzy645/wS620CY9sPuh9Wj+seR6r3A0AV9oU7wrS+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="19219847" X-IronPort-AV: E=Sophos;i="6.06,156,1705392000"; d="scan'208";a="19219847" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 23:30:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,156,1705392000"; d="scan'208";a="2797527" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 12 Feb 2024 23:30:52 -0800 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, pawel.chmielewski@intel.com, sridhar.samudrala@intel.com, jacob.e.keller@intel.com, pio.raczynski@gmail.com, konrad.knitter@intel.com, marcin.szycik@intel.com, wojciech.drewek@intel.com, nex.sw.ncis.nat.hpm.dev@intel.com, przemyslaw.kitszel@intel.com, Michal Swiatkowski Subject: [iwl-next v1 1/7] ice: devlink PF MSI-X max and min parameter Date: Tue, 13 Feb 2024 08:35:03 +0100 Message-ID: <20240213073509.77622-2-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240213073509.77622-1-michal.swiatkowski@linux.intel.com> References: <20240213073509.77622-1-michal.swiatkowski@linux.intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use generic devlink PF MSI-X parameter to allow user to change MSI-X range. Reviewed-by: Wojciech Drewek Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/ice/ice.h | 8 ++ drivers/net/ethernet/intel/ice/ice_devlink.c | 82 ++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_irq.c | 6 ++ 3 files changed, 96 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index c4127d5f2be3..24085f3c0966 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -94,6 +94,7 @@ #define ICE_MIN_LAN_TXRX_MSIX 1 #define ICE_MIN_LAN_OICR_MSIX 1 #define ICE_MIN_MSIX (ICE_MIN_LAN_TXRX_MSIX + ICE_MIN_LAN_OICR_MSIX) +#define ICE_MAX_MSIX 256 #define ICE_FDIR_MSIX 2 #define ICE_RDMA_NUM_AEQ_MSIX 4 #define ICE_MIN_RDMA_MSIX 2 @@ -535,6 +536,12 @@ struct ice_agg_node { u8 valid; }; +struct ice_pf_msix { + u16 cur; + u16 min; + u16 max; +}; + struct ice_pf { struct pci_dev *pdev; @@ -604,6 +611,7 @@ struct ice_pf { struct msi_map ll_ts_irq; /* LL_TS interrupt MSIX vector */ u16 max_pf_txqs; /* Total Tx queues PF wide */ u16 max_pf_rxqs; /* Total Rx queues PF wide */ + struct ice_pf_msix msix; u16 num_lan_msix; /* Total MSIX vectors for base driver */ u16 num_lan_tx; /* num LAN Tx queues setup */ u16 num_lan_rx; /* num LAN Rx queues setup */ diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c index cc717175178b..b82ff9556a4b 100644 --- a/drivers/net/ethernet/intel/ice/ice_devlink.c +++ b/drivers/net/ethernet/intel/ice/ice_devlink.c @@ -1603,6 +1603,78 @@ enum ice_param_id { ICE_DEVLINK_PARAM_ID_LOOPBACK, }; +static int +ice_devlink_msix_max_pf_get(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct ice_pf *pf = devlink_priv(devlink); + + ctx->val.vu16 = pf->msix.max; + + return 0; +} + +static int +ice_devlink_msix_max_pf_set(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct ice_pf *pf = devlink_priv(devlink); + u16 max = ctx->val.vu16; + + pf->msix.max = max; + + return 0; +} + +static int +ice_devlink_msix_max_pf_validate(struct devlink *devlink, u32 id, + union devlink_param_value val, + struct netlink_ext_ack *extack) +{ + if (val.vu16 > ICE_MAX_MSIX) { + NL_SET_ERR_MSG_MOD(extack, "PF max MSI-X is too high"); + return -EINVAL; + } + + return 0; +} + +static int +ice_devlink_msix_min_pf_get(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct ice_pf *pf = devlink_priv(devlink); + + ctx->val.vu16 = pf->msix.min; + + return 0; +} + +static int +ice_devlink_msix_min_pf_set(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct ice_pf *pf = devlink_priv(devlink); + u16 min = ctx->val.vu16; + + pf->msix.min = min; + + return 0; +} + +static int +ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id, + union devlink_param_value val, + struct netlink_ext_ack *extack) +{ + if (val.vu16 <= ICE_MIN_MSIX) { + NL_SET_ERR_MSG_MOD(extack, "PF min MSI-X is too low"); + return -EINVAL; + } + + return 0; +} + static const struct devlink_param ice_devlink_params[] = { DEVLINK_PARAM_GENERIC(ENABLE_ROCE, BIT(DEVLINK_PARAM_CMODE_RUNTIME), ice_devlink_enable_roce_get, @@ -1618,6 +1690,16 @@ static const struct devlink_param ice_devlink_params[] = { ice_devlink_loopback_get, ice_devlink_loopback_set, ice_devlink_loopback_validate), + DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MAX, + BIT(DEVLINK_PARAM_CMODE_PERMANENT), + ice_devlink_msix_max_pf_get, + ice_devlink_msix_max_pf_set, + ice_devlink_msix_max_pf_validate), + DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MIN, + BIT(DEVLINK_PARAM_CMODE_PERMANENT), + ice_devlink_msix_min_pf_get, + ice_devlink_msix_min_pf_set, + ice_devlink_msix_min_pf_validate), }; static void ice_devlink_free(void *devlink_ptr) diff --git a/drivers/net/ethernet/intel/ice/ice_irq.c b/drivers/net/ethernet/intel/ice/ice_irq.c index ad82ff7d1995..fa7178a68b94 100644 --- a/drivers/net/ethernet/intel/ice/ice_irq.c +++ b/drivers/net/ethernet/intel/ice/ice_irq.c @@ -254,6 +254,12 @@ int ice_init_interrupt_scheme(struct ice_pf *pf) int total_vectors = pf->hw.func_caps.common_cap.num_msix_vectors; int vectors, max_vectors; + /* load default PF MSI-X range */ + if (!pf->msix.min) + pf->msix.min = ICE_MIN_MSIX; + if (!pf->msix.max) + pf->msix.max = total_vectors / 2; + vectors = ice_ena_msix_range(pf); if (vectors < 0)