~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to drivers/net/wireless/ath/carl9170/tx.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
        spin_unlock_bh(&ar->tx_stats_lock);
105
105
}
106
106
 
 
107
/* needs rcu_read_lock */
 
108
static struct ieee80211_sta *__carl9170_get_tx_sta(struct ar9170 *ar,
 
109
                                                   struct sk_buff *skb)
 
110
{
 
111
        struct _carl9170_tx_superframe *super = (void *) skb->data;
 
112
        struct ieee80211_hdr *hdr = (void *) super->frame_data;
 
113
        struct ieee80211_vif *vif;
 
114
        unsigned int vif_id;
 
115
 
 
116
        vif_id = (super->s.misc & CARL9170_TX_SUPER_MISC_VIF_ID) >>
 
117
                 CARL9170_TX_SUPER_MISC_VIF_ID_S;
 
118
 
 
119
        if (WARN_ON_ONCE(vif_id >= AR9170_MAX_VIRTUAL_MAC))
 
120
                return NULL;
 
121
 
 
122
        vif = rcu_dereference(ar->vif_priv[vif_id].vif);
 
123
        if (unlikely(!vif))
 
124
                return NULL;
 
125
 
 
126
        /*
 
127
         * Normally we should use wrappers like ieee80211_get_DA to get
 
128
         * the correct peer ieee80211_sta.
 
129
         *
 
130
         * But there is a problem with indirect traffic (broadcasts, or
 
131
         * data which is designated for other stations) in station mode.
 
132
         * The frame will be directed to the AP for distribution and not
 
133
         * to the actual destination.
 
134
         */
 
135
 
 
136
        return ieee80211_find_sta(vif, hdr->addr1);
 
137
}
 
138
 
 
139
static void carl9170_tx_ps_unblock(struct ar9170 *ar, struct sk_buff *skb)
 
140
{
 
141
        struct ieee80211_sta *sta;
 
142
        struct carl9170_sta_info *sta_info;
 
143
 
 
144
        rcu_read_lock();
 
145
        sta = __carl9170_get_tx_sta(ar, skb);
 
146
        if (unlikely(!sta))
 
147
                goto out_rcu;
 
148
 
 
149
        sta_info = (struct carl9170_sta_info *) sta->drv_priv;
 
150
        if (atomic_dec_return(&sta_info->pending_frames) == 0)
 
151
                ieee80211_sta_block_awake(ar->hw, sta, false);
 
152
 
 
153
out_rcu:
 
154
        rcu_read_unlock();
 
155
}
 
156
 
107
157
static void carl9170_tx_accounting_free(struct ar9170 *ar, struct sk_buff *skb)
108
158
{
109
 
        struct ieee80211_tx_info *txinfo;
110
159
        int queue;
111
160
 
112
 
        txinfo = IEEE80211_SKB_CB(skb);
113
161
        queue = skb_get_queue_mapping(skb);
114
162
 
115
163
        spin_lock_bh(&ar->tx_stats_lock);
135
183
        }
136
184
 
137
185
        spin_unlock_bh(&ar->tx_stats_lock);
 
186
 
138
187
        if (atomic_dec_and_test(&ar->tx_total_queued))
139
188
                complete(&ar->tx_flush);
