autotest (wifi): filter out single-stream PHYs

Because our client devices are multi-stream (2x2), we want
to ensure that we only test against multi-stream radios
(2x2, or better) on the other end. To do so, filter out any
single-stream PHYs on the AP side.

BUG=chromium:495880
TEST=manual

Manual test
-----------
Ran network_WiFi_SimpleConnect.wifi_check11a on a device that
had both single-stream, and multi-stream radios. Saw the log message
indicating that the WiFi test framework had filtered out the
single-stream radio. Did not see any log message filtering out the
multi-stream radio. Also, the check11a test passed.

Change-Id: I0e6248ad92d2c3d667729a454de0b223a3cb22d1
Reviewed-on: https://chromium-review.googlesource.com/277150
Trybot-Ready: mukesh agrawal <[email protected]>
Tested-by: mukesh agrawal <[email protected]>
Reviewed-by: Paul Stewart <[email protected]>
Commit-Queue: mukesh agrawal <[email protected]>
diff --git a/server/site_linux_system.py b/server/site_linux_system.py
index 997a0c5..1fd307e 100644
--- a/server/site_linux_system.py
+++ b/server/site_linux_system.py
@@ -37,6 +37,7 @@
     CAPABILITY_TDLS = 'tdls'
     CAPABILITY_VHT = 'vht'
     BRIDGE_INTERFACE_NAME = 'br0'
+    MIN_SPATIAL_STREAMS = 2
 
 
     @property
@@ -106,6 +107,15 @@
         return self._phy_list
 
 
+    def _phy_by_name(self, phy_name):
+        """@return IwPhy for PHY with name |phy_name|, or None."""
+        for phy in self._phy_list:
+            if phy.name == phy_name:
+                return phy
+        else:
+            return None
+
+
     def _get_phy_info(self):
         """Get information about WiFi devices.
 
@@ -293,7 +303,17 @@
         @return string name of phy to use.
 
         """
-        phys = self.phys_for_frequency[frequency]
+        phys = []
+        for phy in self.phys_for_frequency[frequency]:
+            phy_obj = self._phy_by_name(phy)
+            spatial_streams = min(phy_obj.avail_rx_antennas,
+                                  phy_obj.avail_tx_antennas)
+            if spatial_streams >= self.MIN_SPATIAL_STREAMS:
+                phys.append(phy)
+            else:
+                logging.debug(
+                    'Filtered out PHY due to spatial stream limit: %s (%d)',
+                    phy, spatial_streams)
 
         busy_phys = set(net_dev.phy for net_dev in self._wlanifs_in_use)
         idle_phys = [phy for phy in phys if phy not in busy_phys]