Skip to contentSkip to conversation

ice: managing MSI-X in driver

PATCH Superseded Michal Swiatkowski 3 participants 17 messages Feb 13, 2024

Subsystems (5)

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

cover ice: managing MSI-X in driver

Hi,

It is another try to allow user to manage amount of MSI-X used for each feature in ice. First was via devlink resources API, it wasn't accepted in upstream. Also static MSI-X allocation using devlink resources isn't really user friendly.

This try is using more dynamic way. "Dynamic" across whole kernel when platform supports it and "dynamic" across the driver when not.

To achieve that reuse global devlink parameter pf_msix_max and pf_msix_min. It fits how ice hardware counts MSI-X. In case of ice amount of MSI-X reported on PCI is a whole MSI-X for the card (with MSI-X for VFs also). Having pf_msix_max allow user to statically set how many MSI-X he wants on PF and how many should be reserved for VFs.

pf_msix_min is used to set minimum number of MSI-X with which ice driver should probe correctly.

Meaning of this field in case of dynamic vs static allocation:
- on system with dynamic MSI-X allocation support
* alloc pf_msix_min as static, rest will be allocated dynamically
- on system without dynamic MSI-X allocation support
* try alloc pf_msix_max as static, minimum acceptable result is pf_msix_min

As Jesse and Piotr suggested pf_msix_max and pf_msix_min can (an probably should) be stored in NVM. This patchset isn't implementing that.

Dynamic (kernel or driver) way means that splitting MSI-X across the RDMA and eth in case there is a MSI-X shortage isn't correct. Can work when dynamic is only on driver site, but can't when dynamic is on kernel site.

Let's remove this code and move to MSI-X allocation feature by feature. If there is no more MSI-X for a feature, a feature is working with less MSI-X or it is turned off.

There is a regression here. With MSI-X splitting user can run RDMA and eth even on system with not enough MSI-X. Now only eth will work. RDMA can be turned on by changing number of PF queues (lowering) and reprobe RDMA driver.

Example:
72 CPU number, eth, RDMA and flow director (1 MSI-X), 1 MSI-X for OICR on PF, and 1 more for RDMA. Card is using 1 + 72 + 1 + 72 + 1 = 147.

We set pf_msix_min = 2, pf_msix_max = 128

OICR: 1
eth: 72
RDMA: 128 - 73 = 55
flow director: turned off not enough MSI-X

We can change number of queues on pf to 36 and do devlink reinit

OICR: 1
eth: 36
RDMA: 73
flow director: 1

We can also (implemented in "ice: enable_rdma devlink param") turned RDMA off.

OICR: 1
eth: 72
RDMA: 0 (turned off)
flow director: 1

Maybe flow director should have higher priority than RDMA? It needs only 1 MSI-X, so it seems more logic to lower RDMA by one then maxing MSI-X on RDMA and turning off flow director (as default).

After this changes we have a static base vector for SRIOV (SIOV probably in the feature). Last patch from this series is simplifying managing VF MSI-X code based on static vector.

Now changing queues using ethtool is also changing MSI-X. If there is enough MSI-X it is always one to one. When there is not enough there will be more queues than MSI-X. There is a lack of ability to set how many queues should be used per MSI-X. Maybe we should introduce another ethtool param for it? Sth like queues_per_vector?

There is also a lack of ability to change RDMA queues / MSI-X. This patchset moves managing RDMA MSI-X to irdma driver, but there is no mechanism to change default MSI-X amount. Maybe devlink param for that will work? We can think of storing this kind of param in NVM.

Michal Swiatkowski (7):
ice: devlink PF MSI-X max and min parameter
ice: remove splitting MSI-X between features
ice: get rid of num_lan_msix field
ice, irdma: move interrupts code to irdma
ice: treat dyn_allowed only as suggestion
ice: enable_rdma devlink param
ice: simplify VF MSI-X managing

 drivers/infiniband/hw/irdma/hw.c             |   2 -
 drivers/infiniband/hw/irdma/main.c           |  46 +++-
 drivers/infiniband/hw/irdma/main.h           |   3 +
 drivers/net/ethernet/intel/ice/ice.h         |  21 +-
 drivers/net/ethernet/intel/ice/ice_base.c    |  10 +-
 drivers/net/ethernet/intel/ice/ice_devlink.c | 114 +++++++-
 drivers/net/ethernet/intel/ice/ice_ethtool.c |   8 +-
 drivers/net/ethernet/intel/ice/ice_idc.c     |  64 +----
 drivers/net/ethernet/intel/ice/ice_irq.c     | 271 ++++++-------------
 drivers/net/ethernet/intel/ice/ice_irq.h     |  13 +-
 drivers/net/ethernet/intel/ice/ice_lib.c     |  36 ++-
 drivers/net/ethernet/intel/ice/ice_main.c    |  18 +-
 drivers/net/ethernet/intel/ice/ice_sriov.c   | 153 +----------
 include/linux/net/intel/iidc.h               |   2 +
 14 files changed, 327 insertions(+), 434 deletions(-)
Signature · 1 line
2.42.0
#1 lore raw

PATCH 1/7 ice: devlink PF MSI-X max and min parameter

Use generic devlink PF MSI-X parameter to allow user to change MSI-X range.

---
 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(+)
drivers/net/ethernet/intel/ice/ice.h +8 -0
index c4127d5f2be3..24085f3c0966 100644
@@ -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 */
drivers/net/ethernet/intel/ice/ice_devlink.c +82 -0

94 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_irq.c +6 -0
index ad82ff7d1995..fa7178a68b94 100644
@@ -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)
Signature · 1 line
2.42.0
#2 lore raw

Re: [iwl-next v1 1/7] ice: devlink PF MSI-X max and min parameter

Quoted 61 lines · Tue, Feb 13, 2024 at 08:35:03AM CET, [email protected] wrote:

Use generic devlink PF MSI-X parameter to allow user to change MSI-X range.

---

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(+)
drivers/net/ethernet/intel/ice/ice.h +8 -0
index c4127d5f2be3..24085f3c0966 100644
@@ -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 */
drivers/net/ethernet/intel/ice/ice_devlink.c +9 -0
index cc717175178b..b82ff9556a4b 100644
@@ -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;

drivers/net/ethernet/intel/ice/ice_devlink.c enum ice_param_id { · line 1624

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +10 -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;

What's permanent about this exactly?

Quoted 26 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +26 -0
+
+	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;

drivers/net/ethernet/intel/ice/ice_devlink.c enum ice_param_id { · line 1660

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +10 -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;

What's permanent about this exactly?

Quoted 21 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +17 -0
+
+	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,

drivers/net/ethernet/intel/ice/ice_devlink.c static const struct devlink_param ice_devlink_params[] = { · line 1699

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +7 -0
@@ -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),

....

pw-bot: cr

Quoted 27 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +3 -0
+			      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)
drivers/net/ethernet/intel/ice/ice_irq.c +6 -0
index ad82ff7d1995..fa7178a68b94 100644
@@ -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)
Signature · 1 line
2.42.0
#3 lore raw

Re: [iwl-next v1 1/7] ice: devlink PF MSI-X max and min parameter

Quoted 66 lines · Jiri Pirko
Quoted 65 lines · Tue, Feb 13, 2024 at 08:35:03AM CET, [email protected] wrote:

Use generic devlink PF MSI-X parameter to allow user to change MSI-X range.

---

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(+)
drivers/net/ethernet/intel/ice/ice.h +8 -0
index c4127d5f2be3..24085f3c0966 100644
@@ -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 */
drivers/net/ethernet/intel/ice/ice_devlink.c +13 -0
index cc717175178b..b82ff9556a4b 100644
@@ -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,
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_devlink.c enum ice_param_id { · line 1624

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +6 -0
+			    struct devlink_param_gset_ctx *ctx)
+{
+	struct ice_pf *pf = devlink_priv(devlink);
+	u16 max = ctx->val.vu16;
+
+	pf->msix.max = max;

What's permanent about this exactly?

I want to store the value here after driver reinit. Isn't it enough to use this parameter type? Which one should be used for this purpose?

Quoted 31 lines
Quoted 31 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +30 -0
+
+	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,
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_devlink.c enum ice_param_id { · line 1660

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +6 -0
+			    struct devlink_param_gset_ctx *ctx)
+{
+	struct ice_pf *pf = devlink_priv(devlink);
+	u16 min = ctx->val.vu16;
+
+	pf->msix.min = min;

What's permanent about this exactly?

The same as with max.

Quoted 66 lines
Quoted 22 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +17 -0
+
+	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,

drivers/net/ethernet/intel/ice/ice_devlink.c static const struct devlink_param ice_devlink_params[] = { · line 1699

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +7 -0
@@ -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),

....

pw-bot: cr

Quoted 27 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +3 -0
+			      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)
drivers/net/ethernet/intel/ice/ice_irq.c +6 -0
index ad82ff7d1995..fa7178a68b94 100644
@@ -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)
Signature · 1 line
2.42.0
#4 lore raw

