Agora  1.2.0
Agora project
txrx_worker_hw.h
Go to the documentation of this file.
1 
7 #ifndef TXRX_WORKER_HW_H_
8 #define TXRX_WORKER_HW_H_
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "message.h"
14 #include "radio_lib.h"
15 #include "rx_status_tracker.h"
16 #include "txrx_worker.h"
17 
18 namespace TxRxWorkerRx {
19 struct RxParameters {
20  size_t symbol_ = 0;
21  size_t interface_ = 0;
22 };
23 
24 struct RxTimeTracker {
25  size_t start_ticks_;
26  size_t end_ticks_;
27 };
28 } // namespace TxRxWorkerRx
29 
30 class TxRxWorkerHw : public TxRxWorker {
31  public:
32  TxRxWorkerHw(size_t core_offset, size_t tid, size_t interface_count,
33  size_t interface_offset, Config* const config,
34  size_t* rx_frame_start,
37  moodycamel::ProducerToken& tx_producer,
38  moodycamel::ProducerToken& notify_producer,
39  std::vector<RxPacket>& rx_memory, std::byte* const tx_memory,
40  std::mutex& sync_mutex, std::condition_variable& sync_cond,
41  std::atomic<bool>& can_proceed, RadioConfig& radio_config);
42  TxRxWorkerHw() = delete;
43  ~TxRxWorkerHw() final;
44  void DoTxRx() final;
45 
46  private:
47  size_t DoTx(long long time0);
48  std::vector<RxPacket*> DoRx(size_t interface_id, size_t& global_frame_id,
49  size_t& global_symbol_id);
50 
51  void ScheduleTxInit(size_t frames_to_schedule, long long time0);
52  void TxDownlinkZeros(size_t frame_id, size_t radio_id, long long time0);
53 
54  void TxReciprocityCalibPilots(size_t frame_id, size_t radio_id,
55  long long time0);
56 
57  void TxBeaconHw(size_t frame_id, size_t interface_id, long long time0);
58  bool IsTxSymbolNext(size_t radio_id, size_t current_symbol);
59  Radio::TxFlags GetTxFlags(size_t radio_id, size_t tx_symbol_id);
60  long long int GetHwTime();
61 
62  bool IsRxSymbol(size_t interface, size_t symbol_id);
63 
64  //DoRx helper routines
65  void InitRxStatus();
66  void ResetRxStatus(size_t interface, bool reuse_memory);
67 
69  const TxRxWorkerRx::RxParameters& last_rx);
70 
71  void PrintRxSymbolTiming(std::vector<TxRxWorkerRx::RxTimeTracker>& rx_times,
72  size_t current_frame, size_t current_symbol,
73  size_t next_symbol);
74 
75  // This object is created / owned by the parent process
78  const double freq_ghz_;
79 
80  std::vector<std::complex<int16_t>> zeros_;
81 
82  //For each interface.
83  std::vector<TxRxWorkerRx::RxStatusTracker> rx_status_;
84  std::vector<bool> first_symbol_;
85 };
86 #endif // TXRX_WORKER_SIM_H_
TxRxWorkerHw::GetTxFlags
Radio::TxFlags GetTxFlags(size_t radio_id, size_t tx_symbol_id)
Definition: txrx_worker_hw.cc:600
TxRxWorkerHw::IsRxSymbol
bool IsRxSymbol(size_t interface, size_t symbol_id)
Definition: txrx_worker_hw.cc:641
RadioConfig::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: radio_lib.cc:326
fmt::v8::detail::byte
byte
Definition: core.h:388
FrameStats::GetDLSymbolIdx
size_t GetDLSymbolIdx(size_t symbol_number) const
Definition: framestats.cc:152
TxRxWorkerHw::DoTx
size_t DoTx(long long time0)
Definition: txrx_worker_hw.cc:451
FrameStats::NumDLCalSyms
size_t NumDLCalSyms() const
Definition: framestats.cc:79
moodycamel::ProducerToken
Definition: concurrentqueue.h:630
PinToCoreWithOffset
void PinToCoreWithOffset(ThreadType thread_type, size_t core_offset, size_t thread_id, bool allow_reuse, bool verbose)
Definition: utils.cc:157
SymbolType::kCalDL
@ kCalDL
Config::SampsPerSymbol
size_t SampsPerSymbol() const
Definition: config.h:234
fmt::v8::printf
auto printf(const S &fmt, const T &... args) -> int
Definition: printf.h:631
FrameStats::GetULCalSymbol
size_t GetULCalSymbol(size_t location) const
Definition: framestats.cc:118
Config::NumChannels
size_t NumChannels() const
Definition: config.h:98
TxRxWorker::rx_frame_start_
size_t *const rx_frame_start_
Definition: txrx_worker.h:59
SymbolType::kPilot
@ kPilot
gen_tag_t::symbol_id_
uint16_t symbol_id_
Definition: message.h:33
TxRxWorkerHw::DoRx
std::vector< RxPacket * > DoRx(size_t interface_id, size_t &global_frame_id, size_t &global_symbol_id)
Definition: txrx_worker_hw.cc:181
ThreadType::kWorkerTXRX
@ kWorkerTXRX
txrx_worker_hw.h
Implementation of PacketTxRx datapath functions for communicating with real iris / faros hardware.
TxRxWorkerHw::rx_status_
std::vector< TxRxWorkerRx::RxStatusTracker > rx_status_
Definition: txrx_worker_hw.h:83
TxRxWorkerHw::~TxRxWorkerHw
~TxRxWorkerHw() final
EventType::kPacketTX
@ kPacketTX
TxRxWorkerRx::RxTimeTracker::start_ticks_
size_t start_ticks_
Definition: txrx_worker_hw.h:25
TxRxWorker::GetTxPacket
Packet * GetTxPacket(size_t frame, size_t symbol, size_t ant)
Definition: txrx_worker.cc:160
TxRxWorkerHw::zeros_
std::vector< std::complex< int16_t > > zeros_
Definition: txrx_worker_hw.h:80
TxRxWorker::Running
bool Running() const
Definition: txrx_worker.h:42
TxRxWorkerHw::InitRxStatus
void InitRxStatus()
Definition: txrx_worker_hw.cc:904
AGORA_LOG_ERROR
#define AGORA_LOG_ERROR(...)
Definition: logger.h:39
Config::RefRadio
size_t RefRadio(size_t id) const
Definition: config.h:101
Config::Frame
const FrameStats & Frame() const
Definition: config.h:340
Catch::cerr
std::ostream & cerr()
GetTime::CyclesToUs
static double CyclesToUs(size_t cycles, double freq_ghz)
Definition: gettime.h:97
AGORA_LOG_TRACE
#define AGORA_LOG_TRACE(...)
Definition: logger.h:92
rx_tag_t
Definition: message.h:227
Config::BeaconCi16
std::vector< std::complex< int16_t > > & BeaconCi16()
Definition: config.h:380
TxRxWorker::WaitSync
void WaitSync()
Using a latch might be better but adds c++20 requirement.
Definition: txrx_worker.cc:64
TxRxWorkerHw::TxReciprocityCalibPilots
void TxReciprocityCalibPilots(size_t frame_id, size_t radio_id, long long time0)
Definition: txrx_worker_hw.cc:338
TxRxWorker::ReturnRxPacket
void ReturnRxPacket(RxPacket &unused_packet)
Definition: txrx_worker.cc:129
kSymbolTimingEnabled
static constexpr bool kSymbolTimingEnabled
Definition: txrx_worker_hw.cc:16
TxRxWorkerHw::TxRxWorkerHw
TxRxWorkerHw()=delete
radio_lib.h
Declaration file for the RadioConfig class.
gen_tag_t
Definition: message.h:22
TxRxWorkerHw::TxDownlinkZeros
void TxDownlinkZeros(size_t frame_id, size_t radio_id, long long time0)
Definition: txrx_worker_hw.cc:860
TxRxWorkerHw::radio_config_
RadioConfig & radio_config_
Definition: txrx_worker_hw.h:76
kDebugPrintInTask
static constexpr bool kDebugPrintInTask
Definition: symbols.h:201
Config::IsPilot
bool IsPilot(size_t, size_t) const
Definition: config.cc:1495
kDebugDownlink
static constexpr bool kDebugDownlink
Definition: symbols.h:180
TxRxWorker::GetPendingTxEvents
std::vector< EventData > GetPendingTxEvents(size_t max_events=0)
Definition: txrx_worker.cc:85
Radio::TxFlags
TxFlags
Definition: radio.h:20
EventData
Definition: message.h:142
RadioConfig
Definition: radio_lib.h:21
TxRxWorkerHw::ResetRxStatus
void ResetRxStatus(size_t interface, bool reuse_memory)
Definition: txrx_worker_hw.cc:919
gen_tag_t::ant_id_
uint16_t ant_id_
Definition: message.h:38
message.h
Self defined functions for message storage and passing.
TxRxWorkerHw::UpdateRxInterface
TxRxWorkerRx::RxParameters UpdateRxInterface(const TxRxWorkerRx::RxParameters &last_rx)
Returns the next symbol and interface.
Definition: txrx_worker_hw.cc:612
FrameStats::GetDLCalSymbol
size_t GetDLCalSymbol(size_t location) const
Definition: framestats.cc:110
i
for i
Definition: generate_data.m:107
TxRxWorkerHw::IsTxSymbolNext
bool IsTxSymbolNext(size_t radio_id, size_t current_symbol)
Definition: txrx_worker_hw.cc:577
GetTime
Definition: gettime.h:11
TxRxWorkerRx::RxStatusTracker
Definition: rx_status_tracker.h:17
SymbolType::kBeacon
@ kBeacon
Catch::cout
std::ostream & cout()
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
Config::IsCalUlPilot
bool IsCalUlPilot(size_t, size_t) const
Definition: config.cc:1530
comms-lib.h
Communications Library: a) Generate pilot/preamble sequences b) OFDM modulation.
CommsLib::Hadamard2
static int Hadamard2(int i, int j)
Definition: comms-lib.h:95
TxRxWorkerRx::RxTimeTracker
Definition: txrx_worker_hw.h:24
Packet
Definition: message.h:164
TxRxWorker::Configuration
Config * Configuration()
Definition: txrx_worker.h:46
EventType::kPacketRX
@ kPacketRX
TxRxWorkerHw::PrintRxSymbolTiming
void PrintRxSymbolTiming(std::vector< TxRxWorkerRx::RxTimeTracker > &rx_times, size_t current_frame, size_t current_symbol, size_t next_symbol)
Definition: txrx_worker_hw.cc:663
FrameStats::GetDLSymbol
size_t GetDLSymbol(size_t location) const
Definition: framestats.cc:106
TxRxWorkerHw::first_symbol_
std::vector< bool > first_symbol_
Definition: txrx_worker_hw.h:84
kNumStatsFrames
static constexpr size_t kNumStatsFrames
Definition: symbols.h:300
TxRxWorker::NotifyComplete
bool NotifyComplete(const EventData &complete_event)
Definition: txrx_worker.cc:75
RadioConfig::RadioTx
int RadioTx(size_t radio_id, const void *const *buffs, Radio::TxFlags flags, long long &tx_time)
Definition: radio_lib.cc:306
Radio::RxFlags
RxFlags
Definition: radio.h:19
TxRxWorker
Definition: txrx_worker.h:18
FrameStats::NumULCalSyms
size_t NumULCalSyms() const
Definition: framestats.cc:81
TxRxWorkerHw::DoTxRx
void DoTxRx() final
Definition: txrx_worker_hw.cc:44
kIsWorkerTimingEnabled
static constexpr bool kIsWorkerTimingEnabled
Definition: symbols.h:303
TxRxWorker::GetRxPacket
RxPacket & GetRxPacket()
Definition: txrx_worker.cc:104
TxRxWorker::channels_per_interface_
const size_t channels_per_interface_
Definition: txrx_worker.h:58
TxRxWorkerHw::TxBeaconHw
void TxBeaconHw(size_t frame_id, size_t interface_id, long long time0)
Definition: txrx_worker_hw.cc:299
FrameStats::NumDLSyms
size_t NumDLSyms() const
Definition: framestats.cc:83
moodycamel::ConcurrentQueue< EventData >
Config::CellId
const std::vector< size_t > & CellId() const
Definition: config.h:368
Config::GetSymbolType
SymbolType GetSymbolType(size_t symbol_id) const
Return the symbol type of this symbol in this frame.
Definition: config.cc:1557
GetTime::MeasureRdtscFreq
static double MeasureRdtscFreq()
Definition: gettime.h:51
TxRxWorkerRx::RxParameters
Definition: txrx_worker_hw.h:19
AGORA_LOG_SYMBOL
#define AGORA_LOG_SYMBOL(...)
Definition: logger.h:82
TxRxWorker::tid_
const size_t tid_
Definition: txrx_worker.h:54
Config::HwFramer
bool HwFramer() const
Definition: config.h:53
TxRxWorkerHw::ScheduleTxInit
void ScheduleTxInit(size_t frames_to_schedule, long long time0)
Definition: txrx_worker_hw.cc:839
Config
Definition: config.h:26
AGORA_LOG_INFO
#define AGORA_LOG_INFO(...)
Definition: logger.h:62
Config::IsUplink
bool IsUplink(size_t, size_t) const
Definition: config.cc:1537
Config::RefAnt
size_t RefAnt(size_t id) const
Definition: config.h:100
Config::IsCalDlPilot
bool IsCalDlPilot(size_t, size_t) const
Definition: config.cc:1523
std
Definition: json.hpp:5213
TxRxWorkerHw::freq_ghz_
const double freq_ghz_
Definition: txrx_worker_hw.h:78
AGORA_LOG_FRAME
#define AGORA_LOG_FRAME(...)
Definition: logger.h:72
TxRxWorkerHw::GetHwTime
long long int GetHwTime()
Definition: txrx_worker_hw.cc:733
TxRxWorkerRx
Definition: rx_status_tracker.h:15
RtAssert
static void RtAssert(bool condition, const char *throw_str)
Definition: utils.h:104
zeros
N_SC, NUM_UE, NUM_UE zeros()
rx_status_tracker.h
Implementation of RxStatusTracker helper class.
AGORA_LOG_WARN
#define AGORA_LOG_WARN(...)
Definition: logger.h:53
TxRxWorkerHw
Definition: txrx_worker_hw.h:30
kBeamsweepData
static constexpr bool kBeamsweepData
Definition: txrx_worker_hw.cc:17
Config::RecipCalDlAnt
size_t RecipCalDlAnt(size_t frame_id, size_t dl_cal_symbol) const
Definition: config.h:119
TxRxWorkerHw::program_start_ticks_
size_t program_start_ticks_
Definition: txrx_worker_hw.h:77
SymbolType::kCalUL
@ kCalUL
TxRxWorker::interface_offset_
const size_t interface_offset_
Definition: txrx_worker.h:57
TxRxWorkerRx::RxTimeTracker::end_ticks_
size_t end_ticks_
Definition: txrx_worker_hw.h:26
gettime.h
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
FrameStats::GetBeaconSymbol
size_t GetBeaconSymbol(size_t location) const
Definition: framestats.cc:126
txrx_worker.h
txrx worker thread definition. This is the parent / interface
TxRxWorkerRx::RxParameters::interface_
size_t interface_
Definition: txrx_worker_hw.h:21
TxRxWorker::core_offset_
const size_t core_offset_
Definition: txrx_worker.h:55
SymbolType::kUL
@ kUL
Config::BeaconAnt
size_t BeaconAnt() const
Definition: config.h:102
TxRxWorkerRx::RxParameters::symbol_
size_t symbol_
Definition: txrx_worker_hw.h:20
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
Config::BfAntNum
size_t BfAntNum() const
Definition: config.h:39