From patchwork Fri Aug 25 02:30:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mitsyanko X-Patchwork-Id: 9921161 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 D9F98600C5 for ; Fri, 25 Aug 2017 02:30:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C29CC20564 for ; Fri, 25 Aug 2017 02:30:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6758205AD; Fri, 25 Aug 2017 02:30:59 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham 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 DD4C620564 for ; Fri, 25 Aug 2017 02:30:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754468AbdHYCay (ORCPT ); Thu, 24 Aug 2017 22:30:54 -0400 Received: from mail-cys01nam02on0041.outbound.protection.outlook.com ([104.47.37.41]:61440 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754421AbdHYCas (ORCPT ); Thu, 24 Aug 2017 22:30:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=y24ZObiyQGg0YSqQZbrHI99GdXusH1IeEQEA03A1dIE=; b=gfvdU/7x/pzmGZnV1eLPNTlCUX856NX0OpphWI+oiQNJt8heN8Rf4GzvRrxUdAXNwl3O3eqXW0JzhwQy+M0unSohLChO1ZmvRw1xeCHJR2KqF3KaoNKm2gdg/NBGg9K7Yx0MKMXg6mp+tOuvSvOaa4HRACzhIpEhQ+82n1PMC8Q= Received: from dodo-dell.quantenna.com (12.131.200.68) by SN1PR0501MB2047.namprd05.prod.outlook.com (10.163.227.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.4; Fri, 25 Aug 2017 02:30:46 +0000 From: igor.mitsyanko.os@quantenna.com To: linux-wireless@vger.kernel.org Cc: sergey.matyukevich.os@quantenna.com, avinashp@quantenna.com, johannes@sipsolutions.net, Igor Mitsyanko , Igor Mitsyanko Subject: [PATCH 03/27] qtnfmac: retreive current channel info from EP Date: Thu, 24 Aug 2017 19:30:00 -0700 Message-Id: <20170825023024.10565-4-igor.mitsyanko.os@quantenna.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170825023024.10565-1-igor.mitsyanko.os@quantenna.com> References: <20170825023024.10565-1-igor.mitsyanko.os@quantenna.com> MIME-Version: 1.0 X-Originating-IP: [12.131.200.68] X-ClientProxiedBy: CY4PR15CA0017.namprd15.prod.outlook.com (10.172.74.27) To SN1PR0501MB2047.namprd05.prod.outlook.com (10.163.227.20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2d148ab4-00a9-47d4-ce14-08d4eb614b0d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN1PR0501MB2047; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0501MB2047; 3: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uA/PC3CdFDN+qUAPyzVuHzqRbrBljmeI2F5U3l9noKqxWL86zdlHE7r4uhhpbYsnzVD1pSkqvJvehhAO1QJJ3+PH61GgTBb3yMld6vcXnJ8lB+krHTqAhawJltZXyP/ILXaXOFkPX0jqYhr8yfWEYP3nBaFCo1rGYbGW4iGe65p17igGicdF8vpxM6bhhQDu3mAp+AHAuYPj1WmWs/oA6DRpcijKspIcCH5m+oET1HDdhHsmHhupbDeawIjqF0xHpWTdkVzi3bUuVGWrne44qgUawNbHbRHXFzih5KsDYn/ooLqPEzr/btOs7/Ka5tpkqz2+BiZHa8TooP2MwhrxRjxXbQ+47fv+ePUSiuh4kmEv3mkzt+FD/9ku6DDI2lZD6sw5IFEDwDe0aRIzco+LtjLJ05WKzptkVX7S0ktRqar1xz6n2HMKDOJA//bxUKebon6emUCBDMjw+jnmXqCVukphpU=; 4:BzX1e3cU+Hwemm4YoXe5xrPr5VoyxNs9lgw18osdF2o7YAWBhRrAlcUF7FfzmHp6OCFDj1N+9COBk734MwJ1KClgPp2T5fchMcpDJ5/xsqK5Tiy5ZEieCP8ZUWPMNTgBDoD4A5cLqx8EXdA3ljCGv6wghEhkZ/She64eIPsnu7nVZ14lK7VeZfN4vvhViZtnTQ8TNK6ZiBrk44n+m0D21TXxOIb3gMV/7XsKqG0bj8x96GCD9mRKYgOm4gUoTUCI X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(6041248)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR0501MB2047; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR0501MB2047; X-Forefront-PRVS: 041032FF37 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39830400002)(199003)(189002)(76176999)(53416004)(50986999)(110136004)(7350300001)(6916009)(6666003)(2950100002)(47776003)(2906002)(9686003)(54906002)(53936002)(66066001)(2361001)(106356001)(105586002)(2351001)(86362001)(305945005)(33646002)(7736002)(42186005)(81166006)(81156014)(107886003)(8676002)(103116003)(478600001)(85782001)(68736007)(50226002)(50466002)(3846002)(6486002)(25786009)(36756003)(97736004)(5660300001)(1076002)(6116002)(69596002)(5003940100001)(101416001)(4326008)(189998001)(48376002)(85772001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0501MB2047; H:dodo-dell.quantenna.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=igor.mitsyanko.os@quantenna.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0501MB2047; 23:E9PogSXDul0a6ftH4nuOrlF7y6phCNva4DY0ts2?= =?us-ascii?Q?9Vji28veFBvPozxQ7+I5DfF78zZreOoKWYPG3O7VFqbnU5HTB28lLpBYeBLn?= =?us-ascii?Q?ucGUDvm2nwZbuWU0HzmAYTKkyELE+ZKwKzxVj4nUgPZqZRFwcALsJ00jSxKa?= =?us-ascii?Q?gUBWa31yOS4jgTUV2Io7R2kYIIoR4rryoOuWiEhXQPaprTlxsMxrA0MiTxlL?= =?us-ascii?Q?U82P0EOk0k+ai0hguB7tuABupAcW/QgN7jBZkjGAtJnNPx/KwI/q122JCqC4?= =?us-ascii?Q?MrCFPIaHJgti5jQJw6VOVWaRrGNgpQqGpkjK7U3iDug+2Ce2ywPfYQ+3g8GD?= =?us-ascii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1DuaTkAcNdpm?= =?us-ascii?Q?AN1UwbDyy8deOpSYChPfCGCZ8H/WBl+SuatZiRByhZjcKPargN3lpBUzepAm?= =?us-ascii?Q?/og=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR0501MB2047; 6:oWAudtoBqaZAdoGmd6I8S9b9/NGS+TRK3/FhQIRz2LRuToRI/RYeltZbKv5H0FCq5DQFthJwFny0blj6323VLEfDNuhVxlHCD/cqzhhu/juUoXWGVEKBk5XaimNKRJbuPEoPuSJ0GdrFQXhw4lMyp+J8T3dofW3lzefGISUTOddk97IRh0Ofxa4WU+yC5lOJJud2n9LIHWiEBXmzj01QZS/jW6nOzHWWd0egVSiqAFwWUggh+Q14blO++P89IjcAjmbjevNeWgznZX+ORSJmFuaLzetbMNLwGCtrKC1fBwT5JkV7S6UgbhcrWUrDrc6cXGd4iq6K8vLiI448zjHAFQ==; 5:ifObglYF1/7N47GI7hwQuujTQZhNNvB8VzVMN/ZOUYIVpGibzKW/kCWY/NmNs53Ak9M4mXBrYce+29w5pDSehOqBClDX5W495n8k2bhEiUjsfBGkIxqFW9KH6OTsHGwkbjKsISNcpiHZsYvO36uQSw==; 24:R0HndyFUiHl/PGhOL6Iu2oXfrI9kEyJujr5ZDBm4Ejue3IRNXO/VTNVR4ntHplRdF5n2qjmQF/X89l02csD8sWr59liXBOhE7BTTAulC+gg=; 7:0z2aJaaCgn7od5qjXy5XALONEGxQE340s2SjZN0fmojI4viLN//CEa1m/L/PKiQjC2TG+twbjIsNbJ+X8NbAb6gUnojXkG8BrlUbjwUq2Cou06ORU4fF+BwunVmgIWSAqRewGUXQzIbnT/7l57MStfbVuELIfMEggX8Xm2aZLr75wFFBCOr6UhWCRdJt7e6tTSWGtlbS3joHZTCIIL0RgZeRhJSY4xnNnxyiQ/pVWP8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 02:30:46.2758 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0501MB2047 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 From: Igor Mitsyanko Do not try to cache current operational channel info in driver, this is a potential source of synchronization issues + driver does not really need that info. Introduce GET_CHANNEL command and process it appropriately. Signed-off-by: Igor Mitsyanko --- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 34 ++++++++------------ drivers/net/wireless/quantenna/qtnfmac/commands.c | 38 +++++++++++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.h | 1 + drivers/net/wireless/quantenna/qtnfmac/qlink.h | 11 +++++++ 4 files changed, 63 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c index 856fa6e..8bfe61d 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c @@ -793,37 +793,29 @@ qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, struct qtnf_wmac *mac = wiphy_priv(wiphy); struct net_device *ndev = wdev->netdev; struct qtnf_vif *vif; + int ret; if (!ndev) return -ENODEV; vif = qtnf_netdev_get_priv(wdev->netdev); - switch (vif->wdev.iftype) { - case NL80211_IFTYPE_STATION: - if (vif->sta_state == QTNF_STA_DISCONNECTED) { - pr_warn("%s: STA disconnected\n", ndev->name); - return -ENODATA; - } - break; - case NL80211_IFTYPE_AP: - if (!(vif->bss_status & QTNF_STATE_AP_START)) { - pr_warn("%s: AP not started\n", ndev->name); - return -ENODATA; - } - break; - default: - pr_err("unsupported vif type (%d)\n", vif->wdev.iftype); - return -ENODATA; + ret = qtnf_cmd_get_channel(vif, chandef); + if (ret) { + pr_err("%s: failed to get channel: %d\n", ndev->name, ret); + goto out; } - if (!cfg80211_chandef_valid(&mac->chandef)) { - pr_err("invalid channel settings on %s\n", ndev->name); - return -ENODATA; + if (!cfg80211_chandef_valid(chandef)) { + pr_err("%s: bad chan freq1=%u bw=%u\n", ndev->name, + chandef->center_freq1, chandef->width); + ret = -ENODATA; } - memcpy(chandef, &mac->chandef, sizeof(*chandef)); - return 0; + memcpy(&mac->chandef, chandef, sizeof(mac->chandef)); + +out: + return ret; } static int qtnf_channel_switch(struct wiphy *wiphy, struct net_device *dev, diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index 4206886..806b88b 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -2358,3 +2358,41 @@ int qtnf_cmd_send_chan_switch(struct qtnf_wmac *mac, qtnf_bus_unlock(mac->bus); return ret; } + +int qtnf_cmd_get_channel(struct qtnf_vif *vif, struct cfg80211_chan_def *chdef) +{ + struct qtnf_bus *bus = vif->mac->bus; + const struct qlink_resp_channel_get *resp; + struct sk_buff *cmd_skb; + struct sk_buff *resp_skb = NULL; + u16 res_code = QLINK_CMD_RESULT_OK; + int ret; + + cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, + QLINK_CMD_CHAN_GET, + sizeof(struct qlink_cmd)); + if (unlikely(!cmd_skb)) + return -ENOMEM; + + qtnf_bus_lock(bus); + + ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb, &res_code, + sizeof(*resp), NULL); + + qtnf_bus_unlock(bus); + + if (unlikely(ret)) + goto out; + + if (unlikely(res_code != QLINK_CMD_RESULT_OK)) { + ret = -ENODATA; + goto out; + } + + resp = (const struct qlink_resp_channel_get *)resp_skb->data; + qlink_chandef_q2cfg(priv_to_wiphy(vif->mac), &resp->chan, chdef); + +out: + consume_skb(resp_skb); + return ret; +} diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.h b/drivers/net/wireless/quantenna/qtnfmac/commands.h index 783b203..e1bcb83 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.h +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.h @@ -75,5 +75,6 @@ int qtnf_cmd_get_chan_stats(struct qtnf_wmac *mac, u16 channel, struct qtnf_chan_stats *stats); int qtnf_cmd_send_chan_switch(struct qtnf_wmac *mac, struct cfg80211_csa_settings *params); +int qtnf_cmd_get_channel(struct qtnf_vif *vif, struct cfg80211_chan_def *chdef); #endif /* QLINK_COMMANDS_H_ */ diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h index 5936854..fb88f3e 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h @@ -169,6 +169,7 @@ enum qlink_cmd_type { QLINK_CMD_REG_NOTIFY = 0x0019, QLINK_CMD_CHANS_INFO_GET = 0x001A, QLINK_CMD_CHAN_SWITCH = 0x001B, + QLINK_CMD_CHAN_GET = 0x001C, QLINK_CMD_CONFIG_AP = 0x0020, QLINK_CMD_START_AP = 0x0021, QLINK_CMD_STOP_AP = 0x0022, @@ -694,6 +695,16 @@ struct qlink_resp_get_chan_stats { u8 info[0]; } __packed; +/** + * struct qlink_resp_channel_get - response for QLINK_CMD_CHAN_GET command + * + * @chan: definition of current operating channel. + */ +struct qlink_resp_channel_get { + struct qlink_resp rhdr; + struct qlink_chandef chan; +} __packed; + /* QLINK Events messages related definitions */