Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac80211: make rate control tx status API more extensible

Rename .tx_status_noskb to .tx_status_ext and pass a new on-stack
struct ieee80211_tx_status instead of struct ieee80211_tx_info.

This struct can be used to pass extra information, e.g. for dynamic tx
power control

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Felix Fietkau and committed by
Johannes Berg
18fb84d9 dcba665b

+58 -55
+16 -4
include/net/mac80211.h
··· 949 949 }; 950 950 951 951 /** 952 + * struct ieee80211_tx_status - extended tx staus info for rate control 953 + * 954 + * @sta: Station that the packet was transmitted for 955 + * @info: Basic tx status information 956 + * @skb: Packet skb (can be NULL if not provided by the driver) 957 + */ 958 + struct ieee80211_tx_status { 959 + struct ieee80211_sta *sta; 960 + struct ieee80211_tx_info *info; 961 + struct sk_buff *skb; 962 + }; 963 + 964 + /** 952 965 * struct ieee80211_scan_ies - descriptors for different blocks of IEs 953 966 * 954 967 * This structure is used to point to different blocks of IEs in HW scan ··· 5484 5471 void (*free_sta)(void *priv, struct ieee80211_sta *sta, 5485 5472 void *priv_sta); 5486 5473 5487 - void (*tx_status_noskb)(void *priv, 5488 - struct ieee80211_supported_band *sband, 5489 - struct ieee80211_sta *sta, void *priv_sta, 5490 - struct ieee80211_tx_info *info); 5474 + void (*tx_status_ext)(void *priv, 5475 + struct ieee80211_supported_band *sband, 5476 + void *priv_sta, struct ieee80211_tx_status *st); 5491 5477 void (*tx_status)(void *priv, struct ieee80211_supported_band *sband, 5492 5478 struct ieee80211_sta *sta, void *priv_sta, 5493 5479 struct sk_buff *skb);
+22
net/mac80211/rate.c
··· 62 62 set_sta_flag(sta, WLAN_STA_RATE_CONTROL); 63 63 } 64 64 65 + void rate_control_tx_status(struct ieee80211_local *local, 66 + struct ieee80211_supported_band *sband, 67 + struct ieee80211_tx_status *st) 68 + { 69 + struct rate_control_ref *ref = local->rate_ctrl; 70 + struct sta_info *sta = container_of(st->sta, struct sta_info, sta); 71 + void *priv_sta = sta->rate_ctrl_priv; 72 + 73 + if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) 74 + return; 75 + 76 + spin_lock_bh(&sta->rate_ctrl_lock); 77 + if (ref->ops->tx_status_ext) 78 + ref->ops->tx_status_ext(ref->priv, sband, priv_sta, st); 79 + else if (st->skb) 80 + ref->ops->tx_status(ref->priv, sband, st->sta, priv_sta, st->skb); 81 + else 82 + WARN_ON_ONCE(1); 83 + 84 + spin_unlock_bh(&sta->rate_ctrl_lock); 85 + } 86 + 65 87 void rate_control_rate_update(struct ieee80211_local *local, 66 88 struct ieee80211_supported_band *sband, 67 89 struct sta_info *sta, u32 changed)
+3 -41
net/mac80211/rate.h
··· 28 28 struct sta_info *sta, 29 29 struct ieee80211_tx_rate_control *txrc); 30 30 31 - static inline void rate_control_tx_status(struct ieee80211_local *local, 32 - struct ieee80211_supported_band *sband, 33 - struct sta_info *sta, 34 - struct sk_buff *skb) 35 - { 36 - struct rate_control_ref *ref = local->rate_ctrl; 37 - struct ieee80211_sta *ista = &sta->sta; 38 - void *priv_sta = sta->rate_ctrl_priv; 39 - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 40 - 41 - if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) 42 - return; 43 - 44 - spin_lock_bh(&sta->rate_ctrl_lock); 45 - if (ref->ops->tx_status) 46 - ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb); 47 - else 48 - ref->ops->tx_status_noskb(ref->priv, sband, ista, priv_sta, info); 49 - spin_unlock_bh(&sta->rate_ctrl_lock); 50 - } 51 - 52 - static inline void 53 - rate_control_tx_status_noskb(struct ieee80211_local *local, 54 - struct ieee80211_supported_band *sband, 55 - struct sta_info *sta, 56 - struct ieee80211_tx_info *info) 57 - { 58 - struct rate_control_ref *ref = local->rate_ctrl; 59 - struct ieee80211_sta *ista = &sta->sta; 60 - void *priv_sta = sta->rate_ctrl_priv; 61 - 62 - if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) 63 - return; 64 - 65 - if (WARN_ON_ONCE(!ref->ops->tx_status_noskb)) 66 - return; 67 - 68 - spin_lock_bh(&sta->rate_ctrl_lock); 69 - ref->ops->tx_status_noskb(ref->priv, sband, ista, priv_sta, info); 70 - spin_unlock_bh(&sta->rate_ctrl_lock); 71 - } 31 + void rate_control_tx_status(struct ieee80211_local *local, 32 + struct ieee80211_supported_band *sband, 33 + struct ieee80211_tx_status *st); 72 34 73 35 void rate_control_rate_init(struct sta_info *sta); 74 36 void rate_control_rate_update(struct ieee80211_local *local,
+3 -3
net/mac80211/rc80211_minstrel.c
··· 264 264 265 265 static void 266 266 minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband, 267 - struct ieee80211_sta *sta, void *priv_sta, 268 - struct ieee80211_tx_info *info) 267 + void *priv_sta, struct ieee80211_tx_status *st) 269 268 { 269 + struct ieee80211_tx_info *info = st->info; 270 270 struct minstrel_priv *mp = priv; 271 271 struct minstrel_sta_info *mi = priv_sta; 272 272 struct ieee80211_tx_rate *ar = info->status.rates; ··· 726 726 727 727 const struct rate_control_ops mac80211_minstrel = { 728 728 .name = "minstrel", 729 - .tx_status_noskb = minstrel_tx_status, 729 + .tx_status_ext = minstrel_tx_status, 730 730 .get_rate = minstrel_get_rate, 731 731 .rate_init = minstrel_rate_init, 732 732 .alloc = minstrel_alloc,
+5 -5
net/mac80211/rc80211_minstrel_ht.c
··· 678 678 679 679 static void 680 680 minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband, 681 - struct ieee80211_sta *sta, void *priv_sta, 682 - struct ieee80211_tx_info *info) 681 + void *priv_sta, struct ieee80211_tx_status *st) 683 682 { 683 + struct ieee80211_tx_info *info = st->info; 684 684 struct minstrel_ht_sta_priv *msp = priv_sta; 685 685 struct minstrel_ht_sta *mi = &msp->ht; 686 686 struct ieee80211_tx_rate *ar = info->status.rates; ··· 690 690 int i; 691 691 692 692 if (!msp->is_ht) 693 - return mac80211_minstrel.tx_status_noskb(priv, sband, sta, 694 - &msp->legacy, info); 693 + return mac80211_minstrel.tx_status_ext(priv, sband, 694 + &msp->legacy, st); 695 695 696 696 /* This packet was aggregated but doesn't carry status info */ 697 697 if ((info->flags & IEEE80211_TX_CTL_AMPDU) && ··· 1374 1374 1375 1375 static const struct rate_control_ops mac80211_minstrel_ht = { 1376 1376 .name = "minstrel_ht", 1377 - .tx_status_noskb = minstrel_ht_tx_status, 1377 + .tx_status_ext = minstrel_ht_tx_status, 1378 1378 .get_rate = minstrel_ht_get_rate, 1379 1379 .rate_init = minstrel_ht_rate_init, 1380 1380 .rate_update = minstrel_ht_rate_update,
+9 -2
net/mac80211/status.c
··· 637 637 { 638 638 struct ieee80211_local *local = hw_to_local(hw); 639 639 struct ieee80211_supported_band *sband; 640 + struct ieee80211_tx_status status = {}; 640 641 int retry_count; 641 642 bool acked, noack_success; 642 643 ··· 670 669 ieee80211_lost_packet(sta, info); 671 670 } 672 671 673 - rate_control_tx_status_noskb(local, sband, sta, info); 672 + status.sta = pubsta; 673 + status.info = info; 674 + rate_control_tx_status(local, sband, &status); 674 675 } 675 676 676 677 if (acked || noack_success) { ··· 751 748 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 752 749 struct ieee80211_local *local = hw_to_local(hw); 753 750 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 751 + struct ieee80211_tx_status status = {}; 754 752 __le16 fc; 755 753 struct ieee80211_supported_band *sband; 756 754 struct rhlist_head *tmp; ··· 861 857 } 862 858 } 863 859 864 - rate_control_tx_status(local, sband, sta, skb); 860 + status.sta = &sta->sta; 861 + status.skb = skb; 862 + status.info = info; 863 + rate_control_tx_status(local, sband, &status); 865 864 if (ieee80211_vif_is_mesh(&sta->sdata->vif)) 866 865 ieee80211s_update_metric(local, sta, skb); 867 866