Skip to content

Commit 904c277

Browse files
ilanpeer2jmberg-intel
authored andcommitted
wifi: cfg80211: Add support for controlling EPCS
Add support for configuring Emergency Preparedness Communication Services (EPCS) for station mode. Signed-off-by: Ilan Peer <[email protected]> Reviewed-by: Johannes Berg <[email protected]> Signed-off-by: Miri Korenblit <[email protected]> Link: https://patch.msgid.link/20250102161730.ea54ac94445c.I11d750188bc0871e13e86146a3b5cc048d853e69@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 36e05b0 commit 904c277

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed

include/net/cfg80211.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4594,6 +4594,7 @@ struct mgmt_frame_regs {
45944594
*
45954595
* @set_hw_timestamp: Enable/disable HW timestamping of TM/FTM frames.
45964596
* @set_ttlm: set the TID to link mapping.
4597+
* @set_epcs: Enable/Disable EPCS for station mode.
45974598
* @get_radio_mask: get bitmask of radios in use.
45984599
* (invoked with the wiphy mutex held)
45994600
* @assoc_ml_reconf: Request a non-AP MLO connection to perform ML
@@ -4971,6 +4972,8 @@ struct cfg80211_ops {
49714972
int (*assoc_ml_reconf)(struct wiphy *wiphy, struct net_device *dev,
49724973
struct cfg80211_assoc_link *add_links,
49734974
u16 rem_links);
4975+
int (*set_epcs)(struct wiphy *wiphy, struct net_device *dev,
4976+
bool val);
49744977
};
49754978

49764979
/*
@@ -9771,6 +9774,13 @@ void cfg80211_mlo_reconf_add_done(struct net_device *dev,
97719774
*/
97729775
void cfg80211_schedule_channels_check(struct wireless_dev *wdev);
97739776

9777+
/**
9778+
* cfg80211_epcs_changed - Notify about a change in EPCS state
9779+
* @netdev: the wireless device whose EPCS state changed
9780+
* @enabled: set to true if EPCS was enabled, otherwise set to false.
9781+
*/
9782+
void cfg80211_epcs_changed(struct net_device *netdev, bool enabled);
9783+
97749784
#ifdef CONFIG_CFG80211_DEBUGFS
97759785
/**
97769786
* wiphy_locked_debugfs_read - do a locked read in debugfs

include/uapi/linux/nl80211.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,10 @@
13321332
* @NL80211_CMD_ASSOC_MLO_RECONF: For a non-AP MLD station, request to
13331333
* add/remove links to/from the association.
13341334
*
1335+
* @NL80211_CMD_EPCS_CFG: EPCS configuration for a station. Used by userland to
1336+
* control EPCS configuration. Used to notify userland on the current state
1337+
* of EPCS.
1338+
*
13351339
* @NL80211_CMD_MAX: highest used command number
13361340
* @__NL80211_CMD_AFTER_LAST: internal use
13371341
*/
@@ -1590,6 +1594,7 @@ enum nl80211_commands {
15901594
NL80211_CMD_SET_TID_TO_LINK_MAPPING,
15911595

15921596
NL80211_CMD_ASSOC_MLO_RECONF,
1597+
NL80211_CMD_EPCS_CFG,
15931598

15941599
/* add new commands above here */
15951600

@@ -2885,6 +2890,9 @@ enum nl80211_commands {
28852890
* @NL80211_ATTR_MLO_RECONF_REM_LINKS: (u16) A bitmask of the links requested
28862891
* to be removed from the MLO association.
28872892
*
2893+
* @NL80211_ATTR_EPCS: Flag attribute indicating that EPCS is enabled for a
2894+
* station interface.
2895+
*
28882896
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
28892897
* @NL80211_ATTR_MAX: highest attribute number currently defined
28902898
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3438,6 +3446,7 @@ enum nl80211_attrs {
34383446
NL80211_ATTR_SUPPORTED_SELECTORS,
34393447

34403448
NL80211_ATTR_MLO_RECONF_REM_LINKS,
3449+
NL80211_ATTR_EPCS,
34413450

34423451
/* add attributes here, update the policy in nl80211.c */
34433452

net/wireless/nl80211.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
849849
NLA_POLICY_VALIDATE_FN(NLA_BINARY, validate_supported_selectors,
850850
NL80211_MAX_SUPP_SELECTORS),
851851
[NL80211_ATTR_MLO_RECONF_REM_LINKS] = { .type = NLA_U16 },
852+
[NL80211_ATTR_EPCS] = { .type = NLA_FLAG },
852853
};
853854

854855
/* policy for the key attributes */
@@ -16537,6 +16538,26 @@ static int nl80211_assoc_ml_reconf(struct sk_buff *skb, struct genl_info *info)
1653716538
return err;
1653816539
}
1653916540

16541+
static int
16542+
nl80211_epcs_cfg(struct sk_buff *skb, struct genl_info *info)
16543+
{
16544+
struct cfg80211_registered_device *rdev = info->user_ptr[0];
16545+
struct net_device *dev = info->user_ptr[1];
16546+
struct wireless_dev *wdev = dev->ieee80211_ptr;
16547+
bool val;
16548+
16549+
if (wdev->iftype != NL80211_IFTYPE_STATION &&
16550+
wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
16551+
return -EOPNOTSUPP;
16552+
16553+
if (!wdev->connected)
16554+
return -ENOLINK;
16555+
16556+
val = nla_get_flag(info->attrs[NL80211_ATTR_EPCS]);
16557+
16558+
return rdev_set_epcs(rdev, dev, val);
16559+
}
16560+
1654016561
#define NL80211_FLAG_NEED_WIPHY 0x01
1654116562
#define NL80211_FLAG_NEED_NETDEV 0x02
1654216563
#define NL80211_FLAG_NEED_RTNL 0x04
@@ -17735,6 +17756,12 @@ static const struct genl_small_ops nl80211_small_ops[] = {
1773517756
.flags = GENL_UNS_ADMIN_PERM,
1773617757
.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP),
1773717758
},
17759+
{
17760+
.cmd = NL80211_CMD_EPCS_CFG,
17761+
.doit = nl80211_epcs_cfg,
17762+
.flags = GENL_UNS_ADMIN_PERM,
17763+
.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP),
17764+
},
1773817765
};
1773917766

