From patchwork Mon Mar 26 05:39:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Govind Singh X-Patchwork-Id: 10307175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C3B0E600F6 for ; Mon, 26 Mar 2018 05:39:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C46042946B for ; Mon, 26 Mar 2018 05:39:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6BAB2946E; Mon, 26 Mar 2018 05:39:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4A89C2946B for ; Mon, 26 Mar 2018 05:39:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=rdd14gErzFFaFEBYFJCprtpb/55wLwF29jfWR1v3hwg=; b=ZTf BanEbPDgmy4NxFxJtA8dpppQFv+3mrS+CMOYm9Jbd2s25PwTlPZdAVnzE2WOR3p9nXAV6+2aNHF56 /L/K29I1nlXmqp5+MT3Qqdpv15aOJdMiVKvvM+4XvOYhMZmRcZIYbzOBT8FUV8mwgY5L+fYmrzKoq dKw7BwEWhC3RXLGM2cRjcn+O8Lgn3XSFxoQy00nGkRH9fUYO/KB0J5eEQlaZc95z+8n8x8OCEn/m9 Rag/pfnGQxHc9TKfuHh6HNYwo621HJNKou/G3AbjT/dZHUe9ny3KiMv3F1TQKOYb/4Z8cbO7+/ZUn rVoz5lqQZnEOVL/PC0SgBlgww60YKAA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0KrJ-0003qm-Ap; Mon, 26 Mar 2018 05:39:53 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0KrF-0003kZ-Sh for ath10k@lists.infradead.org; Mon, 26 Mar 2018 05:39:51 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 967E460C5F; Mon, 26 Mar 2018 05:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522042779; bh=7rfxcce5vi9r+p5OEs7ONAKXhO7KY0oaZbDulshu+A8=; h=From:To:Cc:Subject:Date:From; b=elhyiVB+uI2LZeeDjRJiri/mJxWOFhbEXGHIwZml2shlAXZ98e5N//RRt4FZde2Au kRZvN3hyso3kPxtD2FWdCex/vP8wKAiSLBY/o3jcea0yrlYSxxP1VteNXfrODr6Z/P yeDvahsUhkA/xu578/AiQzbuik+Tgixwdrx8BtR8= Received: from govinds-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: govinds@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8F23960588; Mon, 26 Mar 2018 05:39:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522042779; bh=7rfxcce5vi9r+p5OEs7ONAKXhO7KY0oaZbDulshu+A8=; h=From:To:Cc:Subject:Date:From; b=elhyiVB+uI2LZeeDjRJiri/mJxWOFhbEXGHIwZml2shlAXZ98e5N//RRt4FZde2Au kRZvN3hyso3kPxtD2FWdCex/vP8wKAiSLBY/o3jcea0yrlYSxxP1VteNXfrODr6Z/P yeDvahsUhkA/xu578/AiQzbuik+Tgixwdrx8BtR8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8F23960588 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=govinds@codeaurora.org From: Govind Singh To: ath10k@lists.infradead.org, bjorn.andersson@linaro.org Subject: [PATCH 04/12] ath10k: add support to start and stop qmi service Date: Mon, 26 Mar 2018 11:09:33 +0530 Message-Id: <1522042773-25775-1-git-send-email-govinds@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180325_223949_959084_7264BDC8 X-CRM114-Status: GOOD ( 14.99 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Govind Singh , linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add support to start qmi service to configure the wlan firmware component and register event notifier to communicate with the WLAN firmware over qmi communication interface. Signed-off-by: Govind Singh --- drivers/net/wireless/ath/ath10k/qmi.c | 155 ++++++++++++++++++++++++++++++++-- drivers/net/wireless/ath/ath10k/qmi.h | 13 +++ 2 files changed, 160 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c index 2235182..3a7fcc6 100644 --- a/drivers/net/wireless/ath/ath10k/qmi.c +++ b/drivers/net/wireless/ath/ath10k/qmi.c @@ -31,15 +31,115 @@ static struct ath10k_qmi *qmi; +static int ath10k_qmi_event_fw_ready_ind(struct ath10k_qmi *qmi) +{ + pr_debug("fw ready event received\n"); + spin_lock(&qmi->event_lock); + qmi->fw_ready = true; + spin_unlock(&qmi->event_lock); + + return 0; +} + +static void ath10k_qmi_fw_ready_ind(struct qmi_handle *qmi_hdl, + struct sockaddr_qrtr *sq, + struct qmi_txn *txn, const void *data) +{ + struct ath10k_qmi *qmi = container_of(qmi_hdl, struct ath10k_qmi, qmi_hdl); + + ath10k_qmi_event_fw_ready_ind(qmi); +} + +static void ath10k_qmi_msa_ready_ind(struct qmi_handle *qmi_hdl, + struct sockaddr_qrtr *sq, + struct qmi_txn *txn, const void *data) +{ + struct ath10k_qmi *qmi = container_of(qmi_hdl, struct ath10k_qmi, qmi_hdl); + + qmi->msa_ready = true; +} + +static struct qmi_msg_handler qmi_msg_handler[] = { + { + .type = QMI_INDICATION, + .msg_id = QMI_WLFW_FW_READY_IND_V01, + .ei = wlfw_fw_ready_ind_msg_v01_ei, + .decoded_size = sizeof(struct wlfw_fw_ready_ind_msg_v01), + .fn = ath10k_qmi_fw_ready_ind, + }, + { + .type = QMI_INDICATION, + .msg_id = QMI_WLFW_MSA_READY_IND_V01, + .ei = wlfw_msa_ready_ind_msg_v01_ei, + .decoded_size = sizeof(struct wlfw_msa_ready_ind_msg_v01), + .fn = ath10k_qmi_msa_ready_ind, + }, + {} +}; + +static int ath10k_qmi_connect_to_fw_server(struct ath10k_qmi *qmi) +{ + struct qmi_handle *qmi_hdl = &qmi->qmi_hdl; + int ret; + + ret = kernel_connect(qmi_hdl->sock, (struct sockaddr *)&qmi->sq, + sizeof(qmi->sq), 0); + if (ret) { + pr_err("fail to connect to remote service port\n"); + return ret; + } + + pr_info("wlan qmi service connected\n"); + + return 0; +} + +static void ath10k_qmi_event_server_arrive(struct work_struct *work) +{ + struct ath10k_qmi *qmi = container_of(work, struct ath10k_qmi, + work_svc_arrive); + int ret; + + ret = ath10k_qmi_connect_to_fw_server(qmi); + if (ret) + return; + + pr_debug("qmi server arrive\n"); +} + +static void ath10k_qmi_event_server_exit(struct work_struct *work) +{ + struct ath10k_qmi *qmi = container_of(work, struct ath10k_qmi, + work_svc_exit); + + spin_lock(&qmi->event_lock); + qmi->fw_ready = false; + spin_unlock(&qmi->event_lock); + pr_info("wlan fw service disconnected\n"); +} + static int ath10k_qmi_new_server(struct qmi_handle *qmi_hdl, struct qmi_service *service) { + struct ath10k_qmi *qmi = container_of(qmi_hdl, struct ath10k_qmi, qmi_hdl); + struct sockaddr_qrtr *sq = &qmi->sq; + + sq->sq_family = AF_QIPCRTR; + sq->sq_node = service->node; + sq->sq_port = service->port; + + queue_work(qmi->event_wq, &qmi->work_svc_arrive); + return 0; } static void ath10k_qmi_del_server(struct qmi_handle *qmi_hdl, struct qmi_service *service) { + struct ath10k_qmi *qmi = + container_of(qmi_hdl, struct ath10k_qmi, qmi_hdl); + + queue_work(qmi->event_wq, &qmi->work_svc_exit); } static struct qmi_ops ath10k_qmi_ops = { @@ -47,6 +147,51 @@ static void ath10k_qmi_del_server(struct qmi_handle *qmi_hdl, .del_server = ath10k_qmi_del_server, }; +static int ath10k_alloc_qmi_resources(struct ath10k_qmi *qmi) +{ + int ret; + + ret = qmi_handle_init(&qmi->qmi_hdl, + WLFW_BDF_DOWNLOAD_REQ_MSG_V01_MAX_MSG_LEN, + &ath10k_qmi_ops, qmi_msg_handler); + if (ret) + goto err; + + qmi->event_wq = alloc_workqueue("qmi_driver_event", + WQ_UNBOUND, 1); + if (!qmi->event_wq) { + pr_err("workqueue alloc failed\n"); + ret = -EFAULT; + goto err_qmi_service; + } + + spin_lock_init(&qmi->event_lock); + INIT_WORK(&qmi->work_svc_arrive, ath10k_qmi_event_server_arrive); + INIT_WORK(&qmi->work_svc_exit, ath10k_qmi_event_server_exit); + + ret = qmi_add_lookup(&qmi->qmi_hdl, WLFW_SERVICE_ID_V01, + WLFW_SERVICE_VERS_V01, 0); + if (ret) + goto err_qmi_service; + + return 0; + +err_qmi_service: + qmi_handle_release(&qmi->qmi_hdl); + +err: + return ret; +} + +static void ath10k_remove_qmi_resources(struct ath10k_qmi *qmi) +{ + cancel_work_sync(&qmi->work_svc_arrive); + cancel_work_sync(&qmi->work_svc_exit); + destroy_workqueue(qmi->event_wq); + qmi_handle_release(&qmi->qmi_hdl); + qmi = NULL; +} + static int ath10k_qmi_probe(struct platform_device *pdev) { int ret; @@ -58,14 +203,8 @@ static int ath10k_qmi_probe(struct platform_device *pdev) qmi->pdev = pdev; platform_set_drvdata(pdev, qmi); - ret = qmi_handle_init(&qmi->qmi_hdl, - WLFW_BDF_DOWNLOAD_REQ_MSG_V01_MAX_MSG_LEN, - &ath10k_qmi_ops, NULL); - if (ret < 0) - goto err; - ret = qmi_add_lookup(&qmi->qmi_hdl, WLFW_SERVICE_ID_V01, - WLFW_SERVICE_VERS_V01, 0); + ret = ath10k_alloc_qmi_resources(qmi); if (ret < 0) goto err; @@ -81,7 +220,7 @@ static int ath10k_qmi_remove(struct platform_device *pdev) { struct ath10k_qmi *qmi = platform_get_drvdata(pdev); - qmi_handle_release(&qmi->qmi_hdl); + ath10k_remove_qmi_resources(qmi); return 0; } diff --git a/drivers/net/wireless/ath/ath10k/qmi.h b/drivers/net/wireless/ath/ath10k/qmi.h index ad256ef..7697d24 100644 --- a/drivers/net/wireless/ath/ath10k/qmi.h +++ b/drivers/net/wireless/ath/ath10k/qmi.h @@ -16,9 +16,22 @@ #ifndef _QMI_H_ #define _QMI_H_ +enum ath10k_qmi_driver_event_type { + ATH10K_QMI_EVENT_SERVER_ARRIVE, + ATH10K_QMI_EVENT_SERVER_EXIT, + ATH10K_QMI_EVENT_FW_READY_IND, + ATH10K_QMI_EVENT_MAX, +}; + struct ath10k_qmi { struct platform_device *pdev; struct qmi_handle qmi_hdl; struct sockaddr_qrtr sq; + bool fw_ready; + bool msa_ready; + struct work_struct work_svc_arrive; + struct work_struct work_svc_exit; + struct workqueue_struct *event_wq; + spinlock_t event_lock; /* spinlock for fw ready status*/ }; #endif /* _QMI_H_ */