From patchwork Tue Jun 18 10:42:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venkateswara Naralasetty X-Patchwork-Id: 11001373 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-2.web.codeaurora.org (Postfix) with ESMTP id 047F414BB for ; Tue, 18 Jun 2019 10:43:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E88BC28A34 for ; Tue, 18 Jun 2019 10:43:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCFEF28A3D; Tue, 18 Jun 2019 10:43:07 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 8399F28A34 for ; Tue, 18 Jun 2019 10:43:07 +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=7p2f77iZnuwQ90K5P5tm62U1xoC7ENp0ojjx1libSuY=; b=bLM INDdcN5uuobsWct6QbcoVIp7BjDZey6dYqEKhrXykPwpFDgDKpK6O97KlRP9MlzXTevGwlZdV+aMi D5LC+whyHe8tgjp13JdLCM7MFW6uplNA5+744vhnVgAA0FYbXhPHmmf9g3R2H10yMu2GDMVZ0iGT8 vmB64psYemzMMRr6ZdIfGvR0Ac99Lk7PhplXuEg+NA4mYiYTH6QpqJpu6H7esRolu8uVePLGZmHB9 8ibZAG3aRLp6ePNWYfMZSRHui9jy2xPDO0Hqq/a5DhWTPV4Abai00gq/GTYeydMLGz/p7cmk6ejkA 018AuEzB+X9nAoZCmTTSuSLwCycZ5lQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hdBZy-0006hS-OW; Tue, 18 Jun 2019 10:43:06 +0000 Received: from alexa-out-blr-02.qualcomm.com ([103.229.18.198] helo=alexa-out-blr.qualcomm.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hdBZu-0006gq-Sg for ath11k@lists.infradead.org; Tue, 18 Jun 2019 10:43:04 +0000 Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by alexa-out-blr.qualcomm.com with ESMTP/TLS/AES256-SHA; 18 Jun 2019 16:12:21 +0530 X-IronPort-AV: E=McAfee;i="6000,8403,9291"; a="10318736" Received: from vnaralas-linux.qualcomm.com ([10.201.26.231]) by ironmsg01-blr.qualcomm.com with ESMTP; 18 Jun 2019 16:12:18 +0530 Received: by vnaralas-linux.qualcomm.com (Postfix, from userid 443942) id C1628DB4; Tue, 18 Jun 2019 16:12:16 +0530 (IST) From: Venkateswara Naralasetty To: ath11k@lists.infradead.org Subject: [PATCH 1/2] ath11k: clean up in htt extd stats Date: Tue, 18 Jun 2019 16:12:13 +0530 Message-Id: <1560854534-29013-1-git-send-email-vnaralas@codeaurora.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190618_034303_357545_40CE683D X-CRM114-Status: UNSURE ( 7.34 ) X-CRM114-Notice: Please train this message. X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Venkateswara Naralasetty MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Removed pointer arithmetic and the magic numbers Signed-off-by: Venkateswara Naralasetty --- drivers/net/wireless/ath/ath11k/debug_htt_stats.c | 29 +++++++++++++---------- drivers/net/wireless/ath/ath11k/dp.h | 19 ++++++--------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/debug_htt_stats.c b/drivers/net/wireless/ath/ath11k/debug_htt_stats.c index e5147ae..57fdb8c 100644 --- a/drivers/net/wireless/ath/ath11k/debug_htt_stats.c +++ b/drivers/net/wireless/ath/ath11k/debug_htt_stats.c @@ -16,7 +16,7 @@ #define HTT_MAX_STRING_LEN 256 #define HTT_MAX_PRINT_CHAR_PER_ELEM 15 -#define HTT_TLV_HDR_LEN HTT_T2H_EXT_STATS_CONF_TLV_HDR_SIZE +#define HTT_TLV_HDR_LEN 4 #define ARRAY_TO_STRING(out, arr, len) \ do { \ @@ -4192,22 +4192,29 @@ static int ath11k_dbg_htt_ext_stats_parse(struct ath11k_base *ab, void ath11k_dbg_htt_ext_stats_handler(struct ath11k_base *ab, struct sk_buff *skb) { - u8 *data = (u8 *)skb->data; - u32 len; - u64 cookie; + struct ath11k_htt_extd_stats_msg *msg; struct debug_htt_stats_req *stats_req; struct ath11k *ar; + u32 len; + u64 cookie; int ret; u8 pdev_id; - data = data + 4; - cookie = *(u64 *)data; + msg = (struct ath11k_htt_extd_stats_msg *)skb->data; + cookie = msg->cookie; stats_req = (struct debug_htt_stats_req *)(uintptr_t)cookie; if (!stats_req) return; - pdev_id = DP_HW2SW_MACID(stats_req->pdev_id); - ar = ab->pdevs[pdev_id].ar; + pdev_id = stats_req->pdev_id; + rcu_read_lock(); + ar = ath11k_get_ar_by_pdev_id(ab, pdev_id); + rcu_read_unlock(); + if (!ar) { + ath11k_warn(ab, "failed to get ar for pdev_id %d\n", pdev_id); + return; + } + spin_lock_bh(&ar->debug.htt_stats.lock); if (stats_req->done) { spin_unlock_bh(&ar->debug.htt_stats.lock); @@ -4216,10 +4223,8 @@ void ath11k_dbg_htt_ext_stats_handler(struct ath11k_base *ab, stats_req->done = true; spin_unlock_bh(&ar->debug.htt_stats.lock); - data = data + 8; - len = FIELD_GET(HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_M, *(u32 *)data); - data = data + 4; - ret = ath11k_dp_htt_tlv_iter(ab, data, len, + len = FIELD_GET(HTT_T2H_EXT_STATS_INFO1_LENGTH, msg->info1); + ret = ath11k_dp_htt_tlv_iter(ab, msg->data, len, ath11k_dbg_htt_ext_stats_parse, (void *)stats_req); if (ret) diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/ath/ath11k/dp.h index 037fcbd..d41886a 100644 --- a/drivers/net/wireless/ath/ath11k/dp.h +++ b/drivers/net/wireless/ath/ath11k/dp.h @@ -1463,20 +1463,15 @@ struct htt_ext_stats_cfg_params { * 4 bytes. */ -#define HTT_T2H_EXT_STATS_COOKIE_SIZE 8 +#define HTT_T2H_EXT_STATS_INFO1_LENGTH GENMASK(31, 16) -#define HTT_T2H_EXT_STATS_CONF_HDR_SIZE 4 - -#define HTT_T2H_EXT_STATS_CONF_TLV_HDR_SIZE 4 +struct ath11k_htt_extd_stats_msg { + u32 info0; + u64 cookie; + u32 info1; + u8 data[0]; +} __packed; -#define HTT_T2H_EXT_STATS_CONF_TLV_TYPE_M 0x000000ff -#define HTT_T2H_EXT_STATS_CONF_TLV_TYPE_S 0 -#define HTT_T2H_EXT_STATS_CONF_TLV_STATUS_M 0x00000700 -#define HTT_T2H_EXT_STATS_CONF_TLV_STATUS_S 8 -#define HTT_T2H_EXT_STATS_CONF_TLV_DONE_M 0x00000800 -#define HTT_T2H_EXT_STATS_CONF_TLV_DONE_S 11 -#define HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_M GENMASK(31, 16) -#define HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_S 16 struct htt_mac_addr { u32 mac_addr_l32;