140
189
}
329
378
{
330
379
        struct _carl9170_tx_superframe *super = (void *) skb->data;
331
380
        struct ieee80211_hdr *hdr = (void *) super->frame_data;
332
 
        struct ieee80211_tx_info *tx_info;
333
 
        struct carl9170_tx_info *ar_info;
 
381
        struct ieee80211_sta *sta;
334
382
        struct carl9170_sta_info *sta_info;
335
 
        struct ieee80211_sta *sta;
336
383
        struct carl9170_sta_tid *tid_info;
337
 
        struct ieee80211_vif *vif;
338
 
        unsigned int vif_id;
339
384
        u8 tid;
340
385
 
341
386
        if (!(txinfo->flags & IEEE80211_TX_CTL_AMPDU) ||
343
388
           (!(super->f.mac_control & cpu_to_le16(AR9170_TX_MAC_AGGR))))
344
389
                return;
345
390
 
346
 
        tx_info = IEEE80211_SKB_CB(skb);
347
 
        ar_info = (void *) tx_info->rate_driver_data;
348
 
 
349
 
        vif_id = (super->s.misc & CARL9170_TX_SUPER_MISC_VIF_ID) >>
350
 
                 CARL9170_TX_SUPER_MISC_VIF_ID_S;
351
 
 
352
 
        if (WARN_ON_ONCE(vif_id >= AR9170_MAX_VIRTUAL_MAC))
353
 
                return;
354
 
 
355
391
        rcu_read_lock();
356
 
        vif = rcu_dereference(ar->vif_priv[vif_id].vif);
357
 
        if (unlikely(!vif))
358
 
                goto out_rcu;
359
 
 
360
 
        /*
361
 
         * Normally we should use wrappers like ieee80211_get_DA to get
362
 
         * the correct peer ieee80211_sta.
363
 
         *
364
 
         * But there is a problem with indirect traffic (broadcasts, or
365
 
         * data which is designated for other stations) in station mode.
366
 
         * The frame will be directed to the AP for distribution and not
367
 
         * to the actual destination.
368
 
         */
369
 
        sta = ieee80211_find_sta(vif, hdr->addr1);
 
392
        sta = __carl9170_get_tx_sta(ar, skb);
370
393
        if (unlikely(!sta))
371
394
                goto out_rcu;
372
395
 
427
450
        if (txinfo->flags & IEEE80211_TX_CTL_AMPDU)
428
451
                carl9170_tx_status_process_ampdu(ar, skb, txinfo);
429
452
 
 
453
        carl9170_tx_ps_unblock(ar, skb);
430
454
        carl9170_tx_put_skb(skb);
431
455
}
432
456
 
540
564
        struct sk_buff *skb;
541
565
        struct ieee80211_tx_info *txinfo;
542
566
        struct carl9170_tx_info *arinfo;
543
 
        struct _carl9170_tx_superframe *super;
544
567
        struct ieee80211_sta *sta;
545
 
        struct ieee80211_vif *vif;
546
 
        struct ieee80211_hdr *hdr;
547
 
        unsigned int vif_id;
548
568
 
549
569
        rcu_read_lock();
550
570
        list_for_each_entry_rcu(iter, &ar->tx_ampdu_list, list) {
562
582
                    msecs_to_jiffies(CARL9170_QUEUE_TIMEOUT)))
563
583
                        goto unlock;
564
584
 
565
 
                super = (void *) skb->data;
566
 
                hdr = (void *) super->frame_data;
567
 
 
568
 
                vif_id = (super->s.misc & CARL9170_TX_SUPER_MISC_VIF_ID) >>
569
 
                         CARL9170_TX_SUPER_MISC_VIF_ID_S;
570
 
 
571
 
                if (WARN_ON(vif_id >= AR9170_MAX_VIRTUAL_MAC))
572
 
                        goto unlock;
573
 
 
574
 
                vif = rcu_dereference(ar->vif_priv[vif_id].vif);
575
 
                if (WARN_ON(!vif))
576
 
                        goto unlock;
577
 
 
578
 
                sta = ieee80211_find_sta(vif, hdr->addr1);
 
585
                sta = __carl9170_get_tx_sta(ar, skb);
579
586
                if (WARN_ON(!sta))
580
587
                        goto unlock;
581
588
 
611
618
{
612
619
        struct sk_buff *skb;
613
620
        struct ieee80211_tx_info *txinfo;
614
 
        struct carl9170_tx_info *arinfo;
615
621
        unsigned int r, t, q;
616
622
        bool success = true;
617
623
 
627
633
        }
628
634
 
629
635
        txinfo = IEEE80211_SKB_CB(skb);
630
 
        arinfo = (void *) txinfo->rate_driver_data;
631
636
 
632
637
        if (!(info & CARL9170_TX_STATUS_SUCCESS))
633
638
                success = false;
1199
1204
        arinfo = (void *) info->rate_driver_data;
1200
1205
 
1201
1206
        arinfo->timeout = jiffies;
