From patchwork Mon Jan 2 23:25:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1720845 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=38TY/iPU; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=ixIvcMPY; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NmBwn6djNz23f3 for ; Tue, 3 Jan 2023 10:32:25 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oKDvB8ZvFr5teMP8tPnlwZrqdlC1fbQqmIYW7Npx89s=; b=38TY/iPUKpTWN3 aOSdG8+jX8oZkCtGg5kOwjkbgREWrExAhLZnosY4YHQkVkvyjKwDYELcnvnvaTG0YnbwPnJweS3qd buMXCO/Sun4reOoI0LcisssexXRe7YiZTQ4Am/HIqFwNMqQ50dFPLpm71uSbh1U8RynsgFbEhY5yO HLw+sD7nXPURGveZ6AH1BgL74duk0ahsya5SwOjsfPsNUdw5S9hKhj0ppqU23GVn2d+l+8yfJoicr LYU1LogriJXqMJ/rTCexHSksL7Os8Rbfxl874j/9V6XOgMrxkloDJt6GiBxI1IZiiDi1NouxaSupt Ig5mo1aT77q5fBid/JzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCUEt-00Erfv-3T; Mon, 02 Jan 2023 23:29:07 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCUBk-00Eqsh-7i for openwrt-devel@lists.openwrt.org; Mon, 02 Jan 2023 23:25:54 +0000 Received: by mail-pl1-x62d.google.com with SMTP id n4so30897518plp.1 for ; Mon, 02 Jan 2023 15:25:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FxT4ZZ6D0IEdo6Atb7324pKyhCOOHdbMAb1je57fBOI=; b=ixIvcMPYtEBHdElni80It9TgAYSmuh4afEyRWsmCeXOHMUN+wPZgBQKAr/EvD3w3rI y3HvJpbJ/EZK43ETTwpnygbZO/HQ30/tWrS9KNJNwVrFVxfLinsdvsB9VopIDDKFGN30 uEa1rrTFwbnlsyAZXgNGQ28bQ9YOJJkActjq4Hq7CRymuwd2MIbOVXMZz65FtNGxuC9i BFvEbX4ZweWUwyF7e6N8HJ70pGHEM8QrkRgvozEdJHewddT74NixV/zDdfwN9ukFxbSb 2QZEtGrTAiFfIMMTxoO42MMCIckCBEpYbYyvco4YQQP4b3a4NAQ5XQLYf/ytAlZcWG3D SEaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FxT4ZZ6D0IEdo6Atb7324pKyhCOOHdbMAb1je57fBOI=; b=uXbAS2+e8rFmhunmRr3uzxvgByfyW/sWCKwe/L2dDBqo0u6eYFs7Ad+rb7QNH5UEUc du23rpgtx1oylR6cgFhhw6azE97LLz/98vLDFyy1gI8lI6krHpVyfOBPaBR3RUpBQn09 5rDIBz1bdc2wGRtQoIptSJbB2MTapnu9+hu95WJFDtroPqvyig0Bk7HW7kNloIZjFLbJ WLkgom/fX4MmniZQtLgWuEB9HMpQNWVq+H/qSr9GhyAHgFSX+PVMq2AphBuZY/XKjppb 3M5K7sk5iRTHt/8acnRoFW+sNyGt2vxToKO9ZLGLhUkYauAXIi33iC0FtrfbWXV9t6qz K7MA== X-Gm-Message-State: AFqh2koNeXTi0PZUX3w1FAC6xJadkfxcZitnb1IwFiacd4qxm+UE7N/2 Qub5vU2EUfoD/iLhVqCU/5K/N21SS7s= X-Google-Smtp-Source: AMrXdXuhmCnr/FGyKKPT/MRg0dqBl38be688GqEc3y+UX9aJTJA8RV4fiFH+JrwEgm+m9DAy1hJuPw== X-Received: by 2002:a17:902:ab8f:b0:192:ce7c:dc43 with SMTP id f15-20020a170902ab8f00b00192ce7cdc43mr4091247plr.40.1672701951486; Mon, 02 Jan 2023 15:25:51 -0800 (PST) Received: from localhost ([2600:1700:38c1:1d7f:f66d:4ff:fe3c:3ceb]) by smtp.gmail.com with ESMTPSA id w3-20020a170902e88300b0018f69009f3esm4048183plg.284.2023.01.02.15.25.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jan 2023 15:25:51 -0800 (PST) From: Brian Norris To: openwrt-devel@lists.openwrt.org Cc: Brian Norris Subject: [PATCH 7/8] ath10k-ct: Support qcom,ath10k-calibration-data-base64 Date: Mon, 2 Jan 2023 15:25:33 -0800 Message-Id: <20230102232534.592501-7-computersforpeace@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230102232534.592501-1-computersforpeace@gmail.com> References: <20230102232534.592501-1-computersforpeace@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230102_152552_379228_C2338784 X-CRM114-Status: GOOD ( 28.21 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: See the patch notes about the stock firmware for TP-Link Onhub and https://chromium-review.googlesource.com/243115. As noted there, the production firmware for Google OnHub devices only provide the *-base64 Device Tree property, and so either the kernel or some user space mechanism needs to know how to parse/conver [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:62d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [computersforpeace[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org See the patch notes about the stock firmware for TP-Link Onhub and https://chromium-review.googlesource.com/243115. As noted there, the production firmware for Google OnHub devices only provide the *-base64 Device Tree property, and so either the kernel or some user space mechanism needs to know how to parse/convert this property. I haven't submitted this patch upstream. However, it applies relatively cleanly to the tree even after almost 8 years, so it doesn't seem too hard to maintain. Signed-off-by: Brian Norris --- .../970-ath10k-calibration-base64.patch | 249 ++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 package/kernel/ath10k-ct/patches/970-ath10k-calibration-base64.patch diff --git a/package/kernel/ath10k-ct/patches/970-ath10k-calibration-base64.patch b/package/kernel/ath10k-ct/patches/970-ath10k-calibration-base64.patch new file mode 100644 index 000000000000..739bdee9ccf4 --- /dev/null +++ b/package/kernel/ath10k-ct/patches/970-ath10k-calibration-base64.patch @@ -0,0 +1,249 @@ +Adapted from: +https://chromium-review.googlesource.com/307062 + +This "hack" remained in the production kernel, and so the production firmware +for Google OnHub still only knows how to patch the *-base64 Device Tree +property. + +CHROMIUM: HACK: ath10k: read calibration data in base64 format from DT + + Chrome OS firmware doesn't support binary format in VPD currently. + As a workaround, the firmware stores the calibration data in base64 + format in the same node with the different name: + + qcom,ath10k-calibration-data-base64 = [ 01 02 03 ... ]; + + Since the original property "qcom,ath10k-calibration-data" is always + looked for first, it should have an invalid size (e.g. 1). + + BUG=chrome-os-partner:35262 + TEST=build/boot on storm suceeded. Setup Storm board as AP using + hostapd and + connected to the board using another device. Device was able to + connect to + the internet and load multiple websites. + + Change-Id: I95675a803fad3b94977ecd0977bd9980779ad7e9 + Signed-off-by: Toshi Kikuchi + Reviewed-on: https://chromium-review.googlesource.com/243115 + Reviewed-by: Grant Grundler + +Change-Id: I17874f0ed03e28d279b08fe70aca70af57c90bda +Signed-off-by: Anilkumar Kolli +Reviewed-on: https://chromium-review.googlesource.com/307062 +Commit-Ready: Grant Grundler +Tested-by: Grant Grundler +Reviewed-by: Srinivasa duvvuri +Reviewed-by: Grant Grundler +--- a/ath10k-5.15/Makefile ++++ b/ath10k-5.15/Makefile +@@ -4,6 +4,7 @@ ath10k_core-y += mac.o \ + debug.o \ + core.o \ + coredump.o \ ++ decode64.o \ + htc.o \ + htt.o \ + htt_rx.o \ +--- a/ath10k-5.15/core.c ++++ b/ath10k-5.15/core.c +@@ -18,6 +18,7 @@ + #include + + #include "core.h" ++#include "decode64.h" + #include "mac.h" + #include "htc.h" + #include "hif.h" +@@ -2167,6 +2168,73 @@ static int ath10k_download_cal_file(stru + return 0; + } + ++static int ath10k_download_cal_dt_base64(struct ath10k *ar) ++{ ++ struct device_node *node; ++ int data_len; ++ void *data; ++ int ret; ++ ++ node = ar->dev->of_node; ++ if (!node) ++ /* Device Tree is optional, don't print any warnings if ++ * there's no node for ath10k. ++ */ ++ return -ENOENT; ++ ++ if (!of_get_property(node, "qcom,ath10k-calibration-data-base64", ++ &data_len)) { ++ /* The calibration data node is optional */ ++ return -ENOENT; ++ } ++ ++ data = kmalloc(data_len, GFP_KERNEL); ++ if (!data) { ++ ret = -ENOMEM; ++ goto out; ++ } ++ ++ ret = of_property_read_u8_array(node, ++ "qcom,ath10k-calibration-data-base64", ++ data, data_len); ++ if (ret) { ++ ath10k_warn(ar, ++ "failed to read calibration data (base64) from DT: %d\n", ++ ret); ++ goto out_free; ++ } ++ ++ data_len = strip_nl(data, data + data_len, data); ++ data_len = decode64(data, data + data_len, data); ++ if (data_len < 0) { ++ ath10k_warn(ar, ++ "base64 decoder found invalid input\n"); ++ ret = -EINVAL; ++ goto out_free; ++ } ++ ++ if (data_len != ar->hw_params.cal_data_len) { ++ ath10k_warn(ar, "invalid calibration data length in DT: %d\n", ++ data_len); ++ ret = -EMSGSIZE; ++ goto out_free; ++ } ++ ++ ret = ath10k_download_board_data(ar, data, data_len); ++ if (ret) { ++ ath10k_warn(ar, "failed to download base64 calibration data from Device Tree: %d\n", ++ ret); ++ goto out_free; ++ } ++ ++ ret = 0; ++out_free: ++ kfree(data); ++ ++out: ++ return ret; ++} ++ + static int ath10k_download_cal_dt(struct ath10k *ar, const char *dt_name) + { + struct device_node *node; +@@ -2787,6 +2855,12 @@ static int ath10k_download_cal_data(stru + "boot did not find target EEPROM entry, try OTP next: %d\n", + ret); + ++ ret = ath10k_download_cal_dt_base64(ar); ++ if (ret == 0) { ++ ar->cal_mode = ATH10K_CAL_MODE_DT; ++ goto done; ++ } ++ + ret = ath10k_download_and_run_otp(ar); + if (ret) { + ath10k_err(ar, "failed to run otp: %d (download-cal-data)\n", ret); +--- /dev/null ++++ b/ath10k-5.15/decode64.c +@@ -0,0 +1,89 @@ ++/* ++ * Copyright (c) 2013 The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014, The Chromium OS Authors ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License as ++ * published by the Free Software Foundation; either version 2 of ++ * the License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, ++ * MA 02111-1307 USA ++ */ ++ ++#include "decode64.h" ++ ++static char revkey[128] = { ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, ++ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, ++ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ++ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, ++ -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, ++ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, ++}; ++ ++int ++decode64(unsigned char *src, unsigned char *src_end, unsigned char *dst) ++{ ++ unsigned char *dst_end = dst; ++ ++ while (&src[3] < src_end) { ++ int x; ++ int t[4]; ++ int i; ++ ++ if (src[0] == '=' || src[1] == '=' || ++ (src[2] == '=' && src[3] != '=')) { ++ return -1; ++ } ++ ++ for (i = 0; i < 4; i++) { ++ if (src[i] == '=') { ++ t[i] = 0; ++ } else { ++ if (src[i] >= 128 || ++ ((t[i] = revkey[src[i]]) < 0)) { ++ return -1; ++ } ++ } ++ } ++ ++ x = (t[0] << 18) + (t[1] << 12) + (t[2] << 6) + t[3]; ++ ++ *dst_end++ = (x >> 16) & 0xff; ++ if (src[2] != '=') ++ *dst_end++ = (x >> 8) & 0xff; ++ if (src[3] != '=') ++ *dst_end++ = x & 0xff; ++ ++ src += 4; ++ } ++ ++ if (src != src_end) ++ return -1; ++ ++ return dst_end - dst; ++} ++ ++int ++strip_nl(unsigned char *src, unsigned char *src_end, unsigned char *dst) ++{ ++ unsigned char *dst_end = dst; ++ ++ while (src < src_end) { ++ if (*src != '\n') ++ *dst_end++ = *src; ++ src++; ++ } ++ ++ return dst_end - dst; ++} +--- /dev/null ++++ b/ath10k-5.15/decode64.h +@@ -0,0 +1,10 @@ ++#ifndef _DECODE64_H_ ++#define _DECODE64_H_ ++ ++int decode64(unsigned char *src, unsigned char *src_end, ++ unsigned char *dst); ++ ++int strip_nl(unsigned char *src, unsigned char *src_end, ++ unsigned char *dst); ++ ++#endif /* _DECODE64_H_ */