]> git.ipfire.org Git - thirdparty/hostap.git/blame - tests/hwsim/test_ap_qosmap.py
tests: Pass wpas/hapd instance to test_connectivity()
[thirdparty/hostap.git] / tests / hwsim / test_ap_qosmap.py
CommitLineData
3208c3e9
JM
1# QoS Mapping tests
2# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
3#
4# This software may be distributed under the terms of the BSD license.
5# See README for more details.
6
7import time
8import subprocess
9import logging
10logger = logging.getLogger()
11
12import hwsim_utils
13import hostapd
65249f6c
JM
14from wlantest import Wlantest
15
a8375c94 16def check_qos_map(ap, hapd, dev, dscp, tid, ap_tid=None):
08567ff6
JM
17 if not ap_tid:
18 ap_tid = tid
65249f6c
JM
19 bssid = ap['bssid']
20 sta = dev.p2p_interface_addr()
21 wt = Wlantest()
22 wt.clear_sta_counters(bssid, sta)
a8375c94 23 hwsim_utils.test_connectivity(dev, hapd, dscp=dscp)
94a2dd0b 24 time.sleep(0.02)
65249f6c
JM
25 [ tx, rx ] = wt.get_tid_counters(bssid, sta)
26 if tx[tid] == 0:
27 logger.info("Expected TX DSCP " + str(dscp) + " with TID " + str(tid) + " but counters: " + str(tx))
28 raise Exception("No STA->AP data frame using the expected TID")
08567ff6
JM
29 if rx[ap_tid] == 0:
30 logger.info("Expected RX DSCP " + str(dscp) + " with TID " + str(ap_tid) + " but counters: " + str(rx))
65249f6c 31 raise Exception("No AP->STA data frame using the expected TID")
3208c3e9
JM
32
33def test_ap_qosmap(dev, apdev):
34 """QoS mapping"""
35 drv_flags = dev[0].get_driver_status_field("capa.flags")
36 if int(drv_flags, 0) & 0x40000000 == 0:
37 return "skip"
38 ssid = "test-qosmap"
39 params = { "ssid": ssid }
65249f6c 40 params['qos_map_set'] = '53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55'
a8375c94 41 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
3208c3e9 42 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
94a2dd0b 43 time.sleep(0.1)
a8375c94
JM
44 check_qos_map(apdev[0], hapd, dev[0], 53, 2)
45 check_qos_map(apdev[0], hapd, dev[0], 22, 6)
46 check_qos_map(apdev[0], hapd, dev[0], 8, 0)
47 check_qos_map(apdev[0], hapd, dev[0], 15, 0)
48 check_qos_map(apdev[0], hapd, dev[0], 0, 1)
49 check_qos_map(apdev[0], hapd, dev[0], 7, 1)
50 check_qos_map(apdev[0], hapd, dev[0], 16, 3)
51 check_qos_map(apdev[0], hapd, dev[0], 31, 3)
52 check_qos_map(apdev[0], hapd, dev[0], 32, 4)
53 check_qos_map(apdev[0], hapd, dev[0], 39, 4)
54 check_qos_map(apdev[0], hapd, dev[0], 40, 6)
55 check_qos_map(apdev[0], hapd, dev[0], 47, 6)
56 check_qos_map(apdev[0], hapd, dev[0], 48, 7)
57 check_qos_map(apdev[0], hapd, dev[0], 55, 7)
65249f6c 58 hapd.request("SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55")
3208c3e9 59 hapd.request("SEND_QOS_MAP_CONF " + dev[0].get_status_field("address"))
a8375c94
JM
60 check_qos_map(apdev[0], hapd, dev[0], 53, 7)
61 check_qos_map(apdev[0], hapd, dev[0], 22, 6)
62 check_qos_map(apdev[0], hapd, dev[0], 48, 7)
63 check_qos_map(apdev[0], hapd, dev[0], 55, 7)
64 check_qos_map(apdev[0], hapd, dev[0], 56, 56 >> 3)
65 check_qos_map(apdev[0], hapd, dev[0], 63, 63 >> 3)
65249f6c
JM
66
67def test_ap_qosmap_default(dev, apdev):
68 """QoS mapping with default values"""
69 ssid = "test-qosmap-default"
70 params = { "ssid": ssid }
a8375c94 71 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
65249f6c
JM
72 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
73 for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]:
a8375c94 74 check_qos_map(apdev[0], hapd, dev[0], dscp, dscp >> 3)
08567ff6
JM
75
76def test_ap_qosmap_default_acm(dev, apdev):
77 """QoS mapping with default values and ACM=1 for VO/VI"""
78 ssid = "test-qosmap-default"
79 params = { "ssid": ssid,
80 "wmm_ac_bk_aifs": "7",
81 "wmm_ac_bk_cwmin": "4",
82 "wmm_ac_bk_cwmax": "10",
83 "wmm_ac_bk_txop_limit": "0",
84 "wmm_ac_bk_acm": "0",
85 "wmm_ac_be_aifs": "3",
86 "wmm_ac_be_cwmin": "4",
87 "wmm_ac_be_cwmax": "10",
88 "wmm_ac_be_txop_limit": "0",
89 "wmm_ac_be_acm": "0",
90 "wmm_ac_vi_aifs": "2",
91 "wmm_ac_vi_cwmin": "3",
92 "wmm_ac_vi_cwmax": "4",
93 "wmm_ac_vi_txop_limit": "94",
94 "wmm_ac_vi_acm": "1",
95 "wmm_ac_vo_aifs": "2",
96 "wmm_ac_vo_cwmin": "2",
97 "wmm_ac_vo_cwmax": "2",
98 "wmm_ac_vo_txop_limit": "47",
99 "wmm_ac_vo_acm": "1" }
a8375c94 100 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
08567ff6
JM
101 dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
102 for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]:
103 ap_tid = dscp >> 3
104 tid = ap_tid
105 # downgrade VI/VO to BE
106 if tid in [ 4, 5, 6, 7 ]:
107 tid = 3
a8375c94 108 check_qos_map(apdev[0], hapd, dev[0], dscp, tid, ap_tid)
986eedcd
JM
109
110def test_ap_qosmap_invalid(dev, apdev):
111 """QoS mapping ctrl_iface error handling"""
112 ssid = "test-qosmap"
113 params = { "ssid": ssid }
114 hapd = hostapd.add_ap(apdev[0]['ifname'], params)
115 if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF 00:11:22:33:44:55"):
116 raise Exception("Unexpected SEND_QOS_MAP_CONF success")
117 if "FAIL" not in hapd.request("SET_QOS_MAP_SET "):
118 raise Exception("Unexpected SET_QOS_MAP_SET success")
119 if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,2,3"):
120 raise Exception("Unexpected SET_QOS_MAP_SET success")
121 if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,-2,3"):
122 raise Exception("Unexpected SET_QOS_MAP_SET success")
123 if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59"):
124 raise Exception("Unexpected SET_QOS_MAP_SET success")
125 if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21"):
126 raise Exception("Unexpected SET_QOS_MAP_SET success")
127
128 if "FAIL" in hapd.request("SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55"):
129 raise Exception("Unexpected SET_QOS_MAP_SET failure")
130 if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF 00:11:22:33:44:55"):
131 raise Exception("Unexpected SEND_QOS_MAP_CONF success")
132 if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF 00:11:22:33:44"):
133 raise Exception("Unexpected SEND_QOS_MAP_CONF success")