Pārlūkot izejas kodu

qcacld-3.0: Add bootup kpi marker for some wlan events

Add the API to record some key wlan events
to "/sys/kernel/debug/bootkpi/kpi_values" from
HDD layer.
Examples:
108 KPI_MARKER 860s389434814ns qca6696 START LOADING
108 KPI_MARKER 860s634063720ns qca6696 DRIVER LOADED
108 KPI_MARKER 869s427276611ns qca6696 wlan0:SAP TRY
TO START
108 KPI_MARKER 869s576171875ns qca6696 wlan0:SAP START
with SUCCESS

Change-Id: I2e40305ee4100248348e9a284df71d1ee340e1e4
CRs-Fixed: 2816054
Chaoli Zhou 4 gadi atpakaļ
vecāks
revīzija
982b98c6e3

+ 9 - 0
Kbuild

@@ -428,6 +428,10 @@ HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_cm_connect.o \
 	    $(HDD_SRC_DIR)/wlan_hdd_cm_disconnect.o
 endif
 
+ifeq ($(CONFIG_WLAN_BOOTUP_MARKER), y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_bootup_marker.o
+endif
+
 ###### OSIF_SYNC ########
 SYNC_DIR := os_if/sync
 SYNC_INC_DIR := $(SYNC_DIR)/inc
@@ -3734,6 +3738,11 @@ ifeq ($(CONFIG_FEATURE_IPA_PIPE_CHANGE_WDI1), y)
 cppflags-y += -DFEATURE_IPA_PIPE_CHANGE_WDI1
 endif
 
+cppflags-$(CONFIG_WLAN_BOOTUP_MARKER) += -DWLAN_BOOTUP_MARKER
+ifdef CONFIG_WLAN_PLACEMARKER_PREFIX
+ccflags-y += -DWLAN_PLACEMARKER_PREFIX=\"$(CONFIG_WLAN_PLACEMARKER_PREFIX)\"
+endif
+
 cppflags-$(CONFIG_FEATURE_STA_MODE_VOTE_LINK) += -DFEATURE_STA_MODE_VOTE_LINK
 cppflags-$(CONFIG_WLAN_ENABLE_GPIO_WAKEUP) += -DWLAN_ENABLE_GPIO_WAKEUP
 

+ 3 - 0
configs/qca6390_defconfig

@@ -798,3 +798,6 @@ CONFIG_WLAN_FW_OFFLOAD := y
 
 CONFIG_WLAN_FEATURE_MEDIUM_ASSESS := y
 
+ifeq ($(CONFIG_MSM_BOOT_TIME_MARKER), y)
+CONFIG_WLAN_BOOTUP_MARKER := y
+endif

+ 50 - 0
core/hdd/inc/wlan_hdd_bootup_marker.h

@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2020 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef WLAN_HDD_BOOTUP_MARKER_H
+#define WLAN_HDD_BOOTUP_MARKER_H
+
+/**
+ * DOC: wlan_hdd_bootup_marker.h
+ *
+ * WLAN Host Device Driver Bootup Marker header file
+ */
+
+#include "wlan_hdd_main.h"
+
+#ifdef WLAN_BOOTUP_MARKER
+/**
+ * hdd_place_marker() - record bootup marker for some events
+ * @adapter: hdd adapter pointer
+ * @format: The strings of the events
+ * @mac: mac address of peer device
+ *
+ * Return: None
+ */
+void hdd_place_marker(struct hdd_adapter *adapter,
+		      const char *format,
+		      uint8_t *mac);
+#else
+static inline
+void hdd_place_marker(struct hdd_adapter *adapter,
+		      const char *format,
+		      uint8_t *mac)
+{
+}
+#endif
+#endif /* WLAN_HDD_BOOTUP_MARKER_H */

+ 3 - 0
core/hdd/src/wlan_hdd_assoc.c

@@ -86,6 +86,7 @@
 #include "osif_cm_util.h"
 #include "wlan_hdd_cm_api.h"
 
+#include "wlan_hdd_bootup_marker.h"
 
 /* These are needed to recognize WPA and RSN suite types */
 #define HDD_WPA_OUI_SIZE 4
@@ -1935,6 +1936,7 @@ static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter,
 
 	/* indicate 'disconnect' status to wpa_supplicant... */
 	hdd_send_association_event(dev, roam_info);
+	hdd_place_marker(adapter, "DISCONNECTED", NULL);
 
 	/*
 	 * Following code will be cleaned once the interface manager
@@ -3001,6 +3003,7 @@ hdd_association_completion_handler(struct hdd_adapter *adapter,
 
 		/* Indicate 'connect' status to user space */
 		hdd_send_association_event(dev, roam_info);
+		hdd_place_marker(adapter, "ASSOCIATION COMPLETE", NULL);
 
 		if (policy_mgr_is_mcc_in_24G(hdd_ctx->psoc)) {
 			if (hdd_ctx->miracast_value)

+ 74 - 0
core/hdd/src/wlan_hdd_bootup_marker.c

@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2020 The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ *  DOC: wlan_hdd_bootup_marker.c
+ *
+ *  WLAN Host Device Driver bootup marker implementation
+ *
+ */
+
+#include "wlan_hdd_bootup_marker.h"
+#include <soc/qcom/boot_stats.h>
+#include <qdf_trace.h>
+
+#ifdef DYNAMIC_SINGLE_CHIP
+#define PREFIX_MARKER DYNAMIC_SINGLE_CHIP
+#else
+#ifdef MULTI_IF_NAME
+#define PREFIX_MARKER MULTI_IF_NAME
+#else
+#define PREFIX_MARKER ""
+#endif
+#endif
+
+#ifndef WLAN_PLACEMARKER_PREFIX
+#define WLAN_PLACEMARKER_PREFIX ""
+#define WLAN_MARKER WLAN_PLACEMARKER_PREFIX PREFIX_MARKER " "
+#else
+#define WLAN_MARKER WLAN_PLACEMARKER_PREFIX " " PREFIX_MARKER " "
+#endif
+
+void hdd_place_marker(struct hdd_adapter *adapter,
+		      const char *format,
+		      uint8_t *mac)
+{
+	char marker[100];
+
+	if (adapter) {
+		if (mac)
+			qdf_snprintf(marker, sizeof(marker),
+				     (WLAN_MARKER "%s:%s %s:" QDF_MAC_ADDR_FMT),
+				     (adapter->dev->name),
+				     qdf_opmode_str(adapter->device_mode),
+				     format, QDF_MAC_ADDR_REF(mac));
+		else
+			qdf_snprintf(marker, sizeof(marker),
+				     (WLAN_MARKER "%s:%s %s"),
+				     (adapter->dev->name),
+				     qdf_opmode_str(adapter->device_mode),
+				     format);
+	} else {
+		qdf_snprintf(marker, sizeof(marker),
+			     (WLAN_MARKER "%s"),
+			     format);
+	}
+
+	place_marker(marker);
+}
+

+ 4 - 0
core/hdd/src/wlan_hdd_cfg80211.c

@@ -169,6 +169,7 @@
 #include "wlan_wfa_ucfg_api.h"
 #include <osif_cm_util.h>
 #include <osif_cm_req.h>
+#include "wlan_hdd_bootup_marker.h"
 
 #define g_mode_rates_size (12)
 #define a_mode_rates_size (8)
@@ -20788,12 +20789,14 @@ static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy,
 
 	wlan_hdd_check_ht20_ht40_ind(hdd_ctx, adapter, req);
 
+	hdd_place_marker(adapter, "TRY TO CONNECT", NULL);
 	status = wlan_hdd_cfg80211_connect_start(adapter, req->ssid,
 						 req->ssid_len, req->bssid,
 						 bssid_hint, ch_freq, 0);
 	if (status) {
 		wlan_hdd_cfg80211_clear_privacy(adapter);
 		hdd_err("connect failed");
+		hdd_place_marker(adapter, "CONNECT FAILURE", NULL);
 	}
 
 	hdd_exit();
@@ -21008,6 +21011,7 @@ int wlan_hdd_disconnect(struct hdd_adapter *adapter, u16 reason,
 	mac_handle = hdd_adapter_get_mac_handle(adapter);
 	wlan_hdd_wait_for_roaming(mac_handle, adapter);
 
+	hdd_place_marker(adapter, "TRY TO DISCONNECT", NULL);
 	/*stop tx queues */
 	hdd_debug("Disabling queues");
 	reset_mscs_params(adapter);

+ 20 - 2
core/hdd/src/wlan_hdd_hostapd.c

@@ -99,6 +99,7 @@
 #include "wlan_if_mgr_ucfg_api.h"
 #include "wlan_if_mgr_public_struct.h"
 #endif
+#include "wlan_hdd_bootup_marker.h"
 
 #define ACS_SCAN_EXPIRY_TIMEOUT_S 4
 
@@ -2283,6 +2284,8 @@ QDF_STATUS hdd_hostapd_sap_event_cb(struct sap_event *sap_event,
 		if (eSAP_STATUS_FAILURE == event->status) {
 			hdd_info("assoc failure: " QDF_MAC_ADDR_FMT,
 				 QDF_MAC_ADDR_REF(wrqu.addr.sa_data));
+			hdd_place_marker(adapter, "CLIENT ASSOC FAILURE",
+					 wrqu.addr.sa_data);
 			break;
 		}
 
@@ -2293,6 +2296,8 @@ QDF_STATUS hdd_hostapd_sap_event_cb(struct sap_event *sap_event,
 		       &event->staMac, QDF_MAC_ADDR_SIZE);
 		hdd_info("associated " QDF_MAC_ADDR_FMT,
 			 QDF_MAC_ADDR_REF(wrqu.addr.sa_data));
+		hdd_place_marker(adapter, "CLIENT ASSOCIATED",
+				 wrqu.addr.sa_data);
 		we_event = IWEVREGISTERED;
 
 		if ((eCSR_ENCRYPT_TYPE_NONE == ap_ctx->encryption_type) ||
@@ -2441,7 +2446,8 @@ QDF_STATUS hdd_hostapd_sap_event_cb(struct sap_event *sap_event,
 		}
 		hdd_nofl_info("SAP disassociated " QDF_MAC_ADDR_FMT,
 			      QDF_MAC_ADDR_REF(wrqu.addr.sa_data));
-
+		hdd_place_marker(adapter, "CLIENT DISASSOCIATED FROM SAP",
+				 wrqu.addr.sa_data);
 		qdf_status = qdf_event_set(&hostapd_state->qdf_sta_disassoc_event);
 		if (!QDF_IS_STATUS_SUCCESS(qdf_status))
 			hdd_err("Station Deauth event Set failed");
@@ -3106,6 +3112,7 @@ int hdd_softap_set_channel_change(struct net_device *dev, int target_chan_freq,
 
 	strict = is_p2p_go_session;
 	strict = strict || forced;
+	hdd_place_marker(adapter, "CHANNEL CHANGE", NULL);
 	status = wlansap_set_channel_change_with_csa(
 		WLAN_HDD_GET_SAP_CTX_PTR(adapter),
 		target_chan_freq,
@@ -5943,7 +5950,7 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
 {
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
 	struct hdd_context *hdd_ctx = wiphy_priv(wiphy);
-	QDF_STATUS status;
+	QDF_STATUS status = QDF_STATUS_E_FAILURE;
 	QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
 	tSirUpdateIE update_ie;
 	int ret;
@@ -6025,6 +6032,7 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
 		struct hdd_hostapd_state *hostapd_state =
 			WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter);
 
+		hdd_place_marker(adapter, "TRY TO STOP", NULL);
 		qdf_event_reset(&hostapd_state->qdf_stop_bss_event);
 		status = wlansap_stop_bss(WLAN_HDD_GET_SAP_CTX_PTR(adapter));
 		if (QDF_IS_STATUS_SUCCESS(status)) {
@@ -6035,6 +6043,8 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
 
 			if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
 				hdd_err("qdf wait for single_event failed!!");
+				hdd_place_marker(adapter, "STOP with FAILURE",
+						 NULL);
 				hdd_sap_indicate_disconnect_for_sta(adapter);
 				QDF_ASSERT(0);
 			}
@@ -6124,6 +6134,10 @@ exit:
 		qdf_mem_free(adapter->session.ap.beacon);
 		adapter->session.ap.beacon = NULL;
 	}
+	if (QDF_IS_STATUS_SUCCESS(status))
+		hdd_place_marker(adapter, "STOP with SUCCESS", NULL);
+	else
+		hdd_place_marker(adapter, "STOP with FAILURE", NULL);
 
 	hdd_exit();
 
@@ -6768,6 +6782,7 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
 		adapter->session.ap.sap_config.ch_width_orig =
 						chandef->width;
 
+		hdd_place_marker(adapter, "TRY TO START", NULL);
 		status =
 			wlan_hdd_cfg80211_start_bss(adapter,
 				&params->beacon,
@@ -6811,11 +6826,14 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
 	goto success;
 
 err_start_bss:
+	hdd_place_marker(adapter, "START with FAILURE", NULL);
 	if (adapter->session.ap.beacon)
 		qdf_mem_free(adapter->session.ap.beacon);
 	adapter->session.ap.beacon = NULL;
 
 success:
+	if (QDF_IS_STATUS_SUCCESS(status))
+		hdd_place_marker(adapter, "START with SUCCESS", NULL);
 	hdd_exit();
 	return status;
 }

+ 7 - 0
core/hdd/src/wlan_hdd_main.c

@@ -198,6 +198,7 @@
 #include "wlan_hdd_thermal.h"
 #include "osif_cm_util.h"
 #include "wlan_hdd_gpio_wakeup.h"
+#include "wlan_hdd_bootup_marker.h"
 
 #ifdef MODULE
 #define WLAN_MODULE_NAME  module_name(THIS_MODULE)
@@ -16735,6 +16736,7 @@ int hdd_driver_load(void)
 
 	pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME,
 	       g_wlan_driver_version);
+	hdd_place_marker(NULL, "START LOADING", NULL);
 
 	status = hdd_qdf_init();
 	if (QDF_IS_STATUS_ERROR(status)) {
@@ -16810,6 +16812,7 @@ int hdd_driver_load(void)
 	}
 
 	hdd_debug("%s: driver loaded", WLAN_MODULE_NAME);
+	hdd_place_marker(NULL, "DRIVER LOADED", NULL);
 
 	return 0;
 
@@ -16861,6 +16864,7 @@ void hdd_driver_unload(void)
 
 	pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME,
 		QWLAN_VERSIONSTR);
+	hdd_place_marker(NULL, "START UNLOADING", NULL);
 
 	/*
 	 * Wait for any trans to complete and then start the driver trans
@@ -16873,6 +16877,7 @@ void hdd_driver_unload(void)
 	QDF_BUG(QDF_IS_STATUS_SUCCESS(status));
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("Unable to unload wlan; status:%u", status);
+		hdd_place_marker(NULL, "UNLOAD FAILURE", NULL);
 		return;
 	}
 
@@ -16911,6 +16916,7 @@ void hdd_driver_unload(void)
 	QDF_BUG(QDF_IS_STATUS_SUCCESS(status));
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("Unable to unload wlan; status:%u", status);
+		hdd_place_marker(NULL, "UNLOAD FAILURE", NULL);
 		return;
 	}
 
@@ -16932,6 +16938,7 @@ void hdd_driver_unload(void)
 	osif_sync_deinit();
 
 	hdd_qdf_deinit();
+	hdd_place_marker(NULL, "UNLOAD DONE", NULL);
 }
 
 #ifdef FEATURE_WLAN_RESIDENT_DRIVER