net: hns3: Add VF Reset Service Task to support event handling
authorSalil Mehta <salil.mehta@huawei.com>
Thu, 22 Mar 2018 14:28:53 +0000 (14:28 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Mar 2018 19:29:03 +0000 (15:29 -0400)
VF reset would involve handling of different reset related events
from the stack, physical function, mailbox etc. Reset service task
would be used in servicing such reset event requests and later
handling the hardware completions waits and initiating the stack
resets.

Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h

index 6c3881d5dbf2d88bc7514e8be323ae5f207d42a6..cdb6e7ae3b70ac17ad59b1eca58148bae558cda0 100644 (file)
@@ -867,6 +867,15 @@ static void hclgevf_get_misc_vector(struct hclgevf_dev *hdev)
        hdev->num_msi_used += 1;
 }
 
+void hclgevf_reset_task_schedule(struct hclgevf_dev *hdev)
+{
+       if (!test_bit(HCLGEVF_STATE_RST_SERVICE_SCHED, &hdev->state) &&
+           !test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) {
+               set_bit(HCLGEVF_STATE_RST_SERVICE_SCHED, &hdev->state);
+               schedule_work(&hdev->rst_service_task);
+       }
+}
+
 static void hclgevf_mbx_task_schedule(struct hclgevf_dev *hdev)
 {
        if (!test_and_set_bit(HCLGEVF_STATE_MBX_SERVICE_SCHED, &hdev->state))
@@ -889,6 +898,24 @@ static void hclgevf_service_timer(struct timer_list *t)
        hclgevf_task_schedule(hdev);
 }
 
+static void hclgevf_reset_service_task(struct work_struct *work)
+{
+       struct hclgevf_dev *hdev =
+               container_of(work, struct hclgevf_dev, rst_service_task);
+
+       if (test_and_set_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state))
+               return;
+
+       clear_bit(HCLGEVF_STATE_RST_SERVICE_SCHED, &hdev->state);
+
+       /* body of the reset service task will constitute of hclge device
+        * reset state handling. This code shall be added subsequently in
+        * next patches.
+        */
+
+       clear_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state);
+}
+
 static void hclgevf_mailbox_service_task(struct work_struct *work)
 {
        struct hclgevf_dev *hdev;
@@ -1097,6 +1124,8 @@ static void hclgevf_state_init(struct hclgevf_dev *hdev)
        INIT_WORK(&hdev->service_task, hclgevf_service_task);
        clear_bit(HCLGEVF_STATE_SERVICE_SCHED, &hdev->state);
 
+       INIT_WORK(&hdev->rst_service_task, hclgevf_reset_service_task);
+
        mutex_init(&hdev->mbx_resp.mbx_mutex);
 
        /* bring the device down */
@@ -1113,6 +1142,8 @@ static void hclgevf_state_uninit(struct hclgevf_dev *hdev)
                cancel_work_sync(&hdev->service_task);
        if (hdev->mbx_service_task.func)
                cancel_work_sync(&hdev->mbx_service_task);
+       if (hdev->rst_service_task.func)
+               cancel_work_sync(&hdev->rst_service_task);
 
        mutex_destroy(&hdev->mbx_resp.mbx_mutex);
 }
index 0eaea063e7c5b21b6c89345954c526659dfcc137..8b5fa670ed1894e8810d6f3b7349ce1cae95a71f 100644 (file)
@@ -52,6 +52,8 @@ enum hclgevf_states {
        HCLGEVF_STATE_DISABLED,
        /* task states */
        HCLGEVF_STATE_SERVICE_SCHED,
+       HCLGEVF_STATE_RST_SERVICE_SCHED,
+       HCLGEVF_STATE_RST_HANDLING,
        HCLGEVF_STATE_MBX_SERVICE_SCHED,
        HCLGEVF_STATE_MBX_HANDLING,
 };
@@ -146,6 +148,7 @@ struct hclgevf_dev {
 
        struct timer_list service_timer;
        struct work_struct service_task;
+       struct work_struct rst_service_task;
        struct work_struct mbx_service_task;
 
        struct hclgevf_tqp *htqp;
@@ -165,4 +168,5 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev);
 void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state);
 void hclgevf_update_speed_duplex(struct hclgevf_dev *hdev, u32 speed,
                                 u8 duplex);
+void hclgevf_reset_task_schedule(struct hclgevf_dev *hdev);
 #endif