@@ -318,33 +318,30 @@ minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index)
318
318
* account the expected number of retransmissions and their expected length
319
319
*/
320
320
int
321
- minstrel_ht_get_tp_avg (struct minstrel_ht_sta * mi , int group , int rate )
321
+ minstrel_ht_get_tp_avg (struct minstrel_ht_sta * mi , int group , int rate ,
322
+ int prob_ewma )
322
323
{
323
- struct minstrel_rate_stats * mrs ;
324
324
unsigned int nsecs = 0 ;
325
- unsigned int tmp_prob_ewma ;
326
-
327
- mrs = & mi -> groups [group ].rates [rate ];
328
- tmp_prob_ewma = mrs -> prob_ewma ;
329
325
330
326
/* do not account throughput if sucess prob is below 10% */
331
- if (mrs -> prob_ewma < MINSTREL_FRAC (10 , 100 ))
327
+ if (prob_ewma < MINSTREL_FRAC (10 , 100 ))
332
328
return 0 ;
333
329
334
- /*
335
- * For the throughput calculation, limit the probability value to 90% to
336
- * account for collision related packet error rate fluctuation
337
- */
338
- if (mrs -> prob_ewma > MINSTREL_FRAC (90 , 100 ))
339
- tmp_prob_ewma = MINSTREL_FRAC (90 , 100 );
340
-
341
330
if (group != MINSTREL_CCK_GROUP )
342
331
nsecs = 1000 * mi -> overhead / MINSTREL_TRUNC (mi -> avg_ampdu_len );
343
332
344
333
nsecs += minstrel_mcs_groups [group ].duration [rate ];
345
334
346
- /* prob is scaled - see MINSTREL_FRAC above */
347
- return MINSTREL_TRUNC (100000 * ((tmp_prob_ewma * 1000 ) / nsecs ));
335
+ /*
336
+ * For the throughput calculation, limit the probability value to 90% to
337
+ * account for collision related packet error rate fluctuation
338
+ * (prob is scaled - see MINSTREL_FRAC above)
339
+ */
340
+ if (prob_ewma > MINSTREL_FRAC (90 , 100 ))
341
+ return MINSTREL_TRUNC (100000 * ((MINSTREL_FRAC (90 , 100 ) * 1000 )
342
+ / nsecs ));
343
+ else
344
+ return MINSTREL_TRUNC (100000 * ((prob_ewma * 1000 ) / nsecs ));
348
345
}
349
346
350
347
/*
@@ -364,14 +361,15 @@ minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index,
364
361
365
362
cur_group = index / MCS_GROUP_RATES ;
366
363
cur_idx = index % MCS_GROUP_RATES ;
367
- cur_tp_avg = minstrel_ht_get_tp_avg (mi , cur_group , cur_idx );
368
364
cur_prob = mi -> groups [cur_group ].rates [cur_idx ].prob_ewma ;
365
+ cur_tp_avg = minstrel_ht_get_tp_avg (mi , cur_group , cur_idx , cur_prob );
369
366
370
367
do {
371
368
tmp_group = tp_list [j - 1 ] / MCS_GROUP_RATES ;
372
369
tmp_idx = tp_list [j - 1 ] % MCS_GROUP_RATES ;
373
- tmp_tp_avg = minstrel_ht_get_tp_avg (mi , tmp_group , tmp_idx );
374
370
tmp_prob = mi -> groups [tmp_group ].rates [tmp_idx ].prob_ewma ;
371
+ tmp_tp_avg = minstrel_ht_get_tp_avg (mi , tmp_group , tmp_idx ,
372
+ tmp_prob );
375
373
if (cur_tp_avg < tmp_tp_avg ||
376
374
(cur_tp_avg == tmp_tp_avg && cur_prob <= tmp_prob ))
377
375
break ;
@@ -396,8 +394,8 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
396
394
struct minstrel_rate_stats * mrs ;
397
395
int tmp_group , tmp_idx , tmp_tp_avg , tmp_prob ;
398
396
int max_tp_group , cur_tp_avg , cur_group , cur_idx ;
399
- int max_group_prob_rate_group , max_group_prob_rate_idx ;
400
- int max_group_prob_rate_tp_avg ;
397
+ int max_gpr_group , max_gpr_idx ;
398
+ int max_gpr_tp_avg , max_gpr_prob ;
401
399
402
400
cur_group = index / MCS_GROUP_RATES ;
403
401
cur_idx = index % MCS_GROUP_RATES ;
@@ -406,8 +404,8 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
406
404
407
405
tmp_group = mi -> max_prob_rate / MCS_GROUP_RATES ;
408
406
tmp_idx = mi -> max_prob_rate % MCS_GROUP_RATES ;
409
- tmp_tp_avg = minstrel_ht_get_tp_avg (mi , tmp_group , tmp_idx );
410
407
tmp_prob = mi -> groups [tmp_group ].rates [tmp_idx ].prob_ewma ;
408
+ tmp_tp_avg = minstrel_ht_get_tp_avg (mi , tmp_group , tmp_idx , tmp_prob );
411
409
412
410
/* if max_tp_rate[0] is from MCS_GROUP max_prob_rate get selected from
413
411
* MCS_GROUP as well as CCK_GROUP rates do not allow aggregation */
@@ -417,18 +415,18 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
417
415
return ;
418
416
419
417
if (mrs -> prob_ewma > MINSTREL_FRAC (75 , 100 )) {
420
- cur_tp_avg = minstrel_ht_get_tp_avg (mi , cur_group , cur_idx );
418
+ cur_tp_avg = minstrel_ht_get_tp_avg (mi , cur_group , cur_idx ,
419
+ mrs -> prob_ewma );
421
420
if (cur_tp_avg > tmp_tp_avg )
422
421
mi -> max_prob_rate = index ;
423
422
424
- max_group_prob_rate_group = mg -> max_group_prob_rate /
425
- MCS_GROUP_RATES ;
426
- max_group_prob_rate_idx = mg -> max_group_prob_rate %
427
- MCS_GROUP_RATES ;
428
- max_group_prob_rate_tp_avg = minstrel_ht_get_tp_avg (mi ,
429
- max_group_prob_rate_group ,
430
- max_group_prob_rate_idx );
431
- if (cur_tp_avg > max_group_prob_rate_tp_avg )
423
+ max_gpr_group = mg -> max_group_prob_rate / MCS_GROUP_RATES ;
424
+ max_gpr_idx = mg -> max_group_prob_rate % MCS_GROUP_RATES ;
425
+ max_gpr_prob = mi -> groups [max_gpr_group ].rates [max_gpr_idx ].prob_ewma ;
426
+ max_gpr_tp_avg = minstrel_ht_get_tp_avg (mi , max_gpr_group ,
427
+ max_gpr_idx ,
428
+ max_gpr_prob );
429
+ if (cur_tp_avg > max_gpr_tp_avg )
432
430
mg -> max_group_prob_rate = index ;
433
431
} else {
434
432
if (mrs -> prob_ewma > tmp_prob )
@@ -450,16 +448,18 @@ minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
450
448
u16 tmp_mcs_tp_rate [MAX_THR_RATES ],
451
449
u16 tmp_cck_tp_rate [MAX_THR_RATES ])
452
450
{
453
- unsigned int tmp_group , tmp_idx , tmp_cck_tp , tmp_mcs_tp ;
451
+ unsigned int tmp_group , tmp_idx , tmp_cck_tp , tmp_mcs_tp , tmp_prob ;
454
452
int i ;
455
453
456
454
tmp_group = tmp_cck_tp_rate [0 ] / MCS_GROUP_RATES ;
457
455
tmp_idx = tmp_cck_tp_rate [0 ] % MCS_GROUP_RATES ;
458
- tmp_cck_tp = minstrel_ht_get_tp_avg (mi , tmp_group , tmp_idx );
456
+ tmp_prob = mi -> groups [tmp_group ].rates [tmp_idx ].prob_ewma ;
457
+ tmp_cck_tp = minstrel_ht_get_tp_avg (mi , tmp_group , tmp_idx , tmp_prob );
459
458
460
459
tmp_group = tmp_mcs_tp_rate [0 ] / MCS_GROUP_RATES ;
461
460
tmp_idx = tmp_mcs_tp_rate [0 ] % MCS_GROUP_RATES ;
462
- tmp_mcs_tp = minstrel_ht_get_tp_avg (mi , tmp_group , tmp_idx );
461
+ tmp_prob = mi -> groups [tmp_group ].rates [tmp_idx ].prob_ewma ;
462
+ tmp_mcs_tp = minstrel_ht_get_tp_avg (mi , tmp_group , tmp_idx , tmp_prob );
463
463
464
464
if (tmp_cck_tp > tmp_mcs_tp ) {
465
465
for (i = 0 ; i < MAX_THR_RATES ; i ++ ) {
@@ -478,7 +478,7 @@ static inline void
478
478
minstrel_ht_prob_rate_reduce_streams (struct minstrel_ht_sta * mi )
479
479
{
480
480
struct minstrel_mcs_group_data * mg ;
481
- int tmp_max_streams , group , tmp_idx ;
481
+ int tmp_max_streams , group , tmp_idx , tmp_prob ;
482
482
int tmp_tp = 0 ;
483
483
484
484
tmp_max_streams = minstrel_mcs_groups [mi -> max_tp_rate [0 ] /
@@ -489,12 +489,14 @@ minstrel_ht_prob_rate_reduce_streams(struct minstrel_ht_sta *mi)
489
489
continue ;
490
490
491
491
tmp_idx = mg -> max_group_prob_rate % MCS_GROUP_RATES ;
492
+ tmp_prob = mi -> groups [group ].rates [tmp_idx ].prob_ewma ;
492
493
493
- if (tmp_tp < minstrel_ht_get_tp_avg (mi , group , tmp_idx ) &&
494
+ if (tmp_tp < minstrel_ht_get_tp_avg (mi , group , tmp_idx , tmp_prob ) &&
494
495
(minstrel_mcs_groups [group ].streams < tmp_max_streams )) {
495
496
mi -> max_prob_rate = mg -> max_group_prob_rate ;
496
497
tmp_tp = minstrel_ht_get_tp_avg (mi , group ,
497
- tmp_idx );
498
+ tmp_idx ,
499
+ tmp_prob );
498
500
}
499
501
}
500
502
}
@@ -513,7 +515,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
513
515
{
514
516
struct minstrel_mcs_group_data * mg ;
515
517
struct minstrel_rate_stats * mrs ;
516
- int group , i , j ;
518
+ int group , i , j , cur_prob ;
517
519
u16 tmp_mcs_tp_rate [MAX_THR_RATES ], tmp_group_tp_rate [MAX_THR_RATES ];
518
520
u16 tmp_cck_tp_rate [MAX_THR_RATES ], index ;
519
521
@@ -555,8 +557,9 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
555
557
mrs = & mg -> rates [i ];
556
558
mrs -> retry_updated = false;
557
559
minstrel_calc_rate_stats (mrs );
560
+ cur_prob = mrs -> prob_ewma ;
558
561
559
- if (minstrel_ht_get_tp_avg (mi , group , i ) == 0 )
562
+ if (minstrel_ht_get_tp_avg (mi , group , i , cur_prob ) == 0 )
560
563
continue ;
561
564
562
565
/* Find max throughput rate set */
@@ -1315,16 +1318,17 @@ static u32 minstrel_ht_get_expected_throughput(void *priv_sta)
1315
1318
{
1316
1319
struct minstrel_ht_sta_priv * msp = priv_sta ;
1317
1320
struct minstrel_ht_sta * mi = & msp -> ht ;
1318
- int i , j , tp_avg ;
1321
+ int i , j , prob , tp_avg ;
1319
1322
1320
1323
if (!msp -> is_ht )
1321
1324
return mac80211_minstrel .get_expected_throughput (priv_sta );
1322
1325
1323
1326
i = mi -> max_tp_rate [0 ] / MCS_GROUP_RATES ;
1324
1327
j = mi -> max_tp_rate [0 ] % MCS_GROUP_RATES ;
1328
+ prob = mi -> groups [i ].rates [j ].prob_ewma ;
1325
1329
1326
1330
/* convert tp_avg from pkt per second in kbps */
1327
- tp_avg = minstrel_ht_get_tp_avg (mi , i , j ) * AVG_PKT_SIZE * 8 / 1024 ;
1331
+ tp_avg = minstrel_ht_get_tp_avg (mi , i , j , prob ) * AVG_PKT_SIZE * 8 / 1024 ;
1328
1332
1329
1333
return tp_avg ;
1330
1334
}
0 commit comments