wlan: Added ioctl to enable/disable Traffic Monitor Feature Dynamically
Added ioctl to enable/disable Traffic Monitor Feature Dynamically
Change-Id: I63f389295ca94b9b27c9b8df5cb1274fc616afbd
CRs-fixed: 567334
diff --git a/CORE/HDD/inc/qc_sap_ioctl.h b/CORE/HDD/inc/qc_sap_ioctl.h
index d995d77..885650b 100644
--- a/CORE/HDD/inc/qc_sap_ioctl.h
+++ b/CORE/HDD/inc/qc_sap_ioctl.h
@@ -256,7 +256,8 @@
#define QCSAP_IOCTL_SET_TX_POWER (SIOCIWFIRSTPRIV+20)
#define QCSAP_IOCTL_GET_STA_INFO (SIOCIWFIRSTPRIV+21)
#define QCSAP_IOCTL_SET_MAX_TX_POWER (SIOCIWFIRSTPRIV+22)
-#define QCSAP_IOCTL_DATAPATH_SNAP_SHOT (SIOCIWFIRSTPRIV+23)
+#define QCSAP_IOCTL_DATAPATH_SNAP_SHOT (SIOCIWFIRSTPRIV+23)
+#define QCSAP_IOCTL_SET_TRAFFIC_MONITOR (SIOCIWFIRSTPRIV+24)
#define MAX_VAR_ARGS 7
#define QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
diff --git a/CORE/HDD/inc/wlan_hdd_softap_tx_rx.h b/CORE/HDD/inc/wlan_hdd_softap_tx_rx.h
index 5168123..d248bd4 100644
--- a/CORE/HDD/inc/wlan_hdd_softap_tx_rx.h
+++ b/CORE/HDD/inc/wlan_hdd_softap_tx_rx.h
@@ -329,4 +329,28 @@
=========================================================================== */
extern VOS_STATUS hdd_softap_GetConnectedStaId( hdd_adapter_t *pAdapter, v_U8_t *staId);
+/**==========================================================================
+
+ \brief hdd_start_trafficMonitor() -
+ This function dynamically enable traffic monitor functonality
+ the command iwpriv wlanX setTrafficMon <value>.
+
+ @param pAdapter : [in] pointer to adapter context
+ @return : VOS_STATUS_E_FAILURE if any errors encountered
+
+ ========================================================================== */
+VOS_STATUS hdd_start_trafficMonitor( hdd_adapter_t *pAdapter );
+
+/**==========================================================================
+
+ \brief hdd_stop_trafficMonitor() -
+ This function dynamically disable traffic monitor functonality
+ the command iwpriv wlanX setTrafficMon <value>.
+
+ @param pAdapter : [in] pointer to adapter context
+ @return : VOS_STATUS_E_FAILURE if any errors encountered
+
+ ========================================================================== */
+VOS_STATUS hdd_stop_trafficMonitor( hdd_adapter_t *pAdapter );
+
#endif // end #if !defined( WLAN_HDD_SOFTAP_TX_RX_H )
diff --git a/CORE/HDD/src/wlan_hdd_hostapd.c b/CORE/HDD/src/wlan_hdd_hostapd.c
index e890d46..53a06c8 100644
--- a/CORE/HDD/src/wlan_hdd_hostapd.c
+++ b/CORE/HDD/src/wlan_hdd_hostapd.c
@@ -2262,6 +2262,78 @@
return 0;
}
+/**---------------------------------------------------------------------------
+
+ \brief iw_softap_set_trafficmonitor() -
+ This function dynamically enable/disable traffic monitor functonality
+ the command iwpriv wlanX setTrafficMon <value>.
+
+ \param - dev - Pointer to the net device.
+ - addr - Pointer to the sockaddr.
+ \return - 0 for success, non zero for failure
+
+ --------------------------------------------------------------------------*/
+
+static int iw_softap_set_trafficmonitor(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
+ int *isSetTrafficMon = (int *)wrqu->data.pointer;
+ hdd_context_t *pHddCtx;
+ int status;
+
+ if (NULL == pAdapter)
+ {
+ VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
+ "%s: HDD adapter is Null", __func__);
+ return -ENODEV;
+ }
+
+ pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
+
+ status = wlan_hdd_validate_context(pHddCtx);
+
+ if (0 != status)
+ {
+ VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+ "%s: HDD context is not valid", __func__);
+ return status;
+ }
+
+ hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
+
+ if (NULL == isSetTrafficMon)
+ {
+ VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
+ "%s: Invalid SAP pointer from extra", __func__);
+ return -ENOMEM;
+ }
+
+ if (TRUE == *isSetTrafficMon)
+ {
+ pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
+ if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
+ {
+ VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
+ "%s: failed to Start Traffic Monitor timer ", __func__ );
+ return -EIO;
+ }
+ }
+ else if (FALSE == *isSetTrafficMon)
+ {
+ pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
+ if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
+ {
+ VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
+ "%s: failed to Stop Traffic Monitor timer ", __func__ );
+ return -EIO;
+ }
+
+ }
+ return 0;
+}
+
#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
int
@@ -3882,8 +3954,17 @@
IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
0,
"setTxMaxPower" },
- { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
- IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE, 0, "dataSnapshot" },
+
+ { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
+ IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
+ 0,
+ "dataSnapshot" },
+
+ /* handlers for main ioctl */
+ { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
+ IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
+ 0,
+ "setTrafficMon" },
};
static const iw_handler hostapd_private[] = {
@@ -3910,6 +3991,7 @@
[QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
[QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
[QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
+ [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
};
const struct iw_handler_def hostapd_handler_def = {
.num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
diff --git a/CORE/HDD/src/wlan_hdd_softap_tx_rx.c b/CORE/HDD/src/wlan_hdd_softap_tx_rx.c
index 6b78c63..035b045 100644
--- a/CORE/HDD/src/wlan_hdd_softap_tx_rx.c
+++ b/CORE/HDD/src/wlan_hdd_softap_tx_rx.c
@@ -125,6 +125,8 @@
if (pHddCtx->cfg_ini->trafficIdleTimeout <
(currentTS - pHddCtx->traffic_monitor.lastFrameTs))
{
+ VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO,
+ "%s: No Data Activity calling Wlan Suspend", __func__ );
hdd_set_wlan_suspend_mode(1);
atomic_set(&pHddCtx->traffic_monitor.isActiveMode, 0);
}
@@ -137,6 +139,79 @@
return;
}
+VOS_STATUS hdd_start_trafficMonitor( hdd_adapter_t *pAdapter )
+{
+
+ hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
+ VOS_STATUS status = VOS_STATUS_SUCCESS;
+
+ status = wlan_hdd_validate_context(pHddCtx);
+
+ if (0 != status)
+ {
+ VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+ "%s: HDD context is not valid", __func__);
+ return status;
+ }
+
+ if ((pHddCtx->cfg_ini->enableTrafficMonitor) &&
+ (!pHddCtx->traffic_monitor.isInitialized))
+ {
+ atomic_set(&pHddCtx->traffic_monitor.isActiveMode, 1);
+ vos_timer_init(&pHddCtx->traffic_monitor.trafficTimer,
+ VOS_TIMER_TYPE_SW,
+ hdd_softap_traffic_monitor_timeout_handler,
+ pHddCtx);
+ vos_lock_init(&pHddCtx->traffic_monitor.trafficLock);
+ pHddCtx->traffic_monitor.isInitialized = 1;
+ pHddCtx->traffic_monitor.lastFrameTs = 0;
+ /* Start traffic monitor timer here
+ * If no AP assoc, immediatly go into suspend */
+ VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO,
+ "%s Start Traffic Monitor Timer", __func__);
+ vos_timer_start(&pHddCtx->traffic_monitor.trafficTimer,
+ pHddCtx->cfg_ini->trafficIdleTimeout);
+ }
+ else
+ {
+ VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO,
+ "%s Traffic Monitor is not Enable in ini file", __func__);
+ }
+ return status;
+}
+
+VOS_STATUS hdd_stop_trafficMonitor( hdd_adapter_t *pAdapter )
+{
+ hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
+ VOS_STATUS status = VOS_STATUS_SUCCESS;
+
+ status = wlan_hdd_validate_context(pHddCtx);
+
+ if (0 != status)
+ {
+ VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+ "%s: HDD context is not valid", __func__);
+ return status;
+ }
+
+ if (pHddCtx->traffic_monitor.isInitialized)
+ {
+ if (VOS_TIMER_STATE_STOPPED !=
+ vos_timer_getCurrentState(&pHddCtx->traffic_monitor.trafficTimer))
+ {
+ VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO,
+ "%s Stop Traffic Monitor Timer", __func__);
+ vos_timer_stop(&pHddCtx->traffic_monitor.trafficTimer);
+ }
+ VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO,
+ "%s Destroy Traffic Monitor Timer", __func__);
+ vos_timer_destroy(&pHddCtx->traffic_monitor.trafficTimer);
+ vos_lock_destroy(&pHddCtx->traffic_monitor.trafficLock);
+ pHddCtx->traffic_monitor.isInitialized = 0;
+ }
+ return status;
+}
+
/**============================================================================
@brief hdd_softap_flush_tx_queues() - Utility function to flush the TX queues
@@ -578,8 +653,6 @@
HDD_SOFTAP_VO_WEIGHT_DEFAULT
};
- hdd_context_t *pHddCtx = NULL;
-
pAdapter->isVosOutOfResource = VOS_FALSE;
pAdapter->isVosLowResource = VOS_FALSE;
@@ -607,35 +680,15 @@
}
}
- pHddCtx = (hdd_context_t *)pAdapter->pHddCtx;
- if (NULL == pHddCtx)
- {
- VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
- "%s: Invalid HDD cntxt", __func__ );
- return VOS_STATUS_E_INVAL;
- }
-
/* Update the AC weights suitable for SoftAP mode of operation */
WLANTL_SetACWeights((WLAN_HDD_GET_CTX(pAdapter))->pvosContext, pACWeights);
- /* Initialize SAP/P2P-GO traffin monitor */
- if ((pHddCtx->cfg_ini->enableTrafficMonitor) &&
- (!pHddCtx->traffic_monitor.isInitialized))
+ if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
{
- atomic_set(&pHddCtx->traffic_monitor.isActiveMode, 1);
- vos_timer_init(&pHddCtx->traffic_monitor.trafficTimer,
- VOS_TIMER_TYPE_SW,
- hdd_softap_traffic_monitor_timeout_handler,
- pHddCtx);
- vos_lock_init(&pHddCtx->traffic_monitor.trafficLock);
- pHddCtx->traffic_monitor.isInitialized = 1;
- pHddCtx->traffic_monitor.lastFrameTs = 0;
- /* Start traffic monitor timer here
- * If no AP assoc, immediatly go into suspend */
- vos_timer_start(&pHddCtx->traffic_monitor.trafficTimer,
- pHddCtx->cfg_ini->trafficIdleTimeout);
+ VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
+ "%s: failed to start Traffic Monito timer ", __func__ );
+ return VOS_STATUS_E_INVAL;
}
-
return status;
}
@@ -650,25 +703,12 @@
VOS_STATUS hdd_softap_deinit_tx_rx( hdd_adapter_t *pAdapter )
{
VOS_STATUS status = VOS_STATUS_SUCCESS;
- hdd_context_t *pHddCtx = NULL;
- pHddCtx = (hdd_context_t *)pAdapter->pHddCtx;
- if (NULL == pHddCtx)
+ if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
{
- VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
- "%s: Invalid HDD cntxt", __func__ );
- return VOS_STATUS_E_INVAL;
- }
- if (pHddCtx->traffic_monitor.isInitialized)
- {
- if (VOS_TIMER_STATE_STOPPED !=
- vos_timer_getCurrentState(&pHddCtx->traffic_monitor.trafficTimer))
- {
- vos_timer_stop(&pHddCtx->traffic_monitor.trafficTimer);
- }
- vos_timer_destroy(&pHddCtx->traffic_monitor.trafficTimer);
- vos_lock_destroy(&pHddCtx->traffic_monitor.trafficLock);
- pHddCtx->traffic_monitor.isInitialized = 0;
+ VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
+ "%s: Fail to Stop Traffic Monito timer", __func__ );
+ return VOS_STATUS_E_INVAL;
}
status = hdd_softap_flush_tx_queues(pAdapter);