cfg80211: Add support for QoS mapping
PATCH v2 1/2 cfg80211: Add support for QoS mapping
From: Kyeyoon Park <[email protected]>
This allows QoS mapping from external networks to be implemented as defined in IEEE Std 802.11-2012, 10.24.9. APs can use this to advertise DSCP ranges and exceptions for mapping frames to a specific UP over Wi-Fi.
The payload of the QoS Map Set element (IEEE Std 802.11-2012, 8.4.2.97) is sent to the driver through the new NL80211_ATTR_QOS_MAP attribute to configure the local behavior either on the AP (based on local configuration) or on a station (based on information received from the AP).
--- drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c | 2 +- drivers/net/wireless/mwifiex/main.c | 2 +- include/net/cfg80211.h | 53 +++++++++++++++++- include/uapi/linux/nl80211.h | 14 +++++ net/mac80211/wme.c | 2 +- net/wireless/ap.c | 1 + net/wireless/ibss.c | 2 + net/wireless/mesh.c | 1 + net/wireless/nl80211.c | 62 ++++++++++++++++++++++ net/wireless/rdev-ops.h | 15 ++++++ net/wireless/sme.c | 2 + net/wireless/trace.h | 40 ++++++++++++++ net/wireless/util.c | 19 ++++++- 13 files changed, 210 insertions(+), 5 deletions(-)
v2:
- remove 'bool valid'
- clear QoS Map configuration from cfg80211 on disconnection, AP stop, etc.
- reject command if in client mode and not associated
drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c +1 -1
@@ -1873,7 +1873,7 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb)brcmf_dbg (DATA ,"tx proto=0x%X\n" ,ntohs (eh->h_proto));/* determine the priority */ if (!skb->priority) - skb->priority =cfg80211_classify8021d (skb); + skb->priority =cfg80211_classify8021d (skb,NULL ); drvr->tx_multicast += !!multicast;if (pae)
drivers/net/wireless/mwifiex/main.c +1 -1
@@ -749,7 +749,7 @@ static struct net_device_stats *mwifiex_get_stats(struct net_device *dev)static u16 mwifiex_netdev_select_wmm_queue (struct net_device *dev,struct sk_buff *skb) { - skb->priority =cfg80211_classify8021d (skb); + skb->priority =cfg80211_classify8021d (skb,NULL );return mwifiex_1d_to_wmm_queue[skb->priority]; }
include/net/cfg80211.h +52 -1
79 lines not on this page · raw message
include/uapi/linux/nl80211.h +14 -0
@@ -693,6 +693,12 @@* other station that transmission must be blocked until the channel * switch is complete. * +* @NL80211_CMD_SET_QOS_MAP: Set Interworking QoS mapping for IP DSCP values. +* The QoS mapping information is included in %NL80211_ATTR_QOS_MAP. If +* that attribute is not included, QoS mapping is disabled. Since this +* QoS mapping is relevant for IP packets, it is only valid during an +* association. This is cleared on disassociation and AP restart. +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -860,6 +866,8 @@ enum nl80211_commands {NL80211_CMD_CHANNEL_SWITCH , + NL80211_CMD_SET_QOS_MAP, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -1520,6 +1528,10 @@ enum nl80211_commands {* @NL80211_ATTR_SUPPORT_10_MHZ: A flag indicating that the device supports * 10 MHz channel bandwidth. * +* @NL80211_ATTR_QOS_MAP: IP DSCP mapping for Interworking QoS mapping. This +* data is in the format defined for the payload of the QoS Map Set element +* in IEEE Std 802.11-2012, 8.4.2.97. +* * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */
@@ -1839,6 +1851,8 @@ enum nl80211_attrs {NL80211_ATTR_SUPPORT_5_MHZ ,NL80211_ATTR_SUPPORT_10_MHZ , +NL80211_ATTR_QOS_MAP , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
net/mac80211/wme.c +1 -1
@@ -155,7 +155,7 @@ u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,/* use the data classifier to determine what 802.1d tag the * data frame has */ - skb->priority =cfg80211_classify8021d (skb); + skb->priority =cfg80211_classify8021d (skb,NULL );return ieee80211_downgrade_queue (sdata, skb); }
net/wireless/ap.c +1 -0
@@ -29,6 +29,7 @@ static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, wdev->beacon_interval =0 ; wdev->channel =NULL ; wdev->ssid_len =0 ; +rdev_set_qos_map (rdev, dev,NULL ); }return err;
net/wireless/ibss.c +2 -0
@@ -183,6 +183,8 @@ static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext)kfree (wdev->connect_keys); wdev->connect_keys =NULL ; +rdev_set_qos_map (rdev, dev,NULL ); +/* * Delete all the keys ... pairwise keys can't really * exist any more anyway, but default keys might.
net/wireless/mesh.c +1 -0
@@ -268,6 +268,7 @@ static int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,if (!err) { wdev->mesh_id_len =0 ; wdev->channel =NULL ; +rdev_set_qos_map (rdev, dev,NULL ); }return err;
net/wireless/nl80211.c +62 -0
86 lines not on this page · raw message
net/wireless/rdev-ops.h +15 -0
@@ -932,4 +932,19 @@ static inline int rdev_channel_switch(struct cfg80211_registered_device *rdev, return ret; } +static inline int rdev_set_qos_map (struct cfg80211_registered_device *rdev, +struct net_device *dev, +struct cfg80211_qos_map *qos_map) +{ +int ret = -EOPNOTSUPP ; + +if (rdev->ops->set_qos_map) { +trace_rdev_set_qos_map (&rdev->wiphy, dev, qos_map); + ret = rdev->ops->set_qos_map (&rdev->wiphy, dev, qos_map); +trace_rdev_return_int (&rdev->wiphy, ret); + } + +return ret; +} +#endif /* __CFG80211_RDEV_OPS */
net/wireless/sme.c +2 -0
@@ -870,6 +870,8 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie,for (i =0 ; i <6 ; i++)rdev_del_key (rdev, dev, i, false,NULL ); +rdev_set_qos_map (rdev, dev,NULL ); +#ifdef CONFIG_CFG80211_WEXT memset (&wrqu,0 ,sizeof (wrqu)); wrqu.ap_addr.sa_family =ARPHRD_ETHER ;
net/wireless/trace.h +40 -0
@@ -186,6 +186,28 @@#define BOOL_TO_STR (bo) (bo) ? "true" : "false" +#define QOS_MAP_ENTRY __field(u8, num_des) \ + __array(u8, dscp_exception, \ + 2 * IEEE80211_QOS_MAP_MAX_EX) \ + __array(u8, up, IEEE80211_QOS_MAP_LEN_MIN) +#define QOS_MAP_ASSIGN (qos_map) \ + do { \ + if ((qos_map)) { \ + __entry->num_des = (qos_map)->num_des; \ + memcpy(__entry->dscp_exception, \ + &(qos_map)->dscp_exception, \ + 2 * IEEE80211_QOS_MAP_MAX_EX); \ + memcpy(__entry->up, &(qos_map)->up, \ + IEEE80211_QOS_MAP_LEN_MIN); \ + } else { \ + __entry->num_des = 0; \ + memset(__entry->dscp_exception, 0, \ + 2 * IEEE80211_QOS_MAP_MAX_EX); \ + memset(__entry->up, 0, \ + IEEE80211_QOS_MAP_LEN_MIN); \ + } \ + } while (0) +/************************************************************* * rdev->ops traces * *************************************************************/
@@ -1875,6 +1897,24 @@ TRACE_EVENT(rdev_channel_switch, __entry->counter_offset_presp) ); +TRACE_EVENT (rdev_set_qos_map, + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, + struct cfg80211_qos_map *qos_map), +TP_ARGS (wiphy, netdev, qos_map), +TP_STRUCT__entry ( + WIPHY_ENTRY + NETDEV_ENTRY +QOS_MAP_ENTRY + ), +TP_fast_assign ( + WIPHY_ASSIGN; + NETDEV_ASSIGN; + QOS_MAP_ASSIGN(qos_map); + ), +TP_printk (WIPHY_PR_FMT ", " NETDEV_PR_FMT ", num_des: %u" , +WIPHY_PR_ARG ,NETDEV_PR_ARG , __entry->num_des) +); +/************************************************************* * cfg80211 exported functions traces * *************************************************************/
net/wireless/util.c +18 -1
@@ -689,7 +689,8 @@ void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,EXPORT_SYMBOL (ieee80211_amsdu_to_8023s);/* Given a data frame determine the 802.1p/1d tag to use. */ -unsigned int cfg80211_classify8021d (struct sk_buff *skb) +unsigned int cfg80211_classify8021d (struct sk_buff *skb, +struct cfg80211_qos_map *qos_map) {unsigned int dscp;unsigned char vlan_priority;
@@ -720,6 +721,21 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb)return 0 ; } +if (qos_map) { +unsigned int i, tmp_dscp = dscp >>2 ; + +for (i =0 ; i < qos_map->num_des; i++) { +if (tmp_dscp == qos_map->dscp_exception[i].dscp) +return qos_map->dscp_exception[i].up; + } + +for (i =0 ; i <8 ; i++) { +if (tmp_dscp >= qos_map->up[i].low && + tmp_dscp <= qos_map->up[i].high) +return i; + } + } +return dscp >>5 ; }EXPORT_SYMBOL (cfg80211_classify8021d);
@@ -863,6 +879,7 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, dev->ieee80211_ptr->use_4addr = false; dev->ieee80211_ptr->mesh_id_up_len =0 ; +rdev_set_qos_map (rdev, dev,NULL );switch (otype) {case NL80211_IFTYPE_AP :
Signature · 5 lines
1.8.3.2 -- Jouni Malinen PGP id EFC895FA