eHalStatus ccmCfgGetStr(tHalHandle hHal, tANI_U32 cfgId, tANI_U8 *pBuf, tANI_U32 *pLength) { tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); tHddHandle hHdd; eHalStatus status = eHAL_STATUS_SUCCESS ; tCfgReq *req; if (!pMac) return eHAL_STATUS_FAILURE; hHdd = halHandle2HddHandle(hHal); req = pMac->ccm.comp[cfgId] ; if (req && req->state == eCCM_REQ_DONE && (tANI_U32)req->length <= *pLength) { *pLength = req->length ; vos_mem_copy((void *)pBuf, (void *)req->ccmPtr, req->length); } else { if (wlan_cfgGetStr(pMac, (tANI_U16)cfgId, pBuf, pLength) != eSIR_SUCCESS) status = eHAL_STATUS_FAILURE; } return status ; }
eHalStatus ccmOpen(tHalHandle hHal) { tHddHandle hHdd = halHandle2HddHandle(hHal); tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); vos_mem_set(&pMac->ccm, sizeof(tCcm), 0); return palSpinLockAlloc(hHdd, &pMac->ccm.lock); }
eHalStatus ccmOpen(tHalHandle hHal) { tHddHandle hHdd = halHandle2HddHandle(hHal); tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); (void)palZeroMemory(hHdd, &pMac->ccm, sizeof(tCcm)) ; return palSpinLockAlloc(hHdd, &pMac->ccm.lock); }
static eHalStatus cfgSet(tHalHandle hHal, tANI_U32 cfgId, tANI_U32 type, tANI_S32 length, void * ccmPtr, tANI_U32 ccmValue, tCcmCfgSetCallback callback, eAniBoolean toBeSaved) { tHddHandle hHdd = halHandle2HddHandle(hHal); tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); eHalStatus status; tCfgReq *req ; if (pal_in_interrupt()) { #ifdef CCM_DEBUG2 smsLog(pMac, LOG1, FL("WNI_CFG_%s (%d 0x%x), in_interrupt()=TRUE"), gCfgParamName[cfgId], (int)cfgId, (int)cfgId); #endif status = cfgSetSub(pMac, hHdd, cfgId, type, length, ccmPtr, ccmValue, callback, toBeSaved, NULL, &req); } else { void *sem ; #ifdef CCM_DEBUG2 smsLog(pMac, LOG1, FL("WNI_CFG_%s (%d 0x%x), in_interrupt()=FALSE"), gCfgParamName[cfgId], (int)cfgId, (int)cfgId); #endif pal_local_bh_disable() ; status = palMutexAllocLocked( hHdd, &sem ) ; if (status != eHAL_STATUS_SUCCESS) { smsLog(pMac, LOGE, FL("mutex alloc failed")); sem = NULL; } else { status = cfgSetSub(pMac, hHdd, cfgId, type, length, ccmPtr, ccmValue, callback, toBeSaved, sem, &req); if ((status != eHAL_STATUS_SUCCESS) || (req == NULL)) { //Either it fails to send or the req is finished already palSemaphoreFree( hHdd, sem ); sem = NULL; } } pal_local_bh_enable() ; if ((status == eHAL_STATUS_SUCCESS) && (sem != NULL)) { #ifdef CCM_DEBUG smsLog(pMac, LOG1, FL("ccmWaitForCompletion(%p)"), req->done); #endif ccmWaitForCompletion(hHdd, sem); #ifdef CCM_DEBUG smsLog(pMac, LOG1, FL("free(%p)"), req->done); #endif palSemaphoreFree( hHdd, sem ) ; } } return status ; }
eHalStatus ccmCfgUpdate(tHalHandle hHal, tCcmCfgSetCallback callback) { tHddHandle hHdd = halHandle2HddHandle(hHal); tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); eHalStatus status ; pal_local_bh_disable() ; status = cfgUpdate(pMac, hHdd, callback) ; if (status == eHAL_STATUS_SUCCESS) { if (pMac->ccm.replay.nr_param == 0) { /* there is nothing saved at comp[], so we are done! */ pMac->ccm.replay.started = 0 ; } else { /* we have sent update message to MAC SW */ void *sem ; status = palMutexAllocLocked( hHdd, &sem ) ; if (status != eHAL_STATUS_SUCCESS) { smsLog(pMac, LOGE, FL("mutex alloc failed")); pMac->ccm.replay.started = 0 ; } else { pMac->ccm.replay.done = sem ; } } } pal_local_bh_enable() ; /* Waiting here ... */ if (status == eHAL_STATUS_SUCCESS && pMac->ccm.replay.done) { #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("ccmWaitForCompletion(%p)"), pMac->ccm.replay.done); #endif ccmWaitForCompletion(hHdd, pMac->ccm.replay.done); #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("free(%p)"), pMac->ccm.replay.done); #endif palSemaphoreFree( hHdd, pMac->ccm.replay.done) ; } return status ; }
eHalStatus ccmClose(tHalHandle hHal) { tHddHandle hHdd = halHandle2HddHandle(hHal); tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); tANI_U32 i ; tCfgReq *req ; ccmStop(hHal); /* Go thru comp[] to free all saved requests */ for (i = 0 ; i < CFG_PARAM_MAX_NUM ; ++i) { if ((req = pMac->ccm.comp[i]) != NULL) { freeCfgReq(hHdd, req); } } return palSpinLockFree(hHdd, pMac->ccm.lock); }
static void purgeReqQ(tHalHandle hHal) { tHddHandle hHdd = halHandle2HddHandle(hHal); tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); tCfgReq *req, *tmp ; for (req = pMac->ccm.reqQ.head; req; req = tmp) { /* loop thru reqQ and invoke callback to return failure */ smsLog(pMac, LOGW, FL("deleting cfgReq, cfgid=%d"), (int)req->cfgId); tmp = req->next ; if (req->callback) { req->callback(hHal, eHAL_STATUS_FAILURE); } palSpinLockTake(hHdd, pMac->ccm.lock); del_req(req, &pMac->ccm.reqQ); palSpinLockGive(hHdd, pMac->ccm.lock); freeCfgReq(hHdd, req); } return ; }
/* This function executes in (Linux) softirq context */ void ccmCfgCnfMsgHandler(tHalHandle hHal, void *m) { tHddHandle hHdd = halHandle2HddHandle(hHal); tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); tSirMbMsg *msg = (tSirMbMsg *)m ; tANI_U32 result, cfgId ; tCfgReq *req, *old ; #if 0 if (pMac->ccm.state != eCCM_STARTED) { return ; } #endif result = pal_be32_to_cpu(msg->data[0]); cfgId = pal_be32_to_cpu(msg->data[1]); if (pMac->ccm.replay.started && cfgId == CFG_UPDATE_MAGIC_DWORD) { pMac->ccm.replay.in_progress = 1 ; return ; } if (pMac->ccm.replay.in_progress) { /* save error code */ if (!CCM_IS_RESULT_SUCCESS(result)) { pMac->ccm.replay.result = result ; } if (--pMac->ccm.replay.nr_param == 0) { pMac->ccm.replay.in_progress = 0 ; if (pMac->ccm.replay.callback) { pMac->ccm.replay.callback(hHal, pMac->ccm.replay.result); } pMac->ccm.replay.started = 0 ; /* Wake up the sleeping process */ #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("ccmComplete(%p)"), pMac->ccm.replay.done); #endif ccmComplete(hHdd, pMac->ccm.replay.done); //Let go with the rest of the set CFGs waiting. sendQueuedReqToMacSw(pMac, hHdd); } } else { /* * Try to match this response with the request. * What if i could not find the req entry ??? */ req = pMac->ccm.reqQ.head ; if (req) { if (req->cfgId == cfgId && req->state == eCCM_REQ_SENT) { palSpinLockTake(hHdd, pMac->ccm.lock); del_req(req, &pMac->ccm.reqQ); palSpinLockGive(hHdd, pMac->ccm.lock); req->state = eCCM_REQ_DONE ; if (result == WNI_CFG_NEED_RESTART || result == WNI_CFG_NEED_RELOAD) { #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("need restart/reload, cfgId=%d"), req->cfgId) ; #endif //purgeReqQ(hHal); } /* invoke callback */ if (req->callback) { #ifdef CCM_DEBUG req->callback(hHal, cfgId) ; #else req->callback(hHal, result) ; #endif } /* Wake up the sleeping process */ #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("cfgId=%ld, calling ccmComplete(%p)"), cfgId, req->done); #endif ccmComplete(hHdd, req->done); /* move the completed req from reqQ to comp[] */ if (req->toBeSaved && (CCM_IS_RESULT_SUCCESS(result))) { if (cfgId < CFG_PARAM_MAX_NUM) { if ((old = pMac->ccm.comp[cfgId]) != NULL) { freeCfgReq(hHdd, old) ; } pMac->ccm.comp[cfgId] = req ; } } else { freeCfgReq(hHdd, req) ; } sendQueuedReqToMacSw(pMac, hHdd); } else { smsLog( pMac, LOGW, FL("can not match RSP with REQ, rspcfgid=%d result=%d reqcfgid=%d reqstate=%d"), (int)cfgId, (int)result, req->cfgId, req->state); #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("ccmComplete(%p)"), req->done); #endif } } } return ; }
void ccmCfgCnfMsgHandler(tHalHandle hHal, void *m) { tHddHandle hHdd = halHandle2HddHandle(hHal); tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); tSirMbMsg *msg = (tSirMbMsg *)m ; tANI_U32 result, cfgId ; tCfgReq *req, *old ; #if 0 if (pMac->ccm.state != eCCM_STARTED) { return ; } #endif result = pal_be32_to_cpu(msg->data[0]); cfgId = pal_be32_to_cpu(msg->data[1]); if (pMac->ccm.replay.started && cfgId == CFG_UPDATE_MAGIC_DWORD) { pMac->ccm.replay.in_progress = 1 ; return ; } if (pMac->ccm.replay.in_progress) { if (!CCM_IS_RESULT_SUCCESS(result)) { pMac->ccm.replay.result = result ; } if (--pMac->ccm.replay.nr_param == 0) { pMac->ccm.replay.in_progress = 0 ; if (pMac->ccm.replay.callback) { pMac->ccm.replay.callback(hHal, pMac->ccm.replay.result); } pMac->ccm.replay.started = 0 ; #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("ccmComplete(%p)"), pMac->ccm.replay.done); #endif ccmComplete(hHdd, pMac->ccm.replay.done); sendQueuedReqToMacSw(pMac, hHdd); } } else { req = pMac->ccm.reqQ.head ; if (req) { if (req->cfgId == cfgId && req->state == eCCM_REQ_SENT) { palSpinLockTake(hHdd, pMac->ccm.lock); del_req(req, &pMac->ccm.reqQ); palSpinLockGive(hHdd, pMac->ccm.lock); req->state = eCCM_REQ_DONE ; if (result == WNI_CFG_NEED_RESTART || result == WNI_CFG_NEED_RELOAD) { #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("need restart/reload, cfgId=%d"), req->cfgId) ; #endif } if (req->callback) { #ifdef CCM_DEBUG req->callback(hHal, cfgId) ; #else req->callback(hHal, result) ; #endif } #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("cfgId=%ld, calling ccmComplete(%p)"), cfgId, req->done); #endif ccmComplete(hHdd, req->done); if (req->toBeSaved && (CCM_IS_RESULT_SUCCESS(result))) { if (cfgId < CFG_PARAM_MAX_NUM) { if ((old = pMac->ccm.comp[cfgId]) != NULL) { freeCfgReq(hHdd, old) ; } pMac->ccm.comp[cfgId] = req ; } } else { freeCfgReq(hHdd, req) ; } sendQueuedReqToMacSw(pMac, hHdd); } else { smsLog( pMac, LOGW, FL("can not match RSP with REQ, rspcfgid=%d result=%d reqcfgid=%d reqstate=%d"), (int)cfgId, (int)result, req->cfgId, req->state); #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("ccmComplete(%p)"), req->done); #endif } } } return ; }