Procházet zdrojové kódy

qcacld-3.0: Create dump_in_progress sysfs file

Based on new requirement create a sysfs file dump_in_progress,
this file has read and write functionalities for a bool variable,
if the value in this file is set to 1 cnss_diag will trigger
DEBUG_DUMP cmd to wpa_supplicant_8_lib through wpa_ctrl socket.
After log copy completion cnss_diag will reset sysfs node to 0.

Change-Id: I93f612d3caf4ef6ad5db98bc531ab091e96c7817
CRs-Fixed: 2971373
Ashish Kumar Dhanotiya před 3 roky
rodič
revize
a341934e9a
2 změnil soubory, kde provedl 152 přidání a 0 odebrání
  1. 2 0
      core/hdd/inc/wlan_hdd_main.h
  2. 150 0
      core/hdd/src/wlan_hdd_sysfs.c

+ 2 - 0
core/hdd/inc/wlan_hdd_main.h

@@ -1860,6 +1860,7 @@ struct hdd_adapter_ops_history {
  * @bbm_ctx: bus bandwidth manager context
  * @is_dual_mac_cfg_updated: indicate whether dual mac cfg has been updated
  * @twt_en_dis_work: work to send twt enable/disable cmd on MCC/SCC concurrency
+ * @dump_in_progress: Stores value of dump in progress
  */
 struct hdd_context {
 	struct wlan_objmgr_psoc *psoc;
@@ -2216,6 +2217,7 @@ struct hdd_context {
 	qdf_work_t twt_en_dis_work;
 #endif
 	bool is_wifi3_0_target;
+	bool dump_in_progress;
 };
 
 /**

+ 150 - 0
core/hdd/src/wlan_hdd_sysfs.c

@@ -90,6 +90,7 @@ static struct kobject *wlan_kobject;
 static struct kobject *driver_kobject;
 static struct kobject *fw_kobject;
 static struct kobject *psoc_kobject;
+static struct kobject *wifi_kobject;
 
 int
 hdd_sysfs_validate_and_copy_buf(char *dest_buf, size_t dest_buf_size,
@@ -492,6 +493,109 @@ static DEVICE_ATTR(beacon_stats, 0444,
 		   show_beacon_reception_stats, NULL);
 #endif
 
+static ssize_t
+__hdd_sysfs_dump_in_progress_store(struct hdd_context *hdd_ctx,
+				   struct kobj_attribute *attr,
+				   char const *buf, size_t count)
+{
+	char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
+	char *sptr, *token;
+	int value, ret;
+
+	if (!wlan_hdd_validate_modules_state(hdd_ctx))
+		return -EINVAL;
+
+	ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
+					      buf, count);
+	if (ret) {
+		hdd_err_rl("invalid input");
+		return ret;
+	}
+
+	sptr = buf_local;
+	/* Get value */
+	token = strsep(&sptr, " ");
+	if (!token)
+		return -EINVAL;
+	if (kstrtou32(token, 0, &value))
+		return -EINVAL;
+
+	hdd_debug_rl("dump in progress %d", value);
+	if (value < 0 || value > 1)
+		return -EINVAL;
+
+	hdd_ctx->dump_in_progress = value;
+
+	return count;
+}
+
+static ssize_t hdd_sysfs_dump_in_progress_store(struct kobject *kobj,
+						struct kobj_attribute *attr,
+						char const *buf, size_t count)
+{
+	struct osif_psoc_sync *psoc_sync;
+	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	ssize_t errno_size;
+	int ret;
+
+	ret = wlan_hdd_validate_context(hdd_ctx);
+	if (ret != 0)
+		return ret;
+
+	errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
+					     &psoc_sync);
+	if (errno_size)
+		return errno_size;
+
+	errno_size = __hdd_sysfs_dump_in_progress_store(hdd_ctx, attr,
+							buf, count);
+
+	osif_psoc_sync_op_stop(psoc_sync);
+
+	return errno_size;
+}
+
+static ssize_t  __hdd_sysfs_dump_in_progress_show(struct hdd_context *hdd_ctx,
+						  struct kobj_attribute *attr,
+						  char *buf)
+{
+	ssize_t ret_val;
+
+	hdd_debug_rl("dump in progress %d", hdd_ctx->dump_in_progress);
+	ret_val = scnprintf(buf, PAGE_SIZE, "%d\n", hdd_ctx->dump_in_progress);
+
+	return ret_val;
+}
+
+static ssize_t hdd_sysfs_dump_in_progress_show(struct kobject *kobj,
+					       struct kobj_attribute *attr,
+					       char *buf)
+{
+	struct osif_psoc_sync *psoc_sync;
+	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	ssize_t errno_size;
+	int ret;
+
+	ret = wlan_hdd_validate_context(hdd_ctx);
+	if (ret != 0)
+		return ret;
+
+	errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
+					     &psoc_sync);
+	if (errno_size)
+		return errno_size;
+
+	errno_size = __hdd_sysfs_dump_in_progress_show(hdd_ctx, attr, buf);
+
+	osif_psoc_sync_op_stop(psoc_sync);
+
+	return errno_size;
+}
+
+static struct kobj_attribute dump_in_progress_attribute =
+	__ATTR(dump_in_progress, 0660, hdd_sysfs_dump_in_progress_show,
+	       hdd_sysfs_dump_in_progress_store);
+
 static struct kobj_attribute dr_ver_attribute =
 	__ATTR(driver_version, 0440, show_driver_version, NULL);
 static struct kobj_attribute fw_ver_attribute =
