iPXE
|
Simple 802.11 rate-control algorithm. More...
Go to the source code of this file.
Data Structures | |
struct | rc80211_ctx |
A rate control context. More... | |
Macros | |
#define | RC_PKT_OK 0x3 |
Two-bit packet status indicator for a packet with no retries. More... | |
#define | RC_PKT_RETRIED_ONCE 0x2 |
Two-bit packet status indicator for a packet with one retry. More... | |
#define | RC_PKT_RETRIED_MULTI 0x1 |
Two-bit packet status indicator for a TX packet with multiple retries. More... | |
#define | RC_PKT_FAILED 0x0 |
Two-bit packet status indicator for a TX packet that was never ACKed. More... | |
#define | RC_TX_FACTOR 4 |
Number of times to weight TX packets more heavily than RX packets. More... | |
#define | RC_TX_EMERG_FAIL 3 |
Number of consecutive failed TX packets that cause an automatic rate drop. More... | |
#define | RC_GOODNESS_MIN 85 |
Minimum net goodness below which we will search for a better rate. More... | |
#define | RC_GOODNESS_MAX 95 |
Maximum net goodness above which we will try to increase our rate. More... | |
#define | RC_UNCERTAINTY_THRESH 4 |
Minimum (num RX + RC_TX_FACTOR * num TX) to use a certain rate. More... | |
#define | TX 0 |
TX direction. More... | |
#define | RX 1 |
RX direction. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER) | |
struct rc80211_ctx * | rc80211_init (struct net80211_device *dev __unused) |
Initialize rate-control algorithm. More... | |
static int | rc80211_calc_net_goodness (struct rc80211_ctx *ctx, int rate_idx) |
Calculate net goodness for a certain rate. More... | |
static int | rc80211_pick_best (struct net80211_device *dev) |
Determine the best rate to switch to and return it. More... | |
static void | rc80211_set_rate (struct net80211_device *dev, int rate_idx) |
Set 802.11 device rate. More... | |
static void | rc80211_maybe_set_new (struct net80211_device *dev) |
Check rate-control state and change rate if necessary. More... | |
static void | rc80211_update (struct net80211_device *dev, int direction, int rate_idx, int retries, int failed) |
Update rate-control state. More... | |
void | rc80211_update_tx (struct net80211_device *dev, int retries, int rc) |
Update rate-control state for transmitted packet. More... | |
void | rc80211_update_rx (struct net80211_device *dev, int retry, u16 rate) |
Update rate-control state for received packet. More... | |
void | rc80211_free (struct rc80211_ctx *ctx) |
Free rate-control context. More... | |
Simple 802.11 rate-control algorithm.
Definition in file rc80211.c.
#define RC_PKT_OK 0x3 |
#define RC_PKT_RETRIED_ONCE 0x2 |
#define RC_PKT_RETRIED_MULTI 0x1 |
Two-bit packet status indicator for a TX packet with multiple retries.
It is not possible to tell whether an RX packet had one or multiple retries; we rely instead on the fact that failed RX packets won't get to us at all, so if we receive a lot of RX packets on a certain rate it must be pretty good.
#define RC_PKT_FAILED 0x0 |
Two-bit packet status indicator for a TX packet that was never ACKed.
It is not possible to tell whether an RX packet was setn if it didn't get through to us, but if we don't see one we won't increase the goodness for its rate. This asymmetry is part of why TX packets are weighted much more heavily than RX.
#define RC_TX_FACTOR 4 |
#define RC_TX_EMERG_FAIL 3 |
#define RC_GOODNESS_MIN 85 |
#define RC_GOODNESS_MAX 95 |
#define RC_UNCERTAINTY_THRESH 4 |
FILE_LICENCE | ( | GPL2_OR_LATER | ) |
struct rc80211_ctx* rc80211_init | ( | struct net80211_device *dev | __unused | ) |
Initialize rate-control algorithm.
dev | 802.11 device |
ctx | Rate-control context, to be stored in dev->rctl |
Definition at line 154 of file rc80211.c.
References zalloc().
Referenced by net80211_step_associate().
|
static |
Calculate net goodness for a certain rate.
ctx | Rate-control context |
rate_idx | Index of rate to calculate net goodness for |
Definition at line 166 of file rc80211.c.
References ctx, num, RC_TX_FACTOR, RC_UNCERTAINTY_THRESH, RX, and TX.
Referenced by rc80211_maybe_set_new(), and rc80211_pick_best().
|
static |
Determine the best rate to switch to and return it.
dev | 802.11 device |
rate_idx | Index of the best rate to switch to |
Definition at line 194 of file rc80211.c.
References ctx, DBGC, net80211_device::nr_rates, net80211_device::rate, rc80211_calc_net_goodness(), RC_GOODNESS_MIN, and net80211_device::rctl.
Referenced by rc80211_maybe_set_new().
|
inlinestatic |
Set 802.11 device rate.
dev | 802.11 device |
rate_idx | Index of rate to switch to |
This is a thin wrapper around net80211_set_rate_idx to insert a debugging message where appropriate.
Definition at line 232 of file rc80211.c.
References DBGC, net80211_set_rate_idx(), net80211_device::rate, net80211_device::rates, and net80211_device::rctl.
Referenced by rc80211_maybe_set_new(), and rc80211_update_tx().
|
static |
Check rate-control state and change rate if necessary.
dev | 802.11 device |
Definition at line 246 of file rc80211.c.
References ctx, net80211_device::nr_rates, net80211_device::rate, rc80211_calc_net_goodness(), rc80211_pick_best(), rc80211_set_rate(), RC_GOODNESS_MAX, RC_GOODNESS_MIN, and net80211_device::rctl.
Referenced by rc80211_update().
|
static |
Update rate-control state.
dev | 802.11 device |
direction | One of the direction constants TX or RX |
rate_idx | Index of rate at which packet was sent or received |
retries | Number of times packet was retried before success |
failed | If nonzero, the packet failed to get through |
Definition at line 283 of file rc80211.c.
References ctx, direction, rc80211_ctx::goodness, rc80211_maybe_set_new(), RC_PKT_FAILED, RC_PKT_OK, RC_PKT_RETRIED_MULTI, RC_PKT_RETRIED_ONCE, and net80211_device::rctl.
Referenced by rc80211_update_rx(), and rc80211_update_tx().
void rc80211_update_tx | ( | struct net80211_device * | dev, |
int | retries, | ||
int | rc | ||
) |
Update rate-control state for transmitted packet.
dev | 802.11 device |
retries | Number of times packet was transmitted before success |
rc | Return status code for transmission |
Definition at line 316 of file rc80211.c.
References ctx, DBGC, net80211_device::rate, net80211_device::rates, rc, rc80211_set_rate(), rc80211_update(), RC_TX_EMERG_FAIL, net80211_device::rctl, and TX.
Referenced by net80211_tx_complete().
void rc80211_update_rx | ( | struct net80211_device * | dev, |
int | retry, | ||
u16 | rate | ||
) |
Update rate-control state for received packet.
dev | 802.11 device |
retry | Whether the received packet had been retransmitted |
rate | Rate at which packet was received, in 100 kbps units |
Definition at line 351 of file rc80211.c.
References net80211_device::nr_rates, net80211_device::rates, rc80211_update(), and RX.
Referenced by net80211_rx().
void rc80211_free | ( | struct rc80211_ctx * | ctx | ) |
Free rate-control context.
ctx | Rate-control context |
Definition at line 369 of file rc80211.c.
Referenced by net80211_free().