status.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2002-2005, Instant802 Networks, Inc.
00003  * Copyright 2005-2006, Devicescape Software, Inc.
00004  * Copyright 2006-2007  Jiri Benc <jbenc@suse.cz>
00005  * Copyright 2008-2010  Johannes Berg <johannes@sipsolutions.net>
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License version 2 as
00009  * published by the Free Software Foundation.
00010  */
00011 
00012 #include <linux/export.h>
00013 #include <net/mac80211.h>
00014 #include "ieee80211_i.h"
00015 #include "rate.h"
00016 #include "mesh.h"
00017 #include "led.h"
00018 #include "wme.h"
00019 
00020 
00021 void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
00022                                  struct sk_buff *skb)
00023 {
00024         struct ieee80211_local *local = hw_to_local(hw);
00025         struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
00026         int tmp;
00027 
00028         skb->pkt_type = IEEE80211_TX_STATUS_MSG;
00029         skb_queue_tail(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS ?
00030                        &local->skb_queue : &local->skb_queue_unreliable, skb);
00031         tmp = skb_queue_len(&local->skb_queue) +
00032                 skb_queue_len(&local->skb_queue_unreliable);
00033         while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
00034                (skb = skb_dequeue(&local->skb_queue_unreliable))) {
00035                 dev_kfree_skb_irq(skb);
00036                 tmp--;
00037                 I802_DEBUG_INC(local->tx_status_drop);
00038         }
00039         tasklet_schedule(&local->tasklet);
00040 }
00041 EXPORT_SYMBOL(ieee80211_tx_status_irqsafe);
00042 
00043 static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,
00044                                             struct sta_info *sta,
00045                                             struct sk_buff *skb)
00046 {
00047         struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
00048         struct ieee80211_hdr *hdr = (void *)skb->data;
00049         int ac;
00050 
00051         /*
00052          * This skb 'survived' a round-trip through the driver, and
00053          * hopefully the driver didn't mangle it too badly. However,
00054          * we can definitely not rely on the control information
00055          * being correct. Clear it so we don't get junk there, and
00056          * indicate that it needs new processing, but must not be
00057          * modified/encrypted again.
00058          */
00059         memset(&info->control, 0, sizeof(info->control));
00060 
00061         info->control.jiffies = jiffies;
00062         info->control.vif = &sta->sdata->vif;
00063         info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING |
00064                        IEEE80211_TX_INTFL_RETRANSMISSION;
00065         info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS;
00066 
00067         sta->tx_filtered_count++;
00068 
00069         /*
00070          * Clear more-data bit on filtered frames, it might be set
00071          * but later frames might time out so it might have to be
00072          * clear again ... It's all rather unlikely (this frame
00073          * should time out first, right?) but let's not confuse
00074          * peers unnecessarily.
00075          */
00076         if (hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_MOREDATA))
00077                 hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_MOREDATA);
00078 
00079         if (ieee80211_is_data_qos(hdr->frame_control)) {
00080                 u8 *p = ieee80211_get_qos_ctl(hdr);
00081                 int tid = *p & IEEE80211_QOS_CTL_TID_MASK;
00082 
00083                 /*
00084                  * Clear EOSP if set, this could happen e.g.
00085                  * if an absence period (us being a P2P GO)
00086                  * shortens the SP.
00087                  */
00088                 if (*p & IEEE80211_QOS_CTL_EOSP)
00089                         *p &= ~IEEE80211_QOS_CTL_EOSP;
00090                 ac = ieee802_1d_to_ac[tid & 7];
00091         } else {
00092                 ac = IEEE80211_AC_BE;
00093         }
00094 
00095         /*
00096          * Clear the TX filter mask for this STA when sending the next
00097          * packet. If the STA went to power save mode, this will happen
00098          * when it wakes up for the next time.
00099          */
00100         set_sta_flag(sta, WLAN_STA_CLEAR_PS_FILT);
00101 
00102         /*
00103          * This code races in the following way:
00104          *
00105          *  (1) STA sends frame indicating it will go to sleep and does so
00106          *  (2) hardware/firmware adds STA to filter list, passes frame up
00107          *  (3) hardware/firmware processes TX fifo and suppresses a frame
00108          *  (4) we get TX status before having processed the frame and
00109          *      knowing that the STA has gone to sleep.
00110          *
00111          * This is actually quite unlikely even when both those events are
00112          * processed from interrupts coming in quickly after one another or
00113          * even at the same time because we queue both TX status events and
00114          * RX frames to be processed by a tasklet and process them in the
00115          * same order that they were received or TX status last. Hence, there
00116          * is no race as long as the frame RX is processed before the next TX
00117          * status, which drivers can ensure, see below.
00118          *
00119          * Note that this can only happen if the hardware or firmware can
00120          * actually add STAs to the filter list, if this is done by the
00121          * driver in response to set_tim() (which will only reduce the race
00122          * this whole filtering tries to solve, not completely solve it)
00123          * this situation cannot happen.
00124          *
00125          * To completely solve this race drivers need to make sure that they
00126          *  (a) don't mix the irq-safe/not irq-safe TX status/RX processing
00127          *      functions and
00128          *  (b) always process RX events before TX status events if ordering
00129          *      can be unknown, for example with different interrupt status
00130          *      bits.
00131          *  (c) if PS mode transitions are manual (i.e. the flag
00132          *      %IEEE80211_HW_AP_LINK_PS is set), always process PS state
00133          *      changes before calling TX status events if ordering can be
00134          *      unknown.
00135          */
00136         if (test_sta_flag(sta, WLAN_STA_PS_STA) &&
00137             skb_queue_len(&sta->tx_filtered[ac]) < STA_MAX_TX_BUFFER) {
00138                 skb_queue_tail(&sta->tx_filtered[ac], skb);
00139                 sta_info_recalc_tim(sta);
00140 
00141                 if (!timer_pending(&local->sta_cleanup))
00142                         mod_timer(&local->sta_cleanup,
00143                                   round_jiffies(jiffies +
00144                                                 STA_INFO_CLEANUP_INTERVAL));
00145                 return;
00146         }
00147 
00148         if (!test_sta_flag(sta, WLAN_STA_PS_STA) &&
00149             !(info->flags & IEEE80211_TX_INTFL_RETRIED)) {
00150                 /* Software retry the packet once */
00151                 info->flags |= IEEE80211_TX_INTFL_RETRIED;
00152                 ieee80211_add_pending_skb(local, skb);
00153                 return;
00154         }
00155 
00156 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
00157         if (net_ratelimit())
00158                 wiphy_debug(local->hw.wiphy,
00159                             "dropped TX filtered frame, queue_len=%d PS=%d @%lu\n",
00160                             skb_queue_len(&sta->tx_filtered[ac]),
00161                             !!test_sta_flag(sta, WLAN_STA_PS_STA), jiffies);
00162 #endif
00163         dev_kfree_skb(skb);
00164 }
00165 
00166 static void ieee80211_check_pending_bar(struct sta_info *sta, u8 *addr, u8 tid)
00167 {
00168         struct tid_ampdu_tx *tid_tx;
00169 
00170         tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
00171         if (!tid_tx || !tid_tx->bar_pending)
00172                 return;
00173 
00174         tid_tx->bar_pending = false;
00175         ieee80211_send_bar(&sta->sdata->vif, addr, tid, tid_tx->failed_bar_ssn);
00176 }
00177 
00178 static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb)
00179 {
00180         struct ieee80211_mgmt *mgmt = (void *) skb->data;
00181         struct ieee80211_local *local = sta->local;
00182         struct ieee80211_sub_if_data *sdata = sta->sdata;
00183 
00184         if (ieee80211_is_data_qos(mgmt->frame_control)) {
00185                 struct ieee80211_hdr *hdr = (void *) skb->data;
00186                 u8 *qc = ieee80211_get_qos_ctl(hdr);
00187                 u16 tid = qc[0] & 0xf;
00188 
00189                 ieee80211_check_pending_bar(sta, hdr->addr1, tid);
00190         }
00191 
00192         if (ieee80211_is_action(mgmt->frame_control) &&
00193             sdata->vif.type == NL80211_IFTYPE_STATION &&
00194             mgmt->u.action.category == WLAN_CATEGORY_HT &&
00195             mgmt->u.action.u.ht_smps.action == WLAN_HT_ACTION_SMPS) {
00196                 /*
00197                  * This update looks racy, but isn't -- if we come
00198                  * here we've definitely got a station that we're
00199                  * talking to, and on a managed interface that can
00200                  * only be the AP. And the only other place updating
00201                  * this variable is before we're associated.
00202                  */
00203                 switch (mgmt->u.action.u.ht_smps.smps_control) {
00204                 case WLAN_HT_SMPS_CONTROL_DYNAMIC:
00205                         sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_DYNAMIC;
00206                         break;
00207                 case WLAN_HT_SMPS_CONTROL_STATIC:
00208                         sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_STATIC;
00209                         break;
00210                 case WLAN_HT_SMPS_CONTROL_DISABLED:
00211                 default: /* shouldn't happen since we don't send that */
00212                         sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_OFF;
00213                         break;
00214                 }
00215 
00216                 ieee80211_queue_work(&local->hw, &local->recalc_smps);
00217         }
00218 }
00219 
00220 static void ieee80211_set_bar_pending(struct sta_info *sta, u8 tid, u16 ssn)
00221 {
00222         struct tid_ampdu_tx *tid_tx;
00223 
00224         tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
00225         if (!tid_tx)
00226                 return;
00227 
00228         tid_tx->failed_bar_ssn = ssn;
00229         tid_tx->bar_pending = true;
00230 }
00231 
00232 static int ieee80211_tx_radiotap_len(struct ieee80211_tx_info *info)
00233 {
00234         int len = sizeof(struct ieee80211_radiotap_header);
00235 
00236         /* IEEE80211_RADIOTAP_RATE rate */
00237         if (info->status.rates[0].idx >= 0 &&
00238             !(info->status.rates[0].flags & IEEE80211_TX_RC_MCS))
00239                 len += 2;
00240 
00241         /* IEEE80211_RADIOTAP_TX_FLAGS */
00242         len += 2;
00243 
00244         /* IEEE80211_RADIOTAP_DATA_RETRIES */
00245         len += 1;
00246 
00247         /* IEEE80211_TX_RC_MCS */
00248         if (info->status.rates[0].idx >= 0 &&
00249             info->status.rates[0].flags & IEEE80211_TX_RC_MCS)
00250                 len += 3;
00251 
00252         return len;
00253 }
00254 
00255 static void ieee80211_add_tx_radiotap_header(struct ieee80211_supported_band
00256                                              *sband, struct sk_buff *skb,
00257                                              int retry_count, int rtap_len)
00258 {
00259         struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
00260         struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
00261         struct ieee80211_radiotap_header *rthdr;
00262         unsigned char *pos;
00263         u16 txflags;
00264 
00265         rthdr = (struct ieee80211_radiotap_header *) skb_push(skb, rtap_len);
00266 
00267         memset(rthdr, 0, rtap_len);
00268         rthdr->it_len = cpu_to_le16(rtap_len);
00269         rthdr->it_present =
00270                 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) |
00271                             (1 << IEEE80211_RADIOTAP_DATA_RETRIES));
00272         pos = (unsigned char *)(rthdr + 1);
00273 
00274         /*
00275          * XXX: Once radiotap gets the bitmap reset thing the vendor
00276          *      extensions proposal contains, we can actually report
00277          *      the whole set of tries we did.
00278          */
00279 
00280         /* IEEE80211_RADIOTAP_RATE */
00281         if (info->status.rates[0].idx >= 0 &&
00282             !(info->status.rates[0].flags & IEEE80211_TX_RC_MCS)) {
00283                 rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_RATE);
00284                 *pos = sband->bitrates[info->status.rates[0].idx].bitrate / 5;
00285                 /* padding for tx flags */
00286                 pos += 2;
00287         }
00288 
00289         /* IEEE80211_RADIOTAP_TX_FLAGS */
00290         txflags = 0;
00291         if (!(info->flags & IEEE80211_TX_STAT_ACK) &&
00292             !is_multicast_ether_addr(hdr->addr1))
00293                 txflags |= IEEE80211_RADIOTAP_F_TX_FAIL;
00294 
00295         if ((info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
00296             (info->status.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT))
00297                 txflags |= IEEE80211_RADIOTAP_F_TX_CTS;
00298         else if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
00299                 txflags |= IEEE80211_RADIOTAP_F_TX_RTS;
00300 
00301         put_unaligned_le16(txflags, pos);
00302         pos += 2;
00303 
00304         /* IEEE80211_RADIOTAP_DATA_RETRIES */
00305         /* for now report the total retry_count */
00306         *pos = retry_count;
00307         pos++;
00308 
00309         /* IEEE80211_TX_RC_MCS */
00310         if (info->status.rates[0].idx >= 0 &&
00311             info->status.rates[0].flags & IEEE80211_TX_RC_MCS) {
00312                 rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_MCS);
00313                 pos[0] = IEEE80211_RADIOTAP_MCS_HAVE_MCS |
00314                          IEEE80211_RADIOTAP_MCS_HAVE_GI |
00315                          IEEE80211_RADIOTAP_MCS_HAVE_BW;
00316                 if (info->status.rates[0].flags & IEEE80211_TX_RC_SHORT_GI)
00317                         pos[1] |= IEEE80211_RADIOTAP_MCS_SGI;
00318                 if (info->status.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
00319                         pos[1] |= IEEE80211_RADIOTAP_MCS_BW_40;
00320                 if (info->status.rates[0].flags & IEEE80211_TX_RC_GREEN_FIELD)
00321                         pos[1] |= IEEE80211_RADIOTAP_MCS_FMT_GF;
00322                 pos[2] = info->status.rates[0].idx;
00323                 pos += 3;
00324         }
00325 
00326 }
00327 
00328 /*
00329  * Use a static threshold for now, best value to be determined
00330  * by testing ...
00331  * Should it depend on:
00332  *  - on # of retransmissions
00333  *  - current throughput (higher value for higher tpt)?
00334  */
00335 #define STA_LOST_PKT_THRESHOLD  50
00336 
00337 void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
00338 {
00339         struct sk_buff *skb2;
00340         struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
00341         struct ieee80211_local *local = hw_to_local(hw);
00342         struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
00343         u16 frag, type;
00344         __le16 fc;
00345         struct ieee80211_supported_band *sband;
00346         struct ieee80211_sub_if_data *sdata;
00347         struct net_device *prev_dev = NULL;
00348         struct sta_info *sta, *tmp;
00349         int retry_count = -1, i;
00350         int rates_idx = -1;
00351         bool send_to_cooked;
00352         bool acked;
00353         struct ieee80211_bar *bar;
00354         u16 tid;
00355         int rtap_len;
00356 
00357         for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
00358                 if (info->status.rates[i].idx < 0) {
00359                         break;
00360                 } else if (i >= hw->max_report_rates) {
00361                         /* the HW cannot have attempted that rate */
00362                         info->status.rates[i].idx = -1;
00363                         info->status.rates[i].count = 0;
00364                         break;
00365                 }
00366 
00367                 retry_count += info->status.rates[i].count;
00368         }
00369         rates_idx = i - 1;
00370 
00371         if (retry_count < 0)
00372                 retry_count = 0;
00373 
00374         rcu_read_lock();
00375 
00376         sband = local->hw.wiphy->bands[info->band];
00377         fc = hdr->frame_control;
00378 
00379         for_each_sta_info(local, hdr->addr1, sta, tmp) {
00380                 /* skip wrong virtual interface */
00381                 if (memcmp(hdr->addr2, sta->sdata->vif.addr, ETH_ALEN))
00382                         continue;
00383 
00384                 if (info->flags & IEEE80211_TX_STATUS_EOSP)
00385                         clear_sta_flag(sta, WLAN_STA_SP);
00386 
00387                 acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
00388                 if (!acked && test_sta_flag(sta, WLAN_STA_PS_STA)) {
00389                         /*
00390                          * The STA is in power save mode, so assume
00391                          * that this TX packet failed because of that.
00392                          */
00393                         ieee80211_handle_filtered_frame(local, sta, skb);
00394                         rcu_read_unlock();
00395                         return;
00396                 }
00397 
00398                 if ((local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) &&
00399                     (rates_idx != -1))
00400                         sta->last_tx_rate = info->status.rates[rates_idx];
00401 
00402                 if ((info->flags & IEEE80211_TX_STAT_AMPDU_NO_BACK) &&
00403                     (ieee80211_is_data_qos(fc))) {
00404                         u16 tid, ssn;
00405                         u8 *qc;
00406 
00407                         qc = ieee80211_get_qos_ctl(hdr);
00408                         tid = qc[0] & 0xf;
00409                         ssn = ((le16_to_cpu(hdr->seq_ctrl) + 0x10)
00410                                                 & IEEE80211_SCTL_SEQ);
00411                         ieee80211_send_bar(&sta->sdata->vif, hdr->addr1,
00412                                            tid, ssn);
00413                 }
00414 
00415                 if (!acked && ieee80211_is_back_req(fc)) {
00416                         u16 control;
00417 
00418                         /*
00419                          * BAR failed, store the last SSN and retry sending
00420                          * the BAR when the next unicast transmission on the
00421                          * same TID succeeds.
00422                          */
00423                         bar = (struct ieee80211_bar *) skb->data;
00424                         control = le16_to_cpu(bar->control);
00425                         if (!(control & IEEE80211_BAR_CTRL_MULTI_TID)) {
00426                                 u16 ssn = le16_to_cpu(bar->start_seq_num);
00427 
00428                                 tid = (control &
00429                                        IEEE80211_BAR_CTRL_TID_INFO_MASK) >>
00430                                       IEEE80211_BAR_CTRL_TID_INFO_SHIFT;
00431 
00432                                 ieee80211_set_bar_pending(sta, tid, ssn);
00433                         }
00434                 }
00435 
00436                 if (info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
00437                         ieee80211_handle_filtered_frame(local, sta, skb);
00438                         rcu_read_unlock();
00439                         return;
00440                 } else {
00441                         if (!acked)
00442                                 sta->tx_retry_failed++;
00443                         sta->tx_retry_count += retry_count;
00444                 }
00445 
00446                 rate_control_tx_status(local, sband, sta, skb);
00447                 if (ieee80211_vif_is_mesh(&sta->sdata->vif))
00448                         ieee80211s_update_metric(local, sta, skb);
00449 
00450                 if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
00451                         ieee80211_frame_acked(sta, skb);
00452 
00453                 if ((sta->sdata->vif.type == NL80211_IFTYPE_STATION) &&
00454                     (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS))
00455                         ieee80211_sta_tx_notify(sta->sdata, (void *) skb->data, acked);
00456 
00457                 if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) {
00458                         if (info->flags & IEEE80211_TX_STAT_ACK) {
00459                                 if (sta->lost_packets)
00460                                         sta->lost_packets = 0;
00461                         } else if (++sta->lost_packets >= STA_LOST_PKT_THRESHOLD) {
00462                                 cfg80211_cqm_pktloss_notify(sta->sdata->dev,
00463                                                             sta->sta.addr,
00464                                                             sta->lost_packets,
00465                                                             GFP_ATOMIC);
00466                                 sta->lost_packets = 0;
00467                         }
00468                 }
00469         }
00470 
00471         rcu_read_unlock();
00472 
00473         ieee80211_led_tx(local, 0);
00474 
00475         /* SNMP counters
00476          * Fragments are passed to low-level drivers as separate skbs, so these
00477          * are actually fragments, not frames. Update frame counters only for
00478          * the first fragment of the frame. */
00479 
00480         frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
00481         type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE;
00482 
00483         if (info->flags & IEEE80211_TX_STAT_ACK) {
00484                 if (frag == 0) {
00485                         local->dot11TransmittedFrameCount++;
00486                         if (is_multicast_ether_addr(hdr->addr1))
00487                                 local->dot11MulticastTransmittedFrameCount++;
00488                         if (retry_count > 0)
00489                                 local->dot11RetryCount++;
00490                         if (retry_count > 1)
00491                                 local->dot11MultipleRetryCount++;
00492                 }
00493 
00494                 /* This counter shall be incremented for an acknowledged MPDU
00495                  * with an individual address in the address 1 field or an MPDU
00496                  * with a multicast address in the address 1 field of type Data
00497                  * or Management. */
00498                 if (!is_multicast_ether_addr(hdr->addr1) ||
00499                     type == IEEE80211_FTYPE_DATA ||
00500                     type == IEEE80211_FTYPE_MGMT)
00501                         local->dot11TransmittedFragmentCount++;
00502         } else {
00503                 if (frag == 0)
00504                         local->dot11FailedCount++;
00505         }
00506 
00507         if (ieee80211_is_nullfunc(fc) && ieee80211_has_pm(fc) &&
00508             (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) &&
00509             !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
00510             local->ps_sdata && !(local->scanning)) {
00511                 if (info->flags & IEEE80211_TX_STAT_ACK) {
00512                         local->ps_sdata->u.mgd.flags |=
00513                                         IEEE80211_STA_NULLFUNC_ACKED;
00514                 } else
00515                         mod_timer(&local->dynamic_ps_timer, jiffies +
00516                                         msecs_to_jiffies(10));
00517         }
00518 
00519         if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) {
00520                 struct ieee80211_work *wk;
00521                 u64 cookie = (unsigned long)skb;
00522 
00523                 rcu_read_lock();
00524                 list_for_each_entry_rcu(wk, &local->work_list, list) {
00525                         if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX)
00526                                 continue;
00527                         if (wk->offchan_tx.frame != skb)
00528                                 continue;
00529                         wk->offchan_tx.status = true;
00530                         break;
00531                 }
00532                 rcu_read_unlock();
00533                 if (local->hw_roc_skb_for_status == skb) {
00534                         cookie = local->hw_roc_cookie ^ 2;
00535                         local->hw_roc_skb_for_status = NULL;
00536                 }
00537 
00538                 cfg80211_mgmt_tx_status(
00539                         skb->dev, cookie, skb->data, skb->len,
00540                         !!(info->flags & IEEE80211_TX_STAT_ACK), GFP_ATOMIC);
00541         }
00542 
00543         /* this was a transmitted frame, but now we want to reuse it */
00544         skb_orphan(skb);
00545 
00546         /* Need to make a copy before skb->cb gets cleared */
00547         send_to_cooked = !!(info->flags & IEEE80211_TX_CTL_INJECTED) ||
00548                         (type != IEEE80211_FTYPE_DATA);
00549 
00550         /*
00551          * This is a bit racy but we can avoid a lot of work
00552          * with this test...
00553          */
00554         if (!local->monitors && (!send_to_cooked || !local->cooked_mntrs)) {
00555                 dev_kfree_skb(skb);
00556                 return;
00557         }
00558 
00559         /* send frame to monitor interfaces now */
00560         rtap_len = ieee80211_tx_radiotap_len(info);
00561         if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) {
00562                 printk(KERN_ERR "ieee80211_tx_status: headroom too small\n");
00563                 dev_kfree_skb(skb);
00564                 return;
00565         }
00566         ieee80211_add_tx_radiotap_header(sband, skb, retry_count, rtap_len);
00567 
00568         /* XXX: is this sufficient for BPF? */
00569         skb_set_mac_header(skb, 0);
00570         skb->ip_summed = CHECKSUM_UNNECESSARY;
00571         skb->pkt_type = PACKET_OTHERHOST;
00572         skb->protocol = htons(ETH_P_802_2);
00573         memset(skb->cb, 0, sizeof(skb->cb));
00574 
00575         rcu_read_lock();
00576         list_for_each_entry_rcu(sdata, &local->interfaces, list) {
00577                 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
00578                         if (!ieee80211_sdata_running(sdata))
00579                                 continue;
00580 
00581                         if ((sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) &&
00582                             !send_to_cooked)
00583                                 continue;
00584 
00585                         if (prev_dev) {
00586                                 skb2 = skb_clone(skb, GFP_ATOMIC);
00587                                 if (skb2) {
00588                                         skb2->dev = prev_dev;
00589                                         netif_rx(skb2);
00590                                 }
00591                         }
00592 
00593                         prev_dev = sdata->dev;
00594                 }
00595         }
00596         if (prev_dev) {
00597                 skb->dev = prev_dev;
00598                 netif_rx(skb);
00599                 skb = NULL;
00600         }
00601         rcu_read_unlock();
00602         dev_kfree_skb(skb);
00603 }
00604 EXPORT_SYMBOL(ieee80211_tx_status);
00605 
00606 void ieee80211_report_low_ack(struct ieee80211_sta *pubsta, u32 num_packets)
00607 {
00608         struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
00609         cfg80211_cqm_pktloss_notify(sta->sdata->dev, sta->sta.addr,
00610                                     num_packets, GFP_ATOMIC);
00611 }
00612 EXPORT_SYMBOL(ieee80211_report_low_ack);


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Mon Oct 6 2014 08:27:11