91 #define RC_PKT_RETRIED_ONCE 0x2 100 #define RC_PKT_RETRIED_MULTI 0x1 109 #define RC_PKT_FAILED 0x0 112 #define RC_TX_FACTOR 4 115 #define RC_TX_EMERG_FAIL 3 118 #define RC_GOODNESS_MIN 85 121 #define RC_GOODNESS_MAX 95 124 #define RC_UNCERTAINTY_THRESH 4 169 int sum[2],
num[2], dir, pkt;
171 for ( dir = 0; dir < 2; dir++ ) {
172 u32 good =
ctx->goodness[dir][rate_idx];
174 num[dir] =
ctx->count[dir][rate_idx];
177 for ( pkt = 0; pkt <
num[dir]; pkt++ )
178 sum[dir] += ( good >> ( 2 * pkt ) ) & 0x3;
197 int best_net_good = 0, best_rate = -1, i;
199 for ( i = 0; i < dev->
nr_rates; i++ ) {
202 if ( net_good > best_net_good ||
205 best_net_good = net_good;
210 if ( best_rate >= 0 ) {
212 if ( old_good != best_net_good )
213 DBGC (
ctx,
"802.11 RC %p switching from goodness " 214 "%d to %d\n",
ctx, old_good, best_net_good );
235 DBGC ( dev->
rctl,
"802.11 RC %p changing rate %d->%d Mbps\n", dev->
rctl,
253 if ( !
ctx->started ) {
263 if ( higher > net_good || higher < 0 )
284 int rate_idx,
int retries,
int failed )
295 else if ( retries > 1 )
320 if ( !
ctx->started )
328 if ( dev->
rate == 0 )
329 DBGC ( dev->
rctl,
"802.11 RC %p saw %d consecutive " 330 "failed TX, but cannot lower rate any further\n",
333 DBGC ( dev->
rctl,
"802.11 RC %p lowering rate (%d->%d " 334 "Mbps) due to %d consecutive TX failures\n",
355 for ( ridx = 0; ridx < dev->
nr_rates && dev->
rates[ridx] != rate;
static void rc80211_maybe_set_new(struct net80211_device *dev)
Check rate-control state and change rate if necessary.
struct arbelprm_rc_send_wqe rc
static int rc80211_pick_best(struct net80211_device *dev)
Determine the best rate to switch to and return it.
static void rc80211_update(struct net80211_device *dev, int direction, int rate_idx, int retries, int failed)
Update rate-control state.
static int rc80211_calc_net_goodness(struct rc80211_ctx *ctx, int rate_idx)
Calculate net goodness for a certain rate.
#define RC_PKT_FAILED
Two-bit packet status indicator for a TX packet that was never ACKed.
uint8_t direction
Direction.
int packets
Counter of all packets sent and received.
struct golan_eq_context ctx
void rc80211_update_tx(struct net80211_device *dev, int retries, int rc)
Update rate-control state for transmitted packet.
#define RC_PKT_RETRIED_MULTI
Two-bit packet status indicator for a TX packet with multiple retries.
int started
Indication of whether we've set the device rate yet.
void net80211_set_rate_idx(struct net80211_device *dev, int rate)
Set data transmission rate for 802.11 device.
#define RC_PKT_RETRIED_ONCE
Two-bit packet status indicator for a packet with one retry.
struct rc80211_ctx * rctl
Rate control state.
#define __unused
Declare a variable or data structure as unused.
u32 goodness[2][NET80211_MAX_RATES]
Goodness state for each rate, TX and RX.
#define RC_TX_EMERG_FAIL
Number of consecutive failed TX packets that cause an automatic rate drop.
u8 nr_rates
The number of transmission rates in the rates array.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
The iPXE 802.11 MAC layer.
Structure encapsulating the complete state of an 802.11 device.
#define RC_TX_FACTOR
Number of times to weight TX packets more heavily than RX packets.
u16 rates[NET80211_MAX_RATES]
A list of all possible TX rates we might use.
struct rc80211_ctx * rc80211_init(struct net80211_device *dev __unused)
Initialize rate-control algorithm.
FILE_LICENCE(GPL2_OR_LATER)
void rc80211_free(struct rc80211_ctx *ctx)
Free rate-control context.
#define RC_PKT_OK
Two-bit packet status indicator for a packet with no retries.
#define NET80211_MAX_RATES
The maximum number of TX rates we allow to be configured simultaneously.
#define RC_UNCERTAINTY_THRESH
Minimum (num RX + RC_TX_FACTOR * num TX) to use a certain rate.
static void rc80211_set_rate(struct net80211_device *dev, int rate_idx)
Set 802.11 device rate.
#define RC_GOODNESS_MIN
Minimum net goodness below which we will search for a better rate.
u8 rate
The rate currently in use, as an index into the rates array.
#define RC_GOODNESS_MAX
Maximum net goodness above which we will try to increase our rate.
u8 count[2][NET80211_MAX_RATES]
Number of packets recorded for each rate.
void rc80211_update_rx(struct net80211_device *dev, int retry, u16 rate)
Update rate-control state for received packet.