Make iwm(4) set various scan command flags just like how iwlwifi sets them.
authorstsp <stsp@openbsd.org>
Fri, 9 Jul 2021 11:24:55 +0000 (11:24 +0000)
committerstsp <stsp@openbsd.org>
Fri, 9 Jul 2021 11:24:55 +0000 (11:24 +0000)
Discrepancies found while investigating an issue related to active scanning.

sys/dev/pci/if_iwm.c
sys/dev/pci/if_iwmreg.h

index 000b7bf..615d9a4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: if_iwm.c,v 1.349 2021/07/09 11:21:31 stsp Exp $       */
+/*     $OpenBSD: if_iwm.c,v 1.350 2021/07/09 11:24:55 stsp Exp $       */
 
 /*
  * Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
@@ -7305,7 +7305,9 @@ iwm_lmac_scan(struct iwm_softc *sc, int bgscan)
                req->scan_flags |=
                    htole32(IWM_LMAC_SCAN_FLAG_PRE_CONNECTION);
        if (isset(sc->sc_enabled_capa, 
-           IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT))
+           IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT) &&
+           isset(sc->sc_enabled_capa, 
+           IWM_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT))
                req->scan_flags |= htole32(IWM_LMAC_SCAN_FLAGS_RRM_ENABLED);
 
        req->flags = htole32(IWM_PHY_BAND_24);
@@ -7565,6 +7567,8 @@ iwm_umac_scan(struct iwm_softc *sc, int bgscan)
                req->v1.passive_dwell = 110;
                req->v1.fragmented_dwell = 44;
                req->v1.extended_dwell = 90;
+
+               req->v1.scan_priority = htole32(IWM_SCAN_PRIORITY_HIGH);
        }
 
        if (bgscan) {
@@ -7583,7 +7587,6 @@ iwm_umac_scan(struct iwm_softc *sc, int bgscan)
                }
        }
 
-       req->v1.scan_priority = htole32(IWM_SCAN_PRIORITY_HIGH);
        req->ooc_priority = htole32(IWM_SCAN_PRIORITY_HIGH);
 
        cmd_data = iwm_get_scan_req_umac_data(sc, req);
@@ -7601,6 +7604,10 @@ iwm_umac_scan(struct iwm_softc *sc, int bgscan)
 
        req->general_flags = htole32(IWM_UMAC_SCAN_GEN_FLAGS_PASS_ALL |
            IWM_UMAC_SCAN_GEN_FLAGS_ITER_COMPLETE);
+       if (isset(sc->sc_ucode_api, IWM_UCODE_TLV_API_ADAPTIVE_DWELL_V2)) {
+               req->v8.general_flags2 =
+                       IWM_UMAC_SCAN_GEN_FLAGS2_ALLOW_CHNL_REORDER;
+       }
 
        /* Check if we're doing an active directed scan. */
        if (ic->ic_des_esslen != 0) {
@@ -7621,7 +7628,9 @@ iwm_umac_scan(struct iwm_softc *sc, int bgscan)
                req->general_flags |= htole32(IWM_UMAC_SCAN_GEN_FLAGS_PASSIVE);
 
        if (isset(sc->sc_enabled_capa, 
-           IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT))
+           IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT) &&
+           isset(sc->sc_enabled_capa, 
+           IWM_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT))
                req->general_flags |=
                    htole32(IWM_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED);
 
index e3e9319..ce7898f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: if_iwmreg.h,v 1.63 2021/07/08 17:14:08 stsp Exp $     */
+/*     $OpenBSD: if_iwmreg.h,v 1.64 2021/07/09 11:24:55 stsp Exp $     */
 
 /******************************************************************************
  *
@@ -5732,6 +5732,16 @@ struct iwm_scan_config {
 #define IWM_UMAC_SCAN_GEN_FLAGS_MAX_CHNL_TIME          (1 << 14)
 #define IWM_UMAC_SCAN_GEN_FLAGS_PROB_REQ_HIGH_TX_RATE  (1 << 15)
 
+/**
+ * UMAC scan general flags #2
+ * @IWM_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL: Whether to send a complete
+ *     notification per channel or not.
+ * @IWM_UMAC_SCAN_GEN_FLAGS2_ALLOW_CHNL_REORDER: Whether to allow channel
+ *     reorder optimization or not.
+ */
+#define IWM_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL                (1 << 0)
+#define IWM_UMAC_SCAN_GEN_FLAGS2_ALLOW_CHNL_REORDER    (1 << 1)
+
 /**
  * struct iwm_scan_channel_cfg_umac
  * @flags:             bitmap - 0-19:  directed scan to i'th ssid.