prima: Framework to print system information

Print state information of HDD, SME, PE, WDA and WDI layers
when active command timeout issue is seen. This can be extended
to print system information of other layers if there is necessity
for such information.

Change-Id: Ibce74761f60f33d37ffde0530c2d2635be46cdd7
CRs-Fixed: 851666
diff --git a/CORE/HDD/src/wlan_hdd_trace.c b/CORE/HDD/src/wlan_hdd_trace.c
index a062523..577f314 100644
--- a/CORE/HDD/src/wlan_hdd_trace.c
+++ b/CORE/HDD/src/wlan_hdd_trace.c
@@ -135,3 +135,63 @@
 {
     vosTraceRegister(VOS_MODULE_ID_HDD, (tpvosTraceCb)&hddTraceDump);
 }
+
+/**
+ * hdd_state_info_dump() - prints state information of hdd layer
+ */
+static void hdd_state_info_dump(void)
+{
+    v_CONTEXT_t vos_ctx_ptr;
+    hdd_context_t *hdd_ctx_ptr = NULL;
+    hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL;
+    VOS_STATUS status;
+    hdd_station_ctx_t *hdd_sta_ctx = NULL;
+    hdd_adapter_t *adapter =NULL;
+
+    /* get the global voss context */
+    vos_ctx_ptr = vos_get_global_context(VOS_MODULE_ID_VOSS, NULL);
+
+    if (NULL != vos_ctx_ptr) {
+        hdd_ctx_ptr = vos_get_context(VOS_MODULE_ID_HDD, vos_ctx_ptr);
+    } else {
+        VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+                  "%s: Invalid Global VOSS Context", __func__);
+        VOS_ASSERT(0);
+        return;
+    }
+
+    hddLog(LOG1,
+           FL("mScanPending %d isWlanSuspended %d disable_dfs_flag %d"),
+           hdd_ctx_ptr->scan_info.mScanPending,
+           hdd_ctx_ptr->isWlanSuspended, hdd_ctx_ptr->disable_dfs_flag);
+
+    status = hdd_get_front_adapter(hdd_ctx_ptr, &adapter_node);
+
+    while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) {
+       adapter = adapter_node->pAdapter;
+       if (adapter->dev)
+           hddLog(LOG1, FL("device name: %s"), adapter->dev->name);
+       switch (adapter->device_mode) {
+       case WLAN_HDD_INFRA_STATION:
+       case WLAN_HDD_P2P_CLIENT:
+           hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+           hddLog(LOG1, FL("connState: %d device_mode: %d"),
+                  hdd_sta_ctx->conn_info.connState, adapter->device_mode);
+           break;
+
+       default:
+           break;
+       }
+       status = hdd_get_next_adapter(hdd_ctx_ptr, adapter_node, &next);
+       adapter_node = next;
+    }
+}
+
+/**
+ * hdd_register_debug_callback() - registration function for hdd layer
+ * to print hdd state information
+ */
+void hdd_register_debug_callback()
+{
+    vos_register_debug_callback(VOS_MODULE_ID_HDD, &hdd_state_info_dump);
+}