Ticket #1329: madwifi-locks.3.diff
| File madwifi-locks.3.diff, 36.7 kB (added by mentor, 5 years ago) |
|---|
-
net80211/ieee80211_beacon.c
old new 286 286 int len_changed = 0; 287 287 u_int16_t capinfo; 288 288 289 IEEE80211_LOCK (ic);289 IEEE80211_LOCK_IRQ(ic); 290 290 291 291 if ((ic->ic_flags & IEEE80211_F_DOTH) && 292 292 (vap->iv_flags & IEEE80211_F_CHANSWITCH) && … … 307 307 if (c == NULL) { 308 308 IEEE80211_DPRINTF(vap, IEEE80211_MSG_DOTH, 309 309 "%s: find channel failure\n", __func__); 310 IEEE80211_UNLOCK (ic);310 IEEE80211_UNLOCK_IRQ_EARLY(ic); 311 311 return 0; 312 312 } 313 313 ic->ic_bsschan = c; … … 547 547 vap->iv_flags_ext &= ~IEEE80211_FEXT_APPIE_UPDATE; 548 548 } 549 549 550 IEEE80211_UNLOCK (ic);550 IEEE80211_UNLOCK_IRQ(ic); 551 551 552 552 return len_changed; 553 553 } -
net80211/ieee80211_scan_sta.c
old new 110 110 int (*st_action)(struct ieee80211vap *, const struct ieee80211_scan_entry *); 111 111 }; 112 112 113 #define SCAN_STA_LOCK_INIT(_st, _name) \ 114 spin_lock_init(&(_st)->st_lock) 115 #define SCAN_STA_LOCK_DESTROY(_st) 116 #define SCAN_STA_LOCK_IRQ(_st) do { \ 117 unsigned long __stlockflags; \ 118 spin_lock_irqsave(&(_st)->st_lock, __stlockflags); 119 #define SCAN_STA_UNLOCK_IRQ(_st) \ 120 spin_unlock_irqrestore(&(_st)->st_lock, __stlockflags); \ 121 } while (0) 122 #define SCAN_STA_UNLOCK_IRQ_EARLY(_st) \ 123 spin_unlock_irqrestore(&(_st)->st_lock, __stlockflags); 124 125 #define SCAN_STA_GEN_LOCK_INIT(_st, _name) \ 126 spin_lock_init(&(_st)->st_lock) 127 #define SCAN_STA_GEN_LOCK_DESTROY(_st) 128 #define SCAN_STA_GEN_LOCK(_st) spin_lock(&(_st)->st_scanlock); 129 #define SCAN_STA_GEN_UNLOCK(_st) spin_unlock(&(_st)->st_scanlock); 130 113 131 static void sta_flush_table(struct sta_table *); 114 132 static int match_bss(struct ieee80211vap *, const struct ieee80211_scan_state *, 115 133 const struct sta_entry *); … … 129 147 M_80211_SCAN, M_NOWAIT | M_ZERO); 130 148 if (st == NULL) 131 149 return 0; 132 spin_lock_init(&st->st_lock);133 spin_lock_init(&st->st_scanlock);150 SCAN_STA_LOCK_INIT(st, "scan_sta"); 151 SCAN_STA_GEN_LOCK_INIT(st, "scan_sta_gen"); 134 152 TAILQ_INIT(&st->st_entry); 135 153 IEEE80211_INIT_TQUEUE(&st->st_actiontq, action_tasklet, ss); 136 154 ss->ss_priv = st; … … 163 181 { 164 182 struct sta_table *st = ss->ss_priv; 165 183 166 spin_lock(&st->st_lock);184 SCAN_STA_LOCK_IRQ(st); 167 185 sta_flush_table(st); 168 spin_unlock(&st->st_lock);186 SCAN_STA_UNLOCK_IRQ(st); 169 187 ss->ss_last = 0; 170 188 return 0; 171 189 } … … 215 233 int hash; 216 234 217 235 hash = STA_HASH(macaddr); 218 spin_lock(&st->st_lock);236 SCAN_STA_LOCK_IRQ(st); 219 237 LIST_FOREACH(se, &st->st_hash[hash], se_hash) 220 238 if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr) && 221 239 sp->ssid[1] == se->base.se_ssid[1] && … … 225 243 MALLOC(se, struct sta_entry *, sizeof(struct sta_entry), 226 244 M_80211_SCAN, M_NOWAIT | M_ZERO); 227 245 if (se == NULL) { 228 spin_unlock(&st->st_lock);246 SCAN_STA_UNLOCK_IRQ_EARLY(st); 229 247 return 0; 230 248 } 231 249 se->se_scangen = st->st_scangen-1; … … 287 305 se->se_seen = 1; 288 306 se->se_notseen = 0; 289 307 290 spin_unlock(&st->st_lock);308 SCAN_STA_UNLOCK_IRQ(st); 291 309 292 310 /* 293 311 * If looking for a quick choice and nothing's … … 792 810 sta_update_notseen(struct sta_table *st) 793 811 { 794 812 struct sta_entry *se; 795 unsigned long stlockflags;796 813 797 spin_lock_irqsave(&st->st_lock, stlockflags);814 SCAN_STA_LOCK_IRQ(st); 798 815 TAILQ_FOREACH(se, &st->st_entry, se_list) { 799 816 /* 800 817 * If seen then reset and don't bump the count; … … 808 825 else 809 826 se->se_notseen++; 810 827 } 811 spin_unlock_irqrestore(&st->st_lock, stlockflags);828 SCAN_STA_UNLOCK_IRQ(st); 812 829 } 813 830 814 831 static void 815 832 sta_dec_fails(struct sta_table *st) 816 833 { 817 834 struct sta_entry *se; 818 unsigned long stlockflags;819 835 820 spin_lock_irqsave(&st->st_lock, stlockflags);836 SCAN_STA_LOCK_IRQ(st); 821 837 TAILQ_FOREACH(se, &st->st_entry, se_list) 822 838 if (se->se_fails) 823 839 se->se_fails--; 824 spin_unlock_irqrestore(&st->st_lock, stlockflags);840 SCAN_STA_UNLOCK_IRQ(st); 825 841 } 826 842 827 843 static struct sta_entry * … … 829 845 { 830 846 struct sta_table *st = ss->ss_priv; 831 847 struct sta_entry *se, *selbs = NULL; 832 unsigned long stlockflags;833 848 834 849 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN | IEEE80211_MSG_ROAM, " %s\n", 835 850 "macaddr bssid chan rssi rate flag wep essid"); 836 spin_lock_irqsave(&st->st_lock, stlockflags);851 SCAN_STA_LOCK_IRQ(st); 837 852 TAILQ_FOREACH(se, &st->st_entry, se_list) { 838 853 if (match_bss(vap, ss, se) == 0) { 839 854 if (selbs == NULL) … … 842 857 selbs = se; 843 858 } 844 859 } 845 spin_unlock_irqrestore(&st->st_lock, stlockflags);860 SCAN_STA_UNLOCK_IRQ(st); 846 861 847 862 return selbs; 848 863 } … … 930 945 struct sta_entry *se; 931 946 int hash = STA_HASH(macaddr); 932 947 933 spin_lock(&st->st_lock);948 SCAN_STA_LOCK_IRQ(st); 934 949 LIST_FOREACH(se, &st->st_hash[hash], se_hash) 935 950 if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr)) 936 951 break; 937 spin_unlock(&st->st_lock);952 SCAN_STA_UNLOCK_IRQ(st); 938 953 939 954 return se; /* NB: unlocked */ 940 955 } … … 1024 1039 struct sta_table *st = ss->ss_priv; 1025 1040 struct sta_entry *se, *next; 1026 1041 1027 spin_lock(&st->st_lock);1042 SCAN_STA_LOCK_IRQ(st); 1028 1043 TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) { 1029 1044 if (se->se_notseen > STA_PURGE_SCANS) { 1030 1045 TAILQ_REMOVE(&st->st_entry, se, se_list); … … 1032 1047 FREE(se, M_80211_SCAN); 1033 1048 } 1034 1049 } 1035 spin_unlock(&st->st_lock);1050 SCAN_STA_UNLOCK_IRQ(st); 1036 1051 /* 1037 1052 * If rate control is enabled check periodically to see if 1038 1053 * we should roam from our current connection to one that … … 1063 1078 u_int gen; 1064 1079 int res = 0; 1065 1080 1066 spin_lock(&st->st_scanlock);1081 SCAN_STA_GEN_LOCK(st); 1067 1082 gen = st->st_scangen++; 1068 1083 restart: 1069 spin_lock(&st->st_lock);1084 SCAN_STA_LOCK_IRQ(st); 1070 1085 TAILQ_FOREACH(se, &st->st_entry, se_list) { 1071 1086 if (se->se_scangen != gen) { 1072 1087 se->se_scangen = gen; 1073 1088 /* update public state */ 1074 1089 se->base.se_age = jiffies - se->se_lastupdate; 1075 spin_unlock(&st->st_lock); 1090 SCAN_STA_UNLOCK_IRQ_EARLY(st); 1091 1076 1092 res = (*f)(arg, &se->base); 1077 1093 1078 if(res != 0) {1094 if(res != 0) 1079 1095 /* We probably ran out of buffer space. */ 1080 1096 goto done; 1081 } 1097 1082 1098 goto restart; 1083 1099 } 1084 1100 } 1085 1101 1086 spin_unlock(&st->st_lock);1102 SCAN_STA_UNLOCK_IRQ(st); 1087 1103 1088 1104 done: 1089 spin_unlock(&st->st_scanlock);1105 SCAN_STA_GEN_UNLOCK(st); 1090 1106 1091 1107 return res; 1092 1108 } … … 1235 1251 bestchan = NULL; 1236 1252 bestrssi = -1; 1237 1253 1238 spin_lock(&st->st_lock);1254 SCAN_STA_LOCK_IRQ(st); 1239 1255 for (i = 0; i < ss->ss_last; i++) { 1240 1256 c = ss->ss_chans[i]; 1241 1257 maxrssi = 0; … … 1248 1264 if (bestchan == NULL || maxrssi < bestrssi) 1249 1265 bestchan = c; 1250 1266 } 1251 spin_unlock(&st->st_lock);1267 SCAN_STA_UNLOCK_IRQ(st); 1252 1268 1253 1269 return bestchan; 1254 1270 } … … 1349 1365 struct sta_table *st = ss->ss_priv; 1350 1366 struct sta_entry *se, *next; 1351 1367 1352 spin_lock(&st->st_lock);1368 SCAN_STA_LOCK_IRQ(st); 1353 1369 TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) { 1354 1370 if (se->se_notseen > STA_PURGE_SCANS) { 1355 1371 TAILQ_REMOVE(&st->st_entry, se, se_list); … … 1357 1373 FREE(se, M_80211_SCAN); 1358 1374 } 1359 1375 } 1360 spin_unlock(&st->st_lock);1376 SCAN_STA_UNLOCK_IRQ(st); 1361 1377 } 1362 1378 1363 1379 /* -
net80211/ieee80211_input.c
old new 3654 3654 } 3655 3655 3656 3656 /* Okay, take the first queued packet and put it out... */ 3657 IEEE80211_NODE_SAVEQ_LOCK (ni);3657 IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 3658 3658 IEEE80211_NODE_SAVEQ_DEQUEUE(ni, skb, qlen); 3659 IEEE80211_NODE_SAVEQ_UNLOCK (ni);3659 IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 3660 3660 if (skb == NULL) { 3661 3661 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_POWER, wh->i_addr2, 3662 3662 "%s", "recv ps-poll, but queue empty"); -
net80211/ieee80211_power.c
old new 113 113 struct sk_buff *skb; 114 114 int qlen; 115 115 116 IEEE80211_NODE_SAVEQ_LOCK (ni);116 IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 117 117 qlen = IEEE80211_NODE_SAVEQ_QLEN(ni); 118 118 while ((skb = __skb_dequeue(&ni->ni_savedq)) != NULL) { 119 119 cb = (struct ieee80211_cb *) skb->cb; 120 120 ieee80211_unref_node(&cb->ni); 121 121 dev_kfree_skb_any(skb); 122 122 } 123 IEEE80211_NODE_SAVEQ_UNLOCK (ni);123 IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 124 124 125 125 return qlen; 126 126 } … … 147 147 #endif 148 148 struct sk_buff *skb; 149 149 150 IEEE80211_NODE_SAVEQ_LOCK (ni);150 IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 151 151 while ((skb = skb_peek(&ni->ni_savedq)) != NULL && 152 152 M_AGE_GET(skb) < IEEE80211_INACT_WAIT) { 153 153 IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, … … 159 159 } 160 160 if (skb != NULL) 161 161 M_AGE_SUB(skb, IEEE80211_INACT_WAIT); 162 IEEE80211_NODE_SAVEQ_UNLOCK (ni);162 IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 163 163 164 164 IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, 165 165 "discard %u frames for age", discard); … … 185 185 KASSERT(aid < vap->iv_max_aid, 186 186 ("bogus aid %u, max %u", aid, vap->iv_max_aid)); 187 187 188 IEEE80211_LOCK (ni->ni_ic);188 IEEE80211_LOCK_IRQ(ni->ni_ic); 189 189 if (set != (isset(vap->iv_tim_bitmap, aid) != 0)) { 190 190 if (set) { 191 191 setbit(vap->iv_tim_bitmap, aid); … … 196 196 } 197 197 vap->iv_flags |= IEEE80211_F_TIMUPDATE; 198 198 } 199 IEEE80211_UNLOCK (ni->ni_ic);199 IEEE80211_UNLOCK_IRQ(ni->ni_ic); 200 200 } 201 201 202 202 /* … … 212 212 struct sk_buff *tail; 213 213 int qlen, age; 214 214 215 IEEE80211_NODE_SAVEQ_LOCK_ IRQ(ni);215 IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 216 216 if (IEEE80211_NODE_SAVEQ_QLEN(ni) >= IEEE80211_PS_MAX_QUEUE) { 217 217 IEEE80211_NODE_STAT(ni, psq_drops); 218 IEEE80211_NODE_SAVEQ_UNLOCK_ IRQ_EARLY(ni);218 IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 219 219 IEEE80211_NOTE(vap, IEEE80211_MSG_ANY, ni, 220 220 "pwr save q overflow, drops %d (size %d)", 221 221 ni->ni_stats.ns_psq_drops, IEEE80211_PS_MAX_QUEUE); … … 244 244 __skb_queue_head(&ni->ni_savedq, skb); 245 245 M_AGE_SET(skb, age); 246 246 qlen = IEEE80211_NODE_SAVEQ_QLEN(ni); 247 IEEE80211_NODE_SAVEQ_UNLOCK_ IRQ(ni);247 IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 248 248 249 249 IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, 250 250 "save frame, %u now queued", qlen); … … 288 288 vap->iv_set_tim(ni, 0); /* just in case */ 289 289 return; 290 290 } 291 291 292 IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, 292 293 "flush ps queue, %u packets queued", 293 294 IEEE80211_NODE_SAVEQ_QLEN(ni)); 295 294 296 for (;;) { 295 297 struct sk_buff *skb; 296 298 int qlen; 297 299 298 IEEE80211_NODE_SAVEQ_LOCK (ni);300 IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 299 301 IEEE80211_NODE_SAVEQ_DEQUEUE(ni, skb, qlen); 300 IEEE80211_NODE_SAVEQ_UNLOCK (ni);302 IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 301 303 if (skb == NULL) 302 304 break; 303 305 /* … … 362 364 for (;;) { 363 365 struct sk_buff *skb; 364 366 365 IEEE80211_NODE_SAVEQ_LOCK (ni);367 IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 366 368 skb = __skb_dequeue(&ni->ni_savedq); 367 IEEE80211_NODE_SAVEQ_UNLOCK (ni);369 IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 368 370 if (skb == NULL) 369 371 break; 370 372 ieee80211_parent_queue_xmit(skb); -
net80211/ieee80211_proto.c
old new 633 633 { 634 634 struct ieee80211com *ic = vap->iv_ic; 635 635 636 IEEE80211_LOCK (ic);636 IEEE80211_LOCK_IRQ(ic); 637 637 ieee80211_wme_initparams_locked(vap); 638 IEEE80211_UNLOCK (ic);638 IEEE80211_UNLOCK_IRQ(ic); 639 639 } 640 640 641 641 void … … 918 918 struct ieee80211com *ic = vap->iv_ic; 919 919 920 920 if (ic->ic_caps & IEEE80211_C_WME) { 921 IEEE80211_LOCK (ic);921 IEEE80211_LOCK_IRQ(ic); 922 922 ieee80211_wme_updateparams_locked(vap); 923 IEEE80211_UNLOCK (ic);923 IEEE80211_UNLOCK_IRQ(ic); 924 924 } 925 925 } 926 926 -
net80211/ieee80211_linux.h
old new 86 86 } while (0) 87 87 #define IEEE80211_UNLOCK_IRQ_EARLY(_ic) \ 88 88 spin_unlock_irqrestore(&(_ic)->ic_comlock, __ilockflags); 89 #define IEEE80211_LOCK_BH(_ic) spin_lock_bh(&(_ic)->ic_comlock)90 #define IEEE80211_UNLOCK_BH(_ic) spin_unlock_bh(&(_ic)->ic_comlock)91 #define IEEE80211_LOCK(_ic) spin_lock(&(_ic)->ic_comlock)92 #define IEEE80211_UNLOCK(_ic) spin_unlock(&(_ic)->ic_comlock)93 89 94 90 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 95 91 #define IEEE80211_LOCK_ASSERT(_ic) \ … … 102 98 #define IEEE80211_VAPS_LOCK_INIT(_ic, _name) \ 103 99 spin_lock_init(&(_ic)->ic_vapslock) 104 100 #define IEEE80211_VAPS_LOCK_DESTROY(_ic) 105 #define IEEE80211_VAPS_LOCK(_ic) spin_lock(&(_ic)->ic_vapslock);106 #define IEEE80211_VAPS_UNLOCK(_ic) spin_unlock(&(_ic)->ic_vapslock);107 101 #define IEEE80211_VAPS_LOCK_BH(_ic) spin_lock_bh(&(_ic)->ic_vapslock); 108 102 #define IEEE80211_VAPS_UNLOCK_BH(_ic) spin_unlock_bh(&(_ic)->ic_vapslock); 109 #define IEEE80211_VAPS_LOCK_IRQ(_ic) do { \110 int _vaps_lockflags; \111 spin_lock_irqsave(&(_ic)->ic_vapslock, _vaps_lockflags);112 #define IEEE80211_VAPS_UNLOCK_IRQ(_ic) \113 spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags); \114 } while (0)115 #define IEEE80211_VAPS_UNLOCK_IRQ_EARLY(_ic) spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags)116 103 117 104 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 118 105 #define IEEE80211_VAPS_LOCK_ASSERT(_ic) \ … … 131 118 typedef spinlock_t ieee80211_node_lock_t; 132 119 #define IEEE80211_NODE_LOCK_INIT(_ni, _name) spin_lock_init(&(_ni)->ni_nodelock) 133 120 #define IEEE80211_NODE_LOCK_DESTROY(_ni) 134 #if 0 /* We should always be contesting in the same contexts */135 #define IEEE80211_NODE_LOCK(_ni) spin_lock(&(_ni)->ni_nodelock)136 #define IEEE80211_NODE_UNLOCK(_ni) spin_unlock(&(_ni)->ni_nodelock)137 #define IEEE80211_NODE_LOCK_BH(_ni) spin_lock_bh(&(_ni)->ni_nodelock)138 #define IEEE80211_NODE_UNLOCK_BH(_ni) spin_unlock_bh(&(_ni)->ni_nodelock)139 #endif140 121 #define IEEE80211_NODE_LOCK_IRQ(_ni) do { \ 141 122 unsigned long __node_lockflags; \ 142 123 spin_lock_irqsave(&(_ni)->ni_nodelock, __node_lockflags); … … 191 172 typedef spinlock_t ieee80211_scan_lock_t; 192 173 #define IEEE80211_SCAN_LOCK_INIT(_nt, _name) spin_lock_init(&(_nt)->nt_scanlock) 193 174 #define IEEE80211_SCAN_LOCK_DESTROY(_nt) 194 #define IEEE80211_SCAN_LOCK_BH(_nt) spin_lock_bh(&(_nt)->nt_scanlock)195 #define IEEE80211_SCAN_UNLOCK_BH(_nt) spin_unlock_bh(&(_nt)->nt_scanlock)196 175 #define IEEE80211_SCAN_LOCK_IRQ(_nt) do { \ 197 176 unsigned long __scan_lockflags; \ 198 177 spin_lock_irqsave(&(_nt)->nt_scanlock, __scan_lockflags); … … 217 196 #define ACL_LOCK_DESTROY(_as) 218 197 #define ACL_LOCK(_as) spin_lock(&(_as)->as_lock) 219 198 #define ACL_UNLOCK(_as) spin_unlock(&(_as)->as_lock) 220 #define ACL_LOCK_BH(_as) spin_lock_bh(&(_as)->as_lock)221 #define ACL_UNLOCK_BH(_as) spin_unlock_bh(&(_as)->as_lock)222 199 223 200 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 224 201 #define ACL_LOCK_ASSERT(_as) \ … … 240 217 skb_queue_head_init(&(_ni)->ni_savedq); \ 241 218 } while (0) 242 219 #define IEEE80211_NODE_SAVEQ_DESTROY(_ni) 243 #define IEEE80211_NODE_SAVEQ_QLEN(_ni) skb_queue_len(&(_ni)->ni_savedq) 244 #define IEEE80211_NODE_SAVEQ_LOCK(_ni) \ 245 spin_lock(&(_ni)->ni_savedq.lock) 246 #define IEEE80211_NODE_SAVEQ_UNLOCK(_ni) \ 247 spin_unlock(&(_ni)->ni_savedq.lock) 248 #define IEEE80211_NODE_SAVEQ_LOCK_IRQ(_ni) do { \ 249 unsigned long __sqlockflags; \ 250 spin_lock_irqsave(&(_ni)->ni_savedq.lock, __sqlockflags); 251 #define IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(_ni) \ 252 spin_unlock_irqrestore(&(_ni)->ni_savedq.lock, __sqlockflags); \ 253 } while (0) 254 #define IEEE80211_NODE_SAVEQ_UNLOCK_IRQ_EARLY(_ni) \ 255 spin_unlock_irqrestore(&(_ni)->ni_savedq.lock, __sqlockflags); 220 #define IEEE80211_NODE_SAVEQ_QLEN(_ni) skb_queue_len(&(_ni)->ni_savedq) 221 #define IEEE80211_NODE_SAVEQ_LOCK_BH(_ni) spin_lock_bh(&(_ni)->ni_savedq.lock); 222 #define IEEE80211_NODE_SAVEQ_UNLOCK_BH(_ni) spin_unlock_bh(&(_ni)->ni_savedq.lock); 256 223 257 224 /* caller MUST lock IEEE80211_NODE_SAVEQ */ 258 225 #define IEEE80211_NODE_SAVEQ_DEQUEUE(_ni, _skb, _qlen) do { \ -
ath/if_ath_pci.c
old new 221 221 222 222 /* looking for device type from broken device id */ 223 223 vdevice = id->device; 224 for(i =0;i<sizeof(ath_devidmap)/sizeof(ath_devidmap[0]);i++) {224 for(i = 0; i < (sizeof(ath_devidmap) / sizeof(ath_devidmap[0])); i++) { 225 225 if(id->device == ath_devidmap[i][0]) { 226 226 vdevice = ath_devidmap[i][1]; 227 227 break; -
ath/if_athvar.h
old new 345 345 #define ATH_NODE(_n) ((struct ath_node *)(_n)) 346 346 #define ATH_NODE_CONST(ni) ((const struct ath_node *)(ni)) 347 347 #define ATH_NODE_UAPSD_LOCK_INIT(_an) spin_lock_init(&(_an)->an_uapsd_lock) 348 #define ATH_NODE_UAPSD_LOCK(_an) spin_lock(&(_an)->an_uapsd_lock)349 #define ATH_NODE_UAPSD_UNLOCK(_an) spin_unlock(&(_an)->an_uapsd_lock)350 348 #define ATH_NODE_UAPSD_LOCK_IRQ(_an) do { \ 351 349 unsigned long __an_uapsd_lockflags; \ 352 350 spin_lock_irqsave(&(_an)->an_uapsd_lock, __an_uapsd_lockflags); … … 476 474 #define ATH_TXQ_INTR_PERIOD 5 /* axq_intrcnt period for intr gen */ 477 475 #define ATH_TXQ_LOCK_INIT(_tq) spin_lock_init(&(_tq)->axq_lock) 478 476 #define ATH_TXQ_LOCK_DESTROY(_tq) 479 #define ATH_TXQ_LOCK(_tq) spin_lock(&(_tq)->axq_lock)480 #define ATH_TXQ_UNLOCK(_tq) spin_unlock(&(_tq)->axq_lock)481 #define ATH_TXQ_LOCK_BH(_tq) spin_lock_bh(&(_tq)->axq_lock)482 #define ATH_TXQ_UNLOCK_BH(_tq) spin_unlock_bh(&(_tq)->axq_lock)483 477 #define ATH_TXQ_LOCK_IRQ(_tq) do { \ 484 478 unsigned long __axq_lockflags; \ 485 479 spin_lock_irqsave(&(_tq)->axq_lock, __axq_lockflags); … … 489 483 #define ATH_TXQ_UNLOCK_IRQ_EARLY(_tq) \ 490 484 spin_unlock_irqrestore(&(_tq)->axq_lock, __axq_lockflags); 491 485 492 #define ATH_TXQ_UAPSDQ_LOCK_IRQ(_tq) spin_lock_irqsave(&(_tq)->axq_lock, uapsdq_lockflags)493 #define ATH_TXQ_UAPSDQ_UNLOCK_IRQ(_tq) spin_unlock_irqrestore(&(_tq)->axq_lock, uapsdq_lockflags)494 495 496 497 498 486 #define ATH_TXQ_LOCK_ASSERT(_tq) \ 499 487 KASSERT(spin_is_locked(&(_tq)->axq_lock), ("txq not locked!")) 488 500 489 #define ATH_TXQ_INSERT_TAIL(_tq, _elm, _field) do { \ 501 490 STAILQ_INSERT_TAIL( &(_tq)->axq_q, (_elm), _field); \ 502 491 (_tq)->axq_depth++; \ … … 688 677 }; 689 678 690 679 typedef void (*ath_callback) (struct ath_softc *); 691 #define ATH_TXQ_SETUP(sc, i) ((sc)->sc_txqsetup & (1 <<i))680 #define ATH_TXQ_SETUP(sc, i) ((sc)->sc_txqsetup & (1 << i)) 692 681 693 682 #define ATH_TXBUF_LOCK_INIT(_sc) spin_lock_init(&(_sc)->sc_txbuflock) 694 683 #define ATH_TXBUF_LOCK_DESTROY(_sc) 695 #define ATH_TXBUF_LOCK(_sc) spin_lock(&(_sc)->sc_txbuflock)696 #define ATH_TXBUF_UNLOCK(_sc) spin_unlock(&(_sc)->sc_txbuflock)697 #define ATH_TXBUF_LOCK_BH(_sc) spin_lock_bh(&(_sc)->sc_txbuflock)698 #define ATH_TXBUF_UNLOCK_BH(_sc) spin_unlock_bh(&(_sc)->sc_txbuflock)699 684 #define ATH_TXBUF_LOCK_IRQ(_sc) do { \ 700 685 unsigned long __txbuflockflags; \ 701 686 spin_lock_irqsave(&(_sc)->sc_txbuflock, __txbuflockflags); … … 711 696 712 697 #define ATH_RXBUF_LOCK_INIT(_sc) spin_lock_init(&(_sc)->sc_rxbuflock) 713 698 #define ATH_RXBUF_LOCK_DESTROY(_sc) 714 #define ATH_RXBUF_LOCK(_sc) spin_lock(&(_sc)->sc_rxbuflock)715 #define ATH_RXBUF_UNLOCK(_sc) spin_unlock(&(_sc)->sc_rxbuflock)716 #define ATH_RXBUF_LOCK_BH(_sc) spin_lock_bh(&(_sc)->sc_rxbuflock)717 #define ATH_RXBUF_UNLOCK_BH(_sc) spin_unlock_bh(&(_sc)->sc_rxbuflock)718 699 #define ATH_RXBUF_LOCK_IRQ(_sc) do { \ 719 700 unsigned long __rxbuflockflags; \ 720 701 spin_lock_irqsave(&(_sc)->sc_rxbuflock, __rxbuflockflags); … … 724 705 #define ATH_RXBUF_UNLOCK_IRQ_EARLY(_sc) \ 725 706 spin_unlock_irqrestore(&(_sc)->sc_rxbuflock, __rxbuflockflags); 726 707 727 728 708 /* Protects the device from concurrent accesses */ 729 709 #define ATH_LOCK_INIT(_sc) init_MUTEX(&(_sc)->sc_lock) 730 710 #define ATH_LOCK_DESTROY(_sc) -
ath/if_ath.c
old new 1289 1289 if (vap->iv_xrvap) 1290 1290 vap->iv_xrvap->iv_xrvap = NULL; 1291 1291 kfree(vap->iv_dev); 1292 ath_tx_cleanupq(sc, sc->sc_xrtxq);1292 ath_tx_cleanupq(sc, sc->sc_xrtxq); 1293 1293 sc->sc_xrtxq = NULL; 1294 1294 if (sc->sc_hasdiversity) { 1295 1295 /* Restore diversity setting to old diversity setting */ … … 1362 1362 * based on ic->ic_uapsdmaxtriggers. 1363 1363 */ 1364 1364 1365 ATH_RXBUF_LOCK (sc);1365 ATH_RXBUF_LOCK_IRQ(sc); 1366 1366 if (sc->sc_rxbufcur == NULL) 1367 1367 sc->sc_rxbufcur = STAILQ_FIRST(&sc->sc_rxbuf); 1368 1368 for (bf = sc->sc_rxbufcur; bf; bf = STAILQ_NEXT(bf, bf_list)) { … … 1542 1542 an = ATH_NODE(ni); 1543 1543 1544 1544 /* start the SP */ 1545 ATH_NODE_UAPSD_LOCK (an);1545 ATH_NODE_UAPSD_LOCK_IRQ(an); 1546 1546 ni->ni_stats.ns_uapsd_triggers++; 1547 1547 ni->ni_flags |= IEEE80211_NODE_UAPSD_SP; 1548 1548 ni->ni_uapsd_trigseq[ac] = frame_seq; 1549 ATH_NODE_UAPSD_UNLOCK (an);1549 ATH_NODE_UAPSD_UNLOCK_IRQ(an); 1550 1550 1551 ATH_TXQ_LOCK (uapsd_xmit_q);1551 ATH_TXQ_LOCK_IRQ(uapsd_xmit_q); 1552 1552 if (STAILQ_EMPTY(&an->an_uapsd_q)) { 1553 1553 DPRINTF(sc, ATH_DEBUG_UAPSD, 1554 1554 "%s: Queue empty, generating QoS NULL to send\n", … … 1605 1605 } 1606 1606 an->an_uapsd_qdepth = 0; 1607 1607 1608 ATH_TXQ_UNLOCK (uapsd_xmit_q);1608 ATH_TXQ_UNLOCK_IRQ(uapsd_xmit_q); 1609 1609 } 1610 1610 sc->sc_rxbufcur = bf; 1611 ATH_RXBUF_UNLOCK (sc);1611 ATH_RXBUF_UNLOCK_IRQ(sc); 1612 1612 #undef PA2DESC 1613 1613 } 1614 1614 … … 2173 2173 * Insert the frame on the outbound list and 2174 2174 * pass it on to the hardware. 2175 2175 */ 2176 ATH_TXQ_LOCK (txq);2176 ATH_TXQ_LOCK_IRQ(txq); 2177 2177 if (ni && ni->ni_vap && txq == &ATH_VAP(ni->ni_vap)->av_mcastq) { 2178 2178 /* 2179 2179 * The CAB queue is started from the SWBA handler since … … 2218 2218 ath_hal_txstart(ah, txq->axq_qnum); 2219 2219 sc->sc_dev->trans_start = jiffies; 2220 2220 } 2221 ATH_TXQ_UNLOCK (txq);2221 ATH_TXQ_UNLOCK_IRQ(txq); 2222 2222 2223 2223 sc->sc_devstats.tx_packets++; 2224 2224 sc->sc_devstats.tx_bytes += framelen; … … 2356 2356 return 0; 2357 2357 } 2358 2358 2359 /* Caller must not hold ATH_TXQ_LOCK and ATH_TXBUF_LOCK2359 /* Caller must not hold ATH_TXQ_LOCK_IRQ and ATH_TXBUF_LOCK 2360 2360 * 2361 2361 * Context: softIRQ 2362 2362 */ … … 2370 2370 int framecnt; 2371 2371 2372 2372 for (;;) { 2373 ATH_TXQ_LOCK (txq);2373 ATH_TXQ_LOCK_IRQ(txq); 2374 2374 2375 2375 bf_ff = TAILQ_LAST(&txq->axq_stageq, axq_headtype); 2376 2376 if ((!bf_ff) || ath_ff_flushdonetest(txq, bf_ff)) { 2377 ATH_TXQ_UNLOCK (txq);2377 ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 2378 2378 break; 2379 2379 } 2380 2380 … … 2384 2384 ATH_NODE(ni)->an_tx_ffbuf[bf_ff->bf_skb->priority] = NULL; 2385 2385 TAILQ_REMOVE(&txq->axq_stageq, bf_ff, bf_stagelist); 2386 2386 2387 ATH_TXQ_UNLOCK (txq);2387 ATH_TXQ_UNLOCK_IRQ(txq); 2388 2388 2389 2389 /* encap and xmit */ 2390 2390 bf_ff->bf_skb = ieee80211_encap(ni, bf_ff->bf_skb, &framecnt); … … 2412 2412 } 2413 2413 #endif 2414 2414 2415 #define ATH_HARDSTART_GET_TX_BUF_WITH_LOCK \2415 #define ATH_HARDSTART_GET_TX_BUF_WITH_LOCK do { \ 2416 2416 ATH_TXBUF_LOCK_IRQ(sc); \ 2417 2417 bf = STAILQ_FIRST(&sc->sc_txbuf); \ 2418 2418 if (bf != NULL) { \ … … 2433 2433 DPRINTF(sc,ATH_DEBUG_XMIT, \ 2434 2434 "%s: discard, no xmit buf\n", __func__); \ 2435 2435 sc->sc_stats.ast_tx_nobuf++; \ 2436 } 2436 } \ 2437 } while (0) 2437 2438 2438 2439 /* 2439 2440 * Transmit a data packet. On failure caller is … … 2515 2516 /* NB: use this lock to protect an->an_ff_txbuf in athff_can_aggregate() 2516 2517 * call too. 2517 2518 */ 2518 ATH_TXQ_LOCK (txq);2519 ATH_TXQ_LOCK_IRQ(txq); 2519 2520 if (athff_can_aggregate(sc, eh, an, skb, vap->iv_fragthreshold, &ff_flush)) { 2520 2521 2521 if (an->an_tx_ffbuf[skb->priority]) { /* i.e., frame on the staging queue */ 2522 2522 bf = an->an_tx_ffbuf[skb->priority]; 2523 2523 … … 2525 2525 TAILQ_REMOVE(&txq->axq_stageq, bf, bf_stagelist); 2526 2526 an->an_tx_ffbuf[skb->priority] = NULL; 2527 2527 2528 ATH_TXQ_UNLOCK(txq);2529 2530 2528 /* 2531 2529 * chain skbs and add FF magic 2532 2530 * … … 2538 2536 skb = bf->bf_skb; 2539 2537 ATH_FF_MAGIC_PUT(skb); 2540 2538 2541 #if 02542 /* decrement extra node reference made when an_tx_ffbuf[] was set */2543 ieee80211_unref_node(&ni); /* XXX where was it set ? */2544 #endif2545 2546 2539 DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 2547 2540 "%s: aggregating fast-frame\n", __func__); 2548 2541 } else { 2549 /* NB: careful grabbing the TX_BUF lock since still holding the txqlock.2550 * this could be avoided by always obtaining the txbuf earlier,2542 /* NB: Careful grabbing the TX_BUF lock since still holding the TXQ lock. 2543 * This could be avoided by always obtaining the TXBuf earlier, 2551 2544 * but the "if" portion of this "if/else" clause would then need 2552 2545 * to give the buffer back. 2553 2546 */ 2554 2547 ATH_HARDSTART_GET_TX_BUF_WITH_LOCK; 2555 2548 if (bf == NULL) { 2556 ATH_TXQ_UNLOCK (txq);2549 ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 2557 2550 goto hardstart_fail; 2558 2551 } 2559 2552 DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, … … 2566 2559 2567 2560 TAILQ_INSERT_HEAD(&txq->axq_stageq, bf, bf_stagelist); 2568 2561 2569 ATH_TXQ_UNLOCK (txq);2562 ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 2570 2563 2571 2564 return 0; 2572 2565 } 2573 2566 } else { 2574 2567 if (ff_flush) { 2575 2568 struct ath_buf *bf_ff = an->an_tx_ffbuf[skb->priority]; 2569 int success = 0; 2576 2570 2577 2571 TAILQ_REMOVE(&txq->axq_stageq, bf_ff, bf_stagelist); 2578 2572 an->an_tx_ffbuf[skb->priority] = NULL; 2579 2573 2580 ATH_TXQ_UNLOCK(txq);2581 2582 2574 /* encap and xmit */ 2583 2575 bf_ff->bf_skb = ieee80211_encap(ni, bf_ff->bf_skb, &framecnt); 2584 2576 … … 2587 2579 "%s: discard, ff flush encap failure\n", 2588 2580 __func__); 2589 2581 sc->sc_stats.ast_tx_encap++; 2590 goto ff_flushbad; 2582 } else { 2583 pktlen = bf_ff->bf_skb->len; /* NB: don't reference skb below */ 2584 if (!ath_tx_start(dev, ni, bf_ff, bf_ff->bf_skb, 0)) 2585 success = 1; 2591 2586 } 2592 pktlen = bf_ff->bf_skb->len; /* NB: don't reference skb below */2593 /* NB: ath_tx_start() will use ATH_TXBUF_LOCK_BH(). The _BH2594 * portion is not needed here since we're running at2595 * interrupt time, but should be harmless.2596 */2597 if (ath_tx_start(dev, ni, bf_ff, bf_ff->bf_skb, 0))2598 goto ff_flushbad;2599 goto ff_flushdone;2600 ff_flushbad:2601 DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF,2602 "%s: ff stageq flush failure\n", __func__);2603 ieee80211_unref_node(&ni);2604 if (bf_ff->bf_skb) {2605 dev_kfree_skb(bf_ff->bf_skb);2606 bf_ff->bf_skb = NULL;2607 }2608 bf_ff->bf_node = NULL;2609 2587 2610 ATH_TXBUF_LOCK(sc); 2611 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf_ff, bf_list); 2612 ATH_TXBUF_UNLOCK(sc); 2613 goto ff_flushdone; 2588 if (!success) { 2589 DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 2590 "%s: ff stageq flush failure\n", __func__); 2591 ieee80211_unref_node(&ni); 2592 if (bf_ff->bf_skb) { 2593 dev_kfree_skb(bf_ff->bf_skb); 2594 bf_ff->bf_skb = NULL; 2595 } 2596 bf_ff->bf_node = NULL; 2597 2598 ATH_TXBUF_LOCK_IRQ(sc); 2599 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf_ff, bf_list); 2600 ATH_TXBUF_UNLOCK_IRQ(sc); 2601 } 2614 2602 } 2615 2603 /* 2616 2604 * XXX: out-of-order condition only occurs for AP mode and multicast. … … 2619 2607 else if (an->an_tx_ffbuf[skb->priority]) { 2620 2608 DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 2621 2609 "%s: Out-Of-Order fast-frame\n", __func__); 2622 ATH_TXQ_UNLOCK(txq); 2623 } else 2624 ATH_TXQ_UNLOCK(txq); 2625 2626 ff_flushdone: 2610 } 2611 2627 2612 ATH_HARDSTART_GET_TX_BUF_WITH_LOCK; 2628 if (bf == NULL) 2613 if (bf == NULL) { 2614 ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 2629 2615 goto hardstart_fail; 2616 } 2630 2617 } 2618 2619 ATH_TXQ_UNLOCK_IRQ(txq); 2631 2620 2632 2621 ff_bypass: 2633 2622 … … 2655 2644 * Allocate 1 ath_buf for each frame given 1 was 2656 2645 * already alloc'd 2657 2646 */ 2658 ATH_TXBUF_LOCK (sc);2647 ATH_TXBUF_LOCK_IRQ(sc); 2659 2648 for (bfcnt = 1; bfcnt < framecnt; ++bfcnt) { 2660 2649 if ((tbf = STAILQ_FIRST(&sc->sc_txbuf)) != NULL) { 2661 2650 STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list); … … 2676 2665 STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list); 2677 2666 } 2678 2667 } 2679 ATH_TXBUF_UNLOCK (sc);2668 ATH_TXBUF_UNLOCK_IRQ_EARLY(sc); 2680 2669 STAILQ_INIT(&bf_head); 2681 2670 goto hardstart_fail; 2682 2671 } 2683 ATH_TXBUF_UNLOCK (sc);2672 ATH_TXBUF_UNLOCK_IRQ(sc); 2684 2673 2685 2674 while ((bf = STAILQ_FIRST(&bf_head)) != NULL && skb != NULL) { 2686 2675 unsigned int nextfraglen = 0; … … 2716 2705 2717 2706 hardstart_fail: 2718 2707 if (!STAILQ_EMPTY(&bf_head)) { 2719 ATH_TXBUF_LOCK (sc);2708 ATH_TXBUF_LOCK_IRQ(sc); 2720 2709 STAILQ_FOREACH_SAFE(tbf, &bf_head, bf_list, tempbf) { 2721 2710 tbf->bf_skb = NULL; 2722 2711 tbf->bf_node = NULL; … … 2726 2715 2727 2716 STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list); 2728 2717 } 2729 ATH_TXBUF_UNLOCK (sc);2718 ATH_TXBUF_UNLOCK_IRQ(sc); 2730 2719 } 2731 2720 2732 2721 /* free sk_buffs */ … … 2781 2770 ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, NULL); 2782 2771 } 2783 2772 ATH_TXBUF_UNLOCK_IRQ(sc); 2773 2784 2774 if (bf == NULL) { 2785 2775 printk("ath_mgtstart: discard, no xmit buf\n"); 2786 2776 sc->sc_stats.ast_tx_nobufmgt++; … … 4048 4038 * Move everything from the VAP's mcast queue 4049 4039 * to the hardware cab queue. 4050 4040 */ 4051 ATH_TXQ_LOCK (&avp->av_mcastq);4052 ATH_TXQ_LOCK (cabq);4041 ATH_TXQ_LOCK_IRQ(&avp->av_mcastq); 4042 ATH_TXQ_LOCK_IRQ(cabq); 4053 4043 bfmcast = STAILQ_FIRST(&avp->av_mcastq.axq_q); 4054 4044 /* link the descriptors */ 4055 4045 if (cabq->axq_link == NULL) … … 4072 4062 ATH_TXQ_MOVE_MCASTQ(&avp->av_mcastq, cabq); 4073 4063 /* NB: gated by beacon so safe to start here */ 4074 4064 ath_hal_txstart(ah, cabq->axq_qnum); 4075 ATH_TXQ_UNLOCK (cabq);4076 ATH_TXQ_UNLOCK (&avp->av_mcastq);4065 ATH_TXQ_UNLOCK_IRQ(cabq); 4066 ATH_TXQ_UNLOCK_IRQ(&avp->av_mcastq); 4077 4067 } 4078 4068 4079 4069 return bf; … … 4742 4732 ni->ni_flags &= ~IEEE80211_NODE_UAPSD_SP; 4743 4733 } 4744 4734 ATH_NODE_UAPSD_UNLOCK_IRQ(an); 4735 4745 4736 while (an->an_uapsd_qdepth) { 4746 4737 bf = STAILQ_FIRST(&an->an_uapsd_q); 4747 4738 STAILQ_REMOVE_HEAD(&an->an_uapsd_q, bf_list); … … 4857 4848 index = WME_AC_VO; 4858 4849 while (index >= WME_AC_BE && txq != sc->sc_ac2q[index]) { 4859 4850 txq = sc->sc_ac2q[index]; 4860 ATH_TXQ_LOCK(txq); 4851 4852 ATH_TXQ_LOCK_IRQ(txq); 4861 4853 ath_hal_stoptxdma(ah, txq->axq_qnum); 4862 4854 bf = prev = STAILQ_FIRST(&txq->axq_q); 4863 4855 /* … … 4940 4932 } else 4941 4933 txq->axq_link = NULL; 4942 4934 4943 ATH_TXQ_UNLOCK(txq); 4935 ATH_TXQ_UNLOCK_IRQ(txq); 4936 4944 4937 /* 4945 4938 * restart the DMA from the first 4946 4939 * buffer that was not DMA'd. … … 4966 4959 skb = bf->bf_skb; 4967 4960 bf->bf_skb = NULL; 4968 4961 bf->bf_node = NULL; 4969 ATH_TXBUF_LOCK(sc); 4962 4963 ATH_TXBUF_LOCK_IRQ(sc); 4970 4964 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 4971 ATH_TXBUF_UNLOCK(sc); 4965 ATH_TXBUF_UNLOCK_IRQ(sc); 4966 4972 4967 ath_hardstart(skb,sc->sc_dev); 4973 4968 ATH_TXQ_REMOVE_HEAD(&tmp_q, bf_list); 4974 4969 bf = STAILQ_FIRST(&tmp_q.axq_q); … … 4990 4985 for (index = 0; index <= WME_AC_VO; index++) 4991 4986 STAILQ_INIT(&wme_tmp_qs[index].axq_q); 4992 4987 txq = sc->sc_xrtxq; 4993 ATH_TXQ_LOCK(txq); 4988 4989 ATH_TXQ_LOCK_IRQ(txq); 4994 4990 ath_hal_stoptxdma(ah, txq->axq_qnum); 4995 4991 bf = prev = STAILQ_FIRST(&txq->axq_q); 4996 4992 /* … … 5093 5089 */ 5094 5090 txq->axq_link = NULL; 5095 5091 } 5096 ATH_TXQ_UNLOCK(txq); 5092 ATH_TXQ_UNLOCK_IRQ(txq); 5093 5097 5094 /* 5098 5095 * restart the DMA from the first 5099 5096 * buffer that was not DMA'd. … … 5102 5099 bf = STAILQ_NEXT(bf_tmp1,bf_list); 5103 5100 else 5104 5101 bf = STAILQ_FIRST(&txq->axq_q); 5102 5105 5103 if (bf) { 5106 5104 ath_hal_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr); 5107 5105 ath_hal_txstart(ah, txq->axq_qnum); 5108 5106 } 5109 5107 5110 /* 5111 * move (concant) the lists from the temp sw queues in to 5112 * WME queues. 5113 */ 5108 /* Move (concat.) the lists from the temp. SW queues in to 5109 * WME queues. */ 5114 5110 index = WME_AC_VO; 5115 txq = NULL; 5116 while (index >= WME_AC_BE) { 5117 prevq = txq; 5111 while (index >= WME_AC_BE) { 5118 5112 txq = sc->sc_ac2q[index]; 5119 if (txq != prevq) {5120 ATH_TXQ_LOCK(txq);5121 ath_hal_stoptxdma(ah, txq->axq_qnum);5122 }5123 5113 5124 wmeq = &wme_tmp_qs[index]; 5125 bf = STAILQ_FIRST(&wmeq->axq_q); 5126 if (bf) { 5127 ATH_TXQ_MOVE_Q(wmeq,txq); 5128 if (txq->axq_link != NULL) { 5114 ATH_TXQ_LOCK_IRQ(txq); 5115 ath_hal_stoptxdma(ah, txq->axq_qnum); 5116 5117 while ((txq == sc->sc_ac2q[index]) && (index >= WME_AC_BE)) { 5118 wmeq = &wme_tmp_qs[index]; 5119 bf = STAILQ_FIRST(&wmeq->axq_q); 5120 if (bf) { 5121 ATH_TXQ_MOVE_Q(wmeq, txq); 5122 if (txq->axq_link != NULL) { 5129 5123 #ifdef AH_NEED_DESC_SWAP 5130 *(txq->axq_link) = cpu_to_le32(bf->bf_daddr);5124 *(txq->axq_link) = cpu_to_le32(bf->bf_daddr); 5131 5125 #else 5132 *(txq->axq_link) = bf->bf_daddr;5126 *(txq->axq_link) = bf->bf_daddr; 5133 5127 #endif 5134 } 5128 } 5129 } 5130 index--; 5135 5131 } 5136 if (index == WME_AC_BE || txq != prevq) { 5137 /* 5138 * find the first buffer to be DMA'd. 5139 */ 5140 bf = STAILQ_FIRST(&txq->axq_q); 5141 while (bf) { 5132 5133 /* Find the first buffer to be DMA'd. */ 5134 bf = STAILQ_FIRST(&txq->axq_q); 5135 while (bf) { 5142 5136 #ifdef ATH_SUPERG_FF 5143 ds = &bf->bf_desc[bf->bf_numdescff];5137 ds = &bf->bf_desc[bf->bf_numdescff]; 5144 5138 #else 5145 ds = bf->bf_desc; /* NB: last descriptor */5139 ds = bf->bf_desc; /* NB: last descriptor */ 5146 5140 #endif 5147 ts = &bf->bf_dsstatus.ds_txstat; 5148 status = ath_hal_txprocdesc(ah, ds, ts); 5149 if (status == HAL_EINPROGRESS) 5150 break; 5151 bf = STAILQ_NEXT(bf,bf_list); 5152 } 5153 if (bf) { 5154 ath_hal_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr); 5155 ath_hal_txstart(ah, txq->axq_qnum); 5156 } 5157 ATH_TXQ_UNLOCK(txq); 5141 ts = &bf->bf_dsstatus.ds_txstat; 5142 status = ath_hal_txprocdesc(ah, ds, ts); 5143 if (status == HAL_EINPROGRESS) 5144 break; 5145 bf = STAILQ_NEXT(bf, bf_list); 5158 5146 } 5159 index--; 5147 5148 if (bf) { 5149 ath_hal_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr); 5150 ath_hal_txstart(ah, txq->axq_qnum); 5151 } 5152 5153 ATH_TXQ_UNLOCK_IRQ(txq); 5160 5154 } 5155 5161 5156 printk("moved %d buffers from XR to NORMAL\n", count); 5162 5157 } 5163 5158 #endif … … 5578 5573 * Reject error frames if we have no vaps that 5579 5574 * are operating in monitor mode. 5580 5575 */ 5581 if(sc->sc_nmonvaps == 0) goto rx_next; 5576 if (sc->sc_nmonvaps == 0) 5577 goto rx_next; 5582 5578 } 5583 5579 rx_accept: 5584 5580 /* … … 5656 5652 * Normal receive. 5657 5653 */ 5658 5654 5659 if (IFF_DUMPPKTS(sc, ATH_DEBUG_RECV)) {5655 if (IFF_DUMPPKTS(sc, ATH_DEBUG_RECV)) 5660 5656 ieee80211_dump_pkt(ic, skb->data, skb->len, 5661 5657 sc->sc_hwmap[rs->rs_rate].ieeerate, 5662 5658 rs->rs_rssi); 5663 }5664 5659 5665 5660 /* 5666 5661 * Locate the node for sender, track state, and then … … 6118 6113 6119 6114 /* move the grppool bufs back to the grppollbuf */ 6120 6115 for (;;) { 6121 ATH_TXQ_LOCK (txq);6116 ATH_TXQ_LOCK_IRQ(txq); 6122 6117 bf = STAILQ_FIRST(&txq->axq_q); 6123 6118 if (bf == NULL) { 6124 6119 txq->axq_link = NULL; 6125 ATH_TXQ_UNLOCK (txq);6120 ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 6126 6121 break; 6127 6122 } 6128 6123 ATH_TXQ_REMOVE_HEAD(txq, bf_list); 6129 ATH_TXQ_UNLOCK(txq); 6124 ATH_TXQ_UNLOCK_IRQ(txq); 6125 6130 6126 bus_unmap_single(sc->sc_bdev, 6131 6127 bf->bf_skbaddr, bf->bf_skb->len, BUS_DMA_TODEVICE); 6132 6128 dev_kfree_skb(bf->bf_skb); 6133 6129 bf->bf_skb = NULL; 6134 6130 bf->bf_node = NULL; 6135 6131 6136 ATH_TXBUF_LOCK (sc);6132 ATH_TXBUF_LOCK_IRQ(sc); 6137 6133 STAILQ_INSERT_TAIL(&sc->sc_grppollbuf, bf, bf_list); 6138 ATH_TXBUF_UNLOCK (sc);6134 ATH_TXBUF_UNLOCK_IRQ(sc); 6139 6135 } 6140 6136 STAILQ_INIT(&txq->axq_q); 6141 6137 ATH_TXQ_LOCK_INIT(txq); … … 6497 6493 dev_kfree_skb(lastbuf->bf_skb); 6498 6494 lastbuf->bf_skb = NULL; 6499 6495 ieee80211_unref_node(&lastbuf->bf_node); 6496 6500 6497 ATH_TXBUF_LOCK_IRQ(sc); 6501 6498 STAILQ_INSERT_TAIL(&sc->sc_txbuf, lastbuf, bf_list); 6502 6499 ATH_TXBUF_UNLOCK_IRQ(sc); … … 7127 7124 struct ath_hal *ah = sc->sc_ah; 7128 7125 struct ath_buf *bf = NULL; 7129 7126 struct ath_desc *ds = NULL; 7130 struct ath_tx_status *ts ;7127 struct ath_tx_status *ts = NULL; 7131 7128 struct ieee80211_node *ni = NULL; 7132 7129 struct ath_node *an = NULL; 7133 7130 unsigned int sr, lr; 7134 7131 HAL_STATUS status; 7135 7132 int uapsdq = 0; 7136 unsigned long uapsdq_lockflags = 0;7137 7133 u_int64_t tsf = 0; /* Only needed for monitor mode */ 7138 7134 7139 7135 DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: tx queue %d (0x%x), link %p\n", __func__, … … 7149 7145 } 7150 7146 7151 7147 for (;;) { 7152 if (uapsdq) 7153 ATH_TXQ_UAPSDQ_LOCK_IRQ(txq); 7154 else 7155 ATH_TXQ_LOCK(txq); 7148 ATH_TXQ_LOCK_IRQ(txq); 7149 7156 7150 txq->axq_intrcnt = 0; /* reset periodic desc intr count */ 7157 7151 bf = STAILQ_FIRST(&txq->axq_q); 7158 7152 if (bf == NULL) { 7159 7153 txq->axq_link = NULL; 7160 if (uapsdq) 7161 ATH_TXQ_UAPSDQ_UNLOCK_IRQ(txq); 7162 else 7163 ATH_TXQ_UNLOCK(txq); 7154 ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 7164 7155 break; 7165 7156 } 7166 7157 … … 7178 7169 ath_printtxbuf(bf, status == HAL_OK); 7179 7170 #endif 7180 7171 if (status == HAL_EINPROGRESS) { 7181 if (uapsdq) 7182 ATH_TXQ_UAPSDQ_UNLOCK_IRQ(txq); 7183 else 7184 ATH_TXQ_UNLOCK(txq); 7172 ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 7185 7173 break; 7186 7174 } 7187 7175 7188 7176 ATH_TXQ_REMOVE_HEAD(txq, bf_list); 7189 if (uapsdq) 7190 ATH_TXQ_UAPSDQ_UNLOCK_IRQ(txq); 7191 else 7192 ATH_TXQ_UNLOCK(txq); 7177 ATH_TXQ_UNLOCK_IRQ(txq); 7193 7178 7194 7179 ni = bf->bf_node; 7195 7180 if (ni != NULL) { … … 7465 7450 * we do not need to block ath_tx_tasklet 7466 7451 */ 7467 7452 for (;;) { 7468 ATH_TXQ_LOCK (txq);7453 ATH_TXQ_LOCK_IRQ(txq); 7469 7454 bf = STAILQ_FIRST(&txq->axq_q); 7470 7455 if (bf == NULL) { 7471 7456 txq->axq_link = NULL; 7472 ATH_TXQ_UNLOCK (txq);7457 ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 7473 7458 break; 7474 7459 } 7475 7460 ATH_TXQ_REMOVE_HEAD(txq, bf_list); 7476 ATH_TXQ_UNLOCK (txq);7461 ATH_TXQ_UNLOCK_IRQ(txq); 7477 7462 #ifdef AR_DEBUG 7478 7463 if (sc->sc_debug & ATH_DEBUG_RESET) 7479 7464 ath_printtxbuf(bf, ath_hal_txprocdesc(ah, bf->bf_desc, &bf->bf_dsstatus.ds_txstat) == HAL_OK); … … 7500 7485 bf->bf_skb = NULL; 7501 7486 bf->bf_node = NULL; 7502 7487 7503 ATH_TXBUF_LOCK (sc);7488 ATH_TXBUF_LOCK_IRQ(sc); 7504 7489 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 7505 ATH_TXBUF_UNLOCK (sc);7490 ATH_TXBUF_UNLOCK_IRQ(sc); 7506 7491 } 7507 7492 } 7508 7493 … … 7697 7682 sc->sc_curchan.channelFlags), sc->sc_curchan.channel, 7698 7683 ath_hal_mhz2ieee(ah, hchan.channel, hchan.channelFlags), 7699 7684 hchan.channel); 7685 7700 7686 /* check if it is turbo mode switch */ 7701 7687 if (hchan.channel == sc->sc_curchan.channel && 7702 7688 (hchan.channelFlags & IEEE80211_CHAN_TURBO) != (sc->sc_curchan.channelFlags & IEEE80211_CHAN_TURBO)) 7703 7689 tswitch = 1; 7690 7704 7691 if (hchan.channel != sc->sc_curchan.channel || 7705 7692 hchan.channelFlags != sc->sc_curchan.channelFlags) { 7706 7693 HAL_STATUS status; … … 7767 7754 sc->sc_dfswaittimer.data = (unsigned long)sc; 7768 7755 add_timer(&sc->sc_dfswaittimer); 7769 7756 } 7770 } else 7771 if (sc->sc_dfswait == 1) 7772 mod_timer(&sc->sc_dfswaittimer, jiffies + 2); 7757 } else if (sc->sc_dfswait == 1) 7758 mod_timer(&sc->sc_dfswaittimer, jiffies + 2); 7773 7759 } 7774 7760 /* 7775 7761 * re configure beacons when it is a turbo mode switch.
