Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ice: devlink PF MSI-X max and min parameter

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

Add notes about this parameters into ice devlink documentation.

Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>

authored by

Michal Swiatkowski and committed by
Tony Nguyen
b2657259 c3a392bd

+106
+11
Documentation/networking/devlink/ice.rst
··· 69 69 70 70 To verify that value has been set: 71 71 $ devlink dev param show pci/0000:16:00.0 name tx_scheduling_layers 72 + * - ``msix_vec_per_pf_max`` 73 + - driverinit 74 + - Set the max MSI-X that can be used by the PF, rest can be utilized for 75 + SRIOV. The range is from min value set in msix_vec_per_pf_min to 76 + 2k/number of ports. 77 + * - ``msix_vec_per_pf_min`` 78 + - driverinit 79 + - Set the min MSI-X that will be used by the PF. This value inform how many 80 + MSI-X will be allocated statically. The range is from 2 to value set 81 + in msix_vec_per_pf_max. 82 + 72 83 .. list-table:: Driver specific parameters implemented 73 84 :widths: 5 5 90 74 85
+81
drivers/net/ethernet/intel/ice/devlink/devlink.c
··· 1202 1202 return status; 1203 1203 } 1204 1204 1205 + static void ice_set_min_max_msix(struct ice_pf *pf) 1206 + { 1207 + struct devlink *devlink = priv_to_devlink(pf); 1208 + union devlink_param_value val; 1209 + int err; 1210 + 1211 + err = devl_param_driverinit_value_get(devlink, 1212 + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, 1213 + &val); 1214 + if (!err) 1215 + pf->msix.min = val.vu32; 1216 + 1217 + err = devl_param_driverinit_value_get(devlink, 1218 + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, 1219 + &val); 1220 + if (!err) 1221 + pf->msix.max = val.vu32; 1222 + } 1223 + 1205 1224 /** 1206 1225 * ice_devlink_reinit_up - do reinit of the given PF 1207 1226 * @pf: pointer to the PF struct ··· 1235 1216 dev_err(ice_pf_to_dev(pf), "ice_init_hw failed: %d\n", err); 1236 1217 return err; 1237 1218 } 1219 + 1220 + /* load MSI-X values */ 1221 + ice_set_min_max_msix(pf); 1238 1222 1239 1223 err = ice_init_dev(pf); 1240 1224 if (err) ··· 1552 1530 return 0; 1553 1531 } 1554 1532 1533 + static int 1534 + ice_devlink_msix_max_pf_validate(struct devlink *devlink, u32 id, 1535 + union devlink_param_value val, 1536 + struct netlink_ext_ack *extack) 1537 + { 1538 + struct ice_pf *pf = devlink_priv(devlink); 1539 + 1540 + if (val.vu32 > pf->hw.func_caps.common_cap.num_msix_vectors) 1541 + return -EINVAL; 1542 + 1543 + return 0; 1544 + } 1545 + 1546 + static int 1547 + ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id, 1548 + union devlink_param_value val, 1549 + struct netlink_ext_ack *extack) 1550 + { 1551 + if (val.vu32 < ICE_MIN_MSIX) 1552 + return -EINVAL; 1553 + 1554 + return 0; 1555 + } 1556 + 1555 1557 enum ice_param_id { 1556 1558 ICE_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, 1557 1559 ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS, ··· 1591 1545 ice_devlink_enable_iw_get, 1592 1546 ice_devlink_enable_iw_set, 1593 1547 ice_devlink_enable_iw_validate), 1548 + }; 1549 + 1550 + static const struct devlink_param ice_dvl_msix_params[] = { 1551 + DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MAX, 1552 + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), 1553 + NULL, NULL, ice_devlink_msix_max_pf_validate), 1554 + DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MIN, 1555 + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), 1556 + NULL, NULL, ice_devlink_msix_min_pf_validate), 1594 1557 }; 1595 1558 1596 1559 static const struct devlink_param ice_dvl_sched_params[] = { ··· 1703 1648 int ice_devlink_register_params(struct ice_pf *pf) 1704 1649 { 1705 1650 struct devlink *devlink = priv_to_devlink(pf); 1651 + union devlink_param_value value; 1706 1652 struct ice_hw *hw = &pf->hw; 1707 1653 int status; 1708 1654 ··· 1712 1656 if (status) 1713 1657 return status; 1714 1658 1659 + status = devl_params_register(devlink, ice_dvl_msix_params, 1660 + ARRAY_SIZE(ice_dvl_msix_params)); 1661 + if (status) 1662 + goto unregister_rdma_params; 1663 + 1715 1664 if (hw->func_caps.common_cap.tx_sched_topo_comp_mode_en) 1716 1665 status = devl_params_register(devlink, ice_dvl_sched_params, 1717 1666 ARRAY_SIZE(ice_dvl_sched_params)); 1667 + if (status) 1668 + goto unregister_msix_params; 1718 1669 1670 + value.vu32 = pf->msix.max; 1671 + devl_param_driverinit_value_set(devlink, 1672 + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, 1673 + value); 1674 + value.vu32 = pf->msix.min; 1675 + devl_param_driverinit_value_set(devlink, 1676 + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, 1677 + value); 1678 + return 0; 1679 + 1680 + unregister_msix_params: 1681 + devl_params_unregister(devlink, ice_dvl_msix_params, 1682 + ARRAY_SIZE(ice_dvl_msix_params)); 1683 + unregister_rdma_params: 1684 + devl_params_unregister(devlink, ice_dvl_rdma_params, 1685 + ARRAY_SIZE(ice_dvl_rdma_params)); 1719 1686 return status; 1720 1687 } 1721 1688 ··· 1749 1670 1750 1671 devl_params_unregister(devlink, ice_dvl_rdma_params, 1751 1672 ARRAY_SIZE(ice_dvl_rdma_params)); 1673 + devl_params_unregister(devlink, ice_dvl_msix_params, 1674 + ARRAY_SIZE(ice_dvl_msix_params)); 1752 1675 1753 1676 if (hw->func_caps.common_cap.tx_sched_topo_comp_mode_en) 1754 1677 devl_params_unregister(devlink, ice_dvl_sched_params,
+7
drivers/net/ethernet/intel/ice/ice.h
··· 542 542 u8 valid; 543 543 }; 544 544 545 + struct ice_pf_msix { 546 + u32 cur; 547 + u32 min; 548 + u32 max; 549 + }; 550 + 545 551 struct ice_pf { 546 552 struct pci_dev *pdev; 547 553 struct ice_adapter *adapter; ··· 618 612 struct msi_map ll_ts_irq; /* LL_TS interrupt MSIX vector */ 619 613 u16 max_pf_txqs; /* Total Tx queues PF wide */ 620 614 u16 max_pf_rxqs; /* Total Rx queues PF wide */ 615 + struct ice_pf_msix msix; 621 616 u16 num_lan_msix; /* Total MSIX vectors for base driver */ 622 617 u16 num_lan_tx; /* num LAN Tx queues setup */ 623 618 u16 num_lan_rx; /* num LAN Rx queues setup */
+7
drivers/net/ethernet/intel/ice/ice_irq.c
··· 254 254 int total_vectors = pf->hw.func_caps.common_cap.num_msix_vectors; 255 255 int vectors, max_vectors; 256 256 257 + /* load default PF MSI-X range */ 258 + if (!pf->msix.min) 259 + pf->msix.min = ICE_MIN_MSIX; 260 + 261 + if (!pf->msix.max) 262 + pf->msix.max = total_vectors / 2; 263 + 257 264 vectors = ice_ena_msix_range(pf); 258 265 259 266 if (vectors < 0)