Message ID | 20241028100341.16631-3-michal.swiatkowski@linux.intel.com |
---|---|
State | Superseded |
Headers | show |
Series | ice: managing MSI-X in driver | expand |
On Mon, Oct 28, 2024 at 11:04 AM Michal Swiatkowski <michal.swiatkowski@linux.intel.com> wrote: > > Use generic devlink PF MSI-X parameter to allow user to change MSI-X > range. > > Add notes about this parameters into ice devlink documentation. > > Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> > Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> > --- > Documentation/networking/devlink/ice.rst | 11 +++ > .../net/ethernet/intel/ice/devlink/devlink.c | 83 ++++++++++++++++++- > drivers/net/ethernet/intel/ice/ice.h | 7 ++ > drivers/net/ethernet/intel/ice/ice_irq.c | 7 ++ > 4 files changed, 107 insertions(+), 1 deletion(-) > > diff --git a/Documentation/networking/devlink/ice.rst b/Documentation/networking/devlink/ice.rst > index e3972d03cea0..792e9f8c846a 100644 > --- a/Documentation/networking/devlink/ice.rst > +++ b/Documentation/networking/devlink/ice.rst > @@ -69,6 +69,17 @@ Parameters > > To verify that value has been set: > $ devlink dev param show pci/0000:16:00.0 name tx_scheduling_layers > + * - ``msix_vec_per_pf_max`` > + - driverinit > + - Set the max MSI-X that can be used by the PF, rest can be utilized for > + SRIOV. The range is from min value set in msix_vec_per_pf_min to > + 2k/number of ports. > + * - ``msix_vec_per_pf_min`` > + - driverinit > + - Set the min MSI-X that will be used by the PF. This value inform how many > + MSI-X will be allocated statically. The range is from 2 to value set > + in msix_vec_per_pf_max. > + > .. list-table:: Driver specific parameters implemented > :widths: 5 5 90 > > diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c > index d1b9ccec5e05..29c1fec4fa93 100644 > --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c > +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c > @@ -1198,6 +1198,25 @@ static int ice_devlink_set_parent(struct devlink_rate *devlink_rate, > return status; > } > > +static void ice_set_min_max_msix(struct ice_pf *pf) > +{ > + struct devlink *devlink = priv_to_devlink(pf); > + union devlink_param_value val; > + int err; > + > + err = devl_param_driverinit_value_get(devlink, > + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, > + &val); > + if (!err) > + pf->msix.min = val.vu16; > + > + err = devl_param_driverinit_value_get(devlink, > + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, > + &val); > + if (!err) > + pf->msix.max = val.vu16; > +} > + > /** > * ice_devlink_reinit_up - do reinit of the given PF > * @pf: pointer to the PF struct > @@ -1207,6 +1226,9 @@ static int ice_devlink_reinit_up(struct ice_pf *pf) > struct ice_vsi *vsi = ice_get_main_vsi(pf); > int err; > > + /* load MSI-X values */ > + ice_set_min_max_msix(pf); > + > err = ice_init_hw(&pf->hw); > if (err) { > dev_err(ice_pf_to_dev(pf), "ice_init_hw failed: %d\n", err); > @@ -1526,6 +1548,37 @@ static int ice_devlink_local_fwd_validate(struct devlink *devlink, u32 id, > 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) > +{ > + struct ice_pf *pf = devlink_priv(devlink); > + > + if (val.vu16 > pf->hw.func_caps.common_cap.num_msix_vectors || > + val.vu16 < pf->msix.min) { > + NL_SET_ERR_MSG_MOD(extack, "Value is invalid"); > + return -EINVAL; > + } > + > + 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) > +{ > + struct ice_pf *pf = devlink_priv(devlink); > + > + if (val.vu16 <= ICE_MIN_MSIX || val.vu16 > pf->msix.max) { > + NL_SET_ERR_MSG_MOD(extack, "Value is invalid"); > + return -EINVAL; > + } > + > + return 0; > +} > + > enum ice_param_id { > ICE_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, > ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS, > @@ -1543,6 +1596,15 @@ static const struct devlink_param ice_dvl_rdma_params[] = { > ice_devlink_enable_iw_validate), > }; > > +static const struct devlink_param ice_dvl_msix_params[] = { > + DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MAX, > + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), > + NULL, NULL, ice_devlink_msix_max_pf_validate), > + DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MIN, > + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), > + NULL, NULL, ice_devlink_msix_min_pf_validate), > +}; > + > static const struct devlink_param ice_dvl_sched_params[] = { > DEVLINK_PARAM_DRIVER(ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS, > "tx_scheduling_layers", > @@ -1644,6 +1706,7 @@ void ice_devlink_unregister(struct ice_pf *pf) > int ice_devlink_register_params(struct ice_pf *pf) > { > struct devlink *devlink = priv_to_devlink(pf); > + union devlink_param_value value; > struct ice_hw *hw = &pf->hw; > int status; > > @@ -1652,11 +1715,27 @@ int ice_devlink_register_params(struct ice_pf *pf) > if (status) > return status; > > + status = devl_params_register(devlink, ice_dvl_msix_params, > + ARRAY_SIZE(ice_dvl_msix_params)); > + if (status) > + return status; > + > if (hw->func_caps.common_cap.tx_sched_topo_comp_mode_en) > status = devl_params_register(devlink, ice_dvl_sched_params, > ARRAY_SIZE(ice_dvl_sched_params)); > + if (status) > + return status; > > - return status; > + value.vu16 = pf->msix.max; > + devl_param_driverinit_value_set(devlink, > + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, > + value); > + value.vu16 = pf->msix.min; > + devl_param_driverinit_value_set(devlink, > + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, > + value); > + > + return 0; > } The type of the devlink parameters msix_vec_per_pf_{min,max} is specified as u32, so you must use value.vu32 everywhere you work with them, not vu16. Michal
On Mon, Oct 28, 2024 at 11:04 AM Michal Swiatkowski <michal.swiatkowski@linux.intel.com> wrote: > > Use generic devlink PF MSI-X parameter to allow user to change MSI-X > range. > > Add notes about this parameters into ice devlink documentation. > > Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> > Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> > --- > Documentation/networking/devlink/ice.rst | 11 +++ > .../net/ethernet/intel/ice/devlink/devlink.c | 83 ++++++++++++++++++- > drivers/net/ethernet/intel/ice/ice.h | 7 ++ > drivers/net/ethernet/intel/ice/ice_irq.c | 7 ++ > 4 files changed, 107 insertions(+), 1 deletion(-) > ... > @@ -1526,6 +1548,37 @@ static int ice_devlink_local_fwd_validate(struct devlink *devlink, u32 id, > 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) > +{ > + struct ice_pf *pf = devlink_priv(devlink); > + > + if (val.vu16 > pf->hw.func_caps.common_cap.num_msix_vectors || > + val.vu16 < pf->msix.min) { > + NL_SET_ERR_MSG_MOD(extack, "Value is invalid"); > + return -EINVAL; > + } > + > + 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) > +{ > + struct ice_pf *pf = devlink_priv(devlink); > + > + if (val.vu16 <= ICE_MIN_MSIX || val.vu16 > pf->msix.max) { Shouldn't this be "<" instead of "<=" ? Michal
On Thu, Oct 31, 2024 at 10:48:37PM +0100, Michal Schmidt wrote: > On Mon, Oct 28, 2024 at 11:04 AM Michal Swiatkowski > <michal.swiatkowski@linux.intel.com> wrote: > > > > Use generic devlink PF MSI-X parameter to allow user to change MSI-X > > range. > > > > Add notes about this parameters into ice devlink documentation. > > > > Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> > > Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> > > --- > > Documentation/networking/devlink/ice.rst | 11 +++ > > .../net/ethernet/intel/ice/devlink/devlink.c | 83 ++++++++++++++++++- > > drivers/net/ethernet/intel/ice/ice.h | 7 ++ > > drivers/net/ethernet/intel/ice/ice_irq.c | 7 ++ > > 4 files changed, 107 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/networking/devlink/ice.rst b/Documentation/networking/devlink/ice.rst > > index e3972d03cea0..792e9f8c846a 100644 > > --- a/Documentation/networking/devlink/ice.rst > > +++ b/Documentation/networking/devlink/ice.rst > > @@ -69,6 +69,17 @@ Parameters > > > > To verify that value has been set: > > $ devlink dev param show pci/0000:16:00.0 name tx_scheduling_layers > > + * - ``msix_vec_per_pf_max`` > > + - driverinit > > + - Set the max MSI-X that can be used by the PF, rest can be utilized for > > + SRIOV. The range is from min value set in msix_vec_per_pf_min to > > + 2k/number of ports. > > + * - ``msix_vec_per_pf_min`` > > + - driverinit > > + - Set the min MSI-X that will be used by the PF. This value inform how many > > + MSI-X will be allocated statically. The range is from 2 to value set > > + in msix_vec_per_pf_max. > > + > > .. list-table:: Driver specific parameters implemented > > :widths: 5 5 90 > > > > diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c > > index d1b9ccec5e05..29c1fec4fa93 100644 > > --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c > > +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c > > @@ -1198,6 +1198,25 @@ static int ice_devlink_set_parent(struct devlink_rate *devlink_rate, > > return status; > > } > > > > +static void ice_set_min_max_msix(struct ice_pf *pf) > > +{ > > + struct devlink *devlink = priv_to_devlink(pf); > > + union devlink_param_value val; > > + int err; > > + > > + err = devl_param_driverinit_value_get(devlink, > > + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, > > + &val); > > + if (!err) > > + pf->msix.min = val.vu16; > > + > > + err = devl_param_driverinit_value_get(devlink, > > + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, > > + &val); > > + if (!err) > > + pf->msix.max = val.vu16; > > +} > > + > > /** > > * ice_devlink_reinit_up - do reinit of the given PF > > * @pf: pointer to the PF struct > > @@ -1207,6 +1226,9 @@ static int ice_devlink_reinit_up(struct ice_pf *pf) > > struct ice_vsi *vsi = ice_get_main_vsi(pf); > > int err; > > > > + /* load MSI-X values */ > > + ice_set_min_max_msix(pf); > > + > > err = ice_init_hw(&pf->hw); > > if (err) { > > dev_err(ice_pf_to_dev(pf), "ice_init_hw failed: %d\n", err); > > @@ -1526,6 +1548,37 @@ static int ice_devlink_local_fwd_validate(struct devlink *devlink, u32 id, > > 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) > > +{ > > + struct ice_pf *pf = devlink_priv(devlink); > > + > > + if (val.vu16 > pf->hw.func_caps.common_cap.num_msix_vectors || > > + val.vu16 < pf->msix.min) { > > + NL_SET_ERR_MSG_MOD(extack, "Value is invalid"); > > + return -EINVAL; > > + } > > + > > + 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) > > +{ > > + struct ice_pf *pf = devlink_priv(devlink); > > + > > + if (val.vu16 <= ICE_MIN_MSIX || val.vu16 > pf->msix.max) { > > + NL_SET_ERR_MSG_MOD(extack, "Value is invalid"); > > + return -EINVAL; > > + } > > + > > + return 0; > > +} > > + > > enum ice_param_id { > > ICE_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, > > ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS, > > @@ -1543,6 +1596,15 @@ static const struct devlink_param ice_dvl_rdma_params[] = { > > ice_devlink_enable_iw_validate), > > }; > > > > +static const struct devlink_param ice_dvl_msix_params[] = { > > + DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MAX, > > + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), > > + NULL, NULL, ice_devlink_msix_max_pf_validate), > > + DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MIN, > > + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), > > + NULL, NULL, ice_devlink_msix_min_pf_validate), > > +}; > > + > > static const struct devlink_param ice_dvl_sched_params[] = { > > DEVLINK_PARAM_DRIVER(ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS, > > "tx_scheduling_layers", > > @@ -1644,6 +1706,7 @@ void ice_devlink_unregister(struct ice_pf *pf) > > int ice_devlink_register_params(struct ice_pf *pf) > > { > > struct devlink *devlink = priv_to_devlink(pf); > > + union devlink_param_value value; > > struct ice_hw *hw = &pf->hw; > > int status; > > > > @@ -1652,11 +1715,27 @@ int ice_devlink_register_params(struct ice_pf *pf) > > if (status) > > return status; > > > > + status = devl_params_register(devlink, ice_dvl_msix_params, > > + ARRAY_SIZE(ice_dvl_msix_params)); > > + if (status) > > + return status; > > + > > if (hw->func_caps.common_cap.tx_sched_topo_comp_mode_en) > > status = devl_params_register(devlink, ice_dvl_sched_params, > > ARRAY_SIZE(ice_dvl_sched_params)); > > + if (status) > > + return status; > > > > - return status; > > + value.vu16 = pf->msix.max; > > + devl_param_driverinit_value_set(devlink, > > + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, > > + value); > > + value.vu16 = pf->msix.min; > > + devl_param_driverinit_value_set(devlink, > > + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, > > + value); > > + > > + return 0; > > } > > > The type of the devlink parameters msix_vec_per_pf_{min,max} is > specified as u32, so you must use value.vu32 everywhere you work with > them, not vu16. > I will change it. > Michal >
On Thu, Oct 31, 2024 at 10:58:03PM +0100, Michal Schmidt wrote: > On Mon, Oct 28, 2024 at 11:04 AM Michal Swiatkowski > <michal.swiatkowski@linux.intel.com> wrote: > > > > Use generic devlink PF MSI-X parameter to allow user to change MSI-X > > range. > > > > Add notes about this parameters into ice devlink documentation. > > > > Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> > > Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> > > --- > > Documentation/networking/devlink/ice.rst | 11 +++ > > .../net/ethernet/intel/ice/devlink/devlink.c | 83 ++++++++++++++++++- > > drivers/net/ethernet/intel/ice/ice.h | 7 ++ > > drivers/net/ethernet/intel/ice/ice_irq.c | 7 ++ > > 4 files changed, 107 insertions(+), 1 deletion(-) > > > ... > > @@ -1526,6 +1548,37 @@ static int ice_devlink_local_fwd_validate(struct devlink *devlink, u32 id, > > 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) > > +{ > > + struct ice_pf *pf = devlink_priv(devlink); > > + > > + if (val.vu16 > pf->hw.func_caps.common_cap.num_msix_vectors || > > + val.vu16 < pf->msix.min) { > > + NL_SET_ERR_MSG_MOD(extack, "Value is invalid"); > > + return -EINVAL; > > + } > > + > > + 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) > > +{ > > + struct ice_pf *pf = devlink_priv(devlink); > > + > > + if (val.vu16 <= ICE_MIN_MSIX || val.vu16 > pf->msix.max) { > > Shouldn't this be "<" instead of "<=" ? > Yeah, will fix. > Michal >
From: Michal Swiatkowski > Sent: 04 November 2024 07:03 ... > > The type of the devlink parameters msix_vec_per_pf_{min,max} is > > specified as u32, so you must use value.vu32 everywhere you work with > > them, not vu16. > > > > I will change it. You also need a pretty good reason to use u16 anywhere at all. Just because the domain of the value is small doesn't mean the best type isn't [unsigned] int. Any arithmetic (particularly on non x86) is likely to increase the code size above any perceived data saving. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Dear David, dear Michal, Am 04.11.24 um 09:51 schrieb David Laight: > From: Michal Swiatkowski >> Sent: 04 November 2024 07:03 > ... >>> The type of the devlink parameters msix_vec_per_pf_{min,max} is >>> specified as u32, so you must use value.vu32 everywhere you work with >>> them, not vu16. >>> >> >> I will change it. > > You also need a pretty good reason to use u16 anywhere at all. > Just because the domain of the value is small doesn't mean the > best type isn't [unsigned] int. > > Any arithmetic (particularly on non x86) is likely to increase > the code size above any perceived data saving. In 2012 Scott Duplichan wrote *Small Integers: Big Penalty* [1]. Of course you always should measure yourself. Kind regards, Paul [1]: https://notabs.org/coding/smallIntsBigPenalty.htm
[Cc: -nex.sw.ncis.nat.hpm.dev@intel.com (550 #5.1.0 Address rejected.)] Am 04.11.24 um 10:09 schrieb Paul Menzel: > Dear David, dear Michal, > > > Am 04.11.24 um 09:51 schrieb David Laight: >> From: Michal Swiatkowski >>> Sent: 04 November 2024 07:03 >> ... >>>> The type of the devlink parameters msix_vec_per_pf_{min,max} is >>>> specified as u32, so you must use value.vu32 everywhere you work with >>>> them, not vu16. >>>> >>> >>> I will change it. >> >> You also need a pretty good reason to use u16 anywhere at all. >> Just because the domain of the value is small doesn't mean the >> best type isn't [unsigned] int. >> >> Any arithmetic (particularly on non x86) is likely to increase >> the code size above any perceived data saving. > > In 2012 Scott Duplichan wrote *Small Integers: Big Penalty* [1]. Of > course you always should measure yourself. > > > Kind regards, > > Paul > > > [1]: https://notabs.org/coding/smallIntsBigPenalty.htm
On Mon, Nov 04, 2024 at 10:12:14AM +0100, Paul Menzel wrote: > [Cc: -nex.sw.ncis.nat.hpm.dev@intel.com (550 #5.1.0 Address rejected.)] > > Am 04.11.24 um 10:09 schrieb Paul Menzel: > > Dear David, dear Michal, > > > > > > Am 04.11.24 um 09:51 schrieb David Laight: > > > From: Michal Swiatkowski > > > > Sent: 04 November 2024 07:03 > > > ... > > > > > The type of the devlink parameters msix_vec_per_pf_{min,max} is > > > > > specified as u32, so you must use value.vu32 everywhere you work with > > > > > them, not vu16. > > > > > > > > > > > > > I will change it. > > > > > > You also need a pretty good reason to use u16 anywhere at all. > > > Just because the domain of the value is small doesn't mean the > > > best type isn't [unsigned] int. > > > > > > Any arithmetic (particularly on non x86) is likely to increase > > > the code size above any perceived data saving. > > > > In 2012 Scott Duplichan wrote *Small Integers: Big Penalty* [1]. Of > > course you always should measure yourself. > > Yeah, I chose it, because previously it was stored in u16. I will change it to u32 too, as it is stored in structure that doesn't really need to be small. Thanks for comments and link to the article. Michal > > > > Kind regards, > > > > Paul > > > > > > [1]: https://notabs.org/coding/smallIntsBigPenalty.htm
> -----Original Message----- > From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> > Sent: Monday, November 4, 2024 3:25 AM > To: Paul Menzel <pmenzel@molgen.mpg.de> > Cc: David Laight <David.Laight@aculab.com>; Drewek, Wojciech > <wojciech.drewek@intel.com>; Szycik, Marcin <marcin.szycik@intel.com>; > netdev@vger.kernel.org; Knitter, Konrad <konrad.knitter@intel.com>; > Chmielewski, Pawel <pawel.chmielewski@intel.com>; horms@kernel.org; intel- > wired-lan@lists.osuosl.org; pio.raczynski@gmail.com; Samudrala, Sridhar > <sridhar.samudrala@intel.com>; Keller, Jacob E <jacob.e.keller@intel.com>; > jiri@resnulli.us; Kitszel, Przemyslaw <przemyslaw.kitszel@intel.com> > Subject: Re: [Intel-wired-lan] Small Integers: Big Penalty > > On Mon, Nov 04, 2024 at 10:12:14AM +0100, Paul Menzel wrote: > > [Cc: -nex.sw.ncis.nat.hpm.dev@intel.com (550 #5.1.0 Address rejected.)] > > > > Am 04.11.24 um 10:09 schrieb Paul Menzel: > > > Dear David, dear Michal, > > > > > > > > > Am 04.11.24 um 09:51 schrieb David Laight: > > > > From: Michal Swiatkowski > > > > > Sent: 04 November 2024 07:03 > > > > ... > > > > > > The type of the devlink parameters msix_vec_per_pf_{min,max} is > > > > > > specified as u32, so you must use value.vu32 everywhere you work with > > > > > > them, not vu16. > > > > > > > > > > > > > > > > I will change it. > > > > > > > > You also need a pretty good reason to use u16 anywhere at all. > > > > Just because the domain of the value is small doesn't mean the > > > > best type isn't [unsigned] int. > > > > > > > > Any arithmetic (particularly on non x86) is likely to increase > > > > the code size above any perceived data saving. > > > > > > In 2012 Scott Duplichan wrote *Small Integers: Big Penalty* [1]. Of > > > course you always should measure yourself. > > > > > Yeah, I chose it, because previously it was stored in u16. I will change > it to u32 too, as it is stored in structure that doesn't really need to > be small. > > Thanks for comments and link to the article. > Michal > Yea.. ice driver code has a bad habit of using smaller size values in structures when its unnecessary.
diff --git a/Documentation/networking/devlink/ice.rst b/Documentation/networking/devlink/ice.rst index e3972d03cea0..792e9f8c846a 100644 --- a/Documentation/networking/devlink/ice.rst +++ b/Documentation/networking/devlink/ice.rst @@ -69,6 +69,17 @@ Parameters To verify that value has been set: $ devlink dev param show pci/0000:16:00.0 name tx_scheduling_layers + * - ``msix_vec_per_pf_max`` + - driverinit + - Set the max MSI-X that can be used by the PF, rest can be utilized for + SRIOV. The range is from min value set in msix_vec_per_pf_min to + 2k/number of ports. + * - ``msix_vec_per_pf_min`` + - driverinit + - Set the min MSI-X that will be used by the PF. This value inform how many + MSI-X will be allocated statically. The range is from 2 to value set + in msix_vec_per_pf_max. + .. list-table:: Driver specific parameters implemented :widths: 5 5 90 diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c index d1b9ccec5e05..29c1fec4fa93 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c @@ -1198,6 +1198,25 @@ static int ice_devlink_set_parent(struct devlink_rate *devlink_rate, return status; } +static void ice_set_min_max_msix(struct ice_pf *pf) +{ + struct devlink *devlink = priv_to_devlink(pf); + union devlink_param_value val; + int err; + + err = devl_param_driverinit_value_get(devlink, + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, + &val); + if (!err) + pf->msix.min = val.vu16; + + err = devl_param_driverinit_value_get(devlink, + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, + &val); + if (!err) + pf->msix.max = val.vu16; +} + /** * ice_devlink_reinit_up - do reinit of the given PF * @pf: pointer to the PF struct @@ -1207,6 +1226,9 @@ static int ice_devlink_reinit_up(struct ice_pf *pf) struct ice_vsi *vsi = ice_get_main_vsi(pf); int err; + /* load MSI-X values */ + ice_set_min_max_msix(pf); + err = ice_init_hw(&pf->hw); if (err) { dev_err(ice_pf_to_dev(pf), "ice_init_hw failed: %d\n", err); @@ -1526,6 +1548,37 @@ static int ice_devlink_local_fwd_validate(struct devlink *devlink, u32 id, 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) +{ + struct ice_pf *pf = devlink_priv(devlink); + + if (val.vu16 > pf->hw.func_caps.common_cap.num_msix_vectors || + val.vu16 < pf->msix.min) { + NL_SET_ERR_MSG_MOD(extack, "Value is invalid"); + return -EINVAL; + } + + 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) +{ + struct ice_pf *pf = devlink_priv(devlink); + + if (val.vu16 <= ICE_MIN_MSIX || val.vu16 > pf->msix.max) { + NL_SET_ERR_MSG_MOD(extack, "Value is invalid"); + return -EINVAL; + } + + return 0; +} + enum ice_param_id { ICE_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS, @@ -1543,6 +1596,15 @@ static const struct devlink_param ice_dvl_rdma_params[] = { ice_devlink_enable_iw_validate), }; +static const struct devlink_param ice_dvl_msix_params[] = { + DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MAX, + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), + NULL, NULL, ice_devlink_msix_max_pf_validate), + DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MIN, + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), + NULL, NULL, ice_devlink_msix_min_pf_validate), +}; + static const struct devlink_param ice_dvl_sched_params[] = { DEVLINK_PARAM_DRIVER(ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS, "tx_scheduling_layers", @@ -1644,6 +1706,7 @@ void ice_devlink_unregister(struct ice_pf *pf) int ice_devlink_register_params(struct ice_pf *pf) { struct devlink *devlink = priv_to_devlink(pf); + union devlink_param_value value; struct ice_hw *hw = &pf->hw; int status; @@ -1652,11 +1715,27 @@ int ice_devlink_register_params(struct ice_pf *pf) if (status) return status; + status = devl_params_register(devlink, ice_dvl_msix_params, + ARRAY_SIZE(ice_dvl_msix_params)); + if (status) + return status; + if (hw->func_caps.common_cap.tx_sched_topo_comp_mode_en) status = devl_params_register(devlink, ice_dvl_sched_params, ARRAY_SIZE(ice_dvl_sched_params)); + if (status) + return status; - return status; + value.vu16 = pf->msix.max; + devl_param_driverinit_value_set(devlink, + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX, + value); + value.vu16 = pf->msix.min; + devl_param_driverinit_value_set(devlink, + DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN, + value); + + return 0; } void ice_devlink_unregister_params(struct ice_pf *pf) @@ -1666,6 +1745,8 @@ void ice_devlink_unregister_params(struct ice_pf *pf) devl_params_unregister(devlink, ice_dvl_rdma_params, ARRAY_SIZE(ice_dvl_rdma_params)); + devl_params_unregister(devlink, ice_dvl_msix_params, + ARRAY_SIZE(ice_dvl_msix_params)); if (hw->func_caps.common_cap.tx_sched_topo_comp_mode_en) devl_params_unregister(devlink, ice_dvl_sched_params, diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 7997745686b3..c6cd7e993ed8 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -543,6 +543,12 @@ struct ice_agg_node { u8 valid; }; +struct ice_pf_msix { + u16 cur; + u16 min; + u16 max; +}; + struct ice_pf { struct pci_dev *pdev; struct ice_adapter *adapter; @@ -613,6 +619,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_irq.c b/drivers/net/ethernet/intel/ice/ice_irq.c index ad82ff7d1995..0659b96b9b8c 100644 --- a/drivers/net/ethernet/intel/ice/ice_irq.c +++ b/drivers/net/ethernet/intel/ice/ice_irq.c @@ -254,6 +254,13 @@ 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)