/* * CCM_STRING_TYPE CCM_INTEGER_TYPE * |<-------- 4 ----->| |<-------- 4 ----->| * +----------+ <-- msg --> +----------+ * |type | |type | * +----------+ +----------+ * |msgLen=24 | |msgLen=16 | * +----------+----------+ +----------+----------+ * | cfgId | | cfgId | * +---------------------+ +---------------------+ * | length=11 | | length=4 | * +---------------------+ +---------------------+ * | | | value | * | | +---------------------+ * | | * | +----+ * | |////| <- padding to 4-byte boundary * +----------------+----+ */ static eHalStatus sendCfg(tpAniSirGlobal pMac, tHddHandle hHdd, tCfgReq *req, tANI_BOOLEAN fRsp) { tSirMbMsg *msg; eHalStatus status; tANI_S16 msgLen = (tANI_U16)(4 + /* 4 bytes for msg header */ CFGOBJ_ID_SIZE + CFGOBJ_LEN_SIZE + CFGOBJ_ALIGN(req->length)) ; msg = vos_mem_malloc(msgLen); if ( NULL != msg ) { if( fRsp ) { msg->type = pal_cpu_to_be16(WNI_CFG_SET_REQ); } else { msg->type = pal_cpu_to_be16(WNI_CFG_SET_REQ_NO_RSP); } msg->msgLen = pal_cpu_to_be16(msgLen); (void)encodeCfgReq(hHdd, msg->data, req->cfgId, req->length, req->ccmPtr, req->ccmValue, req->type) ; status = palSendMBMessage(hHdd, msg) ; if (status != eHAL_STATUS_SUCCESS) { smsLog( pMac, LOGW, FL("palSendMBMessage() failed")); //No need to free msg. palSendMBMessage frees it. status = eHAL_STATUS_FAILURE ; } } else { smsLog( pMac, LOGW, FL("failed to allocate memory(len=%d)"), msgLen ); status = eHAL_STATUS_FAILURE; } return status ; }
static eHalStatus sendCfg(tpAniSirGlobal pMac, tHddHandle hHdd, tCfgReq *req, tANI_BOOLEAN fRsp) { tSirMbMsg *msg; eHalStatus status; tANI_S16 msgLen = (tANI_U16)(4 + CFGOBJ_ID_SIZE + CFGOBJ_LEN_SIZE + CFGOBJ_ALIGN(req->length)) ; status = palAllocateMemory(hHdd, (void **)&msg, msgLen); if (status == eHAL_STATUS_SUCCESS) { if( fRsp ) { msg->type = pal_cpu_to_be16(WNI_CFG_SET_REQ); } else { msg->type = pal_cpu_to_be16(WNI_CFG_SET_REQ_NO_RSP); } msg->msgLen = pal_cpu_to_be16(msgLen); (void)encodeCfgReq(hHdd, msg->data, req->cfgId, req->length, req->ccmPtr, req->ccmValue, req->type) ; status = palSendMBMessage(hHdd, msg) ; if (status != eHAL_STATUS_SUCCESS) { smsLog( pMac, LOGE, FL("palSendMBMessage() failed")); status = eHAL_STATUS_FAILURE ; } } else { smsLog( pMac, LOGW, FL("palAllocateMemory(len=%d)"), msgLen ); } return status ; }
/* * Loop thru comp[] and form an ANI message which contains all completed cfgIds. * The message begins with an INTEGER parameter (cfgId=CFG_UPDATE_MAGIC_DWORD) * to mark the start of the message. */ static eHalStatus cfgUpdate(tpAniSirGlobal pMac, tHddHandle hHdd, tCcmCfgSetCallback callback) { tANI_U32 i, *pl ; tCfgReq *req ; tSirMbMsg *msg ; eHalStatus status ; tANI_S16 msgLen = 4 + /* 4 bytes for msg header */ /* for CFG_UPDATE_MAGIC_DWORD */ CFGOBJ_ID_SIZE + CFGOBJ_LEN_SIZE + CFGOBJ_INTEGER_VALUE_SIZE ; if (pMac->ccm.state == eCCM_STOPPED || pMac->ccm.replay.started) { status = eHAL_STATUS_FAILURE ; goto end ; } palSpinLockTake(hHdd, pMac->ccm.lock); pMac->ccm.replay.started = 1 ; pMac->ccm.replay.nr_param = 0 ; palSpinLockGive(hHdd, pMac->ccm.lock); /* Calculate message length */ for (i = 0 ; i < CFG_PARAM_MAX_NUM ; ++i) { if ((req = pMac->ccm.comp[i]) != NULL) { msgLen += (tANI_S16)(CFGOBJ_ID_SIZE + CFGOBJ_LEN_SIZE + CFGOBJ_ALIGN(req->length)) ; pMac->ccm.replay.nr_param += 1 ; #ifdef CCM_DEBUG smsLog(pMac, LOGW, FL("cfgId=%d"), req->cfgId); #endif } } if (pMac->ccm.replay.nr_param == 0) { if (callback) { callback((tHalHandle)pMac, WNI_CFG_SUCCESS) ; } status = eHAL_STATUS_SUCCESS ; goto end ; } pMac->ccm.replay.in_progress = 0 ; pMac->ccm.replay.result = WNI_CFG_SUCCESS ; pMac->ccm.replay.callback = callback ; pMac->ccm.replay.done = NULL ; msg = vos_mem_malloc(msgLen); if ( NULL == msg ) { pMac->ccm.replay.started = 0 ; status = eHAL_STATUS_FAILURE; goto end; } msg->type = pal_cpu_to_be16(WNI_CFG_SET_REQ); msg->msgLen = pal_cpu_to_be16(msgLen); /* Encode the starting cfgId */ pl = encodeCfgReq(hHdd, msg->data, CFG_UPDATE_MAGIC_DWORD, 4, NULL, 0, CCM_INTEGER_TYPE) ; /* Encode the saved cfg requests */ for (i = 0 ; i < CFG_PARAM_MAX_NUM ; ++i) { if ((req = pMac->ccm.comp[i]) != NULL) { pl = encodeCfgReq(hHdd, pl, req->cfgId, req->length, req->ccmPtr, req->ccmValue, req->type) ; } } status = palSendMBMessage(hHdd, msg) ; if (status != eHAL_STATUS_SUCCESS) { smsLog(pMac, LOGW, FL("palSendMBMessage() failed. status=%d"), status); pMac->ccm.replay.started = 0 ; //No need to free msg. palSendMBMessage frees it. goto end ; } end: return status ; }