linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value
@ 2018-03-27  6:48 Tamizh chelvam
  2018-03-27  6:48 ` [RFC 1/3] cfg80211: fix data type of sta_opmode_info parameter Tamizh chelvam
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Tamizh chelvam @ 2018-03-27  6:48 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Tamizh chelvam

Currently bw and smps_mode are u8 type value in sta_opmode_info
structure. This values filled in mac80211 from ieee80211_sta_rx_bandwidth
and ieee80211_smps_mode. These enum values are specific to mac80211 and
userspace/cfg80211 doesn't know about that. This patchset change its
data type in the sta_opmode_info structure and mapping from mac80211
specific enum to nl80211 enum value.

Tamizh chelvam (3):
  cfg80211: fix data type of sta_opmode_info parameter
  mac80211: Use proper smps_mode enum in sta opmode event
  mac80211: Use proper chan_width enum in sta opmode event

Note :
  * Is this mac80211 approach sufficient ? or whether some more
    complete cleanup would be preferred ?

 include/net/cfg80211.h     |  8 ++++----
 net/mac80211/ht.c          | 15 +++++++++++++++
 net/mac80211/ieee80211_i.h |  4 ++++
 net/mac80211/rx.c          |  6 ++++--
 net/mac80211/vht.c         | 32 +++++++++++++++++++++++++++++++-
 5 files changed, 58 insertions(+), 7 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFC 1/3] cfg80211: fix data type of sta_opmode_info parameter
  2018-03-27  6:48 [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value Tamizh chelvam
@ 2018-03-27  6:48 ` Tamizh chelvam
  2018-03-27  6:48 ` [RFC 2/3] mac80211: Use proper smps_mode enum in sta opmode event Tamizh chelvam
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Tamizh chelvam @ 2018-03-27  6:48 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Tamizh chelvam

Currently bw and smps_mode are u8 type value in sta_opmode_info
structure. This values filled in mac80211 from ieee80211_sta_rx_bandwidth
and ieee80211_smps_mode. These enum values are specific to mac80211 and
userspace/cfg80211 doesn't know about that. This will lead to incorrect
result/assumption by the user space application.
Change bw and smps_mode parameters to their respective enums in nl80211.

Signed-off-by: Tamizh chelvam <tamizhr@codeaurora.org>
---
 include/net/cfg80211.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index fc40843..4341508 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3572,15 +3572,15 @@ enum wiphy_opmode_flag {
 /**
  * struct sta_opmode_info - Station's ht/vht operation mode information
  * @changed: contains value from &enum wiphy_opmode_flag
- * @smps_mode: New SMPS mode of a station
- * @bw: new max bandwidth value of a station
+ * @smps_mode: New SMPS mode value from &enum nl80211_smps_mode of a station
+ * @bw: new max bandwidth value from &enum nl80211_chan_width of a station
  * @rx_nss: new rx_nss value of a station
  */
 
 struct sta_opmode_info {
 	u32 changed;
-	u8 smps_mode;
-	u8 bw;
+	enum nl80211_smps_mode smps_mode;
+	enum nl80211_chan_width bw;
 	u8 rx_nss;
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC 2/3] mac80211: Use proper smps_mode enum in sta opmode event
  2018-03-27  6:48 [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value Tamizh chelvam
  2018-03-27  6:48 ` [RFC 1/3] cfg80211: fix data type of sta_opmode_info parameter Tamizh chelvam
@ 2018-03-27  6:48 ` Tamizh chelvam
  2018-03-27  6:48 ` [RFC 3/3] mac80211: Use proper chan_width " Tamizh chelvam
  2018-03-27 12:56 ` [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value Johannes Berg
  3 siblings, 0 replies; 6+ messages in thread
From: Tamizh chelvam @ 2018-03-27  6:48 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Tamizh chelvam

SMPS_MODE change value notified via nl80211 contains mac80211
specific value(ieee80211_smps_mode) and user space application
will not know those values. This patch add support to map
the mac80211 enum value to nl80211_smps_mode which will be
understood by the userspace application.

Signed-off-by: Tamizh chelvam <tamizhr@codeaurora.org>
---
 net/mac80211/ht.c          | 15 +++++++++++++++
 net/mac80211/ieee80211_i.h |  2 ++
 net/mac80211/rx.c          |  3 ++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c
index d752353..c78036a 100644
--- a/net/mac80211/ht.c
+++ b/net/mac80211/ht.c
@@ -466,6 +466,21 @@ void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
 		__ieee80211_stop_tx_ba_session(sta, tid, AGG_STOP_PEER_REQUEST);
 }
 
+enum nl80211_smps_mode
+ieee80211_smps_mode_to_smps_mode(enum ieee80211_smps_mode smps)
+{
+	switch (smps) {
+	case IEEE80211_SMPS_OFF:
+		return NL80211_SMPS_OFF;
+	case IEEE80211_SMPS_STATIC:
+		return NL80211_SMPS_STATIC;
+	case IEEE80211_SMPS_DYNAMIC:
+		return NL80211_SMPS_DYNAMIC;
+	default:
+		return NL80211_SMPS_OFF;
+	}
+}
+
 int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
 			       enum ieee80211_smps_mode smps, const u8 *da,
 			       const u8 *bssid)
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index ae9c33c..9237ffb 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1788,6 +1788,8 @@ void ieee80211_stop_tx_ba_cb(struct sta_info *sta, int tid,
 void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
 
 u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
+enum nl80211_smps_mode
+ieee80211_smps_mode_to_smps_mode(enum ieee80211_smps_mode smps);
 
 /* VHT */
 void
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 27bb1f0..f8c69ac 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2883,7 +2883,8 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata,
 			if (rx->sta->sta.smps_mode == smps_mode)
 				goto handled;
 			rx->sta->sta.smps_mode = smps_mode;
-			sta_opmode.smps_mode = smps_mode;
+			sta_opmode.smps_mode =
+				ieee80211_smps_mode_to_smps_mode(smps_mode);
 			sta_opmode.changed = STA_OPMODE_SMPS_MODE_CHANGED;
 
 			sband = rx->local->hw.wiphy->bands[status->band];
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC 3/3] mac80211: Use proper chan_width enum in sta opmode event
  2018-03-27  6:48 [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value Tamizh chelvam
  2018-03-27  6:48 ` [RFC 1/3] cfg80211: fix data type of sta_opmode_info parameter Tamizh chelvam
  2018-03-27  6:48 ` [RFC 2/3] mac80211: Use proper smps_mode enum in sta opmode event Tamizh chelvam
@ 2018-03-27  6:48 ` Tamizh chelvam
  2018-03-27 12:56 ` [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value Johannes Berg
  3 siblings, 0 replies; 6+ messages in thread
From: Tamizh chelvam @ 2018-03-27  6:48 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Tamizh chelvam

Bandwidth change value reported via nl80211 contains mac80211
specific enum value(ieee80211_sta_rx_bw) and which is not
understand by userspace application. Map the mac80211 specific
value to nl80211_chan_width enum value to avoid using wrong value
in the userspace application. And used station's ht/vht capability
to map IEEE80211_STA_RX_BW_20 and IEEE80211_STA_RX_BW_160 with
proper nl80211 value.

Signed-off-by: Tamizh chelvam <tamizhr@codeaurora.org>
---
 net/mac80211/ieee80211_i.h |  2 ++
 net/mac80211/rx.c          |  3 ++-
 net/mac80211/vht.c         | 32 +++++++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 9237ffb..6c341d8 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1816,6 +1816,8 @@ void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
 				      struct ieee80211_sta_vht_cap *vht_cap);
 void ieee80211_get_vht_mask_from_cap(__le16 vht_cap,
 				     u16 vht_mask[NL80211_VHT_NSS_MAX]);
+enum nl80211_chan_width
+ieee80211_sta_rx_bw_to_chan_width(struct sta_info *sta);
 
 /* Spectrum management */
 void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index f8c69ac..3a9f0c0 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2922,7 +2922,8 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata,
 
 			rx->sta->sta.bandwidth = new_bw;
 			sband = rx->local->hw.wiphy->bands[status->band];
-			sta_opmode.bw = new_bw;
+			sta_opmode.bw =
+				ieee80211_sta_rx_bw_to_chan_width(rx->sta);
 			sta_opmode.changed = STA_OPMODE_MAX_BW_CHANGED;
 
 			rate_control_rate_update(local, sband, rx->sta,
diff --git a/net/mac80211/vht.c b/net/mac80211/vht.c
index 5714dee..259325c 100644
--- a/net/mac80211/vht.c
+++ b/net/mac80211/vht.c
@@ -358,6 +358,36 @@ enum nl80211_chan_width ieee80211_sta_cap_chan_bw(struct sta_info *sta)
 	return NL80211_CHAN_WIDTH_80;
 }
 
+enum nl80211_chan_width
+ieee80211_sta_rx_bw_to_chan_width(struct sta_info *sta)
+{
+	enum ieee80211_sta_rx_bandwidth cur_bw = sta->sta.bandwidth;
+	struct ieee80211_sta_vht_cap *vht_cap = &sta->sta.vht_cap;
+	u32 cap_width;
+
+	switch (cur_bw) {
+	case IEEE80211_STA_RX_BW_20:
+		if (!sta->sta.ht_cap.ht_supported)
+			return NL80211_CHAN_WIDTH_20_NOHT;
+		else
+			return NL80211_CHAN_WIDTH_20;
+	case IEEE80211_STA_RX_BW_40:
+		return NL80211_CHAN_WIDTH_40;
+	case IEEE80211_STA_RX_BW_80:
+		return NL80211_CHAN_WIDTH_80;
+	case IEEE80211_STA_RX_BW_160:
+		cap_width =
+			vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK;
+
+		if (cap_width == IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ)
+			return NL80211_CHAN_WIDTH_160;
+
+		return NL80211_CHAN_WIDTH_80P80;
+	default:
+		return NL80211_CHAN_WIDTH_20;
+	}
+}
+
 enum ieee80211_sta_rx_bandwidth
 ieee80211_chan_width_to_rx_bw(enum nl80211_chan_width width)
 {
@@ -484,7 +514,7 @@ u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
 	new_bw = ieee80211_sta_cur_vht_bw(sta);
 	if (new_bw != sta->sta.bandwidth) {
 		sta->sta.bandwidth = new_bw;
-		sta_opmode.bw = new_bw;
+		sta_opmode.bw = ieee80211_sta_rx_bw_to_chan_width(sta);
 		changed |= IEEE80211_RC_BW_CHANGED;
 		sta_opmode.changed |= STA_OPMODE_MAX_BW_CHANGED;
 	}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value
  2018-03-27  6:48 [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value Tamizh chelvam
                   ` (2 preceding siblings ...)
  2018-03-27  6:48 ` [RFC 3/3] mac80211: Use proper chan_width " Tamizh chelvam
@ 2018-03-27 12:56 ` Johannes Berg
  2018-03-27 13:12   ` Tamizh chelvam
  3 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2018-03-27 12:56 UTC (permalink / raw)
  To: Tamizh chelvam; +Cc: linux-wireless

On Tue, 2018-03-27 at 12:18 +0530, Tamizh chelvam wrote:
> Currently bw and smps_mode are u8 type value in sta_opmode_info
> structure. This values filled in mac80211 from ieee80211_sta_rx_bandwidth
> and ieee80211_smps_mode. These enum values are specific to mac80211 and
> userspace/cfg80211 doesn't know about that. This patchset change its
> data type in the sta_opmode_info structure and mapping from mac80211
> specific enum to nl80211 enum value.

Good catch.

> Tamizh chelvam (3):
>   cfg80211: fix data type of sta_opmode_info parameter
>   mac80211: Use proper smps_mode enum in sta opmode event
>   mac80211: Use proper chan_width enum in sta opmode event
> 
> Note :
>   * Is this mac80211 approach sufficient ? or whether some more
>     complete cleanup would be preferred ?

Not sure what you mean? The patches look good to me.

johannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value
  2018-03-27 12:56 ` [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value Johannes Berg
@ 2018-03-27 13:12   ` Tamizh chelvam
  0 siblings, 0 replies; 6+ messages in thread
From: Tamizh chelvam @ 2018-03-27 13:12 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On 2018-03-27 18:26, Johannes Berg wrote:
> On Tue, 2018-03-27 at 12:18 +0530, Tamizh chelvam wrote:
>> Currently bw and smps_mode are u8 type value in sta_opmode_info
>> structure. This values filled in mac80211 from 
>> ieee80211_sta_rx_bandwidth
>> and ieee80211_smps_mode. These enum values are specific to mac80211 
>> and
>> userspace/cfg80211 doesn't know about that. This patchset change its
>> data type in the sta_opmode_info structure and mapping from mac80211
>> specific enum to nl80211 enum value.
> 
> Good catch.
> 
>> Tamizh chelvam (3):
>>   cfg80211: fix data type of sta_opmode_info parameter
>>   mac80211: Use proper smps_mode enum in sta opmode event
>>   mac80211: Use proper chan_width enum in sta opmode event
>> 
>> Note :
>>   * Is this mac80211 approach sufficient ? or whether some more
>>     complete cleanup would be preferred ?
> 
> Not sure what you mean? The patches look good to me.
> 
I just wanted to confirm is this approach fine or not! I'll send a patch 
format

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-03-27 13:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27  6:48 [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value Tamizh chelvam
2018-03-27  6:48 ` [RFC 1/3] cfg80211: fix data type of sta_opmode_info parameter Tamizh chelvam
2018-03-27  6:48 ` [RFC 2/3] mac80211: Use proper smps_mode enum in sta opmode event Tamizh chelvam
2018-03-27  6:48 ` [RFC 3/3] mac80211: Use proper chan_width " Tamizh chelvam
2018-03-27 12:56 ` [RFC 0/3] cfg80211/mac80211: Notify proper sta opmode change value Johannes Berg
2018-03-27 13:12   ` Tamizh chelvam

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).