LinuxKPI: 80211: improve linuxkpi_ieee80211_get_tid()

Continue what was started in 26a3694833
in iwlwifi and extend out internal implementation of
linuxkpi_ieee80211_get_tid() by an argument as to whether "no-QoS"
answers are acceptable.  For the LinuxKPI ieee80211_get_tid() set
this to false as the Linux derived drivers seem to do extra checks
for the QoS-Data frame before acquiring the tid.
Add KASSERTs to enforce the extra argument.
This allows us to use the net80211 variant in LinuxKPI for other
means explicitly documenting that we do accept a IEEE80211_NONQOS_TID.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
This commit is contained in:
Bjoern A. Zeeb 2022-09-05 20:57:17 +00:00
parent 4b4cc78a76
commit ec190d9150
2 changed files with 15 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2020-2021 The FreeBSD Foundation
* Copyright (c) 2020-2022 The FreeBSD Foundation
* Copyright (c) 2020-2022 Bjoern A. Zeeb
*
* This software was developed by Björn Zeeb under sponsorship from
@ -967,7 +967,7 @@ void linuxkpi_ieee80211_scan_completed(struct ieee80211_hw *,
struct cfg80211_scan_info *);
void linuxkpi_ieee80211_rx(struct ieee80211_hw *, struct sk_buff *,
struct ieee80211_sta *, struct napi_struct *);
uint8_t linuxkpi_ieee80211_get_tid(struct ieee80211_hdr *);
uint8_t linuxkpi_ieee80211_get_tid(struct ieee80211_hdr *, bool);
struct ieee80211_sta *linuxkpi_ieee80211_find_sta(struct ieee80211_vif *,
const u8 *);
struct ieee80211_sta *linuxkpi_ieee80211_find_sta_by_ifaddr(
@ -1452,7 +1452,7 @@ static __inline uint8_t
ieee80211_get_tid(struct ieee80211_hdr *hdr)
{
return (linuxkpi_ieee80211_get_tid(hdr));
return (linuxkpi_ieee80211_get_tid(hdr, false));
}
static __inline struct sk_buff *

View File

@ -4056,12 +4056,22 @@ linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
}
uint8_t
linuxkpi_ieee80211_get_tid(struct ieee80211_hdr *hdr)
linuxkpi_ieee80211_get_tid(struct ieee80211_hdr *hdr, bool nonqos_ok)
{
const struct ieee80211_frame *wh;
uint8_t tid;
/* Linux seems to assume this is a QOS-Data-Frame */
KASSERT(nonqos_ok || ieee80211_is_data_qos(hdr->frame_control),
("%s: hdr %p fc %#06x not qos_data\n", __func__, hdr,
hdr->frame_control));
wh = (const struct ieee80211_frame *)hdr;
return (ieee80211_gettid(wh));
tid = ieee80211_gettid(wh);
KASSERT(nonqos_ok || tid == (tid & IEEE80211_QOS_TID), ("%s: tid %u "
"not expected (%u?)\n", __func__, tid, IEEE80211_NONQOS_TID));
return (tid);
}
struct wiphy *