1 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
2 +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
5 * Copyright (c) 2010 Broadcom Corporation
6 + * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 @@ -522,9 +523,17 @@ brcms_ops_bss_info_changed(struct ieee80
11 brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid);
12 spin_unlock_bh(&wl->lock);
14 - if (changed & BSS_CHANGED_BEACON)
15 + if (changed & BSS_CHANGED_BEACON) {
16 /* Beacon data changed, retrieve new beacon (beaconing modes) */
17 - brcms_err(core, "%s: beacon changed\n", __func__);
18 + struct sk_buff *beacon;
21 + spin_lock_bh(&wl->lock);
22 + beacon = ieee80211_beacon_get_tim(hw, vif, &tim_offset, NULL);
23 + brcms_c_set_new_beacon(wl->wlc, beacon, tim_offset,
25 + spin_unlock_bh(&wl->lock);
28 if (changed & BSS_CHANGED_BEACON_ENABLED) {
29 /* Beaconing should be enabled/disabled (beaconing modes) */
30 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
31 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
34 * Copyright (c) 2010 Broadcom Corporation
35 + * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
37 * Permission to use, copy, modify, and/or distribute this software for any
38 * purpose with or without fee is hereby granted, provided that the above
39 @@ -450,6 +451,8 @@ static void brcms_c_detach_mfree(struct
40 kfree(wlc->corestate);
41 kfree(wlc->hw->bandstate[0]);
44 + dev_kfree_skb_any(wlc->beacon);
48 @@ -4086,10 +4089,14 @@ void brcms_c_wme_setparams(struct brcms_
54 brcms_c_suspend_mac_and_wait(wlc);
56 + brcms_c_update_beacon(wlc);
57 + brcms_c_update_probe_resp(wlc, false);
60 brcms_c_enable_mac(wlc);
64 static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend)
65 @@ -7379,6 +7386,107 @@ int brcms_c_get_header_len(void)
69 +static void brcms_c_beacon_write(struct brcms_c_info *wlc,
70 + struct sk_buff *beacon, u16 tim_offset,
71 + u16 dtim_period, bool bcn0, bool bcn1)
74 + struct ieee80211_tx_info *tx_info;
75 + struct brcms_hardware *wlc_hw = wlc->hw;
76 + struct ieee80211_hw *ieee_hw = brcms_c_pub(wlc)->ieee_hw;
79 + tx_info = IEEE80211_SKB_CB(beacon);
81 + len = min_t(size_t, beacon->len, BCN_TMPL_LEN);
82 + wlc->bcn_rspec = ieee80211_get_tx_rate(ieee_hw, tx_info)->hw_value;
84 + brcms_c_compute_plcp(wlc, wlc->bcn_rspec,
85 + len + FCS_LEN - D11_PHY_HDR_LEN, beacon->data);
87 + /* "Regular" and 16 MBSS but not for 4 MBSS */
88 + /* Update the phytxctl for the beacon based on the rspec */
89 + brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec);
92 + /* write the probe response into the template region */
93 + brcms_b_write_template_ram(wlc_hw, T_BCN0_TPL_BASE,
94 + (len + 3) & ~3, beacon->data);
96 + /* write beacon length to SCR */
97 + brcms_b_write_shm(wlc_hw, M_BCN0_FRM_BYTESZ, (u16) len);
100 + /* write the probe response into the template region */
101 + brcms_b_write_template_ram(wlc_hw, T_BCN1_TPL_BASE,
102 + (len + 3) & ~3, beacon->data);
104 + /* write beacon length to SCR */
105 + brcms_b_write_shm(wlc_hw, M_BCN1_FRM_BYTESZ, (u16) len);
108 + if (tim_offset != 0) {
109 + brcms_b_write_shm(wlc_hw, M_TIMBPOS_INBEACON,
110 + tim_offset + D11B_PHY_HDR_LEN);
111 + brcms_b_write_shm(wlc_hw, M_DOT11_DTIMPERIOD, dtim_period);
113 + brcms_b_write_shm(wlc_hw, M_TIMBPOS_INBEACON,
114 + len + D11B_PHY_HDR_LEN);
115 + brcms_b_write_shm(wlc_hw, M_DOT11_DTIMPERIOD, 0);
119 +static void brcms_c_update_beacon_hw(struct brcms_c_info *wlc,
120 + struct sk_buff *beacon, u16 tim_offset,
123 + struct brcms_hardware *wlc_hw = wlc->hw;
124 + struct bcma_device *core = wlc_hw->d11core;
126 + /* Hardware beaconing for this config */
127 + u32 both_valid = MCMD_BCN0VLD | MCMD_BCN1VLD;
129 + /* Check if both templates are in use, if so sched. an interrupt
130 + * that will call back into this routine
132 + if ((bcma_read32(core, D11REGOFFS(maccommand)) & both_valid) == both_valid)
133 + /* clear any previous status */
134 + bcma_write32(core, D11REGOFFS(macintstatus), MI_BCNTPL);
136 + if (wlc->beacon_template_virgin) {
137 + wlc->beacon_template_virgin = false;
138 + brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true,
140 + /* mark beacon0 valid */
141 + bcma_set32(core, D11REGOFFS(maccommand), MCMD_BCN0VLD);
145 + /* Check that after scheduling the interrupt both of the
146 + * templates are still busy. if not clear the int. & remask
148 + if ((bcma_read32(core, D11REGOFFS(maccommand)) & both_valid) == both_valid) {
149 + wlc->defmacintmask |= MI_BCNTPL;
153 + if (!(bcma_read32(core, D11REGOFFS(maccommand)) & MCMD_BCN0VLD)) {
154 + brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true,
156 + /* mark beacon0 valid */
157 + bcma_set32(core, D11REGOFFS(maccommand), MCMD_BCN0VLD);
160 + if (!(bcma_read32(core, D11REGOFFS(maccommand)) & MCMD_BCN1VLD)) {
161 + brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period,
163 + /* mark beacon0 valid */
164 + bcma_set32(core, D11REGOFFS(maccommand), MCMD_BCN1VLD);
171 * Update all beacons for the system.
173 @@ -7387,9 +7495,31 @@ void brcms_c_update_beacon(struct brcms_
174 struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
176 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP ||
177 - bsscfg->type == BRCMS_TYPE_ADHOC))
178 + bsscfg->type == BRCMS_TYPE_ADHOC)) {
179 /* Clear the soft intmask */
180 wlc->defmacintmask &= ~MI_BCNTPL;
183 + brcms_c_update_beacon_hw(wlc, wlc->beacon,
184 + wlc->beacon_tim_offset,
185 + wlc->beacon_dtim_period);
189 +void brcms_c_set_new_beacon(struct brcms_c_info *wlc, struct sk_buff *beacon,
190 + u16 tim_offset, u16 dtim_period)
195 + dev_kfree_skb_any(wlc->beacon);
196 + wlc->beacon = beacon;
199 + skb_push(wlc->beacon, D11_PHY_HDR_LEN);
200 + wlc->beacon_tim_offset = tim_offset;
201 + wlc->beacon_dtim_period = dtim_period;
202 + brcms_c_update_beacon(wlc);
205 /* Write ssid into shared memory */
206 @@ -7788,6 +7918,10 @@ bool brcms_c_dpc(struct brcms_c_info *wl
207 brcms_rfkill_set_hw_state(wlc->wl);
210 + /* BCN template is available */
211 + if (macintstatus & MI_BCNTPL)
212 + brcms_c_update_beacon(wlc);
214 /* it isn't done and needs to be resched if macintstatus is non-zero */
215 return wlc->macintstatus != 0;
217 @@ -7919,6 +8053,7 @@ brcms_c_attach(struct brcms_info *wl, st
219 pub->_piomode = piomode;
220 wlc->bandinit_pending = false;
221 + wlc->beacon_template_virgin = true;
223 /* populate struct brcms_c_info with default values */
224 brcms_c_info_init(wlc, unit);
225 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
226 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
227 @@ -492,6 +492,8 @@ struct brcms_c_info {
231 + bool beacon_template_virgin;
233 struct brcms_timer *wdtimer;
234 struct brcms_timer *radio_timer;
236 @@ -561,6 +563,10 @@ struct brcms_c_info {
241 + struct sk_buff *beacon;
242 + u16 beacon_tim_offset;
243 + u16 beacon_dtim_period;
246 /* antsel module specific state */
247 @@ -630,7 +636,6 @@ extern u16 brcms_c_compute_rtscts_dur(st
248 extern void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
249 struct ieee80211_sta *sta,
250 void (*dma_callback_fn));
251 -extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
252 extern void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
253 extern int brcms_c_set_nmode(struct brcms_c_info *wlc);
254 extern void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc,
255 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
256 +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
257 @@ -332,5 +332,9 @@ extern bool brcms_c_check_radio_disabled
258 extern void brcms_c_mute(struct brcms_c_info *wlc, bool on);
259 extern bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
260 extern void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
261 +extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
262 +extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
263 + struct sk_buff *beacon, u16 tim_offset,
266 #endif /* _BRCM_PUB_H_ */