Re: [iwl-next v1 1/7] ice: devlink PF MSI-X max and min parameter

Quoted 77 lines · Tue, Feb 13, 2024 at 11:01:08AM CET, [email protected] wrote:
Quoted 66 lines · Jiri Pirko
Quoted 65 lines · Tue, Feb 13, 2024 at 08:35:03AM CET, [email protected] wrote:

Use generic devlink PF MSI-X parameter to allow user to change MSI-X range.

---

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(+)
drivers/net/ethernet/intel/ice/ice.h +8 -0
index c4127d5f2be3..24085f3c0966 100644
@@ -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 */
drivers/net/ethernet/intel/ice/ice_devlink.c +13 -0
index cc717175178b..b82ff9556a4b 100644
@@ -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,
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_devlink.c enum ice_param_id { · line 1624

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +6 -0
+			    struct devlink_param_gset_ctx *ctx)
+{
+	struct ice_pf *pf = devlink_priv(devlink);
+	u16 max = ctx->val.vu16;
+
+	pf->msix.max = max;

What's permanent about this exactly?

Quoted 2 lines

I want to store the value here after driver reinit. Isn't it enough to use this parameter type? Which one should be used for this purpose?

Documentation/networking/devlink/devlink-params.rst say:

.. list-table:: Possible configuration modes
:widths: 5 90

* - Name
- Description
* - ``runtime``
- set while the driver is running, and takes effect immediately. No reset is required.
* - ``driverinit``
- applied while the driver initializes. Requires the user to restart the driver using the ``devlink`` reload command.
* - ``permanent``
- written to the device's non-volatile memory. A hard reset is required for it to take effect.

[...]

#5 lore raw

Re: [iwl-next v1 1/7] ice: devlink PF MSI-X max and min parameter

Quoted 99 lines · Jiri Pirko
Quoted 77 lines · Tue, Feb 13, 2024 at 11:01:08AM CET, [email protected] wrote:
Quoted 66 lines · Jiri Pirko
Quoted 65 lines · Tue, Feb 13, 2024 at 08:35:03AM CET, [email protected] wrote:

Use generic devlink PF MSI-X parameter to allow user to change MSI-X range.

---

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(+)
drivers/net/ethernet/intel/ice/ice.h +8 -0
index c4127d5f2be3..24085f3c0966 100644
@@ -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 */
drivers/net/ethernet/intel/ice/ice_devlink.c +13 -0
index cc717175178b..b82ff9556a4b 100644
@@ -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,
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_devlink.c enum ice_param_id { · line 1624

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +6 -0
+			    struct devlink_param_gset_ctx *ctx)
+{
+	struct ice_pf *pf = devlink_priv(devlink);
+	u16 max = ctx->val.vu16;
+
+	pf->msix.max = max;

What's permanent about this exactly?

Quoted 2 lines

I want to store the value here after driver reinit. Isn't it enough to use this parameter type? Which one should be used for this purpose?

Documentation/networking/devlink/devlink-params.rst say:

.. list-table:: Possible configuration modes
:widths: 5 90

* - Name
- Description
* - ``runtime``
- set while the driver is running, and takes effect immediately. No reset is required.
* - ``driverinit``
- applied while the driver initializes. Requires the user to restart the driver using the ``devlink`` reload command.
* - ``permanent``
- written to the device's non-volatile memory. A hard reset is required for it to take effect.

Quoted 1 line

[...]

Thanks for pointing it, I changed the idea during developing it (at first I wanted to store it in NVM) and forgot to change the type.

I will go with driverinit param.

#6 lore raw

PATCH 2/7 ice: remove splitting MSI-X between features

In reply to Michal Swiatkowski

With dynamic approach to alloc MSI-X there is no sense to statically split MSI-X between PF features.

---
 drivers/net/ethernet/intel/ice/ice_irq.c | 168 ++---------------------
 1 file changed, 10 insertions(+), 158 deletions(-)
drivers/net/ethernet/intel/ice/ice_irq.c +10 -158
index fa7178a68b94..8116d1d2ffa0 100644
@@ -84,157 +84,6 @@ static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf, bool dyn_only)
 	return entry;
 }
 
-/**
- * ice_reduce_msix_usage - Reduce usage of MSI-X vectors
- * @pf: board private structure
- * @v_remain: number of remaining MSI-X vectors to be distributed
- *
- * Reduce the usage of MSI-X vectors when entire request cannot be fulfilled.
- * pf->num_lan_msix and pf->num_rdma_msix values are set based on number of
- * remaining vectors.
- */
-static void ice_reduce_msix_usage(struct ice_pf *pf, int v_remain)
-{
-	int v_rdma;
-
-	if (!ice_is_rdma_ena(pf)) {
-		pf->num_lan_msix = v_remain;
-		return;
-	}
-
-	/* RDMA needs at least 1 interrupt in addition to AEQ MSIX */
-	v_rdma = ICE_RDMA_NUM_AEQ_MSIX + 1;
-
-	if (v_remain < ICE_MIN_LAN_TXRX_MSIX + ICE_MIN_RDMA_MSIX) {
-		dev_warn(ice_pf_to_dev(pf), "Not enough MSI-X vectors to support RDMA.\n");
-		clear_bit(ICE_FLAG_RDMA_ENA, pf->flags);
-
-		pf->num_rdma_msix = 0;
-		pf->num_lan_msix = ICE_MIN_LAN_TXRX_MSIX;
-	} else if ((v_remain < ICE_MIN_LAN_TXRX_MSIX + v_rdma) ||
-		   (v_remain - v_rdma < v_rdma)) {
-		/* Support minimum RDMA and give remaining vectors to LAN MSIX
-		 */
-		pf->num_rdma_msix = ICE_MIN_RDMA_MSIX;
-		pf->num_lan_msix = v_remain - ICE_MIN_RDMA_MSIX;
-	} else {
-		/* Split remaining MSIX with RDMA after accounting for AEQ MSIX
-		 */
-		pf->num_rdma_msix = (v_remain - ICE_RDMA_NUM_AEQ_MSIX) / 2 +
-				    ICE_RDMA_NUM_AEQ_MSIX;
-		pf->num_lan_msix = v_remain - pf->num_rdma_msix;
-	}
-}
-
-/**
- * ice_ena_msix_range - Request a range of MSIX vectors from the OS
- * @pf: board private structure
- *
- * Compute the number of MSIX vectors wanted and request from the OS. Adjust
- * device usage if there are not enough vectors. Return the number of vectors
- * reserved or negative on failure.
- */
-static int ice_ena_msix_range(struct ice_pf *pf)
-{
-	int num_cpus, hw_num_msix, v_other, v_wanted, v_actual;
-	struct device *dev = ice_pf_to_dev(pf);
-	int err;
-
-	hw_num_msix = pf->hw.func_caps.common_cap.num_msix_vectors;
-	num_cpus = num_online_cpus();
-
-	/* LAN miscellaneous handler */
-	v_other = ICE_MIN_LAN_OICR_MSIX;
-
-	/* Flow Director */
-	if (test_bit(ICE_FLAG_FD_ENA, pf->flags))
-		v_other += ICE_FDIR_MSIX;
-
-	/* switchdev */
-	v_other += ICE_ESWITCH_MSIX;
-
-	v_wanted = v_other;
-
-	/* LAN traffic */
-	pf->num_lan_msix = num_cpus;
-	v_wanted += pf->num_lan_msix;
-
-	/* RDMA auxiliary driver */
-	if (ice_is_rdma_ena(pf)) {
-		pf->num_rdma_msix = num_cpus + ICE_RDMA_NUM_AEQ_MSIX;
-		v_wanted += pf->num_rdma_msix;
-	}
-
-	if (v_wanted > hw_num_msix) {
-		int v_remain;
-
-		dev_warn(dev, "not enough device MSI-X vectors. wanted = %d, available = %d\n",
-			 v_wanted, hw_num_msix);
-
-		if (hw_num_msix < ICE_MIN_MSIX) {
-			err = -ERANGE;
-			goto exit_err;
-		}
-
-		v_remain = hw_num_msix - v_other;
-		if (v_remain < ICE_MIN_LAN_TXRX_MSIX) {
-			v_other = ICE_MIN_MSIX - ICE_MIN_LAN_TXRX_MSIX;
-			v_remain = ICE_MIN_LAN_TXRX_MSIX;
-		}
-
-		ice_reduce_msix_usage(pf, v_remain);
-		v_wanted = pf->num_lan_msix + pf->num_rdma_msix + v_other;
-
-		dev_notice(dev, "Reducing request to %d MSI-X vectors for LAN traffic.\n",
-			   pf->num_lan_msix);
-		if (ice_is_rdma_ena(pf))
-			dev_notice(dev, "Reducing request to %d MSI-X vectors for RDMA.\n",
-				   pf->num_rdma_msix);
-	}
-
-	/* actually reserve the vectors */
-	v_actual = pci_alloc_irq_vectors(pf->pdev, ICE_MIN_MSIX, v_wanted,
-					 PCI_IRQ_MSIX);
-	if (v_actual < 0) {
-		dev_err(dev, "unable to reserve MSI-X vectors\n");
-		err = v_actual;
-		goto exit_err;
-	}
-
-	if (v_actual < v_wanted) {
-		dev_warn(dev, "not enough OS MSI-X vectors. requested = %d, obtained = %d\n",
-			 v_wanted, v_actual);
-
-		if (v_actual < ICE_MIN_MSIX) {
-			/* error if we can't get minimum vectors */
-			pci_free_irq_vectors(pf->pdev);
-			err = -ERANGE;
-			goto exit_err;
-		} else {
-			int v_remain = v_actual - v_other;
-
-			if (v_remain < ICE_MIN_LAN_TXRX_MSIX)
-				v_remain = ICE_MIN_LAN_TXRX_MSIX;
-
-			ice_reduce_msix_usage(pf, v_remain);
-
-			dev_notice(dev, "Enabled %d MSI-X vectors for LAN traffic.\n",
-				   pf->num_lan_msix);
-
-			if (ice_is_rdma_ena(pf))
-				dev_notice(dev, "Enabled %d MSI-X vectors for RDMA.\n",
-					   pf->num_rdma_msix);
-		}
-	}
-
-	return v_actual;
-
-exit_err:
-	pf->num_rdma_msix = 0;
-	pf->num_lan_msix = 0;
-	return err;
-}
-
 /**
  * ice_clear_interrupt_scheme - Undo things done by ice_init_interrupt_scheme
  * @pf: board private structure
@@ -260,15 +109,18 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
 	if (!pf->msix.max)
 		pf->msix.max = total_vectors / 2;
 
-	vectors = ice_ena_msix_range(pf);
-
-	if (vectors < 0)
-		return -ENOMEM;
-
-	if (pci_msix_can_alloc_dyn(pf->pdev))
+	if (pci_msix_can_alloc_dyn(pf->pdev)) {
+		vectors = pf->msix.min;
 		max_vectors = total_vectors;
-	else
+	} else {
+		vectors = pf->msix.max;
 		max_vectors = vectors;
+	}
+
+	vectors = pci_alloc_irq_vectors(pf->pdev, pf->msix.min, vectors,
+					PCI_IRQ_MSIX);
+	if (vectors < pf->msix.min)
+		return -ENOMEM;
 
 	ice_init_irq_tracker(pf, max_vectors, vectors);
 
Signature · 1 line
2.42.0
#7 lore raw

PATCH 3/7 ice: get rid of num_lan_msix field

In reply to Michal Swiatkowski

Remove the field to allow having more queues than MSI-X on VSI. As default the number will be the same, but if there won't be more MSI-X available VSI can run with at least one MSI-X.

---
 drivers/net/ethernet/intel/ice/ice.h         |  1 -
 drivers/net/ethernet/intel/ice/ice_base.c    | 10 +++-----
 drivers/net/ethernet/intel/ice/ice_ethtool.c |  8 +++---
 drivers/net/ethernet/intel/ice/ice_irq.c     | 11 +++------
 drivers/net/ethernet/intel/ice/ice_lib.c     | 26 +++++++++++---------
 5 files changed, 27 insertions(+), 29 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +0 -1
index 24085f3c0966..5c9a95883456 100644
@@ -612,7 +612,6 @@ struct ice_pf {
 	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 */
 	u16 next_vsi;		/* Next free slot in pf->vsi[] - 0-based! */
