netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Luciano Coelho <luca@coelho.fi>,
	"John W. Linville" <linville@tuxdriver.com>,
	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 <johannes@sipsolutions.net>,
	Felipe Contreras <felipe.contreras@gmail.com>,
	David Gnedt <david.gnedt@davizone.at>
Subject: Re: [PATCH v2 06/16] wl1251: configure hardware en-/decryption for monitor mode
Date: Tue, 31 Dec 2013 10:31:49 +0100	[thread overview]
Message-ID: <201312311031.53539@pali> (raw)
In-Reply-To: <20131210093518.GF22756@amd.pavel.ucw.cz>

[-- Attachment #1: Type: Text/Plain, Size: 7848 bytes --]

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 <pavel@ucw.cz>
> 
> Thanks,
> 									Pavel

Here is new version with above fix:

From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
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 <david.gnedt@davizone.at>

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 <david.gnedt@davizone.at>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 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;
-- 
1.7.9.5

-- 
Pali Rohár
pali.rohar@gmail.com


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2013-12-31  9:31 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-26 20:33 [PATCH 00/16] wl1251 patches from linux-n900 tree Pali Rohár
2013-10-26 20:34 ` [PATCH 01/16] mac80211: fix TX device statistics for monitor interfaces Pali Rohár
2013-10-28  5:53   ` Kalle Valo
     [not found]     ` <87iowiszyu.fsf-5ukZ45wKbUHoml4zekdYB16hYfS7NtTn@public.gmane.org>
2013-12-08  8:45       ` [PATCH] " Pali Rohár
     [not found]         ` <1386492357-20826-1-git-send-email-pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-12-16 12:38           ` Johannes Berg
2013-10-28 13:47   ` [PATCH 01/16] " Johannes Berg
2013-10-26 20:34 ` [PATCH 02/16] wl1251: fix scan behaviour while not associated Pali Rohár
2013-10-30 11:24   ` Pavel Machek
     [not found] ` <1382819655-30430-1-git-send-email-pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-26 20:34   ` [PATCH 03/16] wl1251: add sysfs interface for bluetooth coexistence mode configuration Pali Rohár
2013-10-28 23:39     ` Ben Hutchings
2013-10-29  7:09       ` Luca Coelho
2013-10-29 13:35         ` Kalle Valo
     [not found]       ` <1383003587.3779.49.camel-/LGg1Z1CJKQ+9kgCwbf1HqK4ta4zdZpAajtMo4Cw6ucAvxtiuMwx3w@public.gmane.org>
2013-12-08  7:55         ` Pali Rohár
2013-12-08 16:36           ` Ben Hutchings
2013-10-26 20:34   ` [PATCH 07/16] wl1251: configure hardware en-/decryption for monitor mode Pali Rohár
2013-10-30 11:35     ` Pavel Machek
2013-10-26 20:34   ` [PATCH 13/16] wl1251: enforce changed hw encryption support on monitor state change Pali Rohár
2013-10-30 11:55     ` Pavel Machek
2013-11-08 14:20   ` [PATCH 00/16] wl1251 patches from linux-n900 tree Felipe Contreras
2013-11-25 19:54     ` Pali Rohár
2013-10-26 20:34 ` [PATCH 04/16] wl1251: retry power save entry Pali Rohár
2013-10-26 20:34 ` [PATCH 05/16] wl1251: implement hardware ARP filtering Pali Rohár
2013-10-30 11:28   ` Pavel Machek
2013-10-26 20:34 ` [PATCH 06/16] wl1251: split RX and TX data path initialisation Pali Rohár
2013-10-30 11:31   ` Pavel Machek
2013-10-26 20:34 ` [PATCH 08/16] wl1251: implement multicast address filtering Pali Rohár
2013-10-30 11:41   ` Pavel Machek
2013-10-26 20:34 ` [PATCH 09/16] wl1251: disable power saving in monitor mode Pali Rohár
2013-10-30 11:46   ` Pavel Machek
2013-10-26 20:34 ` [PATCH 10/16] wl1251: fix channel switching " Pali Rohár
2013-10-30 11:47   ` Pavel Machek
2013-10-26 20:34 ` [PATCH 11/16] wl1251: enable tx path in monitor mode if necessary for packet injection Pali Rohár
2013-10-30 11:51   ` Pavel Machek
2013-10-26 20:34 ` [PATCH 12/16] wl1251: disable retry and ACK policy for injected packets Pali Rohár
2013-10-30 11:52   ` Pavel Machek
2013-10-26 20:34 ` [PATCH 14/16] wl1251: add nvs file name to module firmware list Pali Rohár
2013-10-30 11:55   ` Pavel Machek
2013-10-26 20:34 ` [PATCH 15/16] wl1251: Add sysfs file tx_mgmt_frm_rate for setting rate Pali Rohár
2013-10-28 13:45   ` Johannes Berg
2013-10-26 20:34 ` [PATCH 16/16] wl1251: Add sysfs file address for setting permanent mac address Pali Rohár
2013-10-28 13:45   ` Johannes Berg
2013-10-28 13:49     ` Pali Rohár
2013-10-28 13:55       ` Johannes Berg
2013-10-28 14:00         ` Pali Rohár
2013-10-28 14:46           ` Dan Williams
2013-10-28 14:56             ` Johannes Berg
2013-10-28 15:04               ` Pali Rohár
2013-10-28 15:29                 ` Dan Williams
2013-10-28 16:21                   ` Pali Rohár
2013-10-28 15:33               ` Stephen Hemminger
2013-10-28 23:50   ` Ben Hutchings
2013-12-08  9:24 ` [PATCH v2 00/16] wl1251 patches from linux-n900 tree Pali Rohár
2013-12-08  9:24   ` [PATCH v2 01/16] wl1251: fix scan behaviour while not associated Pali Rohár
     [not found]     ` <1386494714-21070-2-git-send-email-pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-12-10  9:21       ` Pavel Machek
     [not found]         ` <20131210092114.GB22756-tWAi6jLit6GreWDznjuHag@public.gmane.org>
2013-12-10 15:41           ` Kalle Valo
2013-12-10 17:08             ` Pali Rohár
2013-12-11 20:44               ` Ben Hutchings
2013-12-31  9:44           ` Pali Rohár
2013-12-08  9:25   ` [PATCH v2 03/16] wl1251: retry power save entry Pali Rohár
2013-12-10  9:24     ` Pavel Machek
     [not found]   ` <1386494714-21070-1-git-send-email-pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-12-08  9:25     ` [PATCH v2 02/16] wl1251: add sysfs interface for bluetooth coexistence mode configuration Pali Rohár
     [not found]       ` <1386494714-21070-3-git-send-email-pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-12-10 15:46         ` Kalle Valo
2013-12-10 16:09           ` Pali Rohár
2013-12-08  9:25     ` [PATCH v2 04/16] wl1251: implement hardware ARP filtering Pali Rohár
2013-12-10  9:29       ` Pavel Machek
2013-12-10  9:59         ` Michal Kubecek
2013-12-08  9:25     ` [PATCH v2 05/16] wl1251: split RX and TX data path initialisation Pali Rohár
2013-12-10  9:31       ` Pavel Machek
2013-12-08  9:25     ` [PATCH v2 06/16] wl1251: configure hardware en-/decryption for monitor mode Pali Rohár
2013-12-10  9:35       ` Pavel Machek
2013-12-31  9:31         ` Pali Rohár [this message]
2013-12-08  9:25     ` [PATCH v2 16/16] wl1251: fix NULL pointer dereference Pali Rohár
2013-12-10  9:42       ` Pavel Machek
2013-12-08  9:25   ` [PATCH v2 07/16] wl1251: implement multicast address filtering Pali Rohár
2013-12-10  9:39     ` Pavel Machek
2013-12-08  9:25   ` [PATCH v2 08/16] wl1251: disable power saving in monitor mode Pali Rohár
     [not found]     ` <1386494714-21070-9-git-send-email-pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-12-10  9:41       ` Pavel Machek
2013-12-08  9:25   ` [PATCH v2 09/16] wl1251: fix channel switching " Pali Rohár
2013-12-10  9:43     ` Pavel Machek
2013-12-08  9:25   ` [PATCH v2 10/16] wl1251: enable tx path in monitor mode if necessary for packet injection Pali Rohár
2013-12-10  9:44     ` Pavel Machek
2013-12-08  9:25   ` [PATCH v2 11/16] wl1251: disable retry and ACK policy for injected packets Pali Rohár
2013-12-10  9:46     ` Pavel Machek
2013-12-08  9:25   ` [PATCH v2 12/16] wl1251: enforce changed hw encryption support on monitor state change Pali Rohár
2013-12-10  9:48     ` Pavel Machek
2013-12-08  9:25   ` [PATCH v2 13/16] wl1251: add nvs file name to module firmware list Pali Rohár
2013-12-10  9:49     ` Pavel Machek
2013-12-08  9:25   ` [PATCH v2 14/16] wl1251: Add sysfs file tx_mgmt_frm_rate for setting rate Pali Rohár
2013-12-09 16:50     ` Dan Williams
     [not found]     ` <1386494714-21070-15-git-send-email-pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-12-10 15:36       ` Kalle Valo
2013-12-08  9:25   ` [PATCH v2 15/16] wl1251: Add sysfs file address for setting permanent mac address Pali Rohár
2013-12-10 15:49     ` Kalle Valo
2013-12-10 16:10       ` Pali Rohár
2013-12-10 17:14         ` Pali Rohár
2013-12-10 17:49           ` Dan Williams
     [not found]             ` <1386697762.30202.6.camel-wKZy7rqYPVb5EHUCmHmTqw@public.gmane.org>
2013-12-10 17:52               ` Pali Rohár
2013-12-10 19:22                 ` Dan Williams
2013-12-10 19:31                   ` Pali Rohár
2013-12-11 21:26                     ` Ben Hutchings
2013-12-11 21:17                 ` Ben Hutchings
2013-12-11 21:28                   ` Ben Hutchings
2013-12-11 21:35                   ` Ivajlo Dimitrov
2013-12-11 22:15                     ` Ben Hutchings
2013-12-11 22:36                       ` Ivajlo Dimitrov
2013-12-12 12:45                         ` Sergei Shtylyov
     [not found]                       ` <1386800135.1516.296.camel-/LGg1Z1CJKQ+9kgCwbf1HqK4ta4zdZpAajtMo4Cw6ucAvxtiuMwx3w@public.gmane.org>
2013-12-11 22:53                         ` Dan Williams
     [not found]                           ` <1386802416.17188.69.camel-wKZy7rqYPVb5EHUCmHmTqw@public.gmane.org>
2013-12-12 19:55                             ` Ben Hutchings
2013-12-12 20:24                               ` Ivajlo Dimitrov
2013-12-12 10:56                   ` Pavel Machek
2013-12-31  9:47   ` [PATCH v2 00/16] wl1251 patches from linux-n900 tree Pali Rohár
2014-01-06 20:00     ` John W. Linville
2014-01-06 20:26       ` Johannes Berg
2014-01-06 22:03       ` Pavel Machek
2014-01-07 12:15       ` Pavel Machek
2014-01-16  0:21       ` Pavel Machek
     [not found]         ` <20140116002121.GA3726-tWAi6jLit6GreWDznjuHag@public.gmane.org>
2014-01-16 20:29           ` John W. Linville

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201312311031.53539@pali \
    --to=pali.rohar@gmail.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=david.gnedt@davizone.at \
    --cc=felipe.contreras@gmail.com \
    --cc=freemangordon@abv.bg \
    --cc=johannes@sipsolutions.net \
    --cc=joni.lapilainen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=luca@coelho.fi \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=sre@ring0.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).