Quellcode durchsuchen

qcacmn: Allocate vdev private data along with vdev

Currently vdev private data osif_priv gets allocation
separately and requires to be de-alloc separately.
This de-alloc needs to be taken care at different places
based on the vdev create failure or whenever vdev is freed.
As vdev private data is associated to the vdev and needs to
be freed if vdev is not there, it is good to allocate this
private data along with vdev so that there is no need
to maintain allocation and de-allocation of vdev priv data
separately.
As part of this change alloc the vdev priv data along with
the vdev allocation as a single memory and free of the vdev priv
data will be taken care as part of vdev free.

Change-Id: Ib442958c2d8684706830782d339c589c5f5daddf
CRs-Fixed: 2636222
Ashish Kumar Dhanotiya vor 5 Jahren
Ursprung
Commit
dc6a3bab24

+ 8 - 6
umac/cmn_services/obj_mgr/inc/wlan_objmgr_vdev_obj.h

@@ -237,16 +237,18 @@
 /**
  * struct wlan_vdev_create_params - Create params, HDD/OSIF passes this
  *				    structure While creating VDEV
- * @opmode:      Opmode of VDEV
- * @flags:       create flags
- * @osifp:       OS structure
- * @macaddr[]:   MAC address
- * @mataddr[]:   MAT address
+ * @opmode:         Opmode of VDEV
+ * @flags:          create flags
+ * @size_vdev_priv: Size of vdev private
+ * @legacy_osif:    Legacy os_if private member
+ * @macaddr[]:      MAC address
+ * @mataddr[]:      MAT address
  */
 struct wlan_vdev_create_params {
 	enum QDF_OPMODE opmode;
 	uint32_t flags;
-	struct vdev_osif_priv *osifp;
+	size_t size_vdev_priv;
+	void *legacy_osif;
 	uint8_t macaddr[QDF_MAC_ADDR_SIZE];
 	uint8_t mataddr[QDF_MAC_ADDR_SIZE];
 };

+ 18 - 8
umac/cmn_services/obj_mgr/src/wlan_objmgr_vdev_obj.c

@@ -30,6 +30,8 @@
 #include "wlan_objmgr_pdev_obj_i.h"
 #include "wlan_objmgr_vdev_obj_i.h"
 #include <wlan_utility.h>
+#include <wlan_osif_priv.h>
+
 
 /**
  ** APIs to Create/Delete Global object APIs
@@ -110,7 +112,6 @@ static QDF_STATUS wlan_objmgr_vdev_obj_free(struct wlan_objmgr_vdev *vdev)
 
 	qdf_mem_free(vdev->vdev_mlme.bss_chan);
 	qdf_mem_free(vdev->vdev_mlme.des_chan);
-	qdf_mem_free(vdev->vdev_nif.osdev);
 	wlan_minidump_remove(vdev);
 	qdf_mem_free(vdev);
 
@@ -118,6 +119,17 @@ static QDF_STATUS wlan_objmgr_vdev_obj_free(struct wlan_objmgr_vdev *vdev)
 
 }
 
+static struct vdev_osif_priv *wlan_objmgr_vdev_get_osif_priv(
+						struct wlan_objmgr_vdev *vdev)
+{
+	struct vdev_osif_priv *osif_priv;
+
+	/* private data area immediately follows the struct wlan_objmgr_vdev */
+	osif_priv = (struct vdev_osif_priv *)(vdev + 1);
+
+	return osif_priv;
+}
+
 struct wlan_objmgr_vdev *wlan_objmgr_vdev_obj_create(
 			struct wlan_objmgr_pdev *pdev,
 			struct wlan_vdev_create_params *params)
@@ -142,7 +154,7 @@ struct wlan_objmgr_vdev *wlan_objmgr_vdev_obj_create(
 		return NULL;
 	}
 	/* Allocate vdev object memory */
-	vdev = qdf_mem_malloc(sizeof(*vdev));
+	vdev = qdf_mem_malloc(sizeof(*vdev) + params->size_vdev_priv);
 	if (!vdev)
 		return NULL;
 	vdev->obj_state = WLAN_OBJ_STATE_ALLOCATED;
@@ -199,7 +211,7 @@ struct wlan_objmgr_vdev *wlan_objmgr_vdev_obj_create(
 	/* Set create flags */
 	vdev->vdev_objmgr.c_flags = params->flags;
 	/* store os-specific pointer */
-	vdev->vdev_nif.osdev = params->osifp;
+	vdev->vdev_nif.osdev = wlan_objmgr_vdev_get_osif_priv(vdev);
 	/* peer count to 0 */
 	vdev->vdev_objmgr.wlan_peer_count = 0;
 	qdf_atomic_init(&vdev->vdev_objmgr.ref_cnt);
@@ -212,6 +224,9 @@ struct wlan_objmgr_vdev *wlan_objmgr_vdev_obj_create(
 		vdev->vdev_objmgr.max_peer_count =
 				wlan_pdev_get_max_peer_count(pdev);
 
+	if (params->legacy_osif)
+		vdev->vdev_nif.osdev->legacy_osif_priv = params->legacy_osif;
+
 	/* Initialize peer list */
 	qdf_list_create(&vdev->vdev_objmgr.wlan_peer_list,
 			vdev->vdev_objmgr.max_peer_count +
@@ -255,11 +270,6 @@ struct wlan_objmgr_vdev *wlan_objmgr_vdev_obj_create(
 		obj_mgr_err("VDEV comp objects creation failed for vdev-id:%d",
 			vdev->vdev_objmgr.vdev_id);
 		wlan_objmgr_vdev_obj_delete(vdev);
-		/*
-		 * Set params osifp to NULL as it is freed during vdev obj
-		 * delete, This prevents caller from performing double free.
-		 */
-		params->osifp = NULL;
 		return NULL;
 	}