1# Lint as: python2, python3 2# Copyright (c) 2021 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6from autotest_lib.client.common_lib import error 7from autotest_lib.server.cros.network import hostap_config 8from autotest_lib.server.cros.network import perf_test_manager as perf_manager 9""" 10This file defines the expected throughput values that should be used with the network_WiFi_Perf.* 11tests. 12 13The expected throughput values depend on the following parameters: 141- The test type: 15 a) TCP_BIDIRECTIONAL 16 b) TCP_RX 17 c) TCP_TX 18 a) UDP_BIDIRECTIONAL 19 b) UDP_RX 20 c) UDP_TX 21 Note: The thoughput is viewed from the DUT perspective: 22 streaming to DUT = RX 23 streaming from DUT = TX 24 simultaneous TX + RX = BIDIERECTIONAL 252- The Connection mode: 26 a) 80211n 27 b) 80211ac 283- The channel width: 29 a) 20 MHz 30 b) 40 MHz 31 c) 80 MHz 32""" 33 34expected_throughput_wifi = { 35 perf_manager.PerfTestTypes.TEST_TYPE_TCP_BIDIRECTIONAL: { 36 hostap_config.HostapConfig.MODE_11N_PURE: { 37 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_20: (0, 0), 38 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_PLUS: 39 (0, 0), 40 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_MINUS: 41 (0, 0) 42 }, 43 hostap_config.HostapConfig.MODE_11AC_MIXED: { 44 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_80: (0, 0) 45 }, 46 hostap_config.HostapConfig.MODE_11AC_PURE: { 47 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_20: 48 (0, 0), 49 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_40: (0, 0) 50 } 51 }, 52 perf_manager.PerfTestTypes.TEST_TYPE_UDP_BIDIRECTIONAL: { 53 hostap_config.HostapConfig.MODE_11N_PURE: { 54 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_20: (0, 0), 55 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_PLUS: 56 (0, 0), 57 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_MINUS: 58 (0, 0) 59 }, 60 hostap_config.HostapConfig.MODE_11AC_MIXED: { 61 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_80: (0, 0) 62 }, 63 hostap_config.HostapConfig.MODE_11AC_PURE: { 64 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_20: 65 (0, 0), 66 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_40: (0, 0) 67 } 68 }, 69 perf_manager.PerfTestTypes.TEST_TYPE_TCP_RX: { 70 hostap_config.HostapConfig.MODE_11N_PURE: { 71 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_20: 72 (61, 86), 73 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_PLUS: 74 (115, 166), 75 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_MINUS: 76 (115, 166) 77 }, 78 hostap_config.HostapConfig.MODE_11AC_MIXED: { 79 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_80: 80 (200, 400) 81 }, 82 hostap_config.HostapConfig.MODE_11AC_PURE: { 83 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_20: 84 (74, 103), 85 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_40: 86 (153, 221) 87 } 88 }, 89 perf_manager.PerfTestTypes.TEST_TYPE_TCP_TX: { 90 hostap_config.HostapConfig.MODE_11N_PURE: { 91 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_20: 92 (61, 86), 93 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_PLUS: 94 (115, 166), 95 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_MINUS: 96 (115, 166) 97 }, 98 hostap_config.HostapConfig.MODE_11AC_MIXED: { 99 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_80: 100 (200, 400) 101 }, 102 hostap_config.HostapConfig.MODE_11AC_PURE: { 103 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_20: 104 (74, 103), 105 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_40: 106 (153, 221) 107 } 108 }, 109 perf_manager.PerfTestTypes.TEST_TYPE_UDP_RX: { 110 hostap_config.HostapConfig.MODE_11N_PURE: { 111 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_20: 112 (72, 101), 113 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_PLUS: 114 (135, 195), 115 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_MINUS: 116 (135, 195) 117 }, 118 hostap_config.HostapConfig.MODE_11AC_MIXED: { 119 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_80: 120 (347, 500) 121 }, 122 hostap_config.HostapConfig.MODE_11AC_PURE: { 123 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_20: 124 (87, 121), 125 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_40: 126 (180, 260) 127 } 128 }, 129 perf_manager.PerfTestTypes.TEST_TYPE_UDP_TX: { 130 hostap_config.HostapConfig.MODE_11N_PURE: { 131 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_20: 132 (72, 101), 133 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_PLUS: 134 (135, 195), 135 hostap_config.HostapConfig.HT_CHANNEL_WIDTH_40_MINUS: 136 (135, 195) 137 }, 138 hostap_config.HostapConfig.MODE_11AC_MIXED: { 139 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_80: 140 (347, 500) 141 }, 142 hostap_config.HostapConfig.MODE_11AC_PURE: { 143 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_20: 144 (87, 121), 145 hostap_config.HostapConfig.VHT_CHANNEL_WIDTH_40: 146 (180, 260) 147 } 148 } 149} 150 151 152def get_expected_throughput_wifi(test_type, mode, channel_width): 153 """returns the expected throughput for WiFi only performance tests. 154 155 @param test_type: the PerfTestTypes test type. 156 157 @param mode: the WiFi mode such as 80211n. 158 159 @param channel_width: the channel width used in the test. 160 161 @return a tuple of two integers (must,should) of the expected throughputs in Mbps. 162 163 """ 164 if test_type in expected_throughput_wifi: 165 if mode in expected_throughput_wifi[test_type]: 166 if channel_width in expected_throughput_wifi[test_type][mode]: 167 return expected_throughput_wifi[test_type][mode][channel_width] 168 ret_mode = hostap_config.HostapConfig.VHT_NAMES[channel_width] 169 if ret_mode is None: 170 ret_mode = hostap_config.HostapConfig.HT_NAMES[channel_width] 171 raise error.TestFail( 172 'Failed to find the expected throughput from the key values, test type = %s, mode = %s, channel width = %s' 173 % (test_type, mode, ret_mode)) 174 175 176"""These are special exceptions for specific boards that define the maximum 177throughput in Mbps that we expect boards to be able to achieve. Generally, these 178boards were qualified before the advent of platform throughput requirements, and 179therefore are exempted from meeting certain requirements. Each board must be 180annotated with a bug which includes the history on why the specific expectations 181for that board. 182""" 183max_throughput_expectation_for_boards = { 184 # caroline throughput results tracked in b:200743117. 185 "caroline": { 186 perf_manager.PerfTestTypes.TEST_TYPE_UDP_RX: 200 187 }, 188 # elm throughput results tracked in b:201806809. 189 "elm": { 190 perf_manager.PerfTestTypes.TEST_TYPE_UDP_TX: 200, 191 perf_manager.PerfTestTypes.TEST_TYPE_UDP_RX: 300 192 }, 193 # eve throughput results tracked in b:200743117. 194 "eve": { 195 perf_manager.PerfTestTypes.TEST_TYPE_UDP_RX: 275 196 }, 197 # kukui throughput results tracked in b:201807413. 198 "kukui": { 199 perf_manager.PerfTestTypes.TEST_TYPE_UDP_RX: 300 200 }, 201 # nami throughput results tracked in b:200743117. 202 "nami": { 203 perf_manager.PerfTestTypes.TEST_TYPE_UDP_RX: 140 204 }, 205 # trogdor throughput results tracked in b:201807655. 206 "trogdor": { 207 perf_manager.PerfTestTypes.TEST_TYPE_UDP_RX: 250 208 }, 209 # veyron_fievel throughput results tracked in b:199946512. 210 "veyron_fievel": { 211 perf_manager.PerfTestTypes.TEST_TYPE_TCP_TX: 130, 212 perf_manager.PerfTestTypes.TEST_TYPE_TCP_RX: 70, 213 perf_manager.PerfTestTypes.TEST_TYPE_UDP_TX: 130, 214 perf_manager.PerfTestTypes.TEST_TYPE_UDP_RX: 130 215 } 216} 217 218 219def get_board_max_expectation(test_type, board_name): 220 """Returns the maximum throughput expectation for a given board in a given 221 test type, or None if the board has no exception for that test type. 222 223 @param test_type: the PerfTestTypes test type. 224 @param board_name: string name of the board, as defined by 225 SiteLinuxSystem.board field. 226 227 @return integer value for maximum throughput expectation (in Mbps) for the 228 given boardand test type, or None if the maximum is not defined. 229 """ 230 board_maximums = max_throughput_expectation_for_boards.get(board_name) 231 if not board_maximums: 232 return None 233 return board_maximums.get(test_type) 234