浏览代码

qcacld-3.0: Add magic number in wlan_dp_link

Add magic number field in wlan_dp_link which is to
be used to identify the validity of dp_link.

Add logs in the dp_link free handler/callback.

Change-Id: I76e3149e1d72a9f5e69478734b6dbab5b4d8d922
CRs-Fixed: 3744331
Rakesh Pillai 1 年之前
父节点
当前提交
52cc76d329
共有 2 个文件被更改,包括 28 次插入3 次删除
  1. 4 0
      components/dp/core/inc/wlan_dp_priv.h
  2. 24 3
      components/dp/core/src/wlan_dp_main.c

+ 4 - 0
components/dp/core/inc/wlan_dp_priv.h

@@ -694,9 +694,12 @@ struct wlan_dp_intf {
 	qdf_list_t dp_link_list;
 };
 
+#define WLAN_DP_LINK_MAGIC 0x5F44505F4C494E4B	/* "_DP_LINK" in ASCII */
+
 /**
  * struct wlan_dp_link - DP link (corresponds to objmgr vdev)
  * @node: list node for membership in the DP links list
+ * @magic: magic number to identify validity of dp_link
  * @link_id: ID for this DP link (Same as vdev_id)
  * @mac_addr: mac address of this link
  * @dp_intf: Parent DP interface for this DP link
@@ -711,6 +714,7 @@ struct wlan_dp_intf {
  */
 struct wlan_dp_link {
 	qdf_list_node_t node;
+	uint64_t magic;
 	uint8_t link_id;
 	struct qdf_mac_addr mac_addr;
 	struct wlan_dp_intf *dp_intf;

+ 24 - 3
components/dp/core/src/wlan_dp_main.c

@@ -231,6 +231,11 @@ bool is_dp_link_valid(struct wlan_dp_link *dp_link)
 		return false;
 	}
 
+	if (dp_link->magic != WLAN_DP_LINK_MAGIC) {
+		dp_err("dp_link %pK bad magic %llx", dp_link, dp_link->magic);
+		return false;
+	}
+
 	dp_intf = dp_link->dp_intf;
 	ret = is_dp_intf_valid(dp_intf);
 	if (ret)
@@ -1196,6 +1201,7 @@ dp_vdev_obj_create_notification(struct wlan_objmgr_vdev *vdev, void *arg)
 	}
 
 	/* Update Parent interface details */
+	dp_link->magic = WLAN_DP_LINK_MAGIC;
 	dp_link->dp_intf = dp_intf;
 	qdf_spin_lock_bh(&dp_intf->dp_link_list_lock);
 	qdf_list_insert_front(&dp_intf->dp_link_list, &dp_link->node);
@@ -1255,12 +1261,20 @@ static void dp_link_handle_cdp_vdev_delete(struct wlan_dp_psoc_context *dp_ctx,
 
 	if (!dp_link->cdp_vdev_registered || dp_link->cdp_vdev_deleted) {
 		/* CDP vdev is not created/registered or already deleted */
+		dp_info("Free dp_link %pK id %d (" QDF_MAC_ADDR_FMT ")",
+			dp_link, dp_link->link_id,
+			QDF_MAC_ADDR_REF(dp_link->mac_addr.bytes));
+		dp_link->magic = 0;
 		qdf_mem_free(dp_link);
 	} else {
 		/*
 		 * Add it to inactive dp_link list, and it will be freed when
 		 * the CDP vdev gets deleted
 		 */
+		dp_info("Add to inactive list dp_link %pK id %d ("
+			QDF_MAC_ADDR_FMT ")",
+			dp_link, dp_link->link_id,
+			QDF_MAC_ADDR_REF(dp_link->mac_addr.bytes));
 		TAILQ_INSERT_TAIL(&dp_ctx->inactive_dp_link_list, dp_link,
 				  inactive_list_elem);
 		dp_link->destroyed = 1;
@@ -2012,12 +2026,11 @@ void wlan_dp_link_cdp_vdev_delete_notification(void *context)
 	struct wlan_dp_psoc_context *dp_ctx = NULL;
 	uint8_t found = 0;
 
-	/* TODO - What will happen if cdp vdev was never created ? */
-
 	/* dp_link will not be freed before this point. */
-	if (!dp_link)
+	if (!is_dp_link_valid(dp_link))
 		return;
 
+	dp_info("dp_link %pK id %d", dp_link, dp_link->link_id);
 	dp_intf = dp_link->dp_intf;
 	dp_ctx = dp_intf->dp_ctx;
 
@@ -2042,9 +2055,17 @@ void wlan_dp_link_cdp_vdev_delete_notification(void *context)
 		else
 			qdf_assert_always(0);
 
+		dp_info("Free dp_link %pK id %d (" QDF_MAC_ADDR_FMT ")",
+			dp_link, dp_link->link_id,
+			QDF_MAC_ADDR_REF(dp_link->mac_addr.bytes));
+		dp_link->magic = 0;
 		qdf_mem_free(dp_link);
 	} else {
 		/* dp_link not yet destroyed */
+		dp_info("CDP vdev delete for dp_link %pK id %d ("
+			QDF_MAC_ADDR_FMT ")",
+			dp_link, dp_link->link_id,
+			QDF_MAC_ADDR_REF(dp_link->mac_addr.bytes));
 		dp_link->cdp_vdev_deleted = 1;
 	}