static void rate_control_simple_tx_status(void *priv, struct net_device *dev, struct sk_buff *skb, struct ieee80211_tx_status *status) { struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct sta_info *sta; struct sta_rate_control *srctrl; sta = sta_info_get(local, hdr->addr1); if (!sta) return; srctrl = sta->rate_ctrl_priv; srctrl->tx_num_xmit++; if (status->excessive_retries) { srctrl->tx_num_failures++; sta->tx_retry_failed++; sta->tx_num_consecutive_failures++; sta->tx_num_mpdu_fail++; } else { sta->last_ack_rssi[0] = sta->last_ack_rssi[1]; sta->last_ack_rssi[1] = sta->last_ack_rssi[2]; sta->last_ack_rssi[2] = status->ack_signal; sta->tx_num_consecutive_failures = 0; sta->tx_num_mpdu_ok++; } sta->tx_retry_count += status->retry_count; sta->tx_num_mpdu_fail += status->retry_count; if (time_after(jiffies, srctrl->last_rate_change + RATE_CONTROL_INTERVAL) && srctrl->tx_num_xmit > RATE_CONTROL_MIN_TX) { u32 per_failed; srctrl->last_rate_change = jiffies; per_failed = (100 * sta->tx_num_mpdu_fail) / (sta->tx_num_mpdu_fail + sta->tx_num_mpdu_ok); /* TODO: calculate average per_failed to make adjusting * parameters easier */ #if 0 if (net_ratelimit()) { printk(KERN_DEBUG "MPDU fail=%d ok=%d per_failed=%d\n", sta->tx_num_mpdu_fail, sta->tx_num_mpdu_ok, per_failed); } #endif /* * XXX: Make these configurable once we have an * interface to the rate control algorithms */ if (per_failed > RATE_CONTROL_NUM_DOWN) { rate_control_rate_dec(local, sta); } else if (per_failed < RATE_CONTROL_NUM_UP) { rate_control_rate_inc(local, sta); } srctrl->tx_avg_rate_sum += status->control.rate->rate; srctrl->tx_avg_rate_num++; srctrl->tx_num_failures = 0; srctrl->tx_num_xmit = 0; } else if (sta->tx_num_consecutive_failures >= RATE_CONTROL_EMERG_DEC) { rate_control_rate_dec(local, sta); } if (srctrl->avg_rate_update + 60 * HZ < jiffies) { srctrl->avg_rate_update = jiffies; if (srctrl->tx_avg_rate_num > 0) { #ifdef CONFIG_MAC80211_VERBOSE_DEBUG DECLARE_MAC_BUF(mac); printk(KERN_DEBUG "%s: STA %s Average rate: " "%d (%d/%d)\n", dev->name, print_mac(mac, sta->addr), srctrl->tx_avg_rate_sum / srctrl->tx_avg_rate_num, srctrl->tx_avg_rate_sum, srctrl->tx_avg_rate_num); #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ srctrl->tx_avg_rate_sum = 0; srctrl->tx_avg_rate_num = 0; } } sta_info_put(sta); }
static void rate_control_simple_tx_status(void *priv, struct net_device *dev, struct sk_buff *skb, struct ieee80211_tx_status *status) { struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct sta_info *sta; struct sta_rate_control *srctrl; sta = sta_info_get(local, hdr->addr1); if (!sta) return; srctrl = sta->rate_ctrl_priv; srctrl->tx_num_xmit++; if (status->excessive_retries) { sta->antenna_sel_tx = sta->antenna_sel_tx == 1 ? 2 : 1; sta->antenna_sel_rx = sta->antenna_sel_rx == 1 ? 2 : 1; if (local->sta_antenna_sel == STA_ANTENNA_SEL_SW_CTRL_DEBUG) { printk(KERN_DEBUG "%s: " MAC_FMT " TX antenna --> %d " "RX antenna --> %d (@%lu)\n", dev->name, MAC_ARG(hdr->addr1), sta->antenna_sel_tx, sta->antenna_sel_rx, jiffies); } srctrl->tx_num_failures++; sta->tx_retry_failed++; sta->tx_num_consecutive_failures++; sta->tx_num_mpdu_fail++; } else { sta->last_ack_rssi[0] = sta->last_ack_rssi[1]; sta->last_ack_rssi[1] = sta->last_ack_rssi[2]; sta->last_ack_rssi[2] = status->ack_signal; sta->tx_num_consecutive_failures = 0; sta->tx_num_mpdu_ok++; } sta->tx_retry_count += status->retry_count; sta->tx_num_mpdu_fail += status->retry_count; if (time_after(jiffies, srctrl->last_rate_change + RATE_CONTROL_INTERVAL) && srctrl->tx_num_xmit > RATE_CONTROL_MIN_TX) { u32 per_failed; srctrl->last_rate_change = jiffies; per_failed = (100 * sta->tx_num_mpdu_fail) / (sta->tx_num_mpdu_fail + sta->tx_num_mpdu_ok); /* TODO: calculate average per_failed to make adjusting * parameters easier */ #if 0 if (net_ratelimit()) { printk(KERN_DEBUG "MPDU fail=%d ok=%d per_failed=%d\n", sta->tx_num_mpdu_fail, sta->tx_num_mpdu_ok, per_failed); } #endif if (per_failed > local->rate_ctrl_num_down) { rate_control_rate_dec(local, sta); } else if (per_failed < local->rate_ctrl_num_up) { rate_control_rate_inc(local, sta); } srctrl->tx_avg_rate_sum += status->control.rate->rate; srctrl->tx_avg_rate_num++; srctrl->tx_num_failures = 0; srctrl->tx_num_xmit = 0; } else if (sta->tx_num_consecutive_failures >= RATE_CONTROL_EMERG_DEC) { rate_control_rate_dec(local, sta); } if (srctrl->avg_rate_update + 60 * HZ < jiffies) { srctrl->avg_rate_update = jiffies; if (srctrl->tx_avg_rate_num > 0) { #ifdef CONFIG_MAC80211_VERBOSE_DEBUG printk(KERN_DEBUG "%s: STA " MAC_FMT " Average rate: " "%d (%d/%d)\n", dev->name, MAC_ARG(sta->addr), srctrl->tx_avg_rate_sum / srctrl->tx_avg_rate_num, srctrl->tx_avg_rate_sum, srctrl->tx_avg_rate_num); #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ srctrl->tx_avg_rate_sum = 0; srctrl->tx_avg_rate_num = 0; } } sta_info_put(sta); }