static void event_to_unifi_sys_hip_ind(FsmContext* context, CsrUint8* inputbuffer, CsrUint16 length) { CsrUint8* buffer = &inputbuffer[6]; UnifiSysHipInd_Evt evt; evt.mlmeCommandLength = event_unpack_CsrUint16(&buffer); evt.mlmeCommand = NULL; if (evt.mlmeCommandLength) { evt.mlmeCommand = (CsrUint8*)CsrPmalloc(evt.mlmeCommandLength); event_unpack_buffer(&buffer, evt.mlmeCommand, evt.mlmeCommandLength); } evt.dataRef1Length = event_unpack_CsrUint16(&buffer); evt.dataRef1 = NULL; if (evt.dataRef1Length) { evt.dataRef1 = (CsrUint8*)CsrPmalloc(evt.dataRef1Length); event_unpack_buffer(&buffer, evt.dataRef1, evt.dataRef1Length); } evt.dataRef2Length = event_unpack_CsrUint16(&buffer); evt.dataRef2 = NULL; if (evt.dataRef2Length) { evt.dataRef2 = (CsrUint8*)CsrPmalloc(evt.dataRef2Length); event_unpack_buffer(&buffer, evt.dataRef2, evt.dataRef2Length); } unifi_sys_hip_ind(context, evt.mlmeCommandLength, evt.mlmeCommand, evt.dataRef1Length, evt.dataRef1, evt.dataRef2Length, evt.dataRef2); CsrPfree(evt.mlmeCommand); CsrPfree(evt.dataRef1); CsrPfree(evt.dataRef2); }
int main(int argc, char **argv) { /* Create the Application Context */ linuxContext = (LinuxUserSpaceContext*) CsrPmalloc(sizeof(LinuxUserSpaceContext)); CsrMemSet(linuxContext, 0x00, sizeof(LinuxUserSpaceContext)); linuxContext->mainData = (MainData*) CsrPmalloc(sizeof(MainData)); #ifdef IPC_IP getMainData(linuxContext)->ipIpcCon = NULL; #endif #ifdef IPC_CHARDEVICE getMainData(linuxContext)->charIpcCon = NULL; #endif /* Set Trace levels from the command line */ sme_trace_initialise((CsrUint32)argc, argv); /* Send the first trace message */ sme_trace_entry((TR_STARTUP_SAP, "%s(%d)", __FUNCTION__, argc)); /* Initialise SME and scheduling */ sme_schedule_init(linuxContext, argc, argv); fsm_schedule(linuxContext); return 0; }
CsrUint16 serialise_pal_acl_data_ind(CsrUint8** resultBuffer, CsrUint16 dataLength, const CsrUint8 *data, CsrUint8 physicalLinkHandle, CsrUint16 aclOffset, unifi_FrameFreeFunction freeFunction) { CsrUint16 packedLength = 0; CsrUint32 packedSize = 6; CsrUint8* evt; CsrUint8* buffer; /* Calc Dymanic Size */ packedSize += 2; if (dataLength) { packedSize += dataLength; } packedSize += 1; packedSize += 2; packedSize += 4; evt = (CsrUint8*)CsrPmalloc(packedSize); buffer = evt; packedLength += event_pack_CsrUint16(&buffer, PAL_ACL_DATA_IND_ID); packedLength += event_pack_CsrUint16(&buffer, 0); packedLength += event_pack_CsrUint16(&buffer, 0); packedLength += event_pack_CsrUint16(&buffer, dataLength); if (dataLength) { packedLength += event_pack_buffer(&buffer, data, dataLength); } packedLength += event_pack_CsrUint8(&buffer, physicalLinkHandle); packedLength += event_pack_CsrUint16(&buffer, aclOffset); packedLength += event_pack_CsrUint32(&buffer, 0); *resultBuffer = evt; return packedLength; }
void paldata_pal_ctrl_link_create_req(FsmContext* context, void* appHandle, CsrUint16 logicalLinkHandle, CsrUint8 physicalLinkHandle, CsrUint16 userPriority, const unifi_MACAddress *remoteMacAddress, const unifi_MACAddress *localMacAddress, const unifi_AmpFlowSpec *txFlowSpec) { PalCtrlLinkCreateReq_Evt* evt = (PalCtrlLinkCreateReq_Evt*)CsrPmalloc(sizeof(PalCtrlLinkCreateReq_Evt)); INIT_EVENT_HEADER(evt, PAL_CTRL_LINK_CREATE_REQ_ID); evt->appHandle = appHandle; evt->logicalLinkHandle = logicalLinkHandle; evt->physicalLinkHandle = physicalLinkHandle; evt->userPriority = userPriority; CsrMemCpy(evt->remoteMacAddress.data, remoteMacAddress->data, 6); CsrMemCpy(evt->localMacAddress.data, localMacAddress->data, 6); evt->txFlowSpec.serviceType = txFlowSpec->serviceType; evt->txFlowSpec.maximumSduSize = txFlowSpec->maximumSduSize; evt->txFlowSpec.sduInterArrivalTime = txFlowSpec->sduInterArrivalTime; evt->txFlowSpec.accessLatency = txFlowSpec->accessLatency; evt->txFlowSpec.flushTimeout = txFlowSpec->flushTimeout; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
static CsrBool ipc_chardevice_message_recv(ipcConnection* con, CsrUint32 timeout_ms, CsrUint8 **message, CsrUint32 *length) { int r; *length = 0; sme_trace_entry((TR_IPC, "ipc_message_recv()")); if (!con || !con->impl) { sme_trace_error((TR_IPC, "ipc_message_recv(): Invalid connection")); return FALSE; } *length = 2048; *message = (CsrUint8*)CsrPmalloc(*length); if ((r = read(con->impl->fd, *message, *length)) <= 0) { sme_trace_error((TR_IPC, "ipc_message_recv(): read Failed %d, %d, %s\n", r, errno, strerror(errno))); return FALSE; } *length = ((CsrUint32)r) - sizeof(udi_msg_t); CsrMemMove(*message, &(*message)[sizeof(udi_msg_t)], *length); sme_trace_debug_code(if (*length) { sme_trace_hex((TR_IPC, TR_LVL_DEBUG, "ipc_message_recv():", *message, *length)); }) return TRUE;
/** * @brief Initialize the NULL method state machine. */ void LeapEapMethodInit(CsrWifiSecurityContext* context, eapMethod* method) { LeapContext* leapContext = (LeapContext*) CsrPmalloc(sizeof(LeapContext)); CsrMemCpy(method, &leap_method, sizeof(leap_method)); method->methodContext = leapContext; leapContext->context = context; leapContext->state = LEAP_INIT; }
void paldata_pal_ctrl_deactivate_req(FsmContext* context, void* appHandle) { PalCtrlDeactivateReq_Evt* evt = (PalCtrlDeactivateReq_Evt*)CsrPmalloc(sizeof(PalCtrlDeactivateReq_Evt)); INIT_EVENT_HEADER(evt, PAL_CTRL_DEACTIVATE_REQ_ID); evt->appHandle = appHandle; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg) { CsrUint32 addts_tid; CsrUint8 addts_ie_length; CsrUint8 *addts_ie; CsrUint8 *addts_params; unifi_DataBlock tspec; unifi_DataBlock tclas; int rc; addts_params = (CsrUint8*)(((unifi_cfg_command_t*)arg) + 1); if (get_user(addts_tid, (CsrUint32*)addts_params)) { unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n"); return -EFAULT; } addts_params += sizeof(CsrUint32); if (get_user(addts_ie_length, (CsrUint8*)addts_params)) { unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n"); return -EFAULT; } unifi_trace(priv, UDBG4, "addts: tid = 0x%x ie_length = %d\n", addts_tid, addts_ie_length); addts_ie = CsrPmalloc(addts_ie_length); if (addts_ie == NULL) { unifi_error(priv, "unifi_cfg_wmm_addts: Failed to malloc %d bytes for addts_ie buffer\n", addts_ie_length); return -ENOMEM; } addts_params += sizeof(CsrUint8); rc = copy_from_user(addts_ie, addts_params, addts_ie_length); if (rc) { unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the addts buffer\n"); CsrPfree(addts_ie); return -EFAULT; } tspec.data = addts_ie; tspec.length = addts_ie_length; tclas.data = NULL; tclas.length = 0; rc = sme_mgt_tspec(priv, unifi_ListActionAdd, addts_tid, &tspec, &tclas); CsrPfree(addts_ie); return rc; }
void paldata_sys_eapol_cfm(FsmContext* context, void* appHandle, unifi_EapolRc result) { PaldataSysEapolCfm_Evt* evt = (PaldataSysEapolCfm_Evt*)CsrPmalloc(sizeof(PaldataSysEapolCfm_Evt)); INIT_EVENT_HEADER(evt, PALDATA_SYS_EAPOL_CFM_ID); evt->appHandle = appHandle; evt->result = result; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
void paldata_pal_ctrl_link_alive_req(FsmContext* context, void* appHandle, CsrUint8 physicalLinkHandle) { PalCtrlLinkAliveReq_Evt* evt = (PalCtrlLinkAliveReq_Evt*)CsrPmalloc(sizeof(PalCtrlLinkAliveReq_Evt)); INIT_EVENT_HEADER(evt, PAL_CTRL_LINK_ALIVE_REQ_ID); evt->appHandle = appHandle; evt->physicalLinkHandle = physicalLinkHandle; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
void paldata_pal_ctrl_event_mask_set_req(FsmContext* context, void* appHandle, CsrUint32 indMask) { PalCtrlEventMaskSetReq_Evt* evt = (PalCtrlEventMaskSetReq_Evt*)CsrPmalloc(sizeof(PalCtrlEventMaskSetReq_Evt)); INIT_EVENT_HEADER(evt, PAL_CTRL_EVENT_MASK_SET_REQ_ID); evt->appHandle = appHandle; evt->indMask = indMask; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
void pal_encode_amp_assoc(FsmContext *context, PalChannellist *connectedChannelList, PalChannellist *preferredChannelList, unifi_MACAddress *macAddress, PAL_CoexCapabilities *capabilities, CsrUint8 **data, CsrUint16 *len) { CsrUint8 *buffer; CsrUint8 i; USED_CHANNELS_LIST channelList; *data = CsrPmalloc(PAL_AMP_ASSOC_MAX_TOTAL_LENGTH); /* alloc memory big enough to hold the biggest assoc*/ buffer = *data; sme_trace_entry((TR_PAL_LM_LINK_FSM,"encode_amp_assoc")); encode_amp_assoc_mac_address(&buffer,macAddress->data); CsrMemSet(&channelList, 0, sizeof(USED_CHANNELS_LIST)); /* consider the preferred only if PAL has started the network (which means numChannels==1). * Otherwise regulatory domain can get the appropriate valid channel list */ if (1 == preferredChannelList->numChannels) { channelList.listChangedFlag = TRUE; channelList.Dott11_b_g_ChanList[0].chan_scan_mode = channelScanMode_active; channelList.Dott11_b_g_ChanList[0].chan_number = preferredChannelList->number[0]; } encode_amp_assoc_channel_list(context, &buffer, &channelList, AMP_ASSOC_PREFERRED_CHANNEL_LIST_TYPE); verify(TR_PAL_LM_LINK_FSM, (CsrUint16)(buffer-(*data))<=PAL_AMP_ASSOC_MAX_TOTAL_LENGTH); if (connectedChannelList && connectedChannelList->numChannels) { CsrMemSet(&channelList, 0, sizeof(USED_CHANNELS_LIST)); channelList.listChangedFlag = TRUE; for (i=0; i<connectedChannelList->numChannels && i<HIGHEST_80211_b_g_CHANNEL_NUM; i++) { channelList.Dott11_b_g_ChanList[i].chan_scan_mode = channelScanMode_active; channelList.Dott11_b_g_ChanList[i].chan_number = connectedChannelList->number[i]; } encode_amp_assoc_channel_list(context, &buffer,&channelList, AMP_ASSOC_CONNECTED_CHANNEL_TYPE); verify(TR_PAL_LM_LINK_FSM, (CsrUint16)(buffer-(*data))<=PAL_AMP_ASSOC_MAX_TOTAL_LENGTH); } encode_amp_assoc_capabilities(&buffer,capabilities); encode_amp_assoc_pal_version(&buffer); *len = (CsrUint16)(buffer-(*data)); verify(TR_PAL_LM_LINK_FSM,*len <= PAL_AMP_ASSOC_MAX_TOTAL_LENGTH); sme_trace_info((TR_PAL_LM_LINK_FSM,"encode_amp_assoc:encoded %d bytes",*len)); }
static PayloadEntry* payld_allocate_entry(PldContext* context, CsrUint16 length) { PayloadEntry* entry; require(TR_PAYLOAD_MGR, length != 0); sme_trace_entry((TR_PAYLOAD_MGR, "payld_allocate_entry() bytes %d payloadMax %d payloadCount %d", length, context->payloadMax, context->payloadCount)); /* Check for Payload limit */ if (context->payloadCount + 1 > context->payloadMax) { #ifdef SME_TRACE_ENABLE pld_dump_owners(context); #endif require(TR_PAYLOAD_MGR, context->payloadCount + 1 <= context->payloadMax); return NULL; } /* Create a list entry sized to the PayloadEntry + the buffer */ entry = (PayloadEntry*)CsrPmalloc(sizeof(PayloadEntry) + length - 4 /* Size of the data array in PayloadEntry */); /*lint !e433 */ entry->handle = getNextHandle(context); entry->size = length; verify(TR_PAYLOAD_MGR, payld_get_entry(context, PLDGET_HANDLE(entry->handle)) == NULL); /*lint !e666 */ /* Insert at Head as the last 1 created is the most likely 1 to be accessed */ csr_list_insert_head(&context->payloads, list_owns_value, &entry->node, entry); context->payloadCount++; #ifdef SME_TRACE_ENABLE entry->records.recordsAdded = 0; entry->records.recordsCount = 0; /* Update payload manager statistics, output a diagnostic and return. */ context->stats.totalAllocs++; context->stats.activeMemory += length; context->stats.currentPayloads++; if (context->stats.currentPayloads > context->stats.highPayloads) { context->stats.highPayloads = context->stats.currentPayloads; } if (context->stats.activeMemory > context->stats.highActiveMemory) { context->stats.highActiveMemory = context->stats.activeMemory; } #endif return entry; }
void paldata_sys_capabilities_cfm(FsmContext* context, void* appHandle, CsrUint16 commandQueueSize, CsrUint16 trafficQueueSize) { PaldataSysCapabilitiesCfm_Evt* evt = (PaldataSysCapabilitiesCfm_Evt*)CsrPmalloc(sizeof(PaldataSysCapabilitiesCfm_Evt)); INIT_EVENT_HEADER(evt, PALDATA_SYS_CAPABILITIES_CFM_ID); evt->appHandle = appHandle; evt->commandQueueSize = commandQueueSize; evt->trafficQueueSize = trafficQueueSize; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
void paldata_pal_ctrl_register_req(FsmContext* context, void* appHandle, CsrUint8 ampId, CsrUint16 dataQid) { PalCtrlRegisterReq_Evt* evt = (PalCtrlRegisterReq_Evt*)CsrPmalloc(sizeof(PalCtrlRegisterReq_Evt)); INIT_EVENT_HEADER(evt, PAL_CTRL_REGISTER_REQ_ID); evt->appHandle = appHandle; evt->ampId = ampId; evt->dataQid = dataQid; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
void uf_multicast_list_wq(struct work_struct *work) { unifi_priv_t *priv = container_of(work, unifi_priv_t, multicast_list_task); int i; unifi_MACAddress* multicast_address_list = NULL; int mc_count; u8 *mc_list; unifi_trace(priv, UDBG5, "uf_multicast_list_wq: list count = %d\n", priv->mc_list_count); /* Flush the current list */ unifi_sys_multicast_address_ind(priv->smepriv, unifi_ListActionFlush, 0, NULL); mc_count = priv->mc_list_count; mc_list = priv->mc_list; /* * Allocate a new list, need to free it later * in unifi_mgt_multicast_address_cfm(). */ multicast_address_list = CsrPmalloc(mc_count * sizeof(unifi_MACAddress)); if (multicast_address_list == NULL) { return; } for (i = 0; i < mc_count; i++) { memcpy(multicast_address_list[i].data, mc_list, ETH_ALEN); mc_list += ETH_ALEN; } if (priv->smepriv == NULL) { CsrPfree(multicast_address_list); return; } unifi_sys_multicast_address_ind(priv->smepriv, unifi_ListActionAdd, mc_count, multicast_address_list); /* The SME will take a copy of the addreses*/ CsrPfree(multicast_address_list); }
static void event_to_unifi_sys_tclas_del_req(FsmContext* context, CsrUint8* inputbuffer, CsrUint16 length) { CsrUint8* buffer = &inputbuffer[6]; UnifiSysTclasDelReq_Evt evt; evt.tclasLength = event_unpack_CsrUint16(&buffer); evt.tclas = NULL; if (evt.tclasLength) { evt.tclas = (CsrUint8*)CsrPmalloc(evt.tclasLength); event_unpack_buffer(&buffer, evt.tclas, evt.tclasLength); } unifi_sys_tclas_del_req(context, evt.tclasLength, evt.tclas); CsrPfree(evt.tclas); }
void paldata_pal_ctrl_link_modify_req(FsmContext* context, void* appHandle, CsrUint16 logicalLinkHandle, const unifi_AmpFlowSpec *txFlowSpec) { PalCtrlLinkModifyReq_Evt* evt = (PalCtrlLinkModifyReq_Evt*)CsrPmalloc(sizeof(PalCtrlLinkModifyReq_Evt)); INIT_EVENT_HEADER(evt, PAL_CTRL_LINK_MODIFY_REQ_ID); evt->appHandle = appHandle; evt->logicalLinkHandle = logicalLinkHandle; evt->txFlowSpec.serviceType = txFlowSpec->serviceType; evt->txFlowSpec.maximumSduSize = txFlowSpec->maximumSduSize; evt->txFlowSpec.sduInterArrivalTime = txFlowSpec->sduInterArrivalTime; evt->txFlowSpec.accessLatency = txFlowSpec->accessLatency; evt->txFlowSpec.flushTimeout = txFlowSpec->flushTimeout; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
static void event_to_unifi_sys_eapol_req(FsmContext* context, CsrUint8* inputbuffer, CsrUint16 length) { CsrUint8* buffer = &inputbuffer[6]; UnifiSysEapolReq_Evt evt; evt.appHandle = (void*) event_unpack_CsrUint32(&buffer); evt.subscriptionHandle = event_unpack_CsrUint8(&buffer); evt.frameLength = event_unpack_CsrUint16(&buffer); evt.frame = NULL; if (evt.frameLength) { evt.frame = (CsrUint8*)CsrPmalloc(evt.frameLength); event_unpack_buffer(&buffer, evt.frame, evt.frameLength); } evt.freeFunction = NULL; buffer+=4; unifi_sys_eapol_req(context, evt.appHandle, evt.subscriptionHandle, evt.frameLength, evt.frame, evt.freeFunction); CsrPfree(evt.frame); }
void unifi_mgt_scan_results_get_cfm(void *drvpriv, void* appHandle, unifi_Status status, CsrUint16 scanResultsCount, const unifi_ScanResult *scanResults) { unifi_priv_t *priv = (unifi_priv_t*)drvpriv; int bytesRequired = scanResultsCount * sizeof(unifi_ScanResult); int i; CsrUint8* current_buff; unifi_ScanResult* scanCopy; if (priv == NULL) { unifi_error(NULL, "unifi_mgt_scan_results_get_cfm: Invalid ospriv.\n"); return; } /* Calc the size of the buffer reuired */ for (i = 0; i < scanResultsCount; ++i) { const unifi_ScanResult *scan_result = &scanResults[i]; bytesRequired += scan_result->informationElementsLength; } /* Take a Copy of the scan Results :-) */ scanCopy = CsrPmalloc(bytesRequired); memcpy(scanCopy, scanResults, sizeof(unifi_ScanResult) * scanResultsCount); /* Take a Copy of the Info Elements AND update the scan result pointers */ current_buff = (CsrUint8*)&scanCopy[scanResultsCount]; for (i = 0; i < scanResultsCount; ++i) { unifi_ScanResult *scan_result = &scanCopy[i]; CsrMemCpy(current_buff, scan_result->informationElements, scan_result->informationElementsLength); scan_result->informationElements = current_buff; current_buff += scan_result->informationElementsLength; } priv->sme_reply.reply_scan_results_count = scanResultsCount; priv->sme_reply.reply_scan_results = scanCopy; sme_complete_request(priv, status); }
static void event_to_unifi_sys_multicast_address_ind(FsmContext* context, CsrUint8* inputbuffer, CsrUint16 length) { CsrUint8* buffer = &inputbuffer[6]; UnifiSysMulticastAddressInd_Evt evt; evt.action = (unifi_ListAction) event_unpack_CsrUint8(&buffer); evt.setAddressesCount = event_unpack_CsrUint8(&buffer); evt.setAddresses = NULL; if (evt.setAddressesCount) { CsrUint16 i1; evt.setAddresses = (unifi_MACAddress*)CsrPmalloc(sizeof(unifi_MACAddress) * evt.setAddressesCount); for(i1 = 0; i1 < evt.setAddressesCount; i1++) { event_unpack_buffer(&buffer, evt.setAddresses[i1].data, 6); } } unifi_sys_multicast_address_ind(context, evt.action, evt.setAddressesCount, evt.setAddresses); CsrPfree(evt.setAddresses); }
/* -------------------------------------------------------------------------- * * Initialises the payload manager subsystem. */ PldContext* pld_init(CsrUint16 tableSize, CsrUint16 maxPayloads) { PldContext* context = (PldContext*)CsrPmalloc(sizeof(PldContext)); sme_trace_entry((TR_PAYLOAD_MGR, "pld_init() maxPayloads %d", maxPayloads)); /* Initialise the context */ #ifdef FSM_MUTEX_ENABLE (void)CsrMutexCreate(&context->payloadLock); #endif csr_list_init(&context->payloads); context->payloadMax = maxPayloads; context->payloadCount = 0; context->lastHandle = 0; /* handle 0 should never be used */ context->nextUsedHandle = PLDREFERENCEMASK; #ifdef SME_TRACE_ENABLE CsrMemSet(&context->stats, 0, sizeof(context->stats)); context->stats.maxPayloads = maxPayloads; #endif return context; }
static CsrBool ipc_chardevice_message_send_3(ipcConnection* con, const CsrUint8 *message, CsrUint32 length, const CsrUint8 *data1, CsrUint32 data1length, const CsrUint8 *data2, CsrUint32 data2length) { CsrUint32 bufSize = length + data1length + data2length; CsrUint8* buf; sme_trace_entry((TR_IPC, "ipc_chardevice_message_send_3()")); if (!con || !con->impl) { sme_trace_error((TR_IPC, "ipc_chardevice_message_send_3(): Invalid connection")); return FALSE; } if ((message == NULL) || (length == 0)) { sme_trace_debug((TR_IPC, "ipc_chardevice_message_send_3(): will not send empty message at %p, length %d", message, length)); return FALSE; } buf = (CsrUint8*)CsrPmalloc(bufSize); CsrMemCpy(buf, message, length); CsrMemCpy(&buf[length], data1, data1length); CsrMemCpy(&buf[length + data1length], data2, data2length); sme_trace_hex((TR_IPC, TR_LVL_DEBUG, "ipc_chardevice_message_send_3():", buf, bufSize)); if (write(con->impl->fd, buf, bufSize) <= 0) { sme_trace_error((TR_IPC, "ipc_chardevice_message_send_3(): write Failed %d, %s\n", errno, strerror(errno))); CsrPfree(buf); return FALSE; } CsrPfree(buf); return TRUE; }
static void event_to_unifi_sys_ma_unitdata_ind(FsmContext* context, CsrUint8* inputbuffer, CsrUint16 length) { CsrUint8* buffer = &inputbuffer[6]; UnifiSysMaUnitdataInd_Evt evt; evt.appHandle = (void*) event_unpack_CsrUint32(&buffer); evt.subscriptionHandle = event_unpack_CsrUint8(&buffer); evt.frameLength = event_unpack_CsrUint16(&buffer); evt.frame = NULL; if (evt.frameLength) { evt.frame = (CsrUint8*)CsrPmalloc(evt.frameLength); event_unpack_buffer(&buffer, evt.frame, evt.frameLength); } evt.freeFunction = NULL; buffer+=4; evt.receptionStatus = (unifi_ReceptionStatus) event_unpack_CsrUint16(&buffer); evt.priority = (unifi_Priority) event_unpack_CsrUint16(&buffer); evt.serviceClass = (unifi_ServiceClass) event_unpack_CsrUint16(&buffer); unifi_sys_ma_unitdata_ind(context, evt.appHandle, evt.subscriptionHandle, evt.frameLength, evt.frame, evt.freeFunction, evt.receptionStatus, evt.priority, evt.serviceClass); CsrPfree(evt.frame); }
static CsrBool loadfile(const char* filename, unifi_DataBlock* datablock) { struct stat filestats; FILE *fp; size_t readSize; sme_trace_entry((TR_FSM, "loadfile(%s)", filename)); if (stat(filename, &filestats) < 0) { sme_trace_error((TR_FSM, "loadfile() : file -> %s Failed to stat : %s", filename, strerror(errno))); return FALSE; } datablock->length = (CsrUint16)filestats.st_size; datablock->data = (CsrUint8*)CsrPmalloc(datablock->length); fp = fopen(filename, "r"); if (!fp) { sme_trace_error((TR_FSM, "loadfile() : file -> %s fopen failed : %s", filename, strerror(errno))); return FALSE; } readSize = fread(datablock->data, 1, (unsigned int)datablock->length, fp); if (readSize != datablock->length) { sme_trace_error((TR_FSM, "loadfile() : file -> %s fread failed returned %d : %s", filename, readSize, strerror(errno))); fclose(fp); return FALSE; } fclose(fp); return TRUE; }
void paldata_pal_ctrl_link_supervision_timeout_set_req(FsmContext* context, void* appHandle, CsrUint8 physicalLinkHandle, CsrUint16 linkSupervisionTimeout) { PalCtrlLinkSupervisionTimeoutSetReq_Evt* evt = (PalCtrlLinkSupervisionTimeoutSetReq_Evt*)CsrPmalloc(sizeof(PalCtrlLinkSupervisionTimeoutSetReq_Evt)); INIT_EVENT_HEADER(evt, PAL_CTRL_LINK_SUPERVISION_TIMEOUT_SET_REQ_ID); evt->appHandle = appHandle; evt->physicalLinkHandle = physicalLinkHandle; evt->linkSupervisionTimeout = linkSupervisionTimeout; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
void paldata_pal_ctrl_failed_contact_counter_reset_req(FsmContext* context, void* appHandle, CsrUint16 logicalLinkHandle) { PalCtrlFailedContactCounterResetReq_Evt* evt = (PalCtrlFailedContactCounterResetReq_Evt*)CsrPmalloc(sizeof(PalCtrlFailedContactCounterResetReq_Evt)); INIT_EVENT_HEADER(evt, PAL_CTRL_FAILED_CONTACT_COUNTER_RESET_REQ_ID); evt->appHandle = appHandle; evt->logicalLinkHandle = logicalLinkHandle; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg) { unsigned int fw_length; unsigned char *fw_buf = NULL; unsigned char *fw_user_ptr; struct dlpriv temp_fw_sta; CsrInt32 csr_r; /* Get the f/w buffer length */ if (get_user(fw_length, (unsigned int*)(((unifi_putest_command_t*)arg) + 1))) { unifi_error(priv, "unifi_putest_dl_fw_buff: Failed to get the length arg\n"); return -EFAULT; } unifi_trace(priv, UDBG2, "unifi_putest_dl_fw_buff: size = %d\n", fw_length); /* Sanity check for the buffer length */ if (fw_length == 0 || fw_length > 0xfffffff) { unifi_error(priv, "unifi_putest_dl_fw_buff: buffer length bad %u\n", fw_length); return -EINVAL; } /* Buffer for kernel copy of the f/w image */ fw_buf = CsrPmalloc(fw_length); if (!fw_buf) { unifi_error(priv, "unifi_putest_dl_fw_buff: malloc fail\n"); return -ENOMEM; } /* Get the f/w image */ fw_user_ptr = ((unsigned char*)arg) + sizeof(unifi_putest_command_t) + sizeof(unsigned int); if (copy_from_user(fw_buf, (void*)fw_user_ptr, fw_length)) { unifi_error(priv, "unifi_putest_dl_fw_buff: Failed to get the buffer\n"); CsrPfree(fw_buf); return -EFAULT; } /* Save the existing f/w to a temp, we need to restore it later */ temp_fw_sta = priv->fw_sta; /* Setting fw_desc NULL indicates to the core that no f/w file was loaded * via the kernel request_firmware() mechanism. This indicates to the core * that it shouldn't call release_firmware() after the download is done. */ priv->fw_sta.fw_desc = NULL; /* No OS f/w resource */ priv->fw_sta.dl_data = fw_buf; priv->fw_sta.dl_len = fw_length; /* Application may have stopped the XAPs, but they are needed for reset */ csr_r = unifi_start_processors(priv->card); if (csr_r) { unifi_error(priv, "Failed to start XAPs. Hard reset required.\n"); } /* Download the f/w. On UF6xxx this will cause the f/w file to convert * into patch format and download via the ROM boot loader */ csr_r = unifi_download(priv->card, 0x0c00); if (csr_r < 0) { unifi_error(priv, "unifi_putest_dl_fw_buff: failed to download the f/w\n"); goto free_fw; } free_fw: /* Finished with the putest f/w, so restore the station f/w */ priv->fw_sta = temp_fw_sta; CsrPfree(fw_buf); return convert_csr_error(csr_r); }
void paldata_sys_ma_unitdata_unsubscribe_cfm(FsmContext* context, void* appHandle, unifi_SubscriptionResult status) { PaldataSysMaUnitdataUnsubscribeCfm_Evt* evt = (PaldataSysMaUnitdataUnsubscribeCfm_Evt*)CsrPmalloc(sizeof(PaldataSysMaUnitdataUnsubscribeCfm_Evt)); INIT_EVENT_HEADER(evt, PALDATA_SYS_MA_UNITDATA_UNSUBSCRIBE_CFM_ID); evt->appHandle = appHandle; evt->status = status; fsm_send_event_external(context, (FsmEvent*)evt, getPalDataContext(context)->palDamFsmInstance, evt->common.id); }
static void sme_schedule_init(LinuxUserSpaceContext* context, int argc, char **argv) { CsrBool wifion = FALSE; CsrBool flightmode = FALSE; int i; #ifdef IPC_IP CsrUint32 ipc_portNumber = PORT_NUMBER_Q; #ifdef CSR_AMP_ENABLE CsrUint32 ipc_hciPortNumber = HCI_PORT_NUMBER_Q; CsrUint32 ipc_aclPortNumber = ACL_PORT_NUMBER_Q; #endif #endif #ifdef IPC_CHARDEVICE const char* connectStr = CHAR_DEVICE_Q; #endif sme_trace_entry((TR_FSM, "sme_schedule_init()")); CsrMemSet(&getMainData(linuxContext)->address, 0xFF, sizeof(unifi_MACAddress)); getMainData(linuxContext)->mibfiles.numElements = 0; getMainData(linuxContext)->mibfiles.dataList = (unifi_DataBlock*)CsrPmalloc(sizeof(unifi_DataBlock) * MAX_MIB_FILES); getMainData(linuxContext)->calibrationDataFile = NULL; getMainData(linuxContext)->calibrationData.length = 0; getMainData(linuxContext)->calibrationData.data = NULL; getMainData(linuxContext)->nextCaldataSaveTime = fsm_get_time_of_day_ms(context->fsmContext) + CALDATA_SAVE_INTERVAL_MS; getMainData(linuxContext)->exitOnError = FALSE; getMainData(linuxContext)->stopOnError = FALSE; #ifdef CSR_AMP_ENABLE context->palDataFsmContext = paldata_init(linuxContext); sme_install_wakeup_callback(context->palDataFsmContext, fsm_wakeup_callback); #endif /* Initialise basic constructs used by the SME */ context->fsmContext = sme_init(context, NULL); sme_install_wakeup_callback(context->fsmContext, fsm_wakeup_callback); #ifdef CSR_WIFI_NME_ENABLE context->nmeFsmContext = csr_wifi_nme_init(linuxContext, NULL); csr_wifi_nme_install_wakeup_callback(context->nmeFsmContext, fsm_wakeup_callback); #endif #ifdef FSM_DEBUG fsm_install_on_transition_callback(context->fsmContext, fsm_on_transition_trace_callback); fsm_install_unhandled_event_callback(context->fsmContext, fsm_on_unhandled_trace_callback); fsm_install_save_event_callback(context->fsmContext, fsm_on_saved_trace_callback); fsm_install_invalid_event_callback(context->fsmContext, fsm_on_invalid_trace_callback); fsm_install_ignore_event_callback(context->fsmContext, fsm_on_ignored_trace_callback); #ifdef CSR_WIFI_NME_ENABLE fsm_install_on_transition_callback(context->nmeFsmContext, nme_on_transition_trace_callback); fsm_install_unhandled_event_callback(context->nmeFsmContext, nme_on_unhandled_trace_callback); fsm_install_save_event_callback(context->nmeFsmContext, nme_on_saved_trace_callback); fsm_install_invalid_event_callback(context->nmeFsmContext, nme_on_invalid_trace_callback); fsm_install_ignore_event_callback(context->nmeFsmContext, nme_on_ignored_trace_callback); #endif #endif registerSignalHandlers(); /* If no args print the usage incase the user does not know what the help option is */ if (argc == 1) { print_usage(); } for (i = 1; i < argc; i++) { if (CsrStrNCmp(argv[i], "-ipc_port:", 10) == 0) { #ifdef IPC_IP ipc_portNumber = (CsrUint32)atoi(&argv[i][10]); sme_trace_info((TR_IPC, "sme_schedule_init() : IPC Port override -> %s :: %d", argv[i], ipc_portNumber)); #endif continue; } #ifdef CSR_AMP_ENABLE if (CsrStrNCmp(argv[i], "-ipc_hciport:", 13) == 0) { #ifdef IPC_IP ipc_hciPortNumber = (CsrUint32)atoi(&argv[i][13]); sme_trace_info((TR_IPC, "sme_schedule_init() : HCI IPC Port override -> %s :: %d", argv[i], ipc_hciPortNumber)); #endif continue; } if (CsrStrNCmp(argv[i], "-ipc_aclport:", 13) == 0) { #ifdef IPC_IP ipc_aclPortNumber = (CsrUint32)atoi(&argv[i][13]); sme_trace_info((TR_IPC, "sme_schedule_init() : ACL IPC Port override -> %s :: %d", argv[i], ipc_aclPortNumber)); #endif continue; } #endif /* TODO :: This is depricated... Remove! */ if (CsrStrNCmp(argv[i], "-ipc_connect=", 13) == 0) { #ifdef IPC_CHARDEVICE connectStr = &argv[i][13]; sme_trace_crit((TR_IPC, "sme_schedule_init() : -ipc_connect option is depricated. DO NOT USE!")); sme_trace_info((TR_IPC, "sme_schedule_init() : IPC Connect String -> %s :: %s", argv[i], connectStr)); #endif continue; } if (CsrStrNCmp(argv[i], "-dev=", 5) == 0) { #ifdef IPC_CHARDEVICE connectStr = &argv[i][5]; sme_trace_info((TR_IPC, "sme_schedule_init() : char device -> %s :: %s", argv[i], connectStr)); #endif continue; } if (CsrStrNCmp(argv[i], "-paldatadev=", 12) == 0) { continue; } #ifdef CSR_AMP_ENABLE if (CsrStrNCmp(argv[i], "-palselectchannel=", 18) == 0) { int len = CsrStrLen(argv[i]); char* str = (char*)CsrPmalloc(len); CsrMemCpy(str,&(argv[i][1]), len-1); str[len-1] = '\0'; sme_trace_info((TR_IPC, "sme_schedule_init() : pal channel to select -> %s :: %d , len-%d,str-%s", argv[i], (CsrUint8)atoi(&argv[i][18]),len,str)); unifi_dbg_cmd_req(context->fsmContext, str); continue; } if (CsrStrNCmp(argv[i], "-paldisableqos", 18) == 0) { int len = CsrStrLen(argv[i]); char* str = (char*)CsrPmalloc(len); CsrMemCpy(str,&(argv[i][1]), len-1); str[len-1] = '\0'; sme_trace_info((TR_IPC, "sme_schedule_init() : disable qos to select -%s , len-%d,str-%s", argv[i],len,str)); unifi_dbg_cmd_req(context->fsmContext, str); continue; } if (CsrStrNCmp(argv[i], "-paldisablesecurity", 18) == 0) { int len = CsrStrLen(argv[i]); char* str = (char*)CsrPmalloc(len); CsrMemCpy(str,&(argv[i][1]), len-1); str[len-1] = '\0'; sme_trace_info((TR_IPC, "sme_schedule_init() : disable qos to select -%s", argv[i])); unifi_dbg_cmd_req(context->fsmContext, str); continue; } #endif if (CsrStrNCmp(argv[i], "-flightmode", 11) == 0) { flightmode = TRUE; sme_trace_info((TR_IPC, "sme_schedule_init() : unifi_mgt_wifi_flightmode_req will be sent on connect -> %s", argv[i])); continue; } if (CsrStrNCmp(argv[i], "-wifion", 7) == 0) { wifion = TRUE; sme_trace_info((TR_IPC, "sme_schedule_init() : unifi_mgt_wifi_on_req will be sent on connect -> %s", argv[i])); continue; } if (CsrStrNCmp(argv[i], "-mac=", 5) == 0) { loadMacAddress(&argv[i][5], &getMainData(linuxContext)->address); sme_trace_info((TR_IPC, "sme_schedule_init() : macAddress file -> %s", argv[i])); sme_trace_info((TR_IPC, "sme_schedule_init() : macAddress -> %s", trace_unifi_MACAddress(getMainData(linuxContext)->address, getMainData(linuxContext)->traceMacAddressBuffer))); continue; } if (CsrStrNCmp(argv[i], "-mib=", 5) == 0) { loadMibfile(&argv[i][5], &getMainData(linuxContext)->mibfiles); sme_trace_info((TR_IPC, "sme_schedule_init() : mib file -> %s", argv[i])); continue; } if (CsrStrNCmp(argv[i], "-cal=", 5) == 0) { getMainData(linuxContext)->calibrationDataFile = &argv[i][5]; (void)loadfile(getMainData(linuxContext)->calibrationDataFile, &getMainData(linuxContext)->calibrationData); sme_trace_info((TR_IPC, "sme_schedule_init() : cal file -> %s", getMainData(linuxContext)->calibrationDataFile)); continue; } /* Skip -sme_trace:... as the sme trace module will handle these */ if (CsrStrNCmp(argv[i], "-sme_trace:", 11) == 0) { continue; } if (CsrStrNCmp(argv[i], "-v", CsrStrLen(argv[i])) == 0) { print_versions(); exit(EXIT_CODE_NORMAL_EXIT); } if (CsrStrNCmp(argv[i], "-exitOnError", CsrStrLen(argv[i])) == 0) { getMainData(linuxContext)->exitOnError = TRUE; continue; } if (CsrStrNCmp(argv[i], "-stopOnError", CsrStrLen(argv[i])) == 0) { getMainData(linuxContext)->stopOnError = TRUE; continue; } if (CsrStrNCmp(argv[i], "-h", CsrStrLen(argv[i])) == 0) { print_usage(); exit(EXIT_CODE_WIFION_ERROR); } print_usage(); sme_trace_error((TR_IPC, "error : Unknown commandline option : %s", argv[i])); exit(EXIT_CODE_WIFION_ERROR); } #ifdef IPC_CHARDEVICE if (connectStr) { getMainData(context)->charIpcCon = ipc_chardevice_connect(connectStr, NULL, NULL, NULL, NULL); if (getMainData(context)->charIpcCon == NULL) { sme_trace_crit((TR_IPC, "sme_schedule_init() : char device connect to %s failed", connectStr)); exit(EXIT_CODE_WIFION_ERROR); } } #endif #ifdef IPC_IP getMainData(context)->ipIpcCon = ipc_ip_create((int)ipc_portNumber, NULL, NULL, NULL, NULL); if (getMainData(context)->ipIpcCon == NULL) { sme_trace_crit((TR_IPC, "sme_schedule_init() : ipc_create(port:%d) failed", ipc_portNumber)); exit(EXIT_CODE_WIFION_ERROR); } #ifdef CSR_AMP_ENABLE getMainData(context)->ipHciIpcCon = ipc_ip_create((int)ipc_hciPortNumber, NULL, NULL, NULL, NULL); if (getMainData(context)->ipHciIpcCon == NULL) { sme_trace_crit((TR_IPC, "sme_schedule_init() : ipc_create(port:%d) failed", ipc_hciPortNumber)); exit(EXIT_CODE_WIFION_ERROR); } getMainData(context)->ipAclIpcCon = ipc_ip_create((int)ipc_aclPortNumber, NULL, NULL, NULL, NULL); if (getMainData(context)->ipAclIpcCon == NULL) { sme_trace_crit((TR_IPC, "sme_schedule_init() : ipc_create(port:%d) failed", ipc_aclPortNumber)); exit(EXIT_CODE_WIFION_ERROR); } #endif #endif if (getMainData(linuxContext)->calibrationData.length) { unifi_AppValue appValue; appValue.id = unifi_CalibrationDataValue; appValue.unifi_Value_union.calibrationData = getMainData(linuxContext)->calibrationData; unifi_mgt_claim_sync_access(linuxContext->fsmContext); (void)unifi_mgt_set_value(linuxContext->fsmContext, &appValue); unifi_mgt_release_sync_access(linuxContext->fsmContext); } if (flightmode) { unifi_mgt_wifi_flightmode_req(linuxContext->fsmContext, NULL, &getMainData(context)->address, getMainData(linuxContext)->mibfiles.numElements, getMainData(linuxContext)->mibfiles.dataList); } if (wifion) { /* Set the nextCaldataSaveTime to 1 minute from now */ getMainData(linuxContext)->nextCaldataSaveTime = fsm_get_time_of_day_ms(context->fsmContext) + CALDATA_INITIAL_SAVE_INTERVAL_MS; unifi_mgt_wifi_on_req(linuxContext->fsmContext, NULL, &getMainData(context)->address, getMainData(linuxContext)->mibfiles.numElements, getMainData(linuxContext)->mibfiles.dataList); } }