@@ -6694,30 +6694,6 @@ static bool nl80211_put_signal(struct sk_buff *msg, u8 mask, s8 *signal,
return true;
}
-static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
- u32 seq, int flags,
- struct cfg80211_registered_device *rdev,
- struct net_device *dev,
- const u8 *mac_addr, struct station_info *sinfo)
-{
- void *hdr;
- struct nlattr *sinfoattr, *bss_param;
-
- hdr = nl80211hdr_put(msg, portid, seq, flags, cmd);
- if (!hdr) {
- cfg80211_sinfo_release_content(sinfo);
- return -1;
- }
-
- if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
- nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr) ||
- nla_put_u32(msg, NL80211_ATTR_GENERATION, sinfo->generation))
- goto nla_put_failure;
-
- sinfoattr = nla_nest_start_noflag(msg, NL80211_ATTR_STA_INFO);
- if (!sinfoattr)
- goto nla_put_failure;
-
#define PUT_SINFO(attr, memb, type) do { \
BUILD_BUG_ON(sizeof(type) == sizeof(u64)); \
if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_ ## attr) && \
@@ -6732,9 +6708,13 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
goto nla_put_failure; \
} while (0)
- PUT_SINFO(CONNECTED_TIME, connected_time, u32);
+static int nl80211_fill_link_station(struct sk_buff *msg,
+ struct cfg80211_registered_device *rdev,
+ struct station_info *sinfo)
+{
+ struct nlattr *bss_param;
+
PUT_SINFO(INACTIVE_TIME, inactive_time, u32);
- PUT_SINFO_U64(ASSOC_AT_BOOTTIME, assoc_at);
if (sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES) |
BIT_ULL(NL80211_STA_INFO_RX_BYTES64)) &&
@@ -6795,17 +6775,6 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
PUT_SINFO(EXPECTED_THROUGHPUT, expected_throughput, u32);
PUT_SINFO(BEACON_LOSS, beacon_loss_count, u32);
- PUT_SINFO(LLID, llid, u16);
- PUT_SINFO(PLID, plid, u16);
- PUT_SINFO(PLINK_STATE, plink_state, u8);
- PUT_SINFO(AIRTIME_LINK_METRIC, airtime_link_metric, u32);
- PUT_SINFO(LOCAL_PM, local_pm, u32);
- PUT_SINFO(PEER_PM, peer_pm, u32);
- PUT_SINFO(NONPEER_PM, nonpeer_pm, u32);
- PUT_SINFO(CONNECTED_TO_GATE, connected_to_gate, u8);
- PUT_SINFO(CONNECTED_TO_AS, connected_to_as, u8);
- PUT_SINFO_U64(T_OFFSET, t_offset);
-
if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_BSS_PARAM)) {
bss_param = nla_nest_start_noflag(msg,
NL80211_STA_INFO_BSS_PARAM);
@@ -6826,11 +6795,6 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
nla_nest_end(msg, bss_param);
}
- if ((sinfo->filled & BIT_ULL(NL80211_STA_INFO_STA_FLAGS)) &&
- nla_put(msg, NL80211_STA_INFO_STA_FLAGS,
- sizeof(struct nl80211_sta_flag_update),
- &sinfo->sta_flags))
- goto nla_put_failure;
PUT_SINFO_U64(RX_DROP_MISC, rx_dropped_misc);
PUT_SINFO_U64(BEACON_RX, rx_beacon);
@@ -6843,9 +6807,6 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
PUT_SINFO(ACK_SIGNAL_AVG, avg_ack_signal, s8);
}
-#undef PUT_SINFO
-#undef PUT_SINFO_U64
-
if (sinfo->pertid) {
struct nlattr *tidsattr;
int tid;
@@ -6893,6 +6854,59 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
nla_nest_end(msg, tidsattr);
}
+ return 0;
+
+nla_put_failure:
+ return -EMSGSIZE;
+}
+
+static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
+ u32 seq, int flags,
+ struct cfg80211_registered_device *rdev,
+ struct net_device *dev,
+ const u8 *mac_addr, struct station_info *sinfo)
+{
+ void *hdr;
+ struct nlattr *sinfoattr;
+
+ hdr = nl80211hdr_put(msg, portid, seq, flags, cmd);
+ if (!hdr) {
+ cfg80211_sinfo_release_content(sinfo);
+ return -1;
+ }
+
+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
+ nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr) ||
+ nla_put_u32(msg, NL80211_ATTR_GENERATION, sinfo->generation))
+ goto nla_put_failure;
+
+ sinfoattr = nla_nest_start_noflag(msg, NL80211_ATTR_STA_INFO);
+ if (!sinfoattr)
+ goto nla_put_failure;
+
+ PUT_SINFO(CONNECTED_TIME, connected_time, u32);
+ PUT_SINFO_U64(ASSOC_AT_BOOTTIME, assoc_at);
+
+ PUT_SINFO(LLID, llid, u16);
+ PUT_SINFO(PLID, plid, u16);
+ PUT_SINFO(PLINK_STATE, plink_state, u8);
+ PUT_SINFO(AIRTIME_LINK_METRIC, airtime_link_metric, u32);
+ PUT_SINFO(LOCAL_PM, local_pm, u32);
+ PUT_SINFO(PEER_PM, peer_pm, u32);
+ PUT_SINFO(NONPEER_PM, nonpeer_pm, u32);
+ PUT_SINFO(CONNECTED_TO_GATE, connected_to_gate, u8);
+ PUT_SINFO(CONNECTED_TO_AS, connected_to_as, u8);
+ PUT_SINFO_U64(T_OFFSET, t_offset);
+
+ if ((sinfo->filled & BIT_ULL(NL80211_STA_INFO_STA_FLAGS)) &&
+ nla_put(msg, NL80211_STA_INFO_STA_FLAGS,
+ sizeof(struct nl80211_sta_flag_update),
+ &sinfo->sta_flags))
+ goto nla_put_failure;
+
+ if (nl80211_fill_link_station(msg, rdev, sinfo))
+ goto nla_put_failure;
+
nla_nest_end(msg, sinfoattr);
if (sinfo->assoc_req_ies_len &&
@@ -6926,6 +6940,9 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
return -EMSGSIZE;
}
+#undef PUT_SINFO
+#undef PUT_SINFO_U64
+
static int nl80211_dump_station(struct sk_buff *skb,
struct netlink_callback *cb)
{
Refactor nl80211_send_station() to fill link level NL attributes for station statistics. This will allow to add support for MLO station statistics in ease way in subsequent patches. No functionality changes added. Signed-off-by: Sarika Sharma <quic_sarishar@quicinc.com> --- net/wireless/nl80211.c | 107 ++++++++++++++++++++++++----------------- 1 file changed, 62 insertions(+), 45 deletions(-)