ath79: rb91x: enable pcie power early (WIP)
[openwrt/staging/xback.git] / package / network / services / hostapd / patches / 590-rrm-wnm-statistics.patch
1 From: David Bauer <mail@david-bauer.net>
2 Date: Sat, 27 Nov 2021 22:08:28 +0100
3 Subject: [PATCH] hostapd: add OpenWrt specific statistic counters
4
5 This adds a new struct for storing statistics not (yet) tracked by
6 hostapd regarding RRM and WNM activity.
7
8 These statistics can be read using the get_status hostapd interface ubus
9 method.
10
11 --- a/src/ap/hostapd.h
12 +++ b/src/ap/hostapd.h
13 @@ -163,6 +163,21 @@ struct hostapd_sae_commit_queue {
14 };
15
16 /**
17 + * struct hostapd_openwrt_stats - OpenWrt custom STA/AP statistics
18 + */
19 +struct hostapd_openwrt_stats {
20 + struct {
21 + u64 neighbor_report_tx;
22 + } rrm;
23 +
24 + struct {
25 + u64 bss_transition_query_rx;
26 + u64 bss_transition_request_tx;
27 + u64 bss_transition_response_rx;
28 + } wnm;
29 +};
30 +
31 +/**
32 * struct hostapd_data - hostapd per-BSS data structure
33 */
34 struct hostapd_data {
35 @@ -182,6 +197,9 @@ struct hostapd_data {
36
37 struct hostapd_data *mld_first_bss;
38
39 + /* OpenWrt specific statistics */
40 + struct hostapd_openwrt_stats openwrt_stats;
41 +
42 int num_sta; /* number of entries in sta_list */
43 struct sta_info *sta_list; /* STA info list head */
44 #define STA_HASH_SIZE 256
45 --- a/src/ap/rrm.c
46 +++ b/src/ap/rrm.c
47 @@ -269,6 +269,8 @@ static void hostapd_send_nei_report_resp
48 }
49 }
50
51 + hapd->openwrt_stats.rrm.neighbor_report_tx++;
52 +
53 hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
54 wpabuf_head(buf), wpabuf_len(buf));
55 wpabuf_free(buf);
56 --- a/src/ap/wnm_ap.c
57 +++ b/src/ap/wnm_ap.c
58 @@ -410,6 +410,7 @@ static int ieee802_11_send_bss_trans_mgm
59 mgmt->u.action.u.bss_tm_req.validity_interval = 1;
60 pos = mgmt->u.action.u.bss_tm_req.variable;
61
62 + hapd->openwrt_stats.wnm.bss_transition_request_tx++;
63 wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Request to "
64 MACSTR " dialog_token=%u req_mode=0x%x disassoc_timer=%u "
65 "validity_interval=%u",
66 @@ -814,10 +815,12 @@ int ieee802_11_rx_wnm_action_ap(struct h
67 plen);
68 return 0;
69 case WNM_BSS_TRANS_MGMT_QUERY:
70 + hapd->openwrt_stats.wnm.bss_transition_query_rx++;
71 ieee802_11_rx_bss_trans_mgmt_query(hapd, mgmt->sa, payload,
72 plen);
73 return 0;
74 case WNM_BSS_TRANS_MGMT_RESP:
75 + hapd->openwrt_stats.wnm.bss_transition_response_rx++;
76 ieee802_11_rx_bss_trans_mgmt_resp(hapd, mgmt->sa, payload,
77 plen);
78 return 0;
79 @@ -865,6 +868,7 @@ int wnm_send_disassoc_imminent(struct ho
80
81 pos = mgmt->u.action.u.bss_tm_req.variable;
82
83 + hapd->openwrt_stats.wnm.bss_transition_request_tx++;
84 wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Request frame to indicate imminent disassociation (disassoc_timer=%d) to "
85 MACSTR, disassoc_timer, MAC2STR(sta->addr));
86 if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0, NULL, 0, 0) < 0) {
87 @@ -947,6 +951,7 @@ int wnm_send_ess_disassoc_imminent(struc
88 return -1;
89 }
90
91 + hapd->openwrt_stats.wnm.bss_transition_request_tx++;
92 if (disassoc_timer) {
93 /* send disassociation frame after time-out */
94 set_disassoc_timer(hapd, sta, disassoc_timer);
95 @@ -1028,6 +1033,7 @@ int wnm_send_bss_tm_req(struct hostapd_d
96 }
97 os_free(buf);
98
99 + hapd->openwrt_stats.wnm.bss_transition_request_tx++;
100 if (disassoc_timer) {
101 #ifdef CONFIG_IEEE80211BE
102 if (ap_sta_is_mld(hapd, sta)) {