drivers/net/ethernet/intel/ice/ice_base.c +4 -6
index 79485c944c9d..d071ead71796 100644
@@ -777,13 +777,11 @@ int ice_vsi_alloc_q_vectors(struct ice_vsi *vsi)
 	return 0;
 
 err_out:
-	while (v_idx--)
-		ice_free_q_vector(vsi, v_idx);
 
-	dev_err(dev, "Failed to allocate %d q_vector for VSI %d, ret=%d\n",
-		vsi->num_q_vectors, vsi->vsi_num, err);
-	vsi->num_q_vectors = 0;
-	return err;
+	dev_info(dev, "Failed to allocate %d q_vectors for VSI %d, new value %d",
+		 vsi->num_q_vectors, vsi->vsi_num, v_idx);
+	vsi->num_q_vectors = v_idx;
+	return v_idx ? 0 : err;
 }
 
 /**
drivers/net/ethernet/intel/ice/ice_ethtool.c +4 -4
index 3cc364a4d682..a3e8c15d073d 100644
@@ -3386,8 +3386,8 @@ ice_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
  */
 static int ice_get_max_txq(struct ice_pf *pf)
 {
-	return min3(pf->num_lan_msix, (u16)num_online_cpus(),
-		    (u16)pf->hw.func_caps.common_cap.num_txq);
+	return min_t(u16, num_online_cpus(),
+		     pf->hw.func_caps.common_cap.num_txq);
 }
 
 /**
@@ -3396,8 +3396,8 @@ static int ice_get_max_txq(struct ice_pf *pf)
  */
 static int ice_get_max_rxq(struct ice_pf *pf)
 {
-	return min3(pf->num_lan_msix, (u16)num_online_cpus(),
-		    (u16)pf->hw.func_caps.common_cap.num_rxq);
+	return min_t(u16, num_online_cpus(),
+		     pf->hw.func_caps.common_cap.num_rxq);
 }
 
 /**
drivers/net/ethernet/intel/ice/ice_irq.c +4 -7
index 8116d1d2ffa0..1d7a807454db 100644
@@ -101,7 +101,7 @@ void ice_clear_interrupt_scheme(struct ice_pf *pf)
 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;
+	int vectors;
 
 	/* load default PF MSI-X range */
 	if (!pf->msix.min)
@@ -109,20 +109,17 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
 	if (!pf->msix.max)
 		pf->msix.max = total_vectors / 2;
 
-	if (pci_msix_can_alloc_dyn(pf->pdev)) {
+	if (pci_msix_can_alloc_dyn(pf->pdev))
 		vectors = pf->msix.min;
-		max_vectors = total_vectors;
-	} else {
+	else
 		vectors = pf->msix.max;
-		max_vectors = vectors;
-	}
 
 	vectors = pci_alloc_irq_vectors(pf->pdev, pf->msix.min, vectors,
 					PCI_IRQ_MSIX);
 	if (vectors < pf->msix.min)
 		return -ENOMEM;
 
-	ice_init_irq_tracker(pf, max_vectors, vectors);
+	ice_init_irq_tracker(pf, pf->msix.max, vectors);
 
 	return 0;
 }
drivers/net/ethernet/intel/ice/ice_lib.c +15 -11
index 718cb8df7853..445c54b265b6 100644
@@ -160,6 +160,16 @@ static void ice_vsi_set_num_desc(struct ice_vsi *vsi)
 	}
 }
 
