aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBen Cahill <ben.m.cahill@intel.com>2007-11-28 22:10:12 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:05:35 -0500
commit2bdc7031f9ea1826e16bffc3540d05de891c98bc (patch)
treea7399eadf3a92405fe425b3b86d5c70c0a82c6dc /drivers
parent529699815b79f15a6644786dc4d6e9dd5153a447 (diff)
iwlwifi: document 4965 rate scaling
Document 4965 rate scaling Signed-off-by: Ben Cahill <ben.m.cahill@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-commands.h251
1 files changed, 247 insertions, 4 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-commands.h b/drivers/net/wireless/iwlwifi/iwl-4965-commands.h
index cbe91dbe760c..7988c752a669 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-commands.h
@@ -1322,6 +1322,8 @@ struct iwl4965_compressed_ba_resp {
1322 1322
1323/* 1323/*
1324 * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response) 1324 * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
1325 *
1326 * See details under "TXPOWER" in iwl-4965-hw.h.
1325 */ 1327 */
1326struct iwl4965_txpowertable_cmd { 1328struct iwl4965_txpowertable_cmd {
1327 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ 1329 u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
@@ -1333,39 +1335,280 @@ struct iwl4965_txpowertable_cmd {
1333/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */ 1335/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
1334#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1<<0) 1336#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1<<0)
1335 1337
1338/* # of EDCA prioritized tx fifos */
1336#define LINK_QUAL_AC_NUM AC_NUM 1339#define LINK_QUAL_AC_NUM AC_NUM
1340
1341/* # entries in rate scale table to support Tx retries */
1337#define LINK_QUAL_MAX_RETRY_NUM 16 1342#define LINK_QUAL_MAX_RETRY_NUM 16
1338 1343
1344/* Tx antenna selection values */
1339#define LINK_QUAL_ANT_A_MSK (1<<0) 1345#define LINK_QUAL_ANT_A_MSK (1<<0)
1340#define LINK_QUAL_ANT_B_MSK (1<<1) 1346#define LINK_QUAL_ANT_B_MSK (1<<1)
1341#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK) 1347#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
1342 1348
1349
1350/**
1351 * struct iwl4965_link_qual_general_params
1352 *
1353 * Used in REPLY_TX_LINK_QUALITY_CMD
1354 */
1343struct iwl4965_link_qual_general_params { 1355struct iwl4965_link_qual_general_params {
1344 u8 flags; 1356 u8 flags;
1357
1358 /* No entries at or above this (driver chosen) index contain MIMO */
1345 u8 mimo_delimiter; 1359 u8 mimo_delimiter;
1346 u8 single_stream_ant_msk; 1360
1347 u8 dual_stream_ant_msk; 1361 /* Best single antenna to use for single stream (legacy, SISO). */
1362 u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */
1363
1364 /* Best antennas to use for MIMO (unused for 4965, assumes both). */
1365 u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */
1366
1367 /*
1368 * If driver needs to use different initial rates for different
1369 * EDCA QOS access categories (as implemented by tx fifos 0-3),
1370 * this table will set that up, by indicating the indexes in the
1371 * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
1372 * Otherwise, driver should set all entries to 0.
1373 *
1374 * Entry usage:
1375 * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
1376 * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
1377 */
1348 u8 start_rate_index[LINK_QUAL_AC_NUM]; 1378 u8 start_rate_index[LINK_QUAL_AC_NUM];
1349} __attribute__ ((packed)); 1379} __attribute__ ((packed));
1350 1380
1381/**
1382 * struct iwl4965_link_qual_agg_params
1383 *
1384 * Used in REPLY_TX_LINK_QUALITY_CMD
1385 */
1351struct iwl4965_link_qual_agg_params { 1386struct iwl4965_link_qual_agg_params {
1387
1388 /* Maximum number of uSec in aggregation.
1389 * Driver should set this to 4000 (4 milliseconds). */
1352 __le16 agg_time_limit; 1390 __le16 agg_time_limit;
1391
1392 /*
1393 * Number of Tx retries allowed for a frame, before that frame will
1394 * no longer be considered for the start of an aggregation sequence
1395 * (scheduler will then try to tx it as single frame).
1396 * Driver should set this to 3.
1397 */
1353 u8 agg_dis_start_th; 1398 u8 agg_dis_start_th;
1399
1400 /*
1401 * Maximum number of frames in aggregation.
1402 * 0 = no limit (default). 1 = no aggregation.
1403 * Other values = max # frames in aggregation.
1404 */
1354 u8 agg_frame_cnt_limit; 1405 u8 agg_frame_cnt_limit;
1406
1355 __le32 reserved; 1407 __le32 reserved;
1356} __attribute__ ((packed)); 1408} __attribute__ ((packed));
1357 1409
1358/* 1410/*
1359 * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) 1411 * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
1412 *
1413 * For 4965 only; 3945 uses REPLY_RATE_SCALE.
1414 *
1415 * Each station in the 4965's internal station table has its own table of 16
1416 * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
1417 * an ACK is not received. This command replaces the entire table for
1418 * one station.
1419 *
1420 * NOTE: Station must already be in 4965's station table. Use REPLY_ADD_STA.
1421 *
1422 * The rate scaling procedures described below work well. Of course, other
1423 * procedures are possible, and may work better for particular environments.
1424 *
1425 *
1426 * FILLING THE RATE TABLE
1427 *
1428 * Given a particular initial rate and mode, as determined by the rate
1429 * scaling algorithm described below, the Linux driver uses the following
1430 * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
1431 * Link Quality command:
1432 *
1433 *
1434 * 1) If using High-throughput (HT) (SISO or MIMO) initial rate:
1435 * a) Use this same initial rate for first 3 entries.
1436 * b) Find next lower available rate using same mode (SISO or MIMO),
1437 * use for next 3 entries. If no lower rate available, switch to
1438 * legacy mode (no FAT channel, no MIMO, no short guard interval).
1439 * c) If using MIMO, set command's mimo_delimiter to number of entries
1440 * using MIMO (3 or 6).
1441 * d) After trying 2 HT rates, switch to legacy mode (no FAT channel,
1442 * no MIMO, no short guard interval), at the next lower bit rate
1443 * (e.g. if second HT bit rate was 54, try 48 legacy), and follow
1444 * legacy procedure for remaining table entries.
1445 *
1446 * 2) If using legacy initial rate:
1447 * a) Use the initial rate for only one entry.
1448 * b) For each following entry, reduce the rate to next lower available
1449 * rate, until reaching the lowest available rate.
1450 * c) When reducing rate, also switch antenna selection.
1451 * d) Once lowest available rate is reached, repeat this rate until
1452 * rate table is filled (16 entries), switching antenna each entry.
1453 *
1454 *
1455 * ACCUMULATING HISTORY
1456 *
1457 * The rate scaling algorithm for 4965, as implemented in Linux driver, uses
1458 * two sets of frame Tx success history: One for the current/active modulation
1459 * mode, and one for a speculative/search mode that is being attempted. If the
1460 * speculative mode turns out to be more effective (i.e. actual transfer
1461 * rate is better), then the driver continues to use the speculative mode
1462 * as the new current active mode.
1463 *
1464 * Each history set contains, separately for each possible rate, data for a
1465 * sliding window of the 62 most recent tx attempts at that rate. The data
1466 * includes a shifting bitmap of success(1)/failure(0), and sums of successful
1467 * and attempted frames, from which the driver can additionally calculate a
1468 * success ratio (success / attempted) and number of failures
1469 * (attempted - success), and control the size of the window (attempted).
1470 * The driver uses the bit map to remove successes from the success sum, as
1471 * the oldest tx attempts fall out of the window.
1472 *
1473 * When the 4965 makes multiple tx attempts for a given frame, each attempt
1474 * might be at a different rate, and have different modulation characteristics
1475 * (e.g. antenna, fat channel, short guard interval), as set up in the rate
1476 * scaling table in the Link Quality command. The driver must determine
1477 * which rate table entry was used for each tx attempt, to determine which
1478 * rate-specific history to update, and record only those attempts that
1479 * match the modulation characteristics of the history set.
1480 *
1481 * When using block-ack (aggregation), all frames are transmitted at the same
1482 * rate, since there is no per-attempt acknowledgement from the destination
1483 * station. The Tx response struct iwl_tx_resp indicates the Tx rate in
1484 * rate_n_flags field. After receiving a block-ack, the driver can update
1485 * history for the entire block all at once.
1486 *
1487 *
1488 * FINDING BEST STARTING RATE:
1489 *
1490 * When working with a selected initial modulation mode (see below), the
1491 * driver attempts to find a best initial rate. The initial rate is the
1492 * first entry in the Link Quality command's rate table.
1493 *
1494 * 1) Calculate actual throughput (success ratio * expected throughput, see
1495 * table below) for current initial rate. Do this only if enough frames
1496 * have been attempted to make the value meaningful: at least 6 failed
1497 * tx attempts, or at least 8 successes. If not enough, don't try rate
1498 * scaling yet.
1499 *
1500 * 2) Find available rates adjacent to current initial rate. Available means:
1501 * a) supported by hardware &&
1502 * b) supported by association &&
1503 * c) within any constraints selected by user
1504 *
1505 * 3) Gather measured throughputs for adjacent rates. These might not have
1506 * enough history to calculate a throughput. That's okay, we might try
1507 * using one of them anyway!
1508 *
1509 * 4) Try decreasing rate if, for current rate:
1510 * a) success ratio is < 15% ||
1511 * b) lower adjacent rate has better measured throughput ||
1512 * c) higher adjacent rate has worse throughput, and lower is unmeasured
1513 *
1514 * As a sanity check, if decrease was determined above, leave rate
1515 * unchanged if:
1516 * a) lower rate unavailable
1517 * b) success ratio at current rate > 85% (very good)
1518 * c) current measured throughput is better than expected throughput
1519 * of lower rate (under perfect 100% tx conditions, see table below)
1520 *
1521 * 5) Try increasing rate if, for current rate:
1522 * a) success ratio is < 15% ||
1523 * b) both adjacent rates' throughputs are unmeasured (try it!) ||
1524 * b) higher adjacent rate has better measured throughput ||
1525 * c) lower adjacent rate has worse throughput, and higher is unmeasured
1526 *
1527 * As a sanity check, if increase was determined above, leave rate
1528 * unchanged if:
1529 * a) success ratio at current rate < 70%. This is not particularly
1530 * good performance; higher rate is sure to have poorer success.
1531 *
1532 * 6) Re-evaluate the rate after each tx frame. If working with block-
1533 * acknowledge, history and statistics may be calculated for the entire
1534 * block (including prior history that fits within the history windows),
1535 * before re-evaluation.
1536 *
1537 * FINDING BEST STARTING MODULATION MODE:
1538 *
1539 * After working with a modulation mode for a "while" (and doing rate scaling),
1540 * the driver searches for a new initial mode in an attempt to improve
1541 * throughput. The "while" is measured by numbers of attempted frames:
1542 *
1543 * For legacy mode, search for new mode after:
1544 * 480 successful frames, or 160 failed frames
1545 * For high-throughput modes (SISO or MIMO), search for new mode after:
1546 * 4500 successful frames, or 400 failed frames
1547 *
1548 * Mode switch possibilities are (3 for each mode):
1549 *
1550 * For legacy:
1551 * Change antenna, try SISO (if HT association), try MIMO (if HT association)
1552 * For SISO:
1553 * Change antenna, try MIMO, try shortened guard interval (SGI)
1554 * For MIMO:
1555 * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
1556 *
1557 * When trying a new mode, use the same bit rate as the old/current mode when
1558 * trying antenna switches and shortened guard interval. When switching to
1559 * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
1560 * for which the expected throughput (under perfect conditions) is about the
1561 * same or slightly better than the actual measured throughput delivered by
1562 * the old/current mode.
1563 *
1564 * Actual throughput can be estimated by multiplying the expected throughput
1565 * by the success ratio (successful / attempted tx frames). Frame size is
1566 * not considered in this calculation; it assumes that frame size will average
1567 * out to be fairly consistent over several samples. The following are
1568 * metric values for expected throughput assuming 100% success ratio.
1569 * Only G band has support for CCK rates:
1570 *
1571 * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60
1572 *
1573 * G: 7 13 35 58 40 57 72 98 121 154 177 186 186
1574 * A: 0 0 0 0 40 57 72 98 121 154 177 186 186
1575 * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202
1576 * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211
1577 * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251
1578 * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257
1579 * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257
1580 * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264
1581 * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289
1582 * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293
1583 *
1584 * After the new mode has been tried for a short while (minimum of 6 failed
1585 * frames or 8 successful frames), compare success ratio and actual throughput
1586 * estimate of the new mode with the old. If either is better with the new
1587 * mode, continue to use the new mode.
1588 *
1589 * Continue comparing modes until all 3 possibilities have been tried.
1590 * If moving from legacy to HT, try all 3 possibilities from the new HT
1591 * mode. After trying all 3, a best mode is found. Continue to use this mode
1592 * for the longer "while" described above (e.g. 480 successful frames for
1593 * legacy), and then repeat the search process.
1594 *
1360 */ 1595 */
1361struct iwl4965_link_quality_cmd { 1596struct iwl4965_link_quality_cmd {
1597
1598 /* Index of destination/recipient station in uCode's station table */
1362 u8 sta_id; 1599 u8 sta_id;
1363 u8 reserved1; 1600 u8 reserved1;
1364 __le16 control; 1601 __le16 control; /* not used */
1365 struct iwl4965_link_qual_general_params general_params; 1602 struct iwl4965_link_qual_general_params general_params;
1366 struct iwl4965_link_qual_agg_params agg_params; 1603 struct iwl4965_link_qual_agg_params agg_params;
1604
1605 /*
1606 * Rate info; when using rate-scaling, Tx command's initial_rate_index
1607 * specifies 1st Tx rate attempted, via index into this table.
1608 * 4965 works its way through table when retrying Tx.
1609 */
1367 struct { 1610 struct {
1368 __le32 rate_n_flags; 1611 __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */
1369 } rs_table[LINK_QUAL_MAX_RETRY_NUM]; 1612 } rs_table[LINK_QUAL_MAX_RETRY_NUM];
1370 __le32 reserved2; 1613 __le32 reserved2;
1371} __attribute__ ((packed)); 1614} __attribute__ ((packed));