void init_mac_2threads() { // Start Sora HW if (params_rx->inType == TY_SORA) { RadioStart(*params_rx); InitSoraRx(*params_rx); } if (params_tx->outType == TY_SORA) { RadioStart(*params_tx); InitSoraTx(*params_tx); } // Start NDIS if (params_tx->inType == TY_IP) { HRESULT hResult = SoraUEnableGetTxPacket(); assert(hResult == S_OK); Ndis_init(NULL); } if (params_rx->outType == TY_IP) { // To be implemented // HRESULT hResult = SoraUEnableGetRxPacket(); // assert(hResult == S_OK); } // Start measuring time initMeasurementInfo(&(params_tx->measurementInfo), params_tx->latencyCDFSize); // Init initBufCtxBlock(&buf_ctx_tx); initBufCtxBlock(&buf_ctx_rx); initHeapCtxBlock(&heap_ctx_tx); initHeapCtxBlock(&heap_ctx_rx); wpl_global_init_tx(params_tx->heapSize); wpl_global_init_rx(params_rx->heapSize); }
int __cdecl main(int argc, char **argv) { // Initialize the global parameters params = &Globals; try_parse_args(params, argc, argv); #ifdef SORA_PLATFORM // Start Sora HW if (Globals.inType == TY_SDR || Globals.outType == TY_SDR) { #ifdef BLADE_RF if (BladeRF_RadioStart(params) < 0) { exit(1); } #endif #ifdef SORA_RF // SORA RadioStart(&Globals); if (Globals.inType == TY_SDR) { InitSoraRx(params); } if (Globals.outType == TY_SDR) { InitSoraTx(params); } #endif } // Start NDIS if (Globals.inType == TY_IP || Globals.outType == TY_IP) { HRESULT hResult = SoraUEnableGetTxPacket(); assert(hResult == S_OK); Ndis_init(NULL); } // Start measuring time initMeasurementInfo(&(Globals.measurementInfo), Globals.latencyCDFSize); #endif // Init initBufCtxBlock(&buf_ctx); initHeapCtxBlock(&heap_ctx, Globals.heapSize); wpl_global_init(Globals.heapSize); wpl_input_initialize(); #ifdef SORA_PLATFORM ///////////////////////////////////////////////////////////////////////////// // DV: Pass the User_Routines here int no_threads = wpl_set_up_threads(User_Routines); printf("Setting up threads...\n"); ULONGLONG ttstart, ttend; printf("Starting %d threads...\n", no_threads); StartThreads(&ttstart, &ttend, &Globals.measurementInfo.tsinfo, no_threads, User_Routines); printf("Total input items (including EOF): %d (%d B), output items: %d (%d B)\n", buf_ctx.total_in, buf_ctx.total_in*buf_ctx.size_in, buf_ctx.total_out, buf_ctx.total_out*buf_ctx.size_out); printf("Time Elapsed: %ld us \n", SoraTimeElapsed((ttend / 1000 - ttstart / 1000), &Globals.measurementInfo.tsinfo)); if (Globals.latencySampling > 0) { printf("Min write latency: %ld, max write latency: %ld\n", (ulong)Globals.measurementInfo.minDiff, (ulong) Globals.measurementInfo.maxDiff); printf("CDF: \n "); unsigned int i = 0; while (i < Globals.measurementInfo.aDiffPtr) { printf("%ld ", Globals.measurementInfo.aDiff[i]); if (i % 10 == 9) { printf("\n "); } i++; } printf("\n"); } // Free thread separators // NB: these are typically allocated in blink_set_up_threads ts_free(); #else int usec; #ifdef __GNUC__ struct timespec start, end; clock_gettime(CLOCK_MONOTONIC, &start); wpl_go(); clock_gettime(CLOCK_MONOTONIC, &end); usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000; #else clock_t start = clock(), diff; wpl_go(); diff = clock() - start; usec = diff * 1000000 / CLOCKS_PER_SEC; #endif printf("Time Elapsed: %d\n", usec); #endif printf("Bytes copied: %ld\n", bytes_copied); wpl_output_finalize(); #ifdef SORA_PLATFORM // Stop Sora HW if (Globals.inType == TY_SDR || Globals.outType == TY_SDR) { #ifdef BLADE_RF BladeRF_RadioStop(params); #endif #ifdef SORA_RF RadioStop(&Globals); #endif } // Stop NDIS if (Globals.inType == TY_IP || Globals.outType == TY_IP) { if (hUplinkThread != NULL) { // Sora cleanup. SoraUThreadStop(hUplinkThread); SoraUThreadFree(hUplinkThread); } SoraUDisableGetTxPacket(); // Winsock cleanup. closesocket(ConnectSocket); WSACleanup(); } #endif return 0; }
void init_sora_hw() { // Start Sora HW // Initialize Sora user mode extension BOOLEAN succ = SoraUInitUserExtension("\\\\.\\HWTest"); if (!succ) { printf("Error: fail to find a Sora UMX capable device!\n"); exit(1); } // Override radio ids (as they are hardcoded in firmware) params_tx->radioParams.radioId = TARGET_RADIO_TX; params_rx->radioParams.radioId = TARGET_RADIO_RX; // IMPORTANT!!!! // NOTE: Make sure you start TX before RX // Otherwise, the current firmware will cause BSOD! // (this is a known bug that should be fixed one day...) if (params_tx->outType == TY_SDR) { RadioStart(params_tx); InitSoraTx(params_tx); } if (params_rx->inType == TY_SDR) { RadioStart(params_rx); InitSoraRx(params_rx); } // Firmware is one for all radios RadioSetFirmwareParameters(); // Start NDIS if not in testIP mode if (params_tx->inType == TY_IP && !test_IP) { HRESULT hResult = SoraUEnableGetTxPacket(); if (hResult != S_OK) { printf("*** NDIS binding failed!\n"); } // TODO: Hardcoded Sora MAC address - load from OS/command line memset(ethFrame, 0, 14 * sizeof(char)); ethFrame[0] = 0x02; ethFrame[1] = 0x50; ethFrame[2] = 0xF2; ethFrame[3] = 0x78; ethFrame[4] = 0xFD; ethFrame[5] = 0x6C; ethFrame[12] = 0x08; //assert(hResult == S_OK); //Ndis_init(NULL); } /* No init to be done here, just use SoraUIndicateRxPacket if (params_rx->outType == TY_IP) { // To be implemented HRESULT hResult = SoraUEnableGetRxPacket(); assert(hResult == S_OK); } */ // Init radio context blocks readSoraCtx *rctx = (readSoraCtx *)params_rx->TXBuffer; writeSoraCtx *ctx = (writeSoraCtx *)params_tx->TXBuffer; // Start Sora TX worker that is doing PCI transfer to Sora and the actual TX initTXCtx(ctx, rctx); // Start RX thread initRXCtx(rctx, ctx->TXBufferSize); }