wifi: introduce generic QoS Management framework
cover wifi: introduce generic QoS Management framework
This series implements the generic QoS Management (QM) control-path framework proposed in:
[DESIGN RFC] wifi: Robust AV streaming Design Proposal for AP [1]
The RFC discusses support for IEEE 802.11 Robust AV Streaming protocols, specifically Stream Classification Service (SCS) and Mirrored Stream Classification Service (MSCS), and proposes a generic userspace-to-driver interface for exchanging QoS Management requests and responses.
The protocol procedures used by this series are specified in 11.25.2 and 11.25.3, IEEE Std 802.11-2024. The SCS Descriptor and MSCS Descriptor elements are specified in 9.4.2.120 and 9.4.2.242, IEEE Std 802.11-2024, respectively. The TCLAS element and TCLAS Processing element are specified in 9.4.2.29 and 9.4.2.31, IEEE Std 802.11-2024. The QoS Characteristics element is specified in 9.4.2.326, IEEE Std 802.11be-2024.
SCS and MSCS both follow a common request/response model where a non-AP STA negotiates traffic classification and QoS treatment with the AP using QoS Management action frames. While the descriptors used by the protocols differ, both share request operations and per-descriptor status reporting. SCS uses TCLAS elements and QoS characteristics, while MSCS uses a TCLAS mask together with its user-priority fields.
Rather than introducing protocol-specific nl80211 commands and driver interfaces, this series adds a generic QoS Management framework that can be reused by current and future Robust AV Streaming protocols.
The framework provides:
* IEEE 802.11 definitions for QoS Management protocols, request types and status codes.
* A new NL80211_CMD_QOS_MGMT command and generic nested attributes capable of representing SCS and MSCS descriptors.
* cfg80211 request and response structures together with a driver callback for QoS Management transactions.
* Parsing, validation and response handling in nl80211. Responses are initialized with the request descriptor IDs and a declined status before the driver callback, so an unhandled descriptor cannot be reported as successful.
* mac80211 forwarding support and RCU-protected per-station state tracking for successful QoS Management transactions.
* map SCS-marked packets to negotiated TIDs and apply MSCS priority limiting during TX queue selection.
The MSCS packet mark retains the original uplink priority and applies the priority limit only during transmit queue selection. This avoids rechecking a previously limited priority against the original bitmap.
SCS descriptors carry either TCLAS elements alone (legacy SCS) or a QoS Characteristics element (IEEE 802.11be SCS). mac80211 handles legacy SCS by mapping packets to the negotiated TID during transmit queue selection. When a QoS Characteristics element is present, mac80211 forwards the full descriptor to the driver via the qos_mgmt callback, allowing the driver to apply hardware-specific scheduling or offload.
This series is complementary to Felix's proposal [2]. It deliberately keeps protocol-specific flow classification out of mac80211.
For SCS, userspace and netfilter can classify flows and carry the resulting metadata through conntrack and skb marks. For MSCS, mac80211 uses the received user priority and the negotiated MSCS bitmap.
The corresponding packet-marking model is implemented by the QSDK hostapd nftables integration [3][4]. It exposes a rule-management interface and installs per-interface netdev egress chains that can match MAC, IP and transport-layer fields and write packet marks. This is an implementation reference for the userspace/netfilter integration; it is not currently part of upstream hostapd. The netdev RFC describes the corresponding packet-path support for using this metadata before transmit queue selection [5].
This model avoids duplicating SCS TCLAS and flow-classification logic in mac80211 while allowing userspace and netfilter to evolve classification policies independently. It also keeps the mac80211 data path small and allows drivers to implement hardware-specific handling or offload where appropriate.
For intra-BSS forwarding, the QoS Management mark may not be preserved if the AP nftables configuration restores skb->mark from conntrack unconditionally and the intra-BSS flow is not tracked. Per-station peer isolation routes STA-to-STA traffic through the full bridge path, ensuring conntrack sees the flow and the QoS mark is intact at transmit queue selection.
[1] https://lore.kernel.org/r/[email protected]/
[2] https://lore.kernel.org/linux-wireless/cover.3af9ba310d9145a9dfd653b5a886feaba98e8884.1788338716.git-series.nbd@nbd.name/
[3] https://git.codelinaro.org/clo/qsdk/oss/src/network/services/hostapd/-/blob/win.wlan_host_opensource.4.0.r39/src/ap/nft.h
[4] https://git.codelinaro.org/clo/qsdk/oss/src/network/services/hostapd/-/blob/win.wlan_host_opensource.4.0.r39/src/ap/nft.c
[5] https://lore.kernel.org/netfilter-devel/[email protected]/
Aishwarya R (7):
wifi: nl80211: add QoS Management UAPI
wifi: cfg80211: add QoS Management data structures
wifi: nl80211: implement QoS Management request parsing and response
wifi: mac80211: forward QoS Management configuration to drivers
wifi: mac80211: track QoS Management station state
wifi: mac80211: map SCS packets to configured TIDs
wifi: mac80211: add MSCS packet classification
include/linux/ieee80211.h | 1 + include/net/cfg80211.h | 220 +++++++++++ include/net/mac80211.h | 7 + include/uapi/linux/nl80211.h | 344 +++++++++++++++++ net/mac80211/cfg.c | 13 + net/mac80211/driver-ops.h | 28 ++ net/mac80211/ieee80211_i.h | 18 + net/mac80211/mlme.c | 165 ++++++++ net/mac80211/rx.c | 29 ++ net/mac80211/sta_info.c | 7 + net/mac80211/sta_info.h | 21 + net/mac80211/trace.h | 24 ++ net/mac80211/wme.c | 47 +++ net/wireless/nl80211.c | 730 +++++++++++++++++++++++++++++++++++ net/wireless/rdev-ops.h | 17 + net/wireless/trace.h | 20 + 16 files changed, 1691 insertions(+)
base-commit: a4190accbf7e05496754004bb701fb3e7d04e57f
Signature · 1 line
2.34.1
RFC PATCH 1/7 wifi: nl80211: add QoS Management UAPI
Add the UAPI definitions and nested netlink policies used by the generic QoS Management (QM) framework.
Introduce protocol identifiers for Stream Classification Service (SCS) and Mirrored Stream Classification Service (MSCS), request operation types, QoS characteristics direction encoding, response status codes, and the NL80211_CMD_QOS_MGMT command.
The NL80211_ATTR_QOS_MGMT payload contains the protocol selector and nested descriptor, SCS TCLAS and QoS attributes, and MSCS-specific attributes. The corresponding nl80211 policies validate the attribute types and ranges before parsing.
The SCS and MSCS procedures are specified in 11.25.2 and 11.25.3, IEEE Std 802.11-2024. The SCS Descriptor and MSCS Descriptor elements are specified in 9.4.2.120 and 9.4.2.242, IEEE Std 802.11-2024, respectively. The TCLAS element and TCLAS Processing element are specified in 9.4.2.29 and 9.4.2.31, IEEE Std 802.11-2024. The QoS Characteristics element is specified in 9.4.2.326, IEEE Std 802.11be-2024.
--- include/uapi/linux/nl80211.h | 344 +++++++++++++++++++++++++++++++++++ net/wireless/nl80211.c | 88 +++++++++ 2 files changed, 432 insertions(+)
include/uapi/linux/nl80211.h +344 -0
@@ -1468,6 +1468,10 @@* and multiple can be nested in %NL80211_ATTR_MLO_LINKS but then the * update isn't atomic if any failures happen. * Only supported with %NL80211_EXT_FEATURE_UPDATE_BEACON. +* @NL80211_CMD_QOS_MGMT: QoS Management configuration for a station. Used +* by userspace to send QoS Management (QM) requests and to receive the +* corresponding status response via %NL80211_ATTR_QOS_MGMT. +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -1750,6 +1754,8 @@ enum nl80211_commands {NL80211_CMD_UPDATE_BEACON , + NL80211_CMD_QOS_MGMT, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -3243,6 +3249,13 @@ enum nl80211_commands {* @NL80211_ATTR_ASSOC_PROTECTED_TWT: Enable protected TWT for the association, * requires protected TWT support (flag attribute) * +* @NL80211_ATTR_QOS_MGMT: Used with %NL80211_CMD_QOS_MGMT to configure +* QoS Management (QM) features for a station. The nested payload is +* described by &enum nl80211_qm_attrs. It contains a nested array of +* &enum nl80211_qm_desc_attrs entries; SCS TCLAS and QoS attributes use +* &enum nl80211_qm_tclas_attrs and &enum nl80211_qm_qos_attrs, +* respectively. +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3850,6 +3863,8 @@ enum nl80211_attrs {NL80211_ATTR_ASSOC_PROTECTED_TWT , +NL80211_ATTR_QOS_MGMT , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -9200,4 +9215,333 @@ enum nl80211_nan_peer_map_attrs {#define NL80211_NAN_SCHED_NOT_AVAIL_SLOT 0xff +#define NL80211_IPADDR_MAX_LEN 16 +#define NL80211_QM_TCLAS_TYPE10_MAX_FILTER_LEN 12 +#define NL80211_QM_TCLAS_TYPE4_FLOW_LABEL_LEN 3 + +/* +* The TCLAS element (reference 9.4.2.29, IEEE Std 802.11-2024) is used by +* SCS for traffic classification. +*/ +/** +* enum nl80211_qm_tclas_type4_attrs - TCLAS classifier type 4 attributes +* +* @NL80211_QM_TCLAS_TYPE4_ATTR_INVALID: Invalid +* @NL80211_QM_TCLAS_TYPE4_ATTR_CLASSIFIER_MASK: Classifier mask (u8), see +* &enum nl80211_qm_tclas_type4_mask +* @NL80211_QM_TCLAS_TYPE4_ATTR_IP_VERSION: IP version, 4 or 6 (u8) +* @NL80211_QM_TCLAS_TYPE4_ATTR_SRC_IP: Source IP address +* @NL80211_QM_TCLAS_TYPE4_ATTR_DST_IP: Destination IP address +* @NL80211_QM_TCLAS_TYPE4_ATTR_SRC_PORT: Source port (u16) +* @NL80211_QM_TCLAS_TYPE4_ATTR_DST_PORT: Destination port (u16) +* @NL80211_QM_TCLAS_TYPE4_ATTR_DSCP: DSCP value, 0-63 (u8) +* @NL80211_QM_TCLAS_TYPE4_ATTR_PROTOCOL: IP protocol number, IPv4 only (u8) +* @NL80211_QM_TCLAS_TYPE4_ATTR_NEXT_HEADER: Next header, IPv6 only (u8) +* @NL80211_QM_TCLAS_TYPE4_ATTR_FLOW_LABEL: Flow label, IPv6 only +* @__NL80211_QM_TCLAS_TYPE4_ATTR_AFTER_LAST: internal use +* @NL80211_QM_TCLAS_TYPE4_ATTR_MAX: highest type 4 attribute number currently +* defined +*/ +enum nl80211_qm_tclas_type4_attrs { +NL80211_QM_TCLAS_TYPE4_ATTR_INVALID , +NL80211_QM_TCLAS_TYPE4_ATTR_CLASSIFIER_MASK , +NL80211_QM_TCLAS_TYPE4_ATTR_IP_VERSION , +NL80211_QM_TCLAS_TYPE4_ATTR_SRC_IP , +NL80211_QM_TCLAS_TYPE4_ATTR_DST_IP , +NL80211_QM_TCLAS_TYPE4_ATTR_SRC_PORT , +NL80211_QM_TCLAS_TYPE4_ATTR_DST_PORT , +NL80211_QM_TCLAS_TYPE4_ATTR_DSCP , +NL80211_QM_TCLAS_TYPE4_ATTR_PROTOCOL , +NL80211_QM_TCLAS_TYPE4_ATTR_NEXT_HEADER , +NL80211_QM_TCLAS_TYPE4_ATTR_FLOW_LABEL , + +/* keep last */ + __NL80211_QM_TCLAS_TYPE4_ATTR_AFTER_LAST, +NL80211_QM_TCLAS_TYPE4_ATTR_MAX = + __NL80211_QM_TCLAS_TYPE4_ATTR_AFTER_LAST -1 +}; + +/** +* enum nl80211_qm_tclas_type10_attrs - TCLAS classifier type 10 attributes +* +* @NL80211_QM_TCLAS_TYPE10_ATTR_INVALID: Invalid +* @NL80211_QM_TCLAS_TYPE10_ATTR_PROT_INSTANCE: Protocol instance (u8) +* @NL80211_QM_TCLAS_TYPE10_ATTR_PROT_NUMBER: Protocol number (u8) +* @NL80211_QM_TCLAS_TYPE10_ATTR_FILTER_VALUE: Filter value bytes +* @NL80211_QM_TCLAS_TYPE10_ATTR_FILTER_MASK: Filter mask bytes +* @__NL80211_QM_TCLAS_TYPE10_ATTR_AFTER_LAST: internal use +* @NL80211_QM_TCLAS_TYPE10_ATTR_MAX: highest type 10 attribute number currently +* defined +*/ +enum nl80211_qm_tclas_type10_attrs { +NL80211_QM_TCLAS_TYPE10_ATTR_INVALID , +NL80211_QM_TCLAS_TYPE10_ATTR_PROT_INSTANCE , +NL80211_QM_TCLAS_TYPE10_ATTR_PROT_NUMBER , +NL80211_QM_TCLAS_TYPE10_ATTR_FILTER_VALUE , +NL80211_QM_TCLAS_TYPE10_ATTR_FILTER_MASK , + +/* keep last */ + __NL80211_QM_TCLAS_TYPE10_ATTR_AFTER_LAST, +NL80211_QM_TCLAS_TYPE10_ATTR_MAX = + __NL80211_QM_TCLAS_TYPE10_ATTR_AFTER_LAST -1 +}; + +/** +* enum nl80211_qm_tclas_attrs - TCLAS element attributes +* +* @NL80211_QM_TCLAS_ATTR_INVALID: Invalid +* @NL80211_QM_TCLAS_ATTR_USER_PRIORITY: User priority, 0-7 (u8) +* @NL80211_QM_TCLAS_ATTR_CLASSIFIER_TYPE: Classifier type, 4 or 10 (u8) +* @NL80211_QM_TCLAS_ATTR_TYPE4_PARAMS: Nested type 4 classifier params, see +* &enum nl80211_qm_tclas_type4_attrs +* @NL80211_QM_TCLAS_ATTR_TYPE10_PARAMS: Nested type 10 classifier params, see +* &enum nl80211_qm_tclas_type10_attrs +* @__NL80211_QM_TCLAS_ATTR_AFTER_LAST: internal use +* @NL80211_QM_TCLAS_ATTR_MAX: highest TCLAS attribute number currently defined +*/ +enum nl80211_qm_tclas_attrs { +NL80211_QM_TCLAS_ATTR_INVALID , +NL80211_QM_TCLAS_ATTR_USER_PRIORITY , +NL80211_QM_TCLAS_ATTR_CLASSIFIER_TYPE , +NL80211_QM_TCLAS_ATTR_TYPE4_PARAMS , +NL80211_QM_TCLAS_ATTR_TYPE10_PARAMS , + +/* keep last */ + __NL80211_QM_TCLAS_ATTR_AFTER_LAST, +NL80211_QM_TCLAS_ATTR_MAX = __NL80211_QM_TCLAS_ATTR_AFTER_LAST -1 +}; + +/** +* enum nl80211_qm_tclas_classifier_type - TCLAS classifier type values sent +* in %NL80211_QM_TCLAS_ATTR_CLASSIFIER_TYPE +* @NL80211_QM_TCLAS_CLASSIFIER_TYPE4: Classifier type 4, 5-tuple based; +* reference 9.4.2.29, IEEE Std 802.11-2024. +* @NL80211_QM_TCLAS_CLASSIFIER_TYPE10: Classifier type 10, filter based; +* reference 9.4.2.29, IEEE Std 802.11-2024. +* +* The SCS interface currently supports only classifier types 4 and 10. +*/ +enum nl80211_qm_tclas_classifier_type { +NL80211_QM_TCLAS_CLASSIFIER_TYPE4 =4 , +NL80211_QM_TCLAS_CLASSIFIER_TYPE10 =10 , +}; + +/** +* enum nl80211_qm_tclas_type4_mask - classifier mask bits for TCLAS type 4 +* @NL80211_QM_TCLAS_TYPE4_MASK_VERSION: IP version field +* @NL80211_QM_TCLAS_TYPE4_MASK_SRC_IP: source IP address +* @NL80211_QM_TCLAS_TYPE4_MASK_DST_IP: destination IP address +* @NL80211_QM_TCLAS_TYPE4_MASK_SRC_PORT: source port +* @NL80211_QM_TCLAS_TYPE4_MASK_DST_PORT: destination port +* @NL80211_QM_TCLAS_TYPE4_MASK_DSCP: DSCP field +* @NL80211_QM_TCLAS_TYPE4_MASK_PROTOCOL: protocol / next-header field +* @NL80211_QM_TCLAS_TYPE4_MASK_FLOW_LABEL: IPv6 flow label +*/ +enum nl80211_qm_tclas_type4_mask { +NL80211_QM_TCLAS_TYPE4_MASK_VERSION =1 <<0 , +NL80211_QM_TCLAS_TYPE4_MASK_SRC_IP =1 <<1 , +NL80211_QM_TCLAS_TYPE4_MASK_DST_IP =1 <<2 , +NL80211_QM_TCLAS_TYPE4_MASK_SRC_PORT =1 <<3 , +NL80211_QM_TCLAS_TYPE4_MASK_DST_PORT =1 <<4 , +NL80211_QM_TCLAS_TYPE4_MASK_DSCP =1 <<5 , +NL80211_QM_TCLAS_TYPE4_MASK_PROTOCOL =1 <<6 , +NL80211_QM_TCLAS_TYPE4_MASK_FLOW_LABEL =1 <<7 , +}; + +/** +* enum nl80211_qm_tclas_processing - TCLAS processing rules +* +* Processing field values are defined in 9.4.2.31, IEEE Std 802.11-2024. +* +* @NL80211_QM_TCLAS_PROCESSING_MATCH_ALL: all TCLAS elements must match +* @NL80211_QM_TCLAS_PROCESSING_MATCH_ANY: any TCLAS element may match +* @NL80211_QM_TCLAS_PROCESSING_MATCH_ALL_EXCEPT_FIRST: all except the first +* must match +*/ +enum nl80211_qm_tclas_processing { +NL80211_QM_TCLAS_PROCESSING_MATCH_ALL =0 , +NL80211_QM_TCLAS_PROCESSING_MATCH_ANY =1 , +NL80211_QM_TCLAS_PROCESSING_MATCH_ALL_EXCEPT_FIRST =2 , +}; + +/** +* enum nl80211_qm_qos_attrs - QoS Management QoS attributes +* +* The QoS Characteristics element is specified in 9.4.2.326, +* IEEE Std 802.11be-2024. +* +* @NL80211_QM_QOS_ATTR_INVALID: Invalid +* @NL80211_QM_QOS_ATTR_CONTROL_INFO: QoS characteristics control info (u32) +* @NL80211_QM_QOS_ATTR_MIN_SVC_INTERVAL: Minimum service interval, us (u32) +* @NL80211_QM_QOS_ATTR_MAX_SVC_INTERVAL: Maximum service interval, us (u32) +* @NL80211_QM_QOS_ATTR_MIN_DATA_RATE: Minimum data rate, kbps (u32) +* @NL80211_QM_QOS_ATTR_DELAY_BOUND: Delay bound, us (u32) +* @NL80211_QM_QOS_ATTR_MAX_MSDU_SIZE: Maximum MSDU size, bytes (u16) +* @NL80211_QM_QOS_ATTR_SVC_START_TIME: Service start time, us (u32) +* @NL80211_QM_QOS_ATTR_SVC_START_TIME_LINK_ID: Link ID for service start +* time (u8) +* @NL80211_QM_QOS_ATTR_MEAN_DATA_RATE: Mean data rate, kbps (u32) +* @NL80211_QM_QOS_ATTR_BURST_SIZE: Burst size, bytes (u32) +* @NL80211_QM_QOS_ATTR_MSDU_LIFETIME: MSDU lifetime, ms (u16) +* @NL80211_QM_QOS_ATTR_MSDU_DELIVERY_INFO: MSDU delivery ratio and count +* exponent (u8) +* @NL80211_QM_QOS_ATTR_MEDIUM_TIME: Medium time, 32 us units (u16) +* @__NL80211_QM_QOS_ATTR_AFTER_LAST: internal use +* @NL80211_QM_QOS_ATTR_MAX: highest QoS attribute number currently defined +*/ +enum nl80211_qm_qos_attrs { +NL80211_QM_QOS_ATTR_INVALID , +NL80211_QM_QOS_ATTR_CONTROL_INFO , +NL80211_QM_QOS_ATTR_MIN_SVC_INTERVAL , +NL80211_QM_QOS_ATTR_MAX_SVC_INTERVAL , +NL80211_QM_QOS_ATTR_MIN_DATA_RATE , +NL80211_QM_QOS_ATTR_DELAY_BOUND , +NL80211_QM_QOS_ATTR_MAX_MSDU_SIZE , +NL80211_QM_QOS_ATTR_SVC_START_TIME , +NL80211_QM_QOS_ATTR_SVC_START_TIME_LINK_ID , +NL80211_QM_QOS_ATTR_MEAN_DATA_RATE , +NL80211_QM_QOS_ATTR_BURST_SIZE , +NL80211_QM_QOS_ATTR_MSDU_LIFETIME , +NL80211_QM_QOS_ATTR_MSDU_DELIVERY_INFO , +NL80211_QM_QOS_ATTR_MEDIUM_TIME , + +/* keep last */ + __NL80211_QM_QOS_ATTR_AFTER_LAST, +NL80211_QM_QOS_ATTR_MAX = __NL80211_QM_QOS_ATTR_AFTER_LAST -1 +}; + +/** +* enum nl80211_qm_desc_attrs - QoS Management descriptor attributes +* +* @NL80211_QM_DESC_ATTR_INVALID: Invalid +* @NL80211_QM_DESC_ATTR_QM_ID: Userspace-assigned identifier (u8) used +* to correlate a request descriptor with its response descriptor +* @NL80211_QM_DESC_ATTR_REQUEST_TYPE: Request type, see +* &enum nl80211_qm_req_type (u8) +* @NL80211_QM_DESC_ATTR_PRIORITY: SCS descriptor priority (u8) +* @NL80211_QM_DESC_ATTR_TCLAS_ELEMENTS: Nested array of SCS TCLAS elements, +* see &enum nl80211_qm_tclas_attrs +* @NL80211_QM_DESC_ATTR_TCLAS_PROCESSING: SCS TCLAS processing rule (u8), +* see &enum nl80211_qm_tclas_processing +* @NL80211_QM_DESC_ATTR_QOS_ATTRIBUTES: Nested SCS QoS attributes, see +* &enum nl80211_qm_qos_attrs +* @NL80211_QM_DESC_ATTR_STATUS: Response status for this descriptor (u8), +* see &enum nl80211_qm_status +* @NL80211_QM_DESC_ATTR_USER_PRIORITY_BITMAP: MSCS user priority bitmap of +* TID values sent by the non-AP STA (u8) +* @NL80211_QM_DESC_ATTR_USER_PRIORITY_LIMIT: MSCS user priority limit sent +* by the non-AP STA (u8) +* @NL80211_QM_DESC_ATTR_TCLAS_MASK: MSCS traffic classifier mask with a +* bitmap of parameters to match in an uplink flow for downlink +* prioritization (u8) +* @__NL80211_QM_DESC_ATTR_AFTER_LAST: internal use +* @NL80211_QM_DESC_ATTR_MAX: highest QoS Management descriptor attribute +* number currently defined +*/ +enum nl80211_qm_desc_attrs { +NL80211_QM_DESC_ATTR_INVALID , +NL80211_QM_DESC_ATTR_QM_ID , +NL80211_QM_DESC_ATTR_REQUEST_TYPE , +NL80211_QM_DESC_ATTR_PRIORITY , +NL80211_QM_DESC_ATTR_TCLAS_ELEMENTS , +NL80211_QM_DESC_ATTR_TCLAS_PROCESSING , +NL80211_QM_DESC_ATTR_QOS_ATTRIBUTES , +NL80211_QM_DESC_ATTR_STATUS , +NL80211_QM_DESC_ATTR_USER_PRIORITY_BITMAP , +NL80211_QM_DESC_ATTR_USER_PRIORITY_LIMIT , +NL80211_QM_DESC_ATTR_TCLAS_MASK , + +/* keep last */ + __NL80211_QM_DESC_ATTR_AFTER_LAST, +NL80211_QM_DESC_ATTR_MAX = __NL80211_QM_DESC_ATTR_AFTER_LAST -1 +}; + +/** +* enum nl80211_qm_attrs - QoS Management attributes +* +* @NL80211_QM_ATTR_INVALID: Invalid +* @NL80211_QM_ATTR_MAC_ADDR: Target station MAC address (6 bytes) +* @NL80211_QM_ATTR_QM_TYPE: QoS Management protocol type, see +* &enum nl80211_qm_type (u8) +* @NL80211_QM_ATTR_DESCRIPTOR_PARAMS: Nested array of QM descriptors, see +* &enum nl80211_qm_desc_attrs +* @__NL80211_QM_ATTR_AFTER_LAST: internal use +* @NL80211_QM_ATTR_MAX: highest QoS Management attribute number currently +* defined +*/ +enum nl80211_qm_attrs { +NL80211_QM_ATTR_INVALID , +NL80211_QM_ATTR_MAC_ADDR , +NL80211_QM_ATTR_QM_TYPE , +NL80211_QM_ATTR_DESCRIPTOR_PARAMS , + +/* keep last */ + __NL80211_QM_ATTR_AFTER_LAST, +NL80211_QM_ATTR_MAX = __NL80211_QM_ATTR_AFTER_LAST -1 +}; + +/** +* enum nl80211_qm_type - QoS Management protocol types +* @NL80211_QM_TYPE_SCS: Stream Classification Service (SCS) protocol, +* reference 11.25.2, IEEE Std 802.11-2024. +* @NL80211_QM_TYPE_MSCS: Mirrored Stream Classification Service (MSCS) +* protocol, reference 11.25.3, IEEE Std 802.11-2024. +* @NL80211_QM_TYPE_MAX: Maximum value for QoS Management protocol types +* +* Enumerates the QoS Management protocols supported through the generic +* QoS Management (QM) request/response framework. +* +*/ +enum nl80211_qm_type { +NL80211_QM_TYPE_SCS , +NL80211_QM_TYPE_MSCS , +/* Future QM protocols to be added here */ +NL80211_QM_TYPE_MAX , +}; + +/** +* enum nl80211_qm_direction - QoS Management descriptor +* traffic direction +* @NL80211_QM_DIRECTION_UPLINK: Traffic direction is uplink, from the +* non-AP STA to the AP. +* @NL80211_QM_DIRECTION_DOWNLINK: Traffic direction is downlink, from +* the AP to the non-AP STA. +* @NL80211_QM_DIRECTION_DIRECT: Direct link traffic between STAs (P2P). +* +* Encodes the QoS characteristics element direction subfield, denoting +* which traffic direction a set of QoS attributes applies to. The QoS +* Characteristics element is specified in 9.4.2.326, IEEE Std 802.11be-2024. +*/ +enum nl80211_qm_direction { +NL80211_QM_DIRECTION_UPLINK =0 , +NL80211_QM_DIRECTION_DOWNLINK =1 , +NL80211_QM_DIRECTION_DIRECT =2 , +}; + +/** +* enum nl80211_qm_req_type - QoS Management request types +* @NL80211_QM_ADD_REQ: Add a new QoS Management configuration +* @NL80211_QM_REMOVE_REQ: Remove an existing QoS Management configuration +* @NL80211_QM_CHANGE_REQ: Modify an existing QoS Management configuration +* +* Identifies the operation requested in a QoS Management transaction. +* Reference 11.25.2 and 11.25.3, IEEE Std 802.11-2024, for the operation +* values. +*/ +enum nl80211_qm_req_type { +NL80211_QM_ADD_REQ , +NL80211_QM_REMOVE_REQ , +NL80211_QM_CHANGE_REQ , +}; + +/** +* enum nl80211_qm_status - QoS Management response status codes +* @NL80211_QM_STATUS_SUCCESS: request accepted +* @NL80211_QM_STATUS_DECLINED: request declined +*/ +enum nl80211_qm_status { +NL80211_QM_STATUS_SUCCESS =0 , +NL80211_QM_STATUS_DECLINED =1 , +}; +#endif /* __LINUX_NL80211_H */
net/wireless/nl80211.c +88 -0
100 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 2/7 wifi: cfg80211: add QoS Management data structures
In reply to Aishwarya RIntroduce cfg80211 data structures to support QoS Management (QM) requests from userspace and the corresponding driver responses.
A QM request contains the peer address, protocol type and a dynamically sized descriptor list. Each descriptor carries the requested operation and SCS-specific priority, TCLAS type 4 or type 10 classification elements, and QoS characteristics, and protocol-specific fields for SCS or MSCS.
Add the set_qos_mgmt_cfg() cfg80211_ops callback to deliver a parsed QM request to the driver. The driver returns the processing result through a cfg80211_qm_resp_data container populated with one response descriptor per request descriptor. Each response descriptor carries the corresponding qm_id together with an IEEE 802.11 QM status code indicating whether the request was accepted or declined.
--- include/net/cfg80211.h | 220 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+)
include/net/cfg80211.h +220 -0
@@ -4860,6 +4860,216 @@ struct cfg80211_update_owe_info {u8 peer_mld_addr[ETH_ALEN ]__aligned(2) ; }; +/* QoS Management IP address lengths */ +#define QM_IPV4_LEN 4 +#define QM_IPV6_LEN 16 + +/** +* enum cfg80211_qm_ip_version - IP protocol version identifiers used in +* QoS Management traffic classification +* @QM_IP_VERSION_4: Internet Protocol version 4 (IPv4) +* @QM_IP_VERSION_6: Internet Protocol version 6 (IPv6) +*/ +enum cfg80211_qm_ip_version { +QM_IP_VERSION_4 =4 , +QM_IP_VERSION_6 =6 , +}; + +/** +* struct cfg80211_qm_tclas4_params - TCLAS classifier type 4 parameters +* @classifier_mask: bitmask indicating which fields are used for +* classification; the version bit is mandatory and the remaining bits +* identify fields used for classification, as defined by +* &enum nl80211_qm_tclas_type4_mask +* @ip_ver: IP version of @src_ip / @dst_ip +* @src_ip: source IP address (IPv4 or IPv6) +* @dst_ip: destination IP address (IPv4 or IPv6) +* @src_port: source port number +* @dst_port: destination port number +* @dscp: Differentiated Services Code Point +* @protocol: IP protocol number, valid for IPv4 only +* @next_header: next header field, valid for IPv6 only +* @flow_label: flow label, valid for IPv6 only +*/ +struct cfg80211_qm_tclas4_params { +u8 classifier_mask; +enum cfg80211_qm_ip_version ip_ver; +union { +u8 ipv4[QM_IPV4_LEN ]; +u8 ipv6[QM_IPV6_LEN ]; + } src_ip; +union { +u8 ipv4[QM_IPV4_LEN ]; +u8 ipv6[QM_IPV6_LEN ]; + } dst_ip; +u16 src_port; +u16 dst_port; +u8 dscp; +u8 protocol; +u8 next_header; +u8 flow_label[NL80211_QM_TCLAS_TYPE4_FLOW_LABEL_LEN ]; +}; + +/** +* struct cfg80211_qm_tclas10_params - TCLAS classifier type 10 parameters +* @protocol_instance: protocol instance identifier +* @protocol_number: protocol number +* @filter_value: filter value bytes +* @filter_mask: filter mask bytes +* @filter_len: length of @filter_value / @filter_mask +*/ +struct cfg80211_qm_tclas10_params { +u8 protocol_instance; +u8 protocol_number; +u8 filter_value[NL80211_QM_TCLAS_TYPE10_MAX_FILTER_LEN ]; +u8 filter_mask[NL80211_QM_TCLAS_TYPE10_MAX_FILTER_LEN ]; +u8 filter_len; +}; + +/** +* struct cfg80211_qm_tclas_elements - a single TCLAS element +* @up: user priority +* @classifier_type: classifier type, see +* &enum nl80211_qm_tclas_classifier_type +* @tclas_elem: classifier-specific parameters +*/ +struct cfg80211_qm_tclas_elements { +u8 up; +enum nl80211_qm_tclas_classifier_type classifier_type; +union { +struct cfg80211_qm_tclas4_params type4_params; +struct cfg80211_qm_tclas10_params type10_params; + } tclas_elem; +}; + +/** +* struct cfg80211_qm_qos_attributes - QoS attributes of a QoS Management +* request +* @direction: traffic direction, see &enum nl80211_qm_direction +* @tid: traffic identifier +* @up: user priority +* @bitmap: TID/UP bitmap +* @link_id: link identifier +* @min_service_interval: minimum service interval, in microseconds +* @max_service_interval: maximum service interval, in microseconds +* @min_data_rate: minimum data rate, in kbps +* @delay_bound: delay bound, in microseconds +* @max_msdu_size: maximum MSDU size, in bytes +* @service_start_time: service start time, in microseconds +* @service_start_time_link_id: link ID for @service_start_time +* @mean_data_rate: mean data rate, in kbps +* @burst_size: burst size, in bytes +* @msdu_lifetime: MSDU lifetime, in milliseconds +* @msdu_delivery_ratio: MSDU delivery ratio +* @msdu_count_exponent: MSDU count exponent +* @medium_time: medium time, in units of 32 microseconds +*/ +struct cfg80211_qm_qos_attributes { +enum nl80211_qm_direction direction; +u8 tid; +u8 up; +u16 bitmap; +u8 link_id; +u32 min_service_interval; +u32 max_service_interval; +u32 min_data_rate; +u32 delay_bound; +u16 max_msdu_size; +u32 service_start_time; +u8 service_start_time_link_id; +u32 mean_data_rate; +u32 burst_size; +u16 msdu_lifetime; +u8 msdu_delivery_ratio; +u8 msdu_count_exponent; +u16 medium_time; +}; + +/** +* struct cfg80211_qm_req_desc_data - a single QoS Management request +* descriptor +* @qm_id: identifier for this descriptor within the request +* @request_type: request type, see &enum nl80211_qm_req_type +* @priority: SCS descriptor priority +* @num_tclas_elements: number of entries in @tclas +* @tclas: SCS TCLAS elements used for traffic classification +* @tclas_processing: SCS TCLAS processing rule, see +* &enum nl80211_qm_tclas_processing +* @is_qos_present: whether @qos_attr is populated +* @qos_attr: SCS QoS attributes associated with this descriptor +* @user_priority_bitmap: user priority bitmap of TID values sent by the +* non-AP STA in an MSCS request +* @user_priority_limit: user priority limit sent by the non-AP STA in an +* MSCS request +* @tclas_mask: traffic classifier mask with a bitmap of parameters to +* match in an uplink flow for downlink prioritization +*/ +struct cfg80211_qm_req_desc_data { +u8 qm_id; +enum nl80211_qm_req_type request_type; +u8 priority; +unsigned int num_tclas_elements; +struct cfg80211_qm_tclas_elements *tclas; +enum nl80211_qm_tclas_processing tclas_processing; +bool is_qos_present; +struct cfg80211_qm_qos_attributes qos_attr; +u8 user_priority_bitmap; +u8 user_priority_limit; +u8 tclas_mask; +}; + +/** +* struct cfg80211_qm_req_data - a complete QoS Management request for a +* peer +* @peer_mac: MAC address of the peer +* @qm_type: QoS Management protocol, see &enum nl80211_qm_type +* @num_qm_desc: number of entries in @qm_req_desc +* @qm_req_desc: QoS Management request descriptors +* +* This is the parsed representation passed to the driver by the +* &struct cfg80211_ops.set_qos_mgmt_cfg callback. The descriptor and TCLAS +* arrays are owned by cfg80211 and are valid only for the duration of the +* callback. The driver must not retain these pointers after the callback +* returns. +*/ +struct cfg80211_qm_req_data { +u8 peer_mac[ETH_ALEN ]; +enum nl80211_qm_type qm_type; +unsigned int num_qm_desc; +struct cfg80211_qm_req_desc_data *qm_req_desc; +}; + +/** +* struct cfg80211_qm_resp_desc_data - result of processing a single QoS +* Management request descriptor +* @qm_id: identifier matching the corresponding request descriptor +* @status: response status, see &enum nl80211_qm_status +*/ +struct cfg80211_qm_resp_desc_data { +u8 qm_id; +enum nl80211_qm_status status; +}; + +/** +* struct cfg80211_qm_resp_data - a complete QoS Management response +* @qm_resp_desc: response descriptors corresponding to the request +* +* cfg80211 allocates and initializes one response descriptor for each +* request descriptor with the corresponding +* &struct cfg80211_qm_req_desc_data.qm_id and a declined status. +* The driver updates the status for each descriptor it processes. The +* response array is parallel to the request descriptor array: entry @i +* corresponds to request descriptor @i, and the driver must update entries +* in place without reordering them. The initialized @qm_id values must be +* left unchanged. The response array is valid only for the duration of the +* callback and must not be retained by the driver. +* cfg80211/nl80211 supplies the peer address and protocol type from the +* request when it builds the reply. +*/ +struct cfg80211_qm_resp_data { +struct cfg80211_qm_resp_desc_data *qm_resp_desc; +}; +/** * struct mgmt_frame_regs - management frame registrations data * @global_stypes: bitmap of management frame subtypes registered
@@ -5332,6 +5542,13 @@ struct mgmt_frame_regs {* * @start_pd: Start the PD interface. * @stop_pd: Stop the PD interface. +* +* @set_qos_mgmt_cfg: Configure QoS Management (QM) parameters such as +* traffic classification (TCLAS) and QoS attributes for a station. The +* request has already been parsed from the nested nl80211 attributes. +* The driver or firmware applies the protocol-specific configuration and +* populates the response structure with a status for each descriptor. +* This callback provides the control-path interface for the driver. */ struct cfg80211_ops {int (*suspend)(struct wiphy *wiphy,struct cfg80211_wowlan *wow);
@@ -5730,6 +5947,9 @@ struct cfg80211_ops { bool val);int (*start_pd)(struct wiphy *wiphy,struct wireless_dev *wdev);void (*stop_pd)(struct wiphy *wiphy,struct wireless_dev *wdev); +int (*set_qos_mgmt_cfg)(struct wiphy *wiphy,struct net_device *dev, +struct cfg80211_qm_req_data *qm_req, +struct cfg80211_qm_resp_data *qm_resp); };/*
Signature · 1 line
2.34.1
RFC PATCH 3/7 wifi: nl80211: implement QoS Management request parsing and response
In reply to Aishwarya RAdd support for NL80211_CMD_QOS_MGMT to allow userspace to submit QoS Management requests through nl80211.
Parse QoS Management request descriptors and forward them to drivers through cfg80211. Descriptor attributes are parsed according to the requested operation and QoS Management protocol. Drivers process the request through the new set_qos_mgmt_cfg() operation and return a status for each descriptor.
Send a QoS Management reply containing the request identifier and processing status for each descriptor, allowing userspace to correlate responses with submitted requests.
--- net/wireless/nl80211.c | 642 ++++++++++++++++++++++++++++++++++++++++ net/wireless/rdev-ops.h | 17 ++ net/wireless/trace.h | 20 ++ 3 files changed, 679 insertions(+)
net/wireless/nl80211.c +642 -0
@@ -20547,6 +20547,642 @@ static const struct genl_ops nl80211_ops[] = { }, }; +static int +nl80211_parse_qm_tclas4_elem (struct nlattr *tb_tclas_entry[], +struct cfg80211_qm_tclas4_params *type4_params) +{ +struct nlattr *tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_MAX +1 ]; +struct nlattr *attr; +u8 version; + +if (nla_parse_nested (tb_tclas_type4,NL80211_QM_TCLAS_TYPE4_ATTR_MAX , + tb_tclas_entry[NL80211_QM_TCLAS_ATTR_TYPE4_PARAMS ], + nl80211_qm_tclas_type4_policy,NULL )) +return -EINVAL ; + +if (!tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_CLASSIFIER_MASK ] || + !tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_IP_VERSION ] || + !tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_SRC_IP ] || + !tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_DST_IP ] || + !tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_SRC_PORT ] || + !tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_DST_PORT ] || + !tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_DSCP ]) +return -EINVAL ; + + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_CLASSIFIER_MASK ]; + type4_params->classifier_mask =nla_get_u8 (attr); +if (!(type4_params->classifier_mask & +NL80211_QM_TCLAS_TYPE4_MASK_VERSION )) +return -EINVAL ; + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_IP_VERSION ]; + type4_params->ip_ver =nla_get_u8 (attr); + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_SRC_PORT ]; + type4_params->src_port =nla_get_u16 (attr); + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_DST_PORT ]; + type4_params->dst_port =nla_get_u16 (attr); + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_DSCP ]; + type4_params->dscp =nla_get_u8 (attr); + + version = type4_params->ip_ver; +if (version ==QM_IP_VERSION_4 ) { +if (!tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_PROTOCOL ]) +return -EINVAL ; + + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_SRC_IP ]; +if (nla_len (attr) !=QM_IPV4_LEN ) +return -EINVAL ; + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_DST_IP ]; +if (nla_len (attr) !=QM_IPV4_LEN ) +return -EINVAL ; + + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_PROTOCOL ]; + type4_params->protocol =nla_get_u8 (attr); + +nla_memcpy (type4_params->src_ip.ipv4, + tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_SRC_IP ], +QM_IPV4_LEN ); +nla_memcpy (type4_params->dst_ip.ipv4, + tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_DST_IP ], +QM_IPV4_LEN ); + }else if (version ==QM_IP_VERSION_6 ) { +if (!tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_NEXT_HEADER ] || + !tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_FLOW_LABEL ]) +return -EINVAL ; + + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_SRC_IP ]; +if (nla_len (attr) !=QM_IPV6_LEN ) +return -EINVAL ; + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_DST_IP ]; +if (nla_len (attr) !=QM_IPV6_LEN ) +return -EINVAL ; + +nla_memcpy (type4_params->src_ip.ipv6, + tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_SRC_IP ], +QM_IPV6_LEN ); +nla_memcpy (type4_params->dst_ip.ipv6, + tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_DST_IP ], +QM_IPV6_LEN ); + + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_NEXT_HEADER ]; + type4_params->next_header =nla_get_u8 (attr); + + attr = tb_tclas_type4[NL80211_QM_TCLAS_TYPE4_ATTR_FLOW_LABEL ]; +nla_memcpy (type4_params->flow_label, + attr, +NL80211_QM_TCLAS_TYPE4_FLOW_LABEL_LEN ); + }else { +return -EINVAL ; + } + +return 0 ; +} + +static int +nl80211_parse_qm_tclas10_elem (struct nlattr *tb_tclas_entry[], +struct cfg80211_qm_tclas10_params *type10_params) +{ +struct nlattr *tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_MAX +1 ]; +struct nlattr *attr; +u8 filter_value_len, filter_mask_len; + + attr = tb_tclas_entry[NL80211_QM_TCLAS_ATTR_TYPE10_PARAMS ]; +if (nla_parse_nested (tb_tclas_type10,NL80211_QM_TCLAS_TYPE10_ATTR_MAX , + attr, + nl80211_qm_tclas_type10_policy,NULL )) +return -EINVAL ; + +if (!tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_PROT_INSTANCE ] || + !tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_PROT_NUMBER ] || + !tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_FILTER_VALUE ] || + !tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_FILTER_MASK ]) +return -EINVAL ; + + attr = tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_PROT_INSTANCE ]; + type10_params->protocol_instance =nla_get_u8 (attr); + attr = tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_PROT_NUMBER ]; + type10_params->protocol_number =nla_get_u8 (attr); + + attr = tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_FILTER_VALUE ]; + filter_value_len =nla_len (attr); + attr = tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_FILTER_MASK ]; + filter_mask_len =nla_len (attr); + +if (filter_value_len != filter_mask_len || + filter_value_len >NL80211_QM_TCLAS_TYPE10_MAX_FILTER_LEN ) +return -EINVAL ; + + type10_params->filter_len = filter_value_len; +nla_memcpy (type10_params->filter_value, + tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_FILTER_VALUE ], + type10_params->filter_len); +nla_memcpy (type10_params->filter_mask, + tb_tclas_type10[NL80211_QM_TCLAS_TYPE10_ATTR_FILTER_MASK ], + type10_params->filter_len); + +return 0 ; +} + +static int +nl80211_parse_qm_tclas_elem (struct nlattr *tb_tclas, +struct cfg80211_qm_tclas_elements *tclas) +{ +struct nlattr *tb_tclas_entry[NL80211_QM_TCLAS_ATTR_MAX +1 ]; +struct cfg80211_qm_tclas4_params *type4_params; +struct cfg80211_qm_tclas10_params *type10_params; +struct nlattr *attr; +u8 classifier_type; +int ret; + +if (nla_parse_nested (tb_tclas_entry,NL80211_QM_TCLAS_ATTR_MAX , + tb_tclas, nl80211_qm_tclas_policy,NULL )) +return -EINVAL ; + +if (!tb_tclas_entry[NL80211_QM_TCLAS_ATTR_USER_PRIORITY ] || + !tb_tclas_entry[NL80211_QM_TCLAS_ATTR_CLASSIFIER_TYPE ]) +return -EINVAL ; + + tclas->up = +nla_get_u8 (tb_tclas_entry[NL80211_QM_TCLAS_ATTR_USER_PRIORITY ]); + attr = tb_tclas_entry[NL80211_QM_TCLAS_ATTR_CLASSIFIER_TYPE ]; + tclas->classifier_type =nla_get_u8 (attr); + classifier_type = tclas->classifier_type; + type4_params = &tclas->tclas_elem.type4_params; + type10_params = &tclas->tclas_elem.type10_params; + +switch (classifier_type) { +case NL80211_QM_TCLAS_CLASSIFIER_TYPE4 : +if (!tb_tclas_entry[NL80211_QM_TCLAS_ATTR_TYPE4_PARAMS ]) +return -EINVAL ; + + ret =nl80211_parse_qm_tclas4_elem (tb_tclas_entry, + type4_params); +if (ret) +return ret; +break ; + +case NL80211_QM_TCLAS_CLASSIFIER_TYPE10 : +if (!tb_tclas_entry[NL80211_QM_TCLAS_ATTR_TYPE10_PARAMS ]) +return -EINVAL ; + + ret =nl80211_parse_qm_tclas10_elem (tb_tclas_entry, + type10_params); +if (ret) +return ret; +break ; + +default : +return -EINVAL ; + } + +return 0 ; +} + +static int +nl80211_parse_qm_tclas (struct nlattr *tb[], +struct cfg80211_qm_req_desc_data *qm_req_desc) +{ +struct nlattr *tb_tclas; +struct nlattr *tclas_elements; +struct cfg80211_qm_tclas_elements *tclas_elem; +struct nlattr *attr; +int rem_tclas_desc; +unsigned int num_tclas_elements =0 ; +unsigned int tclas_idx =0 ; +int ret; + + tclas_elements = tb[NL80211_QM_DESC_ATTR_TCLAS_ELEMENTS ]; +nla_for_each_nested (tb_tclas, tclas_elements, rem_tclas_desc) + num_tclas_elements++; + +if (num_tclas_elements) { + qm_req_desc->tclas =kzalloc_objs (*qm_req_desc->tclas, + num_tclas_elements, +GFP_KERNEL ); +if (!qm_req_desc->tclas) +return -ENOMEM ; + } + +nla_for_each_nested (tb_tclas, tclas_elements, + rem_tclas_desc) { + tclas_elem = &qm_req_desc->tclas[tclas_idx]; + ret =nl80211_parse_qm_tclas_elem (tb_tclas, tclas_elem); +if (ret) +return ret; + + tclas_idx++; + } + + qm_req_desc->num_tclas_elements = num_tclas_elements; + + attr = tb[NL80211_QM_DESC_ATTR_TCLAS_PROCESSING ]; +if (attr) + qm_req_desc->tclas_processing =nla_get_u8 (attr); + +return 0 ; +} + +/* +* QoS characteristics control info bitfield masks, used only here to +* parse NL80211_QM_QOS_ATTR_CONTROL_INFO. +*/ +#define QM_CTRL_INFO_DIRECTION_MASK GENMASK(1, 0) +#define QM_CTRL_INFO_TID_MASK GENMASK(5, 2) +#define QM_CTRL_INFO_UP_MASK GENMASK(8, 6) +#define QM_CTRL_INFO_BITMAP_MASK GENMASK(24, 9) +#define QM_CTRL_INFO_LINK_ID_MASK GENMASK(28, 25) +#define QM_CTRL_INFO_RESERVED_MASK GENMASK(31, 29) + +/* +* MSDU delivery info bitfield masks, used only here to parse +* NL80211_QM_QOS_ATTR_MSDU_DELIVERY_INFO. +*/ +#define QM_MSDU_DELIVERY_INFO_RATIO_MASK GENMASK(3, 0) +#define QM_MSDU_DELIVERY_INFO_COUNT_EXPONENT_MASK GENMASK(7, 4) + +#define GET_FIELD_FROM_QM_CTRL_INFO (ctrl_info,FIELD ) \ + u32_get_bits((ctrl_info), QM_CTRL_INFO_##FIELD##_MASK) + +#define GET_FIELD_FROM_QM_MSDU_DELIVERY_INFO (msdu_delivery_info,FIELD ) \ + u8_get_bits((msdu_delivery_info), \ + QM_MSDU_DELIVERY_INFO_##FIELD##_MASK) + +static int +nl80211_parse_qm_qos_attr (struct nlattr *tb[], +struct cfg80211_qm_qos_attributes *qos_attr) +{ +struct nlattr *tb_qm_qos[NL80211_QM_QOS_ATTR_MAX +1 ]; +struct nlattr *attr; +u8 msdu_delivery_info; +u32 control_info; + + attr = tb[NL80211_QM_DESC_ATTR_QOS_ATTRIBUTES ]; +if (nla_parse_nested (tb_qm_qos,NL80211_QM_QOS_ATTR_MAX , attr, + nl80211_qm_qos_policy,NULL )) +return -EINVAL ; + +if (!tb_qm_qos[NL80211_QM_QOS_ATTR_CONTROL_INFO ] || + !tb_qm_qos[NL80211_QM_QOS_ATTR_MIN_SVC_INTERVAL ] || + !tb_qm_qos[NL80211_QM_QOS_ATTR_MAX_SVC_INTERVAL ] || + !tb_qm_qos[NL80211_QM_QOS_ATTR_MIN_DATA_RATE ] || + !tb_qm_qos[NL80211_QM_QOS_ATTR_DELAY_BOUND ]) +return -EINVAL ; + + attr = tb_qm_qos[NL80211_QM_QOS_ATTR_CONTROL_INFO ]; + control_info =nla_get_u32 (attr); + qos_attr->direction = +GET_FIELD_FROM_QM_CTRL_INFO (control_info,DIRECTION ); + qos_attr->tid =GET_FIELD_FROM_QM_CTRL_INFO (control_info,TID ); + qos_attr->up =GET_FIELD_FROM_QM_CTRL_INFO (control_info,UP ); + qos_attr->bitmap =GET_FIELD_FROM_QM_CTRL_INFO (control_info,BITMAP ); + qos_attr->link_id =GET_FIELD_FROM_QM_CTRL_INFO (control_info,LINK_ID ); + + qos_attr->min_service_interval = +nla_get_u32 (tb_qm_qos[NL80211_QM_QOS_ATTR_MIN_SVC_INTERVAL ]); + qos_attr->max_service_interval = +nla_get_u32 (tb_qm_qos[NL80211_QM_QOS_ATTR_MAX_SVC_INTERVAL ]); + qos_attr->min_data_rate = +nla_get_u32 (tb_qm_qos[NL80211_QM_QOS_ATTR_MIN_DATA_RATE ]); + qos_attr->delay_bound = +nla_get_u32 (tb_qm_qos[NL80211_QM_QOS_ATTR_DELAY_BOUND ]); + +if (tb_qm_qos[NL80211_QM_QOS_ATTR_MAX_MSDU_SIZE ]) { + attr = tb_qm_qos[NL80211_QM_QOS_ATTR_MAX_MSDU_SIZE ]; + qos_attr->max_msdu_size =nla_get_u16 (attr); + } + +if (tb_qm_qos[NL80211_QM_QOS_ATTR_SVC_START_TIME ]) { + attr = tb_qm_qos[NL80211_QM_QOS_ATTR_SVC_START_TIME ]; + qos_attr->service_start_time =nla_get_u32 (attr); + } + +if (tb_qm_qos[NL80211_QM_QOS_ATTR_SVC_START_TIME_LINK_ID ]) { + attr = tb_qm_qos[NL80211_QM_QOS_ATTR_SVC_START_TIME_LINK_ID ]; + qos_attr->service_start_time_link_id =nla_get_u8 (attr); + } + +if (tb_qm_qos[NL80211_QM_QOS_ATTR_MEAN_DATA_RATE ]) { + attr = tb_qm_qos[NL80211_QM_QOS_ATTR_MEAN_DATA_RATE ]; + qos_attr->mean_data_rate =nla_get_u32 (attr); + } + +if (tb_qm_qos[NL80211_QM_QOS_ATTR_BURST_SIZE ]) + qos_attr->burst_size = +nla_get_u32 (tb_qm_qos[NL80211_QM_QOS_ATTR_BURST_SIZE ]); + +if (tb_qm_qos[NL80211_QM_QOS_ATTR_MSDU_LIFETIME ]) { + attr = tb_qm_qos[NL80211_QM_QOS_ATTR_MSDU_LIFETIME ]; + qos_attr->msdu_lifetime =nla_get_u16 (attr); + } + +if (tb_qm_qos[NL80211_QM_QOS_ATTR_MSDU_DELIVERY_INFO ]) { + attr = tb_qm_qos[NL80211_QM_QOS_ATTR_MSDU_DELIVERY_INFO ]; + msdu_delivery_info =nla_get_u8 (attr); + + qos_attr->msdu_delivery_ratio = +GET_FIELD_FROM_QM_MSDU_DELIVERY_INFO (msdu_delivery_info, +RATIO ); + qos_attr->msdu_count_exponent = +GET_FIELD_FROM_QM_MSDU_DELIVERY_INFO (msdu_delivery_info, +COUNT_EXPONENT ); + } + +if (tb_qm_qos[NL80211_QM_QOS_ATTR_MEDIUM_TIME ]) + qos_attr->medium_time = +nla_get_u16 (tb_qm_qos[NL80211_QM_QOS_ATTR_MEDIUM_TIME ]); + +return 0 ; +} + +static int nl80211_parse_qm_desc (struct nlattr *tb_qm_desc, +struct cfg80211_qm_req_desc_data *qm_req_desc, +enum nl80211_qm_type qm_type) +{ +struct nlattr *tb[NL80211_QM_DESC_ATTR_MAX +1 ]; +struct nlattr *attr; +int ret; + +if (nla_parse_nested (tb,NL80211_QM_DESC_ATTR_MAX , + tb_qm_desc, nl80211_qm_desc_params_policy,NULL )) +return -EINVAL ; + +if (!tb[NL80211_QM_DESC_ATTR_QM_ID ] || + !tb[NL80211_QM_DESC_ATTR_REQUEST_TYPE ]) +return -EINVAL ; + + qm_req_desc->qm_id =nla_get_u8 (tb[NL80211_QM_DESC_ATTR_QM_ID ]); +if (!qm_req_desc->qm_id) +return -EINVAL ; + + qm_req_desc->request_type = +nla_get_u8 (tb[NL80211_QM_DESC_ATTR_REQUEST_TYPE ]); + +switch (qm_req_desc->request_type) { +case NL80211_QM_REMOVE_REQ : +return 0 ; +case NL80211_QM_ADD_REQ : +case NL80211_QM_CHANGE_REQ : +break ; +default : +return -EINVAL ; + } + +switch (qm_type) { +case NL80211_QM_TYPE_SCS : +if (tb[NL80211_QM_DESC_ATTR_PRIORITY ]) { + attr = tb[NL80211_QM_DESC_ATTR_PRIORITY ]; + qm_req_desc->priority =nla_get_u8 (attr); + } + +if (tb[NL80211_QM_DESC_ATTR_TCLAS_ELEMENTS ]) { + ret =nl80211_parse_qm_tclas (tb, qm_req_desc); +if (ret) +return ret; + } + +if (tb[NL80211_QM_DESC_ATTR_QOS_ATTRIBUTES ]) { + ret =nl80211_parse_qm_qos_attr (tb, + &qm_req_desc->qos_attr); +if (ret) +return ret; + + qm_req_desc->is_qos_present = true; + } +break ; + +case NL80211_QM_TYPE_MSCS : +if (tb[NL80211_QM_DESC_ATTR_USER_PRIORITY_BITMAP ]) { + attr = tb[NL80211_QM_DESC_ATTR_USER_PRIORITY_BITMAP ]; + qm_req_desc->user_priority_bitmap =nla_get_u8 (attr); + } + +if (tb[NL80211_QM_DESC_ATTR_USER_PRIORITY_LIMIT ]) { + attr = tb[NL80211_QM_DESC_ATTR_USER_PRIORITY_LIMIT ]; + qm_req_desc->user_priority_limit =nla_get_u8 (attr); + } + +if (tb[NL80211_QM_DESC_ATTR_TCLAS_MASK ]) { + attr = tb[NL80211_QM_DESC_ATTR_TCLAS_MASK ]; + qm_req_desc->tclas_mask =nla_get_u8 (attr); + } +break ; + +default : +return -EINVAL ; + } + +return 0 ; +} + +static int +nl80211_set_qm_resp_desc (struct sk_buff *msg, +struct cfg80211_qm_resp_desc_data *qm_resp_desc, +int idx) +{ +struct nlattr *qm_desc_entry; + + qm_desc_entry =nla_nest_start (msg, idx); +if (!qm_desc_entry) +return -ENOBUFS ; + +if (nla_put_u8 (msg,NL80211_QM_DESC_ATTR_QM_ID , + qm_resp_desc->qm_id) || +nla_put_u8 (msg,NL80211_QM_DESC_ATTR_STATUS , + qm_resp_desc->status)) { +nla_nest_cancel (msg, qm_desc_entry); +return -ENOBUFS ; + } + +nla_nest_end (msg, qm_desc_entry); +return 0 ; +} + +static int +nl80211_qm_send_resp (struct genl_info *info, +struct cfg80211_qm_req_data *qm_req, +struct cfg80211_qm_resp_data *qm_resp) +{ +struct nlattr *qm, *qm_desc; +struct sk_buff *msg; +void *hdr; +int ret; +int idx; + + msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + + hdr =nl80211hdr_put (msg, info->snd_portid, info->snd_seq,0 , +NL80211_CMD_QOS_MGMT ); +if (!hdr) { + ret = -ENOBUFS ; + goto nla_fail; + } + + qm =nla_nest_start (msg,NL80211_ATTR_QOS_MGMT ); +if (!qm) { + ret = -ENOBUFS ; + goto nla_fail; + } + +if (nla_put (msg,NL80211_QM_ATTR_MAC_ADDR ,ETH_ALEN , + qm_req->peer_mac) || +nla_put_u8 (msg,NL80211_QM_ATTR_QM_TYPE , + qm_req->qm_type)) { + ret = -ENOBUFS ; + goto nla_qm_fail; + } + + qm_desc =nla_nest_start (msg,NL80211_QM_ATTR_DESCRIPTOR_PARAMS ); +if (!qm_desc) { + ret = -ENOBUFS ; + goto nla_qm_fail; + } + +for (idx =0 ; idx < qm_req->num_qm_desc; idx++) { + ret =nl80211_set_qm_resp_desc (msg, &qm_resp->qm_resp_desc[idx], + idx); +if (ret) { +GENL_SET_ERR_MSG (info, +"QoS Management response descriptor failed" ); + goto nla_qm_desc_fail; + } + } + +nla_nest_end (msg, qm_desc); +nla_nest_end (msg, qm); +genlmsg_end (msg, hdr); + +return genlmsg_reply (msg, info); + +nla_qm_desc_fail: +nla_nest_cancel (msg, qm_desc); +nla_qm_fail: +nla_nest_cancel (msg, qm); +nla_fail: +nlmsg_free (msg); +return ret; +} + +static void +nl80211_free_qm_req (struct cfg80211_qm_req_data *qm_req) +{ +unsigned int i; + +for (i =0 ; i < qm_req->num_qm_desc; i++) +kfree (qm_req->qm_req_desc[i].tclas); + +kfree (qm_req->qm_req_desc); +} + +static int +nl80211_qos_mgmt_cfg (struct sk_buff *skb,struct genl_info *info) +{ +struct cfg80211_registered_device *rdev = info->user_ptr[0 ]; +struct net_device *dev = info->user_ptr[1 ]; +struct wireless_dev *wdev = dev->ieee80211_ptr; +struct nlattr *tb_qm[NL80211_QM_ATTR_MAX +1 ]; +struct cfg80211_qm_resp_data qm_resp = {}; +struct cfg80211_qm_req_data qm_req = {}; +struct cfg80211_qm_req_desc_data *qm_req_desc; +struct nlattr *tb_qm_desc; +int rem_qm_desc; +unsigned int num_qm_desc =0 ; +unsigned int idx; +int ret; + +if (wdev->iftype !=NL80211_IFTYPE_AP ) +return -EOPNOTSUPP ; + +if (!info->attrs[NL80211_ATTR_QOS_MGMT ]) { +GENL_SET_ERR_MSG (info,"QoS Management attribute missing" ); +return -EINVAL ; + } + +if (nla_parse_nested (tb_qm,NL80211_QM_ATTR_MAX , + info->attrs[NL80211_ATTR_QOS_MGMT ], + nl80211_qm_policy,NULL )) { +GENL_SET_ERR_MSG (info, +"QoS Management attribute parsing failed" ); +return -EINVAL ; + } + +if (!tb_qm[NL80211_QM_ATTR_MAC_ADDR ] || + !tb_qm[NL80211_QM_ATTR_QM_TYPE ] || + !tb_qm[NL80211_QM_ATTR_DESCRIPTOR_PARAMS ]) { +GENL_SET_ERR_MSG (info, +"QoS Management request attributes missing" ); +return -EINVAL ; + } + +nla_memcpy (qm_req.peer_mac, tb_qm[NL80211_QM_ATTR_MAC_ADDR ],ETH_ALEN ); + qm_req.qm_type =nla_get_u8 (tb_qm[NL80211_QM_ATTR_QM_TYPE ]); + +nla_for_each_nested (tb_qm_desc, + tb_qm[NL80211_QM_ATTR_DESCRIPTOR_PARAMS ], + rem_qm_desc) + num_qm_desc++; + +if (!num_qm_desc) { +GENL_SET_ERR_MSG (info, +"QoS Management descriptor list is empty" ); +return -EINVAL ; + } + + qm_req.qm_req_desc =kzalloc_objs (*qm_req.qm_req_desc, + num_qm_desc,GFP_KERNEL ); +if (!qm_req.qm_req_desc) { + ret = -ENOMEM ; + goto free_qm; + } + +nla_for_each_nested (tb_qm_desc, + tb_qm[NL80211_QM_ATTR_DESCRIPTOR_PARAMS ], + rem_qm_desc) { + qm_req_desc = &qm_req.qm_req_desc[qm_req.num_qm_desc]; + ret =nl80211_parse_qm_desc (tb_qm_desc, qm_req_desc, + qm_req.qm_type); +if (ret) { +GENL_SET_ERR_MSG (info, +"QoS Management descriptor parsing failed" ); + goto free_qm; + } + qm_req.num_qm_desc++; + } + +if (qm_req.qm_type ==NL80211_QM_TYPE_MSCS && qm_req.num_qm_desc !=1 ) { +GENL_SET_ERR_MSG (info, +"MSCS request must contain exactly one descriptor" ); + ret = -EINVAL ; + goto free_qm; + } + + qm_resp.qm_resp_desc =kzalloc_objs (*qm_resp.qm_resp_desc, + qm_req.num_qm_desc,GFP_KERNEL ); +if (!qm_resp.qm_resp_desc) { + ret = -ENOMEM ; + goto free_qm; + } + +for (idx =0 ; idx < qm_req.num_qm_desc; idx++) { + qm_resp.qm_resp_desc[idx].qm_id = + qm_req.qm_req_desc[idx].qm_id; + qm_resp.qm_resp_desc[idx].status =NL80211_QM_STATUS_DECLINED ; + } + + ret =rdev_set_qos_mgmt_cfg (rdev, dev, &qm_req, &qm_resp); +if (ret) { +GENL_SET_ERR_MSG (info,"set_qos_mgmt_cfg failed" ); + goto free_qm; + } + + ret =nl80211_qm_send_resp (info, &qm_req, &qm_resp); + +free_qm: +kfree (qm_resp.qm_resp_desc); +nl80211_free_qm_req (&qm_req); +return ret; +} +static const struct genl_small_ops nl80211_small_ops[] = { { .cmd =NL80211_CMD_SET_WIPHY ,
@@ -21438,6 +22074,12 @@ static const struct genl_small_ops nl80211_small_ops[] = { .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP | NL80211_FLAG_NO_WIPHY_MTX), }, + { + .cmd = NL80211_CMD_QOS_MGMT, + .doit = nl80211_qos_mgmt_cfg, + .flags = GENL_UNS_ADMIN_PERM, + .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP), + }, };static struct genl_family nl80211_fam__ro_after_init = {
net/wireless/rdev-ops.h +17 -0
@@ -1707,4 +1707,21 @@ rdev_set_epcs(struct cfg80211_registered_device *rdev, return ret; } +static inline int +rdev_set_qos_mgmt_cfg (struct cfg80211_registered_device *rdev, +struct net_device *dev, +struct cfg80211_qm_req_data *qm_req, +struct cfg80211_qm_resp_data *qm_resp) +{ +struct wiphy *wiphy = &rdev->wiphy; +int ret = -EOPNOTSUPP ; + +trace_rdev_set_qos_mgmt_cfg (wiphy, dev, qm_req); +if (rdev->ops->set_qos_mgmt_cfg) + ret = rdev->ops->set_qos_mgmt_cfg (wiphy, dev, qm_req, qm_resp); +trace_rdev_return_int (wiphy, ret); + +return ret; +} +#endif /* __CFG80211_RDEV_OPS */
net/wireless/trace.h +20 -0
@@ -3281,6 +3281,26 @@ TRACE_EVENT(rdev_set_epcs, WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->val) ); +TRACE_EVENT (rdev_set_qos_mgmt_cfg, + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, + struct cfg80211_qm_req_data *qm_req), +TP_ARGS (wiphy, netdev, qm_req), + TP_STRUCT__entry(WIPHY_ENTRY + NETDEV_ENTRY + __field(u8, qm_type) + __field(unsigned int, num_qm_desc) + ), + TP_fast_assign(WIPHY_ASSIGN; + NETDEV_ASSIGN; + __entry->qm_type = qm_req->qm_type; + __entry->num_qm_desc = qm_req->num_qm_desc; + ), +TP_printk (WIPHY_PR_FMT ", " NETDEV_PR_FMT +", qm_type=%u num_qm_desc=%u" , +WIPHY_PR_ARG ,NETDEV_PR_ARG , __entry->qm_type, + __entry->num_qm_desc) +); +/************************************************************* * cfg80211 exported functions traces * *************************************************************/
Signature · 1 line
2.34.1
RFC PATCH 4/7 wifi: mac80211: forward QoS Management configuration to drivers
In reply to Aishwarya RAdd a mac80211 QoS Management driver operation and connect it to the cfg80211 set_qos_mgmt_cfg() callback.
Pass the parsed SCS/MSCS request, including any QoS Characteristics, to the driver together with the response descriptor array. The driver is expected to apply the protocol-specific configuration and update each response descriptor with the status for its corresponding request.
The accepted configuration is then retained by mac80211 for use by subsequent data-path handling.
--- include/net/mac80211.h | 7 +++++++ net/mac80211/cfg.c | 13 +++++++++++++ net/mac80211/driver-ops.h | 28 ++++++++++++++++++++++++++++ net/mac80211/ieee80211_i.h | 4 ++++ net/mac80211/mlme.c | 17 +++++++++++++++++ net/mac80211/trace.h | 24 ++++++++++++++++++++++++ 6 files changed, 93 insertions(+)
include/net/mac80211.h +7 -0
@@ -4760,6 +4760,9 @@ struct ieee80211_prep_tx_info {* @set_eml_op_mode: Configure eMLSR/eMLMR operation mode in the underlay * driver according to the parameter received in the EML Operating mode * notification frame. +* @qos_mgmt_cfg: Configure QoS Management (QM) for a station. The request +* contains SCS or MSCS parameters, and the driver populates the +* per-descriptor response status. */ struct ieee80211_ops { void (*tx)(struct ieee80211_hw *hw,
@@ -5173,6 +5176,10 @@ struct ieee80211_ops {struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_eml_params *eml_params); +int (*qos_mgmt_cfg)(struct ieee80211_hw *hw,struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +struct cfg80211_qm_req_data *qm_req, +struct cfg80211_qm_resp_data *qm_resp); };/**
net/mac80211/cfg.c +13 -0
@@ -6309,6 +6309,18 @@ ieee80211_set_nan_non_evac_channels(struct wiphy *wiphy,return ieee80211_nan_set_non_evac_channels (sdata, channels); } +static int +ieee80211_set_qos_mgmt_cfg (struct wiphy *wiphy,struct net_device *dev, +struct cfg80211_qm_req_data *qm_req, +struct cfg80211_qm_resp_data *qm_resp) +{ +struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev); + +lockdep_assert_wiphy (wiphy); + +return ieee80211_qos_mgmt_cfg (sdata, qm_req, qm_resp); +} +const struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface,
@@ -6432,4 +6444,5 @@ const struct cfg80211_ops mac80211_config_ops = { .nan_set_local_sched = ieee80211_set_local_nan_sched, .nan_set_peer_sched = ieee80211_set_peer_nan_sched, .nan_set_non_evac_channels = ieee80211_set_nan_non_evac_channels, + .set_qos_mgmt_cfg = ieee80211_set_qos_mgmt_cfg, };
net/mac80211/driver-ops.h +28 -0
@@ -1804,4 +1804,32 @@ drv_nan_peer_sched_changed(struct ieee80211_local *local, return ret; } +static inline int +drv_qos_mgmt_cfg (struct ieee80211_sub_if_data *sdata, +struct ieee80211_local *local,struct ieee80211_sta *sta, +struct cfg80211_qm_req_data *qm_req, +struct cfg80211_qm_resp_data *qm_resp) +{ +int ret = -EOPNOTSUPP ; + +might_sleep (); +lockdep_assert_wiphy (local->hw.wiphy); + +if (!check_sdata_in_driver (sdata)) +return ret; + +/* +* Called only for SCS descriptors carrying a QoS Characteristics +* element (9.4.2.326, IEEE Std 802.11be-2024). Legacy SCS and MSCS +* are handled in mac80211. +*/ +trace_drv_qos_mgmt_cfg (local, sdata, sta, qm_req); +if (local->ops->qos_mgmt_cfg) + ret = local->ops->qos_mgmt_cfg (&local->hw, &sdata->vif, + sta, qm_req, qm_resp); +trace_drv_return_int (local, ret); + +return ret; +} +#endif /* __MAC80211_DRIVER_OPS */
net/mac80211/ieee80211_i.h +4 -0
@@ -3020,6 +3020,10 @@ ieee80211_uhr_cap_ie_to_sta_uhr_cap(struct ieee80211_sub_if_data *sdata,u8 uhr_cap_len, struct link_sta_info *link_sta); +int ieee80211_qos_mgmt_cfg (struct ieee80211_sub_if_data *sdata, +struct cfg80211_qm_req_data *qm_req, +struct cfg80211_qm_resp_data *qm_resp); +#if IS_ENABLED (CONFIG_MAC80211_KUNIT_TEST )#define EXPORT_SYMBOL_IF_MAC80211_KUNIT (sym) EXPORT_SYMBOL_IF_KUNIT(sym)#define VISIBLE_IF_MAC80211_KUNIT
net/mac80211/mlme.c +17 -0
@@ -12036,3 +12036,20 @@ void ieee80211_sta_rx_queued_frame(struct ieee80211_sub_if_data *sdata,break ; } } + +int ieee80211_qos_mgmt_cfg (struct ieee80211_sub_if_data *sdata, +struct cfg80211_qm_req_data *qm_req, +struct cfg80211_qm_resp_data *qm_resp) +{ +struct ieee80211_local *local = sdata->local; +struct sta_info *sta; + +if (sdata->vif.type !=NL80211_IFTYPE_AP ) +return -EOPNOTSUPP ; + + sta =sta_info_get_bss (sdata, qm_req->peer_mac); +if (!sta) +return -ENOENT ; + +return drv_qos_mgmt_cfg (sdata, local, &sta->sta, qm_req, qm_resp); +}
net/mac80211/trace.h +24 -0
@@ -3431,6 +3431,30 @@ TRACE_EVENT(drv_nan_peer_sched_changed, ) ); +TRACE_EVENT (drv_qos_mgmt_cfg, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct ieee80211_sta *sta, + struct cfg80211_qm_req_data *qm_req), +TP_ARGS (local, sdata, sta, qm_req), + TP_STRUCT__entry(LOCAL_ENTRY + VIF_ENTRY + STA_ENTRY + __field(u8, qm_type) + __field(unsigned int, num_qm_desc) + ), + TP_fast_assign(LOCAL_ASSIGN; + VIF_ASSIGN; + STA_NAMED_ASSIGN(sta); + __entry->qm_type = qm_req->qm_type; + __entry->num_qm_desc = qm_req->num_qm_desc; + ), + TP_printk(LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT +" qm_type:%u num_qm_desc:%u" , +LOCAL_PR_ARG ,VIF_PR_ARG ,STA_PR_ARG , + __entry->qm_type, __entry->num_qm_desc) +); +#endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH
Signature · 1 line
2.34.1
RFC PATCH 5/7 wifi: mac80211: track QoS Management station state
In reply to Aishwarya RStore accepted SCS and MSCS configuration in an RCU-published per-station object. TX and RX paths read this state without taking the wiphy lock, so replacing the object and freeing the old version is deferred until after an RCU grace period.
The state is updated after successful driver processing. The QoS Characteristics element is specified in 9.4.2.326, IEEE Std 802.11be-2024.
Retire replaced state through RCU and release remaining state when the station is removed.
--- net/mac80211/mlme.c | 150 +++++++++++++++++++++++++++++++++++++++- net/mac80211/sta_info.c | 7 ++ net/mac80211/sta_info.h | 21 ++++++ 3 files changed, 177 insertions(+), 1 deletion(-)
net/mac80211/mlme.c +149 -1
@@ -12037,12 +12037,119 @@ void ieee80211_sta_rx_queued_frame(struct ieee80211_sub_if_data *sdata, } } +static void +ieee80211_qos_mgmt_update_scs (struct ieee80211_sta_qos *qos, +struct cfg80211_qm_req_data *qm_req, +struct cfg80211_qm_resp_data *qm_resp) +{ +u8 tid; +int i; + +if (qm_req->qm_type !=NL80211_QM_TYPE_SCS ) +return ; + +for (i =0 ; i < qm_req->num_qm_desc; i++) { +struct cfg80211_qm_req_desc_data *qm_req_desc = + &qm_req->qm_req_desc[i]; +struct cfg80211_qm_resp_desc_data *qm_resp_desc = + &qm_resp->qm_resp_desc[i]; + +if (qm_resp_desc->qm_id != qm_req_desc->qm_id || + qm_resp_desc->status !=NL80211_QM_STATUS_SUCCESS ) +continue ; + +switch (qm_req_desc->request_type) { +case NL80211_QM_REMOVE_REQ : +clear_bit (qm_req_desc->qm_id, qos->active_scs_id); +break ; +case NL80211_QM_ADD_REQ : +case NL80211_QM_CHANGE_REQ : +/* +* For legacy SCS the TID is derived from the UP +* field of the first TCLAS element (11.25.2, IEEE +* Std 802.11-2024). For 802.11be SCS the TID is +* taken from the QoS +* Characteristics element (9.4.2.326, IEEE Std +* 802.11be-2024). +*/ +if (qm_req_desc->is_qos_present) + tid = qm_req_desc->qos_attr.tid; +else if (qm_req_desc->num_tclas_elements >0 ) + tid = qm_req_desc->tclas[0 ].up; +else +continue ; + +if (tid >=IEEE80211_QOS_MGMT_MAX_TID ) +continue ; + + qos->scs_id_tid_mapping[qm_req_desc->qm_id] = tid; +set_bit (qm_req_desc->qm_id, qos->active_scs_id); +break ; +default : +break ; + } + } + + qos->scs_enabled = + !bitmap_empty (qos->active_scs_id, +IEEE80211_QOS_MGMT_MAX_SCS_ID +1 ); +} + +static void +ieee80211_qos_mgmt_update_mscs (struct ieee80211_sta_qos *qos, +struct cfg80211_qm_req_data *qm_req, +struct cfg80211_qm_resp_data *qm_resp) +{ +struct cfg80211_qm_req_desc_data *qm_req_desc; +struct cfg80211_qm_resp_desc_data *qm_resp_desc; + + qm_req_desc = &qm_req->qm_req_desc[0 ]; + qm_resp_desc = &qm_resp->qm_resp_desc[0 ]; + +if (qm_resp_desc->qm_id != qm_req_desc->qm_id || + qm_resp_desc->status !=NL80211_QM_STATUS_SUCCESS ) +return ; + +switch (qm_req_desc->request_type) { +case NL80211_QM_ADD_REQ : +case NL80211_QM_CHANGE_REQ : + qos->mscs_user_priority_bitmap = + qm_req_desc->user_priority_bitmap; + qos->mscs_user_priority_limit = + qm_req_desc->user_priority_limit; + qos->mscs_enabled = true; +break ; +case NL80211_QM_REMOVE_REQ : + qos->mscs_user_priority_bitmap =0 ; + qos->mscs_user_priority_limit =0 ; + qos->mscs_enabled = false; +break ; +default : +break ; + } +} + +static bool +ieee80211_qos_mgmt_has_qos_char (struct cfg80211_qm_req_data *qm_req) +{ +unsigned int i; + +for (i =0 ; i < qm_req->num_qm_desc; i++) { +if (qm_req->qm_req_desc[i].is_qos_present) +return true; + } +return false; +} +int ieee80211_qos_mgmt_cfg (struct ieee80211_sub_if_data *sdata,struct cfg80211_qm_req_data *qm_req,struct cfg80211_qm_resp_data *qm_resp) {struct ieee80211_local *local = sdata->local; +struct ieee80211_sta_qos_rcu *new_qos =NULL ; +struct ieee80211_sta_qos_rcu *old_qos;struct sta_info *sta; +int ret;if (sdata->vif.type !=NL80211_IFTYPE_AP )return -EOPNOTSUPP ;
@@ -12051,5 +12158,46 @@ int ieee80211_qos_mgmt_cfg(struct ieee80211_sub_if_data *sdata,if (!sta)return -ENOENT ; -return drv_qos_mgmt_cfg (sdata, local, &sta->sta, qm_req, qm_resp); +if (qm_req->qm_type ==NL80211_QM_TYPE_SCS || + qm_req->qm_type ==NL80211_QM_TYPE_MSCS ) { + new_qos =kzalloc_obj (*new_qos); +if (!new_qos) +return -ENOMEM ; + + old_qos =rcu_dereference_protected (sta->qos, +lockdep_is_held (&local->hw.wiphy->mtx)); +if (old_qos) + new_qos->data = old_qos->data; + } + +/* +* SCS descriptors carrying a QoS Characteristics element +* (9.4.2.326, IEEE Std 802.11be-2024) require hardware-specific +* scheduling support; forward the request to the driver. Legacy +* SCS and MSCS are handled in mac80211. +*/ +if (ieee80211_qos_mgmt_has_qos_char (qm_req)) { + ret =drv_qos_mgmt_cfg (sdata, local, &sta->sta, + qm_req, qm_resp); +if (ret) { +kfree (new_qos); +return ret; + } + } + +if (!new_qos) +return 0 ; + +if (qm_req->qm_type ==NL80211_QM_TYPE_SCS ) +ieee80211_qos_mgmt_update_scs (&new_qos->data, qm_req, + qm_resp); +else +ieee80211_qos_mgmt_update_mscs (&new_qos->data, qm_req, + qm_resp); + old_qos =rcu_replace_pointer (sta->qos, new_qos, +lockdep_is_held (&local->hw.wiphy->mtx)); +if (old_qos) +kfree_rcu (old_qos, rcu_head); + +return 0 ; }
net/mac80211/sta_info.c +7 -0
@@ -467,8 +467,15 @@ static void sta_remove_link(struct sta_info *sta, unsigned int link_id,*/ void sta_info_free (struct ieee80211_local *local,struct sta_info *sta) { +struct ieee80211_sta_qos_rcu *qos;int i; +lockdep_assert_wiphy (local->hw.wiphy); + qos =rcu_replace_pointer (sta->qos,NULL , +lockdep_is_held (&local->hw.wiphy->mtx)); +if (qos) +kfree_rcu (qos, rcu_head); +for (i =0 ; i <ARRAY_SIZE (sta->link); i++) {struct link_sta_info *link_sta;
net/mac80211/sta_info.h +21 -0
@@ -16,10 +16,29 @@#include <linux/average.h> #include <linux/bitfield.h> #include <linux/etherdevice.h> +#include <linux/rcupdate.h> #include <linux/rhashtable.h> #include <linux/u64_stats_sync.h> #include "key.h" +/* SCS IDs are in the range 1-255; zero is reserved. */ +#define IEEE80211_QOS_MGMT_MAX_SCS_ID 255 +#define IEEE80211_QOS_MGMT_MAX_TID 8 + +struct ieee80211_sta_qos { +bool scs_enabled; +bool mscs_enabled; + DECLARE_BITMAP(active_scs_id, IEEE80211_QOS_MGMT_MAX_SCS_ID + 1); +u8 scs_id_tid_mapping[IEEE80211_QOS_MGMT_MAX_SCS_ID +1 ]; +u8 mscs_user_priority_bitmap; +u8 mscs_user_priority_limit; +}; + +struct ieee80211_sta_qos_rcu { +struct rcu_head rcu_head; +struct ieee80211_sta_qos data; +}; +/** * enum ieee80211_sta_info_flags - Stations flags *
@@ -657,6 +676,7 @@ struct ieee80211_sta_removed_link_stats {* @rate_ctrl_priv: rate control private per-STA pointer * @lock: used for locking all fields that require locking, see comments * in the header file. +* @qos: RCU-published QoS Management state * @drv_deliver_wk: used for delivering frames after driver PS unblocking * @listen_interval: listen interval of this station, when we're acting as AP * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly
@@ -728,6 +748,7 @@ struct sta_info {void *rate_ctrl_priv;spinlock_t rate_ctrl_lock;spinlock_t lock; +struct ieee80211_sta_qos_rcu __rcu *qos;struct ieee80211_fast_tx __rcu *fast_tx;struct ieee80211_fast_rx __rcu *fast_rx;
Signature · 1 line
2.34.1
RFC PATCH 6/7 wifi: mac80211: map SCS packets to configured TIDs
In reply to Aishwarya RUse the negotiated SCS descriptor-to-TID mapping when selecting the transmit queue for packets carrying QoS Management metadata.
The low 16 bits of skb->mark are used as private QoS Management metadata. Bits 0-7 carry the IEEE Std 802.11-2024 element ID for the respective QoS Management descriptor: WLAN_EID_SCS_DESCRIPTOR (185, 0xB9) for SCS and WLAN_EID_EXT_MSCS_DESCRIPTOR (88, 0x58) for MSCS. Bits 8-15 carry the negotiated SCS identifier.
During transmit queue selection, look up the negotiated SCS state for the station and apply the corresponding TID mapping.
SCS identifier zero is reserved and is rejected before accessing the RCU-protected per-station QoS state.
hostapd programs nftables rules on the netdev egress hook to maintain QoS Management metadata in the conntrack mark and to copy it into skb->mark before packets reach mac80211 transmit queue selection, for example:
nft add rule netdev qos wlan0_wifi_qos meta mark set ct mark
This nftables rule copies the conntrack mark (ct mark) into skb->mark on egress, allowing the negotiated SCS state to be applied during transmit queue selection.
The conntrack mark is restored into skb->mark at the final egress hook, after earlier L3 policy-routing decisions have completed. mac80211 first checks the QoS Management tag and then validates it against the per-station state, so SCS metadata is used only when SCS is enabled and the marked SCS ID is active. Packets without a matching tag or active descriptor, including ordinary non-SCS traffic, are ignored by this path.
Intra-BSS forwarding requires per-station peer isolation to ensure the SCS mark is preserved at transmit queue selection.
This implementation depends on the corresponding hostapd and nftables configuration that populates the conntrack mark with the QoS Management metadata.
--- include/linux/ieee80211.h | 1 + net/mac80211/ieee80211_i.h | 14 ++++++++++++++ net/mac80211/wme.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+)
include/linux/ieee80211.h +1 -0
@@ -1821,6 +1821,7 @@ enum ieee80211_eid_ext {WLAN_EID_EXT_SHORT_SSID_LIST =58 ,WLAN_EID_EXT_HE_6GHZ_CAPA =59 ,WLAN_EID_EXT_UL_MU_POWER_CAPA =60 , +WLAN_EID_EXT_MSCS_DESCRIPTOR =88 ,WLAN_EID_EXT_EHT_OPERATION =106 ,WLAN_EID_EXT_EHT_MULTI_LINK =107 , WLAN_EID_EXT_EHT_CAPABILITY = 108,
net/mac80211/ieee80211_i.h +14 -0
@@ -80,6 +80,20 @@ struct ieee80211_mesh_fast_tx;#define IEEE80211_DEFAULT_MAX_SP_LEN \ IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL +/* +* TODO: Synchronize this skb->mark encoding with the userspace application +* (hostapd). These values reuse IEEE element IDs, but their use in skb->mark +* is an implementation contract between hostapd/nftables and mac80211. +*/ +/* skb->mark bits [7:0] carry a QoS Management protocol tag. The values +* match the IEEE Std 802.11-2024 element IDs for the respective descriptors: +* WLAN_EID_SCS_DESCRIPTOR (185) and WLAN_EID_EXT_MSCS_DESCRIPTOR (88). +*/ +#define IEEE80211_QOS_MGMT_TAG_MASK GENMASK(7, 0) +#define IEEE80211_QOS_MGMT_SCS_TAG WLAN_EID_SCS_DESCRIPTOR +#define IEEE80211_QOS_MGMT_MSCS_TAG WLAN_EID_EXT_MSCS_DESCRIPTOR +#define IEEE80211_QOS_MGMT_ID_MASK GENMASK(15, 8) +extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS ]; #define IEEE80211_DEAUTH_FRAME_LEN (24 /* hdr */ + 2 /* reason */)
net/mac80211/wme.c +36 -0
@@ -113,6 +113,41 @@ static u16 ieee80211_downgrade_queue(struct ieee80211_sub_if_data *sdata,return ieee802_1d_to_ac[skb->priority]; } +static void +ieee80211_qos_mgmt_set_priority (struct sta_info *sta,struct sk_buff *skb) +{ +struct ieee80211_sta_qos_rcu *qos; +u8 qos_tag; +u8 qos_id; +u8 tid; + +if (!sta) +return ; + + qos_tag =u32_get_bits (skb->mark,IEEE80211_QOS_MGMT_TAG_MASK ); + qos_id =u32_get_bits (skb->mark,IEEE80211_QOS_MGMT_ID_MASK ); +if (qos_tag !=IEEE80211_QOS_MGMT_SCS_TAG ) +return ; + +if (!qos_id) +return ; + +guard (rcu)(); + qos =rcu_dereference (sta->qos); + +if (!qos) +return ; + +if (!qos->data.scs_enabled || + !test_bit (qos_id, qos->data.active_scs_id)) +return ; + + tid = qos->data.scs_id_tid_mapping[qos_id]; + +if (tid <IEEE80211_QOS_MGMT_MAX_TID ) + skb->priority = tid; +} +/* Indicate which queue to use for this fully formed 802.11 frame */ u16 ieee80211_select_queue_80211(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
@@ -179,6 +214,7 @@ u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata, qos_map =rcu_dereference (sdata->qos_map); skb->priority =cfg80211_classify8021d (skb, qos_map ? &qos_map->qos_map :NULL ); +ieee80211_qos_mgmt_set_priority (sta, skb); downgrade:return ieee80211_downgrade_queue (sdata, sta, skb);
Signature · 1 line
2.34.1
RFC PATCH 7/7 wifi: mac80211: add MSCS packet classification
In reply to Aishwarya RUse the negotiated MSCS configuration to classify uplink traffic and enforce the configured user priority limit during transmit queue selection for AP-forwarded packets.
For packets received from an associated non-AP STA, the RX path checks the received user priority against the negotiated MSCS user-priority bitmap. When a match is found, mac80211 records an MSCS tag together with the received user priority in skb->mark.
The received user priority can be associated with a connection by copying skb->mark to the conntrack mark using nftables. Since the conntrack entry is shared by both directions of the connection, the stored metadata can later be restored into skb->mark for corresponding downlink packets. When such a packet is forwarded to mac80211, ieee80211_select_queue() consumes the metadata from skb->mark, applies the negotiated MSCS user-priority limit, updates skb->priority, and normal queue selection maps it to the transmit TID.
Intra-BSS forwarding requires per-station peer isolation to ensure the MSCS mark is preserved at transmit queue selection.
--- net/mac80211/rx.c | 29 +++++++++++++++++++++++++++++ net/mac80211/wme.c | 23 +++++++++++++++++------ 2 files changed, 46 insertions(+), 6 deletions(-)
net/mac80211/rx.c +29 -0
@@ -1003,6 +1003,31 @@ static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) rx->skb->priority = (tid >7 ) ?0 : tid; } +static void ieee80211_qos_mgmt_mscs_set_mark (struct ieee80211_rx_data *rx) +{ +struct ieee80211_sta_qos_rcu *qos; +u8 tid; + +if (!rx->sta || + (rx->sdata->vif.type !=NL80211_IFTYPE_AP && + rx->sdata->vif.type !=NL80211_IFTYPE_AP_VLAN ) || + rx->seqno_idx >=IEEE80211_QOS_MGMT_MAX_TID ) +return ; + + tid = rx->skb->priority; + + qos =rcu_dereference (rx->sta->qos); +if (!qos || !qos->data.mscs_enabled || + !(BIT (tid) & qos->data.mscs_user_priority_bitmap)) +return ; + + rx->skb->mark =u32_replace_bits (rx->skb->mark, +IEEE80211_QOS_MGMT_MSCS_TAG , +IEEE80211_QOS_MGMT_TAG_MASK ); + rx->skb->mark =u32_replace_bits (rx->skb->mark, tid, +IEEE80211_QOS_MGMT_ID_MASK ); +} +/** * DOC: Packet alignment *
@@ -3333,6 +3358,9 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx) rx->skb->dev = dev; +if (!port_control) +ieee80211_qos_mgmt_mscs_set_mark (rx); +if (!ieee80211_hw_check (&local->hw,SUPPORTS_DYNAMIC_PS ) && local->ps_sdata && local->hw.conf.dynamic_ps_timeout >0 && !is_multicast_ether_addr(
@@ -4996,6 +5024,7 @@ static void ieee80211_rx_8023(struct ieee80211_rx_data *rx, stats->packets++; skb->dev = fast_rx->dev; +ieee80211_qos_mgmt_mscs_set_mark (rx);dev_sw_netstats_rx_add (fast_rx->dev, skb->len);
net/mac80211/wme.c +17 -6
@@ -126,10 +126,11 @@ ieee80211_qos_mgmt_set_priority(struct sta_info *sta, struct sk_buff *skb) qos_tag =u32_get_bits (skb->mark,IEEE80211_QOS_MGMT_TAG_MASK ); qos_id =u32_get_bits (skb->mark,IEEE80211_QOS_MGMT_ID_MASK ); -if (qos_tag !=IEEE80211_QOS_MGMT_SCS_TAG ) +if (qos_tag !=IEEE80211_QOS_MGMT_SCS_TAG && + qos_tag !=IEEE80211_QOS_MGMT_MSCS_TAG )return ; -if (!qos_id) +if (qos_tag ==IEEE80211_QOS_MGMT_SCS_TAG && !qos_id)return ;guard (rcu)();
@@ -138,11 +139,21 @@ ieee80211_qos_mgmt_set_priority(struct sta_info *sta, struct sk_buff *skb)if (!qos)return ; -if (!qos->data.scs_enabled || - !test_bit (qos_id, qos->data.active_scs_id)) -return ; +if (qos_tag ==IEEE80211_QOS_MGMT_SCS_TAG ) { +if (!qos->data.scs_enabled || + !test_bit (qos_id, qos->data.active_scs_id)) +return ; + + tid = qos->data.scs_id_tid_mapping[qos_id]; + }else { +if (!qos->data.mscs_enabled || + qos_id >=IEEE80211_QOS_MGMT_MAX_TID || + !(qos->data.mscs_user_priority_bitmap &BIT (qos_id))) +return ; - tid = qos->data.scs_id_tid_mapping[qos_id]; + tid =min_t (u8, qos_id, + qos->data.mscs_user_priority_limit); + }if (tid <IEEE80211_QOS_MGMT_MAX_TID ) skb->priority = tid;
Signature · 1 line
2.34.1