From patchwork Tue Jun 18 11:05:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venkateswara Naralasetty X-Patchwork-Id: 11001383 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 B6B8614B6 for ; Tue, 18 Jun 2019 11:05:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A421628987 for ; Tue, 18 Jun 2019 11:05:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9820628A4E; Tue, 18 Jun 2019 11:05:28 +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 3BAC628987 for ; Tue, 18 Jun 2019 11:05:28 +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=7vjaxKP1nji1J6hbRxAlGUCIy7IvIWKs9YLH8p0i1ok=; b=gGF 1RHThNKIyDrSAQfzCvm1vRqb37/Cq0J/do7J++hiMbnPlcvHGma0HFnZTlYi4BKWF0oDUwzT6ndt/ AIpbu5pp8T7qOnqg4bKmMC2SqQxryLLywG0SMCJzoKuHYjOZ/eMepKI9oEQbvR6oWz6UHyQMvOVCN GaDu5HW9RJjval08LBN5nAiqnt/Ka/E769sJAoz2v4riW2CEXb98SqJ13GUTI096RYYz/S3jOM2LJ 4srWUcJIT1dwp3MRRd+kSSZdFXTUtxkFnfGv/jvG/dRbbqklyAOXHDBz6T5t2Qjg1+ilpQPLI1uBC paOYJJ21tETY0+KmFepBfWhS4sdBWuA==; 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 1hdBvb-0002BO-De; Tue, 18 Jun 2019 11:05:27 +0000 Received: from alexa-out-blr-01.qualcomm.com ([103.229.18.197]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hdBvX-000288-Rq for ath11k@lists.infradead.org; Tue, 18 Jun 2019 11:05:25 +0000 Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by alexa-out-blr-01.qualcomm.com with ESMTP/TLS/AES256-SHA; 18 Jun 2019 16:35:21 +0530 X-IronPort-AV: E=McAfee;i="6000,8403,9291"; a="9716308" Received: from vnaralas-linux.qualcomm.com ([10.201.26.231]) by ironmsg02-blr.qualcomm.com with ESMTP; 18 Jun 2019 16:35:20 +0530 Received: by vnaralas-linux.qualcomm.com (Postfix, from userid 443942) id B69FF15DA; Tue, 18 Jun 2019 16:35:19 +0530 (IST) From: Venkateswara Naralasetty To: ath11k@lists.infradead.org Subject: [PATCH] ath11k: clean up in htt ppdu stats Date: Tue, 18 Jun 2019 16:35:18 +0530 Message-Id: <1560855918-31801-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_040524_337025_45856323 X-CRM114-Status: UNSURE ( 7.57 ) 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/dp.h | 12 ++++++++++-- drivers/net/wireless/ath/ath11k/dp_rx.c | 18 ++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/ath/ath11k/dp.h index 037fcbd..514acf1 100644 --- a/drivers/net/wireless/ath/ath11k/dp.h +++ b/drivers/net/wireless/ath/ath11k/dp.h @@ -1005,8 +1005,16 @@ struct htt_resp_msg { * Value: payload_size in bytes */ -#define HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_M GENMASK(31, 16) -#define HTT_T2H_PPDU_STATS_PDEV_ID_M GENMASK(11, 10) +#define HTT_T2H_PPDU_STATS_INFO_PDEV_ID GENMASK(11, 10) +#define HTT_T2H_PPDU_STATS_INFO_PAYLOAD_SIZE GENMASK(31, 16) + +struct ath11k_htt_ppdu_stats_msg { + u32 info; + u32 ppdu_id; + u32 timestamp; + u32 rsvd; + u8 data[0]; +} __packed; struct htt_tlv { u32 header; diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 0c660de..03390a8 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -1035,17 +1035,18 @@ struct htt_ppdu_stats_info *ath11k_dp_htt_get_ppdu_desc(struct ath11k *ar, static int ath11k_htt_pull_ppdu_stats(struct ath11k_base *ab, struct sk_buff *skb) { - u8 *data = (u8 *)skb->data; + struct ath11k_htt_ppdu_stats_msg *msg; struct htt_ppdu_stats_info *ppdu_info; struct ath11k *ar; int ret; u8 pdev_id; u32 ppdu_id, len; - len = FIELD_GET(HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_M, *(u32 *)data); - pdev_id = FIELD_GET(HTT_T2H_PPDU_STATS_PDEV_ID_M, *(u32 *)data); + msg = (struct ath11k_htt_ppdu_stats_msg *)skb->data; + len = FIELD_GET(HTT_T2H_PPDU_STATS_INFO_PAYLOAD_SIZE, msg->info); + pdev_id = FIELD_GET(HTT_T2H_PPDU_STATS_INFO_PDEV_ID, msg->info); pdev_id = DP_HW2SW_MACID(pdev_id); - ppdu_id = *((u32 *)data + 1); + ppdu_id = msg->ppdu_id; rcu_read_lock(); ar = ath11k_get_ar_by_pdev_id(ab, pdev_id); @@ -1058,9 +1059,6 @@ static int ath11k_htt_pull_ppdu_stats(struct ath11k_base *ab, trace_ath11k_htt_ppdu_stats(ar, skb->data, len); } - /* TLV info starts after 16bytes of header */ - data = (u8 *)data + 16; - ppdu_info = ath11k_dp_htt_get_ppdu_desc(ar, ppdu_id); if (!ppdu_info) { ret = -EINVAL; @@ -1068,7 +1066,7 @@ static int ath11k_htt_pull_ppdu_stats(struct ath11k_base *ab, } ppdu_info->ppdu_id = ppdu_id; - ret = ath11k_dp_htt_tlv_iter(ab, data, len, + ret = ath11k_dp_htt_tlv_iter(ab, msg->data, len, ath11k_htt_tlv_ppdu_stats_parse, (void *)ppdu_info); if (ret) { @@ -1090,7 +1088,7 @@ static void ath11k_htt_pktlog(struct ath11k_base *ab, u32 len; u8 pdev_id; - len = FIELD_GET(HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_M, data->hdr); + len = FIELD_GET(HTT_T2H_PPDU_STATS_INFO_PAYLOAD_SIZE, data->hdr); if (len > ATH11K_HTT_PKTLOG_MAX_SIZE) { @@ -1100,7 +1098,7 @@ static void ath11k_htt_pktlog(struct ath11k_base *ab, return; } - pdev_id = FIELD_GET(HTT_T2H_PPDU_STATS_PDEV_ID_M, data->hdr); + pdev_id = FIELD_GET(HTT_T2H_PPDU_STATS_INFO_PDEV_ID, data->hdr); pdev_id = DP_HW2SW_MACID(pdev_id); ar = ab->pdevs[pdev_id].ar;