Skip to content

Commit

Permalink
net: hns3: use HCLGEVF_STATE_NIC_REGISTERED to indicate VF NIC client…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
Huazhong Tan authored and David S. Miller committed May 29, 2019
1 parent 2a0bfc3 commit 25d1817
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 25d1817

Please sign in to comment.