Search Linux Wireless

[RFC v2 5/8] mac80211: setting link-specific mesh power modes when plink opens

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When plink is opened peer link-specific power mode is set up equal to
peer non-peer power mode value.

When plink is opened local link-specific power mode is set up equal
to local non-peer value.

Signed-off-by: Ivan Bezyazychnyy <ivan.bezyazychnyy@xxxxxxxxx>
Signed-off-by: Mike Krinkin <krinkin.m.u@xxxxxxxxx>
Signed-off-by: Max Filippov <jcmvbkbc@xxxxxxxxx>
---
 net/mac80211/mesh.c       |   33 +++++++++++++++++++++++++++++++++
 net/mac80211/mesh.h       |    6 ++++++
 net/mac80211/mesh_plink.c |   22 +++++++++++++++++++++-
 3 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 5b8c5d3..5963164 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -386,6 +386,39 @@ void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh)
 	}
 }
 
+void ieee80211s_set_local_ps_mode(struct sta_info *sta, u8 pm)
+{
+	switch (pm) {
+	case NL80211_MESH_POWER_ACTIVE:
+		sta->local_ps_mode = NL80211_MESH_POWER_ACTIVE;
+#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
+		printk(KERN_DEBUG "%s: local STA operates in active mode with STA %pM\n",
+			sta->sdata->name, sta->sta.addr);
+#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
+		break;
+	case NL80211_MESH_POWER_LIGHT_SLEEP:
+		sta->local_ps_mode = NL80211_MESH_POWER_LIGHT_SLEEP;
+#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
+		printk(KERN_DEBUG "%s: local STA operates in light sleep mode with STA %pM\n",
+				sta->sdata->name, sta->sta.addr);
+#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
+		break;
+	case NL80211_MESH_POWER_DEEP_SLEEP:
+		sta->local_ps_mode = NL80211_MESH_POWER_DEEP_SLEEP;
+#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
+		printk(KERN_DEBUG "%s: local STA operates in deep sleep mode with STA %pM\n",
+				sta->sdata->name, sta->sta.addr);
+#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
+		break;
+	default:
+#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
+		printk(KERN_DEBUG "%s: local STA used invalid power mode to operate with STA %pM\n",
+				sta->sdata->name, sta->sta.addr);
+#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
+		break;
+	}
+}
+
 /**
  * ieee80211_fill_mesh_addresses - fill addresses of a locally originated mesh frame
  * @hdr:    	802.11 frame header
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index e62c53b..1b2c58d 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -227,6 +227,7 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
 void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
 void ieee80211s_set_sta_ps_mode(struct sta_info *sta,
 				enum nl80211_mesh_power_mode mode);
+void ieee80211s_set_local_ps_mode(struct sta_info *sta, u8 pm);
 
 /* Mesh paths */
 int mesh_nexthop_lookup(struct sk_buff *skb,
@@ -312,6 +313,11 @@ static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
 	return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
 }
 
+static inline bool ieee80211s_has_capab_pm(__le16 capab_info)
+{
+	return (capab_info & MESHCONF_CAPAB_POWER_SAVE_LEVEL) != 0;
+}
+
 void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local);
 
 void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata);
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index 7e57f5d..a8f92f3 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -248,6 +248,8 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates,
 {
 	struct ieee80211_local *local = sdata->local;
 	struct sta_info *sta;
+	struct ieee80211_mgmt *mgmt = container_of(hw_addr,
+					struct ieee80211_mgmt, sa[0]);
 
 	rcu_read_lock();
 
@@ -275,8 +277,26 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates,
 	if (mesh_peer_accepts_plinks(elems) &&
 			sta->plink_state == NL80211_PLINK_LISTEN &&
 			sdata->u.mesh.accepting_plinks &&
-			sdata->u.mesh.mshcfg.auto_open_plinks)
+			sdata->u.mesh.mshcfg.auto_open_plinks) {
+		if (ieee80211_has_pm(mgmt->frame_control)) {
+			__le16 capab_info = mgmt->u.probe_resp.capab_info;
+			if (ieee80211s_has_capab_pm(capab_info)) {
+				ieee80211s_set_sta_ps_mode(sta,
+					NL80211_MESH_POWER_DEEP_SLEEP);
+			} else {
+				ieee80211s_set_sta_ps_mode(sta,
+					NL80211_MESH_POWER_LIGHT_SLEEP);
+			}
+		} else {
+			ieee80211s_set_sta_ps_mode(sta,
+				NL80211_MESH_POWER_ACTIVE);
+		}
+
+		ieee80211s_set_local_ps_mode(sta,
+			sdata->u.mesh.mshcfg.power_mode);
+
 		mesh_plink_open(sta);
+	}
 
 	rcu_read_unlock();
 }
-- 
1.7.3.4

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


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux