From b4d37620f3b0f4dc19fd5f2d7ebac4860745afdc Mon Sep 17 00:00:00 2001 From: Naveen Rawat Date: Fri, 13 Nov 2015 16:15:25 -0800 Subject: [PATCH] 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 --- core/hdd/src/wlan_hdd_ocb.c | 3 +-- core/sme/inc/sme_api.h | 4 ++++ core/sme/src/common/sme_api.c | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/core/hdd/src/wlan_hdd_ocb.c b/core/hdd/src/wlan_hdd_ocb.c index a34959d2f292..10674cbfcff0 100644 --- a/core/hdd/src/wlan_hdd_ocb.c +++ b/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, diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 43a6e8d8b1d9..c8e1e361e4e1 100644 --- a/core/sme/inc/sme_api.h +++ b/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); diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index f91b44ca8982..ac42abd8e347 100644 --- a/core/sme/src/common/sme_api.c +++ b/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