Skip to contentSkip to conversation

ice: Enable configuration of number of qps per VF via devlink

PATCH Superseded Sridhar Samudrala 2 participants 2 messages Apr 23, 2021

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: Enable configuration of number of qps per VF via devlink

Introduce a devlink parameter 'num_qps_per_vf' to allow user to configure the maximum number of queue pairs given to SR-IOV VFs before they are created.

This is currently determined by the driver based on the number of SR-IOV VFs created. In order to keep this behavior by default the parameter is initialized to 0. To change the default behavior, user can set num_qps_per_vf parameter via devlink and this will be used as the preferred value to determine the queues and vectors assigned per VF.

USAGE:
On a 2 port NIC

 # devlink dev param show
 pci/0000:42:00.0:
   name num_qps_per_vf type driver-specific
     values:
       cmode runtime value 0
 pci/0000:42:00.1:
   name num_qps_per_vf type driver-specific
     values:
       cmode runtime value 0

/* Set num_qps_per_vf to 4 */

 # devlink dev param set pci/0000:42:00.0 name num_qps_per_vf value 4 cmode runtime
 # devlink dev param show pci/0000:42:00.0 name num_qps_per_vf
 pci/0000:42:00.0:
   name num_qps_per_vf type driver-specific
     values:
       cmode runtime value 4
 # echo 8 > /sys/class/net/enp66s0f0/device/sriov_numvfs

This will create 8 VFs with 4 queue pairs and 5 vectors per VF compared to the default behavior of 16 queue pairs and 17 vectors per VF.

---
 Documentation/networking/devlink/ice.rst      |  23 ++++
 drivers/net/ethernet/intel/ice/ice_devlink.c  | 110 +++++++++++++++++-
 drivers/net/ethernet/intel/ice/ice_main.c     |   3 +
 .../net/ethernet/intel/ice/ice_virtchnl_pf.c  |   5 +-
 4 files changed, 139 insertions(+), 2 deletions(-)
Documentation/networking/devlink/ice.rst +23 -0
index a432dc419fa4..38bed190fa48 100644
@@ -193,3 +193,26 @@ Users can request an immediate capture of a snapshot via the
     0000000000000210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 
     $ devlink region delete pci/0000:01:00.0/device-caps snapshot 1
+
+Parameters
+==========
+
+The ``ice`` driver implements the following driver-specific
+parameters.
+
+.. list-table:: Driver-specific parameters implemented
+   :widths: 5 5 5 85
+
+   * - Name
+     - Type
+     - Mode
+     - Description
+   * - ``num_qps_per_vf``
+     - u16
+     - runtime
+     - Number of queue pairs assigned to SR-IOV VFs. The default
+       value is 0 indicating that the driver will determine based
+       on the number of SR-IOV VFs created and the available resources.
+       It can be set to a value between 1 to 16 and is used as a
+       preferred value in determining the queues and vectors assigned
+       per VF.
drivers/net/ethernet/intel/ice/ice_devlink.c +109 -1

134 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_main.c +3 -0
index 4ee85a217c6f..89f30255b711 100644
@@ -4092,6 +4092,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	}
 
 	ice_devlink_init_regions(pf);
+	devlink_params_publish(priv_to_devlink(pf));
 
 	pf->hw.udp_tunnel_nic.set_port = ice_udp_tunnel_set_port;
 	pf->hw.udp_tunnel_nic.unset_port = ice_udp_tunnel_unset_port;
@@ -4285,6 +4286,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	devm_kfree(dev, pf->vsi);
 err_init_pf_unroll:
 	ice_deinit_pf(pf);
+	devlink_params_unpublish(priv_to_devlink(pf));
 	ice_devlink_destroy_regions(pf);
 	ice_deinit_hw(hw);
 err_exit_unroll:
@@ -4398,6 +4400,7 @@ static void ice_remove(struct pci_dev *pdev)
 		ice_vsi_free_q_vectors(pf->vsi[i]);
 	}
 	ice_deinit_pf(pf);
+	devlink_params_unpublish(priv_to_devlink(pf));
 	ice_devlink_destroy_regions(pf);
 	ice_deinit_hw(&pf->hw);
 	ice_devlink_unregister(pf);
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +4 -1
index a1d22d2aa0bd..18538b1c57c1 100644
@@ -637,6 +637,7 @@ void ice_free_vfs(struct ice_pf *pf)
 
 	tmp = pf->num_alloc_vfs;
 	pf->num_qps_per_vf = 0;
+	pf->num_msix_per_vf = 0;
 	pf->num_alloc_vfs = 0;
 	for (i = 0; i < tmp; i++) {
 		if (test_bit(ICE_VF_STATE_INIT, pf->vf[i].vf_states)) {
@@ -1228,7 +1229,9 @@ static int ice_set_per_vf_res(struct ice_pf *pf)
 	msix_avail_for_sriov = pf->hw.func_caps.common_cap.num_msix_vectors -
 		pf->irq_tracker->num_entries;
 	msix_avail_per_vf = msix_avail_for_sriov / pf->num_alloc_vfs;
-	if (msix_avail_per_vf >= ICE_NUM_VF_MSIX_MED) {
+	if (pf->num_msix_per_vf && msix_avail_per_vf >= pf->num_msix_per_vf) {
+		num_msix_per_vf = pf->num_msix_per_vf;
+	} else if (msix_avail_per_vf >= ICE_NUM_VF_MSIX_MED) {
 		num_msix_per_vf = ICE_NUM_VF_MSIX_MED;
 	} else if (msix_avail_per_vf >= ICE_NUM_VF_MSIX_SMALL) {
 		num_msix_per_vf = ICE_NUM_VF_MSIX_SMALL;
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/1 ice: Enable configuration of number of qps per VF via devlink

On Thu, 2021-04-22 at 21:46 -0700, Sridhar Samudrala wrote:

<snip>

Quoted 15 lines

+/**
+ * ice_devlink_num_qps_per_vf_validate - Validate the number of qps per vf
+ * @devlink: pointer to the devlink instance
+ * @id: the parameter ID to validate
+ * @ctx: context to return the parameter value
+ * @extack: netlink extended ACK structure
+ *
+ * Check that the value passed is less than the max qps allowed for a VF and
+ * no VFs are created yet.
+ * Returns: zero on success, or an error code on failure and extack with a
+ * reason for failure.
+ */

drivers/net/ethernet/intel/ice/ice_devlink.c struct ice_pf *ice_allocate_pf(struct device *dev) · line 524

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +4 -0
+static int
+ice_devlink_num_qps_per_vf_validate(struct devlink *devlink, u32 id,
+				    union devlink_param_value val,
+				    struct netlink_ext_ack *extack)

I believe you changed a parameter, but forgot to update the kdoc:

drivers/net/ethernet/intel/ice/ice_devlink.c:526: warning: Function parameter or member 'val' not described in 'ice_devlink_num_qps_per_vf_validate' drivers/net/ethernet/intel/ice/ice_devlink.c:526: warning: Excess function parameter 'ctx' description in 'ice_devlink_num_qps_per_vf_validate'