@@ -1198,6 +1198,25 @@ static int ice_devlink_set_parent(struct devlink_rate *devlink_rate,
11981198 return status ;
11991199}
12001200
1201+ static void ice_set_min_max_msix (struct ice_pf * pf )
1202+ {
1203+ struct devlink * devlink = priv_to_devlink (pf );
1204+ union devlink_param_value val ;
1205+ int err ;
1206+
1207+ err = devl_param_driverinit_value_get (devlink ,
1208+ DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN ,
1209+ & val );
1210+ if (!err )
1211+ pf -> msix .min = val .vu32 ;
1212+
1213+ err = devl_param_driverinit_value_get (devlink ,
1214+ DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX ,
1215+ & val );
1216+ if (!err )
1217+ pf -> msix .max = val .vu32 ;
1218+ }
1219+
12011220/**
12021221 * ice_devlink_reinit_up - do reinit of the given PF
12031222 * @pf: pointer to the PF struct
@@ -1207,9 +1226,18 @@ static int ice_devlink_reinit_up(struct ice_pf *pf)
12071226 struct ice_vsi * vsi = ice_get_main_vsi (pf );
12081227 int err ;
12091228
1229+ err = ice_init_hw (& pf -> hw );
1230+ if (err ) {
1231+ dev_err (ice_pf_to_dev (pf ), "ice_init_hw failed: %d\n" , err );
1232+ return err ;
1233+ }
1234+
1235+ /* load MSI-X values */
1236+ ice_set_min_max_msix (pf );
1237+
12101238 err = ice_init_dev (pf );
12111239 if (err )
1212- return err ;
1240+ goto unroll_hw_init ;
12131241
12141242 vsi -> flags = ICE_VSI_FLAG_INIT ;
12151243
@@ -1232,6 +1260,8 @@ static int ice_devlink_reinit_up(struct ice_pf *pf)
12321260 rtnl_unlock ();
12331261err_vsi_cfg :
12341262 ice_deinit_dev (pf );
1263+ unroll_hw_init :
1264+ ice_deinit_hw (& pf -> hw );
12351265 return err ;
12361266}
12371267
@@ -1518,6 +1548,43 @@ static int ice_devlink_local_fwd_validate(struct devlink *devlink, u32 id,
15181548 return 0 ;
15191549}
15201550
1551+ static int
1552+ ice_devlink_msix_max_pf_validate (struct devlink * devlink , u32 id ,
1553+ union devlink_param_value val ,
1554+ struct netlink_ext_ack * extack )
1555+ {
1556+ struct ice_pf * pf = devlink_priv (devlink );
1557+
1558+ if (val .vu32 > pf -> hw .func_caps .common_cap .num_msix_vectors )
1559+ return - EINVAL ;
1560+
1561+ return 0 ;
1562+ }
1563+
1564+ static int
1565+ ice_devlink_msix_min_pf_validate (struct devlink * devlink , u32 id ,
1566+ union devlink_param_value val ,
1567+ struct netlink_ext_ack * extack )
1568+ {
1569+ if (val .vu32 < ICE_MIN_MSIX )
1570+ return - EINVAL ;
1571+
1572+ return 0 ;
1573+ }
1574+
1575+ static int ice_devlink_enable_rdma_validate (struct devlink * devlink , u32 id ,
1576+ union devlink_param_value val ,
1577+ struct netlink_ext_ack * extack )
1578+ {
1579+ struct ice_pf * pf = devlink_priv (devlink );
1580+ bool new_state = val .vbool ;
1581+
1582+ if (new_state && !test_bit (ICE_FLAG_RDMA_ENA , pf -> flags ))
1583+ return - EOPNOTSUPP ;
1584+
1585+ return 0 ;
1586+ }
1587+
15211588enum ice_param_id {
15221589 ICE_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX ,
15231590 ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS ,
@@ -1533,6 +1600,17 @@ static const struct devlink_param ice_dvl_rdma_params[] = {
15331600 ice_devlink_enable_iw_get ,
15341601 ice_devlink_enable_iw_set ,
15351602 ice_devlink_enable_iw_validate ),
1603+ DEVLINK_PARAM_GENERIC (ENABLE_RDMA , BIT (DEVLINK_PARAM_CMODE_DRIVERINIT ),
1604+ NULL , NULL , ice_devlink_enable_rdma_validate ),
1605+ };
1606+
1607+ static const struct devlink_param ice_dvl_msix_params [] = {
1608+ DEVLINK_PARAM_GENERIC (MSIX_VEC_PER_PF_MAX ,
1609+ BIT (DEVLINK_PARAM_CMODE_DRIVERINIT ),
1610+ NULL , NULL , ice_devlink_msix_max_pf_validate ),
1611+ DEVLINK_PARAM_GENERIC (MSIX_VEC_PER_PF_MIN ,
1612+ BIT (DEVLINK_PARAM_CMODE_DRIVERINIT ),
1613+ NULL , NULL , ice_devlink_msix_min_pf_validate ),
15361614};
15371615
15381616static const struct devlink_param ice_dvl_sched_params [] = {
@@ -1636,6 +1714,7 @@ void ice_devlink_unregister(struct ice_pf *pf)
16361714int ice_devlink_register_params (struct ice_pf * pf )
16371715{
16381716 struct devlink * devlink = priv_to_devlink (pf );
1717+ union devlink_param_value value ;
16391718 struct ice_hw * hw = & pf -> hw ;
16401719 int status ;
16411720
@@ -1644,10 +1723,39 @@ int ice_devlink_register_params(struct ice_pf *pf)
16441723 if (status )
16451724 return status ;
16461725
1726+ status = devl_params_register (devlink , ice_dvl_msix_params ,
1727+ ARRAY_SIZE (ice_dvl_msix_params ));
1728+ if (status )
1729+ goto unregister_rdma_params ;
1730+
16471731 if (hw -> func_caps .common_cap .tx_sched_topo_comp_mode_en )
16481732 status = devl_params_register (devlink , ice_dvl_sched_params ,
16491733 ARRAY_SIZE (ice_dvl_sched_params ));
1734+ if (status )
1735+ goto unregister_msix_params ;
1736+
1737+ value .vu32 = pf -> msix .max ;
1738+ devl_param_driverinit_value_set (devlink ,
1739+ DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX ,
1740+ value );
1741+ value .vu32 = pf -> msix .min ;
1742+ devl_param_driverinit_value_set (devlink ,
1743+ DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN ,
1744+ value );
1745+
1746+ value .vbool = test_bit (ICE_FLAG_RDMA_ENA , pf -> flags );
1747+ devl_param_driverinit_value_set (devlink ,
1748+ DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA ,
1749+ value );
1750+
1751+ return 0 ;
16501752
1753+ unregister_msix_params :
1754+ devl_params_unregister (devlink , ice_dvl_msix_params ,
1755+ ARRAY_SIZE (ice_dvl_msix_params ));
1756+ unregister_rdma_params :
1757+ devl_params_unregister (devlink , ice_dvl_rdma_params ,
1758+ ARRAY_SIZE (ice_dvl_rdma_params ));
16511759 return status ;
16521760}
16531761
@@ -1658,6 +1766,8 @@ void ice_devlink_unregister_params(struct ice_pf *pf)
16581766
16591767 devl_params_unregister (devlink , ice_dvl_rdma_params ,
16601768 ARRAY_SIZE (ice_dvl_rdma_params ));
1769+ devl_params_unregister (devlink , ice_dvl_msix_params ,
1770+ ARRAY_SIZE (ice_dvl_msix_params ));
16611771
16621772 if (hw -> func_caps .common_cap .tx_sched_topo_comp_mode_en )
16631773 devl_params_unregister (devlink , ice_dvl_sched_params ,
0 commit comments