ath9k_htc: Add support for NL80211_IFTYPE_MESH_POINT interfaces
RFC 1/1 ath9k_htc: Add support for NL80211_IFTYPE_MESH_POINT interfaces
More specifically, enable AP-style beaconing on mesh ifaces, honor FIF_OTHER_BSS filter and change the hw capabilities to reflect mesh support.
Tested on two TP-Link TL-WN821N and with this patch we could establish peer links and ping.
--- drivers/net/wireless/ath/ath9k/htc.h | 7 +++++++ drivers/net/wireless/ath/ath9k/htc_drv_beacon.c | 8 +++++++- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 3 ++- drivers/net/wireless/ath/ath9k/htc_drv_main.c | 13 +++++++++++++ drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 3 +++ 5 files changed, 32 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/htc.h +7 -0
@@ -219,6 +219,9 @@ struct ath9k_htc_target_rx_stats {case NL80211_IFTYPE_AP : \ _priv->num_ap_vif++; \break ; \ +case NL80211_IFTYPE_MESH_POINT : \ + _priv->num_mbss_vif++; \ +break ; \default : \break ; \ } \
@@ -235,6 +238,9 @@ struct ath9k_htc_target_rx_stats {case NL80211_IFTYPE_AP : \ _priv->num_ap_vif--; \break ; \ +case NL80211_IFTYPE_MESH_POINT : \ + _priv->num_mbss_vif--; \ +break ; \default : \break ; \ } \
@@ -449,6 +455,7 @@ struct ath9k_htc_priv {u8 sta_slot;u8 vif_sta_pos[ATH9K_HTC_MAX_VIF ];u8 num_ibss_vif; +u8 num_mbss_vif;u8 num_sta_vif;u8 num_ap_vif;
drivers/net/wireless/ath/ath9k/htc_drv_beacon.c +7 -1
@@ -28,7 +28,8 @@ void ath9k_htc_beaconq_config(struct ath9k_htc_priv *priv)ath9k_hw_get_txq_props (ah, priv->beaconq, &qi); -if (priv->ah->opmode ==NL80211_IFTYPE_AP ) { +if (priv->ah->opmode ==NL80211_IFTYPE_AP || + priv->ah->opmode ==NL80211_IFTYPE_MESH_POINT ) { qi.tqi_aifs =1 ; qi.tqi_cwmin =0 ; qi.tqi_cwmax =0 ;
@@ -633,6 +634,11 @@ void ath9k_htc_beacon_config(struct ath9k_htc_priv *priv,case NL80211_IFTYPE_ADHOC :ath9k_htc_beacon_config_adhoc (priv, cur_conf);break ; +case NL80211_IFTYPE_MESH_POINT : +/* 802.11s defines a different beaconing method for mesh points +* that closely resembles AP-style beaconing. Until that is +* implemented, just use AP-style beaconing for mesh points. */ +/* Fall through */ case NL80211_IFTYPE_AP :ath9k_htc_beacon_config_ap (priv, cur_conf);break ;
drivers/net/wireless/ath/ath9k/htc_drv_init.c +2 -1
@@ -761,7 +761,8 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv,BIT (NL80211_IFTYPE_ADHOC ) |BIT (NL80211_IFTYPE_AP ) |BIT (NL80211_IFTYPE_P2P_GO ) | -BIT (NL80211_IFTYPE_P2P_CLIENT ); +BIT (NL80211_IFTYPE_P2P_CLIENT ) | +BIT (NL80211_IFTYPE_MESH_POINT ); hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT ;
drivers/net/wireless/ath/ath9k/htc_drv_main.c +13 -0
@@ -171,6 +171,8 @@ static void ath9k_htc_set_opmode(struct ath9k_htc_priv *priv) priv->ah->opmode =NL80211_IFTYPE_ADHOC ; else if (priv->num_ap_vif) priv->ah->opmode = NL80211_IFTYPE_AP; + else if (priv->num_mbss_vif) + priv->ah->opmode = NL80211_IFTYPE_MESH_POINT; else priv->ah->opmode = NL80211_IFTYPE_STATION;
@@ -1056,6 +1058,13 @@ static int ath9k_htc_add_interface(struct ieee80211_hw *hw,return -ENOBUFS ; } +if (priv->num_mbss_vif || + (priv->nvifs && vif->type ==NL80211_IFTYPE_MESH_POINT )) { +ath_err (common,"Mesh BSS coexistence with other modes is not allowed\n" ); +mutex_unlock (&priv->mutex); +return -ENOBUFS ; + } +if (((vif->type ==NL80211_IFTYPE_AP ) || (vif->type ==NL80211_IFTYPE_ADHOC )) && ((priv->num_ap_vif + priv->num_ibss_vif) >=ATH9K_HTC_MAX_BCN_VIF )) {
@@ -1078,6 +1087,9 @@ static int ath9k_htc_add_interface(struct ieee80211_hw *hw,case NL80211_IFTYPE_AP : hvif.opmode =HTC_M_HOSTAP ;break ; +case NL80211_IFTYPE_MESH_POINT : + hvif.opmode =HTC_M_WDS ;/* close enough */ +break ;default :ath_err (common,"Interface type %d not yet supported\n" , vif->type);
@@ -1110,6 +1122,7 @@ static int ath9k_htc_add_interface(struct ieee80211_hw *hw,INC_VIF (priv, vif->type);if ((vif->type ==NL80211_IFTYPE_AP ) || + (vif->type ==NL80211_IFTYPE_MESH_POINT ) || (vif->type ==NL80211_IFTYPE_ADHOC ))ath9k_htc_assign_bslot (priv, vif);
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +3 -0
@@ -888,6 +888,9 @@ u32 ath9k_htc_calcrxfilter(struct ath9k_htc_priv *priv)if (priv->rxfilter &FIF_PSPOLL ) rfilt |=ATH9K_RX_FILTER_PSPOLL ; +if (priv->rxfilter &FIF_OTHER_BSS ) + rfilt |=ATH9K_RX_FILTER_MCAST_BCAST_ALL ; +return rfilt;#undef RX_FILTER_PRESERVE
Signature · 1 line
1.7.1
Hello!
You may want to copy to linux-wireless as well. You'll get more eyeballs looking at your code.
Quoted 6 lines · Javier Cardona
More specifically, enable AP-style beaconing on mesh ifaces, honor
FIF_OTHER_BSSfilter and change the hw capabilities to reflect mesh support.Tested on two TP-Link TL-WN821N and with this patch we could establish peer links and ping.
...
drivers/net/wireless/ath/ath9k/htc_drv_beacon.c void ath9k_htc_beacon_config(struct ath9k_htc_priv *priv, · line 643
Quoted 7 lines
drivers/net/wireless/ath/ath9k/htc_drv_beacon.c +5
-0+case NL80211_IFTYPE_MESH_POINT : +/* 802.11s defines a different beaconing method for mesh points +* that closely resembles AP-style beaconing. Until that is +* implemented, just use AP-style beaconing for mesh points. */ +/* Fall through */ case NL80211_IFTYPE_AP :ath9k_htc_beacon_config_ap (priv, cur_conf);
Is it fundamentally impossible for AP and mesh VIFs to coexist? If it's possible, you may want to use NL80211_IFTYPE_AP even if there is a mesh VIF and use num_ap_vif and num_mbss_vif to code needed for AP and mesh respectively.
Having distinct global opmodes would stand in the way if AP and mesh coexistence is to be implemented.
By the way, we may want to use distinctive names for the common opmodes to avoid confusion with the VIF modes.
drivers/net/wireless/ath/ath9k/htc_drv_main.c static int ath9k_htc_add_interface(struct ieee80211_hw *hw, · line 1066
Quoted 6 lines
drivers/net/wireless/ath/ath9k/htc_drv_main.c +6
-0+if (priv->num_mbss_vif || + (priv->nvifs&& vif->type ==NL80211_IFTYPE_MESH_POINT )) { +ath_err (common,"Mesh BSS coexistence with other modes is not allowed\n" ); +mutex_unlock (&priv->mutex); +return -ENOBUFS ; + }
This code appears to allow only one mesh interface. Is that your intention? I think you just copied the code from Ad-Hoc without realizing what it does.
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (priv->rxfilter& FIF_OTHER_BSS) + rfilt |= ATH9K_RX_FILTER_MCAST_BCAST_ALL;
I think this could be a separate patch. It may have effect beyond mesh support.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 4 lines · Pavel Roskin
Hello!
You may want to copy to linux-wireless as well. ?You'll get more eyeballs looking at your code.
Thanks for reviewing.
Quoted 23 lines · Javier Cardona
Quoted 8 lines
More specifically, enable AP-style beaconing on mesh ifaces, honor
FIF_OTHER_BSSfilter and change the hw capabilities to reflect mesh support.Tested on two TP-Link TL-WN821N and with this patch we could establish peer
links and ping....
Quoted 11 lines
+ ? ? ? case
NL80211_IFTYPE_MESH_POINT:
+ ? ? ? ? ? ? ? /* 802.11s defines a different beaconing method for mesh points
+ ? ? ? ? ? ? ? ?* that closely resembles AP-style beaconing. ?Until that is
+ ? ? ? ? ? ? ? ?* implemented, just use AP-style beaconing for mesh points. */
+ ? ? ? ? ? ? ? /* Fall through */
? ? ? ?caseNL80211_IFTYPE_AP:
? ? ? ? ? ? ? ?ath9k_htc_beacon_config_ap(priv,cur_conf);
Quoted 4 lines
Is it fundamentally impossible for AP and mesh VIFs to coexist? ?If it's possible, you may want to use
NL80211_IFTYPE_APeven if there is a mesh VIF and usenum_ap_vifandnum_mbss_vifto code needed for AP and mesh respectively.
It is not precluded by the standard, but requires that the hardware can do dual-beaconing given that mesh and AP beacons are different:
different MAC address, frequency. etc.
Quoted 2 lines
Having distinct global opmodes would stand in the way if AP and mesh coexistence is to be implemented.
Noted. It is definitively a doable and desired use case so we plan the driver as if there will soon be hardware that can do it. (Or maybe there is, do you know?)
Quoted 11 lines
By the way, we may want to use distinctive names for the common opmodes to avoid confusion with the VIF modes.
Quoted 7 lines
+ ? ? ? if (
priv->num_mbss_vif||
+ ? ? ? ? ? (priv->nvifs&& ?vif->type ==NL80211_IFTYPE_MESH_POINT)) {
+ ? ? ? ? ? ? ?ath_err(common, "Mesh BSS coexistence with other modes is not allowed\n");
+ ? ? ? ? ? ? ?mutex_unlock(&priv->mutex);
+ ? ? ? ? ? ? ? return-ENOBUFS;
+ ? ? ? }
Quoted 3 lines
This code appears to allow only one mesh interface. ?Is that your intention? ?I think you just copied the code from Ad-Hoc without realizing what it does.
Again I thought the hardware could not do dual beaconning. If it can, then there is no need to limit the number of mesh vifs.
Quoted 5 lines
Quoted 2 lines
+ ? ? ? if (priv->rxfilter& ?FIF_OTHER_BSS)
+ ? ? ? ? ? ? ? rfilt |=ATH9K_RX_FILTER_MCAST_BCAST_ALL;I think this could be a separate patch. ?It may have effect beyond mesh support.
Noted.
Thanks!
Javier
Signature · 3 lines
Javier Cardona cozybit Inc. http://www.cozybit.com