Agora  1.2.0
Agora project
txrx_worker_client_hw.h
Go to the documentation of this file.
1 
7 #ifndef TXRX_WORKER_CLIENT_HW_H_
8 #define TXRX_WORKER_CLIENT_HW_H_
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "client_radio.h"
14 #include "message.h"
15 #include "rx_status_tracker.h"
16 #include "txrx_worker.h"
17 
19  public:
20  TxRxWorkerClientHw(size_t core_offset, size_t tid, size_t interface_count,
21  size_t interface_offset, Config* const config,
22  size_t* rx_frame_start,
25  moodycamel::ProducerToken& tx_producer,
26  moodycamel::ProducerToken& notify_producer,
27  std::vector<RxPacket>& rx_memory,
28  std::byte* const tx_memory, std::mutex& sync_mutex,
29  std::condition_variable& sync_cond,
30  std::atomic<bool>& can_proceed,
31  ClientRadioConfig& radio_config);
32  TxRxWorkerClientHw() = delete;
33  ~TxRxWorkerClientHw() final;
34  void DoTxRx() final;
35 
36  private:
37  size_t DoTx(const long long time0);
38  std::vector<Packet*> DoRx(size_t interface_id, size_t& global_frame_id,
39  size_t& global_symbol_id, long long& receive_time,
40  ssize_t& sample_offset);
41 
42  ssize_t SyncBeacon(size_t local_interface, size_t sample_window);
43  ssize_t FindSyncBeacon(const std::complex<int16_t>* check_data,
44  size_t sample_window, float corr_scale = 1.f);
45  void AdjustRx(size_t local_interface, size_t discard_samples);
46  bool IsRxSymbol(size_t symbol_id);
47  void TxUplinkSymbols(size_t radio_id, size_t frame_id, long long time0);
48  void TxPilot(size_t pilot_ant, size_t frame_id, long long time0);
49  bool IsTxSymbolNext(size_t radio_id, size_t current_symbol);
50  Radio::TxFlags GetTxFlags(size_t radio_id, size_t tx_symbol_id);
51  void WaitDetectBeacon(size_t local_interface);
52  long long EstablishTime0(size_t local_interface);
53  bool DoResync(const std::vector<Packet*>& check_pkts,
54  ssize_t& adjust_samples);
55  bool ResyncOnBeacon(size_t frame_id, size_t frame_sync_period,
56  const std::vector<Packet*>& beacon_pkts,
57  ssize_t& adjust_samples);
58 
59  //DoRx helper routines
60  void InitRxStatus();
61  void ResetRxStatus(size_t interface, bool reuse_memory);
62 
63  // This object is created / owned by the parent process
66 
67  std::vector<std::vector<std::complex<int16_t>>> frame_zeros_;
68  std::vector<std::vector<std::complex<int16_t>>> frame_storage_;
69  std::vector<RxPacket> rx_frame_pkts_;
70  std::vector<RxPacket*> rx_pkts_ptrs_;
71 
72  //Resync logic
73  bool attempt_resync_ = false;
74  size_t resync_success_cnt_ = 0;
75  size_t resync_retry_cnt_ = 0;
76 
77  //For each interface.
78  std::vector<TxRxWorkerRx::RxStatusTracker> rx_status_;
79 };
80 #endif // TXRX_WORKER_CLIENT_HW_H_
TxRxWorkerClientHw::frame_storage_
std::vector< std::vector< std::complex< int16_t > > > frame_storage_
Definition: txrx_worker_client_hw.h:68
kPrintClientBeaconSNR
static constexpr bool kPrintClientBeaconSNR
Definition: txrx_worker_client_hw.cc:25
fmt::v8::detail::byte
byte
Definition: core.h:388
moodycamel::ProducerToken
Definition: concurrentqueue.h:630
Config::Running
void Running(bool value)
Definition: config.h:33
TxRxWorkerClientHw::attempt_resync_
bool attempt_resync_
Definition: txrx_worker_client_hw.h:73
PinToCoreWithOffset
void PinToCoreWithOffset(ThreadType thread_type, size_t core_offset, size_t thread_id, bool allow_reuse, bool verbose)
Definition: utils.cc:157
TxRxWorkerClientHw::FindSyncBeacon
ssize_t FindSyncBeacon(const std::complex< int16_t > *check_data, size_t sample_window, float corr_scale=1.f)
Definition: txrx_worker_client_hw.cc:472
Config::SampsPerSymbol
size_t SampsPerSymbol() const
Definition: config.h:234
datatype_conversion.h
ClientRadioConfig::RadioRx
int RadioRx(size_t radio_id, std::vector< std::vector< std::complex< int16_t >>> &rx_data, size_t rx_size, Radio::RxFlags &out_flags, long long &rx_time_ns)
Definition: client_radio.cc:101
FrameStats::GetPilotSymbol
size_t GetPilotSymbol(size_t location) const
Definition: framestats.cc:122
ConvertShortToFloat
static void ConvertShortToFloat(const short *in_buf, float *out_buf, size_t n_elems)
Produces outputs -1->+0.999.
Definition: datatype_conversion.h:41
Config::OfdmTxZeroPrefix
size_t OfdmTxZeroPrefix() const
Definition: config.h:211
TxRxWorkerClientHw::DoTxRx
void DoTxRx() final
Definition: txrx_worker_client_hw.cc:81
SymbolType::kPilot
@ kPilot
kDebugBeaconChannels
static constexpr bool kDebugBeaconChannels
Definition: txrx_worker_client_hw.cc:19
TxRxWorkerRx::RxStatusTracker::DiscardOld
void DiscardOld(size_t new_samples, long long sample_rx_start)
Definition: rx_status_tracker.h:53
ThreadType::kWorkerTXRX
@ kWorkerTXRX
EventType::kPacketPilotTX
@ kPacketPilotTX
Config::UeResyncPeriod
size_t UeResyncPeriod() const
Definition: config.h:55
TxRxWorkerClientHw::rx_status_
std::vector< TxRxWorkerRx::RxStatusTracker > rx_status_
Definition: txrx_worker_client_hw.h:78
TxRxWorkerClientHw::ResyncOnBeacon
bool ResyncOnBeacon(size_t frame_id, size_t frame_sync_period, const std::vector< Packet * > &beacon_pkts, ssize_t &adjust_samples)
Definition: txrx_worker_client_hw.cc:850
ClientRadioConfig
Definition: client_radio.h:15
EventType::kPacketTX
@ kPacketTX
TxRxWorkerClientHw::rx_pkts_ptrs_
std::vector< RxPacket * > rx_pkts_ptrs_
Definition: txrx_worker_client_hw.h:70
TxRxWorkerClientHw::GetTxFlags
Radio::TxFlags GetTxFlags(size_t radio_id, size_t tx_symbol_id)
Definition: txrx_worker_client_hw.cc:708
TxRxWorker::Running
bool Running() const
Definition: txrx_worker.h:42
AGORA_LOG_ERROR
#define AGORA_LOG_ERROR(...)
Definition: logger.h:39
TxRxWorkerClientHw::rx_frame_pkts_
std::vector< RxPacket > rx_frame_pkts_
Definition: txrx_worker_client_hw.h:69
Config::Frame
const FrameStats & Frame() const
Definition: config.h:340
kSyncDetectChannel
static constexpr size_t kSyncDetectChannel
Definition: txrx_worker_client_hw.cc:20
TxRxWorker::GetUlTxPacket
Packet * GetUlTxPacket(size_t frame, size_t symbol, size_t ant)
Definition: txrx_worker.cc:173
AGORA_LOG_TRACE
#define AGORA_LOG_TRACE(...)
Definition: logger.h:92
rx_tag_t
Definition: message.h:227
gen_tag_t::ue_id_
uint16_t ue_id_
Definition: message.h:37
TxRxWorker::WaitSync
void WaitSync()
Using a latch might be better but adds c++20 requirement.
Definition: txrx_worker.cc:64
TxRxWorkerClientHw::program_start_ticks_
size_t program_start_ticks_
Definition: txrx_worker_client_hw.h:65
kBeaconsToStart
static constexpr size_t kBeaconsToStart
Definition: txrx_worker_client_hw.cc:24
gen_tag_t::FrmSymUe
static gen_tag_t FrmSymUe(size_t frame_id, size_t symbol_id, size_t ue_id)
Definition: message.h:84
kReSyncRetryCount
static constexpr size_t kReSyncRetryCount
Definition: txrx_worker_client_hw.cc:22
gen_tag_t
Definition: message.h:22
fmt::v8::detail::abs
constexpr std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
Definition: chrono.h:1488
kBeaconDetectWindow
static constexpr float kBeaconDetectWindow
Definition: txrx_worker_client_hw.cc:23
kDebugPrintInTask
static constexpr bool kDebugPrintInTask
Definition: symbols.h:201
TxRxWorkerClientHw::WaitDetectBeacon
void WaitDetectBeacon(size_t local_interface)
Definition: txrx_worker_client_hw.cc:720
TxRxWorker::GetPendingTxEvents
std::vector< EventData > GetPendingTxEvents(size_t max_events=0)
Definition: txrx_worker.cc:85
Radio::TxFlags
TxFlags
Definition: radio.h:20
rx_tag_t::tag_
size_t tag_
Definition: message.h:229
EventData
Definition: message.h:142
TxRxWorkerClientHw::DoRx
std::vector< Packet * > DoRx(size_t interface_id, size_t &global_frame_id, size_t &global_symbol_id, long long &receive_time, ssize_t &sample_offset)
Definition: txrx_worker_client_hw.cc:172
message.h
Self defined functions for message storage and passing.
i
for i
Definition: generate_data.m:107
TxRxWorkerRx::RxStatusTracker
Definition: rx_status_tracker.h:17
TxRxWorkerClientHw
Definition: txrx_worker_client_hw.h:18
SymbolType::kBeacon
@ kBeacon
u
Plot Rx waveform for u
Definition: inspect_single_frame.m:108
GetTime::Rdtsc
static size_t Rdtsc()
Return the TSC.
Definition: gettime.h:25
comms-lib.h
Communications Library: a) Generate pilot/preamble sequences b) OFDM modulation.
Packet
Definition: message.h:164
TxRxWorkerClientHw::TxUplinkSymbols
void TxUplinkSymbols(size_t radio_id, size_t frame_id, long long time0)
Definition: txrx_worker_client_hw.cc:523
TxRxWorker::Configuration
Config * Configuration()
Definition: txrx_worker.h:46
EventType::kPacketRX
@ kPacketRX
TxRxWorkerRx::RxStatusTracker::GetRxPtrs
std::vector< void * > GetRxPtrs() const
Definition: rx_status_tracker.h:125
TxRxWorkerClientHw::~TxRxWorkerClientHw
~TxRxWorkerClientHw() final
TxRxWorkerClientHw::DoResync
bool DoResync(const std::vector< Packet * > &check_pkts, ssize_t &adjust_samples)
Definition: txrx_worker_client_hw.cc:803
txrx_worker_client_hw.h
Implementation of PacketTxRxRadio datapath functions for communicating with real iris / faros hardwar...
TxRxWorker::NotifyComplete
bool NotifyComplete(const EventData &complete_event)
Definition: txrx_worker.cc:75
Radio::RxFlags
RxFlags
Definition: radio.h:19
TxRxWorker
Definition: txrx_worker.h:18
CommsLib::FindBeaconAvx
static int FindBeaconAvx(const std::vector< std::complex< float >> &iq, const std::vector< std::complex< float >> &seq, float corr_scale=1.f)
Correlation and Peak detection of a beacon with Gold code (2 repetitions)
Definition: comms-lib-avx.cc:46
TxRxWorker::GetRxPacket
RxPacket & GetRxPacket()
Definition: txrx_worker.cc:104
TxRxWorkerClientHw::resync_retry_cnt_
size_t resync_retry_cnt_
Definition: txrx_worker_client_hw.h:75
TxRxWorker::channels_per_interface_
const size_t channels_per_interface_
Definition: txrx_worker.h:58
ClientRadioConfig::RadioTx
int RadioTx(size_t radio_id, void **buffs, size_t num_samps, Radio::TxFlags flags, long long &tx_time)
Definition: client_radio.cc:96
moodycamel::ConcurrentQueue< EventData >
kDebugTxData
static constexpr bool kDebugTxData
Definition: symbols.h:365
TxRxWorkerClientHw::AdjustRx
void AdjustRx(size_t local_interface, size_t discard_samples)
Definition: txrx_worker_client_hw.cc:374
TxRxWorkerRx::RxStatusTracker::Update
void Update(size_t new_samples, long long sample_rx_start)
Definition: rx_status_tracker.h:81
Config::UlIqT
Table< std::complex< int16_t > > & UlIqT()
Definition: config.h:390
FrameStats::GetPilotSymbolIdx
size_t GetPilotSymbolIdx(size_t symbol_number) const
Definition: framestats.cc:160
Config::GetSymbolType
SymbolType GetSymbolType(size_t symbol_id) const
Return the symbol type of this symbol in this frame.
Definition: config.cc:1557
TxRxWorkerClientHw::IsRxSymbol
bool IsRxSymbol(size_t symbol_id)
Definition: txrx_worker_client_hw.cc:509
kVerifyFirstSync
static constexpr bool kVerifyFirstSync
Definition: txrx_worker_client_hw.cc:21
FrameStats::NumULSyms
size_t NumULSyms() const
Definition: framestats.cc:85
TxRxWorker::tid_
const size_t tid_
Definition: txrx_worker.h:54
Config::NumUeChannels
size_t NumUeChannels() const
Definition: config.h:99
Config
Definition: config.h:26
kMaxBeaconAdjust
static constexpr ssize_t kMaxBeaconAdjust
Definition: txrx_worker_client_hw.cc:26
AGORA_LOG_INFO
#define AGORA_LOG_INFO(...)
Definition: logger.h:62
std
Definition: json.hpp:5213
AGORA_LOG_FRAME
#define AGORA_LOG_FRAME(...)
Definition: logger.h:72
TxRxWorkerClientHw::EstablishTime0
long long EstablishTime0(size_t local_interface)
Definition: txrx_worker_client_hw.cc:762
RtAssert
static void RtAssert(bool condition, const char *throw_str)
Definition: utils.h:104
tx_data
end Generate data if GENERATE_DATA tx_data
Definition: generate_data.m:38
rx_status_tracker.h
Implementation of RxStatusTracker helper class.
AGORA_LOG_WARN
#define AGORA_LOG_WARN(...)
Definition: logger.h:53
TxRxWorkerClientHw::radio_
ClientRadioConfig & radio_
Definition: txrx_worker_client_hw.h:64
Config::ClTxAdvance
const std::vector< int > & ClTxAdvance() const
Definition: config.h:333
Config::BeaconLen
size_t BeaconLen() const
Definition: config.h:103
TxRxWorkerClientHw::TxRxWorkerClientHw
TxRxWorkerClientHw()=delete
TxRxWorkerClientHw::SyncBeacon
ssize_t SyncBeacon(size_t local_interface, size_t sample_window)
Definition: txrx_worker_client_hw.cc:408
TxRxWorkerClientHw::ResetRxStatus
void ResetRxStatus(size_t interface, bool reuse_memory)
Definition: txrx_worker_client_hw.cc:670
TxRxWorkerClientHw::InitRxStatus
void InitRxStatus()
Definition: txrx_worker_client_hw.cc:652
Config::UeHwFramer
bool UeHwFramer() const
Definition: config.h:54
TxRxWorkerRx::RxStatusTracker::SamplesAvailable
size_t SamplesAvailable() const
Definition: rx_status_tracker.h:121
TxRxWorkerClientHw::IsTxSymbolNext
bool IsTxSymbolNext(size_t radio_id, size_t current_symbol)
Definition: txrx_worker_client_hw.cc:686
TxRxWorker::interface_offset_
const size_t interface_offset_
Definition: txrx_worker.h:57
gettime.h
TxRxWorkerClientHw::resync_success_cnt_
size_t resync_success_cnt_
Definition: txrx_worker_client_hw.h:74
TxRxWorker::num_interfaces_
const size_t num_interfaces_
Definition: txrx_worker.h:56
gen_tag_t::frame_id_
uint32_t frame_id_
Definition: message.h:32
TxRxWorkerRx::RxStatusTracker::CheckContinuity
bool CheckContinuity(long long sample_rx_start) const
Definition: rx_status_tracker.h:108
txrx_worker.h
txrx worker thread definition. This is the parent / interface
noise_power
noise_power
Definition: process_rx_frame.m:35
TxRxWorker::core_offset_
const size_t core_offset_
Definition: txrx_worker.h:55
SymbolType::kUL
@ kUL
client_radio.h
Declaration file for the client radio config class.
FrameStats::GetULSymbol
size_t GetULSymbol(size_t location) const
Definition: framestats.cc:114
TxRxWorkerClientHw::TxPilot
void TxPilot(size_t pilot_ant, size_t frame_id, long long time0)
Definition: txrx_worker_client_hw.cc:599
TxRxWorkerClientHw::frame_zeros_
std::vector< std::vector< std::complex< int16_t > > > frame_zeros_
Definition: txrx_worker_client_hw.h:67
TxRxWorker::running_
bool running_
Definition: txrx_worker.h:60
Config::PilotCi16
std::vector< std::complex< int16_t > > & PilotCi16()
Definition: config.h:377
TX_FRAME_DELTA
#define TX_FRAME_DELTA
Definition: symbols.h:20
FrameStats::NumTotalSyms
size_t NumTotalSyms() const
Definition: framestats.cc:93
SymbolType::kDL
@ kDL
TxRxWorkerClientHw::DoTx
size_t DoTx(const long long time0)
Definition: txrx_worker_client_hw.cc:303
TxRxWorkerRx::RxStatusTracker::Reset
void Reset(std::vector< RxPacket * > new_packets)
Definition: rx_status_tracker.h:32