From patchwork Tue Feb 21 16:15:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Stromdahl X-Patchwork-Id: 9585049 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 425186042F for ; Tue, 21 Feb 2017 16:17:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F10E200F5 for ; Tue, 21 Feb 2017 16:17:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22D6E27BFF; Tue, 21 Feb 2017 16:17:11 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 BCA30200F5 for ; Tue, 21 Feb 2017 16:17:10 +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:References: In-Reply-To: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:List-Owner; bh=IafDeZVTt9kUaERFSnHlSvDrlTjRX+PJQSiuTD2TLWU=; b=uu9/RObApBCbKgR43KxzW51vTE 8CO/VPBZwGYhcXJNl6QT5E+DA8M92IT8/qnTB+0UWGWnCWdKJmJ/H+r+ZN9CSsjJoE2zMHTN2CPbR mgDPXVh6et5umV8XpNttCVJ1t0DImo+L38wPxSxQZGXarFFmhwl2CN2TZTj51JXD8+LeFx1EJRcPV WLb6OanUTe5rw8cRgkI48TXR9EVRdVvGW6zViIpx0vZz04oqRGN01GEKtthCHvqJ0S5HxhLqYhCJl zB1d09OQEJF1T1c8VFX5zUQ8MRBeRgGY075tDbZhGvWZpBa5Dhx57yt2UAKj5pXurQabTjQosmutp Y1TtIDfw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cgD7h-0007BG-1l; Tue, 21 Feb 2017 16:17:05 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cgD7E-0006bd-AL for ath10k@lists.infradead.org; Tue, 21 Feb 2017 16:16:41 +0000 Received: by mail-lf0-x243.google.com with SMTP id h67so3751829lfg.1 for ; Tue, 21 Feb 2017 08:16:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vfNb+727wwk8I/U0aiaHEV/cGMI0Wy2Qu9F9UBjlBn0=; b=dPUeHU/xi+Himl6QCm/ogjvGgufyoG7RUKvtPMNiEzcNr066uXNdnrc3nOf2sFk1Nz AhVENt748NhFP2DALbShSOjM4ruTkthVXqa9lgMRLHjx0R+ee69cQu9xcBK6ywvQOkEY E8Z1VgCmx5YqJa1HpWyhYeJRrFJB6xXndr7YSr2Bm1pbyX9w9qN37TBOP4/zD3D8EB/0 vsmHkTdqPfni2oAzNts4sRlyr8QN66dKP9sD9WGdR3Ig3eEgEbSPNmxfxAGRBOwsllph 4LdokkcD6NxpAxOCi2gu9M9NHM8/UPm9raOLgprBXFVPcIgaUZFWwFpRMqahF5flAJvl MYdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vfNb+727wwk8I/U0aiaHEV/cGMI0Wy2Qu9F9UBjlBn0=; b=h+E+aZ2R9Rv59zjZOUqYOJNOirv65aCm8JwWOW8wnXOi1WccJnBJhuCBZsjK067Z9B tADbE3QwWMKyzRxtL7TnpxI8i9YDBzuxa7aGaOAthu3u4ESH0eMMV3tDdf3BvsyWCXwx YFhAbHN32ov8RL+3RdUH+btpYV3SZ87r643Hahw5XuMtkzSxjyOI7lOcPkQS6k2Ii2+p xTP+EI5NTH42A41hajwnzgBu4Fqgs1WnsfZOFtvEPeJQx8r6oYH2ctYl9rZPEyOm2zzm m/hYcJYrg5Au5IHAbr7hpXiZTfOzADYNXAiHvk5KnnJUKBOF1b0ChzFf9hnGNlzuDEGZ kA2A== X-Gm-Message-State: AMke39mlgS51q/2sxfTpTxnhm9wFKN56dmHgF6jxbV8B0VBEdrRRPQymvMTtnfrzeNVVBQ== X-Received: by 10.46.77.9 with SMTP id a9mr7279377ljb.25.1487693774254; Tue, 21 Feb 2017 08:16:14 -0800 (PST) Received: from erik-mate-1604.lan (90-227-62-61-no75.tbcn.telia.com. [90.227.62.61]) by smtp.gmail.com with ESMTPSA id t29sm6336069ljd.39.2017.02.21.08.16.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Feb 2017 08:16:13 -0800 (PST) From: Erik Stromdahl To: kvalo@qca.qualcomm.com, linux-wireless@vger.kernel.org, ath10k@lists.infradead.org Subject: [RFC v4 02/21] ath10k: htc: rx trailer lookahead support Date: Tue, 21 Feb 2017 17:15:22 +0100 Message-Id: <1487693741-10042-3-git-send-email-erik.stromdahl@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487693741-10042-1-git-send-email-erik.stromdahl@gmail.com> References: <1487693741-10042-1-git-send-email-erik.stromdahl@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170221_081636_828134_1FAF9881 X-CRM114-Status: GOOD ( 15.20 ) 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: Erik Stromdahl MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The RX trailer parsing is now capable of parsing lookahead reports. A lookahead contains the first 4 bytes of the next HTC message (that will be read in the next SDIO read operation). Lookaheads are used by the SDIO/mbox HIF layer to determine if the next message is part of a bundle, which endpoint it belongs to and how long it is. Signed-off-by: Erik Stromdahl --- drivers/net/wireless/ath/ath10k/htc.c | 93 ++++++++++++++++++++++++++++++++++- drivers/net/wireless/ath/ath10k/htc.h | 30 +++++++++-- 2 files changed, 118 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c index 35e67c4..e72f385 100644 --- a/drivers/net/wireless/ath/ath10k/htc.c +++ b/drivers/net/wireless/ath/ath10k/htc.c @@ -228,10 +228,76 @@ ath10k_htc_process_credit_report(struct ath10k_htc *htc, 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, + void *next_lookaheads, + int *next_lookaheads_len) +{ + struct ath10k *ar = htc->ar; + + /* 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 + */ + if (report->pre_valid != ((~report->post_valid) & 0xFF)) + return 0; + + if (next_lookaheads && next_lookaheads_len) { + ath10k_dbg(ar, ATH10K_DBG_HTC, + "htc rx lookahead 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_lookaheads, report->lookahead, 4); + + *next_lookaheads_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, + void *next_lookaheads, + int *next_lookaheads_len) +{ + struct ath10k *ar = htc->ar; + int bundle_cnt = len / sizeof(*report); + + if (!bundle_cnt || (bundle_cnt > HTC_HOST_MAX_MSG_PER_BUNDLE)) { + ath10k_warn(ar, "Invalid lookahead bundle count: %d\n", + bundle_cnt); + return -EINVAL; + } + + if (next_lookaheads && next_lookaheads_len) { + int i; + + for (i = 0; i < bundle_cnt; i++) { + memcpy(((u8 *)next_lookaheads) + 4 * i, + report->lookahead, 4); + report++; + } + + *next_lookaheads_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, + void *next_lookaheads, + int *next_lookaheads_len) { struct ath10k *ar = htc->ar; int status = 0; @@ -272,6 +338,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->lookahead_report, + record->hdr.len, + src_eid, + next_lookaheads, + next_lookaheads_len); + break; + case ATH10K_HTC_RECORD_LOOKAHEAD_BUNDLE: + status = ath10k_htc_process_lookahead_bundle(htc, + record->lookahead_bundle, + record->hdr.len, + src_eid, + next_lookaheads, + next_lookaheads_len); + break; default: ath10k_warn(ar, "Unhandled record: id:%d length:%d\n", record->hdr.id, record->hdr.len); @@ -359,7 +447,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 f728ce7..9a1db90 100644 --- a/drivers/net/wireless/ath/ath10k/htc.h +++ b/drivers/net/wireless/ath/ath10k/htc.h @@ -50,6 +50,8 @@ struct ath10k; * 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 lookahead[4]; + u8 post_valid; + u8 pad3; + u8 pad4; + u8 pad5; +} __packed; + +struct ath10k_htc_lookahead_report_bundle { + u8 lookahead[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 lookahead_report[0]; + struct ath10k_htc_lookahead_report_bundle lookahead_bundle[0]; u8 pauload[0]; }; } __packed __aligned(4); @@ -356,6 +378,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, + void *next_lookaheads, + int *next_lookaheads_len); #endif