[PATCH] iw: print 4ADDR attribute when dumping interface

2019-03-23 Thread Antonio Quartulli
Print the value of the 4ADDR attribute when dumping the interface
status.

Signed-off-by: Antonio Quartulli 
---

This patch was sleeping in my local repo for a while .. maybe it is useful to
other people too.

Cheers,

 interface.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/interface.c b/interface.c
index 712bbdc..678955d 100644
--- a/interface.c
+++ b/interface.c
@@ -447,6 +447,11 @@ static int print_iface_handler(struct nl_msg *msg, void 
*arg)
printf("%s\tmulticast TXQ:%s\n", indent, buf);
}
 
+   if (tb_msg[NL80211_ATTR_4ADDR]) {
+   uint8_t use_4addr = nla_get_u8(tb_msg[NL80211_ATTR_4ADDR]);
+   printf("%s\t4addr: %d\n", indent, use_4addr);
+   }
+
return NL_SKIP;
 }
 
-- 
2.21.0



[PATCH 2/2] mac80211: passively scan DFS channels if requested

2015-11-13 Thread Antonio Quartulli
if the NL80211_SCAN_FLAG_PASSIVE_RADAR flag was specified upon
sw scan start, passively scan any channel marked as DFS.

Signed-off-by: Antonio Quartulli 
---
 net/mac80211/scan.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 4aeca4b..d8f7b4a 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -599,7 +599,9 @@ static int __ieee80211_start_scan(struct 
ieee80211_sub_if_data *sdata,
 
if ((req->channels[0]->flags &
 IEEE80211_CHAN_NO_IR) ||
-   !req->n_ssids) {
+   !req->n_ssids ||
+   ((chan->flags & IEEE80211_CHAN_RADAR) &&
+(scan_req->flags & NL80211_SCAN_FLAG_PASSIVE_RADAR))) {
next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
} else {
ieee80211_scan_state_send_probe(local, &next_delay);
@@ -645,7 +647,9 @@ ieee80211_scan_get_channel_time(struct ieee80211_channel 
*chan)
 * TODO: channel switching also consumes quite some time,
 * add that delay as well to get a better estimation
 */
-   if (chan->flags & IEEE80211_CHAN_NO_IR)
+   if ((chan->flags & IEEE80211_CHAN_NO_IR) ||
+   ((chan->flags & IEEE80211_CHAN_RADAR) &&
+(scan_req->flags & NL80211_SCAN_FLAG_PASSIVE_RADAR)))
return IEEE80211_PASSIVE_CHANNEL_TIME;
return IEEE80211_PROBE_DELAY + IEEE80211_CHANNEL_TIME;
 }
@@ -777,7 +781,9 @@ static void ieee80211_scan_state_set_channel(struct 
ieee80211_local *local,
 *
 * In any case, it is not necessary for a passive scan.
 */
-   if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids) {
+   if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids ||
+   ((chan->flags & IEEE80211_CHAN_RADAR) &&
+(scan_req->flags & NL80211_SCAN_FLAG_PASSIVE_RADAR))) {
*next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
local->next_scan_state = SCAN_DECISION;
return;
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] nl80211: add flag to force passive scan on DFS channels

2015-11-13 Thread Antonio Quartulli
In certain circumstances the user might not want to actively
scan DFS channels, therefore add a nl80211 scan flag to
instruct the underlying layers that DFS channels must be
passively scanned.

This flag can be specified upon scan trigger command.

Signed-off-by: Antonio Quartulli 
---
 include/uapi/linux/nl80211.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 1f0b4cf..2083e53 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4456,12 +4456,14 @@ enum nl80211_connect_failed_reason {
  * locally administered 1, multicast 0) is assumed.
  * This flag must not be requested when the feature isn't supported, check
  * the nl80211 feature flags for the device.
+ * @NL80211_SCAN_FLAG_PASSIVE_RADAR: force passive scan on DFS channels
  */
 enum nl80211_scan_flags {
NL80211_SCAN_FLAG_LOW_PRIORITY  = 1<<0,
NL80211_SCAN_FLAG_FLUSH = 1<<1,
NL80211_SCAN_FLAG_AP= 1<<2,
NL80211_SCAN_FLAG_RANDOM_ADDR   = 1<<3,
+   NL80211_SCAN_FLAG_PASSIVE_RADAR = 1<<4,
 };
 
 /**
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] nl80211: add flag to force passive scan on DFS channels

2015-11-13 Thread Antonio Quartulli
In certain circumstances the user might not want to actively
scan DFS channels, therefore add a nl80211 scan flag to
instruct the underlying layers that DFS channels must be
passively scanned.

This flag can be specified upon scan trigger command.

Signed-off-by: Antonio Quartulli 
---

v2: no change

 include/uapi/linux/nl80211.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 1f0b4cf..2083e53 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4456,12 +4456,14 @@ enum nl80211_connect_failed_reason {
  * locally administered 1, multicast 0) is assumed.
  * This flag must not be requested when the feature isn't supported, check
  * the nl80211 feature flags for the device.
+ * @NL80211_SCAN_FLAG_PASSIVE_RADAR: force passive scan on DFS channels
  */
 enum nl80211_scan_flags {
NL80211_SCAN_FLAG_LOW_PRIORITY  = 1<<0,
NL80211_SCAN_FLAG_FLUSH = 1<<1,
NL80211_SCAN_FLAG_AP= 1<<2,
NL80211_SCAN_FLAG_RANDOM_ADDR   = 1<<3,
+   NL80211_SCAN_FLAG_PASSIVE_RADAR = 1<<4,
 };
 
 /**
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] mac80211: passively scan DFS channels if requested

2015-11-13 Thread Antonio Quartulli
if the NL80211_SCAN_FLAG_PASSIVE_RADAR flag was specified upon
sw scan start, passively scan any channel marked as DFS.

Signed-off-by: Antonio Quartulli 
---

v2: fix variable names and add scan_req argument to
ieee80211_scan_get_channel_time()

 net/mac80211/scan.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 4aeca4b..e369d61 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -599,7 +599,9 @@ static int __ieee80211_start_scan(struct 
ieee80211_sub_if_data *sdata,
 
if ((req->channels[0]->flags &
 IEEE80211_CHAN_NO_IR) ||
-   !req->n_ssids) {
+   !req->n_ssids ||
+   ((req->channels[0]->flags & IEEE80211_CHAN_RADAR) &&
+(req->flags & NL80211_SCAN_FLAG_PASSIVE_RADAR))) {
next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
} else {
ieee80211_scan_state_send_probe(local, &next_delay);
@@ -639,13 +641,16 @@ static int __ieee80211_start_scan(struct 
ieee80211_sub_if_data *sdata,
 }
 
 static unsigned long
-ieee80211_scan_get_channel_time(struct ieee80211_channel *chan)
+ieee80211_scan_get_channel_time(struct ieee80211_channel *chan,
+   struct cfg80211_scan_request *scan_req)
 {
/*
 * TODO: channel switching also consumes quite some time,
 * add that delay as well to get a better estimation
 */
-   if (chan->flags & IEEE80211_CHAN_NO_IR)
+   if ((chan->flags & IEEE80211_CHAN_NO_IR) ||
+   ((chan->flags & IEEE80211_CHAN_RADAR) &&
+(scan_req->flags & NL80211_SCAN_FLAG_PASSIVE_RADAR)))
return IEEE80211_PASSIVE_CHANNEL_TIME;
return IEEE80211_PROBE_DELAY + IEEE80211_CHANNEL_TIME;
 }
