Home | History | Annotate | Download | only in network_WiFi_RegDomain
      1 # Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 AUTHOR = 'pstew, quiche'
      6 NAME = 'network_WiFi_RegDomain'
      7 TIME = 'MEDIUM'
      8 TEST_TYPE = 'Server'
      9 ATTRIBUTES = "suite:wifi_matfunc_bcm4356"
     10 SUITE = ('wifi_matfunc_bcm4356')
     11 DEPENDENCIES = 'wificell'
     12 
     13 DOC = """
     14 This test verifies that a DUT can, or cannot, connect on given
     15 channels, in given regions.
     16 
     17 This test exercises:
     18 - parsing of VPD data
     19 - mapping of VPD data to ISO country code
     20 - communication of country code from user-space to kernel
     21 - communication of country code / rules from kernel to driver
     22 - communication of country code / rules from driver to firmware
     23 
     24 This test is an aid to identify changes in behavior. It does not
     25 provide advice on regulatory requirements.
     26 """
     27 
     28 import logging
     29 
     30 from autotest_lib.client.common_lib import error
     31 from autotest_lib.client.common_lib.cros.network import interface
     32 
     33 
     34 # When adding a negative rule ('expect': 'no-connect'), be sure to add
     35 # a case with a positive rule ('expect': 'connect', or 'expect':
     36 # 'passive-scan'). Otherwise, we haven't ruled out the possibility
     37 # that the test itself prevents the DUT from connecting.
     38 #
     39 # Note:
     40 # - 'passive-scan' implies 'connect'
     41 # - 'no-connect' implies no probes
     42 DEVTYPE_TO_REGION_INFOS = {
     43     # TODO(quiche): Add ath9k expectations for channels 52 and 120.
     44     'ath9k':
     45         [
     46          # This first set of expectations is based on
     47          # ath_world_regdom_63_65 in ath/regd.c. We may need to change
     48          # or remove these, if it turns out that some DUTs have other
     49          # ath9k SKUs.
     50          {'region_name': '',
     51           'country_code': '00',
     52           'channel_infos': [
     53               {'chnum': 13, 'expect': 'passive-scan'},
     54               {'chnum': 36, 'expect': 'passive-scan'},
     55               {'chnum': 149, 'expect': 'passive-scan'}]},
     56          # Many of the 'passive-scan' expectations for the remaining
     57          # regions seem to arise from ath_world_regdom_63_65. (Or, at
     58          # least, not all of the passive scanning expectations can be
     59          # attributed to data in wireless-regdb.)
     60          {'region_name': 'ar',
     61           'country_code': 'AR',
     62           'channel_infos': [
     63               {'chnum': 13, 'expect': 'passive-scan'},
     64               {'chnum': 36, 'expect': 'passive-scan'},
     65               {'chnum': 149, 'expect': 'passive-scan'}]},
     66          {'region_name': 'id',
     67           'country_code': 'ID',
     68           'channel_infos': [
     69               {'chnum': 13, 'expect': 'passive-scan'},
     70               {'chnum': 36, 'expect': 'no-connect'},
     71               {'chnum': 149, 'expect': 'passive-scan'}]},
     72          {'region_name': 'ru',
     73           'country_code': 'RU',
     74           'channel_infos': [
     75               {'chnum': 13, 'expect': 'passive-scan'},
     76               {'chnum': 36, 'expect': 'passive-scan'},
     77               {'chnum': 149, 'expect': 'passive-scan'}]},
     78          {'region_name': 'us',
     79           'country_code': 'US',
     80           'channel_infos': [
     81               {'chnum': 13, 'expect': 'no-connect'},
     82               {'chnum': 36, 'expect': 'passive-scan'},
     83               {'chnum': 149, 'expect': 'passive-scan'}]}],
     84     'bcm435x':
     85         [{'region_name': 'ca.hybrid',  # <country code>.<extra>
     86           'country_code': 'CA',
     87           'channel_infos': [
     88               {'chnum': 13, 'expect': 'no-connect'},
     89               {'chnum': 36, 'expect': 'connect'},
     90               {'chnum': 52, 'expect': 'passive-scan'},
     91               {'chnum': 120, 'expect': 'passive-scan'},
     92               {'chnum': 149, 'expect': 'connect'},
     93               {'chnum': 165, 'expect': 'connect'}]},
     94          {'region_name': 'nordic',  # virtual set
     95           'country_code': 'SE',
     96           'channel_infos': [
     97               {'chnum': 13, 'expect': 'connect'},
     98               {'chnum': 36, 'expect': 'connect'},
     99               {'chnum': 52, 'expect': 'passive-scan'},
    100               {'chnum': 120, 'expect': 'passive-scan'},
    101               {'chnum': 149, 'expect': 'no-connect'},
    102               {'chnum': 165, 'expect': 'no-connect'}]},
    103          {'region_name': 'us',
    104           'country_code': 'US',
    105           'channel_infos': [
    106               {'chnum': 13, 'expect': 'no-connect'},
    107               {'chnum': 36, 'expect': 'connect'},
    108               {'chnum': 52, 'expect': 'passive-scan'},
    109               {'chnum': 120, 'expect': 'no-connect'},
    110               {'chnum': 149, 'expect': 'connect'},
    111               {'chnum': 165, 'expect': 'connect'}]}],
    112     'intel_wp2':
    113     # TODO(quiche): Add wp2 expectations for channels 52 and 120. If
    114     # those expectations match the (to-be-added) expectations for
    115     # ath9k, then collapse both configs into a 'cfg80211' config.
    116         [
    117          {'region_name': '',
    118           'country_code': '00',
    119           'channel_infos': [
    120               {'chnum': 13, 'expect': 'passive-scan'},
    121               {'chnum': 36, 'expect': 'passive-scan'},
    122               {'chnum': 149, 'expect': 'passive-scan'}]},
    123          # Many of the 'passive-scan' expectations seem to follow from
    124          # the initial world rules above. (Or, at least, not all of
    125          # the passive scanning expectations can be attributed to
    126          # country-speific data in wireless-regdb. We haven't
    127          # investigated if the 'passive-scan' expectations are due to
    128          # rules in the driver.)
    129          {'region_name': 'ar',
    130           'country_code': 'AR',
    131           'channel_infos': [
    132               {'chnum': 13, 'expect': 'passive-scan'},
    133               {'chnum': 36, 'expect': 'passive-scan'},
    134               {'chnum': 149, 'expect': 'passive-scan'}]},
    135          {'region_name': 'id',
    136           'country_code': 'ID',
    137           'channel_infos': [
    138               {'chnum': 13, 'expect': 'passive-scan'},
    139               {'chnum': 36, 'expect': 'no-connect'},
    140               {'chnum': 149, 'expect': 'passive-scan'}]},
    141          {'region_name': 'ru',
    142           'country_code': 'RU',
    143           'channel_infos': [
    144               {'chnum': 13, 'expect': 'passive-scan'},
    145               {'chnum': 36, 'expect': 'passive-scan'},
    146               {'chnum': 149, 'expect': 'passive-scan'}]},
    147          {'region_name': 'us',
    148           'country_code': 'US',
    149           'channel_infos': [
    150               {'chnum': 13, 'expect': 'no-connect'},
    151               {'chnum': 36, 'expect': 'passive-scan'},
    152               {'chnum': 149, 'expect': 'passive-scan'}]}]}
    153 WLAN_DEV = 'wlan0'
    154 
    155 
    156 def run(machine):
    157     host = hosts.create_host(machine)
    158     wlan_info = interface.Interface(WLAN_DEV, host=host).device_description
    159     if not wlan_info:
    160         raise error.TestFail('Couldn\'t find the WiFi device.')
    161     if wlan_info.name in (
    162         interface.NAME_ATHEROS_AR9280,
    163         interface.NAME_ATHEROS_AR9382,
    164         interface.NAME_ATHEROS_AR9462):
    165             devtype = 'ath9k'
    166     elif wlan_info.name in (
    167         interface.NAME_BROADCOM_BCM4354_SDIO,
    168         interface.NAME_BROADCOM_BCM4356_PCIE):
    169             devtype = 'bcm435x'
    170     elif wlan_info.name in (
    171         interface.NAME_INTEL_7260,
    172         interface.NAME_INTEL_7265):
    173             devtype = 'intel_wp2'
    174     else:
    175         raise error.TestNAError(
    176             'Unrecognized WiFi chip |%s|.' % wlan_info.name)
    177 
    178     logging.debug('Running test with devtype=%s', devtype)
    179     for region_info in DEVTYPE_TO_REGION_INFOS[devtype]:
    180         # Use a fresh |host| every time, as WiFiTestContextManager
    181         # cleans up |host| on context exit.
    182         host = hosts.create_host(machine)
    183         job.run_test(
    184             'network_WiFi_RegDomain',
    185             tag=region_info['region_name'] or 'default',
    186             host=host,
    187             raw_cmdline_args=args,
    188             additional_params=region_info)
    189 
    190 
    191 parallel_simple(run, machines)
    192