diff options
author | Huazhong Tan <tanhuazhong@huawei.com> | 2019-05-28 17:02:56 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-05-28 17:39:01 -0700 |
commit | 25d1817c4e5020b850b8bc383401ceff3cbc6e31 (patch) | |
tree | 653380706af2f01f91956b0ceee08f15ade50dc4 | |
parent | net: hns3: use HCLGE_STATE_ROCE_REGISTERED to indicate PF ROCE client has registered (diff) | |
download | linux-dev-25d1817c4e5020b850b8bc383401ceff3cbc6e31.tar.xz linux-dev-25d1817c4e5020b850b8bc383401ceff3cbc6e31.zip |
net: hns3: use HCLGEVF_STATE_NIC_REGISTERED to indicate VF NIC client has registered
When VF NIC client's init_instance() succeeds, it means this client
has been registered successfully, so we use HCLGEVF_STATE_NIC_REGISTERED
to indicate that. And before calling VF NIC client's uninit_instance(),
we clear this state.
So any operation of VF NIC client from HCLGEVF is not allowed if this
state is not set.
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 7 | ||||
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 5d53467ee2d2..8b3f8fdd4492 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1306,6 +1306,10 @@ static int hclgevf_notify_client(struct hclgevf_dev *hdev, struct hnae3_handle *handle = &hdev->nic; int ret; + if (!test_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state) || + !client) + return 0; + if (!client->ops->reset_notify) return -EOPNOTSUPP; @@ -2265,6 +2269,7 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, goto clear_nic; hnae3_set_client_init_flag(client, ae_dev, 1); + set_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state); if (netif_msg_drv(&hdev->nic)) hclgevf_info_show(hdev); @@ -2342,6 +2347,8 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client, /* un-init nic/unic, if this was not called by roce client */ if (client->ops->uninit_instance && hdev->nic_client && client->type != HNAE3_CLIENT_ROCE) { + clear_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state); + client->ops->uninit_instance(&hdev->nic, 0); hdev->nic_client = NULL; hdev->nic.client = NULL; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index cc52f54f8c08..eab1095bf221 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -130,6 +130,7 @@ enum hclgevf_states { HCLGEVF_STATE_DOWN, HCLGEVF_STATE_DISABLED, HCLGEVF_STATE_IRQ_INITED, + HCLGEVF_STATE_NIC_REGISTERED, /* task states */ HCLGEVF_STATE_SERVICE_SCHED, HCLGEVF_STATE_RST_SERVICE_SCHED, |