@@ -560,6 +664,48 @@ static void hdd_sysfs_destroy_version_interface(void)
 	}
 }
 
+static void hdd_sysfs_create_wifi_root_obj(void)
+{
+	wifi_kobject = kobject_create_and_add("wifi", NULL);
+	if (!wifi_kobject)
+		hdd_err("could not allocate wifi kobject");
+}
+
+static void hdd_sysfs_destroy_wifi_root_obj(void)
+{
+	if (!wifi_kobject) {
+		hdd_err("could not get wifi kobject!");
+		return;
+	}
+	kobject_put(wifi_kobject);
+	wifi_kobject = NULL;
+}
+
+static void hdd_sysfs_create_dump_in_progress_interface(void)
+{
+	int error;
+
+	if (!wifi_kobject) {
+		hdd_err("could not get wifi kobject!");
+		return;
+	}
+	error = sysfs_create_file(wifi_kobject,
+				  &dump_in_progress_attribute.attr);
+	if (error)
+		hdd_err("could not create dump in progress sysfs file");
+}
+
+static void hdd_sysfs_destroy_dump_in_progress_interface(void)
+{
+	if (!wifi_kobject) {
+		hdd_err("could not get wifi kobject!");
+		return;
+	}
+
+	sysfs_remove_file(wifi_kobject,
+			  &dump_in_progress_attribute.attr);
+}
+
 #ifdef WLAN_POWER_DEBUG
 static void hdd_sysfs_create_powerstats_interface(void)
 {
@@ -825,8 +971,10 @@ void hdd_create_sysfs_files(struct hdd_context *hdd_ctx)
 	hdd_sysfs_create_driver_root_obj();
 	hdd_sysfs_create_version_interface(hdd_ctx->psoc);
 	hdd_sysfs_mem_stats_create(wlan_kobject);
+	hdd_sysfs_create_wifi_root_obj();
 	if  (QDF_GLOBAL_MISSION_MODE == hdd_get_conparam()) {
 		hdd_sysfs_create_powerstats_interface();
+		hdd_sysfs_create_dump_in_progress_interface();
 		hdd_sysfs_fw_mode_config_create(driver_kobject);
 		hdd_sysfs_scan_disable_create(driver_kobject);
 		hdd_sysfs_wow_ito_create(driver_kobject);
@@ -861,8 +1009,10 @@ void hdd_destroy_sysfs_files(void)
 		hdd_sysfs_wow_ito_destroy(driver_kobject);
 		hdd_sysfs_scan_disable_destroy(driver_kobject);
 		hdd_sysfs_fw_mode_config_destroy(driver_kobject);
+		hdd_sysfs_destroy_dump_in_progress_interface();
 		hdd_sysfs_destroy_powerstats_interface();
 	}
+	hdd_sysfs_destroy_wifi_root_obj();
 	hdd_sysfs_mem_stats_destroy(wlan_kobject);
 	hdd_sysfs_destroy_version_interface();
 	hdd_sysfs_destroy_driver_root_obj();