From patchwork Mon Nov 14 16:33:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Stromdahl X-Patchwork-Id: 9427935 X-Patchwork-Delegate: kvalo@adurom.com 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 D22946047D for ; Mon, 14 Nov 2016 16:36:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF54B28A31 for ; Mon, 14 Nov 2016 16:36:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C43A328A38; Mon, 14 Nov 2016 16:36:04 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CE3628A35 for ; Mon, 14 Nov 2016 16:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933005AbcKNQfa (ORCPT ); Mon, 14 Nov 2016 11:35:30 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33064 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932174AbcKNQf2 (ORCPT ); Mon, 14 Nov 2016 11:35:28 -0500 Received: by mail-lf0-f68.google.com with SMTP id 98so7490648lfs.0 for ; Mon, 14 Nov 2016 08:35:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wqGXRkaQBSd/yPGW8hYe4jCr5FLEAxjFZuSdmRz0sJQ=; b=xcBzFyggZ+avWPVVeEc4nwyilCzEUtXHOpfeDpc44b/sEYWVQ8L88HdTJPyAtXeQAV bz3XC/w4YpBoykECAMlbuq+tOLIoexb/mbYionyryMpWN6U054y9e4EQkk0qfJiTD1Pt UyW6/CqTk5pKDJO17Wmq+dGvi8U3OPndlR8tVsQpaIyzKTX7MDgHx+v57N1UOMmYGzSI mm59gmMea1CzrTi4Ni0/XFMQVl2zD0KEJu12YOx5Ay41dxX+e6tLsdwxHDEUvBlVFnPI uWcsQQUK9so9pQgZAeQpvLH32qeu8+2bDy9c/pMDskwOdEmDj5LxLCPVtnv/Meuy/9E8 XWjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wqGXRkaQBSd/yPGW8hYe4jCr5FLEAxjFZuSdmRz0sJQ=; b=Mg9WNy2LMhIKcuQP4DjuaZGWbE2dYq4kid2Jd045Z/RVXEUppmH9MJNmgqRQWC8t2J Wpeb7xfjR/rYYu4FztcTCfduSyF/LkH6TdtK/Mf55L1GiUpYi2fryBt6xwLQTyj1Vd2N eoNVxzKB788miVIKFpFbl+At6L+z89aVJb6epe4Y//tqvKhlKaDVmVqvwzpk4RlKlYeP 7p1jp4/8PPuTXq9cAaC4AuH9s+AIrzWd7mM8Uk4b3Jr+4sPSmH2pG9SfsP8iDjuqGbzy cfknwectl6K++zzUY8crlhglbE/5RySBlnklLd5gKHEUeLoI4jcbJ+mZEDIgDyTdFjkr tsbw== X-Gm-Message-State: ABUngvepRZ+unPPT8xJGigHZ22+WDAX6FVrCieH9ttVqE5EU0m5CaR4HoxkMdKw7Cy9Mxg== X-Received: by 10.25.206.13 with SMTP id e13mr5440253lfg.38.1479141326401; Mon, 14 Nov 2016 08:35:26 -0800 (PST) Received: from erik-desktop.lan (81-233-218-8-no25.tbcn.telia.com. [81.233.218.8]) by smtp.gmail.com with ESMTPSA id w67sm5105849lff.16.2016.11.14.08.35.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2016 08:35:25 -0800 (PST) From: Erik Stromdahl To: kvalo@qca.qualcomm.com, linux-wireless@vger.kernel.org, ath10k@lists.infradead.org Cc: Erik Stromdahl Subject: [RFC 02/12] ath10k: htc: rx trailer lookahead support Date: Mon, 14 Nov 2016 17:33:32 +0100 Message-Id: <1479141222-8493-3-git-send-email-erik.stromdahl@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1479141222-8493-1-git-send-email-erik.stromdahl@gmail.com> References: <1479141222-8493-1-git-send-email-erik.stromdahl@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The RX trailer parsing is now capable of parsing lookahead reports. This is needed by SDIO/mbox. Signed-off-by: Erik Stromdahl --- drivers/net/wireless/ath/ath10k/htc.c | 91 ++++++++++++++++++++++++++++++++- drivers/net/wireless/ath/ath10k/htc.h | 30 +++++++++-- 2 files changed, 116 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c index 26b1e15..e3f7bf4 100644 --- a/drivers/net/wireless/ath/ath10k/htc.c +++ b/drivers/net/wireless/ath/ath10k/htc.c @@ -228,10 +228,74 @@ void ath10k_htc_tx_completion_handler(struct ath10k *ar, struct sk_buff *skb) spin_unlock_bh(&htc->tx_lock); } +static int +ath10k_htc_process_lookahead(struct ath10k_htc *htc, + const struct ath10k_htc_lookahead_report *report, + int len, + enum ath10k_htc_ep_id eid, + u32 *next_lk_ahds, + int *next_lk_ahds_len) +{ + struct ath10k *ar = htc->ar; + + if (report->pre_valid != ((~report->post_valid) & 0xFF)) + /* Invalid lookahead flags are actually transmitted by + * the target in the HTC control message. + * Since this will happen at every boot we silently ignore + * the lookahead in this case + */ + return 0; + + if (next_lk_ahds && next_lk_ahds_len) { + ath10k_dbg(ar, ATH10K_DBG_HTC, + "htc rx lk_ahd found pre_valid 0x%x post_valid 0x%x\n", + report->pre_valid, report->post_valid); + + /* look ahead bytes are valid, copy them over */ + memcpy((u8 *)&next_lk_ahds[0], report->lk_ahd, 4); + + *next_lk_ahds_len = 1; + } + + return 0; +} + +static int +ath10k_htc_process_lookahead_bundle(struct ath10k_htc *htc, + const struct ath10k_htc_lookahead_report_bundle *report, + int len, + enum ath10k_htc_ep_id eid, + u32 *next_lk_ahds, + int *next_lk_ahds_len) +{ + int bundle_cnt = len / sizeof(*report); + + if (!bundle_cnt || (bundle_cnt > HTC_HOST_MAX_MSG_PER_BUNDLE)) { + WARN_ON(1); + return -EINVAL; + } + + if (next_lk_ahds && next_lk_ahds_len) { + int i; + + for (i = 0; i < bundle_cnt; i++) { + memcpy((u8 *)&next_lk_ahds[i], report->lk_ahd, + sizeof(u32)); + report++; + } + + *next_lk_ahds_len = bundle_cnt; + } + + return 0; +} + int ath10k_htc_process_trailer(struct ath10k_htc *htc, u8 *buffer, int length, - enum ath10k_htc_ep_id src_eid) + enum ath10k_htc_ep_id src_eid, + u32 *next_lk_ahds, + int *next_lk_ahds_len) { struct ath10k *ar = htc->ar; int status = 0; @@ -272,6 +336,28 @@ int ath10k_htc_process_trailer(struct ath10k_htc *htc, record->hdr.len, src_eid); break; + case ATH10K_HTC_RECORD_LOOKAHEAD: + len = sizeof(struct ath10k_htc_lookahead_report); + if (record->hdr.len < len) { + ath10k_warn(ar, "Lookahead report too long\n"); + status = -EINVAL; + break; + } + status = ath10k_htc_process_lookahead(htc, + record->lkahd_report, + record->hdr.len, + src_eid, + next_lk_ahds, + next_lk_ahds_len); + break; + case ATH10K_HTC_RECORD_LOOKAHEAD_BUNDLE: + status = ath10k_htc_process_lookahead_bundle(htc, + record->lkahd_bundle, + record->hdr.len, + src_eid, + next_lk_ahds, + next_lk_ahds_len); + break; default: ath10k_warn(ar, "Unhandled record: id:%d length:%d\n", record->hdr.id, record->hdr.len); @@ -359,7 +445,8 @@ void ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb) trailer += payload_len; trailer -= trailer_len; status = ath10k_htc_process_trailer(htc, trailer, - trailer_len, hdr->eid); + trailer_len, hdr->eid, + NULL, NULL); if (status) goto out; diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h index 858e19f..589800a 100644 --- a/drivers/net/wireless/ath/ath10k/htc.h +++ b/drivers/net/wireless/ath/ath10k/htc.h @@ -50,6 +50,8 @@ * 4-byte aligned. */ +#define HTC_HOST_MAX_MSG_PER_BUNDLE 8 + enum ath10k_htc_tx_flags { ATH10K_HTC_FLAG_NEED_CREDIT_UPDATE = 0x01, ATH10K_HTC_FLAG_SEND_BUNDLE = 0x02 @@ -174,8 +176,10 @@ struct ath10k_htc_msg { } __packed __aligned(4); enum ath10k_ath10k_htc_record_id { - ATH10K_HTC_RECORD_NULL = 0, - ATH10K_HTC_RECORD_CREDITS = 1 + ATH10K_HTC_RECORD_NULL = 0, + ATH10K_HTC_RECORD_CREDITS = 1, + ATH10K_HTC_RECORD_LOOKAHEAD = 2, + ATH10K_HTC_RECORD_LOOKAHEAD_BUNDLE = 3, }; struct ath10k_ath10k_htc_record_hdr { @@ -192,10 +196,28 @@ struct ath10k_htc_credit_report { u8 pad1; } __packed; +struct ath10k_htc_lookahead_report { + u8 pre_valid; + u8 pad0; + u8 pad1; + u8 pad2; + u8 lk_ahd[4]; + u8 post_valid; + u8 pad3; + u8 pad4; + u8 pad5; +} __packed; + +struct ath10k_htc_lookahead_report_bundle { + u8 lk_ahd[4]; +} __packed; + struct ath10k_htc_record { struct ath10k_ath10k_htc_record_hdr hdr; union { struct ath10k_htc_credit_report credit_report[0]; + struct ath10k_htc_lookahead_report lkahd_report[0]; + struct ath10k_htc_lookahead_report_bundle lkahd_bundle[0]; u8 pauload[0]; }; } __packed __aligned(4); @@ -359,6 +381,8 @@ void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep, int ath10k_htc_process_trailer(struct ath10k_htc *htc, u8 *buffer, int length, - enum ath10k_htc_ep_id src_eid); + enum ath10k_htc_ep_id src_eid, + u32 *next_lk_ahds, + int *next_lk_ahds_len); #endif