qcacld-3.0: Implement iwpriv command to send connection info

There is no iwpriv command to send STA/P2P_CLI connection information
to userspace. Implement "iwpriv wlan0 get_cxn_info" command
to send the information to userspace.

CRs-Fixed: 2342141
Change-Id: I39e461b62eb5263d7e185686ae42bdbbc8edec7a
This commit is contained in:
Krunal Soni 2018-10-25 15:42:44 -07:00 • committed by Nitesh Shrivastav
commit 5e48378848
5 changed files with 223 additions and 1 deletions

View file

@ -2060,6 +2060,25 @@
*/
#define WE_GET_BA_AGEING_TIMEOUT 16
/*
* <ioctl>
*
* 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
*
* </ioctl>
*/
#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,

View file

@ -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

View file

@ -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,

View file

@ -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,

View file

@ -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__ */