void* K2ArmSpiderCommunicator::ctrl_start_send(int lrtIx, int size){ int dataOffset = 0; if(cur_mono_pkt_out[lrtIx] != 0) throw "SpiderCommunicator: Ctrl: Try to send a msg when previous one is not sent"; while(cur_mono_pkt_out[lrtIx] == 0){ cur_mono_pkt_out[lrtIx] = (Cppi_Desc*)Qmss_queuePop(QUEUE_FREE_CTRL); if(cur_mono_pkt_out[lrtIx] != 0){ /* Get Packet info */ cur_mono_pkt_out_size[lrtIx] = CTRL_DESC_SIZE;//QMSS_DESC_SIZE(cur_mono_pkt_out[lrtIx]); cur_mono_pkt_out[lrtIx] = (Cppi_Desc*)QMSS_DESC_PTR (cur_mono_pkt_out[lrtIx]); /* Clear Cache */ Osal_qmssBeginMemAccess(cur_mono_pkt_out[lrtIx], cur_mono_pkt_out_size[lrtIx]); /* Get info */ dataOffset = Cppi_getDataOffset(Cppi_DescType_MONOLITHIC, cur_mono_pkt_out[lrtIx]); break; } usleep(100); } if(size > cur_mono_pkt_out_size[lrtIx] - dataOffset) throw "LrtCommunicator: Try to send a message too big"; /* Add data to current descriptor */ void* data_pkt = (void*)(((int)cur_mono_pkt_out[lrtIx]) + dataOffset); return data_pkt; }
int K2ArmSpiderCommunicator::trace_start_recv(void** data){ int dataOffset; if(cur_mono_trace_in == 0){ cur_mono_trace_in = (Cppi_Desc*)Qmss_queuePop(QUEUE_TRACE); if(cur_mono_trace_in == 0){ return 0; } /* Get Packet info */ cur_mono_trace_in_size = TRACE_DESC_SIZE;//QMSS_DESC_SIZE(cur_mono_trace_in); cur_mono_trace_in = (Cppi_Desc*)QMSS_DESC_PTR (cur_mono_trace_in); /* Clear Cache */ Osal_qmssBeginMemAccess(cur_mono_trace_in, cur_mono_trace_in_size); /* Get info */ dataOffset = Cppi_getDataOffset(Cppi_DescType_MONOLITHIC, cur_mono_trace_in); }else throw "SpiderCommunicator: Ctrl: Try to receive a message when the previous one is not free'd"; void* data_pkt = (void*)(((int)cur_mono_trace_in) + dataOffset); int data_size = cur_mono_trace_in_size - dataOffset; *data = data_pkt; return data_size; }
void* K2ArmSpiderCommunicator::trace_start_send(int size){ int dataOffset = 0; if(cur_mono_trace_out != 0) throw "SpiderCommunicator: Try to send a trace msg when previous one is not sent"; while(cur_mono_trace_out == 0){ cur_mono_trace_out = (Cppi_Desc*)Qmss_queuePop(QUEUE_FREE_TRACE); if(cur_mono_trace_out != 0){ /* Get Packet info */ cur_mono_trace_out_size = TRACE_DESC_SIZE;//QMSS_DESC_SIZE(cur_mono_trace_out); cur_mono_trace_out = (Cppi_Desc*)QMSS_DESC_PTR (cur_mono_trace_out); /* Clear Cache */ Osal_qmssBeginMemAccess(cur_mono_trace_out, cur_mono_trace_out_size); /* Get info */ dataOffset = Cppi_getDataOffset(Cppi_DescType_MONOLITHIC, cur_mono_trace_out); break; } usleep(100); } if(size > cur_mono_trace_out_size - dataOffset) throw "SpiderCommunicator: Try to send a trace message too big"; /* Add data to current descriptor */ void* data_pkt = (void*)(((int)cur_mono_trace_out) + dataOffset); return data_pkt; }
int K2ArmSpiderCommunicator::ctrl_start_recv(int lrtIx, void** data){ int dataOffset; if(cur_mono_pkt_in[lrtIx] == 0){ cur_mono_pkt_in[lrtIx] = (Cppi_Desc*)Qmss_queuePop(CTRL_LRT_TO_SPIDER(lrtIx)); if(cur_mono_pkt_in[lrtIx] == 0){ return 0; } /* Get Packet info */ cur_mono_pkt_in_size[lrtIx] = CTRL_DESC_SIZE;//QMSS_DESC_SIZE(cur_mono_pkt_in[lrtIx]); cur_mono_pkt_in[lrtIx] = (Cppi_Desc*)QMSS_DESC_PTR (cur_mono_pkt_in[lrtIx]); /* Clear Cache */ Osal_qmssBeginMemAccess(cur_mono_pkt_in[lrtIx], cur_mono_pkt_in_size[lrtIx]); /* Get info */ dataOffset = Cppi_getDataOffset(Cppi_DescType_MONOLITHIC, cur_mono_pkt_in[lrtIx]); }else throw "SpiderCommunicator: Ctrl: Try to receive a message when the previous one is not free'd"; void* data_pkt = (void*)(((int)cur_mono_pkt_in[lrtIx]) + dataOffset); int data_size = cur_mono_pkt_in_size[lrtIx] - dataOffset; *data = data_pkt; return data_size; }
long K2DspLrtCommunicator::data_recv(Fifo* f){ if(f->ntoken){ Cppi_Desc *mono_pkt; int queueId = QUEUE_DATA_BASE+f->id; if(queueId < QUEUE_DATA_BASE || queueId > QUEUE_LAST ) throw "Error: request queue out of bound\n"; for(int i=0; i<f->ntoken; i++){ do{ mono_pkt = (Cppi_Desc*)Qmss_queuePop(queueId); }while(mono_pkt == 0); /* Get Packet info */ int mono_pkt_size = QMSS_DESC_SIZE(mono_pkt); mono_pkt = (Cppi_Desc*)QMSS_DESC_PTR (mono_pkt); // /* Clear Cache */ // Osal_qmssBeginMemAccess(mono_pkt, mono_pkt_size); // // /* Write back cache */ // Osal_qmssEndMemAccess(mono_pkt, mono_pkt_size); Qmss_queuePushDesc(QUEUE_FREE_DATA, mono_pkt); } } /* Invalidate cache */ Osal_qmssBeginMemAccess( Platform::get()->virt_to_phy((void*)(f->alloc)), f->size); return (long)Platform::get()->virt_to_phy((void*)(f->alloc)); }
int K2DspLrtCommunicator::ctrl_start_recv(void** data){ int dataOffset; if(cur_mono_pkt_in == 0){ cur_mono_pkt_in = (Cppi_Desc*)Qmss_queuePop(CTRL_SPIDER_TO_LRT); if(cur_mono_pkt_in == 0){ return 0; } /* Get Packet info */ cur_mono_pkt_in_size = QMSS_DESC_SIZE(cur_mono_pkt_in); cur_mono_pkt_in = (Cppi_Desc*)QMSS_DESC_PTR (cur_mono_pkt_in); /* Clear Cache */ Osal_qmssBeginMemAccess(cur_mono_pkt_in, cur_mono_pkt_in_size); /* Get info */ dataOffset = Cppi_getDataOffset(Cppi_DescType_MONOLITHIC, cur_mono_pkt_in); }else throw "LrtCommunicator: Try to receive a message when the previous one is not free'd"; void* data_pkt = (void*)(((int)cur_mono_pkt_in) + dataOffset); int data_size = cur_mono_pkt_in_size - dataOffset; *data = data_pkt; return data_size; }