+static u16 ice_get_rxq_count(struct ice_pf *pf)
+{
+	return min_t(u16, ice_get_avail_rxq_count(pf), num_online_cpus());
+}
+
+static u16 ice_get_txq_count(struct ice_pf *pf)
+{
+	return min_t(u16, ice_get_avail_txq_count(pf), num_online_cpus());
+}
+
 /**
  * ice_vsi_set_num_qs - Set number of queues, descriptors and vectors for a VSI
  * @vsi: the VSI being configured
@@ -181,9 +191,7 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi)
 			vsi->alloc_txq = vsi->req_txq;
 			vsi->num_txq = vsi->req_txq;
 		} else {
-			vsi->alloc_txq = min3(pf->num_lan_msix,
-					      ice_get_avail_txq_count(pf),
-					      (u16)num_online_cpus());
+			vsi->alloc_txq = ice_get_txq_count(pf);
 		}
 
 		pf->num_lan_tx = vsi->alloc_txq;
@@ -196,17 +204,14 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi)
 				vsi->alloc_rxq = vsi->req_rxq;
 				vsi->num_rxq = vsi->req_rxq;
 			} else {
-				vsi->alloc_rxq = min3(pf->num_lan_msix,
-						      ice_get_avail_rxq_count(pf),
-						      (u16)num_online_cpus());
+				vsi->alloc_rxq = ice_get_rxq_count(pf);
 			}
 		}
 
 		pf->num_lan_rx = vsi->alloc_rxq;
 
-		vsi->num_q_vectors = min_t(int, pf->num_lan_msix,
-					   max_t(int, vsi->alloc_rxq,
-						 vsi->alloc_txq));
+		vsi->num_q_vectors = max_t(int, vsi->alloc_rxq,
+					   vsi->alloc_txq);
 		break;
 	case ICE_VSI_VF:
 		if (vf->num_req_qs)
@@ -1162,12 +1167,11 @@ static void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi)
 static void
 ice_chnl_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt)
 {
-	struct ice_pf *pf = vsi->back;
 	u16 qcount, qmap;
 	u8 offset = 0;
 	int pow;
 
-	qcount = min_t(int, vsi->num_rxq, pf->num_lan_msix);
+	qcount = vsi->num_rxq;
 
 	pow = order_base_2(qcount);
 	qmap = FIELD_PREP(ICE_AQ_VSI_TC_Q_OFFSET_M, offset);
Signature · 1 line
2.42.0
#8 lore raw

PATCH 4/7 ice, irdma: move interrupts code to irdma

In reply to Michal Swiatkowski

Move responsibility of MSI-X requesting for RDMA feature from ice driver to irdma driver. It is done to allow simple fallback when there is not enough MSI-X available.

---
 drivers/infiniband/hw/irdma/hw.c         |  2 -
 drivers/infiniband/hw/irdma/main.c       | 46 ++++++++++++++++-
 drivers/infiniband/hw/irdma/main.h       |  3 ++
 drivers/net/ethernet/intel/ice/ice.h     |  2 -
 drivers/net/ethernet/intel/ice/ice_idc.c | 64 ++++++------------------
 include/linux/net/intel/iidc.h           |  2 +
 6 files changed, 63 insertions(+), 56 deletions(-)
drivers/infiniband/hw/irdma/hw.c +0 -2
index bd4b2b896444..748abddf71ef 100644
@@ -497,8 +497,6 @@ static int irdma_save_msix_info(struct irdma_pci_f *rf)
 	iw_qvlist->num_vectors = rf->msix_count;
 	if (rf->msix_count <= num_online_cpus())
 		rf->msix_shared = true;
-	else if (rf->msix_count > num_online_cpus() + 1)
-		rf->msix_count = num_online_cpus() + 1;
 
 	pmsix = rf->msix_entries;
 	for (i = 0, ceq_idx = 0; i < rf->msix_count; i++, iw_qvinfo++) {
drivers/infiniband/hw/irdma/main.c +44 -2

77 lines not on this page · raw message

drivers/infiniband/hw/irdma/main.h +3 -0
index b65bc2ea542f..6c6bafb7b478 100644
@@ -117,6 +117,9 @@ extern struct auxiliary_driver i40iw_auxiliary_drv;
 
 #define IRDMA_IRQ_NAME_STR_LEN (64)
 
+#define IRDMA_NUM_AEQ_MSIX	1
+#define IRDMA_MIN_MSIX		2
+
 enum init_completion_state {
 	INVALID_STATE = 0,
 	INITIAL_STATE,
drivers/net/ethernet/intel/ice/ice.h +0 -2
index 5c9a95883456..1f4d31549528 100644
@@ -96,8 +96,6 @@
 #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
 #define ICE_ESWITCH_MSIX	1
 #define ICE_NO_VSI		0xffff
 #define ICE_VSI_MAP_CONTIG	0
drivers/net/ethernet/intel/ice/ice_idc.c +14 -50

101 lines not on this page · raw message

include/linux/net/intel/iidc.h +2 -0
index 1c1332e4df26..13274c3def66 100644
@@ -78,6 +78,8 @@ int ice_del_rdma_qset(struct ice_pf *pf, struct iidc_rdma_qset_params *qset);
 int ice_rdma_request_reset(struct ice_pf *pf, enum iidc_reset_type reset_type);
 int ice_rdma_update_vsi_filter(struct ice_pf *pf, u16 vsi_id, bool enable);
 void ice_get_qos_params(struct ice_pf *pf, struct iidc_qos_params *qos);
+int ice_alloc_rdma_qvector(struct ice_pf *pf, struct msix_entry *entry);
+void ice_free_rdma_qvector(struct ice_pf *pf, struct msix_entry *entry);
 
 /* Structure representing auxiliary driver tailored information about the core
  * PCI dev, each auxiliary driver using the IIDC interface will have an
Signature · 1 line
2.42.0
#9 lore raw

PATCH 5/7 ice: treat dyn_allowed only as suggestion

In reply to Michal Swiatkowski

It can be needed to have some MSI-X allocated as static and rest as dynamic. For example on PF VSI. We want to always have minimum one MSI-X on it, because of that it is allocated as a static one, rest can be dynamic if it is supported.

Change the ice_get_irq_res() to allow using static entries if they are free even if caller wants dynamic one.

Adjust limit values to the new approach. Min and max in limit means the values that are valid, so decrease max and num_static by one.

Set vsi::irq_dyn_alloc if dynamic allocation is supported.

---
 drivers/net/ethernet/intel/ice/ice_irq.c | 25 ++++++++++++------------
 drivers/net/ethernet/intel/ice/ice_lib.c |  2 ++
 2 files changed, 15 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_irq.c +13 -12
index 1d7a807454db..f95f6e5987b7 100644
@@ -45,7 +45,7 @@ static void ice_free_irq_res(struct ice_pf *pf, u16 index)
 /**
  * ice_get_irq_res - get an interrupt resource
  * @pf: board private structure
- * @dyn_only: force entry to be dynamically allocated
+ * @dyn_allowed: allow entry to be dynamically allocated
  *
  * Allocate new irq entry in the free slot of the tracker. Since xarray
  * is used, always allocate new entry at the lowest possible index. Set
@@ -53,11 +53,12 @@ static void ice_free_irq_res(struct ice_pf *pf, u16 index)
  *
  * Returns allocated irq entry or NULL on failure.
  */
-static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf, bool dyn_only)
+static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf,
+					     bool dyn_allowed)
 {
-	struct xa_limit limit = { .max = pf->irq_tracker.num_entries,
+	struct xa_limit limit = { .max = pf->irq_tracker.num_entries - 1,
 				  .min = 0 };
-	unsigned int num_static = pf->irq_tracker.num_static;
+	unsigned int num_static = pf->irq_tracker.num_static - 1;
 	struct ice_irq_entry *entry;
 	unsigned int index;
 	int ret;
@@ -66,9 +67,9 @@ static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf, bool dyn_only)
 	if (!entry)
 		return NULL;
 
-	/* skip preallocated entries if the caller says so */
-	if (dyn_only)
-		limit.min = num_static;
+	/* only already allocated if the caller says so */
+	if (!dyn_allowed)
+		limit.max = num_static;
 
 	ret = xa_alloc(&pf->irq_tracker.entries, &index, entry, limit,
 		       GFP_KERNEL);
@@ -78,7 +79,7 @@ static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf, bool dyn_only)
 		entry = NULL;
 	} else {
 		entry->index = index;
-		entry->dynamic = index >= num_static;
+		entry->dynamic = index > num_static;
 	}
 
 	return entry;
@@ -127,7 +128,7 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
 /**
  * ice_alloc_irq - Allocate new interrupt vector
  * @pf: board private structure
- * @dyn_only: force dynamic allocation of the interrupt
+ * @dyn_allowed: allow dynamic allocation of the interrupt
  *
  * Allocate new interrupt vector for a given owner id.
  * return struct msi_map with interrupt details and track
@@ -140,20 +141,20 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
  * interrupt will be allocated with pci_msix_alloc_irq_at.
  *
  * Some callers may only support dynamically allocated interrupts.
- * This is indicated with dyn_only flag.
+ * This is indicated with dyn_allowed flag.
  *
  * On failure, return map with negative .index. The caller
  * is expected to check returned map index.
  *
  */
-struct msi_map ice_alloc_irq(struct ice_pf *pf, bool dyn_only)
+struct msi_map ice_alloc_irq(struct ice_pf *pf, bool dyn_allowed)
 {
 	int sriov_base_vector = pf->sriov_base_vector;
 	struct msi_map map = { .index = -ENOENT };
 	struct device *dev = ice_pf_to_dev(pf);
 	struct ice_irq_entry *entry;
 
-	entry = ice_get_irq_res(pf, dyn_only);
+	entry = ice_get_irq_res(pf, dyn_allowed);
 	if (!entry)
 		return map;
 
drivers/net/ethernet/intel/ice/ice_lib.c +2 -0
index 445c54b265b6..a30d2d2b51c1 100644
@@ -570,6 +570,8 @@ ice_vsi_alloc_def(struct ice_vsi *vsi, struct ice_channel *ch)
 			return -ENOMEM;
 	}
 
+	vsi->irq_dyn_alloc = pci_msix_can_alloc_dyn(vsi->back->pdev);
+
 	switch (vsi->type) {
 	case ICE_VSI_PF:
 		/* Setup default MSIX irq handler for VSI */
Signature · 1 line
2.42.0
#10 lore raw

PATCH 6/7 ice: enable_rdma devlink param

In reply to Michal Swiatkowski

Implement enable_rdma devlink parameter to allow user to turn RDMA feature on and off.

It is useful when there is no enough interrupts and user doesn't need RDMA feature.

---
 drivers/net/ethernet/intel/ice/ice_devlink.c | 32 ++++++++++++++++++--
 drivers/net/ethernet/intel/ice/ice_lib.c     |  8 ++++-
 drivers/net/ethernet/intel/ice/ice_main.c    | 18 +++++------
 3 files changed, 45 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +30 -2
index b82ff9556a4b..4f048268db72 100644
@@ -1675,6 +1675,19 @@ ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id,
 	return 0;
 }
 
+static int ice_devlink_enable_rdma_validate(struct devlink *devlink, u32 id,
+					    union devlink_param_value val,
+					    struct netlink_ext_ack *extack)
+{
+	struct ice_pf *pf = devlink_priv(devlink);
+	bool new_state = val.vbool;
+
+	if (new_state && !test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
+		return -EOPNOTSUPP;
+
+	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,
@@ -1700,6 +1713,8 @@ static const struct devlink_param ice_devlink_params[] = {
 			      ice_devlink_msix_min_pf_get,
 			      ice_devlink_msix_min_pf_set,
 			      ice_devlink_msix_min_pf_validate),
+	DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
+			      NULL, NULL, ice_devlink_enable_rdma_validate),
 };
 
 static void ice_devlink_free(void *devlink_ptr)
@@ -1776,9 +1791,22 @@ ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid)
 int ice_devlink_register_params(struct ice_pf *pf)
 {
 	struct devlink *devlink = priv_to_devlink(pf);
+	union devlink_param_value value;
+	int err;
+
+	err = devlink_params_register(devlink, ice_devlink_params,
+				      ARRAY_SIZE(ice_devlink_params));
+	if (err)
+		return err;
 
-	return devlink_params_register(devlink, ice_devlink_params,
-				       ARRAY_SIZE(ice_devlink_params));
+	devl_lock(devlink);
+	value.vbool = test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	devl_param_driverinit_value_set(devlink,
+					DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					value);
+	devl_unlock(devlink);
+
+	return 0;
 }
 
 void ice_devlink_unregister_params(struct ice_pf *pf)
drivers/net/ethernet/intel/ice/ice_lib.c +7 -1
index a30d2d2b51c1..4d5c3d699044 100644
@@ -829,7 +829,13 @@ bool ice_is_safe_mode(struct ice_pf *pf)
  */
 bool ice_is_rdma_ena(struct ice_pf *pf)
 {
-	return test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	union devlink_param_value value;
+	int err;
+
+	err = devl_param_driverinit_value_get(priv_to_devlink(pf),
+					      DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					      &value);
+	return err ? false : value.vbool;
 }
 
 /**
drivers/net/ethernet/intel/ice/ice_main.c +8 -10
index 824732f16112..4dd59d888ec7 100644
@@ -5177,23 +5177,21 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	if (err)
 		goto err_init;
 
+	err = ice_init_devlink(pf);
+	if (err)
+		goto err_init_devlink;
+
 	devl_lock(priv_to_devlink(pf));
 	err = ice_load(pf);
 	devl_unlock(priv_to_devlink(pf));
 	if (err)
 		goto err_load;
 
-	err = ice_init_devlink(pf);
-	if (err)
-		goto err_init_devlink;
-
 	return 0;
 
-err_init_devlink:
-	devl_lock(priv_to_devlink(pf));
-	ice_unload(pf);
-	devl_unlock(priv_to_devlink(pf));
 err_load:
+	ice_deinit_devlink(pf);
+err_init_devlink:
 	ice_deinit(pf);
 err_init:
 	pci_disable_device(pdev);
@@ -5290,12 +5288,12 @@ static void ice_remove(struct pci_dev *pdev)
 	if (!ice_is_safe_mode(pf))
 		ice_remove_arfs(pf);
 
-	ice_deinit_devlink(pf);
-
 	devl_lock(priv_to_devlink(pf));
 	ice_unload(pf);
 	devl_unlock(priv_to_devlink(pf));
 
+	ice_deinit_devlink(pf);
+
 	ice_deinit(pf);
 	ice_vsi_release_all(pf);
 
Signature · 1 line
2.42.0
#11 lore raw

Re: [iwl-next v1 6/7] ice: enable_rdma devlink param

Quoted 49 lines · Tue, Feb 13, 2024 at 08:35:08AM CET, [email protected] wrote:

Implement enable_rdma devlink parameter to allow user to turn RDMA feature on and off.

It is useful when there is no enough interrupts and user doesn't need RDMA feature.

---

drivers/net/ethernet/intel/ice/ice_devlink.c | 32 ++++++++++++++++++--
drivers/net/ethernet/intel/ice/ice_lib.c     |  8 ++++-
drivers/net/ethernet/intel/ice/ice_main.c    | 18 +++++------
3 files changed, 45 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +15 -0
index b82ff9556a4b..4f048268db72 100644
@@ -1675,6 +1675,19 @@ ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id,
 	return 0;
 }
 
+static int ice_devlink_enable_rdma_validate(struct devlink *devlink, u32 id,
+					    union devlink_param_value val,
+					    struct netlink_ext_ack *extack)
+{
+	struct ice_pf *pf = devlink_priv(devlink);
+	bool new_state = val.vbool;
+
+	if (new_state && !test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
+		return -EOPNOTSUPP;
+
+	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,
@@ -1700,6 +1713,8 @@ static const struct devlink_param ice_devlink_params[] = {
 			      ice_devlink_msix_min_pf_get,
 			      ice_devlink_msix_min_pf_set,
 			      ice_devlink_msix_min_pf_validate),
+	DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
+			      NULL, NULL, ice_devlink_enable_rdma_validate),
 };
 
 static void ice_devlink_free(void *devlink_ptr)

drivers/net/ethernet/intel/ice/ice_devlink.c ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid) · line 1797

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +4 -0
@@ -1776,9 +1791,22 @@ ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid)
 int ice_devlink_register_params(struct ice_pf *pf)
 {
 	struct devlink *devlink = priv_to_devlink(pf);
+	union devlink_param_value value;
+	int err;
+
+	err = devlink_params_register(devlink, ice_devlink_params,

Interesting, can't you just take the lock before this and call devl_params_register()?

Moreover, could you please fix your init/cleanup paths for hold devlink instance lock the whole time?

pw-bot: cr

Quoted 89 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +11 -2
+				      ARRAY_SIZE(ice_devlink_params));
+	if (err)
+		return err;
 
-	return devlink_params_register(devlink, ice_devlink_params,
-				       ARRAY_SIZE(ice_devlink_params));
+	devl_lock(devlink);
+	value.vbool = test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	devl_param_driverinit_value_set(devlink,
+					DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					value);
+	devl_unlock(devlink);
+
+	return 0;
 }
 
 void ice_devlink_unregister_params(struct ice_pf *pf)
drivers/net/ethernet/intel/ice/ice_lib.c +7 -1
index a30d2d2b51c1..4d5c3d699044 100644
@@ -829,7 +829,13 @@ bool ice_is_safe_mode(struct ice_pf *pf)
 */
 bool ice_is_rdma_ena(struct ice_pf *pf)
 {
-	return test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	union devlink_param_value value;
+	int err;
+
+	err = devl_param_driverinit_value_get(priv_to_devlink(pf),
+					      DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					      &value);
+	return err ? false : value.vbool;
 }
 
 /**
drivers/net/ethernet/intel/ice/ice_main.c +4 -8
index 824732f16112..4dd59d888ec7 100644
@@ -5177,23 +5177,21 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	if (err)
 		goto err_init;
 
+	err = ice_init_devlink(pf);
+	if (err)
+		goto err_init_devlink;
+
 	devl_lock(priv_to_devlink(pf));
 	err = ice_load(pf);
 	devl_unlock(priv_to_devlink(pf));
 	if (err)
 		goto err_load;
 
-	err = ice_init_devlink(pf);
-	if (err)
-		goto err_init_devlink;
-
 	return 0;
 
-err_init_devlink:
-	devl_lock(priv_to_devlink(pf));
-	ice_unload(pf);
-	devl_unlock(priv_to_devlink(pf));

err_load:

drivers/net/ethernet/intel/ice/ice_main.c +2 -0
+	ice_deinit_devlink(pf);
+err_init_devlink:
	ice_deinit(pf);
err_init:
	pci_disable_device(pdev);
drivers/net/ethernet/intel/ice/ice_main.c +2 -2
@@ -5290,12 +5288,12 @@ static void ice_remove(struct pci_dev *pdev)
 	if (!ice_is_safe_mode(pf))
 		ice_remove_arfs(pf);
 
-	ice_deinit_devlink(pf);
-
 	devl_lock(priv_to_devlink(pf));
 	ice_unload(pf);
 	devl_unlock(priv_to_devlink(pf));
 
+	ice_deinit_devlink(pf);
+
 	ice_deinit(pf);
 	ice_vsi_release_all(pf);
 
Signature · 1 line
2.42.0
#12 lore raw

Re: [iwl-next v1 6/7] ice: enable_rdma devlink param

Quoted 48 lines · Jiri Pirko
Quoted 47 lines · Tue, Feb 13, 2024 at 08:35:08AM CET, [email protected] wrote:

Implement enable_rdma devlink parameter to allow user to turn RDMA feature on and off.

It is useful when there is no enough interrupts and user doesn't need RDMA feature.

---

drivers/net/ethernet/intel/ice/ice_devlink.c | 32 ++++++++++++++++++--
drivers/net/ethernet/intel/ice/ice_lib.c     |  8 ++++-
drivers/net/ethernet/intel/ice/ice_main.c    | 18 +++++------
3 files changed, 45 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +15 -0
index b82ff9556a4b..4f048268db72 100644
@@ -1675,6 +1675,19 @@ ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id,
 	return 0;
 }
 
+static int ice_devlink_enable_rdma_validate(struct devlink *devlink, u32 id,
+					    union devlink_param_value val,
+					    struct netlink_ext_ack *extack)
+{
+	struct ice_pf *pf = devlink_priv(devlink);
+	bool new_state = val.vbool;
+
+	if (new_state && !test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
+		return -EOPNOTSUPP;
+
+	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,
@@ -1700,6 +1713,8 @@ static const struct devlink_param ice_devlink_params[] = {
 			      ice_devlink_msix_min_pf_get,
 			      ice_devlink_msix_min_pf_set,
 			      ice_devlink_msix_min_pf_validate),
+	DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
+			      NULL, NULL, ice_devlink_enable_rdma_validate),
 };
 
Quoted 13 lines

drivers/net/ethernet/intel/ice/ice_devlink.c ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid) · line 1797

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +4 -0
 static void ice_devlink_free(void *devlink_ptr)
@@ -1776,9 +1791,22 @@ ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid)
 int ice_devlink_register_params(struct ice_pf *pf)
 {
 	struct devlink *devlink = priv_to_devlink(pf);
+	union devlink_param_value value;
+	int err;
+
+	err = devlink_params_register(devlink, ice_devlink_params,

Interesting, can't you just take the lock before this and call devl_params_register()?

I mess up a locking here and also in subfunction patchset. I will follow you suggestion and take lock for whole init/cleanup. Thanks.

Quoted 3 lines

Moreover, could you please fix your init/cleanup paths for hold devlink instance lock the whole time?

You right, I will prepare patch for it.

Quoted 93 lines

pw-bot: cr

Quoted 89 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +11 -2
+				      ARRAY_SIZE(ice_devlink_params));
+	if (err)
+		return err;
 
-	return devlink_params_register(devlink, ice_devlink_params,
-				       ARRAY_SIZE(ice_devlink_params));
+	devl_lock(devlink);
+	value.vbool = test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	devl_param_driverinit_value_set(devlink,
+					DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					value);
+	devl_unlock(devlink);
+
+	return 0;
 }
 
 void ice_devlink_unregister_params(struct ice_pf *pf)
drivers/net/ethernet/intel/ice/ice_lib.c +7 -1
index a30d2d2b51c1..4d5c3d699044 100644
@@ -829,7 +829,13 @@ bool ice_is_safe_mode(struct ice_pf *pf)
 */
 bool ice_is_rdma_ena(struct ice_pf *pf)
 {
-	return test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	union devlink_param_value value;
+	int err;
+
+	err = devl_param_driverinit_value_get(priv_to_devlink(pf),
+					      DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					      &value);
+	return err ? false : value.vbool;
 }
 
 /**
drivers/net/ethernet/intel/ice/ice_main.c +4 -8
index 824732f16112..4dd59d888ec7 100644
@@ -5177,23 +5177,21 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	if (err)
 		goto err_init;
 
+	err = ice_init_devlink(pf);
+	if (err)
+		goto err_init_devlink;
+
 	devl_lock(priv_to_devlink(pf));
 	err = ice_load(pf);
 	devl_unlock(priv_to_devlink(pf));
 	if (err)
 		goto err_load;
 
-	err = ice_init_devlink(pf);
-	if (err)
-		goto err_init_devlink;
-
 	return 0;
 
-err_init_devlink:
-	devl_lock(priv_to_devlink(pf));
-	ice_unload(pf);
-	devl_unlock(priv_to_devlink(pf));

err_load:

drivers/net/ethernet/intel/ice/ice_main.c +2 -0
+	ice_deinit_devlink(pf);
+err_init_devlink:
	ice_deinit(pf);
err_init:
	pci_disable_device(pdev);
drivers/net/ethernet/intel/ice/ice_main.c +2 -2
@@ -5290,12 +5288,12 @@ static void ice_remove(struct pci_dev *pdev)
 	if (!ice_is_safe_mode(pf))
 		ice_remove_arfs(pf);
 
-	ice_deinit_devlink(pf);
-
 	devl_lock(priv_to_devlink(pf));
 	ice_unload(pf);
 	devl_unlock(priv_to_devlink(pf));
 
+	ice_deinit_devlink(pf);
+
 	ice_deinit(pf);
 	ice_vsi_release_all(pf);
 
Signature · 1 line
2.42.0
#13 lore raw

Re: [iwl-next v1 6/7] ice: enable_rdma devlink param

Quoted 62 lines · Michal Swiatkowski
Quoted 48 lines · Jiri Pirko
Quoted 47 lines · Tue, Feb 13, 2024 at 08:35:08AM CET, [email protected] wrote:

Implement enable_rdma devlink parameter to allow user to turn RDMA feature on and off.

It is useful when there is no enough interrupts and user doesn't need RDMA feature.

---

drivers/net/ethernet/intel/ice/ice_devlink.c | 32 ++++++++++++++++++--
drivers/net/ethernet/intel/ice/ice_lib.c     |  8 ++++-
drivers/net/ethernet/intel/ice/ice_main.c    | 18 +++++------
3 files changed, 45 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +15 -0
index b82ff9556a4b..4f048268db72 100644
@@ -1675,6 +1675,19 @@ ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id,
 	return 0;
 }
 
+static int ice_devlink_enable_rdma_validate(struct devlink *devlink, u32 id,
+					    union devlink_param_value val,
+					    struct netlink_ext_ack *extack)
+{
+	struct ice_pf *pf = devlink_priv(devlink);
+	bool new_state = val.vbool;
+
+	if (new_state && !test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
+		return -EOPNOTSUPP;
+
+	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,
@@ -1700,6 +1713,8 @@ static const struct devlink_param ice_devlink_params[] = {
 			      ice_devlink_msix_min_pf_get,
 			      ice_devlink_msix_min_pf_set,
 			      ice_devlink_msix_min_pf_validate),
+	DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
+			      NULL, NULL, ice_devlink_enable_rdma_validate),
 };
 
Quoted 13 lines

drivers/net/ethernet/intel/ice/ice_devlink.c ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid) · line 1797

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +4 -0
 static void ice_devlink_free(void *devlink_ptr)
@@ -1776,9 +1791,22 @@ ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid)
 int ice_devlink_register_params(struct ice_pf *pf)
 {
 	struct devlink *devlink = priv_to_devlink(pf);
+	union devlink_param_value value;
+	int err;
+
+	err = devlink_params_register(devlink, ice_devlink_params,

Interesting, can't you just take the lock before this and call devl_params_register()?

Quoted 7 lines

I mess up a locking here and also in subfunction patchset. I will follow you suggestion and take lock for whole init/cleanup. Thanks.

Quoted 3 lines

Moreover, could you please fix your init/cleanup paths for hold devlink instance lock the whole time?

You right, I will prepare patch for it.

I think my patch implements your suggestion Jiri:
https://lore.kernel.org/netdev/[email protected]/

Quoted 94 lines
Quoted 94 lines

pw-bot: cr

Quoted 89 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +11 -2
+				      ARRAY_SIZE(ice_devlink_params));
+	if (err)
+		return err;
 
-	return devlink_params_register(devlink, ice_devlink_params,
-				       ARRAY_SIZE(ice_devlink_params));
+	devl_lock(devlink);
+	value.vbool = test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	devl_param_driverinit_value_set(devlink,
+					DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					value);
+	devl_unlock(devlink);
+
+	return 0;
 }
 
 void ice_devlink_unregister_params(struct ice_pf *pf)
drivers/net/ethernet/intel/ice/ice_lib.c +7 -1
index a30d2d2b51c1..4d5c3d699044 100644
@@ -829,7 +829,13 @@ bool ice_is_safe_mode(struct ice_pf *pf)
 */
 bool ice_is_rdma_ena(struct ice_pf *pf)
 {
-	return test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	union devlink_param_value value;
+	int err;
+
+	err = devl_param_driverinit_value_get(priv_to_devlink(pf),
+					      DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					      &value);
+	return err ? false : value.vbool;
 }
 
 /**
drivers/net/ethernet/intel/ice/ice_main.c +4 -8
index 824732f16112..4dd59d888ec7 100644
@@ -5177,23 +5177,21 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	if (err)
 		goto err_init;
 
+	err = ice_init_devlink(pf);
+	if (err)
+		goto err_init_devlink;
+
 	devl_lock(priv_to_devlink(pf));
 	err = ice_load(pf);
 	devl_unlock(priv_to_devlink(pf));
 	if (err)
 		goto err_load;
 
-	err = ice_init_devlink(pf);
-	if (err)
-		goto err_init_devlink;
-
 	return 0;
 
-err_init_devlink:
-	devl_lock(priv_to_devlink(pf));
-	ice_unload(pf);
-	devl_unlock(priv_to_devlink(pf));

err_load:

drivers/net/ethernet/intel/ice/ice_main.c +2 -0
+	ice_deinit_devlink(pf);
+err_init_devlink:
	ice_deinit(pf);
err_init:
	pci_disable_device(pdev);
drivers/net/ethernet/intel/ice/ice_main.c +2 -2
@@ -5290,12 +5288,12 @@ static void ice_remove(struct pci_dev *pdev)
 	if (!ice_is_safe_mode(pf))
 		ice_remove_arfs(pf);
 
-	ice_deinit_devlink(pf);
-
 	devl_lock(priv_to_devlink(pf));
 	ice_unload(pf);
 	devl_unlock(priv_to_devlink(pf));
 
+	ice_deinit_devlink(pf);
+
 	ice_deinit(pf);
 	ice_vsi_release_all(pf);
 
Signature · 1 line
2.42.0
#14 lore raw

Re: [iwl-next v1 6/7] ice: enable_rdma devlink param

Quoted 68 lines · Wojciech Drewek
Quoted 65 lines · Michal Swiatkowski
Quoted 48 lines · Jiri Pirko
Quoted 47 lines · Tue, Feb 13, 2024 at 08:35:08AM CET, [email protected] wrote:

Implement enable_rdma devlink parameter to allow user to turn RDMA feature on and off.

It is useful when there is no enough interrupts and user doesn't need RDMA feature.

---

drivers/net/ethernet/intel/ice/ice_devlink.c | 32 ++++++++++++++++++--
drivers/net/ethernet/intel/ice/ice_lib.c     |  8 ++++-
drivers/net/ethernet/intel/ice/ice_main.c    | 18 +++++------
3 files changed, 45 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +15 -0
index b82ff9556a4b..4f048268db72 100644
@@ -1675,6 +1675,19 @@ ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id,
 	return 0;
 }
 
+static int ice_devlink_enable_rdma_validate(struct devlink *devlink, u32 id,
+					    union devlink_param_value val,
+					    struct netlink_ext_ack *extack)
+{
+	struct ice_pf *pf = devlink_priv(devlink);
+	bool new_state = val.vbool;
+
+	if (new_state && !test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
+		return -EOPNOTSUPP;
+
+	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,
@@ -1700,6 +1713,8 @@ static const struct devlink_param ice_devlink_params[] = {
 			      ice_devlink_msix_min_pf_get,
 			      ice_devlink_msix_min_pf_set,
 			      ice_devlink_msix_min_pf_validate),
+	DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
+			      NULL, NULL, ice_devlink_enable_rdma_validate),
 };
 
Quoted 13 lines

drivers/net/ethernet/intel/ice/ice_devlink.c ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid) · line 1797

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +4 -0
 static void ice_devlink_free(void *devlink_ptr)
@@ -1776,9 +1791,22 @@ ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid)
 int ice_devlink_register_params(struct ice_pf *pf)
 {
 	struct devlink *devlink = priv_to_devlink(pf);
+	union devlink_param_value value;
+	int err;
+
+	err = devlink_params_register(devlink, ice_devlink_params,

Interesting, can't you just take the lock before this and call devl_params_register()?

I mess up a locking here and also in subfunction patchset. I will follow you suggestion and take lock for whole init/cleanup. Thanks.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Moreover, could you please fix your init/cleanup paths for hold devlink instance lock the whole time?

You right, I will prepare patch for it.

I think my patch implements your suggestion Jiri:
https://lore.kernel.org/netdev/[email protected]/

Right, I based my patchset before your changes was applied to Tony's tree. Thanks Wojtek.

So, in v2 there will be dev_version.

Thanks
Michal

Quoted 94 lines
Quoted 94 lines
Quoted 94 lines

pw-bot: cr

Quoted 89 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +11 -2
+				      ARRAY_SIZE(ice_devlink_params));
+	if (err)
+		return err;
 
-	return devlink_params_register(devlink, ice_devlink_params,
-				       ARRAY_SIZE(ice_devlink_params));
+	devl_lock(devlink);
+	value.vbool = test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	devl_param_driverinit_value_set(devlink,
+					DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					value);
+	devl_unlock(devlink);
+
+	return 0;
 }
 
 void ice_devlink_unregister_params(struct ice_pf *pf)
drivers/net/ethernet/intel/ice/ice_lib.c +7 -1
index a30d2d2b51c1..4d5c3d699044 100644
@@ -829,7 +829,13 @@ bool ice_is_safe_mode(struct ice_pf *pf)
 */
 bool ice_is_rdma_ena(struct ice_pf *pf)
 {
-	return test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	union devlink_param_value value;
+	int err;
+
+	err = devl_param_driverinit_value_get(priv_to_devlink(pf),
+					      DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					      &value);
+	return err ? false : value.vbool;
 }
 
 /**
drivers/net/ethernet/intel/ice/ice_main.c +4 -8
index 824732f16112..4dd59d888ec7 100644
@@ -5177,23 +5177,21 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	if (err)
 		goto err_init;
 
+	err = ice_init_devlink(pf);
+	if (err)
+		goto err_init_devlink;
+
 	devl_lock(priv_to_devlink(pf));
 	err = ice_load(pf);
 	devl_unlock(priv_to_devlink(pf));
 	if (err)
 		goto err_load;
 
-	err = ice_init_devlink(pf);
-	if (err)
-		goto err_init_devlink;
-
 	return 0;
 
-err_init_devlink:
-	devl_lock(priv_to_devlink(pf));
-	ice_unload(pf);
-	devl_unlock(priv_to_devlink(pf));

err_load:

drivers/net/ethernet/intel/ice/ice_main.c +2 -0
+	ice_deinit_devlink(pf);
+err_init_devlink:
	ice_deinit(pf);
err_init:
	pci_disable_device(pdev);
drivers/net/ethernet/intel/ice/ice_main.c +2 -2
@@ -5290,12 +5288,12 @@ static void ice_remove(struct pci_dev *pdev)
 	if (!ice_is_safe_mode(pf))
 		ice_remove_arfs(pf);
 
-	ice_deinit_devlink(pf);
-
 	devl_lock(priv_to_devlink(pf));
 	ice_unload(pf);
 	devl_unlock(priv_to_devlink(pf));
 
+	ice_deinit_devlink(pf);
+
 	ice_deinit(pf);
 	ice_vsi_release_all(pf);
 
Signature · 1 line
2.42.0
#15 lore raw

Re: [iwl-next v1 6/7] ice: enable_rdma devlink param

In reply to Wojciech Drewek
Quoted 68 lines · Tue, Feb 13, 2024 at 11:19:49AM CET, [email protected] wrote:
Quoted 65 lines · Michal Swiatkowski
Quoted 48 lines · Jiri Pirko
Quoted 47 lines · Tue, Feb 13, 2024 at 08:35:08AM CET, [email protected] wrote:

Implement enable_rdma devlink parameter to allow user to turn RDMA feature on and off.

It is useful when there is no enough interrupts and user doesn't need RDMA feature.

---

drivers/net/ethernet/intel/ice/ice_devlink.c | 32 ++++++++++++++++++--
drivers/net/ethernet/intel/ice/ice_lib.c     |  8 ++++-
drivers/net/ethernet/intel/ice/ice_main.c    | 18 +++++------
3 files changed, 45 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +15 -0
index b82ff9556a4b..4f048268db72 100644
@@ -1675,6 +1675,19 @@ ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id,
 	return 0;
 }
 
+static int ice_devlink_enable_rdma_validate(struct devlink *devlink, u32 id,
+					    union devlink_param_value val,
+					    struct netlink_ext_ack *extack)
+{
+	struct ice_pf *pf = devlink_priv(devlink);
+	bool new_state = val.vbool;
+
+	if (new_state && !test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
+		return -EOPNOTSUPP;
+
+	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,
@@ -1700,6 +1713,8 @@ static const struct devlink_param ice_devlink_params[] = {
 			      ice_devlink_msix_min_pf_get,
 			      ice_devlink_msix_min_pf_set,
 			      ice_devlink_msix_min_pf_validate),
+	DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
+			      NULL, NULL, ice_devlink_enable_rdma_validate),
 };
 
Quoted 13 lines

drivers/net/ethernet/intel/ice/ice_devlink.c ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid) · line 1797

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +4 -0
 static void ice_devlink_free(void *devlink_ptr)
@@ -1776,9 +1791,22 @@ ice_devlink_set_switch_id(struct ice_pf *pf, struct netdev_phys_item_id *ppid)
 int ice_devlink_register_params(struct ice_pf *pf)
 {
 	struct devlink *devlink = priv_to_devlink(pf);
+	union devlink_param_value value;
+	int err;
+
+	err = devlink_params_register(devlink, ice_devlink_params,

Interesting, can't you just take the lock before this and call devl_params_register()?

I mess up a locking here and also in subfunction patchset. I will follow you suggestion and take lock for whole init/cleanup. Thanks.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

Moreover, could you please fix your init/cleanup paths for hold devlink instance lock the whole time?

You right, I will prepare patch for it.

I think my patch implements your suggestion Jiri:
https://lore.kernel.org/netdev/[email protected]/

This patch is based on the one in your link apparently. I think it is incomplete. Idk

Quoted 95 lines
Quoted 95 lines
Quoted 95 lines

pw-bot: cr

Quoted 89 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +11 -2
+				      ARRAY_SIZE(ice_devlink_params));
+	if (err)
+		return err;
 
-	return devlink_params_register(devlink, ice_devlink_params,
-				       ARRAY_SIZE(ice_devlink_params));
+	devl_lock(devlink);
+	value.vbool = test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	devl_param_driverinit_value_set(devlink,
+					DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					value);
+	devl_unlock(devlink);
+
+	return 0;
 }
 
 void ice_devlink_unregister_params(struct ice_pf *pf)
drivers/net/ethernet/intel/ice/ice_lib.c +7 -1
index a30d2d2b51c1..4d5c3d699044 100644
@@ -829,7 +829,13 @@ bool ice_is_safe_mode(struct ice_pf *pf)
 */
 bool ice_is_rdma_ena(struct ice_pf *pf)
 {
-	return test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
+	union devlink_param_value value;
+	int err;
+
+	err = devl_param_driverinit_value_get(priv_to_devlink(pf),
+					      DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
+					      &value);
+	return err ? false : value.vbool;
 }
 
 /**
drivers/net/ethernet/intel/ice/ice_main.c +4 -8
index 824732f16112..4dd59d888ec7 100644
@@ -5177,23 +5177,21 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	if (err)
 		goto err_init;
 
+	err = ice_init_devlink(pf);
+	if (err)
+		goto err_init_devlink;
+
 	devl_lock(priv_to_devlink(pf));
 	err = ice_load(pf);
 	devl_unlock(priv_to_devlink(pf));
 	if (err)
 		goto err_load;
 
-	err = ice_init_devlink(pf);
-	if (err)
-		goto err_init_devlink;
-
 	return 0;
 
-err_init_devlink:
-	devl_lock(priv_to_devlink(pf));
-	ice_unload(pf);
-	devl_unlock(priv_to_devlink(pf));

err_load:

drivers/net/ethernet/intel/ice/ice_main.c +2 -0
+	ice_deinit_devlink(pf);
+err_init_devlink:
	ice_deinit(pf);
err_init:
	pci_disable_device(pdev);
drivers/net/ethernet/intel/ice/ice_main.c +2 -2
@@ -5290,12 +5288,12 @@ static void ice_remove(struct pci_dev *pdev)
 	if (!ice_is_safe_mode(pf))
 		ice_remove_arfs(pf);
 
-	ice_deinit_devlink(pf);
-
 	devl_lock(priv_to_devlink(pf));
 	ice_unload(pf);
 	devl_unlock(priv_to_devlink(pf));
 
+	ice_deinit_devlink(pf);
+
 	ice_deinit(pf);
 	ice_vsi_release_all(pf);
 
Signature · 1 line
2.42.0
#16 lore raw

PATCH 7/7 ice: simplify VF MSI-X managing

In reply to Michal Swiatkowski

After implementing pf->msix.max field, base vector for other use cases (like VFs) can be fixed. This simplify code when changing MSI-X amount on particular VF, because there is no need to move a base vector.

A fixed base vector allows to reserve vectors from the beginning instead of from the end, which is also simpler in code.

Store total and rest value in the same struct as max and min for PF. Move tracking vectors from ice_sriov.c to ice_irq.c as it can be also use for other none PF use cases (SIOV).

---
 drivers/net/ethernet/intel/ice/ice.h       |  10 +-
 drivers/net/ethernet/intel/ice/ice_irq.c   |  79 +++++++----
 drivers/net/ethernet/intel/ice/ice_irq.h   |  13 +-
 drivers/net/ethernet/intel/ice/ice_sriov.c | 153 ++-------------------
 4 files changed, 80 insertions(+), 175 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +3 -7
index 1f4d31549528..89afab4fbe50 100644
@@ -538,6 +538,8 @@ struct ice_pf_msix {
 	u16 cur;
 	u16 min;
 	u16 max;
+	u16 total;
+	u16 rest;
 };
 
 struct ice_pf {
@@ -553,13 +555,7 @@ struct ice_pf {
 	/* OS reserved IRQ details */
 	struct msix_entry *msix_entries;
 	struct ice_irq_tracker irq_tracker;
