Re: [ath9k-devel] [PATCH 1/3] mac80211: move mesh sync beacon handler into neighbour_update

2013-02-18 Thread Johannes Berg
On Mon, 2013-02-18 at 16:07 +0100, Marco Porsch wrote:

  I guess you can tell I'm not in a good mood today. I think any use of
  get_tsf() for operation is a complete waste of time, there's no way you
  can get the timings correct. You could be preempted, and suddenly sleep
  for a few tens or hundreds milliseconds, so none of this makes any
  sense... To properly do it you have to do calculations in relative times
  and let the device apply them.
 
 I don't get your last sentence here. Maybe you can elaborate?

I'm saying what could happens is this:

 tsf = drv_get_tsf()
 [be preempted, 100ms later]
 do_something_with(tsf)

so I think using drv_get_tsf() is pretty much always wrong.


 Concerning timestamp vs. TSF usage; wow - I tested it when using the 
 timestamp value for TBTT scheduling. Works fine. Works even better than 
 TSF as it slightly reduces the measured wakeup overhead.
 
 Hm, I was sure the TSF as in *now* would be more appropriate than the 
 TSF at receipt time... But either way, if it works better and is less 
 ugly, it is a win-win =)
 
 I'll send an updated patch with the more intuitive API.

:)

johannes

___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] [PATCHv2 1/3] mac80211: move mesh sync beacon handler into neighbour_update

2013-02-18 Thread Marco Porsch
Move the beacon handler into mesh_neighbour_update where the STA
pointer is already available. This avoids additional overhead
and simplifies the handler.
The repositioning will also benefit mesh PS which uses T_r and
the updated T_offset value.

Rename the handler to better reflect its purpose.

Signed-off-by: Marco Porsch ma...@cozybit.com
---

v2:
calculate T_r outside mesh sync handler (Johannes)
remove unused variables

 net/mac80211/ieee80211_i.h |9 -
 net/mac80211/mesh.c|7 +--
 net/mac80211/mesh.h|4 +++-
 net/mac80211/mesh_plink.c  |   31 +-
 net/mac80211/mesh_sync.c   |   45 ++--
 5 files changed, 44 insertions(+), 52 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 388580a..631760f 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -529,11 +529,10 @@ struct ieee80211_if_ibss {
  */
 struct ieee802_11_elems;
 struct ieee80211_mesh_sync_ops {
-   void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata,
-u16 stype,
-struct ieee80211_mgmt *mgmt,
-struct ieee802_11_elems *elems,
-struct ieee80211_rx_status *rx_status);
+   void (*rx_bcn)(struct sta_info *sta,
+  struct ieee80211_mgmt *mgmt,
+  struct ieee802_11_elems *elems,
+  u64 t_r);
void (*adjust_tbtt)(struct ieee80211_sub_if_data *sdata);
/* add other framework functions here */
 };
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 29ce2aa..94682d2 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -938,7 +938,6 @@ static void ieee80211_mesh_rx_bcn_presp(struct 
ieee80211_sub_if_data *sdata,
struct ieee80211_rx_status *rx_status)
 {
struct ieee80211_local *local = sdata-local;
-   struct ieee80211_if_mesh *ifmsh = sdata-u.mesh;
struct ieee802_11_elems elems;
struct ieee80211_channel *channel;
size_t baselen;
@@ -974,11 +973,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct 
ieee80211_sub_if_data *sdata,
return;
 
if (mesh_matches_local(sdata, elems))
-   mesh_neighbour_update(sdata, mgmt-sa, elems);
-
-   if (ifmsh-sync_ops)
-   ifmsh-sync_ops-rx_bcn_presp(sdata,
-   stype, mgmt, elems, rx_status);
+   mesh_neighbour_update(sdata, mgmt, elems, rx_status);
 }
 
 static void ieee80211_mesh_rx_mgmt_action(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index 336c88a..ac02f38 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -283,7 +283,9 @@ int mesh_gate_num(struct ieee80211_sub_if_data *sdata);
 
 /* Mesh plinks */
 void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
-  u8 *hw_addr, struct ieee802_11_elems *ie);
+  struct ieee80211_mgmt *mgmt,
+  struct ieee802_11_elems *ie,
+  struct ieee80211_rx_status *rx_status);
 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
 u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
 void mesh_plink_broken(struct sta_info *sta);
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index 07d396d..d40fedd 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -12,6 +12,7 @@
 #include ieee80211_i.h
 #include rate.h
 #include mesh.h
+#include driver-ops.h
 
 #define PLINK_GET_LLID(p) (p + 2)
 #define PLINK_GET_PLID(p) (p + 4)
