Browse Source

qcacld-3.0: Refactor suspend/resume and def_pkt_filter APIs

Refactor the following APIs to iterate all the links in
the adapter and add vdev_id argument to packet filter APIs
to configure each VDEV in the process of iterating adapter.

1) hdd_resume_wlan()
2) hdd_suspend_wlan()
3) hdd_disable_default_pkt_filters()
4) hdd_enable_default_pkt_filters()

Change-Id: I6dd439dfbf1cb94f0a195fd3eed91007b61f403c
CRs-Fixed: 3522971
Vinod Kumar Pirla 2 years ago
parent
commit
15829aeaad

+ 11 - 6
core/hdd/inc/wlan_hdd_packet_filter_api.h

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. 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
@@ -33,20 +34,24 @@
 /**
  * hdd_enable_default_pkt_filters() - Enable default packet filters based
  * on, filters bit map provided in INI, when target goes to suspend mode
- * @adapter: Adapter context for which default filters to be configure
+ * @hdd_ctx: Global HDD Context
+ * @vdev_id: vdev_id
  *
  * Return: zero if success, non-zero otherwise
  */
-int hdd_enable_default_pkt_filters(struct hdd_adapter *adapter);
+int
+hdd_enable_default_pkt_filters(struct hdd_context *hdd_ctx, uint8_t vdev_id);
 
 /**
  * hdd_disable_default_pkt_filters() - Disable default packet filters based
  * on, filters bit map provided in INI, when target resumes
- * @adapter: Adapter context for which default filters to be cleared
+ * @hdd_ctx: Global HDD Context
+ * @vdev_id: vdev_id
  *
  * Return: zero if success, non-zero otherwise
  */
-int hdd_disable_default_pkt_filters(struct hdd_adapter *adapter);
+int
+hdd_disable_default_pkt_filters(struct hdd_context *hdd_ctx, uint8_t vdev_id);
 
 /**
  * wlan_hdd_set_filter() - Set packet filter
@@ -63,13 +68,13 @@ int wlan_hdd_set_filter(struct hdd_context *hdd_ctx,
 #else /* WLAN_FEATURE_PACKET_FILTERING */
 
 static inline int
-hdd_enable_default_pkt_filters(struct hdd_adapter *adapter)
+hdd_enable_default_pkt_filters(struct hdd_context *hdd_ctx, uint8_t vdev_id)
 {
 	return 0;
 }
 
 static inline int
-hdd_disable_default_pkt_filters(struct hdd_adapter *adapter)
+hdd_disable_default_pkt_filters(struct hdd_context *hdd_ctx, uint8_t vdev_id)
 {
 	return 0;
 }

+ 6 - 18
core/hdd/src/wlan_hdd_packet_filter.c

@@ -28,16 +28,11 @@
 #include "wlan_hdd_packet_filter_api.h"
 #include "wlan_hdd_packet_filter_rules.h"
 
-int hdd_enable_default_pkt_filters(struct hdd_adapter *adapter)
+int
+hdd_enable_default_pkt_filters(struct hdd_context *hdd_ctx, uint8_t vdev_id)
 {
-	struct hdd_context *hdd_ctx;
 	uint8_t filters = 0, i = 0, filter_id = 1;
 
-	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
-	if (!hdd_ctx) {
-		hdd_err("HDD context is Null!!!");
-		return -EINVAL;
-	}
 	if (hdd_ctx->user_configured_pkt_filter_rules) {
 		hdd_info("user has defined pkt filter run hence skipping default packet filter rule");
 		return 0;
@@ -52,7 +47,7 @@ int hdd_enable_default_pkt_filters(struct hdd_adapter *adapter)
 			packet_filter_default_rules[i].filter_id = filter_id;
 			wlan_hdd_set_filter(hdd_ctx,
 					    &packet_filter_default_rules[i],
-					    adapter->deflink->vdev_id);
+					    vdev_id);
 			filter_id++;
 		}
 		filters = filters >> 1;
@@ -62,19 +57,12 @@ int hdd_enable_default_pkt_filters(struct hdd_adapter *adapter)
 	return 0;
 }
 
