From patchwork Tue Mar 29 06:06:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 8682661 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EFC01C0553 for ; Tue, 29 Mar 2016 06:11:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E8CC22017D for ; Tue, 29 Mar 2016 06:11:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EDBCB2014A for ; Tue, 29 Mar 2016 06:11:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755897AbcC2GGm (ORCPT ); Tue, 29 Mar 2016 02:06:42 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:34836 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751453AbcC2GGj (ORCPT ); Tue, 29 Mar 2016 02:06:39 -0400 Received: by mail-pf0-f172.google.com with SMTP id n5so6547635pfn.2 for ; Mon, 28 Mar 2016 23:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SyzeNnVUFyYIDn7ulr0F/GLPzUMsp+H/ybdv18ditjs=; b=UJf2V3hPHzEfqVoP0doloJXyy/OYvVI6mJER8p1azxuBybF3M5KL88MloUKyVcpb8/ UZpwplU92TCajkYKXh5Vdt+vV8+IhzIwJIAuAfUnVQCBSz5A6/ecYHbzUFMrI8/3UonL 2KV1R2NH1fZ1msVuN6x0VI2NQsWeXIbuzf2OQ= 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=SyzeNnVUFyYIDn7ulr0F/GLPzUMsp+H/ybdv18ditjs=; b=WZmTwtRkLNNHy7Dncwoyv4eH9brFnGBgKOnyykQdKfuWVuGjMGCqs5SVQrArYN9nHw PD1gPKgfSxZyJd3S/5aECEHe/aCU7+SJhemHjFyJrfZwM3ATrypXV93aOhgiEUQGJisq c1ctf4q1EPUfGSNkK+VTB4vaHoU5lT5a0rCR338BP2ij4X+fKn0SGz2cEBvAhDkNTO9g 4h+Ey0nyV4iUxTO6oy8sjtMRxcCLCBS9fJ0ic/NGpOdu45IfL294R0lMFKsMJbmQZDxf PyF2iMcOMVWkrpQqWPe4n4TRomwK3os29FOnXRLNedG/qV3UAbh77d4jB6aknq52CQ/g N3FA== X-Gm-Message-State: AD7BkJJf60uLtPj0G9ZWPCXLbrDBYns1/lL2rNklO23aLrkOk30wTPkwmu7uipyTVcKOqBf+ X-Received: by 10.98.66.75 with SMTP id p72mr757990pfa.50.1459231598788; Mon, 28 Mar 2016 23:06:38 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id k88sm39878073pfj.0.2016.03.28.23.06.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Mar 2016 23:06:38 -0700 (PDT) From: Bjorn Andersson To: Eugene Krasnikov , Kalle Valo Cc: wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pontus Fuchs Subject: [PATCH 02/16] wcn36xx: Pad TIM PVM if needed Date: Mon, 28 Mar 2016 23:06:19 -0700 Message-Id: <1459231593-360-3-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459231593-360-1-git-send-email-bjorn.andersson@linaro.org> References: <1459231593-360-1-git-send-email-bjorn.andersson@linaro.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pontus Fuchs The wcn36xx FW expects a fixed size TIM PVM in the beacon template. If supplied with a shorter than expected PVM it will overwrite the IE following the TIM. Signed-off-by: Pontus Fuchs Signed-off-by: Bjorn Andersson --- drivers/net/wireless/ath/wcn36xx/hal.h | 3 +++ drivers/net/wireless/ath/wcn36xx/smd.c | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h index 4fd77ccc2287..6f99b6134e4e 100644 --- a/drivers/net/wireless/ath/wcn36xx/hal.h +++ b/drivers/net/wireless/ath/wcn36xx/hal.h @@ -54,6 +54,9 @@ /* Default Beacon template size. */ #define BEACON_TEMPLATE_SIZE 0x17C +/* Minimum PVM size that the FW expects. See comment in smd.c for details. */ +#define TIM_MIN_PVM_SIZE 6 + /* Param Change Bitmap sent to HAL */ #define PARAM_BCN_INTERVAL_CHANGED (1 << 0) #define PARAM_SHORT_PREAMBLE_CHANGED (1 << 1) diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c index ff3ed2461a69..0aa3ae62494e 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.c +++ b/drivers/net/wireless/ath/wcn36xx/smd.c @@ -1375,12 +1375,14 @@ int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct ieee80211_vif *vif, u16 p2p_off) { struct wcn36xx_hal_send_beacon_req_msg msg_body; - int ret = 0; + int ret = 0, pad, pvm_len; mutex_lock(&wcn->hal_mutex); INIT_HAL_MSG(msg_body, WCN36XX_HAL_SEND_BEACON_REQ); - msg_body.beacon_length = skb_beacon->len; + pvm_len = skb_beacon->data[tim_off + 1] - 3; + pad = TIM_MIN_PVM_SIZE - pvm_len; + msg_body.beacon_length = skb_beacon->len + pad; /* TODO need to find out why + 6 is needed */ msg_body.beacon_length6 = msg_body.beacon_length + 6; @@ -1393,6 +1395,22 @@ int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct ieee80211_vif *vif, memcpy(msg_body.beacon, skb_beacon->data, skb_beacon->len); memcpy(msg_body.bssid, vif->addr, ETH_ALEN); + if (pad > 0) { + /* + * The wcn36xx FW has a fixed size for the PVM in the TIM. If + * given the beacon template from mac80211 with a PVM shorter + * than the FW expectes it will overwrite the data after the + * TIM. + */ + wcn36xx_dbg(WCN36XX_DBG_HAL, "Pad TIM PVM. %d bytes at %d\n", + pad, pvm_len); + memmove(&msg_body.beacon[tim_off + 5 + pvm_len + pad], + &msg_body.beacon[tim_off + 5 + pvm_len], + skb_beacon->len - (tim_off + 5 + pvm_len)); + memset(&msg_body.beacon[tim_off + 5 + pvm_len], 0, pad); + msg_body.beacon[tim_off + 1] += pad; + } + /* TODO need to find out why this is needed? */ if (vif->type == NL80211_IFTYPE_MESH_POINT) /* mesh beacon don't need this, so push further down */