Received: by 10.213.65.68 with SMTP id h4csp742535imn; Thu, 22 Mar 2018 07:38:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELuneyXyqA6+O7dyMtPbR36JMzMISCvOkkp3UU2qwydq19TRGk3SQNE5TlXYsvST+wec4XAY X-Received: by 10.98.211.211 with SMTP id z80mr20255227pfk.16.1521729510395; Thu, 22 Mar 2018 07:38:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729510; cv=none; d=google.com; s=arc-20160816; b=iDBVcp95oo9rciOZEmZabe9SgCCdoUGr10AZx26GYHI8rQqipHH6uG7d1FtDivVvbz +G07JGf310vK9r+OLQwLIA8/NMbYEtwQlCfxu+V5X8im0BeC0y/no1YbEafj9DeVAZl1 4+0LhoxXRS++fl97ZbYKVdzp6a6KJWJrDSCUdDZ1dRjqJWfgf9387MwNyDCMO1dczDhG TB8hb//+tdKyQ0AlUpCHUPbm6GZh9pmurnGY8fk7V0Itq86VcYa4o1Wg2nhDW2xNaiwo S/4C+Me2i5TeXUNA44A7WVT8uJwfnVVUydhbl1TB0WrCtFZEjRU8qQon1RihwUvdTG2k zXcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=P1qAa47DWNC1khHEXP6fiziUjpStC9CKqnRemGSKSIQ=; b=E7CVH2G2QY99SULh6h33BjdWk8+7qj3yVEUUpR0dElkZ9A7xfm6EjmRdI2UbnwkbTU 1RPvuiAxrt4rBGgWCEcpjSiS+FpyQlLpeKMwB6IrdPLiJvcJrGdPqAWiEjBJxJ4v3b3Y +89uO5dWAChsc/7O6dDGBMW0N5rnN4jB8+JnvrGGo1fo1h9HVUoOYVYne/984eglCg9r leo9aSYMkSpcqgSjw81PkNAaNhkQCo4p3bMVQ5cLQsQWBpdb4QUY8ACuI6v+XyVAS3nu cLnZx0oR8nLGN5YEwh2/sJ+6EKMtSbPD55mpIwq9LSbQW2g0GsKd2vpQUWeeH52cWN5e 8Uhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x16si1668595pfh.76.2018.03.22.07.38.15; Thu, 22 Mar 2018 07:38:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755394AbeCVObu (ORCPT + 99 others); Thu, 22 Mar 2018 10:31:50 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6260 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754583AbeCVOaM (ORCPT ); Thu, 22 Mar 2018 10:30:12 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3D7431C3D6BD1; Thu, 22 Mar 2018 22:29:57 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.47) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.361.1; Thu, 22 Mar 2018 22:29:47 +0800 From: Salil Mehta To: CC: , , , , , Subject: [PATCH net-next 2/9] net: hns3: Add VF Reset Service Task to support event handling Date: Thu, 22 Mar 2018 14:28:53 +0000 Message-ID: <20180322142900.22860-3-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180322142900.22860-1-salil.mehta@huawei.com> References: <20180322142900.22860-1-salil.mehta@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.202.226.47] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 31 ++++++++++++++++++++++ .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 4 +++ 2 files changed, 35 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 6c3881d..cdb6e7a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -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); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 0eaea06..8b5fa67 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -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 -- 2.7.4