1202
 
 
1203
 
        /*
1204
 
         * increase ref count to "2".
1205
 
         * Ref counting is the easiest way to solve the race between
1206
 
         * the the urb's completion routine: carl9170_tx_callback and
1207
 
         * wlan tx status functions: carl9170_tx_status/janitor.
1208
 
         */
1209
 
        carl9170_tx_get_skb(skb);
1210
 
 
1211
1207
        return skb;
1212
1208
 
1213
1209
err_unlock:
1228
1224
        __carl9170_tx_process_status(ar, super->s.cookie, q);
1229
1225
}
1230
1226
 
 
1227
static bool carl9170_tx_ps_drop(struct ar9170 *ar, struct sk_buff *skb)
 
1228
{
 
1229
        struct ieee80211_sta *sta;
 
1230
        struct carl9170_sta_info *sta_info;
 
1231
 
 
1232
        rcu_read_lock();
 
1233
        sta = __carl9170_get_tx_sta(ar, skb);
 
1234
        if (!sta)
 
1235
                goto out_rcu;
 
1236
 
 
1237
        sta_info = (void *) sta->drv_priv;
 
1238
        if (unlikely(sta_info->sleeping)) {
 
1239
                struct ieee80211_tx_info *tx_info;
 
1240
 
 
1241
                rcu_read_unlock();
 
1242
 
 
1243
                tx_info = IEEE80211_SKB_CB(skb);
 
1244
                if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
 
1245
                        atomic_dec(&ar->tx_ampdu_upload);
 
1246
 
 
1247
                tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
 
1248
                carl9170_tx_status(ar, skb, false);
 
1249
                return true;
 
1250
        }
 
1251
 
 
1252
out_rcu:
 
1253
        rcu_read_unlock();
 
1254
        return false;
 
1255
}
 
1256
 
1231
1257
static void carl9170_tx(struct ar9170 *ar)
1232
1258
{
1233
1259
        struct sk_buff *skb;
1247
1273
                        if (unlikely(!skb))
1248
1274
                                break;
1249
1275
 
 
1276
                        if (unlikely(carl9170_tx_ps_drop(ar, skb)))
 
1277
                                continue;
 
1278
 
1250
1279
                        atomic_inc(&ar->tx_total_pending);
1251
1280
 
1252
1281
                        q = __carl9170_get_queue(ar, i);
1256
1285
                         */
1257
1286
                        skb_queue_tail(&ar->tx_status[q], skb);
1258
1287
 
 
1288
                        /*
 
1289
                         * increase ref count to "2".
 
1290
                         * Ref counting is the easiest way to solve the
 
1291
                         * race between the urb's completion routine:
 
1292
                         *      carl9170_tx_callback
 
1293
                         * and wlan tx status functions:
 
1294
                         *      carl9170_tx_status/janitor.
 
1295
                         */
 
1296
                        carl9170_tx_get_skb(skb);
 
1297
 
1259
1298
                        carl9170_usb_tx(ar, skb);
1260
1299
                        schedule_garbagecollector = true;
1261
1300
                }
1275
1314
        struct carl9170_sta_info *sta_info;
1276
1315
        struct carl9170_sta_tid *agg;
1277
1316
        struct sk_buff *iter;
1278
 
        unsigned int max;
1279
1317
        u16 tid, seq, qseq, off;
1280
1318
        bool run = false;
1281
1319
 
1285
1323
 
1286
1324
        rcu_read_lock();
1287
1325
        agg = rcu_dereference(sta_info->agg[tid]);
1288
 
        max = sta_info->ampdu_max_len;
1289
1326
 
1290
1327
        if (!agg)
1291
1328
                goto err_unlock_rcu;
1368
1405
         * all ressouces which are associated with the frame.
1369
1406
         */
1370
1407
 
 
1408
        if (sta) {
 
1409
                struct carl9170_sta_info *stai = (void *) sta->drv_priv;
 
1410
                atomic_inc(&stai->pending_frames);
 
1411
        }
 
1412
 
1371
1413
        if (info->flags & IEEE80211_TX_CTL_AMPDU) {
1372
1414
                run = carl9170_tx_ampdu_queue(ar, sta, skb);
1373
1415
                if (run)