Skip to content

Commit 466b993

Browse files
tamizhr@codeaurora.orgjmberg-intel
authored andcommitted
cfg80211: Add support to notify station's opmode change to userspace
ht/vht action frames will be sent to AP from station to notify change of its ht/vht opmode(max bandwidth, smps mode or nss) modified values. Currently these valuse used by driver/firmware for rate control algorithm. This patch introduces NL80211_CMD_STA_OPMODE_CHANGED command to notify those modified/current supported values(max bandwidth, smps mode, max nss) to userspace application. This will be useful for the application like steering, which closely monitoring station's capability changes. Since the application has taken these values during station association. Signed-off-by: Tamizh chelvam <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 25b0ba7 commit 466b993

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed

include/net/cfg80211.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3553,6 +3553,35 @@ enum wiphy_vendor_command_flags {
35533553
WIPHY_VENDOR_CMD_NEED_RUNNING = BIT(2),
35543554
};
35553555

3556+
/**
3557+
* enum wiphy_opmode_flag - Station's ht/vht operation mode information flags
3558+
*
3559+
* @STA_OPMODE_MAX_BW_CHANGED: Max Bandwidth changed
3560+
* @STA_OPMODE_SMPS_MODE_CHANGED: SMPS mode changed
3561+
* @STA_OPMODE_N_SS_CHANGED: max N_SS (number of spatial streams) changed
3562+
*
3563+
*/
3564+
enum wiphy_opmode_flag {
3565+
STA_OPMODE_MAX_BW_CHANGED = BIT(0),
3566+
STA_OPMODE_SMPS_MODE_CHANGED = BIT(1),
3567+
STA_OPMODE_N_SS_CHANGED = BIT(2),
3568+
};
3569+
3570+
/**
3571+
* struct sta_opmode_info - Station's ht/vht operation mode information
3572+
* @changed: contains value from &enum wiphy_opmode_flag
3573+
* @smps_mode: New SMPS mode of a station
3574+
* @bw: new max bandwidth value of a station
3575+
* @rx_nss: new rx_nss value of a station
3576+
*/
3577+
3578+
struct sta_opmode_info {
3579+
u32 changed;
3580+
u8 smps_mode;
3581+
u8 bw;
3582+
u8 rx_nss;
3583+
};
3584+
35563585
/**
35573586
* struct wiphy_vendor_command - vendor command definition
35583587
* @info: vendor command identifying information, as used in nl80211
@@ -5721,6 +5750,20 @@ void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp);
57215750
void cfg80211_radar_event(struct wiphy *wiphy,
57225751
struct cfg80211_chan_def *chandef, gfp_t gfp);
57235752

5753+
/**
5754+
* cfg80211_sta_opmode_change_notify - STA's ht/vht operation mode change event
5755+
* @dev: network device
5756+
* @mac: MAC address of a station which opmode got modified
5757+
* @sta_opmode: station's current opmode value
5758+
* @gfp: context flags
5759+
*
5760+
* Driver should call this function when station's opmode modified via action
5761+
* frame.
5762+
*/
5763+
void cfg80211_sta_opmode_change_notify(struct net_device *dev, const u8 *mac,
5764+
struct sta_opmode_info *sta_opmode,
5765+
gfp_t gfp);
5766+
57245767
/**
57255768
* cfg80211_cac_event - Channel availability check (CAC) event
57265769
* @netdev: network device

include/uapi/linux/nl80211.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,11 @@
10131013
* user space through the connect result as the user space would have
10141014
* initiated the connection through the connect request.
10151015
*
1016+
* @NL80211_CMD_STA_OPMODE_CHANGED: An event that notify station's
1017+
* ht opmode or vht opmode changes using any of &NL80211_ATTR_SMPS_MODE,
1018+
* &NL80211_ATTR_CHANNEL_WIDTH,&NL80211_ATTR_NSS attributes with its
1019+
* address(specified in &NL80211_ATTR_MAC).
1020+
*
10161021
* @NL80211_CMD_MAX: highest used command number
10171022
* @__NL80211_CMD_AFTER_LAST: internal use
10181023
*/
@@ -1221,6 +1226,8 @@ enum nl80211_commands {
12211226

12221227
NL80211_CMD_EXTERNAL_AUTH,
12231228

1229+
NL80211_CMD_STA_OPMODE_CHANGED,
1230+
12241231
/* add new commands above here */
12251232

12261233
/* used to define NL80211_CMD_MAX below */
@@ -2186,6 +2193,9 @@ enum nl80211_commands {
21862193
* authentication processing to user space if this capability is indicated
21872194
* in NL80211_CMD_CONNECT requests from the user space.
21882195
*
2196+
* @NL80211_ATTR_NSS: Station's New/updated RX_NSS value notified using this
2197+
* u8 attribute. This is used with %NL80211_CMD_STA_OPMODE_CHANGED.
2198+
*
21892199
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
21902200
* @NL80211_ATTR_MAX: highest attribute number currently defined
21912201
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2615,6 +2625,8 @@ enum nl80211_attrs {
26152625
NL80211_ATTR_EXTERNAL_AUTH_ACTION,
26162626
NL80211_ATTR_EXTERNAL_AUTH_SUPPORT,
26172627

2628+
NL80211_ATTR_NSS,
2629+
26182630
/* add attributes here, update the policy in nl80211.c */
26192631

26202632
__NL80211_ATTR_AFTER_LAST,

net/wireless/nl80211.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14950,6 +14950,61 @@ nl80211_radar_notify(struct cfg80211_registered_device *rdev,
1495014950
nlmsg_free(msg);
1495114951
}
1495214952

14953+
void cfg80211_sta_opmode_change_notify(struct net_device *dev, const u8 *mac,
14954+
struct sta_opmode_info *sta_opmode,
14955+
gfp_t gfp)
14956+
{
14957+
struct sk_buff *msg;
14958+
struct wireless_dev *wdev = dev->ieee80211_ptr;
14959+
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
14960+
void *hdr;
14961+
14962+
if (WARN_ON(!mac))
14963+
return;
14964+
14965+
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
14966+
if (!msg)
14967+
return;
14968+
14969+
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_STA_OPMODE_CHANGED);
14970+
if (!hdr) {
14971+
nlmsg_free(msg);
14972+
return;
14973+
}
14974+
14975+
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx))
14976+
goto nla_put_failure;
14977+
14978+
if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex))
14979+
goto nla_put_failure;
14980+
14981+
if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac))
14982+
goto nla_put_failure;
14983+
14984+
if ((sta_opmode->changed & STA_OPMODE_SMPS_MODE_CHANGED) &&
14985+
nla_put_u8(msg, NL80211_ATTR_SMPS_MODE, sta_opmode->smps_mode))
14986+
goto nla_put_failure;
14987+
14988+
if ((sta_opmode->changed & STA_OPMODE_MAX_BW_CHANGED) &&
14989+
nla_put_u8(msg, NL80211_ATTR_CHANNEL_WIDTH, sta_opmode->bw))
14990+
goto nla_put_failure;
14991+
14992+
if ((sta_opmode->changed & STA_OPMODE_N_SS_CHANGED) &&
14993+
nla_put_u8(msg, NL80211_ATTR_NSS, sta_opmode->rx_nss))
14994+
goto nla_put_failure;
14995+
14996+
genlmsg_end(msg, hdr);
14997+
14998+
genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
14999+
NL80211_MCGRP_MLME, gfp);
15000+
15001+
return;
15002+
15003+
nla_put_failure:
15004+
nlmsg_free(msg);
15005+
}
15006+
EXPORT_SYMBOL(cfg80211_sta_opmode_change_notify);
15007+
1495315008
void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
1495415009
u64 cookie, bool acked, gfp_t gfp)
1495515010
{

0 commit comments

Comments
 (0)