From patchwork Wed Feb 26 20:38:00 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: 3728701 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 775309F2ED for ; Wed, 26 Feb 2014 20:38:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 86EFE201F9 for ; Wed, 26 Feb 2014 20:38:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 32D42201CD for ; Wed, 26 Feb 2014 20:38:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751228AbaBZUiK (ORCPT ); Wed, 26 Feb 2014 15:38:10 -0500 Received: from mail-pd0-f182.google.com ([209.85.192.182]:48101 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750999AbaBZUiI (ORCPT ); Wed, 26 Feb 2014 15:38:08 -0500 Received: by mail-pd0-f182.google.com with SMTP id g10so368779pdj.27 for ; Wed, 26 Feb 2014 12:38:08 -0800 (PST) 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=RjrdRNzal5OzsTtoRRveeuL3dhVyIx/Pzm7miQOL5+k=; b=VAea5ioI+R5p0V+y/gKP+MywWSgi50rXLHgN6f5WmmXm/hFaZDJ4IEAgH0aHQLKaIP WMyT6SeLUFL/b4WLv6N3zAg8WThRYi4PyAqwdlfHWRoBHgypqgnAQwhGToaj98m/vLOu oCUrIKZSpijLQt7jN1UgBqTHRueOn/r25YS5SmdQcAL1NvpA8aN9N65qSzJoSpKItODy fmcTFFbDujuPObthItw/J5SylogdgCQ5XNzfRckNdYGK3dDeS1P9/QnnFNU6HioJJGxg k/UO5gWTNOlUmmSLVZZqwC+UCCRz6N0KihoNJ5D10iSxq3TkJD6ZBI9CCDUd5QlGZ166 ek0Q== X-Received: by 10.66.179.7 with SMTP id dc7mr11088116pac.47.1393447088051; Wed, 26 Feb 2014 12:38:08 -0800 (PST) Received: from mcgrof@gmail.com (c-24-7-61-223.hsd1.ca.comcast.net. [24.7.61.223]) by mx.google.com with ESMTPSA id ac5sm6268639pbc.37.2014.02.26.12.38.03 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 26 Feb 2014 12:38:05 -0800 (PST) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Wed, 26 Feb 2014 12:38:02 -0800 From: "Luis R. Rodriguez" To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH v3] cfg80211: processing regulatory requests on netdev notifier Date: Wed, 26 Feb 2014 12:38:00 -0800 Message-Id: <1393447080-9783-1-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 1.8.5.3 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 This adds a trigger to review any pending regulatory requests whenever an 802.11 device interface is brought down or up. We use this as an opportunistic trigger for checking the regulatory work queues as otherwise they they're only checked upon an initial regulatory request or when beacon hints are found. This opportunistic mechanism can be used to trigger kicking the queues regulatory queues at any time from userspace without having to change the regulatory state. A timer just waiting upon init is not that appropriate as when it should be triggered will depend on systems, a much better approach is to use and add opportunistic triggers. The interface coming up is typically a good indicator that filesystems have been mounted since firmware is required for some devices. Reported-by: Sander Eikelenboom Signed-off-by: Luis R. Rodriguez --- net/wireless/core.c | 2 ++ net/wireless/reg.c | 5 +++++ net/wireless/reg.h | 1 + 3 files changed, 8 insertions(+) diff --git a/net/wireless/core.c b/net/wireless/core.c index 276cf93..7110631 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -812,6 +812,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, SET_NETDEV_DEVTYPE(dev, &wiphy_type); break; case NETDEV_REGISTER: + reg_process_pending_work(); /* * NB: cannot take rdev->mtx here because this may be * called within code protected by it when interfaces @@ -874,6 +875,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, wake_up(&rdev->dev_wait); break; case NETDEV_UP: + reg_process_pending_work(); cfg80211_update_iface_num(rdev, wdev->iftype, 1); wdev_lock(wdev); switch (wdev->iftype) { diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 7203b74..b358856 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -192,6 +192,11 @@ static DECLARE_WORK(reg_work, reg_todo); static void reg_timeout_work(struct work_struct *work); static DECLARE_DELAYED_WORK(reg_timeout, reg_timeout_work); +void reg_process_pending_work(void) +{ + schedule_work(®_work); +} + /* We keep a static world regulatory domain in case of the absence of CRDA */ static const struct ieee80211_regdomain world_regdom = { .n_reg_rules = 6, diff --git a/net/wireless/reg.h b/net/wireless/reg.h index 37c180d..51912b3 100644 --- a/net/wireless/reg.h +++ b/net/wireless/reg.h @@ -37,6 +37,7 @@ unsigned int reg_get_max_bandwidth(const struct ieee80211_regdomain *rd, const struct ieee80211_reg_rule *rule); bool reg_last_request_cell_base(void); +void reg_process_pending_work(void); /** * regulatory_hint_found_beacon - hints a beacon was found on a channel