From patchwork Wed Oct 20 13:50:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 516022 Delivered-To: patch@linaro.org Received: by 2002:ac0:cd8c:0:0:0:0:0 with SMTP id d12csp1792970imp; Wed, 20 Oct 2021 06:38:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLPMUxJSwFoYqmnDvd+OUvX0Zp08t1OXY3CPT3tJvyjvnduYgHfGhJ2zTDh29bWP5XlocZ X-Received: by 2002:aa7:8882:0:b0:44c:9270:1cba with SMTP id z2-20020aa78882000000b0044c92701cbamr6578612pfe.26.1634737115756; Wed, 20 Oct 2021 06:38:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634737115; cv=none; d=google.com; s=arc-20160816; b=o2iwki0XwPIvMvrxGv+yLI0lCoDzO0lst49eGRLszrJzhLuja2LbBFKMRJoydEb7kE HylqSQQOAklq2E6ChrRaIEr4+IcFruWu4JrxcW0FfINs/80l9qG/hn0cbeYwYacNqszu imxbMYZb5RTxDwqRJW+IDVq1F9fp0nfI++oV10RFvV5FkZZWKIO23w3nZmJ5xldcDyAX +owghDS4xZ1vfT2m9bOOzTaxFamj0MrMg+j2HGMN5intkzS47TsJ4EhYxKZxohdcSXST SPQGRr23eEoozIDbmAcbNuRVrSdhqrlRDuEl61GtjVLHfwTfa7+tHej+p8VErUqjsJ4+ mQ1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=70vUWLH+PrzHYlAHdr/731Jda8sscVSSqpmxF5dYNXg=; b=JI4meAtM8H2hXfffJJkoUj7QF1GKby81FzHn/atsukf7VQQrR9OnGM7hgCRkvAzs89 PNnb8ymzlR/u6NErH25KOG09YBahmm0kbBtVrjGkYnql1l2Uq/Wkaha2PLx/SvA+FiGj I+W1juhRSgA1pqAwmVTaFiNWZEbWxI4gWT0yC7EnemgeErNSOqWxYZfbpHrY4HVXd6l9 V3YHxZ9pSkKqpvZ805k9a/HL2GCz1h6iE14ARzPSdrv7aNyDQMhn2sh2uPtEMQF/kyoQ ta8EgfC8GlCJObd25NkiVvoLdgBJyXbP1XraPDF0GA+NMRyYxf/84qlLsfp4KAzj0xfa v+Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=Wy2jWwPl; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Id3rGnL3; spf=pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 129si2958924pfy.191.2021.10.20.06.38.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 06:38:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=Wy2jWwPl; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Id3rGnL3; spf=pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc: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=70vUWLH+PrzHYlAHdr/731Jda8sscVSSqpmxF5dYNXg=; b=Wy2jWwPlxr89pH jZgG58vST8/K9lnGLdU38JLRVFJmAIXO9U1b7AFCdMJyqAn1AFX4PIfJ1dvE8dRKbnOMoRNLUwhTc 6h4j5mLcydZ8I3oXoha4OSPJ8DbEldkl4HqQjvHh1tepjOYr0f2ITBqa+mDWpRs6n4Ps3XS7RVd0j SbOUCQ7eFem2blh2ekSh55flWDRCFycht0Lk5EanRyTqV2iAGzOOlVQW5LVNrCV2/KAmUoBRym+Um Ep/EuCXk+2B6CZcc9ROrkSKvAExKLEShp516YqeNv+eMLPt1QsX4HyAzJNOoUpLEVIMLPpRCtgwof yyILwh24NnLBoIvgmTlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdBne-004dgR-Cg; Wed, 20 Oct 2021 13:38:34 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdBna-004dew-Cq for wcn36xx@lists.infradead.org; Wed, 20 Oct 2021 13:38:32 +0000 Received: by mail-wm1-x335.google.com with SMTP id g39so14945952wmp.3 for ; Wed, 20 Oct 2021 06:38:29 -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; bh=D7S7r9FECONNPF1Z5UgVqVgPsfoniOE/HTO607xVpzo=; b=Id3rGnL3hEDWcIKfWcZiYDXL+Qg3NqOPhRa07bj/a5CUCZ95qFMxVpqvIfdDQWUB1/ 5UUx/Ipvx8RgH3SiyaxbUKNGQsdBF69ELWl84thNtfK1VZB0WP5DxAF5axldOu4Zj0uZ u4E6fqkuVmF9lZXE9IL56tULE0pv44S9FStY8v8sNPA2c/xl/YkQmDXnzOe+UvYJWX23 mkVSeQmfWyffEkPREiE76Rt7DLgIdR96jqpq4x8FJJ9SDS0T4e4KVNaqgrslBQGGxcor p90IC7Kz+sv662+BiJq3X1Y3/qSE6VyIX8Z2ueF2zYGoof4gHAjaO1BHSDtvbDd5F+vC 2Vvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=D7S7r9FECONNPF1Z5UgVqVgPsfoniOE/HTO607xVpzo=; b=eERbllnK2mkC7OO1e5qX+0McFBIeIXHLMOPHj8F544OdkE3/UKX7auw4kkPe4jvxMB CGA0R3Wey9W6Q84RB8Vj00yYHKs5Y+m8DyvgwWhtMEhYOQisIwf+gFvwbd0RdKSCKvrW 2VKyb20581t15TJ2x600IpfezeswF/MhIZUO91E7MeDDwyxVoGsELCHpCY3P3Uljpg87 ov8CXj235rTbc9rantjBnfrfrhAMDGg08Fd2QcNxoZPV6DkSt4/S401LeHLUvFRUgAMI RZ3kN1vw6+K5zIsdYqxTsxyZF3gi3lTzVci/HngR+yZyGuK1k+lQL3ixorxHwuEDo6Mt qVqQ== X-Gm-Message-State: AOAM532IlHjV5mKH/I/DG/1YCxPxWSAeFqwMGi8CtJvWor8LahmeJMyu X43/Uso8igSATxdgkIpZQ4HRGsGk/4Jwug== X-Received: by 2002:a5d:67cd:: with SMTP id n13mr51964082wrw.86.1634737108362; Wed, 20 Oct 2021 06:38:28 -0700 (PDT) Received: from localhost.localdomain ([88.160.176.23]) by smtp.gmail.com with ESMTPSA id z1sm2126579wre.21.2021.10.20.06.38.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Oct 2021 06:38:27 -0700 (PDT) From: Loic Poulain To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org, bryan.odonoghue@linaro.org, Loic Poulain , stable@vger.kernel.org Subject: [PATCH] wcn36xx: Channel list update before hardware scan Date: Wed, 20 Oct 2021 15:50:01 +0200 Message-Id: <1634737801-26071-1-git-send-email-loic.poulain@linaro.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-20211020_063830_487741_D8263083 X-CRM114-Status: GOOD ( 17.07 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The channel scan list must be updated before triggering a hardware scan so that firmware takes into account the regulatory info for each single channel such as active/passive config, power, DFS, etc.. [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:335 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: wcn36xx@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "wcn36xx" Errors-To: wcn36xx-bounces+patch=linaro.org@lists.infradead.org The channel scan list must be updated before triggering a hardware scan so that firmware takes into account the regulatory info for each single channel such as active/passive config, power, DFS, etc... Without this the firmware uses its own internal default channel configuration, which is not aligned with mac80211 regulatory rules, and misses several channels (e.g. 144). Cc: stable@vger.kernel.org Fixes: 2f3bef4b247e ("wcn36xx: Add hardware scan offload support") Signed-off-by: Loic Poulain --- drivers/net/wireless/ath/wcn36xx/hal.h | 27 +++++++++ drivers/net/wireless/ath/wcn36xx/main.c | 1 + drivers/net/wireless/ath/wcn36xx/smd.c | 98 +++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/smd.h | 1 + 4 files changed, 127 insertions(+) -- 2.7.4 _______________________________________________ wcn36xx mailing list wcn36xx@lists.infradead.org http://lists.infradead.org/mailman/listinfo/wcn36xx diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h index 5f1f248..229a1c3 100644 --- a/drivers/net/wireless/ath/wcn36xx/hal.h +++ b/drivers/net/wireless/ath/wcn36xx/hal.h @@ -359,6 +359,8 @@ enum wcn36xx_hal_host_msg_type { WCN36XX_HAL_START_SCAN_OFFLOAD_RSP = 205, WCN36XX_HAL_STOP_SCAN_OFFLOAD_REQ = 206, WCN36XX_HAL_STOP_SCAN_OFFLOAD_RSP = 207, + WCN36XX_HAL_UPDATE_CHANNEL_LIST_REQ = 208, + WCN36XX_HAL_UPDATE_CHANNEL_LIST_RSP = 209, WCN36XX_HAL_SCAN_OFFLOAD_IND = 210, WCN36XX_HAL_AVOID_FREQ_RANGE_IND = 233, @@ -1353,6 +1355,31 @@ struct wcn36xx_hal_stop_scan_offload_rsp_msg { u32 status; } __packed; +#define WCN36XX_HAL_CHAN_FLAG_PASSIVE BIT(7) +#define WCN36XX_HAL_CHAN_FLAG_DFS BIT(10) +#define WCN36XX_HAL_CHAN_FLAG_HT BIT(11) +#define WCN36XX_HAL_CHAN_FLAG_VHT BIT(12) +#define WCN36XX_HAL_CHAN_PHY_MODE_11A 0 +#define WCN36XX_HAL_CHAN_PHY_MODE_11BG 1 +#define WCN36XX_HAL_DEFAULT_ANT_GAIN 6 +#define WCN36XX_HAL_DEFAULT_MIN_POWER 6 + +struct wcn36xx_hal_channel_param { + u32 mhz; + u32 band_center_freq1; + u32 band_center_freq2; + u32 channel_info; + u32 reg_info_1; + u32 reg_info_2; +} __packed; + +struct wcn36xx_hal_update_channel_list_req_msg { + struct wcn36xx_hal_msg_header header; + + u8 num_channel; + struct wcn36xx_hal_channel_param channels[80]; +} __packed; + enum wcn36xx_hal_rate_index { HW_RATE_INDEX_1MBPS = 0x82, HW_RATE_INDEX_2MBPS = 0x84, diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index 4f139d9..a42eae6 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -689,6 +689,7 @@ static int wcn36xx_hw_scan(struct ieee80211_hw *hw, mutex_unlock(&wcn->scan_lock); + wcn36xx_smd_update_channel_list(wcn, &hw_req->req); return wcn36xx_smd_start_hw_scan(wcn, vif, &hw_req->req); } diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c index 3cecc8f..608d4cc 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.c +++ b/drivers/net/wireless/ath/wcn36xx/smd.c @@ -928,6 +928,103 @@ int wcn36xx_smd_stop_hw_scan(struct wcn36xx *wcn) return ret; } +static void wcn36xx_channel_set_max_power(struct wcn36xx_hal_channel_param *p, u32 max) +{ + u32 min = WCN36XX_HAL_DEFAULT_MIN_POWER; + + if (min > max) + min = max; + + p->reg_info_1 &= 0xffff0000; + p->reg_info_1 |= (min & 0xff) + ((max & 0xff) << 8); +} + +static void wcn36xx_channel_set_reg_power(struct wcn36xx_hal_channel_param *p, u32 power) +{ + p->reg_info_1 &= 0xff00ffff; + p->reg_info_1 |= (power & 0xff) << 16; +} + +static void wcn36xx_channel_set_class_id(struct wcn36xx_hal_channel_param *p, u32 id) +{ + p->reg_info_1 &= 0x00ffffff; + p->reg_info_1 |= (id & 0xff) << 24; +} + +static void wcn36xx_channel_set_antenna_gain(struct wcn36xx_hal_channel_param *p, u32 gain) +{ + if (!gain) + gain = WCN36XX_HAL_DEFAULT_ANT_GAIN; + + p->reg_info_2 = gain; +} + +int wcn36xx_smd_update_channel_list(struct wcn36xx *wcn, struct cfg80211_scan_request *req) +{ + struct wcn36xx_hal_update_channel_list_req_msg *msg_body; + int ret, i; + + msg_body = kzalloc(sizeof(*msg_body), GFP_KERNEL); + if (!msg_body) + return -ENOMEM; + + INIT_HAL_MSG((*msg_body), WCN36XX_HAL_UPDATE_CHANNEL_LIST_REQ); + + msg_body->num_channel = min_t(u8, req->n_channels, sizeof(msg_body->channels)); + for (i = 0; i < msg_body->num_channel; i++) { + struct wcn36xx_hal_channel_param *param = &msg_body->channels[i]; + + param->mhz = req->channels[i]->center_freq; + param->band_center_freq1 = req->channels[i]->center_freq; + param->band_center_freq2 = 0; + + if (req->channels[i]->flags & IEEE80211_CHAN_NO_IR) + param->channel_info |= WCN36XX_HAL_CHAN_FLAG_PASSIVE; + + if (req->channels[i]->flags & IEEE80211_CHAN_RADAR) + param->channel_info |= WCN36XX_HAL_CHAN_FLAG_DFS; + + if (req->channels[i]->band == NL80211_BAND_5GHZ) { + param->channel_info |= WCN36XX_HAL_CHAN_FLAG_HT; + param->channel_info |= WCN36XX_HAL_CHAN_FLAG_VHT; + param->channel_info |= WCN36XX_HAL_CHAN_PHY_MODE_11A; + } else { + param->channel_info |= WCN36XX_HAL_CHAN_PHY_MODE_11BG; + } + + wcn36xx_channel_set_max_power(param, req->channels[i]->max_power); + wcn36xx_channel_set_reg_power(param, req->channels[i]->max_reg_power); + wcn36xx_channel_set_antenna_gain(param, req->channels[i]->max_antenna_gain); + wcn36xx_channel_set_class_id(param, 0); /* don't care ? */ + + wcn36xx_dbg(WCN36XX_DBG_HAL, + "%s: freq=%u, channel_info=%08x, reg_info1=%08x, reg_info2=%08x\n", + __func__, param->mhz, param->channel_info, param->reg_info_1, + param->reg_info_2); + } + + mutex_lock(&wcn->hal_mutex); + + PREPARE_HAL_BUF(wcn->hal_buf, (*msg_body)); + + ret = wcn36xx_smd_send_and_wait(wcn, msg_body->header.len); + if (ret) { + wcn36xx_err("Sending hal_update_channel_list failed\n"); + goto out; + } + + ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len); + if (ret) { + wcn36xx_err("hal_update_channel_list response failed err=%d\n", ret); + goto out; + } + +out: + kfree(msg_body); + mutex_unlock(&wcn->hal_mutex); + return ret; +} + static int wcn36xx_smd_switch_channel_rsp(void *buf, size_t len) { struct wcn36xx_hal_switch_channel_rsp_msg *rsp; @@ -3138,6 +3235,7 @@ int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev, case WCN36XX_HAL_HOST_RESUME_RSP: case WCN36XX_HAL_ENTER_IMPS_RSP: case WCN36XX_HAL_EXIT_IMPS_RSP: + case WCN36XX_HAL_UPDATE_CHANNEL_LIST_RSP: memcpy(wcn->hal_buf, buf, len); wcn->hal_rsp_len = len; complete(&wcn->hal_rsp_compl); diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h index 5f98c1d..88e045d 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.h +++ b/drivers/net/wireless/ath/wcn36xx/smd.h @@ -70,6 +70,7 @@ int wcn36xx_smd_update_scan_params(struct wcn36xx *wcn, u8 *channels, size_t cha int wcn36xx_smd_start_hw_scan(struct wcn36xx *wcn, struct ieee80211_vif *vif, struct cfg80211_scan_request *req); int wcn36xx_smd_stop_hw_scan(struct wcn36xx *wcn); +int wcn36xx_smd_update_channel_list(struct wcn36xx *wcn, struct cfg80211_scan_request *req); int wcn36xx_smd_add_sta_self(struct wcn36xx *wcn, struct ieee80211_vif *vif); int wcn36xx_smd_delete_sta_self(struct wcn36xx *wcn, u8 *addr); int wcn36xx_smd_delete_sta(struct wcn36xx *wcn, u8 sta_index);