Bladeren bron

qcacld: Fix layering violation in __wlan_hdd_cfg80211_ocb_start_timing_advert()

This is qcacld-2.0 to qcacld-3.0 propagation

HDD directly calls in to MAC layer function with mac context as one
of the parameters which is a software layering violation.
Fix the issue by introducing a SME api which accepts hal handle as
one of the parameters instead of mac context and call the SME function
from HDD,  which calls the MAC api with correct function parameters.

Change-Id: Iaac4ad7b67b0cb0f7b8b0d08e32904833afad707
CRs-Fixed: 913015
Naveen Rawat 9 jaren geleden
bovenliggende
commit
a4215acb60
3 gewijzigde bestanden met toevoegingen van 29 en 2 verwijderingen
  1. 1 2
      core/hdd/src/wlan_hdd_ocb.c
  2. 4 0
      core/sme/inc/sme_api.h
  3. 24 0
      core/sme/src/common/sme_api.c

+ 1 - 2
core/hdd/src/wlan_hdd_ocb.c

@@ -1202,7 +1202,6 @@ __wlan_hdd_cfg80211_ocb_start_timing_advert(struct wiphy *wiphy,
 	hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
 	struct net_device *dev = wdev->netdev;
 	hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
-	tpAniSirGlobal mac_ctx = PMAC_STRUCT(WLAN_HDD_GET_HAL_CTX(adapter));
 	struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_OCB_START_TIMING_ADVERT_MAX + 1];
 	struct sir_ocb_timing_advert *timing_advert;
 	int rc = -EINVAL;
@@ -1256,7 +1255,7 @@ __wlan_hdd_cfg80211_ocb_start_timing_advert(struct wiphy *wiphy,
 		tb[QCA_WLAN_VENDOR_ATTR_OCB_START_TIMING_ADVERT_REPEAT_RATE]);
 
 	timing_advert->template_length =
-		sch_gen_timing_advert_frame(mac_ctx,
+		sme_ocb_gen_timing_advert_frame(hdd_ctx->hHal,
 			*(tSirMacAddr *)&adapter->macAddressCurrent.bytes,
 			&timing_advert->template_value,
 			&timing_advert->timestamp_offset,

+ 4 - 0
core/sme/inc/sme_api.h

@@ -1026,6 +1026,10 @@ CDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
 CDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
 	struct sir_ocb_timing_advert *timing_advert);
 
+int sme_ocb_gen_timing_advert_frame(tHalHandle hHal, tSirMacAddr self_addr,
+				    uint8_t **buf, uint32_t *timestamp_offset,
+				    uint32_t *time_value_offset);
+
 CDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
 				 ocb_callback callback,
 				 struct sir_ocb_get_tsf_timer *request);

+ 24 - 0
core/sme/src/common/sme_api.c

@@ -58,6 +58,7 @@
 #include "cfg_api.h"
 #include "sme_power_save_api.h"
 #include "wma.h"
+#include "sch_api.h"
 
 extern tSirRetStatus u_mac_post_ctrl_msg(void *pSirGlobal, tSirMbMsg *pMb);
 
@@ -10935,6 +10936,29 @@ end:
 	return status;
 }
 
+/**
+ * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
+ * @hal_handle: reference to the HAL
+ * @self_addr: the self MAC address
+ * @buf: the buffer that will contain the frame
+ * @timestamp_offset: return for the offset of the timestamp field
+ * @time_value_offset: return for the time_value field in the TA IE
+ *
+ * Return: the length of the buffer.
+ */
+int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
+				    tSirMacAddr self_addr, uint8_t **buf,
+				    uint32_t *timestamp_offset,
+				    uint32_t *time_value_offset)
+{
+	int template_length;
+	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
+
+	template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
+						  timestamp_offset,
+						  time_value_offset);
+	return template_length;
+}
 /**
  * sme_ocb_get_tsf_timer() - Get the TSF timer value
  * @hHal: reference to the HAL