1774017767
static struct genl_family nl80211_fam __ro_after_init = {
@@ -20480,6 +20507,39 @@ void cfg80211_schedule_channels_check(struct wireless_dev *wdev)
2048020507
}
2048120508
EXPORT_SYMBOL(cfg80211_schedule_channels_check);
2048220509

20510+
void cfg80211_epcs_changed(struct net_device *netdev, bool enabled)
20511+
{
20512+
struct wireless_dev *wdev = netdev->ieee80211_ptr;
20513+
struct wiphy *wiphy = wdev->wiphy;
20514+
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
20515+
struct sk_buff *msg;
20516+
void *hdr;
20517+
20518+
trace_cfg80211_epcs_changed(wdev, enabled);
20519+
20520+
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
20521+
if (!msg)
20522+
return;
20523+
20524+
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_EPCS_CFG);
20525+
if (!hdr) {
20526+
nlmsg_free(msg);
20527+
return;
20528+
}
20529+
20530+
if (enabled && nla_put_flag(msg, NL80211_ATTR_EPCS))
20531+
goto nla_put_failure;
20532+
20533+
genlmsg_end(msg, hdr);
20534+
genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
20535+
NL80211_MCGRP_MLME, GFP_KERNEL);
20536+
return;
20537+
20538+
nla_put_failure:
20539+
nlmsg_free(msg);
20540+
}
20541+
EXPORT_SYMBOL(cfg80211_epcs_changed);
20542+
2048320543
/* initialisation/exit functions */
2048420544

2048520545
int __init nl80211_init(void)

net/wireless/rdev-ops.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,4 +1566,19 @@ rdev_assoc_ml_reconf(struct cfg80211_registered_device *rdev,
15661566
return ret;
15671567
}
15681568

1569+
static inline int
1570+
rdev_set_epcs(struct cfg80211_registered_device *rdev,
1571+
struct net_device *dev, bool val)
1572+
{
1573+
struct wiphy *wiphy = &rdev->wiphy;
1574+
int ret = -EOPNOTSUPP;
1575+
1576+
trace_rdev_set_epcs(wiphy, dev, val);
1577+
if (rdev->ops->set_epcs)
1578+
ret = rdev->ops->set_epcs(wiphy, dev, val);
1579+
trace_rdev_return_int(wiphy, ret);
1580+
1581+
return ret;
1582+
}
1583+
15691584
#endif /* __CFG80211_RDEV_OPS */

net/wireless/trace.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,6 +3049,24 @@ TRACE_EVENT(rdev_set_ttlm,
30493049
WIPHY_PR_ARG, NETDEV_PR_ARG)
30503050
);
30513051

3052+
TRACE_EVENT(rdev_set_epcs,
3053+
TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
3054+
bool val),
3055+
TP_ARGS(wiphy, netdev, val),
3056+
TP_STRUCT__entry(
3057+
WIPHY_ENTRY
3058+
NETDEV_ENTRY
3059+
__field(bool, val)
3060+
),
3061+
TP_fast_assign(
3062+
WIPHY_ASSIGN;
3063+
NETDEV_ASSIGN;
3064+
__entry->val = val;
3065+
),
3066+
TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", config=%u",
3067+
WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->val)
3068+
);
3069+
30523070
/*************************************************************
30533071
* cfg80211 exported functions traces *
30543072
*************************************************************/
@@ -4148,6 +4166,22 @@ TRACE_EVENT(rdev_assoc_ml_reconf,
41484166
WIPHY_PR_ARG, NETDEV_PR_ARG,
41494167
__entry->add_links, __entry->rem_links)
41504168
);
4169+
4170+
TRACE_EVENT(cfg80211_epcs_changed,
4171+
TP_PROTO(struct wireless_dev *wdev, bool enabled),
4172+
TP_ARGS(wdev, enabled),
4173+
TP_STRUCT__entry(
4174+
WDEV_ENTRY
4175+
__field(u32, enabled)
4176+
),
4177+
TP_fast_assign(
4178+
WDEV_ASSIGN;
4179+
__entry->enabled = enabled;
4180+
),
4181+
TP_printk(WDEV_PR_FMT ", enabled=%u",
4182+
WDEV_PR_ARG, __entry->enabled)
4183+
);
4184+
41514185
#endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
41524186

41534187
#undef TRACE_INCLUDE_PATH

0 commit comments

Comments
 (0)