@@ -497,23 +498,43 @@ mesh_sta_info_get(struct ieee80211_sub_if_data *sdata,
  * Initiates peering if appropriate.
  */
 void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
-  u8 *hw_addr,
-  struct ieee802_11_elems *elems)
+  struct ieee80211_mgmt *mgmt,
+  struct ieee802_11_elems *elems,
+  struct ieee80211_rx_status *rx_status)
 {
+   struct ieee80211_local *local = sdata-local;
+   struct ieee80211_if_mesh *ifmsh = sdata-u.mesh;
struct sta_info *sta;
u32 changed = 0;
+   u64 t_r;
+
+   /*
+* If available, calculate the time the beacon timestamp field was
+* received from the rx_status-mactime field. Otherwise get the
+* current TSF as approximation before entering rcu-read section.
+*/
+   if (ieee80211_have_rx_timestamp(rx_status))
+   t_r = ieee80211_calculate_rx_timestamp(local, rx_status,
+  24 + 12 +
+  elems-total_len +
+  FCS_LEN,
+ 

[ath9k-devel] [PATCHv2 2/3] mac80211: mesh power save doze scheduling

2013-02-18 Thread Marco Porsch
Configure the HW for PS mode if the local mesh PS parameters
allow so.

Expose a callback ieee80211_mps_init for drivers to register
mesh powersave ops:
- hw_doze - put the radio to sleep now, wake up at given TBTT
- hw_wakeup - wake the radio up for frame RX
These ops may be extended in the future to allow drivers/HW to
implement mesh PS themselves. (The current design goal was to
concentrate most mesh PS routines in mac80211 to keep driver
modifications minimal.

Track the beacon timing information of peers we are in PS mode
towards. Calculate the next TBTT per STA. Stay awake to receive
multicast traffic after DTIM beacons.

When going to doze state, get the most imminent STA TBTT and
configure the driver to trigger a wakeup on time to catch that
beacon. After successful receipt put the HW to doze again.
Set a timeout for the case that the beacon is not received on
time. In this case calculate the following TBTT and go to doze
again.

For mesh Awake Windows wakeup on SWBA (beacon_get_tim) and start
a timer which triggers a doze call on expiry.

Signed-off-by: Marco Porsch ma...@cozybit.com
---
 include/net/mac80211.h |   29 
 net/mac80211/ieee80211_i.h |7 +-
 net/mac80211/mesh.c|   11 ++
 net/mac80211/mesh.h|   13 ++
 net/mac80211/mesh_plink.c  |3 +
 net/mac80211/mesh_ps.c |  313 
 net/mac80211/sta_info.h|   10 ++
 net/mac80211/tx.c  |2 +
 8 files changed, 387 insertions(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index f7eba13..a27383f 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2801,6 +2801,18 @@ enum ieee80211_tpt_led_trigger_flags {
IEEE80211_TPT_LEDTRIG_FL_CONNECTED  = BIT(2),
 };
 
+/**
+ * struct ieee80211_mps_ops - callbacks from mac80211 to the driver for mesh PS
+ *
+ * @hw_doze: put the radio to doze state to conserve power, schedule wakeup
+ * at given TSF value to receive peer beacon
+ * @hw_wakeup: wake up the radio to receive frames again
+ */
+struct ieee80211_mps_ops {
+   void (*hw_doze)(struct ieee80211_hw *hw, u64 nexttbtt);
+   void (*hw_wakeup)(struct ieee80211_hw *hw);
+};
+
 #ifdef CONFIG_MAC80211_LEDS
 extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
 extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
@@ -4058,6 +4070,23 @@ void ieee80211_stop_rx_ba_session(struct ieee80211_vif 
*vif, u16 ba_rx_bitmap,
  */
 void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn);
 
+/**
+ * ieee80211_mps_init - register callbacks for mesh powersave mode
+ *
+ * @hw: the hardware
+ * @ops: callbacks for this device
+ *
+ * called by driver on mesh interface add/remove
+ */
+#ifdef CONFIG_MAC80211_MESH
+void ieee80211_mps_init(struct ieee80211_hw *hw,
+   const struct ieee80211_mps_ops *ops);
+#else
+static inline void ieee80211_mps_init(struct ieee80211_hw *hw,
+ const struct ieee80211_mps_ops *ops)
+{ return; }
+#endif
+
 /* Rate control API */
 
 /**
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 631760f..c42a506 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -599,6 +599,7 @@ struct ieee80211_if_mesh {
int ps_peers_light_sleep;
int ps_peers_deep_sleep;
struct ps_data ps;
+   struct timer_list awake_window_end_timer;
 };
 
 #ifdef CONFIG_MAC80211_MESH
@@ -1092,7 +1093,7 @@ struct ieee80211_local {
bool pspolling;
bool offchannel_ps_enabled;
/*
-* PS can only be enabled when we have exactly one managed
+* managed mode PS can only be enabled when we have exactly one managed
 * interface (and monitors) in PS, this then points there.
 */
struct ieee80211_sub_if_data *ps_sdata;
@@ -,6 +1112,10 @@ struct ieee80211_local {
 
int user_power_level; /* in dBm, for all interfaces */
 
+   /* mesh power save can be enabled for multiple (but only mesh) vif */
+   bool mps_enabled;
+   const struct ieee80211_mps_ops *mps_ops;
+
enum ieee80211_smps_mode smps_mode;
 
struct work_struct restart_work;
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 94682d2..61cfbe0 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -168,6 +168,7 @@ void mesh_sta_cleanup(struct sta_info *sta)
if (sdata-u.mesh.security == IEEE80211_MESH_SEC_NONE) {
changed |= mesh_plink_deactivate(sta);
del_timer_sync(sta-plink_timer);
+   del_timer_sync(sta-nexttbtt_timer);
}
 
if (changed)
@@ -1026,6 +1027,7 @@ void ieee80211_mesh_rx_queued_mgmt(struct 
ieee80211_sub_if_data *sdata,
 
 void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata)
 {
+   struct ieee80211_local *local = sdata-local;
struct ieee80211_if_mesh *ifmsh = sdata-u.mesh;
 
if 

Re: [ath9k-devel] [PATCHv2 2/3] mac80211: mesh power save doze scheduling

2013-02-18 Thread Christian Lamparter
On Monday, February 18, 2013 05:08:28 PM Marco Porsch wrote:
 ---
 +/**
 + * ieee80211_mps_sta_tbtt_update - update peer beacon wakeup schedule
 + *
 + * @sta: mesh STA
 + * @mgmt: beacon frame
 + * @tim: TIM IE of beacon frame
 + * @tsf_local: current HW TSF
 + */
 +void ieee80211_mps_sta_tbtt_update(struct sta_info *sta,
 +struct ieee80211_mgmt *mgmt,
 +const struct ieee80211_tim_ie *tim,
 +u64 tsf_local)
 +{
 + struct ieee80211_sub_if_data *sdata = sta-sdata;
 +
 + if (!sdata-local-mps_enabled ||
 + sta-plink_state != NL80211_PLINK_ESTAB)
 + return;
 +
 + sta-beacon_interval = le16_to_cpu(mgmt-u.beacon.beacon_int) * 1024;
If you want, you could use ieee80211_tu_to_usec instead of * 1024:
sta-beacon_interval = 
ieee80211_tu_to_usec(le16_to_cpu(mgmt-u.beacon.beacon_int));

Regards,
Chr
___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


[ath9k-devel] txpower setting regression

2013-02-18 Thread Georgiewskiy Yuriy


Hi all, there is some kind of regression with setting transmit power, hardware 
is warious
ar9280 cards, all work as sould with compat-wireless-3.6 and compat-drivers-2013-02-13, i 
have modified regulatory database:


iw reg get
country RU:
(2402 - 2494 @ 40), (24, 23)
(5030 - 5835 @ 40), (24, 23)

with compat-wireless-3.6 and compat-drivers-2013-02-13 i can change txpower in 
this rules,
iw list show channels and it's power according to database rules:

Frequencies:
* 2412 MHz [1] (23.0 dBm)
* 2417 MHz [2] (23.0 dBm)
* 2422 MHz [3] (23.0 dBm)
* 2427 MHz [4] (23.0 dBm)
* 2432 MHz [5] (23.0 dBm)
* 2437 MHz [6] (23.0 dBm)
* 2442 MHz [7] (23.0 dBm)
* 2447 MHz [8] (23.0 dBm)
* 2452 MHz [9] (23.0 dBm)
* 2457 MHz [10] (23.0 dBm)
* 2462 MHz [11] (23.0 dBm)
* 2467 MHz [12] (23.0 dBm)
* 2472 MHz [13] (23.0 dBm)
* 2484 MHz [14] (23.0 dBm)

but with compat-drivers 3.7.6 and 3.8-rc7 i cannot set power level, 
iw phy phy0 set txpower fixed 10/limit 10/iw dev dev0/etc give same 
error - command failed: Operation not supported (-95), and iw list 
give strange output like this:


Frequencies:
* 2412 MHz [1] (20.0 dBm)
* 2417 MHz [2] (21.0 dBm)
* 2422 MHz [3] (21.0 dBm)
* 2427 MHz [4] (21.0 dBm)
* 2432 MHz [5] (21.0 dBm)
* 2437 MHz [6] (21.0 dBm)
* 2442 MHz [7] (21.0 dBm)
* 2447 MHz [8] (21.0 dBm)
* 2452 MHz [9] (21.0 dBm)
* 2457 MHz [10] (21.0 dBm)
* 2462 MHz [11] (20.0 dBm)
* 2467 MHz [12] (23.0 dBm)
* 2472 MHz [13] (23.0 dBm)
* 2484 MHz [14] (23.0 dBm)

and channel levels different on different cards.


C уважением   With Best Regards
Георгиевский Юрий.Georgiewskiy Yuriy
+7 4872 711666+7 4872 711666
факс +7 4872 711143   fax +7 4872 711143
Компания ООО Ай Ти Сервис   IT Service Ltd
http://nkoort.ru  http://nkoort.ru
JID: ghh...@icf.org.ruJID: ghh...@icf.org.ru
YG129-RIPEYG129-RIPE___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel


Re: [ath9k-devel] txpower setting regression

2013-02-18 Thread Georgiewskiy Yuriy
On 2013-02-19 04:04 +0400, Georgiewskiy Yuriy wrote linux-wirel...@vger.ker...:

hm, update - on 3.8.0 all ok

GY
GYHi all, there is some kind of regression with setting transmit power,
GYhardware is warious
GYar9280 cards, all work as sould with compat-wireless-3.6 and
GYcompat-drivers-2013-02-13, i have modified regulatory database:
GY
GYiw reg get
GYcountry RU:
GY(2402 - 2494 @ 40), (24, 23)
GY(5030 - 5835 @ 40), (24, 23)
GY
GYwith compat-wireless-3.6 and compat-drivers-2013-02-13 i can change txpower
GYin this rules,
GYiw list show channels and it's power according to database rules:
GY
GYFrequencies:
GY* 2412 MHz [1] (23.0 dBm)
GY* 2417 MHz [2] (23.0 dBm)
GY* 2422 MHz [3] (23.0 dBm)
GY* 2427 MHz [4] (23.0 dBm)
GY* 2432 MHz [5] (23.0 dBm)
GY* 2437 MHz [6] (23.0 dBm)
GY* 2442 MHz [7] (23.0 dBm)
GY* 2447 MHz [8] (23.0 dBm)
GY* 2452 MHz [9] (23.0 dBm)
GY* 2457 MHz [10] (23.0 dBm)
GY* 2462 MHz [11] (23.0 dBm)
GY* 2467 MHz [12] (23.0 dBm)
GY* 2472 MHz [13] (23.0 dBm)
GY* 2484 MHz [14] (23.0 dBm)
GY
GYbut with compat-drivers 3.7.6 and 3.8-rc7 i cannot set power level, iw phy
GYphy0 set txpower fixed 10/limit 10/iw dev dev0/etc give same error - command
GYfailed: Operation not supported (-95), and iw list give strange output like
GYthis:
GY
GYFrequencies:
GY* 2412 MHz [1] (20.0 dBm)
GY* 2417 MHz [2] (21.0 dBm)
GY* 2422 MHz [3] (21.0 dBm)
GY* 2427 MHz [4] (21.0 dBm)
GY* 2432 MHz [5] (21.0 dBm)
GY* 2437 MHz [6] (21.0 dBm)
GY* 2442 MHz [7] (21.0 dBm)
GY* 2447 MHz [8] (21.0 dBm)
GY* 2452 MHz [9] (21.0 dBm)
GY* 2457 MHz [10] (21.0 dBm)
GY* 2462 MHz [11] (20.0 dBm)
GY* 2467 MHz [12] (23.0 dBm)
GY* 2472 MHz [13] (23.0 dBm)
GY * 2484 MHz [14] (23.0 dBm)
GY
GYand channel levels different on different cards.
GY
GY
GYC уважением   With Best Regards
GYГеоргиевский Юрий.Georgiewskiy Yuriy
GY+7 4872 711666+7 4872 711666
GYфакс +7 4872 711143   fax +7 4872 711143
GYКомпания ООО Ай Ти Сервис   IT Service Ltd
GYhttp://nkoort.ru  http://nkoort.ru
GYJID: ghh...@icf.org.ruJID: ghh...@icf.org.ru
GYYG129-RIPEYG129-RIPE

C уважением   With Best Regards
Георгиевский Юрий.Georgiewskiy Yuriy
+7 4872 711666+7 4872 711666
факс +7 4872 711143   fax +7 4872 711143
Компания ООО Ай Ти Сервис   IT Service Ltd
http://nkoort.ru  http://nkoort.ru
JID: ghh...@icf.org.ruJID: ghh...@icf.org.ru
YG129-RIPEYG129-RIPE___
ath9k-devel mailing list
ath9k-devel@lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel