Skip to content

Commit f027c2a

Browse files
Felix Fietkaujmberg-intel
authored andcommitted
mac80211: add ieee80211_tx_status_noskb
This can be used by drivers that cannot reliably map tx status information onto specific skbs. Signed-off-by: Felix Fietkau <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 7e1cdcb commit f027c2a

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

include/net/mac80211.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3618,6 +3618,26 @@ void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
36183618
void ieee80211_tx_status(struct ieee80211_hw *hw,
36193619
struct sk_buff *skb);
36203620

3621+
/**
3622+
* ieee80211_tx_status_noskb - transmit status callback without skb
3623+
*
3624+
* This function can be used as a replacement for ieee80211_tx_status
3625+
* in drivers that cannot reliably map tx status information back to
3626+
* specific skbs.
3627+
*
3628+
* Calls to this function for a single hardware must be synchronized
3629+
* against each other. Calls to this function, ieee80211_tx_status_ni()
3630+
* and ieee80211_tx_status_irqsafe() may not be mixed for a single hardware.
3631+
*
3632+
* @hw: the hardware the frame was transmitted by
3633+
* @sta: the receiver station to which this packet is sent
3634+
* (NULL for multicast packets)
3635+
* @info: tx status information
3636+
*/
3637+
void ieee80211_tx_status_noskb(struct ieee80211_hw *hw,
3638+
struct ieee80211_sta *sta,
3639+
struct ieee80211_tx_info *info);
3640+
36213641
/**
36223642
* ieee80211_tx_status_ni - transmit status callback (in process context)
36233643
*

net/mac80211/rate.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ static inline void rate_control_tx_status(struct ieee80211_local *local,
4848
ref->ops->tx_status_noskb(ref->priv, sband, ista, priv_sta, info);
4949
}
5050

51+
static inline void
52+
rate_control_tx_status_noskb(struct ieee80211_local *local,
53+
struct ieee80211_supported_band *sband,
54+
struct sta_info *sta,
55+
struct ieee80211_tx_info *info)
56+
{
57+
struct rate_control_ref *ref = local->rate_ctrl;
58+
struct ieee80211_sta *ista = &sta->sta;
59+
void *priv_sta = sta->rate_ctrl_priv;
60+
61+
if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
62+
return;
63+
64+
if (WARN_ON_ONCE(!ref->ops->tx_status_noskb))
65+
return;
66+
67+
ref->ops->tx_status_noskb(ref->priv, sband, ista, priv_sta, info);
68+
}
5169

5270
static inline void rate_control_rate_init(struct sta_info *sta)
5371
{

net/mac80211/status.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,60 @@ static int ieee80211_tx_get_rates(struct ieee80211_hw *hw,
656656
return rates_idx;
657657
}
658658

659+
void ieee80211_tx_status_noskb(struct ieee80211_hw *hw,
660+
struct ieee80211_sta *pubsta,
661+
struct ieee80211_tx_info *info)
662+
{
663+
struct ieee80211_local *local = hw_to_local(hw);
664+
struct ieee80211_supported_band *sband;
665+
int retry_count;
666+
int rates_idx;
667+
bool acked;
668+
669+
rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
670+
671+
sband = hw->wiphy->bands[info->band];
672+
673+
acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
674+
if (pubsta) {
675+
struct sta_info *sta;
676+
677+
sta = container_of(pubsta, struct sta_info, sta);
678+
679+
if (!acked)
680+
sta->tx_retry_failed++;
681+
sta->tx_retry_count += retry_count;
682+
683+
if (acked) {
684+
sta->last_rx = jiffies;
685+
686+
if (sta->lost_packets)
687+
sta->lost_packets = 0;
688+
689+
/* Track when last TDLS packet was ACKed */
690+
if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH))
691+
sta->last_tdls_pkt_time = jiffies;
692+
} else {
693+
ieee80211_lost_packet(sta, info);
694+
}
695+
696+
rate_control_tx_status_noskb(local, sband, sta, info);
697+
}
698+
699+
if (acked) {
700+
local->dot11TransmittedFrameCount++;
701+
if (!pubsta)
702+
local->dot11MulticastTransmittedFrameCount++;
703+
if (retry_count > 0)
704+
local->dot11RetryCount++;
705+
if (retry_count > 1)
706+
local->dot11MultipleRetryCount++;
707+
} else {
708+
local->dot11FailedCount++;
709+
}
710+
}
711+
EXPORT_SYMBOL(ieee80211_tx_status_noskb);
712+
659713
void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
660714
{
661715
struct sk_buff *skb2;

0 commit comments

Comments
 (0)