Skip to content

Commit

Permalink
wifi: mac80211: extend ieee80211_nullfunc_get() for MLO
Browse files Browse the repository at this point in the history
Add a link_id parameter to ieee80211_nullfunc_get() to be
able to obtain a correctly addressed frame.

Change-Id: I0dfa6e8c5e2e4f8715aed9e47c4e4ca739c28430
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
jmberg-intel committed Sep 1, 2022
1 parent 43af0cd commit 60286c2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
5 changes: 4 additions & 1 deletion include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -5298,6 +5298,9 @@ struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw,
* ieee80211_nullfunc_get - retrieve a nullfunc template
* @hw: pointer obtained from ieee80211_alloc_hw().
* @vif: &struct ieee80211_vif pointer from the add_interface callback.
* @link_id: If the vif is an MLD, get a frame with the link addresses
* for the given link ID. For a link_id < 0 you get a frame with
* MLD addresses, however useful that might be.
* @qos_ok: QoS NDP is acceptable to the caller, this should be set
* if at all possible
*
Expand All @@ -5315,7 +5318,7 @@ struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw,
*/
struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
bool qos_ok);
int link_id, bool qos_ok);

/**
* ieee80211_probereq_get - retrieve a Probe Request template
Expand Down
5 changes: 3 additions & 2 deletions net/mac80211/mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1546,8 +1546,9 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local,
struct ieee80211_hdr_3addr *nullfunc;
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;

skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif,
!ieee80211_hw_check(&local->hw, DOESNT_SUPPORT_QOS_NDP));
skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif, -1,
!ieee80211_hw_check(&local->hw,
DOESNT_SUPPORT_QOS_NDP));
if (!skb)
return;

Expand Down
43 changes: 28 additions & 15 deletions net/mac80211/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -5469,33 +5469,39 @@ EXPORT_SYMBOL(ieee80211_pspoll_get);

struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
bool qos_ok)
int link_id, bool qos_ok)
{
struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
struct ieee80211_local *local = sdata->local;
struct ieee80211_link_data *link = NULL;
struct ieee80211_hdr_3addr *nullfunc;
struct ieee80211_sub_if_data *sdata;
struct ieee80211_local *local;
struct sk_buff *skb;
bool qos = false;

if (WARN_ON(vif->type != NL80211_IFTYPE_STATION))
return NULL;

sdata = vif_to_sdata(vif);
local = sdata->local;
skb = dev_alloc_skb(local->hw.extra_tx_headroom +
sizeof(*nullfunc) + 2);
if (!skb)
return NULL;

rcu_read_lock();
if (qos_ok) {
struct sta_info *sta;

rcu_read_lock();
sta = sta_info_get(sdata, sdata->deflink.u.mgd.bssid);
sta = sta_info_get(sdata, vif->cfg.ap_addr);
qos = sta && sta->sta.wme;
rcu_read_unlock();
}

skb = dev_alloc_skb(local->hw.extra_tx_headroom +
sizeof(*nullfunc) + 2);
if (!skb)
return NULL;
if (link_id >= 0) {
link = rcu_dereference(sdata->link[link_id]);
if (WARN_ON_ONCE(!link)) {
rcu_read_unlock();
kfree_skb(skb);
return NULL;
}
}

skb_reserve(skb, local->hw.extra_tx_headroom);

Expand All @@ -5516,9 +5522,16 @@ struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw,
skb_put_data(skb, &qoshdr, sizeof(qoshdr));
}

memcpy(nullfunc->addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN);
memcpy(nullfunc->addr2, vif->addr, ETH_ALEN);
memcpy(nullfunc->addr3, sdata->deflink.u.mgd.bssid, ETH_ALEN);
if (link) {
memcpy(nullfunc->addr1, link->conf->bssid, ETH_ALEN);
memcpy(nullfunc->addr2, link->conf->addr, ETH_ALEN);
memcpy(nullfunc->addr3, link->conf->bssid, ETH_ALEN);
} else {
memcpy(nullfunc->addr1, vif->cfg.ap_addr, ETH_ALEN);
memcpy(nullfunc->addr2, vif->addr, ETH_ALEN);
memcpy(nullfunc->addr3, vif->cfg.ap_addr, ETH_ALEN);
}
rcu_read_unlock();

return skb;
}
Expand Down

0 comments on commit 60286c2

Please sign in to comment.