-	/* First MSIX vector used by SR-IOV VFs. Calculated by subtracting the
-	 * number of MSIX vectors needed for all SR-IOV VFs from the number of
-	 * MSIX vectors allowed on this PF.
-	 */
-	u16 sriov_base_vector;
-	unsigned long *sriov_irq_bm;	/* bitmap to track irq usage */
-	u16 sriov_irq_size;		/* size of the irq_bm bitmap */
+	struct ice_virt_irq_tracker virt_irq_tracker;
 
 	u16 ctrl_vsi_idx;		/* control VSI index in pf->vsi array */
 
drivers/net/ethernet/intel/ice/ice_irq.c +55 -24

133 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_irq.h +12 -1
index f35efc08575e..d5e0fdd9b535 100644
@@ -15,11 +15,22 @@ struct ice_irq_tracker {
 	u16 num_static;	/* preallocated entries */
 };
 
+struct ice_virt_irq_tracker {
+	unsigned long *bm;	/* bitmap to track irq usage */
+	u16 num_entries;
+	/* First MSIX vector used by SR-IOV VFs. Calculated by subtracting the
+	 * number of MSIX vectors needed for all SR-IOV VFs from the number of
+	 * MSIX vectors allowed on this PF.
+	 */
+	u16 base;
+};
+
 int ice_init_interrupt_scheme(struct ice_pf *pf);
 void ice_clear_interrupt_scheme(struct ice_pf *pf);
 
 struct msi_map ice_alloc_irq(struct ice_pf *pf, bool dyn_only);
 void ice_free_irq(struct ice_pf *pf, struct msi_map map);
-int ice_get_max_used_msix_vector(struct ice_pf *pf);
 
+int ice_virt_get_irqs(struct ice_pf *pf, u16 needed);
+void ice_virt_free_irqs(struct ice_pf *pf, u16 index, u16 irqs);
 #endif
drivers/net/ethernet/intel/ice/ice_sriov.c +10 -143

263 lines not on this page · raw message

Signature · 1 line
2.42.0