mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-14 16:23:51 +08:00
wifi: cfg80211: add optional link add/remove callbacks
Add some optional callbacks for link add/remove so that drivers can react here. Initially, I thought it would be sufficient to just create the link in start_ap etc., but it turns out that's not so simple, since there are quite a few callbacks that can be called: if they're erroneously without start_ap, things might crash. Thus it might be easier for drivers to allocate all the necessary data structures immediately, to not have to worry about it in each callback, since cfg80211 checks that the link ID is valid (has been added.) Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
c8a11ed553
commit
f2a0290b2d
@ -3858,6 +3858,11 @@ struct mgmt_frame_regs {
|
||||
* keep the struct wireless_dev's iftype updated.
|
||||
* This additionally holds the RTNL to be able to do netdev changes.
|
||||
*
|
||||
* @add_intf_link: Add a new MLO link to the given interface. Note that
|
||||
* the wdev->link[] data structure has been updated, so the new link
|
||||
* address is available.
|
||||
* @del_intf_link: Remove an MLO link from the given interface.
|
||||
*
|
||||
* @add_key: add a key with the given parameters. @mac_addr will be %NULL
|
||||
* when adding a group key.
|
||||
*
|
||||
@ -4212,6 +4217,13 @@ struct cfg80211_ops {
|
||||
enum nl80211_iftype type,
|
||||
struct vif_params *params);
|
||||
|
||||
int (*add_intf_link)(struct wiphy *wiphy,
|
||||
struct wireless_dev *wdev,
|
||||
unsigned int link_id);
|
||||
void (*del_intf_link)(struct wiphy *wiphy,
|
||||
struct wireless_dev *wdev,
|
||||
unsigned int link_id);
|
||||
|
||||
int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
|
||||
u8 key_index, bool pairwise, const u8 *mac_addr,
|
||||
struct key_params *params);
|
||||
|
@ -15556,9 +15556,11 @@ static int nl80211_set_fils_aad(struct sk_buff *skb,
|
||||
|
||||
static int nl80211_add_link(struct sk_buff *skb, struct genl_info *info)
|
||||
{
|
||||
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
||||
unsigned int link_id = nl80211_link_id(info->attrs);
|
||||
struct net_device *dev = info->user_ptr[1];
|
||||
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
||||
int ret;
|
||||
|
||||
if (!(wdev->wiphy->flags & WIPHY_FLAG_SUPPORTS_MLO))
|
||||
return -EINVAL;
|
||||
@ -15578,13 +15580,20 @@ static int nl80211_add_link(struct sk_buff *skb, struct genl_info *info)
|
||||
wdev->valid_links |= BIT(link_id);
|
||||
ether_addr_copy(wdev->links[link_id].addr,
|
||||
nla_data(info->attrs[NL80211_ATTR_MAC]));
|
||||
|
||||
ret = rdev_add_intf_link(rdev, wdev, link_id);
|
||||
if (ret) {
|
||||
wdev->valid_links &= ~BIT(link_id);
|
||||
eth_zero_addr(wdev->links[link_id].addr);
|
||||
}
|
||||
wdev_unlock(wdev);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int nl80211_remove_link(struct sk_buff *skb, struct genl_info *info)
|
||||
{
|
||||
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
||||
unsigned int link_id = nl80211_link_id(info->attrs);
|
||||
struct net_device *dev = info->user_ptr[1];
|
||||
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
||||
@ -15604,6 +15613,9 @@ static int nl80211_remove_link(struct sk_buff *skb, struct genl_info *info)
|
||||
|
||||
wdev_lock(wdev);
|
||||
wdev->valid_links &= ~BIT(link_id);
|
||||
|
||||
rdev_del_intf_link(rdev, wdev, link_id);
|
||||
|
||||
eth_zero_addr(wdev->links[link_id].addr);
|
||||
wdev_unlock(wdev);
|
||||
|
||||
|
@ -1422,4 +1422,30 @@ rdev_set_radar_background(struct cfg80211_registered_device *rdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int
|
||||
rdev_add_intf_link(struct cfg80211_registered_device *rdev,
|
||||
struct wireless_dev *wdev,
|
||||
unsigned int link_id)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
trace_rdev_add_intf_link(&rdev->wiphy, wdev, link_id);
|
||||
if (rdev->ops->add_intf_link)
|
||||
ret = rdev->ops->add_intf_link(&rdev->wiphy, wdev, link_id);
|
||||
trace_rdev_return_int(&rdev->wiphy, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rdev_del_intf_link(struct cfg80211_registered_device *rdev,
|
||||
struct wireless_dev *wdev,
|
||||
unsigned int link_id)
|
||||
{
|
||||
trace_rdev_del_intf_link(&rdev->wiphy, wdev, link_id);
|
||||
if (rdev->ops->add_intf_link)
|
||||
rdev->ops->add_intf_link(&rdev->wiphy, wdev, link_id);
|
||||
trace_rdev_return_void(&rdev->wiphy);
|
||||
}
|
||||
|
||||
#endif /* __CFG80211_RDEV_OPS */
|
||||
|
@ -2064,7 +2064,7 @@ TRACE_EVENT(rdev_set_noack_map,
|
||||
WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->noack_map)
|
||||
);
|
||||
|
||||
TRACE_EVENT(rdev_get_channel,
|
||||
DECLARE_EVENT_CLASS(wiphy_wdev_link_evt,
|
||||
TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
|
||||
unsigned int link_id),
|
||||
TP_ARGS(wiphy, wdev, link_id),
|
||||
@ -2082,6 +2082,12 @@ TRACE_EVENT(rdev_get_channel,
|
||||
WIPHY_PR_ARG, WDEV_PR_ARG, __entry->link_id)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wiphy_wdev_link_evt, rdev_get_channel,
|
||||
TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
|
||||
unsigned int link_id),
|
||||
TP_ARGS(wiphy, wdev, link_id)
|
||||
);
|
||||
|
||||
TRACE_EVENT(rdev_return_chandef,
|
||||
TP_PROTO(struct wiphy *wiphy, int ret,
|
||||
struct cfg80211_chan_def *chandef),
|
||||
@ -2823,6 +2829,18 @@ TRACE_EVENT(rdev_set_radar_background,
|
||||
WIPHY_PR_ARG, CHAN_DEF_PR_ARG)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wiphy_wdev_link_evt, rdev_add_intf_link,
|
||||
TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
|
||||
unsigned int link_id),
|
||||
TP_ARGS(wiphy, wdev, link_id)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(wiphy_wdev_link_evt, rdev_del_intf_link,
|
||||
TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
|
||||
unsigned int link_id),
|
||||
TP_ARGS(wiphy, wdev, link_id)
|
||||
);
|
||||
|
||||
/*************************************************************
|
||||
* cfg80211 exported functions traces *
|
||||
*************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user