Skip to content

Commit 98c8a60

Browse files
Jouni Malinenlinvjw
authored andcommitted
nl80211: Provide access to STA TX/RX packet counters
The TX/RX packet counters are needed to fill in RADIUS Accounting attributes Acct-Output-Packets and Acct-Input-Packets. We already collect the needed information, but only the TX/RX bytes were previously exposed through nl80211. Allow applications to fetch the packet counters, too, to provide more complete support for accounting. Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com> Acked-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent fdbf733 commit 98c8a60

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎include/linux/nl80211.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@ enum nl80211_rate_info {
526526
* @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm)
527527
* @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute
528528
* containing info as possible, see &enum nl80211_sta_info_txrate.
529+
* @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station)
530+
* @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this
531+
* station)
529532
*/
530533
enum nl80211_sta_info {
531534
__NL80211_STA_INFO_INVALID,
@@ -537,6 +540,8 @@ enum nl80211_sta_info {
537540
NL80211_STA_INFO_PLINK_STATE,
538541
NL80211_STA_INFO_SIGNAL,
539542
NL80211_STA_INFO_TX_BITRATE,
543+
NL80211_STA_INFO_RX_PACKETS,
544+
NL80211_STA_INFO_TX_PACKETS,
540545

541546
/* keep last */
542547
__NL80211_STA_INFO_AFTER_LAST,

‎include/net/cfg80211.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ struct station_parameters {
178178
* @STATION_INFO_SIGNAL: @signal filled
179179
* @STATION_INFO_TX_BITRATE: @tx_bitrate fields are filled
180180
* (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs)
181+
* @STATION_INFO_RX_PACKETS: @rx_packets filled
182+
* @STATION_INFO_TX_PACKETS: @tx_packets filled
181183
*/
182184
enum station_info_flags {
183185
STATION_INFO_INACTIVE_TIME = 1<<0,
@@ -188,6 +190,8 @@ enum station_info_flags {
188190
STATION_INFO_PLINK_STATE = 1<<5,
189191
STATION_INFO_SIGNAL = 1<<6,
190192
STATION_INFO_TX_BITRATE = 1<<7,
193+
STATION_INFO_RX_PACKETS = 1<<8,
194+
STATION_INFO_TX_PACKETS = 1<<9,
191195
};
192196

193197
/**
@@ -235,6 +239,8 @@ struct rate_info {
235239
* @plink_state: mesh peer link state
236240
* @signal: signal strength of last received packet in dBm
237241
* @txrate: current unicast bitrate to this station
242+
* @rx_packets: packets received from this station
243+
* @tx_packets: packets transmitted to this station
238244
*/
239245
struct station_info {
240246
u32 filled;
@@ -246,6 +252,8 @@ struct station_info {
246252
u8 plink_state;
247253
s8 signal;
248254
struct rate_info txrate;
255+
u32 rx_packets;
256+
u32 tx_packets;
249257
};
250258

251259
/**

‎net/mac80211/cfg.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,15 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
341341
sinfo->filled = STATION_INFO_INACTIVE_TIME |
342342
STATION_INFO_RX_BYTES |
343343
STATION_INFO_TX_BYTES |
344+
STATION_INFO_RX_PACKETS |
345+
STATION_INFO_TX_PACKETS |
344346
STATION_INFO_TX_BITRATE;
345347

346348
sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
347349
sinfo->rx_bytes = sta->rx_bytes;
348350
sinfo->tx_bytes = sta->tx_bytes;
351+
sinfo->rx_packets = sta->rx_packets;
352+
sinfo->tx_packets = sta->tx_packets;
349353

350354
if (sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
351355
sinfo->filled |= STATION_INFO_SIGNAL;

‎net/wireless/nl80211.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,12 @@ static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq,
12061206

12071207
nla_nest_end(msg, txrate);
12081208
}
1209+
if (sinfo->filled & STATION_INFO_RX_PACKETS)
1210+
NLA_PUT_U32(msg, NL80211_STA_INFO_RX_PACKETS,
1211+
sinfo->rx_packets);
1212+
if (sinfo->filled & STATION_INFO_TX_PACKETS)
1213+
NLA_PUT_U32(msg, NL80211_STA_INFO_TX_PACKETS,
1214+
sinfo->tx_packets);
12091215
nla_nest_end(msg, sinfoattr);
12101216

12111217
return genlmsg_end(msg, hdr);

0 commit comments

Comments
 (0)