From patchwork Mon Jul 14 21:19:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 4549581 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A16279F2F4 for ; Mon, 14 Jul 2014 21:20:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE1432013D for ; Mon, 14 Jul 2014 21:20:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BE9920136 for ; Mon, 14 Jul 2014 21:20:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757323AbaGNVUN (ORCPT ); Mon, 14 Jul 2014 17:20:13 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:40349 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756896AbaGNVUM (ORCPT ); Mon, 14 Jul 2014 17:20:12 -0400 Received: by mail-pd0-f169.google.com with SMTP id y10so1525286pdj.28 for ; Mon, 14 Jul 2014 14:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=rBCTu7G/QqAK/KKcFcAcfSp3gSU9V9xsRRbiLvktFRs=; b=aK+aErk5A9t8tdu6FuwaHBq+HeM3U5e+h8MWKjKqzqp5+w1r6JtUWhlOcOHbyvw26j EQxuWSl6Q3Hp/a9Y0p9ZJ7Yn8+yKQLZZS66tnrpW1Aa+t6uVSFqNX3njAujwBJDPVIOq 8CfVKiNeIJhtv/ks2gPqBgr54JHkPdjcetdL7430IjE6I5+mbVes6/KJq9Jxmpwer0+Q KQeD7CZnFh8tYAqWOpnbY98PyaLQkJgNX8mGnEBDsliz1wWXzDC5K+Z/Yer1IWqbbQ2k lg2OCsbzcZ/5VxLiipvcnsJBWM8EFE3EAcsiSvuX7OS9qiYWXDz6bEdGOkhz+u9WsrUA 9P4w== X-Received: by 10.70.100.131 with SMTP id ey3mr18882093pdb.60.1405372811403; Mon, 14 Jul 2014 14:20:11 -0700 (PDT) Received: from mcgrof@gmail.com (c-98-234-145-61.hsd1.ca.comcast.net. [98.234.145.61]) by mx.google.com with ESMTPSA id ce9sm15783825pdb.49.2014.07.14.14.20.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 14 Jul 2014 14:20:04 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Mon, 14 Jul 2014 14:20:01 -0700 From: "Luis R. Rodriguez" To: johannes@sipsolutions.net Cc: linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, john@x109.net, chaitanya.mgit@gmail.com, linville@tuxdriver.com, gregkh@linuxfoundation.org, tiwai@suse.de, keescook@chromium.org, nbd@openwrt.org, "Luis R. Rodriguez" Subject: [PATCH] wireless: fixup genregdb.awk for remove of antenna gain from wireless-regd Date: Mon, 14 Jul 2014 14:19:49 -0700 Message-Id: <1405372789-24733-1-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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: "Luis R. Rodriguez" Since "wireless-regdb: remove antenna gain" was merged in the wireless-regdb tree, the awk script parser has been incompatible with the 'official' regulatory database. This fixes that up. Without this change the max EIRP is set to 0 making 802.11 devices useless. The fragile nature of the awk parser must be replaced, but ideas over how to do that in the most scalable way are being reviewed. In the meantime update the documentation for CFG80211_INTERNAL_REGDB so folks are aware of expectations for now. Reported-by: John Walker Reported-by: Krishna Chaitanya Signed-off-by: Luis R. Rodriguez Acked-by:Krishna Chaitanya --- !!! Note !!! This means older kernels that upgrade wireless-regdb and use CFG80211_INTERNAL_REGDB are bust too and they should then merge the latest updates to the awk script if they want to synch the wireless-regdb files with the kernel builds. The affected Linux distributions would be the users of CFG80211_INTERNAL_REGDB which should consists of OpenWrt which is reported to have this fixed already and mobile platforms. We are looking at a way to not have to deal with parsers all together at build time, for that discussion see: https://lkml.org/lkml/2014/7/14/706 net/wireless/Kconfig | 6 ++++++ net/wireless/genregdb.awk | 35 ++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig index 405f3c4..29c8675 100644 --- a/net/wireless/Kconfig +++ b/net/wireless/Kconfig @@ -162,6 +162,12 @@ config CFG80211_INTERNAL_REGDB and includes code to query that database. This is an alternative to using CRDA for defining regulatory rules for the kernel. + Using this option requires some parsing of the db.txt at build time, + the parser will be upkept with the latest wireless-regdb updates but + older wireless-regdb formats will be ignored. The parser may later + be replaced to avoid issues with conflicts on versions of + wireless-regdb. + For details see: http://wireless.kernel.org/en/developers/Regulatory diff --git a/net/wireless/genregdb.awk b/net/wireless/genregdb.awk index 40c37fc..baf2426 100644 --- a/net/wireless/genregdb.awk +++ b/net/wireless/genregdb.awk @@ -51,32 +51,41 @@ function parse_country_head() { function parse_reg_rule() { + flag_starts_at = 7 + start = $1 sub(/\(/, "", start) end = $3 bw = $5 sub(/\),/, "", bw) - gain = $6 - sub(/\(/, "", gain) - sub(/,/, "", gain) - power = $7 - sub(/\)/, "", power) - sub(/,/, "", power) + gain = 0 + power = $6 # power might be in mW... - units = $8 + units = $7 + dfs_cac = 0 + + sub(/\(/, "", power) + sub(/\),/, "", power) + sub(/\),/, "", units) sub(/\)/, "", units) - sub(/,/, "", units) - dfs_cac = $9 + if (units == "mW") { + flag_starts_at = 8 power = 10 * log(power)/log(10) + if ($8 ~ /[[:digit:]]/) { + flag_starts_at = 9 + dfs_cac = $8 + } } else { - dfs_cac = $8 + if ($7 ~ /[[:digit:]]/) { + flag_starts_at = 8 + dfs_cac = $7 + } } - sub(/,/, "", dfs_cac) sub(/\(/, "", dfs_cac) - sub(/\)/, "", dfs_cac) + sub(/\),/, "", dfs_cac) flagstr = "" - for (i=8; i<=NF; i++) + for (i=flag_starts_at; i<=NF; i++) flagstr = flagstr $i split(flagstr, flagarray, ",") flags = ""