From: Hao Lan <lanhao@huawei.com>
Currently, the queried maximum of vf channels is the maximum of channels
supported by each TC. However, the actual maximum of channels is
the maximum of channels supported by the device.
Fixes: 849e46077689 ("net: hns3: add ethtool_ops.get_channels support for VF")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Hao Lan <lanhao@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 33136a1e02cf..626f5419fd7d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -3094,11 +3094,7 @@ static void hclgevf_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
static u32 hclgevf_get_max_channels(struct hclgevf_dev *hdev)
{
- struct hnae3_handle *nic = &hdev->nic;
- struct hnae3_knic_private_info *kinfo = &nic->kinfo;
-
- return min_t(u32, hdev->rss_size_max,
- hdev->num_tqps / kinfo->tc_info.num_tc);
+ return min_t(u32, hdev->rss_size_max, hdev->num_tqps);
}
/**
--
2.33.0
+ David Laight On Wed, Jul 02, 2025 at 09:09:00PM +0800, Jijie Shao wrote: > From: Hao Lan <lanhao@huawei.com> > > Currently, the queried maximum of vf channels is the maximum of channels > supported by each TC. However, the actual maximum of channels is > the maximum of channels supported by the device. > > Fixes: 849e46077689 ("net: hns3: add ethtool_ops.get_channels support for VF") > Signed-off-by: Jian Shen <shenjian15@huawei.com> > Signed-off-by: Hao Lan <lanhao@huawei.com> > Signed-off-by: Jijie Shao <shaojijie@huawei.com> Reviewed-by: Simon Horman <horms@kernel.org> > --- > drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > index 33136a1e02cf..626f5419fd7d 100644 > --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > @@ -3094,11 +3094,7 @@ static void hclgevf_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) > > static u32 hclgevf_get_max_channels(struct hclgevf_dev *hdev) > { > - struct hnae3_handle *nic = &hdev->nic; > - struct hnae3_knic_private_info *kinfo = &nic->kinfo; > - > - return min_t(u32, hdev->rss_size_max, > - hdev->num_tqps / kinfo->tc_info.num_tc); > + return min_t(u32, hdev->rss_size_max, hdev->num_tqps); min_t() wasn't needed before and it certainly doesn't seem to be needed now, as both .rss_size_max, and .num_tqps are u16. As a follow-up, once this change hits net-next, please update to use min() instead. Likely elsewhere too.
On Fri, 4 Jul 2025 17:05:37 +0100 Simon Horman <horms@kernel.org> wrote: > + David Laight > > On Wed, Jul 02, 2025 at 09:09:00PM +0800, Jijie Shao wrote: > > From: Hao Lan <lanhao@huawei.com> > > > > Currently, the queried maximum of vf channels is the maximum of channels > > supported by each TC. However, the actual maximum of channels is > > the maximum of channels supported by the device. > > > > Fixes: 849e46077689 ("net: hns3: add ethtool_ops.get_channels support for VF") > > Signed-off-by: Jian Shen <shenjian15@huawei.com> > > Signed-off-by: Hao Lan <lanhao@huawei.com> > > Signed-off-by: Jijie Shao <shaojijie@huawei.com> > > Reviewed-by: Simon Horman <horms@kernel.org> > > > --- > > drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 6 +----- > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > > index 33136a1e02cf..626f5419fd7d 100644 > > --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > > @@ -3094,11 +3094,7 @@ static void hclgevf_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) > > > > static u32 hclgevf_get_max_channels(struct hclgevf_dev *hdev) > > { > > - struct hnae3_handle *nic = &hdev->nic; > > - struct hnae3_knic_private_info *kinfo = &nic->kinfo; > > - > > - return min_t(u32, hdev->rss_size_max, > > - hdev->num_tqps / kinfo->tc_info.num_tc); > > + return min_t(u32, hdev->rss_size_max, hdev->num_tqps); > > min_t() wasn't needed before and it certainly doesn't seem to be needed > now, as both .rss_size_max, and .num_tqps are u16. It (well something) would have been needed before the min_t() changes. The u16 values get promoted to 'signed int' prior to the division. > > As a follow-up, once this change hits net-next, please update to use min() > instead. Likely elsewhere too. Especially any min_t(u16, ...) or u8 ones. They are just so wrong and have caused bugs. David
on 2025/7/5 15:24, David Laight wrote: > On Fri, 4 Jul 2025 17:05:37 +0100 > Simon Horman <horms@kernel.org> wrote: > >> + David Laight >> >> On Wed, Jul 02, 2025 at 09:09:00PM +0800, Jijie Shao wrote: >>> From: Hao Lan <lanhao@huawei.com> >>> >>> Currently, the queried maximum of vf channels is the maximum of channels >>> supported by each TC. However, the actual maximum of channels is >>> the maximum of channels supported by the device. >>> >>> Fixes: 849e46077689 ("net: hns3: add ethtool_ops.get_channels support for VF") >>> Signed-off-by: Jian Shen <shenjian15@huawei.com> >>> Signed-off-by: Hao Lan <lanhao@huawei.com> >>> Signed-off-by: Jijie Shao <shaojijie@huawei.com> >> Reviewed-by: Simon Horman <horms@kernel.org> >> >>> --- >>> drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 6 +----- >>> 1 file changed, 1 insertion(+), 5 deletions(-) >>> >>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c >>> index 33136a1e02cf..626f5419fd7d 100644 >>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c >>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c >>> @@ -3094,11 +3094,7 @@ static void hclgevf_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) >>> >>> static u32 hclgevf_get_max_channels(struct hclgevf_dev *hdev) >>> { >>> - struct hnae3_handle *nic = &hdev->nic; >>> - struct hnae3_knic_private_info *kinfo = &nic->kinfo; >>> - >>> - return min_t(u32, hdev->rss_size_max, >>> - hdev->num_tqps / kinfo->tc_info.num_tc); >>> + return min_t(u32, hdev->rss_size_max, hdev->num_tqps); >> min_t() wasn't needed before and it certainly doesn't seem to be needed >> now, as both .rss_size_max, and .num_tqps are u16. > It (well something) would have been needed before the min_t() changes. > The u16 values get promoted to 'signed int' prior to the division. > >> As a follow-up, once this change hits net-next, please update to use min() >> instead. Likely elsewhere too. > Especially any min_t(u16, ...) or u8 ones. > They are just so wrong and have caused bugs. > > David Does this mean that min_t() will be deprecated? If so, I will replace all instances of min_t() with min() in the hns3 driver. Thanks Jijie Shao
On Tue, Jul 08, 2025 at 05:37:11PM +0800, Jijie Shao wrote: > > on 2025/7/5 15:24, David Laight wrote: > > On Fri, 4 Jul 2025 17:05:37 +0100 > > Simon Horman <horms@kernel.org> wrote: > > > > > + David Laight > > > > > > On Wed, Jul 02, 2025 at 09:09:00PM +0800, Jijie Shao wrote: > > > > From: Hao Lan <lanhao@huawei.com> > > > > > > > > Currently, the queried maximum of vf channels is the maximum of channels > > > > supported by each TC. However, the actual maximum of channels is > > > > the maximum of channels supported by the device. > > > > > > > > Fixes: 849e46077689 ("net: hns3: add ethtool_ops.get_channels support for VF") > > > > Signed-off-by: Jian Shen <shenjian15@huawei.com> > > > > Signed-off-by: Hao Lan <lanhao@huawei.com> > > > > Signed-off-by: Jijie Shao <shaojijie@huawei.com> > > > Reviewed-by: Simon Horman <horms@kernel.org> > > > > > > > --- > > > > drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 6 +----- > > > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > > > > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > > > > index 33136a1e02cf..626f5419fd7d 100644 > > > > --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > > > > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > > > > @@ -3094,11 +3094,7 @@ static void hclgevf_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) > > > > static u32 hclgevf_get_max_channels(struct hclgevf_dev *hdev) > > > > { > > > > - struct hnae3_handle *nic = &hdev->nic; > > > > - struct hnae3_knic_private_info *kinfo = &nic->kinfo; > > > > - > > > > - return min_t(u32, hdev->rss_size_max, > > > > - hdev->num_tqps / kinfo->tc_info.num_tc); > > > > + return min_t(u32, hdev->rss_size_max, hdev->num_tqps); > > > min_t() wasn't needed before and it certainly doesn't seem to be needed > > > now, as both .rss_size_max, and .num_tqps are u16. > > It (well something) would have been needed before the min_t() changes. > > The u16 values get promoted to 'signed int' prior to the division. > > > > > As a follow-up, once this change hits net-next, please update to use min() > > > instead. Likely elsewhere too. > > Especially any min_t(u16, ...) or u8 ones. > > They are just so wrong and have caused bugs. > > > > David > > > Does this mean that min_t() will be deprecated? > If so, I will replace all instances of min_t() with min() in the hns3 driver. No, it means that min_t() should only be used when it is needed. AFAIK, basically when the operands need to be cast.
© 2016 - 2025 Red Hat, Inc.