Index: src/drivers/driver_wext.c
===================================================================
--- src/drivers/driver_wext.c.orig
+++ src/drivers/driver_wext.c
@@ -1901,19 +1901,26 @@ int wpa_driver_wext_associate(void *priv
 	 * SIOCSIWENCODE here.
 	 */
 	if (drv->auth_alg_fallback &&
-	    wpa_driver_wext_auth_alg_fallback(drv, params) < 0)
+	    wpa_driver_wext_auth_alg_fallback(drv, params) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because auth_alg_fallback failed", __FUNCTION__);
 		ret = -1;
+	}
 
 	if (!params->bssid &&
-	    wpa_driver_wext_set_bssid(drv, NULL) < 0)
+	    wpa_driver_wext_set_bssid(drv, NULL) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_bssid failed", __FUNCTION__);
 		ret = -1;
+	}
 
 	/* TODO: should consider getting wpa version and cipher/key_mgmt suites
 	 * from configuration, not from here, where only the selected suite is
 	 * available */
 	if (wpa_driver_wext_set_gen_ie(drv, params->wpa_ie, params->wpa_ie_len)
-	    < 0)
+	    < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_gen_ie failed", __FUNCTION__);
 		ret = -1;
+	}
+
 	if (params->wpa_ie == NULL || params->wpa_ie_len == 0)
 		value = IW_AUTH_WPA_VERSION_DISABLED;
 	else if (params->wpa_ie[0] == WLAN_EID_RSN)
@@ -1921,27 +1928,41 @@ int wpa_driver_wext_associate(void *priv
 	else
 		value = IW_AUTH_WPA_VERSION_WPA;
 	if (wpa_driver_wext_set_auth_param(drv,
-					   IW_AUTH_WPA_VERSION, value) < 0)
+					   IW_AUTH_WPA_VERSION, value) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_auth_param(WPA_VERSION) failed", __FUNCTION__);
 		ret = -1;
+	}
+
 	value = wpa_driver_wext_cipher2wext(params->pairwise_suite);
 	if (wpa_driver_wext_set_auth_param(drv,
-					   IW_AUTH_CIPHER_PAIRWISE, value) < 0)
+					   IW_AUTH_CIPHER_PAIRWISE, value) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_auth_param(CIPHER_PAIRWISE) failed", __FUNCTION__);
 		ret = -1;
+	}
+
 	value = wpa_driver_wext_cipher2wext(params->group_suite);
 	if (wpa_driver_wext_set_auth_param(drv,
-					   IW_AUTH_CIPHER_GROUP, value) < 0)
+					   IW_AUTH_CIPHER_GROUP, value) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_auth_param(CIPHER_GROUP) failed", __FUNCTION__);
 		ret = -1;
+	}
+
 	value = wpa_driver_wext_keymgmt2wext(params->key_mgmt_suite);
 	if (wpa_driver_wext_set_auth_param(drv,
-					   IW_AUTH_KEY_MGMT, value) < 0)
+					   IW_AUTH_KEY_MGMT, value) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_auth_param(KEY_MGMT) failed", __FUNCTION__);
 		ret = -1;
+	}
+
 	value = params->key_mgmt_suite != KEY_MGMT_NONE ||
 		params->pairwise_suite != CIPHER_NONE ||
 		params->group_suite != CIPHER_NONE ||
 		params->wpa_ie_len;
 	if (wpa_driver_wext_set_auth_param(drv,
-					   IW_AUTH_PRIVACY_INVOKED, value) < 0)
+					   IW_AUTH_PRIVACY_INVOKED, value) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_auth_param(PRIVACY_INVOKED) failed", __FUNCTION__);
 		ret = -1;
+	}
 
 	/* Allow unencrypted EAPOL messages even if pairwise keys are set when
 	 * not using WPA. IEEE 802.1X specifies that these frames are not
@@ -1952,12 +1973,18 @@ int wpa_driver_wext_associate(void *priv
 	else
 		allow_unencrypted_eapol = 1;
 
-	if (wpa_driver_wext_set_psk(drv, params->psk) < 0)
+	if (wpa_driver_wext_set_psk(drv, params->psk) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_psk failed", __FUNCTION__);
 		ret = -1;
+	}
+
 	if (wpa_driver_wext_set_auth_param(drv,
 					   IW_AUTH_RX_UNENCRYPTED_EAPOL,
-					   allow_unencrypted_eapol) < 0)
+					   allow_unencrypted_eapol) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_auth_param(RX_UNENCRYPTED_EAPOL) failed", __FUNCTION__);
 		ret = -1;
+	}
+
 #ifdef CONFIG_IEEE80211W
 	switch (params->mgmt_frame_protection) {
 	case NO_MGMT_FRAME_PROTECTION:
@@ -1970,17 +1997,25 @@ int wpa_driver_wext_associate(void *priv
 		value = IW_AUTH_MFP_REQUIRED;
 		break;
 	};
-	if (wpa_driver_wext_set_auth_param(drv, IW_AUTH_MFP, value) < 0)
+	if (wpa_driver_wext_set_auth_param(drv, IW_AUTH_MFP, value) < 0) {
+	        wpa_printf(MSG_DEBUG, "%s: assoc failed because set_auth_param(IW_AUTH_MFP) failed", __FUNCTION__);
 		ret = -1;
+	}
 #endif /* CONFIG_IEEE80211W */
-	if (params->freq && wpa_driver_wext_set_freq(drv, params->freq) < 0)
+	if (params->freq && wpa_driver_wext_set_freq(drv, params->freq) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_freq failed", __FUNCTION__);
 		ret = -1;
+	}
 	if (!drv->cfg80211 &&
-	    wpa_driver_wext_set_ssid(drv, params->ssid, params->ssid_len) < 0)
+	    wpa_driver_wext_set_ssid(drv, params->ssid, params->ssid_len) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_ssid failed", __FUNCTION__);
 		ret = -1;
+	}
 	if (params->bssid &&
-	    wpa_driver_wext_set_bssid(drv, params->bssid) < 0)
+	    wpa_driver_wext_set_bssid(drv, params->bssid) < 0) {
+		wpa_printf(MSG_DEBUG, "%s: assoc failed because set_bssid failed", __FUNCTION__);
 		ret = -1;
+	}
 	if (drv->cfg80211 &&
 	    wpa_driver_wext_set_ssid(drv, params->ssid, params->ssid_len) < 0)
 		ret = -1;
@@ -2008,6 +2043,10 @@ static int wpa_driver_wext_set_auth_alg(
 	res = wpa_driver_wext_set_auth_param(drv, IW_AUTH_80211_AUTH_ALG,
 					     algs);
 	drv->auth_alg_fallback = res == -2;
+
+	if (res == -2)
+		wpa_printf(MSG_DEBUG, "%s: falling back to ENCODE for AUTH", __FUNCTION__);
+
 	return res;
 }
 
