• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Chromium 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
5import logging
6
7from autotest_lib.client.bin import test
8from autotest_lib.client.bin import utils
9from autotest_lib.client.common_lib import error
10from autotest_lib.client.common_lib.cros.network import interface
11from autotest_lib.client.cros.networking import shill_proxy
12
13
14class network_WlanDriver(test.test):
15    """
16    Ensure wireless devices have the expected associated kernel driver.
17    """
18    version = 1
19    EXPECTED_DRIVER = {
20            'Atheros AR9280': {
21                    '3.4': 'wireless/ath/ath9k/ath9k.ko',
22                    '3.8': 'wireless-3.4/ath/ath9k/ath9k.ko',
23                    '4.14': 'wireless/ath/ath9k/ath9k.ko',
24                    '4.19': 'wireless/ath/ath9k/ath9k.ko',
25            },
26            'Atheros AR9382': {
27                    '3.4': 'wireless/ath/ath9k/ath9k.ko',
28                    '3.8': 'wireless-3.4/ath/ath9k/ath9k.ko',
29                    '4.14': 'wireless/ath/ath9k/ath9k.ko',
30                    '4.19': 'wireless/ath/ath9k/ath9k.ko',
31            },
32            'Intel 7260': {
33                    '3.8': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
34                    '3.14': 'wireless-3.8/iwl7000/iwlwifi/iwlwifi.ko',
35                    '4.4': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
36                    '4.14': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
37                    '4.19': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
38            },
39            'Intel 7265': {
40                    '3.8': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
41                    '3.14': 'wireless-3.8/iwl7000/iwlwifi/iwlwifi.ko',
42                    '3.18': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
43                    '4.4': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
44                    '4.14': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
45                    '4.19': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
46            },
47            'Intel 9000': {
48                    '4.14': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
49                    '4.19': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
50            },
51            'Intel 9260': {
52                    '4.4': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
53                    '4.14': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
54                    '4.19': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
55            },
56            'Intel 22260': {
57                    '4.4': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
58                    '4.14': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
59                    '4.19': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
60            },
61            'Intel 22560': {
62                    '4.19': 'wireless/iwl7000/iwlwifi/iwlwifi.ko',
63            },
64            'Atheros AR9462': {
65                    '3.4': 'wireless/ath/ath9k_btcoex/ath9k_btcoex.ko',
66                    '3.8': 'wireless-3.4/ath/ath9k_btcoex/ath9k_btcoex.ko',
67                    '4.14': 'wireless/ath/ath9k/ath9k.ko',
68                    '4.19': 'wireless/ath/ath9k/ath9k.ko',
69            },
70            'Qualcomm Atheros QCA6174': {
71                    '4.4': 'wireless/ar10k/ath/ath10k/ath10k_pci.ko',
72                    '4.14': 'wireless/ath/ath10k/ath10k_pci.ko',
73                    '4.19': 'wireless/ath/ath10k/ath10k_pci.ko',
74            },
75            'Qualcomm Atheros QCA6174 SDIO': {
76                    '4.19': 'wireless/ath/ath10k/ath10k_sdio.ko',
77            },
78            'Qualcomm WCN3990': {
79                    '4.14': 'wireless/ath/ath10k/ath10k_snoc.ko',
80                    '4.19': 'wireless/ath/ath10k/ath10k_snoc.ko',
81            },
82            'Marvell 88W8797 SDIO': {
83                    '3.4': 'wireless/mwifiex/mwifiex_sdio.ko',
84                    '3.8': 'wireless-3.4/mwifiex/mwifiex_sdio.ko',
85                    '4.14': 'wireless/marvell/mwifiex/mwifiex_sdio.ko',
86                    '4.19': 'wireless/marvell/mwifiex/mwifiex_sdio.ko',
87            },
88            'Marvell 88W8887 SDIO': {
89                     '3.14': 'wireless-3.8/mwifiex/mwifiex_sdio.ko',
90                     '4.14': 'wireless/marvell/mwifiex/mwifiex_sdio.ko',
91                     '4.19': 'wireless/marvell/mwifiex/mwifiex_sdio.ko',
92            },
93            'Marvell 88W8897 PCIE': {
94                     '3.8': 'wireless/mwifiex/mwifiex_pcie.ko',
95                     '3.10': 'wireless-3.8/mwifiex/mwifiex_pcie.ko',
96                     '4.14': 'wireless/marvell/mwifiex/mwifiex_pcie.ko',
97                     '4.19': 'wireless/marvell/mwifiex/mwifiex_pcie.ko',
98            },
99            'Marvell 88W8897 SDIO': {
100                     '3.8': 'wireless/mwifiex/mwifiex_sdio.ko',
101                     '3.10': 'wireless-3.8/mwifiex/mwifiex_sdio.ko',
102                     '3.14': 'wireless-3.8/mwifiex/mwifiex_sdio.ko',
103                     '3.18': 'wireless/mwifiex/mwifiex_sdio.ko',
104                     '4.14': 'wireless/marvell/mwifiex/mwifiex_sdio.ko',
105                     '4.19': 'wireless/marvell/mwifiex/mwifiex_sdio.ko',
106            },
107            'Broadcom BCM4354 SDIO': {
108                     '3.8': 'wireless/brcm80211/brcmfmac/brcmfmac.ko',
109                     '3.14': 'wireless-3.8/brcm80211/brcmfmac/brcmfmac.ko',
110                     '4.14': 'wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko',
111                     '4.19': 'wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko',
112            },
113            'Broadcom BCM4356 PCIE': {
114                     '3.10': 'wireless-3.8/brcm80211/brcmfmac/brcmfmac.ko',
115                     '4.14': 'wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko',
116                     '4.19': 'wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko',
117            },
118            'Marvell 88W8997 PCIE': {
119                     '4.4': 'wireless/marvell/mwifiex/mwifiex_pcie.ko',
120                     '4.14': 'wireless/marvell/mwifiex/mwifiex_pcie.ko',
121                     '4.19': 'wireless/marvell/mwifiex/mwifiex_pcie.ko',
122            },
123            'Realtek 8822C PCIE': {
124                    '4.14': 'wireless/realtek/rtw88/rtwpci.ko',
125            },
126    }
127    EXCEPTION_BOARDS = [
128            # Exhibits very similar symptoms to http://crbug.com/693724,
129            # b/65858242, b/36264732.
130            'nyan_kitty',
131    ]
132
133    def run_once(self, forgive_flaky=False):
134        """Test main loop"""
135        # full_revision looks like "3.4.0".
136        full_revision = utils.system_output('uname -r')
137        # base_revision looks like "3.4".
138        base_revision = '.'.join(full_revision.split('.')[:2])
139        logging.info('Kernel base is %s', base_revision)
140
141        proxy = shill_proxy.ShillProxy()
142
143        uninit = proxy.get_proxy().get_dbus_property(proxy.manager,
144                 shill_proxy.ShillProxy.MANAGER_PROPERTY_UNINITIALIZED_TECHNOLOGIES)
145        logging.info("Uninitialized technologies: %s", uninit)
146        # If Wifi support is not enabled for shill, it will be uninitialized.
147        # Don't fail the test if Wifi was intentionally disabled.
148        if "wifi" in uninit:
149            raise error.TestNAError('Wireless support not enabled')
150
151        wlan_ifs = [nic for nic in interface.get_interfaces()
152                        if nic.is_wifi_device()]
153        if wlan_ifs:
154            net_if = wlan_ifs[0]
155        else:
156            board = utils.get_board()
157            if forgive_flaky and board in self.EXCEPTION_BOARDS:
158                logging.error('Found no recognized wirelss device; '
159                              'forgiven for flaky board %s.', board)
160                # "Pass"; apparently error.TestWarn() is considered a failure.
161                return
162            else:
163                raise error.TestFail('Found no recognized wireless device')
164
165        # Some systems (e.g., moblab) might blacklist certain devices. We don't
166        # rely on shill for most of this test, but it can be a helpful clue if
167        # we see shill barfing.
168        device_obj = proxy.find_object('Device',
169                                       {'Type': proxy.TECHNOLOGY_WIFI})
170        if device_obj is None:
171            logging.warning("Shill couldn't find wireless device; "
172                            "did someone blacklist it?")
173
174        device_description = net_if.device_description
175        if not device_description:
176            raise error.TestFail('Device %s is not supported' % net_if.name)
177
178        device_name, module_path = device_description
179        logging.info('Device name %s, module path %s', device_name, module_path)
180        if not device_name in self.EXPECTED_DRIVER:
181            raise error.TestFail('Unexpected device name %s' %
182                                 device_name)
183
184        if not base_revision in self.EXPECTED_DRIVER[device_name]:
185            raise error.TestNAError('Unexpected base kernel revision %s with device name %s' %
186                                    (base_revision, device_name))
187
188        expected_driver = self.EXPECTED_DRIVER[device_name][base_revision]
189        if module_path != expected_driver:
190            raise error.TestFail('Unexpected driver for %s/%s; got %s but expected %s' %
191                                 (base_revision, device_name,
192                                  module_path, expected_driver))
193