From: Huazhong Tan <tanhuazhong@huawei.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<salil.mehta@huawei.com>, <yisen.zhuang@huawei.com>,
<linuxarm@huawei.com>, <kuba@kernel.org>,
Huazhong Tan <tanhuazhong@huawei.com>
Subject: [PATCH net-next 04/12] net: hns3: refactor hclge_query_bd_num_cmd_send()
Date: Thu, 28 May 2020 21:48:11 +0800 [thread overview]
Message-ID: <1590673699-63819-5-git-send-email-tanhuazhong@huawei.com> (raw)
In-Reply-To: <1590673699-63819-1-git-send-email-tanhuazhong@huawei.com>
In order to improve code maintainability and readability, rewrite
the process of BDs' initialization in hclge_query_bd_num_cmd_send().
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
---
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 35e5cb8..e9b0e1c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -10723,16 +10723,19 @@ static int hclge_get_64_bit_regs(struct hclge_dev *hdev, u32 regs_num,
int hclge_query_bd_num_cmd_send(struct hclge_dev *hdev, struct hclge_desc *desc)
{
- /*prepare 4 commands to query DFX BD number*/
- hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_DFX_BD_NUM, true);
- desc[0].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
- hclge_cmd_setup_basic_desc(&desc[1], HCLGE_OPC_DFX_BD_NUM, true);
- desc[1].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
- hclge_cmd_setup_basic_desc(&desc[2], HCLGE_OPC_DFX_BD_NUM, true);
- desc[2].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
- hclge_cmd_setup_basic_desc(&desc[3], HCLGE_OPC_DFX_BD_NUM, true);
+ int i;
+
+ /* initialize command BD except the last one */
+ for (i = 0; i < HCLGE_GET_DFX_REG_TYPE_CNT - 1; i++) {
+ hclge_cmd_setup_basic_desc(&desc[i], HCLGE_OPC_DFX_BD_NUM,
+ true);
+ desc[i].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
+ }
+
+ /* initialize the last command BD */
+ hclge_cmd_setup_basic_desc(&desc[i], HCLGE_OPC_DFX_BD_NUM, true);
- return hclge_cmd_send(&hdev->hw, desc, 4);
+ return hclge_cmd_send(&hdev->hw, desc, HCLGE_GET_DFX_REG_TYPE_CNT);
}
static int hclge_get_dfx_reg_bd_num(struct hclge_dev *hdev,
--
2.7.4
next prev parent reply other threads:[~2020-05-28 13:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-28 13:48 [PATCH net-next 00/12] net: hns3: misc updates for -next Huazhong Tan
2020-05-28 13:48 ` [PATCH net-next 01/12] net: hns3: remove an unnecessary 'goto' in hclge_init_ae_dev() Huazhong Tan
2020-05-28 13:48 ` [PATCH net-next 02/12] net: hns3: add a missing mutex destroy in hclge_init_ad_dev() Huazhong Tan
2020-05-28 13:48 ` [PATCH net-next 03/12] net: hns3: refactor hclge_config_tso() Huazhong Tan
2020-05-28 13:48 ` Huazhong Tan [this message]
2020-05-28 13:48 ` [PATCH net-next 05/12] net: hns3: modify an incorrect type in struct hclge_cfg_gro_status_cmd Huazhong Tan
2020-05-28 13:48 ` [PATCH net-next 06/12] net: hns3: modify an incorrect type in struct hclgevf_cfg_gro_status_cmd Huazhong Tan
2020-05-28 13:48 ` [PATCH net-next 07/12] net: hns3: remove some unused fields in struct hns3_nic_priv Huazhong Tan
2020-05-28 13:48 ` [PATCH net-next 08/12] net: hns3; remove unused HNAE3_RESTORE_CLIENT in enum hnae3_reset_notify_type Huazhong Tan
2020-05-28 13:48 ` [PATCH net-next 09/12] net: hns3: remove unused struct hnae3_unic_private_info Huazhong Tan
2020-05-28 13:48 ` [PATCH net-next 10/12] net: hns3: remove two duplicated register macros in hclgevf_main.h Huazhong Tan
2020-05-28 13:48 ` [PATCH net-next 11/12] net: hns3: remove some unused fields in struct hclge_dev Huazhong Tan
2020-05-28 13:48 ` [PATCH net-next 12/12] net: hns3: print out speed info when parsing speed fails Huazhong Tan
2020-05-28 23:39 ` [PATCH net-next 00/12] net: hns3: misc updates for -next 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=1590673699-63819-5-git-send-email-tanhuazhong@huawei.com \
--to=tanhuazhong@huawei.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--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;
as well as URLs for NNTP newsgroup(s).