diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index cbf8b9413efc..22e57ea43e78 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -2060,6 +2060,25 @@ */ #define WE_GET_BA_AGEING_TIMEOUT 16 +/* + * + * + * sta_cxn_info - STA connection information + * + * @INPUT: none + * + * @OUTPUT: STA's connection information + * + * This IOCTL is used to get connection's information. + * + * @E.g: iwpriv wlan0 get_cxn_info + * + * Usage: Internal + * + * + */ +#define WE_GET_STA_CXN_INFO 17 + /* Private ioctls and their sub-ioctls */ #define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6) @@ -6260,6 +6279,32 @@ static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev, } #endif +#ifdef WLAN_UNIT_TEST +static int hdd_get_sta_cxn_info(struct hdd_context *hdd_ctx, + struct hdd_adapter *adapter, + char *extra) +{ + QDF_STATUS status; + + status = sme_get_sta_cxn_info(hdd_ctx->mac_handle, adapter->session_id, + extra, WE_MAX_STR_LEN); + if (status != QDF_STATUS_SUCCESS) + qdf_scnprintf(extra, WE_MAX_STR_LEN, + "\nNo active connection"); + + return 0; +} +#else +static int hdd_get_sta_cxn_info(struct hdd_context *hdd_ctx, + struct hdd_adapter *adapter, + char *extra) +{ + qdf_scnprintf(extra, WE_MAX_STR_LEN, + "\nNot supported"); + return -ENOTSUPP; +} +#endif + /** * iw_get_char_setnone() - Generic "get string" private ioctl handler * @dev: device upon which the ioctl was received @@ -6829,6 +6874,11 @@ static int __iw_get_char_setnone(struct net_device *dev, break; } + case WE_GET_STA_CXN_INFO: + ret = hdd_get_sta_cxn_info(hdd_ctx, adapter, extra); + wrqu->data.length = strlen(extra) + 1; + break; + default: hdd_err("Invalid IOCTL command %d", sub_cmd); break; @@ -10074,6 +10124,13 @@ static const struct iw_priv_args we_private_args[] = { "getPMFInfo" }, #endif + { + WE_GET_STA_CXN_INFO, + 0, + IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN, + "get_cxn_info" + }, + { WE_GET_IBSS_STA_INFO, 0, diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 0b6ab4afef78..9b3306d8c50f 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -3093,6 +3093,31 @@ QDF_STATUS sme_deregister_twt_disable_complete_cb(mac_handle_t mac_handle) return QDF_STATUS_SUCCESS; } #endif +/** + * sme_get_sta_cxn_info() - This function populates all the connection + * information which is formed by DUT-STA to AP + * by calling CSR helper API. + * @mac_ctx: pointer to mac context + * @session: pointer to sta session + * @conn_profile: pointer to connected DUTSTA-REFAP profile + * @buf: pointer to char buffer to write all the connection information. + * @buf_size: maximum size of the provided buffer + * + * Returns: QDF_STATUS + */ +#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR +QDF_STATUS sme_get_sta_cxn_info(mac_handle_t mac_handle, uint32_t session_id, + char *buf, uint32_t buf_sz); +#else +static inline QDF_STATUS +sme_get_sta_cxn_info(mac_handle_t mac_handle, uint32_t session_id, + char *buf, uint32_t buf_sz) +{ + qdf_scnprintf(buf, buf_sz, + "\nDiag macro disable, ask vendor to enable"); + return QDF_STATUS_SUCCESS; +} +#endif /** * sme_find_session_by_bssid() - checks whether has session diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 96a3c20bb7d2..45e2df04f313 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -16716,6 +16716,34 @@ bool sme_find_session_by_bssid(mac_handle_t mac_handle, uint8_t *bssid) return ret; } +#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR +QDF_STATUS sme_get_sta_cxn_info(mac_handle_t mac_handle, uint32_t session_id, + char *buf, uint32_t buf_sz) +{ + QDF_STATUS status; + struct mac_context *mac_ctx = MAC_CONTEXT(mac_handle); + struct tagCsrRoamConnectedProfile *conn_profile; + struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id); + + status = sme_acquire_global_lock(&mac_ctx->sme); + if (!QDF_IS_STATUS_SUCCESS(status)) + return status; + if (!session || !session->pCurRoamProfile) { + status = QDF_STATUS_E_FAILURE; + goto end; + } + conn_profile = &session->connectedProfile; + if (!conn_profile) { + status = QDF_STATUS_E_FAILURE; + goto end; + } + csr_get_sta_cxn_info(mac_ctx, session, conn_profile, buf, buf_sz); +end: + sme_release_global_lock(&mac_ctx->sme); + + return status; +} +#endif QDF_STATUS sme_get_roam_scan_stats(mac_handle_t mac_handle, roam_scan_stats_cb cb, void *context, diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c index 18729880240e..912d170a72a7 100644 --- a/core/sme/src/csr/csr_api_roam.c +++ b/core/sme/src/csr/csr_api_roam.c @@ -3508,7 +3508,25 @@ static const char *csr_get_ch_width_str(uint8_t ch_width) } } -static const char *csr_get_dot11_mode_str(enum csr_cfgdot11mode dot11mode) +static const char *csr_get_persona(enum mgmt_bss_type persona) +{ + switch (persona) { + CASE_RETURN_STRING(STA_PERSONA); + CASE_RETURN_STRING(SAP_PERSONA); + CASE_RETURN_STRING(P2P_CLIENT_PERSONA); + CASE_RETURN_STRING(P2P_GO_PERSONA); + CASE_RETURN_STRING(FTM_PERSONA); + CASE_RETURN_STRING(IBSS_PERSONA); + CASE_RETURN_STRING(MONITOR_PERSONA); + CASE_RETURN_STRING(P2P_DEVICE_PERSONA); + CASE_RETURN_STRING(NDI_PERSONA); + CASE_RETURN_STRING(WDS_PERSONA); + default: + return "Unknown"; + } +} + +static const char *csr_get_dot11_mode_str(enum mgmt_dot11_mode dot11mode) { switch (dot11mode) { CASE_RETURN_STRING(DOT11_MODE_AUTO); @@ -3626,6 +3644,82 @@ static void csr_dump_connection_stats(tpAniSirGlobal mac_ctx, WLAN_HOST_DIAG_EVENT_REPORT(&conn_stats, EVENT_WLAN_CONN_STATS_V2); } + +void csr_get_sta_cxn_info(tpAniSirGlobal mac_ctx, + struct csr_roam_session *session, + struct tagCsrRoamConnectedProfile *conn_profile, + char *buf, uint32_t buf_sz) +{ + int8_t rssi = 0; + uint32_t nss, hw_mode; + struct policy_mgr_conc_connection_info *conn_info; + struct wma_txrx_node *wma_conn_table_entry = NULL; + uint32_t i = 0, len = 0, max_cxn = 0; + enum mgmt_ch_width ch_width; + enum mgmt_dot11_mode dot11mode; + enum mgmt_bss_type type; + enum mgmt_auth_type authtype; + enum mgmt_encrypt_type enctype; + + if (!session || !session->pCurRoamProfile || !conn_profile) + return; + if (!conn_profile->operationChannel) + return; + qdf_mem_set(buf, buf_sz, '\0'); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tbssid: %pM", conn_profile->bssid.bytes); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tssid: %.*s", conn_profile->SSID.length, + conn_profile->SSID.ssId); + sme_get_rssi_snr_by_bssid(MAC_HANDLE(mac_ctx), + session->pCurRoamProfile, + conn_profile->bssid.bytes, + &rssi, NULL); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\trssi: %d", rssi); + ch_width = diag_ch_width_from_csr_type(conn_profile->vht_channel_width); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tbw: %s", csr_get_ch_width_str(ch_width)); + dot11mode = diag_dot11_mode_from_csr_type(conn_profile->dot11Mode); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tdot11mode: %s", + csr_get_dot11_mode_str(dot11mode)); + type = diag_persona_from_csr_type(session->pCurRoamProfile->csrPersona); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tbss_type: %s", csr_get_persona(type)); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tchnl: %d", conn_profile->operationChannel); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tQoS: %d", conn_profile->qosConnection); + authtype = diag_auth_type_from_csr_type(conn_profile->AuthType); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tauth_type: %s", + csr_get_auth_type_str(authtype)); + enctype = diag_enc_type_from_csr_type(conn_profile->EncryptionType); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tencry_type: %s", + csr_get_encr_type_str(enctype)); + conn_info = policy_mgr_get_conn_info(&max_cxn); + for (i = 0; i < max_cxn; i++) + if ((conn_info->vdev_id == session->sessionId) && + (conn_info->in_use)) + break; + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tmac: %d", conn_info->mac); + wma_conn_table_entry = wma_get_interface_by_vdev_id(session->sessionId); + if (wma_conn_table_entry) + nss = wma_conn_table_entry->nss; + else + nss = 0; + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\torig_nss: %dx%d neg_nss: %dx%d", + conn_info->original_nss, conn_info->original_nss, + nss, nss); + hw_mode = policy_mgr_is_current_hwmode_dbs(mac_ctx->psoc); + len += qdf_scnprintf(buf + len, buf_sz - len, + "\n\tis_current_hw_mode_dbs: %s", + ((hw_mode != 0) ? "yes" : "no")); +} #else static void csr_dump_connection_stats(tpAniSirGlobal mac_ctx, struct csr_roam_session *session, diff --git a/core/sme/src/csr/csr_inside_api.h b/core/sme/src/csr/csr_inside_api.h index 3ab6bac6e536..b5b522e1eb5d 100644 --- a/core/sme/src/csr/csr_inside_api.h +++ b/core/sme/src/csr/csr_inside_api.h @@ -1144,4 +1144,22 @@ uint8_t csr_scan_get_channel_for_hw_mode_change( tpAniSirGlobal mac_ctx, uint32_t session_id, struct csr_roam_profile *profile); + +#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR +/** + * csr_get_sta_cxn_info() - This function populates all the connection + * information which is formed by DUT-STA to AP + * @mac_ctx: pointer to mac context + * @session: pointer to sta session + * @conn_profile: pointer to connected DUTSTA-REFAP profile + * @buf: pointer to char buffer to write all the connection information. + * @buf_size: maximum size of the provided buffer + * + * Returns: None (information gets populated in buffer) + */ +void csr_get_sta_cxn_info(tpAniSirGlobal mac_ctx, + struct csr_roam_session *session, + struct tagCsrRoamConnectedProfile *conn_profile, + char *buf, uint32_t buf_sz); +#endif #endif /* CSR_INSIDE_API_H__ */