From: tanhuazhong <tanhuazhong@huawei.com>
To: Michal Kubecek <mkubecek@suse.cz>, <netdev@vger.kernel.org>
Cc: <davem@davemloft.net>, <linux-kernel@vger.kernel.org>,
<salil.mehta@huawei.com>, <yisen.zhuang@huawei.com>,
<linuxarm@huawei.com>, <jakub.kicinski@netronome.com>
Subject: Re: [PATCH V2 net-next 1/7] net: hns3: add ethtool_ops.set_channels support for HNS3 VF driver
Date: Thu, 12 Sep 2019 16:20:47 +0800 [thread overview]
Message-ID: <8d51697c-703e-09f2-74e1-c83a31b5f52f@huawei.com> (raw)
In-Reply-To: <20190912062301.GE24779@unicorn.suse.cz>
Hi, Michal
On 2019/9/12 14:23, Michal Kubecek wrote:
> On Wed, Sep 11, 2019 at 10:40:33AM +0800, Huazhong Tan wrote:
>> From: Guangbin Huang <huangguangbin2@huawei.com>
>>
>> This patch adds ethtool_ops.set_channels support for HNS3 VF driver,
>> and updates related TQP information and RSS information, to support
>> modification of VF TQP number, and uses current rss_size instead of
>> max_rss_size to initialize RSS.
>>
>> Also, fixes a format error in hclgevf_get_rss().
>>
>> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
>> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
>> ---
>> drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 1 +
>> .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 83 ++++++++++++++++++++--
>> 2 files changed, 79 insertions(+), 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 594cae8..e3090b3 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
> ...
>> +static void hclgevf_update_rss_size(struct hnae3_handle *handle,
>> + u32 new_tqps_num)
>> +{
>> + struct hnae3_knic_private_info *kinfo = &handle->kinfo;
>> + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
>> + u16 max_rss_size;
>> +
>> + kinfo->req_rss_size = new_tqps_num;
>> +
>> + max_rss_size = min_t(u16, hdev->rss_size_max,
>> + hdev->num_tqps / kinfo->num_tc);
>> +
>> + /* Use the user's configuration when it is not larger than
>> + * max_rss_size, otherwise, use the maximum specification value.
>> + */
>> + if (kinfo->req_rss_size != kinfo->rss_size && kinfo->req_rss_size &&
>> + kinfo->req_rss_size <= max_rss_size)
>> + kinfo->rss_size = kinfo->req_rss_size;
>> + else if (kinfo->rss_size > max_rss_size ||
>> + (!kinfo->req_rss_size && kinfo->rss_size < max_rss_size))
>> + kinfo->rss_size = max_rss_size;
>
> I don't think requested channel count can be larger than max_rss_size
> here. In ethtool_set_channels(), we check that requested channel counts
> do not exceed maximum channel counts as reported by ->get_channels().
> And hclgevf_get_max_channels() cannot return more than max_rss_size.
>
When we can modify the TC number (which PF has already supported, VF may
implement in the future) using lldptool or tc cmd,
hclgevf_update_rss_size will be called to update the rss information,
which may also change max_rss_size, so we will use max_rss_size instead
if the kinfo->rss_size configured using ethtool is bigger than max_rss_size.
>> +
>> + kinfo->num_tqps = kinfo->num_tc * kinfo->rss_size;
>> +}
>> +
>> +static int hclgevf_set_channels(struct hnae3_handle *handle, u32 new_tqps_num,
>> + bool rxfh_configured)
>> +{
>> + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
>> + struct hnae3_knic_private_info *kinfo = &handle->kinfo;
>> + u16 cur_rss_size = kinfo->rss_size;
>> + u16 cur_tqps = kinfo->num_tqps;
>> + u32 *rss_indir;
>> + unsigned int i;
>> + int ret;
>> +
>> + hclgevf_update_rss_size(handle, new_tqps_num);
>> +
>> + ret = hclgevf_set_rss_tc_mode(hdev, kinfo->rss_size);
>> + if (ret)
>> + return ret;
>> +
>> + /* RSS indirection table has been configuared by user */
>> + if (rxfh_configured)
>> + goto out;
>> +
>> + /* Reinitializes the rss indirect table according to the new RSS size */
>> + rss_indir = kcalloc(HCLGEVF_RSS_IND_TBL_SIZE, sizeof(u32), GFP_KERNEL);
>> + if (!rss_indir)
>> + return -ENOMEM;
>> +
>> + for (i = 0; i < HCLGEVF_RSS_IND_TBL_SIZE; i++)
>> + rss_indir[i] = i % kinfo->rss_size;
>> +
>> + ret = hclgevf_set_rss(handle, rss_indir, NULL, 0);
>> + if (ret)
>> + dev_err(&hdev->pdev->dev, "set rss indir table fail, ret=%d\n",
>> + ret);
>> +
>> + kfree(rss_indir);
>> +
>> +out:
>> + if (!ret)
>> + dev_info(&hdev->pdev->dev,
>> + "Channels changed, rss_size from %u to %u, tqps from %u to %u",
>> + cur_rss_size, kinfo->rss_size,
>> + cur_tqps, kinfo->rss_size * kinfo->num_tc);
>> +
>> + return ret;
>> +}
>
> IIRC David asked you not to issue this log message in v1 review.
>
> Michal Kubecek
>
Sorry for missing this log.
Thanks.
> .
>
next prev parent reply other threads:[~2019-09-12 8:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-11 2:40 [PATCH V2 net-next 0/7] net: hns3: add a feature & bugfixes & cleanups Huazhong Tan
2019-09-11 2:40 ` [PATCH V2 net-next 1/7] net: hns3: add ethtool_ops.set_channels support for HNS3 VF driver Huazhong Tan
2019-09-12 6:23 ` Michal Kubecek
2019-09-12 8:20 ` tanhuazhong [this message]
2019-09-11 2:40 ` [PATCH V2 net-next 2/7] net: hns3: revert to old channel when setting new channel num fail Huazhong Tan
2019-09-11 2:40 ` [PATCH V2 net-next 3/7] net: hns3: fix shaper parameter algorithm Huazhong Tan
2019-09-11 2:40 ` [PATCH V2 net-next 4/7] net: hns3: fix port setting handle for fibre port Huazhong Tan
2019-09-11 10:16 ` Sergei Shtylyov
2019-09-12 0:56 ` tanhuazhong
2019-09-11 10:17 ` Sergei Shtylyov
2019-09-11 2:40 ` [PATCH V2 net-next 5/7] net: hns3: modify some logs format Huazhong Tan
2019-09-11 2:40 ` [PATCH V2 net-next 6/7] net: hns3: check NULL pointer before use Huazhong Tan
2019-09-11 2:40 ` [PATCH V2 net-next 7/7] net: hns3: add some DFX info for reset issue Huazhong Tan
2019-09-11 8:09 ` [PATCH V2 net-next 0/7] net: hns3: add a feature & bugfixes & cleanups David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8d51697c-703e-09f2-74e1-c83a31b5f52f@huawei.com \
--to=tanhuazhong@huawei.com \
--cc=davem@davemloft.net \
--cc=jakub.kicinski@netronome.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox