From patchwork Tue Dec 31 09:31:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 3421591 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 78E989F295 for ; Tue, 31 Dec 2013 09:32:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48D2620115 for ; Tue, 31 Dec 2013 09:32:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A263200F0 for ; Tue, 31 Dec 2013 09:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752254Ab3LaJcD (ORCPT ); Tue, 31 Dec 2013 04:32:03 -0500 Received: from mail-bk0-f52.google.com ([209.85.214.52]:36309 "EHLO mail-bk0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752027Ab3LaJb7 (ORCPT ); Tue, 31 Dec 2013 04:31:59 -0500 Received: by mail-bk0-f52.google.com with SMTP id u14so4073454bkz.11 for ; Tue, 31 Dec 2013 01:31:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; bh=xar3tO0PqbS/3FNfeKqbTuvU1whVmSJpiR88EchDzkI=; b=ADlalKfQfcfK/nkoXTdI1ylmelAYV3EchzIAYwL3E4mRxdy6DiDkPlQs16oMB/fT+U zuUjnM3MUNOMtdWmMtDPVPIgqmM7DzYU3rhCQ2tT+FXdXw+b38mSEk1/sVwbxo5c9MA5 QmuGtFevqfoT69oeg67J3QsPVz43+Drk2KRBJvojM+eX8B5rb1vWEL6xwiNCbtYs0naU mFdVtj7O+yrVL1DTfW3TBup7V0zc2WP94VaAidcdnVOtMakktvJGehB8GzPWR8CvdMxF hIGs8Sztk6KWJR3xIJxV6pdUYQ1kg4sKoVfkJJLKinlK5ARR14EDrEXu7umg8MCRo8sp DtdA== X-Received: by 10.204.68.197 with SMTP id w5mr33713bki.179.1388482318068; Tue, 31 Dec 2013 01:31:58 -0800 (PST) Received: from izba.localnet ([2a02:130:501:7:a10e:5ae4:7f51:e2c0]) by mx.google.com with ESMTPSA id bg1sm20836782bkc.4.2013.12.31.01.31.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 31 Dec 2013 01:31:56 -0800 (PST) From: Pali =?utf-8?q?Roh=C3=A1r?= To: Pavel Machek Subject: Re: [PATCH v2 06/16] wl1251: configure hardware en-/decryption for monitor mode Date: Tue, 31 Dec 2013 10:31:49 +0100 User-Agent: KMail/1.13.7 (Linux/3.11.0-15-generic; KDE/4.12.0; x86_64; ; ) Cc: Luciano Coelho , "John W. Linville" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, freemangordon@abv.bg, aaro.koskinen@iki.fi, sre@ring0.de, joni.lapilainen@gmail.com, Johannes Berg , Felipe Contreras , David Gnedt References: <1382819655-30430-1-git-send-email-pali.rohar@gmail.com> <1386494714-21070-7-git-send-email-pali.rohar@gmail.com> <20131210093518.GF22756@amd.pavel.ucw.cz> In-Reply-To: <20131210093518.GF22756@amd.pavel.ucw.cz> MIME-Version: 1.0 Message-Id: <201312311031.53539@pali> 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.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable 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 On Tuesday 10 December 2013 10:35:18 Pavel Machek wrote: > Hi! > > > --- a/drivers/net/wireless/ti/wl1251/tx.c > > +++ b/drivers/net/wireless/ti/wl1251/tx.c > > @@ -287,6 +287,9 @@ static int wl1251_tx_frame(struct wl1251 > > *wl, struct sk_buff *skb) > > > > info = IEEE80211_SKB_CB(skb); > > > > if (info->control.hw_key) { > > > > + if (unlikely(wl->monitor_present)) > > + return -1; > > + > > This function seems to use 0/-errno convention. So probably > "return -EINVAL"? > > With that fixed: > > Reviewed-by: Pavel Machek > > Thanks, > Pavel Here is new version with above fix: From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH v2 06/16] wl1251: configure hardware en-/decryption for monitor mode Date: Sun, 8 Dec 2013 10:25:04 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: David Gnedt Disable hardware encryption (DF_ENCRYPTION_DISABLE) and decryption (DF_SNIFF_MODE_ENABLE) via wl1251_acx_feature_cfg while monitor interface is present. Signed-off-by: David Gnedt Signed-off-by: Pali Rohár --- drivers/net/wireless/ti/wl1251/acx.c | 6 +++--- drivers/net/wireless/ti/wl1251/acx.h | 2 +- drivers/net/wireless/ti/wl1251/init.c | 2 +- drivers/net/wireless/ti/wl1251/main.c | 34 ++++++++++++++++++++++++++----- drivers/net/wireless/ti/wl1251/rx.c | 2 +- drivers/net/wireless/ti/wl1251/tx.c | 3 +++ drivers/net/wireless/ti/wl1251/wl1251.h | 1 + 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/ti/wl1251/acx.c b/drivers/net/wireless/ti/wl1251/acx.c index 5f4a552..1ec98e9 100644 --- a/drivers/net/wireless/ti/wl1251/acx.c +++ b/drivers/net/wireless/ti/wl1251/acx.c @@ -209,7 +209,7 @@ out: return ret; } -int wl1251_acx_feature_cfg(struct wl1251 *wl) +int wl1251_acx_feature_cfg(struct wl1251 *wl, u32 data_flow_options) { struct acx_feature_config *feature; int ret; @@ -222,8 +222,8 @@ int wl1251_acx_feature_cfg(struct wl1251 *wl) goto out; } - /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */ - feature->data_flow_options = 0; + /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE can be set */ + feature->data_flow_options = data_flow_options; feature->options = 0; ret = wl1251_cmd_configure(wl, ACX_FEATURE_CFG, diff --git a/drivers/net/wireless/ti/wl1251/acx.h b/drivers/net/wireless/ti/wl1251/acx.h index 4444cd0..bea2e67 100644 --- a/drivers/net/wireless/ti/wl1251/acx.h +++ b/drivers/net/wireless/ti/wl1251/acx.h @@ -1455,7 +1455,7 @@ int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event, int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth); int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len); int wl1251_acx_tx_power(struct wl1251 *wl, int power); -int wl1251_acx_feature_cfg(struct wl1251 *wl); +int wl1251_acx_feature_cfg(struct wl1251 *wl, u32 data_flow_options); int wl1251_acx_mem_map(struct wl1251 *wl, struct acx_header *mem_map, size_t len); int wl1251_acx_data_path_params(struct wl1251 *wl, diff --git a/drivers/net/wireless/ti/wl1251/init.c b/drivers/net/wireless/ti/wl1251/init.c index 424ce01..92de289 100644 --- a/drivers/net/wireless/ti/wl1251/init.c +++ b/drivers/net/wireless/ti/wl1251/init.c @@ -33,7 +33,7 @@ int wl1251_hw_init_hwenc_config(struct wl1251 *wl) { int ret; - ret = wl1251_acx_feature_cfg(wl); + ret = wl1251_acx_feature_cfg(wl, 0); if (ret < 0) { wl1251_warning("couldn't set feature config"); return ret; diff --git a/drivers/net/wireless/ti/wl1251/main.c b/drivers/net/wireless/ti/wl1251/main.c index 0e27f1f..39a6105 100644 --- a/drivers/net/wireless/ti/wl1251/main.c +++ b/drivers/net/wireless/ti/wl1251/main.c @@ -485,6 +485,7 @@ static void wl1251_op_stop(struct ieee80211_hw *hw) wl->power_level = WL1251_DEFAULT_POWER_LEVEL; wl->rssi_thold = 0; wl->channel = WL1251_DEFAULT_CHANNEL; + wl->monitor_present = false; wl1251_debugfs_reset(wl); @@ -577,8 +578,10 @@ static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed) channel = ieee80211_frequency_to_channel( conf->chandef.chan->center_freq); - wl1251_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d", + wl1251_debug(DEBUG_MAC80211, + "mac80211 config ch %d monitor %s psm %s power %d", channel, + conf->flags & IEEE80211_CONF_MONITOR ? "on" : "off", conf->flags & IEEE80211_CONF_PS ? "on" : "off", conf->power_level); @@ -588,6 +591,22 @@ static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed) if (ret < 0) goto out; + if (changed & IEEE80211_CONF_CHANGE_MONITOR) { + u32 mode; + + if (conf->flags & IEEE80211_CONF_MONITOR) { + wl->monitor_present = true; + mode = DF_SNIFF_MODE_ENABLE | DF_ENCRYPTION_DISABLE; + } else { + wl->monitor_present = false; + mode = 0; + } + + ret = wl1251_acx_feature_cfg(wl, mode); + if (ret < 0) + goto out_sleep; + } + if (channel != wl->channel) { wl->channel = channel; @@ -804,12 +823,12 @@ static int wl1251_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, mutex_lock(&wl->mutex); - ret = wl1251_ps_elp_wakeup(wl); - if (ret < 0) - goto out_unlock; - switch (cmd) { case SET_KEY: + if (wl->monitor_present) { + ret = -EOPNOTSUPP; + goto out_unlock; + } wl_cmd->key_action = KEY_ADD_OR_REPLACE; break; case DISABLE_KEY: @@ -820,6 +839,10 @@ static int wl1251_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, break; } + ret = wl1251_ps_elp_wakeup(wl); + if (ret < 0) + goto out_unlock; + ret = wl1251_set_key_type(wl, wl_cmd, cmd, key, addr); if (ret < 0) { wl1251_error("Set KEY type failed"); @@ -1520,6 +1543,7 @@ struct ieee80211_hw *wl1251_alloc_hw(void) INIT_DELAYED_WORK(&wl->elp_work, wl1251_elp_work); wl->channel = WL1251_DEFAULT_CHANNEL; + wl->monitor_present = false; wl->scanning = false; wl->default_key = 0; wl->listen_int = 1; diff --git a/drivers/net/wireless/ti/wl1251/rx.c b/drivers/net/wireless/ti/wl1251/rx.c index 23289d4..123c4bb 100644 --- a/drivers/net/wireless/ti/wl1251/rx.c +++ b/drivers/net/wireless/ti/wl1251/rx.c @@ -83,7 +83,7 @@ static void wl1251_rx_status(struct wl1251 *wl, status->flag |= RX_FLAG_MACTIME_START; - if (desc->flags & RX_DESC_ENCRYPTION_MASK) { + if (!wl->monitor_present && (desc->flags & RX_DESC_ENCRYPTION_MASK)) { status->flag |= RX_FLAG_IV_STRIPPED | RX_FLAG_MMIC_STRIPPED; if (likely(!(desc->flags & RX_DESC_DECRYPT_FAIL))) diff --git a/drivers/net/wireless/ti/wl1251/tx.c b/drivers/net/wireless/ti/wl1251/tx.c index 28121c5..3cc82fd 100644 --- a/drivers/net/wireless/ti/wl1251/tx.c +++ b/drivers/net/wireless/ti/wl1251/tx.c @@ -287,6 +287,9 @@ static int wl1251_tx_frame(struct wl1251 *wl, struct sk_buff *skb) info = IEEE80211_SKB_CB(skb); if (info->control.hw_key) { + if (unlikely(wl->monitor_present)) + return -EINVAL; + idx = info->control.hw_key->hw_key_idx; if (unlikely(wl->default_key != idx)) { ret = wl1251_acx_default_key(wl, idx); diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h index de9e418..45df03a 100644 --- a/drivers/net/wireless/ti/wl1251/wl1251.h +++ b/drivers/net/wireless/ti/wl1251/wl1251.h @@ -309,6 +309,7 @@ struct wl1251 { u8 bss_type; u8 listen_int; int channel; + bool monitor_present; void *target_mem_map; struct acx_data_path_params_resp *data_path;