-int hdd_disable_default_pkt_filters(struct hdd_adapter *adapter)
+int
+hdd_disable_default_pkt_filters(struct hdd_context *hdd_ctx, uint8_t vdev_id)
 {
-	struct hdd_context *hdd_ctx;
 	uint8_t filters = 0, i = 0, filter_id = 1;
-
 	struct pkt_filter_cfg packet_filter_default_rules = {0};
 
-	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
-	if (!hdd_ctx) {
-		hdd_err("HDD context is Null!!!");
-		return -EINVAL;
-	}
-
 	if (hdd_ctx->user_configured_pkt_filter_rules) {
 		hdd_info("user has defined pkt filter run hence skipping default packet filter rule");
 		return 0;
@@ -91,7 +79,7 @@ int hdd_disable_default_pkt_filters(struct hdd_adapter *adapter)
 			packet_filter_default_rules.filter_id = filter_id;
 			wlan_hdd_set_filter(hdd_ctx,
 					    &packet_filter_default_rules,
-					    adapter->deflink->vdev_id);
+					    vdev_id);
 			filter_id++;
 		}
 		filters = filters >> 1;

+ 22 - 20
core/hdd/src/wlan_hdd_power.c

@@ -1587,6 +1587,7 @@ hdd_suspend_wlan(void)
 	QDF_STATUS status;
 	struct hdd_adapter *adapter = NULL, *next_adapter = NULL;
 	uint32_t conn_state_mask = 0;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_info("WLAN being suspended by OS");
 
@@ -1602,18 +1603,18 @@ hdd_suspend_wlan(void)
 
 	hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter,
 					   NET_DEV_HOLD_SUSPEND_WLAN) {
-		if (wlan_hdd_validate_vdev_id(adapter->deflink->vdev_id)) {
-			hdd_adapter_dev_put_debug(adapter,
-						  NET_DEV_HOLD_SUSPEND_WLAN);
-			continue;
-		}
+		hdd_adapter_for_each_active_link_info(adapter, link_info) {
+			if (wlan_hdd_validate_vdev_id(link_info->vdev_id))
+				continue;
 
-		if (adapter->device_mode == QDF_STA_MODE)
-			status = hdd_enable_default_pkt_filters(adapter);
+			if (adapter->device_mode == QDF_STA_MODE)
+				status = hdd_enable_default_pkt_filters(
+						hdd_ctx, link_info->vdev_id);
 
-		/* Configure supported OffLoads */
-		hdd_enable_host_offloads(adapter, pmo_apps_suspend);
-		hdd_update_conn_state_mask(adapter, &conn_state_mask);
+			/* Configure supported OffLoads */
+			hdd_enable_host_offloads(adapter, pmo_apps_suspend);
+			hdd_update_conn_state_mask(adapter, &conn_state_mask);
+		}
 		hdd_adapter_dev_put_debug(adapter, NET_DEV_HOLD_SUSPEND_WLAN);
 	}
 
@@ -1643,6 +1644,7 @@ static int hdd_resume_wlan(void)
 	struct hdd_context *hdd_ctx;
 	struct hdd_adapter *adapter, *next_adapter = NULL;
 	QDF_STATUS status;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_info("WLAN being resumed by OS");
 
@@ -1662,19 +1664,19 @@ static int hdd_resume_wlan(void)
 	/*loop through all adapters. Concurrency */
 	hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter,
 					   NET_DEV_HOLD_RESUME_WLAN) {
-		if (wlan_hdd_validate_vdev_id(adapter->deflink->vdev_id)) {
-			hdd_adapter_dev_put_debug(adapter,
-						  NET_DEV_HOLD_RESUME_WLAN);
-			continue;
-		}
+		hdd_adapter_for_each_active_link_info(adapter, link_info) {
+			if (wlan_hdd_validate_vdev_id(link_info->vdev_id))
+				continue;
 
-		/* Disable supported OffLoads */
-		hdd_disable_host_offloads(adapter, pmo_apps_resume);
+			/* Disable supported OffLoads */
+			hdd_disable_host_offloads(adapter, pmo_apps_resume);
 
-		if (adapter->device_mode == QDF_STA_MODE)
-			status = hdd_disable_default_pkt_filters(adapter);
+			if (adapter->device_mode == QDF_STA_MODE)
+				status = hdd_disable_default_pkt_filters(
+						hdd_ctx, link_info->vdev_id);
 
-		hdd_restart_tsf_sync_post_wlan_resume(adapter);
+			hdd_restart_tsf_sync_post_wlan_resume(adapter);
+		}
 		hdd_adapter_dev_put_debug(adapter, NET_DEV_HOLD_RESUME_WLAN);
 	}