@@ -698,7 +703,8 @@ static void ieee80211_scan_state_decision(struct 
ieee80211_local *local,
 */
 
bad_latency = time_after(jiffies +
-ieee80211_scan_get_channel_time(next_chan),
+ieee80211_scan_get_channel_time(next_chan,
+scan_req),
 local->leave_oper_channel_time + HZ / 8);
 
if (associated && !tx_empty) {
@@ -777,7 +783,9 @@ static void ieee80211_scan_state_set_channel(struct 
ieee80211_local *local,
 *
 * In any case, it is not necessary for a passive scan.
 */
-   if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids) {
+   if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids ||
+   ((chan->flags & IEEE80211_CHAN_RADAR) &&
+(scan_req->flags & NL80211_SCAN_FLAG_PASSIVE_RADAR))) {
*next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
local->next_scan_state = SCAN_DECISION;
return;
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/2] mac80211: passively scan DFS channels if requested

2015-11-20 Thread Antonio Quartulli
On 20/11/15 18:49, Johannes Berg wrote:
> 
>> @@ -599,7 +599,9 @@ static int __ieee80211_start_scan(struct
>> ieee80211_sub_if_data *sdata,
>>  
>>  if ((req->channels[0]->flags &
>>   IEEE80211_CHAN_NO_IR) ||
>> -!req->n_ssids) {
>> +!req->n_ssids ||
>> +((req->channels[0]->flags &
>> IEEE80211_CHAN_RADAR) &&
>> + (req->flags &
>> NL80211_SCAN_FLAG_PASSIVE_RADAR))) {
>>  next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
>>
> 
> I don't really see any circumstances under which it's valid to actively
> scan radar channels ... seems like we should do this unconditionally?

I think it would be reasonable only if the target channel is the one we
are using and we have done CSA. But when scanning non-operative channels
I don't think this could work.

As discussed on IRC I'd rather go for passively scanning any DFS channel.

Cheers,


-- 
Antonio Quartulli



signature.asc
Description: OpenPGP digital signature


[PATCH] mac80211: do not actively scan DFS channels

2015-11-21 Thread Antonio Quartulli
DFS channels should not be actively scanned as we can't be sure
if we are allowed or not.

If the current channel is in the DFS band, active scan might be
performed after CSA, but we have no guarantee about other channels,
therefore it is safer to prevent active scanning at all.

Signed-off-by: Antonio Quartulli 
---

this patch was: "mac80211: passively scan DFS channels if requested" and has
been changed after discussing with Johannes.


 net/mac80211/scan.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 4aeca4b..46a5da0 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -599,7 +599,8 @@ static int __ieee80211_start_scan(struct 
ieee80211_sub_if_data *sdata,
 
if ((req->channels[0]->flags &
 IEEE80211_CHAN_NO_IR) ||
-   !req->n_ssids) {
+   !req->n_ssids ||
+   (req->channels[0]->flags & IEEE80211_CHAN_RADAR)) {
next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
} else {
ieee80211_scan_state_send_probe(local, &next_delay);
@@ -639,13 +640,15 @@ static int __ieee80211_start_scan(struct 
ieee80211_sub_if_data *sdata,
 }
 
 static unsigned long
-ieee80211_scan_get_channel_time(struct ieee80211_channel *chan)
+ieee80211_scan_get_channel_time(struct ieee80211_channel *chan,
+   struct cfg80211_scan_request *scan_req)
 {
/*
 * TODO: channel switching also consumes quite some time,
 * add that delay as well to get a better estimation
 */
-   if (chan->flags & IEEE80211_CHAN_NO_IR)
+   if ((chan->flags & IEEE80211_CHAN_NO_IR) ||
+   (chan->flags & IEEE80211_CHAN_RADAR))
return IEEE80211_PASSIVE_CHANNEL_TIME;
return IEEE80211_PROBE_DELAY + IEEE80211_CHANNEL_TIME;
 }
@@ -698,7 +701,8 @@ static void ieee80211_scan_state_decision(struct 
ieee80211_local *local,
 */
 
bad_latency = time_after(jiffies +
-ieee80211_scan_get_channel_time(next_chan),
+ieee80211_scan_get_channel_time(next_chan,
+scan_req),
 local->leave_oper_channel_time + HZ / 8);
 
if (associated && !tx_empty) {
@@ -777,7 +781,8 @@ static void ieee80211_scan_state_set_channel(struct 
ieee80211_local *local,
 *
 * In any case, it is not necessary for a passive scan.
 */
-   if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids) {
+   if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids ||
+   (chan->flags & IEEE80211_CHAN_RADAR)) {
*next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
local->next_scan_state = SCAN_DECISION;
return;
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] mac80211: do not actively scan DFS channels

2015-11-21 Thread Antonio Quartulli
DFS channels should not be actively scanned as we can't be sure
if we are allowed or not.

If the current channel is in the DFS band, active scan might be
performed after CSA, but we have no guarantee about other channels,
therefore it is safer to prevent active scanning at all.

Signed-off-by: Antonio Quartulli 
---

v2: remove unused scan_req argument in ieee80211_scan_get_channel_time()

 net/mac80211/scan.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 4aeca4b..ce01f74 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -599,7 +599,8 @@ static int __ieee80211_start_scan(struct 
ieee80211_sub_if_data *sdata,
 
if ((req->channels[0]->flags &
 IEEE80211_CHAN_NO_IR) ||
-   !req->n_ssids) {
+   !req->n_ssids ||
+   (req->channels[0]->flags & IEEE80211_CHAN_RADAR)) {
next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
} else {
ieee80211_scan_state_send_probe(local, &next_delay);
@@ -645,7 +646,8 @@ ieee80211_scan_get_channel_time(struct ieee80211_channel 
*chan)
 * TODO: channel switching also consumes quite some time,
 * add that delay as well to get a better estimation
 */
-   if (chan->flags & IEEE80211_CHAN_NO_IR)
+   if ((chan->flags & IEEE80211_CHAN_NO_IR) ||
+   (chan->flags & IEEE80211_CHAN_RADAR))
return IEEE80211_PASSIVE_CHANNEL_TIME;
return IEEE80211_PROBE_DELAY + IEEE80211_CHANNEL_TIME;
 }
@@ -698,7 +700,8 @@ static void ieee80211_scan_state_decision(struct 
ieee80211_local *local,
 */
 
bad_latency = time_after(jiffies +
-ieee80211_scan_get_channel_time(next_chan),
+ieee80211_scan_get_channel_time(next_chan,
+scan_req),
 local->leave_oper_channel_time + HZ / 8);
 
if (associated && !tx_empty) {
@@ -777,7 +780,8 @@ static void ieee80211_scan_state_set_channel(struct 
ieee80211_local *local,
 *
 * In any case, it is not necessary for a passive scan.
 */
-   if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids) {
+   if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids ||
+   (chan->flags & IEEE80211_CHAN_RADAR)) {
*next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
local->next_scan_state = SCAN_DECISION;
return;
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] mac80211: do not actively scan DFS channels

2015-11-21 Thread Antonio Quartulli
DFS channels should not be actively scanned as we can't be sure
if we are allowed or not.

If the current channel is in the DFS band, active scan might be
performed after CSA, but we have no guarantee about other channels,
therefore it is safer to prevent active scanning at all.

Signed-off-by: Antonio Quartulli 
---

v3: remove scan_req argument in ieee80211_scan_get_channel_time() invocation

 net/mac80211/scan.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 4aeca4b..7e66e20 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -599,7 +599,8 @@ static int __ieee80211_start_scan(struct 
ieee80211_sub_if_data *sdata,
 
if ((req->channels[0]->flags &
 IEEE80211_CHAN_NO_IR) ||
-   !req->n_ssids) {
+   !req->n_ssids ||
+   (req->channels[0]->flags & IEEE80211_CHAN_RADAR)) {
next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
} else {
ieee80211_scan_state_send_probe(local, &next_delay);
@@ -645,7 +646,8 @@ ieee80211_scan_get_channel_time(struct ieee80211_channel 
*chan)
 * TODO: channel switching also consumes quite some time,
 * add that delay as well to get a better estimation
 */
-   if (chan->flags & IEEE80211_CHAN_NO_IR)
+   if ((chan->flags & IEEE80211_CHAN_NO_IR) ||
+   (chan->flags & IEEE80211_CHAN_RADAR))
return IEEE80211_PASSIVE_CHANNEL_TIME;
return IEEE80211_PROBE_DELAY + IEEE80211_CHANNEL_TIME;
 }
@@ -777,7 +779,8 @@ static void ieee80211_scan_state_set_channel(struct 
ieee80211_local *local,
 *
 * In any case, it is not necessary for a passive scan.
 */
-   if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids) {
+   if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids ||
+   (chan->flags & IEEE80211_CHAN_RADAR)) {
*next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
local->next_scan_state = SCAN_DECISION;
return;
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: minstrel: Scale expected_throughput by 10

2016-02-01 Thread Antonio Quartulli
On Mon, Feb 01, 2016 at 01:57:53PM +0100, Johannes Berg wrote:
> On Mon, 2016-02-01 at 13:56 +0100, Sven Eckelmann wrote:
> > On Monday 01 February 2016 13:30:37 Johannes Berg wrote:
> > > On Mon, 2016-02-01 at 13:24 +0100, Sven Eckelmann wrote:
> > > > The change from cur_tp to the function
> > > > minstrel_get_tp_avg/minstrel_ht_get_tp_avg changed the unit used
> > > > for
> > > > the
> > > > current throughtput. For example in minstrel_ht the correct
> > > > conversion between them would be:
> > > > 
> > > > mrs->cur_tp / 10 == minstrel_ht_get_tp_avg(..).
> > > > 
> > > > This factor 10 must also be included in the calculation of
> > > > minstrel_get_expected_throughput and
> > > > minstrel_ht_get_expected_throughput to
> > > > get similar results as before the change.
> > > > 
> > > 
> > > 10 is a pretty expensive factor, perhaps that should use 16
> > > instead?
> > 
> > Not really funny but I will change the title.
> 
> Huh? Not sure what you mean. I really meant to change 10 to 16 overall
> as far as the factor is concerned, since division by/multiplication
> with 16 is far easier in base 2 than by/with 10.

Should we first fix the bug introduced by 6a27b2c40b48 and then (with another
patch) improve this by changing the factor from 10 to 16 ?
The latter is going to be a bigger change because we need to make sure that the
value exported via station_info gets still scaled to kbps.

Cheers,


-- 
Antonio Quartulli
Director of Embedded Software | Open Mesh, Inc.


signature.asc
Description: Digital signature


[NOT FOR MERGE] ath9k: work around key cache corruption

2016-10-18 Thread Antonio Quartulli
From: Antonio Quartulli 

This patch was crafted long time ago to work around a key cache
corruption problem on ath9k chipsets.

The workaround consists in periodically triggering a worker that
uploads all the keys to the HW cache. The worker is triggered also
when the vif detects 21 undecryptable packets.


This patch is based on top compat-wireless-2015-10-26.


I was asked to release this code to the public and, since it is
GPL, I am now doing it.


Signed-off-by: Antonio Quartulli 

---
 drivers/net/wireless/ath/ath.h |  11 +++
 drivers/net/wireless/ath/ath9k/ath9k.h |   7 ++
 drivers/net/wireless/ath/ath9k/init.c  |   1 +
 drivers/net/wireless/ath/ath9k/main.c  |  21 +
 drivers/net/wireless/ath/ath9k/recv.c  |  25 ++
 drivers/net/wireless/ath/key.c | 149 +
 include/net/mac80211.h |   4 +
 net/mac80211/key.c |  22 ++---
 net/mac80211/key.h |   1 +
 net/mac80211/sta_info.c|  13 +++
 10 files changed, 243 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index 91eeca5..85377bc 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -187,6 +187,13 @@ struct ath_common {
 
int last_rssi;
struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
+
+   struct {
+   struct mutex mtx;
+   atomic_t running;
+   void (*refresh_cb)(struct ieee80211_sta *sta);
+   struct work_struct refresh_work;
+   } key_cache;
 };
 
 static inline const struct ath_ps_ops *ath_ps_ops(struct ath_common *common)
@@ -201,10 +208,14 @@ bool ath_is_mybeacon(struct ath_common *common, struct 
ieee80211_hdr *hdr);
 
 void ath_hw_setbssidmask(struct ath_common *common);
 void ath_key_delete(struct ath_common *common, struct ieee80211_key_conf *key);
+void ath_keys_config(struct ath_common *common);
 int ath_key_config(struct ath_common *common,
  struct ieee80211_vif *vif,
  struct ieee80211_sta *sta,
  struct ieee80211_key_conf *key);
+void ath_key_refresher_init(struct ath_common *common,
+   void (*cb)(struct ieee80211_sta *sta));
+void ath_key_refresher_start(struct ath_common *common);
 bool ath_hw_keyreset(struct ath_common *common, u16 entry);
 void ath_hw_cycle_counters_update(struct ath_common *common);
 int32_t ath_hw_get_listen_time(struct ath_common *common);
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index 0aab323..3930962 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "common.h"
 #include "debug.h"
@@ -38,6 +40,8 @@ extern int ath9k_led_blink;
 extern bool is_ath9k_unloaded;
 extern int ath9k_use_chanctx;
 
+#define ATH_RX_DEC_MAX_ERR 20
+
 /*/
 /* Descriptor Management */
 /*/
@@ -266,6 +270,8 @@ struct ath_node {
 #endif
u8 key_idx[4];
 
+   atomic_t decrypt_errors;
+
u32 ackto;
struct list_head list;
 };
@@ -584,6 +590,7 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
   u16 tids, int nframes,
   enum ieee80211_frame_release_type reason,
   bool more_data);
+void ath9k_refresh_iter(struct ieee80211_sta *sta);
 
 //
 /* VIFs */
diff --git a/drivers/net/wireless/ath/ath9k/init.c 
b/drivers/net/wireless/ath/ath9k/init.c
index 1b57d12..adec135 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -612,6 +612,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
common->bt_ant_diversity = 1;
 
spin_lock_init(&common->cc_lock);
+   ath_key_refresher_init(common, ath9k_refresh_iter);
spin_lock_init(&sc->sc_serial_rw);
spin_lock_init(&sc->sc_pm_lock);
spin_lock_init(&sc->chan_lock);
diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index 56520ac..8ddb0e0 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -16,6 +16,7 @@
 
 #include 
 #include 
+#include 
 #include "ath9k.h"
 #include "btcoex.h"
 
@@ -1690,6 +1691,9 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
if (sta)
an = (struct ath_node *)sta->drv_priv;
 
+   if (sta)
+   an = (struct ath_node *)sta->drv_priv;
+
switch (cmd) {
case SET_KEY:
if (sta)
@@ -1717,6 +1721,14 @@ static int ath9k_set_key(struct ieee80211_hw *hw,

Re: [NOT FOR MERGE] ath9k: work around key cache corruption

2016-10-22 Thread Antonio Quartulli
Hello,

I am trying to understand what's required by this patch to be merged upstream.
Sven Eckelmann commented in another email by saying:

"The patch itself has (at least) one big problem. It is using some mac80211
internals in ath_key_config_iter to make sure that the uploaded keys were
actually programmed in the hardware. Without this check the keys could end up
in the lower slots and thus break all connections."


Does anybody else have any other additional comment?
(Please keep me in CC as I am not registered to the ath9k ML).

Cheers,

On Tue, Oct 18, 2016 at 04:35:52PM +0800, Antonio Quartulli wrote:
> From: Antonio Quartulli 
> 
> This patch was crafted long time ago to work around a key cache
> corruption problem on ath9k chipsets.
> 
> The workaround consists in periodically triggering a worker that
> uploads all the keys to the HW cache. The worker is triggered also
> when the vif detects 21 undecryptable packets.
> 
> 
> This patch is based on top compat-wireless-2015-10-26.
> 
> 
> I was asked to release this code to the public and, since it is
> GPL, I am now doing it.
> 
> 
> Signed-off-by: Antonio Quartulli 

-- 
Antonio Quartulli


signature.asc
Description: Digital signature


Re: [PATCH v2 2/2] mac80211: passively scan DFS channels if requested

2016-10-24 Thread Antonio Quartulli
On Fri, Nov 20, 2015 at 08:52:32PM +0800, Antonio Quartulli wrote:
> On 20/11/15 18:49, Johannes Berg wrote:
> > 
> >> @@ -599,7 +599,9 @@ static int __ieee80211_start_scan(struct
> >> ieee80211_sub_if_data *sdata,
> >>  
> >>if ((req->channels[0]->flags &
> >> IEEE80211_CHAN_NO_IR) ||
> >> -  !req->n_ssids) {
> >> +  !req->n_ssids ||
> >> +  ((req->channels[0]->flags &
> >> IEEE80211_CHAN_RADAR) &&
> >> +   (req->flags &
> >> NL80211_SCAN_FLAG_PASSIVE_RADAR))) {
> >>next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
> >>
> > 
> > I don't really see any circumstances under which it's valid to actively
> > scan radar channels ... seems like we should do this unconditionally?
> 
> I think it would be reasonable only if the target channel is the one we
> are using and we have done CSA. But when scanning non-operative channels
> I don't think this could work.
> 
> As discussed on IRC I'd rather go for passively scanning any DFS channel.
> 
> Cheers,

Hey Johannes,

this has been sleeping for a while.. :)
Would it make sense to rebase it and resubmit it for inclusion?

Given the previous discussion we could change the logic as:
* always passively scan DFS channels that are not usable
* always actively scan DFS channels that are usable (i.e. CAC was performed).

How does it sound? this would totally avoid the use of the switch in the scan
command.

Cheers,


-- 
Antonio Quartulli


signature.asc
Description: Digital signature


Re: [PATCH v2 2/2] mac80211: passively scan DFS channels if requested

2016-10-24 Thread Antonio Quartulli
On Mon, Oct 24, 2016 at 03:33:24PM +0200, Johannes Berg wrote:
> 
> > > I think it would be reasonable only if the target channel is the
> > > one we are using and we have done CSA. But when scanning non-
> > > operative channels I don't think this could work.
> 
> > this has been sleeping for a while.. :)
> > Would it make sense to rebase it and resubmit it for inclusion?
> > 
> > Given the previous discussion we could change the logic as:
> > * always passively scan DFS channels that are not usable
> > * always actively scan DFS channels that are usable (i.e. CAC was
> > performed).
> 
> Doesn't that contradict what you said above?
> 
> If we scan, don't we possibly lose our CAC result anyway, since we went
> off-channel? In FCC at least? In ETSI I think we're allowed to do that
> for a bit?

argh. ok, I think I had forgotten about this detail.

> 
> Anyway, why not just always scan passively, to simplify?
> 

Probably better..ok let's do it this way.

Thanks !


-- 
Antonio Quartulli


signature.asc
Description: Digital signature


Re: [NOT FOR MERGE] ath9k: work around key cache corruption

2016-10-26 Thread Antonio Quartulli
On Wed, Oct 26, 2016 at 05:05:14PM +0300, Kalle Valo wrote:
> Antonio Quartulli  writes:
> 
> > From: Antonio Quartulli 
> >
> > This patch was crafted long time ago to work around a key cache
> > corruption problem on ath9k chipsets.
> >
> > The workaround consists in periodically triggering a worker that
> > uploads all the keys to the HW cache. The worker is triggered also
> > when the vif detects 21 undecryptable packets.
> >
> >
> > This patch is based on top compat-wireless-2015-10-26.
> >
> >
> > I was asked to release this code to the public and, since it is
> > GPL, I am now doing it.
> 
> GPL? AFAICS ath9k is under ISC. I'm not sure what you mean with the
> sentence above, but it's possible to interpret it so that this patch is
> not under ISC license, which is problematic.

Honestly, my sentence was just a way to say "it makes sense to release this
patch to the public".

If it needs to be ISC in order to be merged, then it can be released under ISC.

I don't want to enter a legal case :) I just to make the patch public

Cheers,

-- 
Antonio Quartulli


signature.asc
Description: Digital signature


Re: [PATCH net-next 4/5] treewide: replace dev->trans_start update with helper

2016-05-04 Thread Antonio Quartulli
On Tue, May 03, 2016 at 04:33:13PM +0200, Florian Westphal wrote:
> Replace all trans_start updates with netif_trans_update helper.
> change was done via spatch:
> 
> struct net_device *d;
> @@
> - d->trans_start = jiffies
> + netif_trans_update(d)
> 
> Compile tested only.
> 
> Cc: user-mode-linux-de...@lists.sourceforge.net
> Cc: linux-xte...@linux-xtensa.org
> Cc: linux1394-de...@lists.sourceforge.net
> Cc: linux-r...@vger.kernel.org
> Cc: net...@vger.kernel.org
> Cc: mpt-fusionlinux@broadcom.com
> Cc: linux-s...@vger.kernel.org
> Cc: linux-...@vger.kernel.org
> Cc: linux-par...@vger.kernel.org
> Cc: linux-o...@vger.kernel.org
> Cc: linux-h...@vger.kernel.org
> Cc: linux-...@vger.kernel.org
> Cc: linux-wireless@vger.kernel.org
> Cc: linux-s...@vger.kernel.org
> Cc: de...@driverdev.osuosl.org
> Cc: b.a.t.m@lists.open-mesh.org
> Cc: linux-blueto...@vger.kernel.org
> Signed-off-by: Florian Westphal 
> ---

[...]

>  net/batman-adv/soft-interface.c| 2 +-

[...]

> diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
> index 0710379..bae1397 100644
> --- a/net/batman-adv/soft-interface.c
> +++ b/net/batman-adv/soft-interface.c
> @@ -208,7 +208,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
>   if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
>   goto dropped;
>  
> - soft_iface->trans_start = jiffies;
> + netif_trans_update(soft_iface);
>   vid = batadv_get_vid(skb, 0);
>   ethhdr = eth_hdr(skb);
>  


Acked-by: Antonio Quartulli 

-- 
Antonio Quartulli


signature.asc
Description: Digital signature


Re: how to achieve SSID isolation

2014-10-12 Thread Antonio Quartulli
On 13/10/14 02:10, Sourav wrote:
> I understand that client isolation(in a single SSID is achieved using
> "ap_isolate" parameter).
> Is there any parameter in hostapd.conf to achieve SSID
> isolation..i.e the a client connected to that SSID, can't talk to
> any other clients connected to any other SSID?
> 

I think this is something you should easily solve at the layer "above"
hostapd. Each SSID in hostapd is represented by an interface, therefore
you need to prevent hosts connected to one to talk to hosts connected to
the other..but this is not hostapd's role and it depends on your network
configuration.

Cheers,

-- 
Antonio Quartulli



signature.asc
Description: OpenPGP digital signature


ath10k: fw_stats not reporting peer_stats with 10.2

2014-12-18 Thread Antonio Quartulli
Hello,

I have a device equipped with a ath10k driven wifi card, specifically:

qca988x hw2.0 (0x4100016c, 0x043202ff) fw 10.2-00082-4-2 api 3 htt 2.1
wmi 65.109.0.0 cal file


(line grabbed from dmesg at boot time)

On my device I have configured 2 AP vifs and for each of them I would
like to read the last TX rate of the associated stations.

As I've read on wireless.kernel.org this is not possible through the
standard nl/cfg80211 interface and therefore I have been trying to read
/sys/kernel/debug/ieee80211/phy1/ath10k/fw_stats  , but this file always
reports "ath10k PEER stats (0)" (no peers..).

I tried printing some debug messages here and there and the only useful
information I got is that in "ath10k_wmi_10x_pull_fw_stats()" the value
of "ev->num_peer_stats" is always 0.

Is this yet another fw limitation?


I also realized that upon station connection ath10k receives the
WMI_10_2_PEER_RATECODE_LIST_EVENTID event but it is not handled as no
handler is implemented. Might it be related with my problem ?


Thanks a lot for any information you would be able to provide :)

Cheers,


-- 
Antonio Quartulli



signature.asc
Description: OpenPGP digital signature


Re: ath10k: fw_stats not reporting peer_stats with 10.2

2015-01-12 Thread Antonio Quartulli
On 12/01/15 12:54, Michal Kazior wrote:
> On 18 December 2014 at 14:00, Antonio Quartulli  wrote:
>> I tried printing some debug messages here and there and the only useful
>> information I got is that in "ath10k_wmi_10x_pull_fw_stats()" the value
>> of "ev->num_peer_stats" is always 0.
>>
>> Is this yet another fw limitation?
> 
> Firmware stats has a very fragile ABI. Apparently 10.2 changed it
> again and thus is broken. I'll try to look into it more if time
> permits.

Thank MichaƂ!
I will be happy to test any change you might be able to provide.

Cheers,


-- 
Antonio Quartulli



signature.asc
Description: OpenPGP digital signature


Re: Cannot use ap and sta mode on same interface with ath9k and kernel 3.8.13 :-(

2015-01-17 Thread Antonio Quartulli
On 17/01/15 00:43, Beat Meier wrote:
> On 01/16/2015 08:16 PM, Pat Erley wrote:
>> On 01/16/2015 04:29 PM, Beat Meier wrote:
>>> Hi
>>>
>>> I'm using an WLM200NX card in master mode ath1 and want to do scanning
>>> on the same interface.
>>> I'm using ath9k on 3.8.13 kernel (voyage-linux)
>>>
>>> So I setup an additional  interface in sta mode with
>>>iw phy phy1 interface add ath2 type managed
>>> This works but the interface is not coming up.
>>> I tried several things like
>>> auto ath2
>>> iface ath2 inet static
>>>  address 10.58.1.1
>>>  netmask 255.255.255.0
>>>  wireless-mode Managed
>>>  wpa-conf /etc/wpa_supplicant.conf.WPA-PSK
>>>
>>> But wpa_spplicant comes with error:
>>>wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
>>>run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return
>>> code 1
>>>RTNETLINK answers: Name not unique on network
>>>Failed to bring up ath2.
>>>
>>> I can setup monitor mode but I want to scan to see what other equipment
>>> is on which channel ...
>>>
>>> What's the problem? With ath9k I cannot use ap and sta mode together???
>>>
>>
>> You need to assign a different mac address to the new interface.
>>
>> [Resend, accidentally dropped mailing list]
>>
> 
> This solved the problem.
> Would be nice to add a comment in
>   http://wireless.kernel.org/en/users/Documentation/iw/vif#station

By the way, you can scan also with a master interface. You just need to
pass the ap-force flag to the scan command.

Cheers,


-- 
Antonio Quartulli



signature.asc
Description: OpenPGP digital signature


Re: iw and non-ASCII SSIDs

2015-06-26 Thread Antonio Quartulli


On 26/06/15 10:50, Johannes Berg wrote:
> 
> OTOH, what choice do we really have - the only other option would be to
> add a command line flag indicating that this behaviour is desired?

Why not just using wpa_supplicant with key_mgmt=NONE ? It can handle the
case where no encryption is required.

From your previous email I understood that it already supports hex
SSIDs, therefore this should probably work, I guess. Has somebody tried
this ?

This way there is no need to break/extend any other tool.

Cheers,


-- 
Antonio Quartulli



signature.asc
Description: OpenPGP digital signature


[PATCH] nl80211: report 4ADDR status with GET_INTERFACE

2018-06-13 Thread Antonio Quartulli
User space tools might be interested in knowing the current
status of the 4ADDR property of an interface (when supported).

Send the status along with the other attributes when replying
to a GET_INTERFACE netlink query.

Signed-off-by: Antonio Quartulli 
---
 net/wireless/nl80211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 07514ca011b2..cfed20dbaa7e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2757,7 +2757,8 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 
portid, u32 seq, int flag
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, wdev_address(wdev)) ||
nla_put_u32(msg, NL80211_ATTR_GENERATION,
rdev->devlist_generation ^
-   (cfg80211_rdev_list_generation << 2)))
+   (cfg80211_rdev_list_generation << 2)) ||
+   nla_put_u8(msg, NL80211_ATTR_4ADDR, wdev->use_4addr))
goto nla_put_failure;
 
if (rdev->ops->get_channel) {
-- 
2.17.1



[PATCH] iw: print 4ADDR attribute when dumping interface

2018-06-17 Thread Antonio Quartulli
Print the value of the 4ADDr attribute when dumping the interface
status.

Signed-off-by: Antonio Quartulli 
---
 interface.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/interface.c b/interface.c
index 712bbdc..678955d 100644
--- a/interface.c
+++ b/interface.c
@@ -447,6 +447,11 @@ static int print_iface_handler(struct nl_msg *msg, void 
*arg)
printf("%s\tmulticast TXQ:%s\n", indent, buf);
}
 
+   if (tb_msg[NL80211_ATTR_4ADDR]) {
+   uint8_t use_4addr = nla_get_u8(tb_msg[NL80211_ATTR_4ADDR]);
+   printf("%s\t4addr: %d\n", indent, use_4addr);
+   }
+
return NL_SKIP;
 }
 
-- 
2.17.1