瀏覽代碼

qcacld-3.0: Add new diag event to capture connection stats

Add diag event and its structure to log various connection statistics
after the connection has been made.

Change-Id: I3572cd9230d89e2d4154fd43579c258a2e2bdb58
CRs-Fixed: 2208503
Krunal Soni 7 年之前
父節點
當前提交
4b6c946459
共有 2 個文件被更改,包括 294 次插入29 次删除
  1. 242 4
      core/sme/src/csr/csr_api_roam.c
  2. 52 25
      core/sme/src/csr/csr_inside_api.h

+ 242 - 4
core/sme/src/csr/csr_api_roam.c

@@ -178,11 +178,11 @@ static inline QDF_STATUS csr_sae_callback(tpAniSirGlobal mac_ctx,
 
 
 #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
-int diag_auth_type_from_csr_type(eCsrAuthType authType)
+enum mgmt_auth_type diag_auth_type_from_csr_type(eCsrAuthType authtype)
 {
 	int n = AUTH_OPEN;
 
-	switch (authType) {
+	switch (authtype) {
 	case eCSR_AUTH_TYPE_SHARED_KEY:
 		n = AUTH_SHARED;
 		break;
@@ -218,11 +218,11 @@ int diag_auth_type_from_csr_type(eCsrAuthType authType)
 	return n;
 }
 
-int diag_enc_type_from_csr_type(eCsrEncryptionType encType)
+enum mgmt_encrypt_type diag_enc_type_from_csr_type(eCsrEncryptionType enctype)
 {
 	int n = ENC_MODE_OPEN;
 
-	switch (encType) {
+	switch (enctype) {
 	case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
 	case eCSR_ENCRYPT_TYPE_WEP40:
 		n = ENC_MODE_WEP40;
@@ -253,7 +253,101 @@ int diag_enc_type_from_csr_type(eCsrEncryptionType encType)
 	}
 	return n;
 }
+
+enum mgmt_dot11_mode
+diag_dot11_mode_from_csr_type(enum csr_cfgdot11mode dot11mode)
+{
+	switch (dot11mode) {
+	case eCSR_CFG_DOT11_MODE_ABG:
+		return DOT11_MODE_ABG;
+	case eCSR_CFG_DOT11_MODE_11A:
+		return DOT11_MODE_11A;
+	case eCSR_CFG_DOT11_MODE_11B:
+		return DOT11_MODE_11B;
+	case eCSR_CFG_DOT11_MODE_11G:
+		return DOT11_MODE_11G;
+	case eCSR_CFG_DOT11_MODE_11N:
+		return DOT11_MODE_11N;
+	case eCSR_CFG_DOT11_MODE_11AC:
+		return DOT11_MODE_11AC;
+	case eCSR_CFG_DOT11_MODE_11G_ONLY:
+		return DOT11_MODE_11G_ONLY;
+	case eCSR_CFG_DOT11_MODE_11N_ONLY:
+		return DOT11_MODE_11N_ONLY;
+	case eCSR_CFG_DOT11_MODE_11AC_ONLY:
+		return DOT11_MODE_11AC_ONLY;
+	case eCSR_CFG_DOT11_MODE_AUTO:
+		return DOT11_MODE_AUTO;
+	case eCSR_CFG_DOT11_MODE_11AX:
+		return DOT11_MODE_11AX;
+	case eCSR_CFG_DOT11_MODE_11AX_ONLY:
+		return DOT11_MODE_11AX_ONLY;
+	default:
+		return DOT11_MODE_MAX;
+	}
+}
+
+enum mgmt_ch_width diag_ch_width_from_csr_type(enum phy_ch_width ch_width)
+{
+	switch (ch_width) {
+	case CH_WIDTH_20MHZ:
+		return BW_20MHZ;
+	case CH_WIDTH_40MHZ:
+		return BW_40MHZ;
+	case CH_WIDTH_80MHZ:
+		return BW_80MHZ;
+	case CH_WIDTH_160MHZ:
+		return BW_160MHZ;
+	case CH_WIDTH_80P80MHZ:
+		return BW_80P80MHZ;
+	case CH_WIDTH_5MHZ:
+		return BW_5MHZ;
+	case CH_WIDTH_10MHZ:
+		return BW_10MHZ;
+	default:
+		return BW_MAX;
+	}
+}
+
+enum mgmt_bss_type diag_persona_from_csr_type(enum QDF_OPMODE persona)
+{
+	switch (persona) {
+	case QDF_STA_MODE:
+		return STA_PERSONA;
+	case QDF_SAP_MODE:
+		return SAP_PERSONA;
+	case QDF_P2P_CLIENT_MODE:
+		return P2P_CLIENT_PERSONA;
+	case QDF_P2P_GO_MODE:
+		return P2P_GO_PERSONA;
+	case QDF_FTM_MODE:
+		return FTM_PERSONA;
+	case QDF_IBSS_MODE:
+		return IBSS_PERSONA;
+	case QDF_MONITOR_MODE:
+		return MONITOR_PERSONA;
+	case QDF_P2P_DEVICE_MODE:
+		return P2P_DEVICE_PERSONA;
+	case QDF_OCB_MODE:
+		return OCB_PERSONA;
+	case QDF_EPPING_MODE:
+		return EPPING_PERSONA;
+	case QDF_QVIT_MODE:
+		return QVIT_PERSONA;
+	case QDF_NDI_MODE:
+		return NDI_PERSONA;
+	case QDF_WDS_MODE:
+		return WDS_PERSONA;
+	case QDF_BTAMP_MODE:
+		return BTAMP_PERSONA;
+	case QDF_AHDEMO_MODE:
+		return AHDEMO_PERSONA;
+	default:
+		return MAX_PERSONA;
+	}
+}
 #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */
+
 static const uint8_t
 csr_start_ibss_channels50[CSR_NUM_IBSS_START_CHAN_50] = { 36, 44, 52, 56, 140 };
 static const uint8_t
@@ -3920,6 +4014,148 @@ static void csr_roam_populate_channels(tDot11fBeaconIEs *beacon_ies,
 	}
 }
 
+#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
+static const char *csr_get_ch_width_str(uint8_t ch_width)
+{
+	switch (ch_width) {
+	CASE_RETURN_STRING(BW_20MHZ);
+	CASE_RETURN_STRING(BW_40MHZ);
+	CASE_RETURN_STRING(BW_80MHZ);
+	CASE_RETURN_STRING(BW_160MHZ);
+	CASE_RETURN_STRING(BW_80P80MHZ);
+	CASE_RETURN_STRING(BW_5MHZ);
+	CASE_RETURN_STRING(BW_10MHZ);
+	default:
+		return "Unknown";
+	}
+}
+
+static const char *csr_get_dot11_mode_str(enum csr_cfgdot11mode dot11mode)
+{
+	switch (dot11mode) {
+	CASE_RETURN_STRING(DOT11_MODE_AUTO);
+	CASE_RETURN_STRING(DOT11_MODE_ABG);
+	CASE_RETURN_STRING(DOT11_MODE_11A);
+	CASE_RETURN_STRING(DOT11_MODE_11B);
+	CASE_RETURN_STRING(DOT11_MODE_11G);
+	CASE_RETURN_STRING(DOT11_MODE_11N);
+	CASE_RETURN_STRING(DOT11_MODE_11AC);
+	CASE_RETURN_STRING(DOT11_MODE_11G_ONLY);
+	CASE_RETURN_STRING(DOT11_MODE_11N_ONLY);
+	CASE_RETURN_STRING(DOT11_MODE_11AC_ONLY);
+	CASE_RETURN_STRING(DOT11_MODE_11AX);
+	CASE_RETURN_STRING(DOT11_MODE_11AX_ONLY);
+	default:
+		return "Unknown";
+	}
+}
+
+static const char *csr_get_auth_type_str(uint8_t auth_type)
+{
+	switch (auth_type) {
+	CASE_RETURN_STRING(AUTH_OPEN);
+	CASE_RETURN_STRING(AUTH_SHARED);
+	CASE_RETURN_STRING(AUTH_WPA_EAP);
+	CASE_RETURN_STRING(AUTH_WPA_PSK);
+	CASE_RETURN_STRING(AUTH_WPA2_EAP);
+	CASE_RETURN_STRING(AUTH_WPA2_PSK);
+	CASE_RETURN_STRING(AUTH_WAPI_CERT);
+	CASE_RETURN_STRING(AUTH_WAPI_PSK);
+	default:
+		return "Unknown";
+	}
+}
+
+static const char *csr_get_encr_type_str(uint8_t encr_type)
+{
+	switch (encr_type) {
+	CASE_RETURN_STRING(ENC_MODE_OPEN);
+	CASE_RETURN_STRING(ENC_MODE_WEP40);
+	CASE_RETURN_STRING(ENC_MODE_WEP104);
+	CASE_RETURN_STRING(ENC_MODE_TKIP);
+	CASE_RETURN_STRING(ENC_MODE_AES);
+	CASE_RETURN_STRING(ENC_MODE_AES_GCMP);
+	CASE_RETURN_STRING(ENC_MODE_AES_GCMP_256);
+	CASE_RETURN_STRING(ENC_MODE_SMS4);
+	default:
+		return "Unknown";
+	}
+}
+
+static void csr_dump_connection_stats(tpAniSirGlobal mac_ctx,
+		struct csr_roam_session *session,
+		struct csr_roam_info *roam_info,
+		eRoamCmdStatus u1, eCsrRoamResult u2)
+{
+	struct tagCsrRoamConnectedProfile *conn_profile;
+	struct csr_roam_profile *profile;
+	WLAN_HOST_DIAG_EVENT_DEF(conn_stats,
+				 struct host_event_wlan_connection_stats);
+
+	if (!session || !session->pCurRoamProfile || !roam_info)
+		return;
+
+	conn_profile = roam_info->u.pConnectedProfile;
+	if (!conn_profile)
+		return;
+	profile = session->pCurRoamProfile;
+	qdf_mem_set(&conn_stats,
+		    sizeof(struct host_event_wlan_connection_stats), 0);
+	qdf_mem_copy(conn_stats.bssid, conn_profile->bssid.bytes,
+		     QDF_MAC_ADDR_SIZE);
+	conn_stats.ssid_len = conn_profile->SSID.length;
+	if (conn_stats.ssid_len > SIR_MAC_MAX_SSID_LENGTH)
+		conn_stats.ssid_len = SIR_MAC_MAX_SSID_LENGTH;
+	qdf_mem_copy(conn_stats.ssid, conn_profile->SSID.ssId,
+		     conn_stats.ssid_len);
+	sme_get_rssi_snr_by_bssid(mac_ctx, session->pCurRoamProfile,
+				  &conn_stats.bssid[0],
+				  &conn_stats.rssi, NULL);
+	conn_stats.est_link_speed = 0;
+	conn_stats.chnl_bw =
+		diag_ch_width_from_csr_type(conn_profile->vht_channel_width);
+	conn_stats.dot11mode =
+		diag_dot11_mode_from_csr_type(conn_profile->dot11Mode);
+	conn_stats.bss_type =
+	     diag_persona_from_csr_type(session->pCurRoamProfile->csrPersona);
+	conn_stats.operating_channel = conn_profile->operationChannel;
+	conn_stats.qos_capability = conn_profile->qosConnection;
+	conn_stats.auth_type =
+	     diag_auth_type_from_csr_type(conn_profile->AuthType);
+	conn_stats.encryption_type =
+	     diag_enc_type_from_csr_type(conn_profile->EncryptionType);
+	conn_stats.result_code = (u2 == eCSR_ROAM_RESULT_ASSOCIATED) ? 1 : 0;
+	conn_stats.reason_code = 0;
+	sme_debug("+---------CONNECTION INFO START------------+");
+	sme_debug("connection stats for session-id: %d", session->sessionId);
+	sme_debug("ssid: %.*s", conn_stats.ssid_len, conn_stats.ssid);
+	sme_debug("bssid: %pM", conn_stats.bssid);
+	sme_debug("rssi: %d dBm", conn_stats.rssi);
+	sme_debug("channel: %d", conn_stats.operating_channel);
+	sme_debug("dot11Mode: %s",
+		  csr_get_dot11_mode_str(conn_stats.dot11mode));
+	sme_debug("channel bw: %s",
+		  csr_get_ch_width_str(conn_stats.chnl_bw));
+	sme_debug("Qos enable: %d", conn_stats.qos_capability);
+	sme_debug("Auth-type: %s",
+		  csr_get_auth_type_str(conn_stats.auth_type));
+	sme_debug("Encry-type: %s",
+		  csr_get_encr_type_str(conn_stats.encryption_type));
+	sme_debug("is associated?: %s",
+		  (conn_stats.result_code ? "yes" : "no"));
+	sme_debug("+---------CONNECTION INFO END------------+");
+
+	WLAN_HOST_DIAG_EVENT_REPORT(&conn_stats, EVENT_WLAN_CONN_STATS_V2);
+}
+#else
+static void csr_dump_connection_stats(tpAniSirGlobal mac_ctx,
+		struct csr_roam_session *session,
+		struct csr_roam_info *roam_info,
+		eRoamCmdStatus u1, eCsrRoamResult u2)
+{}
+
+#endif
+
 QDF_STATUS csr_roam_call_callback(tpAniSirGlobal pMac, uint32_t sessionId,
 				  struct csr_roam_info *roam_info,
 				  uint32_t roamId,
@@ -4009,6 +4245,8 @@ QDF_STATUS csr_roam_call_callback(tpAniSirGlobal pMac, uint32_t sessionId,
 		else
 			sme_err("session_open_cb is not registered");
 	}
+	if (eCSR_ROAM_ASSOCIATION_COMPLETION == u1)
+		csr_dump_connection_stats(pMac, pSession, roam_info, u1, u2);
 
 	if (NULL != pSession->callback) {
 		if (roam_info) {

+ 52 - 25
core/sme/src/csr/csr_inside_api.h

@@ -597,29 +597,6 @@ void csr_get_vdev_type_nss(tpAniSirGlobal mac_ctx,
 #define WLAN_SECURITY_EVENT_SET_BCAST_REQ    12
 #define WLAN_SECURITY_EVENT_SET_BCAST_RSP    13
 
-
-#define AUTH_OPEN       0
-#define AUTH_SHARED     1
-#define AUTH_WPA_EAP    2
-#define AUTH_WPA_PSK    3
-#define AUTH_WPA2_EAP   4
-#define AUTH_WPA2_PSK   5
-#ifdef FEATURE_WLAN_WAPI
-#define AUTH_WAPI_CERT  6
-#define AUTH_WAPI_PSK   7
-#endif /* FEATURE_WLAN_WAPI */
-
-#define ENC_MODE_OPEN   0
-#define ENC_MODE_WEP40  1
-#define ENC_MODE_WEP104 2
-#define ENC_MODE_TKIP   3
-#define ENC_MODE_AES    4
-#define ENC_MODE_AES_GCMP    5
-#define ENC_MODE_AES_GCMP_256    6
-#ifdef FEATURE_WLAN_WAPI
-#define ENC_MODE_SMS4   5       /* WAPI */
-#endif /* FEATURE_WLAN_WAPI */
-
 #define NO_MATCH    0
 #define MATCH       1
 
@@ -663,8 +640,58 @@ void csr_get_vdev_type_nss(tpAniSirGlobal mac_ctx,
 #define WLAN_80211D_SUPPORT_MULTI_DOMAIN     1
 #define WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN     2
 
-int diag_auth_type_from_csr_type(eCsrAuthType authType);
-int diag_enc_type_from_csr_type(eCsrEncryptionType encType);
+/**
+ * diag_auth_type_from_csr_type() - to convert CSR auth type to DIAG auth type
+ * @authtype: CSR auth type
+ *
+ * DIAG tool understands its own ENUMs, so this API can be used to convert
+ * CSR defined auth type ENUMs to DIAG defined auth type ENUMs
+ *
+ *
+ * Return: DIAG auth type
+ */
+enum mgmt_auth_type diag_auth_type_from_csr_type(eCsrAuthType authtype);
+/**
+ * diag_enc_type_from_csr_type() - to convert CSR encr type to DIAG encr type
+ * @enctype: CSR encryption type
+ *
+ * DIAG tool understands its own ENUMs, so this API can be used to convert
+ * CSR defined encr type ENUMs to DIAG defined encr type ENUMs
+ *
+ * Return: DIAG encryption type
+ */
+enum mgmt_encrypt_type diag_enc_type_from_csr_type(eCsrEncryptionType enctype);
+/**
+ * diag_dot11_mode_from_csr_type() - to convert CSR .11 mode to DIAG .11 mode
+ * @dot11mode: CSR 80211 mode
+ *
+ * DIAG tool understands its own ENUMs, so this API can be used to convert
+ * CSR defined 80211 mode ENUMs to DIAG defined 80211 mode ENUMs
+ *
+ * Return: DIAG 80211mode
+ */
+enum mgmt_dot11_mode
+diag_dot11_mode_from_csr_type(enum csr_cfgdot11mode dot11mode);
+/**
+ * diag_ch_width_from_csr_type() - to convert CSR ch width to DIAG ch width
+ * @ch_width: CSR channel width
+ *
+ * DIAG tool understands its own ENUMs, so this API can be used to convert
+ * CSR defined ch width ENUMs to DIAG defined ch width ENUMs
+ *
+ * Return: DIAG channel width
+ */
+enum mgmt_ch_width diag_ch_width_from_csr_type(enum phy_ch_width ch_width);
+/**
+ * diag_persona_from_csr_type() - to convert QDF persona to DIAG persona
+ * @persona: QDF persona
+ *
+ * DIAG tool understands its own ENUMs, so this API can be used to convert
+ * QDF defined persona type ENUMs to DIAG defined persona type ENUMs
+ *
+ * Return: DIAG persona
+ */
+enum mgmt_bss_type diag_persona_from_csr_type(enum QDF_OPMODE persona);
 #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */
 /*
  * csr_scan_result_purge() -