Commit 1db58f86 authored by Huazhong Tan's avatar Huazhong Tan Committed by David S. Miller

net: hns3: modify hclgevf_init_client_instance()

hclgevf_init_client_instance() is a little bloated and there is
some duplicated code. This patch adds some cleanup for it.
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 994e04f1
...@@ -2253,40 +2253,68 @@ static void hclgevf_info_show(struct hclgevf_dev *hdev) ...@@ -2253,40 +2253,68 @@ static void hclgevf_info_show(struct hclgevf_dev *hdev)
dev_info(dev, "VF info end.\n"); dev_info(dev, "VF info end.\n");
} }
static int hclgevf_init_client_instance(struct hnae3_client *client, static int hclgevf_init_nic_client_instance(struct hnae3_ae_dev *ae_dev,
struct hnae3_ae_dev *ae_dev) struct hnae3_client *client)
{ {
struct hclgevf_dev *hdev = ae_dev->priv; struct hclgevf_dev *hdev = ae_dev->priv;
int ret; int ret;
switch (client->type) {
case HNAE3_CLIENT_KNIC:
hdev->nic_client = client;
hdev->nic.client = client;
ret = client->ops->init_instance(&hdev->nic); ret = client->ops->init_instance(&hdev->nic);
if (ret) if (ret)
goto clear_nic; return ret;
hnae3_set_client_init_flag(client, ae_dev, 1);
set_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state); set_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state);
hnae3_set_client_init_flag(client, ae_dev, 1);
if (netif_msg_drv(&hdev->nic)) if (netif_msg_drv(&hdev->nic))
hclgevf_info_show(hdev); hclgevf_info_show(hdev);
if (hdev->roce_client && hnae3_dev_roce_supported(hdev)) { return 0;
struct hnae3_client *rc = hdev->roce_client; }
static int hclgevf_init_roce_client_instance(struct hnae3_ae_dev *ae_dev,
struct hnae3_client *client)
{
struct hclgevf_dev *hdev = ae_dev->priv;
int ret;
if (!hnae3_dev_roce_supported(hdev) || !hdev->roce_client ||
!hdev->nic_client)
return 0;
ret = hclgevf_init_roce_base_info(hdev); ret = hclgevf_init_roce_base_info(hdev);
if (ret) if (ret)
goto clear_roce; return ret;
ret = rc->ops->init_instance(&hdev->roce);
ret = client->ops->init_instance(&hdev->roce);
if (ret)
return ret;
hnae3_set_client_init_flag(client, ae_dev, 1);
return 0;
}
static int hclgevf_init_client_instance(struct hnae3_client *client,
struct hnae3_ae_dev *ae_dev)
{
struct hclgevf_dev *hdev = ae_dev->priv;
int ret;
switch (client->type) {
case HNAE3_CLIENT_KNIC:
hdev->nic_client = client;
hdev->nic.client = client;
ret = hclgevf_init_nic_client_instance(ae_dev, client);
if (ret)
goto clear_nic;
ret = hclgevf_init_roce_client_instance(ae_dev,
hdev->roce_client);
if (ret) if (ret)
goto clear_roce; goto clear_roce;
hnae3_set_client_init_flag(hdev->roce_client, ae_dev,
1);
}
break; break;
case HNAE3_CLIENT_UNIC: case HNAE3_CLIENT_UNIC:
hdev->nic_client = client; hdev->nic_client = client;
...@@ -2304,17 +2332,10 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, ...@@ -2304,17 +2332,10 @@ static int hclgevf_init_client_instance(struct hnae3_client *client,
hdev->roce.client = client; hdev->roce.client = client;
} }
if (hdev->roce_client && hdev->nic_client) { ret = hclgevf_init_roce_client_instance(ae_dev, client);
ret = hclgevf_init_roce_base_info(hdev);
if (ret) if (ret)
goto clear_roce; goto clear_roce;
ret = client->ops->init_instance(&hdev->roce);
if (ret)
goto clear_roce;
}
hnae3_set_client_init_flag(client, ae_dev, 1);
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment