From 72b5d58a2a25b47122e2b9fe96fcc9822af2ccf1 Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Sun, 24 Mar 2013 00:53:15 +0000
Subject: [PATCH] mac80211: update brcmsmac ap patches

SVN-Revision: 36113
---
 ...62-brcmsmac-remove-brcms_bss_cfg-BSS.patch | 10 ++-
 ...smac-remove-brcms_bss_cfg-associated.patch |  2 +-
 ...865-brcmsmac-remove-brcms_bss_cfg-up.patch | 18 +++--
 ...brcmsmac-add-beacon-template-support.patch | 12 +--
 ...-support-for-probe-response-template.patch | 14 ++--
 ...tivate-ucode-sending-probe-responses.patch | 59 +++++++++++++++
 ...=> 873-brcmsmac-activate-AP-support.patch} | 17 +++--
 ...-brcmsmac-add-support-for-adhoc-mode.patch | 74 +++++++++++++++++++
 ...remove-extra-regulation-restriction.patch} |  0
 9 files changed, 175 insertions(+), 31 deletions(-)
 create mode 100644 package/mac80211/patches/872-brcmsmac-deactivate-ucode-sending-probe-responses.patch
 rename package/mac80211/patches/{872-brcmsmac-activate-AP-support.patch => 873-brcmsmac-activate-AP-support.patch} (86%)
 create mode 100644 package/mac80211/patches/874-brcmsmac-add-support-for-adhoc-mode.patch
 rename package/mac80211/patches/{873-brcmsmac-remove-extra-regulation-restriction.patch => 875-brcmsmac-remove-extra-regulation-restriction.patch} (100%)

diff --git a/package/mac80211/patches/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch b/package/mac80211/patches/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch
index a7ffcf6a78..1fafd63a28 100644
--- a/package/mac80211/patches/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch
+++ b/package/mac80211/patches/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch
@@ -39,21 +39,23 @@
  					brcms_err(wlc->hw->d11core,
  						  "wl%d: up: rfdisable -> "
  						  "bsscfg_disable()\n",
-@@ -7390,7 +7383,7 @@ void brcms_c_update_beacon(struct brcms_
+@@ -7390,7 +7383,8 @@ void brcms_c_update_beacon(struct brcms_
  {
  	struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
  
 -	if (bsscfg->up && !bsscfg->BSS)
-+	if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
++	if (bsscfg->up && (bsscfg->type == BRCMS_TYPE_AP ||
++			   bsscfg->type == BRCMS_TYPE_ADHOC))
  		/* Clear the soft intmask */
  		wlc->defmacintmask &= ~MI_BCNTPL;
  }
-@@ -7465,7 +7458,7 @@ void brcms_c_update_probe_resp(struct br
+@@ -7465,7 +7459,8 @@ void brcms_c_update_probe_resp(struct br
  	struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
  
  	/* update AP or IBSS probe responses */
 -	if (bsscfg->up && !bsscfg->BSS)
-+	if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
++	if (bsscfg->up && (bsscfg->type == BRCMS_TYPE_AP ||
++			   bsscfg->type == BRCMS_TYPE_ADHOC))
  		brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
  }
  
diff --git a/package/mac80211/patches/863-brcmsmac-remove-brcms_bss_cfg-associated.patch b/package/mac80211/patches/863-brcmsmac-remove-brcms_bss_cfg-associated.patch
index 7f84f00e29..79a4b688d6 100644
--- a/package/mac80211/patches/863-brcmsmac-remove-brcms_bss_cfg-associated.patch
+++ b/package/mac80211/patches/863-brcmsmac-remove-brcms_bss_cfg-associated.patch
@@ -46,7 +46,7 @@
  			mcsset_bss = wlc->bsscfg->current_bss;
  		else
  			mcsset_bss = wlc->default_bss;
-@@ -7498,7 +7493,6 @@ void brcms_c_scan_stop(struct brcms_c_in
+@@ -7500,7 +7495,6 @@ void brcms_c_scan_stop(struct brcms_c_in
  void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state)
  {
  	wlc->pub->associated = state;
diff --git a/package/mac80211/patches/865-brcmsmac-remove-brcms_bss_cfg-up.patch b/package/mac80211/patches/865-brcmsmac-remove-brcms_bss_cfg-up.patch
index 40fe6eaf6e..b596d799f6 100644
--- a/package/mac80211/patches/865-brcmsmac-remove-brcms_bss_cfg-up.patch
+++ b/package/mac80211/patches/865-brcmsmac-remove-brcms_bss_cfg-up.patch
@@ -1,24 +1,28 @@
 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
-@@ -7377,7 +7377,7 @@ void brcms_c_update_beacon(struct brcms_
+@@ -7377,8 +7377,8 @@ void brcms_c_update_beacon(struct brcms_
  {
  	struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
  
--	if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
-+	if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
+-	if (bsscfg->up && (bsscfg->type == BRCMS_TYPE_AP ||
+-			   bsscfg->type == BRCMS_TYPE_ADHOC))
++	if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP ||
++			     bsscfg->type == BRCMS_TYPE_ADHOC))
  		/* Clear the soft intmask */
  		wlc->defmacintmask &= ~MI_BCNTPL;
  }
-@@ -7452,7 +7452,7 @@ void brcms_c_update_probe_resp(struct br
+@@ -7453,8 +7453,8 @@ void brcms_c_update_probe_resp(struct br
  	struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
  
  	/* update AP or IBSS probe responses */
--	if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
-+	if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
+-	if (bsscfg->up && (bsscfg->type == BRCMS_TYPE_AP ||
+-			   bsscfg->type == BRCMS_TYPE_ADHOC))
++	if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP ||
++			     bsscfg->type == BRCMS_TYPE_ADHOC))
  		brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
  }
  
-@@ -7805,7 +7805,7 @@ void brcms_c_init(struct brcms_c_info *w
+@@ -7807,7 +7807,7 @@ void brcms_c_init(struct brcms_c_info *w
  	brcms_c_set_bssid(wlc->bsscfg);
  
  	/* Update tsf_cfprep if associated and up */
diff --git a/package/mac80211/patches/869-brcmsmac-add-beacon-template-support.patch b/package/mac80211/patches/869-brcmsmac-add-beacon-template-support.patch
index ab864a3dbf..7ea09a8540 100644
--- a/package/mac80211/patches/869-brcmsmac-add-beacon-template-support.patch
+++ b/package/mac80211/patches/869-brcmsmac-add-beacon-template-support.patch
@@ -170,12 +170,12 @@
  /*
   * Update all beacons for the system.
   */
-@@ -7386,9 +7494,31 @@ void brcms_c_update_beacon(struct brcms_
- {
+@@ -7387,9 +7495,31 @@ void brcms_c_update_beacon(struct brcms_
  	struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
  
--	if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
-+	if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP) {
+ 	if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP ||
+-			     bsscfg->type == BRCMS_TYPE_ADHOC))
++			     bsscfg->type == BRCMS_TYPE_ADHOC)) {
  		/* Clear the soft intmask */
  		wlc->defmacintmask &= ~MI_BCNTPL;
 +		if (!wlc->beacon)
@@ -203,7 +203,7 @@
  }
  
  /* Write ssid into shared memory */
-@@ -7786,6 +7916,10 @@ bool brcms_c_dpc(struct brcms_c_info *wl
+@@ -7788,6 +7918,10 @@ bool brcms_c_dpc(struct brcms_c_info *wl
  		brcms_rfkill_set_hw_state(wlc->wl);
  	}
  
@@ -214,7 +214,7 @@
  	/* it isn't done and needs to be resched if macintstatus is non-zero */
  	return wlc->macintstatus != 0;
  
-@@ -7917,6 +8051,7 @@ brcms_c_attach(struct brcms_info *wl, st
+@@ -7919,6 +8053,7 @@ brcms_c_attach(struct brcms_info *wl, st
  	pub->unit = unit;
  	pub->_piomode = piomode;
  	wlc->bandinit_pending = false;
diff --git a/package/mac80211/patches/871-brcmsmac-add-support-for-probe-response-template.patch b/package/mac80211/patches/871-brcmsmac-add-support-for-probe-response-template.patch
index 5d022d2b57..38d3648a8d 100644
--- a/package/mac80211/patches/871-brcmsmac-add-support-for-probe-response-template.patch
+++ b/package/mac80211/patches/871-brcmsmac-add-support-for-probe-response-template.patch
@@ -106,7 +106,7 @@
  int brcms_c_get_header_len(void)
  {
  	return TXOFF;
-@@ -7530,6 +7469,20 @@ void brcms_c_set_new_beacon(struct brcms
+@@ -7531,6 +7470,20 @@ void brcms_c_set_new_beacon(struct brcms
  	brcms_c_update_beacon(wlc);
  }
  
@@ -127,7 +127,7 @@
  /* Write ssid into shared memory */
  static void
  brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg)
-@@ -7549,30 +7502,19 @@ brcms_c_shm_ssid_upd(struct brcms_c_info
+@@ -7550,30 +7503,19 @@ brcms_c_shm_ssid_upd(struct brcms_c_info
  static void
  brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc,
  			      struct brcms_bss_cfg *cfg,
@@ -162,7 +162,7 @@
  
  	/* write the length of the probe response frame (+PLCP/-FCS) */
  	brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len);
-@@ -7586,13 +7528,11 @@ brcms_c_bss_update_probe_resp(struct brc
+@@ -7587,13 +7529,11 @@ brcms_c_bss_update_probe_resp(struct brc
  	 * PLCP header for the call to brcms_c_mod_prb_rsp_rate_table()
  	 * by subtracting the PLCP len and adding the FCS.
  	 */
@@ -178,13 +178,13 @@
  }
  
  void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend)
-@@ -7600,8 +7540,12 @@ void brcms_c_update_probe_resp(struct br
- 	struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+@@ -7602,8 +7542,12 @@ void brcms_c_update_probe_resp(struct br
  
  	/* update AP or IBSS probe responses */
--	if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
+ 	if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP ||
+-			     bsscfg->type == BRCMS_TYPE_ADHOC))
 -		brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
-+	if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP) {
++			     bsscfg->type == BRCMS_TYPE_ADHOC)) {
 +		if (!wlc->probe_resp)
 +			return;
 +		brcms_c_bss_update_probe_resp(wlc, bsscfg, wlc->probe_resp,
diff --git a/package/mac80211/patches/872-brcmsmac-deactivate-ucode-sending-probe-responses.patch b/package/mac80211/patches/872-brcmsmac-deactivate-ucode-sending-probe-responses.patch
new file mode 100644
index 0000000000..9c150b1547
--- /dev/null
+++ b/package/mac80211/patches/872-brcmsmac-deactivate-ucode-sending-probe-responses.patch
@@ -0,0 +1,59 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -554,6 +554,12 @@ brcms_ops_bss_info_changed(struct ieee80
+ 		/* Beaconing should be enabled/disabled (beaconing modes) */
+ 		brcms_err(core, "%s: Beacon enabled: %s\n", __func__,
+ 			  info->enable_beacon ? "true" : "false");
++		if (info->enable_beacon &&
++		    hw->wiphy->flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) {
++			brcms_c_enable_probe_resp(wl->wlc, true);
++		} else {
++			brcms_c_enable_probe_resp(wl->wlc, false);
++		}
+ 	}
+ 
+ 	if (changed & BSS_CHANGED_CQM) {
+@@ -1048,7 +1054,12 @@ static int ieee_hw_init(struct ieee80211
+ 	hw->channel_change_time = 7 * 1000;
+ 	hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+ 
+-	hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
++	/*
++	 * deactivate sending probe responses by ucude, because this will
++	 * cause problems when WPS is used.
++	 *
++	 * hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
++	 */
+ 
+ 	hw->rate_control_algorithm = "minstrel_ht";
+ 
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -7484,6 +7484,17 @@ void brcms_c_set_new_probe_resp(struct b
+ 	brcms_c_update_probe_resp(wlc, false);
+ }
+ 
++void brcms_c_enable_probe_resp(struct brcms_c_info *wlc, bool enable)
++{
++	/*
++	 * prevent ucode from sending probe responses by setting the timeout
++	 * to 1, it can not send it in that time frame.
++	 */
++	wlc->prb_resp_timeout = enable ? BRCMS_PRB_RESP_TIMEOUT : 1;
++	brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout);
++	/* TODO: if (enable) => also deactivate receiving of probe request */
++}
++
+ /* Write ssid into shared memory */
+ static void
+ brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg)
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -338,6 +338,7 @@ extern void brcms_c_set_new_beacon(struc
+ 				   u16 dtim_period);
+ extern void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc,
+ 				       struct sk_buff *probe_resp);
++extern void brcms_c_enable_probe_resp(struct brcms_c_info *wlc, bool enable);
+ extern void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid,
+ 			     size_t ssid_len);
+ 
diff --git a/package/mac80211/patches/872-brcmsmac-activate-AP-support.patch b/package/mac80211/patches/873-brcmsmac-activate-AP-support.patch
similarity index 86%
rename from package/mac80211/patches/872-brcmsmac-activate-AP-support.patch
rename to package/mac80211/patches/873-brcmsmac-activate-AP-support.patch
index aaf6840c56..83b3aa808e 100644
--- a/package/mac80211/patches/872-brcmsmac-activate-AP-support.patch
+++ b/package/mac80211/patches/873-brcmsmac-activate-AP-support.patch
@@ -1,15 +1,20 @@
 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
 +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
-@@ -360,7 +360,8 @@ brcms_ops_add_interface(struct ieee80211
+@@ -359,10 +359,11 @@ brcms_ops_add_interface(struct ieee80211
+ {
  	struct brcms_info *wl = hw->priv;
  
- 	/* Just STA for now */
+-	/* Just STA for now */
 -	if (vif->type != NL80211_IFTYPE_STATION) {
++	/* Just STA and AP for now */
 +	if (vif->type != NL80211_IFTYPE_STATION &&
 +	    vif->type != NL80211_IFTYPE_AP) {
  		brcms_err(wl->wlc->hw->d11core,
- 			  "%s: Attempt to add type %d, only STA for now\n",
+-			  "%s: Attempt to add type %d, only STA for now\n",
++			  "%s: Attempt to add type %d, only STA and AP for now\n",
  			  __func__, vif->type);
+ 		return -EOPNOTSUPP;
+ 	}
 @@ -372,6 +373,9 @@ brcms_ops_add_interface(struct ieee80211
  	brcms_c_mute(wl->wlc, false);
  	if (vif->type == NL80211_IFTYPE_STATION)
@@ -20,7 +25,7 @@
  	spin_unlock_bh(&wl->lock);
  
  	return 0;
-@@ -1046,7 +1050,8 @@ static int ieee_hw_init(struct ieee80211
+@@ -1052,7 +1056,8 @@ static int ieee_hw_init(struct ieee80211
  
  	/* channel change time is dependent on chip and band  */
  	hw->channel_change_time = 7 * 1000;
@@ -28,8 +33,8 @@
 +	hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
 +				     BIT(NL80211_IFTYPE_AP);
  
- 	hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
- 
+ 	/*
+ 	 * deactivate sending probe responses by ucude, because this will
 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
 @@ -2176,6 +2176,18 @@ void brcms_c_start_station(struct brcms_
diff --git a/package/mac80211/patches/874-brcmsmac-add-support-for-adhoc-mode.patch b/package/mac80211/patches/874-brcmsmac-add-support-for-adhoc-mode.patch
new file mode 100644
index 0000000000..d1c740793a
--- /dev/null
+++ b/package/mac80211/patches/874-brcmsmac-add-support-for-adhoc-mode.patch
@@ -0,0 +1,74 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -359,11 +359,12 @@ brcms_ops_add_interface(struct ieee80211
+ {
+ 	struct brcms_info *wl = hw->priv;
+ 
+-	/* Just STA and AP for now */
++	/* Just STA, AP and ADHOC for now */
+ 	if (vif->type != NL80211_IFTYPE_STATION &&
+-	    vif->type != NL80211_IFTYPE_AP) {
++	    vif->type != NL80211_IFTYPE_AP &&
++	    vif->type != NL80211_IFTYPE_ADHOC) {
+ 		brcms_err(wl->wlc->hw->d11core,
+-			  "%s: Attempt to add type %d, only STA and AP for now\n",
++			  "%s: Attempt to add type %d, only STA, AP and AdHoc for now\n",
+ 			  __func__, vif->type);
+ 		return -EOPNOTSUPP;
+ 	}
+@@ -376,6 +377,8 @@ brcms_ops_add_interface(struct ieee80211
+ 	else if (vif->type == NL80211_IFTYPE_AP)
+ 		brcms_c_start_ap(wl->wlc, vif->addr, vif->bss_conf.bssid,
+ 				 vif->bss_conf.ssid, vif->bss_conf.ssid_len);
++	else if (vif->type == NL80211_IFTYPE_ADHOC)
++		brcms_c_start_adhoc(wl->wlc, vif->addr);
+ 	spin_unlock_bh(&wl->lock);
+ 
+ 	return 0;
+@@ -1057,7 +1060,8 @@ static int ieee_hw_init(struct ieee80211
+ 	/* channel change time is dependent on chip and band  */
+ 	hw->channel_change_time = 7 * 1000;
+ 	hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
+-				     BIT(NL80211_IFTYPE_AP);
++				     BIT(NL80211_IFTYPE_AP) |
++				     BIT(NL80211_IFTYPE_ADHOC);
+ 
+ 	/*
+ 	 * deactivate sending probe responses by ucude, because this will
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -2188,6 +2188,14 @@ void brcms_c_start_ap(struct brcms_c_inf
+ 	brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, MCTL_AP | MCTL_INFRA);
+ }
+ 
++void brcms_c_start_adhoc(struct brcms_c_info *wlc, u8 *addr)
++{
++	memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr));
++	wlc->bsscfg->type = BRCMS_TYPE_ADHOC;
++
++	brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, 0);
++}
++
+ /* Initialize GPIOs that are controlled by D11 core */
+ static void brcms_c_gpio_init(struct brcms_c_info *wlc)
+ {
+@@ -3079,6 +3087,9 @@ static bool brcms_c_ps_allowed(struct br
+ 	if (wlc->bsscfg->type == BRCMS_TYPE_AP)
+ 		return false;
+ 
++	if (wlc->bsscfg->type == BRCMS_TYPE_ADHOC)
++		return false;
++
+ 	return true;
+ }
+ 
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -334,6 +334,7 @@ extern bool brcms_c_tx_flush_completed(s
+ extern void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
+ extern void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr,
+ 			     const u8 *bssid, u8 *ssid, size_t ssid_len);
++extern void brcms_c_start_adhoc(struct brcms_c_info *wlc, u8 *addr);
+ extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
+ extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
+ 				   struct sk_buff *beacon, u16 tim_offset,
diff --git a/package/mac80211/patches/873-brcmsmac-remove-extra-regulation-restriction.patch b/package/mac80211/patches/875-brcmsmac-remove-extra-regulation-restriction.patch
similarity index 100%
rename from package/mac80211/patches/873-brcmsmac-remove-extra-regulation-restriction.patch
rename to package/mac80211/patches/875-brcmsmac-remove-extra-regulation-restriction.patch
-- 
2.30.2