From patchwork Fri May 20 11:38:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 9129321 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 783BC60467 for ; Fri, 20 May 2016 11:40:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A7E11FFC9 for ; Fri, 20 May 2016 11:40:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EEF627A84; Fri, 20 May 2016 11:40:26 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 097991FFC9 for ; Fri, 20 May 2016 11:40:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755646AbcETLj6 (ORCPT ); Fri, 20 May 2016 07:39:58 -0400 Received: from mail-lb0-f194.google.com ([209.85.217.194]:35555 "EHLO mail-lb0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751667AbcETLj4 (ORCPT ); Fri, 20 May 2016 07:39:56 -0400 Received: by mail-lb0-f194.google.com with SMTP id mx9so5449800lbb.2; Fri, 20 May 2016 04:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2UcRBeq0Mlv+RQAq+oivb8jGcnW+b0cyPI/HpIzYtlQ=; b=igw9yuBpq9X8eFejXQ0HwVifcpszmeMa+2pgjVhH6yfhJouKGKg8VLUJygZZ5Oiuo0 +X7P9rRmpOokvu7L+ATerk0rPg8t7aohc3TvHjZkkypXhYvi2PA1iDMSmWVB0xYv+mws hy2SrC+oAzQ/1njLP9ZBDWYwPoJSHswTk4/xoJbRkzWpqSDh+3F087v3gf4t0xHIcKic J+6CEPlgCjgyb5wxBeQ0lIJPKPDJ8DRaedHvxnTXyLh4T+Xry3Fh84I7/Dzgeu/hsb42 oikJexm2iYglPjCaiJ7+9FQ9CfG7BP1ThIoqhR2gKKWrehLl9T+CslLdIMt1KIivE4i/ tGuA== 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:mime-version:content-transfer-encoding; bh=2UcRBeq0Mlv+RQAq+oivb8jGcnW+b0cyPI/HpIzYtlQ=; b=fbMp1McsAvct7EpxaPQ09G/LG+4WThp/tIdZMm7haWfHsdUS3SE+wrSV7xaSYZb9IM 9TnwDGlTpP3x8ieQ/oYufjH30wHlkTQ/6SXfdslhXwdLdMe5eqaJVidxnNyRMhnaOpbw d8Pd5TvLRaU3XBEzC1G8FYTDIEvEcrWDHP4ZFEm56TYHC/k3BfDe0rihDkAMg4kyY++Q Yo2favvl7rKQAhbKnJkF3K23chx6daQntucpsltsUwZ4YH6lYEEEG3ZMy+/Rh1QVWXGB 9WTnbmVbsr8JHJGn/u4n/sD7HQFWvAU5q9BnNC2Tm8wRh3FNs+euAG8ME9uUpcfkpPdC 3dDw== X-Gm-Message-State: AOPr4FVmwUqDZz+ICf584Asbu9uAn6mAso8aM+kt8D+s2mrAIBzwVecTMWj4AUSheeGSAw== X-Received: by 10.112.59.229 with SMTP id c5mr797865lbr.119.1463744393617; Fri, 20 May 2016 04:39:53 -0700 (PDT) Received: from linux-samsung.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id t11sm3231556lfd.20.2016.05.20.04.39.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 May 2016 04:39:52 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Kalle Valo Cc: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Brett Rudley , Arend van Spriel , "Franky (Zhenhui) Lin" , Hante Meuleman , Pieter-Paul Giesberts , linux-wireless@vger.kernel.org (open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER), brcm80211-dev-list@broadcom.com (open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER), netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH V2 4.8 2/2] brcmfmac: support get_channel cfg80211 callback Date: Fri, 20 May 2016 13:38:58 +0200 Message-Id: <1463744355-5528-2-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1463744355-5528-1-git-send-email-zajec5@gmail.com> References: <1463655770-22467-1-git-send-email-zajec5@gmail.com> <1463744355-5528-1-git-send-email-zajec5@gmail.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is important for brcmfmac as some of released firmwares (e.g. brcmfmac4366b-pcie.bin) may pick different channel than requested. This has been tested with BCM4366B1 in D-Link DIR-885L. Signed-off-by: Rafał Miłecki --- V2: Check if ndev isn't NULL, update description. --- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index 597495d..299a404 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -4892,6 +4892,68 @@ exit: return err; } +static int brcmf_cfg80211_get_channel(struct wiphy *wiphy, + struct wireless_dev *wdev, + struct cfg80211_chan_def *chandef) +{ + struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); + struct net_device *ndev = wdev->netdev; + struct brcmf_if *ifp; + struct brcmu_chan ch; + enum nl80211_band band = 0; + enum nl80211_chan_width width = 0; + u32 chanspec; + int freq, err; + + if (!ndev) + return -ENODEV; + ifp = netdev_priv(ndev); + + err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec); + if (err) { + brcmf_err("chanspec failed (%d)\n", err); + return err; + } + + ch.chspec = chanspec; + cfg->d11inf.decchspec(&ch); + + switch (ch.band) { + case BRCMU_CHAN_BAND_2G: + band = NL80211_BAND_2GHZ; + break; + case BRCMU_CHAN_BAND_5G: + band = NL80211_BAND_5GHZ; + break; + } + + switch (ch.bw) { + case BRCMU_CHAN_BW_80: + width = NL80211_CHAN_WIDTH_80; + break; + case BRCMU_CHAN_BW_40: + width = NL80211_CHAN_WIDTH_40; + break; + case BRCMU_CHAN_BW_20: + width = NL80211_CHAN_WIDTH_20; + break; + case BRCMU_CHAN_BW_80P80: + width = NL80211_CHAN_WIDTH_80P80; + break; + case BRCMU_CHAN_BW_160: + width = NL80211_CHAN_WIDTH_160; + break; + } + + freq = ieee80211_channel_to_frequency(ch.control_ch_num, band); + chandef->chan = ieee80211_get_channel(wiphy, freq); + chandef->width = width; + chandef->center_freq1 = ieee80211_channel_to_frequency(ch.chnum, band); + chandef->center_freq2 = 0; + + return 0; +} + static int brcmf_cfg80211_crit_proto_start(struct wiphy *wiphy, struct wireless_dev *wdev, enum nl80211_crit_proto_id proto, @@ -5054,6 +5116,7 @@ static struct cfg80211_ops brcmf_cfg80211_ops = { .mgmt_tx = brcmf_cfg80211_mgmt_tx, .remain_on_channel = brcmf_p2p_remain_on_channel, .cancel_remain_on_channel = brcmf_cfg80211_cancel_remain_on_channel, + .get_channel = brcmf_cfg80211_get_channel, .start_p2p_device = brcmf_p2p_start_device, .stop_p2p_device = brcmf_p2p_stop_device, .crit_proto_start = brcmf_cfg80211_crit_proto_start,