5G-MAG Reference Tools - MBMS Modem
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
Phy Class Reference

The PHY component. More...

#include <Phy.h>

Collaboration diagram for Phy:
Collaboration graph

Classes

struct  mch_info_t
 
struct  mtch_info_t
 

Public Types

enum class  SubcarrierSpacing { df_15kHz , df_7kHz5 , df_1kHz25 }
 
typedef std::function< int(cf_t *data[SRSRAN_MAX_CHANNELS], uint32_t nsamples, srsran_timestamp_t *rx_time)> get_samples_t
 Definition of the callback function used to fetch samples from the SDR. More...
 

Public Member Functions

 Phy (const libconfig::Config &cfg, get_samples_t cb, uint8_t cs_nof_prb, int8_t override_nof_prb, uint8_t rx_channels)
 Default constructor. More...
 
virtual ~Phy ()
 Default destructor. More...
 
bool init ()
 Initialize the underlying components. More...
 
bool cell_search ()
 Search for a cell. More...
 
bool synchronize_subframe ()
 Synchronizes PSS/SSS and tries to deocode the MIB. More...
 
bool get_next_frame (cf_t **buffer, uint32_t size)
 Get the sample data for the next subframe. More...
 
srsran_cell_t cell ()
 Get the current cell (with params adjusted for MBSFN) More...
 
unsigned nr_prb ()
 Get the current number of PRB. More...
 
uint32_t tti ()
 Get the current subframe TTI. More...
 
float cfo ()
 Get the current CFO value. More...
 
void set_cfo_from_channel_estimation (float cfo)
 Set the CFO value from channel estimation. More...
 
void set_mch_scheduling_info (const srsran::sib13_t &sib13)
 Set the values received in SIB13. More...
 
void set_mbsfn_config (const srsran::mcch_msg_t &mcch)
 Set MBSFN configuration values. More...
 
void reset ()
 Clear configuration values. More...
 
bool mcch_configured ()
 Return true if MCCH has been configured. More...
 
uint8_t mbsfn_area_id ()
 Returns the current MBSFN area ID. More...
 
srsran_mbsfn_cfg_t mbsfn_config_for_tti (uint32_t tti, unsigned &area)
 Returns the MBSFN configuration (MCS, etc) for the subframe with the passed TTI. More...
 
void set_decode_mcch (bool d)
 Enable MCCH decoding. More...
 
uint8_t nof_mbsfn_prb ()
 Get number of PRB in MBSFN/PMCH. More...
 
void set_nof_mbsfn_prb (uint8_t prb)
 Override number of PRB in MBSFN/PMCH. More...
 
void set_cell ()
 
bool is_cas_subframe (unsigned tti)
 
bool is_mbsfn_subframe (unsigned tti)
 
void set_ue_sync_cfo_loop_bw_pss (float bw)
 Set the factor for the PSS loopback. More...
 
float get_ue_sync_cfo_loop_bw_pss ()
 
void set_ue_sync_find_cfo_pss_enable (bool enable)
 Enables or disables the CFO estimation from the PSS in the finding stage. More...
 
bool get_ue_sync_find_cfo_pss_enable ()
 
void set_ue_sync_track_cfo_pss_enable (bool enable)
 Enables or disables the CFO estimation from the PSS in the tracking stage. More...
 
bool get_ue_sync_track_cfo_pss_enable ()
 
void set_ue_sync_find_cfo_correct_enable (bool enable)
 Enables the CFO correction while finding the synchronization from previous estimations. More...
 
bool get_ue_sync_find_cfo_correct_enable ()
 
void set_ue_sync_track_cfo_correct_enable (bool enable)
 Enables the CFO correction while tracking the synchronization from previous estimations. More...
 
bool get_ue_sync_track_cfo_correct_enable ()
 
void set_ue_sync_track_cfo_ema (float ema)
 Sets the ema alpha value used for the tracking of the CFO in the trackin sync object, both in CP and PSS CFO estimation. More...
 
float get_ue_sync_track_cfo_ema ()
 
void set_ue_sync_find_cfo_ema (float ema)
 Sets the ema alpha value used for the tracking of the CFO in the trackin sync object, both in CP and PSS CFO estimation. More...
 
float get_ue_sync_find_cfo_ema ()
 
void set_ue_sync_track_sfo_ema (float ema)
 Sets the ema alpha value used for the tracking of the SFO in ue_sync in the function track_peak_ok. More...
 
float get_ue_sync_track_sfo_ema ()
 
void set_ue_sync_pss_cfo_ema_find (float ema)
 Sets the weight factor alpha for the exponential moving average of the PSS correlation output
More...
 
float get_ue_sync_pss_cfo_ema_find ()
 
void set_ue_sync_pss_cfo_ema_track (float ema)
 Sets the weight factor alpha for the exponential moving average of the PSS correlation output
More...
 
float get_ue_sync_pss_cfo_ema_track ()
 
void set_ue_sync_threshold_track (float threshold)
 Sets the threshold of the peak found while tracking for synchronization. More...
 
float get_ue_sync_threshold_track ()
 
void set_ue_sync_threshold_find (float threshold)
 Sets the threshold of the peak found while searching for synchronization. More...
 
float get_ue_sync_threshold_find ()
 
const std::vector< mch_info_t > & mch_info ()
 
void set_dest_for_lcid (uint32_t mch_idx, int lcid, std::string dest)
 
SubcarrierSpacing mbsfn_subcarrier_spacing ()
 
float mbsfn_subcarrier_spacing_khz ()
 
srsran::mcch_msg_t & mcch ()
 

Public Attributes

int _mcs = 0
 
get_samples_t _sample_cb
 

Private Attributes

const libconfig::Config & _cfg
 
srsran_ue_sync_t _ue_sync = {}
 
srsran_ue_cellsearch_t _cell_search = {}
 
srsran_ue_mib_sync_t _mib_sync = {}
 
srsran_ue_mib_t _mib = {}
 
srsran_cell_t _cell = {}
 
bool _decode_mcch = false
 
cf_t * _mib_buffer [SRSRAN_MAX_CHANNELS] = {}
 
uint32_t _buffer_max_samples = 0
 
uint32_t _tti = 0
 
uint8_t _mcch_table [10] = {}
 
bool _mcch_configured = false
 
srsran::sib13_t _sib13 = {}
 
srsran::mcch_msg_t _mcch = {}
 
bool _mch_configured = false
 
uint8_t _cs_nof_prb
 
std::vector< mch_info_t_mch_info
 
std::map< uint32_t, std::map< int, std::string > > _dests
 
int8_t _override_nof_prb
 
uint8_t _rx_channels
 
bool _search_extended_cp = true
 

Detailed Description

The PHY component.

Handles synchronisation and is the central hub for lower level processing

Definition at line 42 of file Phy.h.

Member Typedef Documentation

◆ get_samples_t

typedef std::function<int(cf_t* data[SRSRAN_MAX_CHANNELS], uint32_t nsamples, srsran_timestamp_t* rx_time)> Phy::get_samples_t

Definition of the callback function used to fetch samples from the SDR.

Definition at line 47 of file Phy.h.

Member Enumeration Documentation

◆ SubcarrierSpacing

Enumerator
df_15kHz 
df_7kHz5 
df_1kHz25 

Definition at line 257 of file Phy.h.

257  {
258  df_15kHz,
259  df_7kHz5,
260  df_1kHz25
261  };

Constructor & Destructor Documentation

◆ Phy()

Phy::Phy ( const libconfig::Config &  cfg,
get_samples_t  cb,
uint8_t  cs_nof_prb,
int8_t  override_nof_prb,
uint8_t  rx_channels 
)

Default constructor.

Parameters
cfgConfig singleton reference
cbSample recv callback
cs_nof_prbNr of PRBs to use during cell search
override_nof_prbIf set, overrides the nof PRB received in the MIB

Definition at line 47 of file Phy.cpp.

49  : _cfg(cfg),
50  _sample_cb(std::move(std::move(cb))),
51  _cs_nof_prb(cs_nof_prb),
52  _override_nof_prb(override_nof_prb),
53  _rx_channels(rx_channels) {
55  _mib_buffer[0] = static_cast<cf_t*>(malloc(_buffer_max_samples * sizeof(cf_t))); // NOLINT
56  _mib_buffer[1] = static_cast<cf_t*>(malloc(_buffer_max_samples * sizeof(cf_t))); // NOLINT
57 }
const uint32_t kMaxBufferSamples
Definition: Phy.cpp:35
uint8_t _cs_nof_prb
Definition: Phy.h:313
cf_t * _mib_buffer[SRSRAN_MAX_CHANNELS]
Definition: Phy.h:302
const libconfig::Config & _cfg
Definition: Phy.h:293
uint8_t _rx_channels
Definition: Phy.h:320
uint32_t _buffer_max_samples
Definition: Phy.h:303
get_samples_t _sample_cb
Definition: Phy.h:290
int8_t _override_nof_prb
Definition: Phy.h:319
static Config cfg
Global configuration object.
Definition: main.cpp:172

◆ ~Phy()

Phy::~Phy ( )
virtual

Default destructor.

Definition at line 59 of file Phy.cpp.

59  {
60  srsran_ue_sync_free(&_ue_sync);
61  free(_mib_buffer[0]); // NOLINT
62 }
srsran_ue_sync_t _ue_sync
Definition: Phy.h:294

Member Function Documentation

◆ cell()

srsran_cell_t Phy::cell ( )
inline

Get the current cell (with params adjusted for MBSFN)

Definition at line 91 of file Phy.h.

91  {
92  return _cell;
93  }
srsran_cell_t _cell
Definition: Phy.h:298

◆ cell_search()

auto Phy::cell_search ( )

Search for a cell.

Returns true if a cell has been found and the MIB could be decoded, false otherwise.

Definition at line 96 of file Phy.cpp.

96  {
97  std::array<srsran_ue_cellsearch_result_t, kMaxCellsToDiscover> found_cells = {0};
98 
99  uint32_t max_peak_cell = 0;
100  int ret = srsran_ue_cellsearch_scan(&_cell_search, found_cells.data(), &max_peak_cell);
101  if (ret < 0) {
102  spdlog::error("Phy: Error decoding MIB: Error searching PSS\n");
103  return false;
104  }
105  if (ret == 0) {
106  spdlog::error("Phy: Could not find any cell in this frequency\n");
107  return false;
108  }
109 
110  srsran_cell_t new_cell = {};
111  new_cell.id = found_cells.at(max_peak_cell).cell_id;
112  new_cell.cp = found_cells.at(max_peak_cell).cp;
113  new_cell.frame_type = found_cells.at(max_peak_cell).frame_type;
114  float cfo = found_cells.at(max_peak_cell).cfo;
115 
116  spdlog::info("Phy: PSS/SSS detected: Mode {}, PCI {}, CFO {} KHz, CP {}",
117  new_cell.frame_type != 0U ? "TDD" : "FDD", new_cell.id,
118  cfo / 1000, srsran_cp_string(new_cell.cp));
119 
120 
121 
122  std::array<uint8_t, SRSRAN_BCH_PAYLOAD_LEN> bch_payload = {};
123  /* Find and decode MIB */
124  int sfn_offset = 0;
125 
126  // Try to decode MIB-MBMS
127  new_cell.mbms_dedicated = true;
128  if (srsran_ue_mib_sync_set_cell_prb(&_mib_sync, new_cell, _cs_nof_prb) != 0) {
129  spdlog::error("Phy: Error setting UE MIB sync cell");
130  return false;
131  }
132  srsran_ue_sync_reset(&_mib_sync.ue_sync);
133  ret = srsran_ue_mib_sync_decode_prb(&_mib_sync, kMaxFramesTimeout, bch_payload.data(), &new_cell.nof_ports, &sfn_offset, _cs_nof_prb);
134 
135  if (!ret) { // MIB-MBMS failed, try to decode regular MIB
136  init();
137  new_cell.mbms_dedicated = false;
138  if (srsran_ue_mib_sync_set_cell_prb(&_mib_sync, new_cell, _cs_nof_prb) != 0) {
139  spdlog::error("Phy: Error setting UE MIB sync cell");
140  return false;
141  }
142  srsran_ue_sync_reset(&_mib_sync.ue_sync);
143  ret = srsran_ue_mib_sync_decode_prb(&_mib_sync, kMaxFramesTimeout, bch_payload.data(), &new_cell.nof_ports, &sfn_offset, _cs_nof_prb);
144  }
145 
146  if (ret == 1) {
147  uint32_t sfn = 0;
148 
149  if (new_cell.mbms_dedicated) {
150  srsran_pbch_mib_mbms_unpack(bch_payload.data(), &new_cell, &sfn, nullptr,
152  } else {
153  srsran_pbch_mib_unpack(bch_payload.data(), &new_cell, &sfn);
154  }
155  sfn = (sfn + sfn_offset) % 1024;
156 
157  spdlog::info(
158  "Phy: MIB Decoded. {} cell, Mode {}, PCI {}, PRB {}, Ports {}, CFO {} KHz, SFN "
159  "{}, sfn_offset {}\n",
160  new_cell.mbms_dedicated ? "MBMS dedicated" : "MBMS/Unicast mixed",
161  new_cell.frame_type != 0u ? "TDD" : "FDD", new_cell.id,
162  new_cell.nof_prb, new_cell.nof_ports, cfo / 1000, sfn, sfn_offset);
163 
164  if (!srsran_cell_isvalid(&new_cell)) {
165  spdlog::error("SYNC: Detected invalid cell.\n");
166  return false;
167  }
168 
169  _cell = new_cell;
170  _cell.mbsfn_prb = _cell.nof_prb;
171 
172  if (srsran_ue_sync_set_cell(&_ue_sync, cell()) != 0) {
173  spdlog::error("Phy: failed to set cell.\n");
174  return false;
175  }
176  if (srsran_ue_mib_set_cell(&_mib, cell()) != 0) {
177  spdlog::error("Phy: Error setting UE MIB cell");
178  return false;
179  }
180 
181  return true;
182  }
183 
184  spdlog::error("Phy: failed to receive MIB\n");
185  return false;
186 }
const uint32_t kMaxFramesTimeout
Definition: Phy.cpp:45
srsran_cell_t cell()
Get the current cell (with params adjusted for MBSFN)
Definition: Phy.h:91
srsran_ue_cellsearch_t _cell_search
Definition: Phy.h:295
bool init()
Initialize the underlying components.
Definition: Phy.cpp:197
srsran_ue_mib_t _mib
Definition: Phy.h:297
float cfo()
Get the current CFO value.
Definition: Phy.h:108
srsran_ue_mib_sync_t _mib_sync
Definition: Phy.h:296

◆ cfo()

float Phy::cfo ( )
inline

Get the current CFO value.

Definition at line 108 of file Phy.h.

108 { return srsran_ue_sync_get_cfo(&_ue_sync);}

◆ get_next_frame()

auto Phy::get_next_frame ( cf_t **  buffer,
uint32_t  size 
)

Get the sample data for the next subframe.

Definition at line 225 of file Phy.cpp.

225  {
226  return 1 == srsran_ue_sync_zerocopy(&_ue_sync, buffer, size);
227 }

◆ get_ue_sync_cfo_loop_bw_pss()

float Phy::get_ue_sync_cfo_loop_bw_pss ( )
inline

Definition at line 173 of file Phy.h.

173 { return _ue_sync.cfo_loop_bw_pss; };

◆ get_ue_sync_find_cfo_correct_enable()

bool Phy::get_ue_sync_find_cfo_correct_enable ( )
inline

Definition at line 193 of file Phy.h.

193 { return _ue_sync.cfo_correct_enable_find; }

◆ get_ue_sync_find_cfo_ema()

float Phy::get_ue_sync_find_cfo_ema ( )
inline

Definition at line 211 of file Phy.h.

211 { return _ue_sync.sfind.cfo_ema_alpha; };

◆ get_ue_sync_find_cfo_pss_enable()

bool Phy::get_ue_sync_find_cfo_pss_enable ( )
inline

Definition at line 179 of file Phy.h.

179 { return _ue_sync.sfind.cfo_pss_enable; };

◆ get_ue_sync_pss_cfo_ema_find()

float Phy::get_ue_sync_pss_cfo_ema_find ( )
inline

Definition at line 223 of file Phy.h.

223 { return _ue_sync.sfind.pss.ema_alpha; };

◆ get_ue_sync_pss_cfo_ema_track()

float Phy::get_ue_sync_pss_cfo_ema_track ( )
inline

Definition at line 229 of file Phy.h.

229 { return _ue_sync.strack.pss.ema_alpha; };

◆ get_ue_sync_threshold_find()

float Phy::get_ue_sync_threshold_find ( )
inline

Definition at line 241 of file Phy.h.

241 { return _ue_sync.sfind.threshold; };

◆ get_ue_sync_threshold_track()

float Phy::get_ue_sync_threshold_track ( )
inline

Definition at line 235 of file Phy.h.

235 { return _ue_sync.strack.threshold; };

◆ get_ue_sync_track_cfo_correct_enable()

bool Phy::get_ue_sync_track_cfo_correct_enable ( )
inline

Definition at line 199 of file Phy.h.

199 { return _ue_sync.cfo_correct_enable_track; }

◆ get_ue_sync_track_cfo_ema()

float Phy::get_ue_sync_track_cfo_ema ( )
inline

Definition at line 205 of file Phy.h.

205 { return _ue_sync.strack.cfo_ema_alpha; };

◆ get_ue_sync_track_cfo_pss_enable()

bool Phy::get_ue_sync_track_cfo_pss_enable ( )
inline

Definition at line 185 of file Phy.h.

185 { return _ue_sync.strack.cfo_pss_enable; };

◆ get_ue_sync_track_sfo_ema()

float Phy::get_ue_sync_track_sfo_ema ( )
inline

Definition at line 217 of file Phy.h.

217 { return _ue_sync.sfo_ema; };

◆ init()

auto Phy::init ( )

Initialize the underlying components.

Definition at line 197 of file Phy.cpp.

197  {
198  if (srsran_ue_cellsearch_init_multi_prb_cp(&_cell_search, kMaxScannedFrames, receive_callback, _rx_channels,
199  this, _cs_nof_prb, _search_extended_cp) != 0) {
200  spdlog::error("Phy: error while initiating UE cell search\n");
201  return false;
202  }
203  srsran_ue_cellsearch_set_nof_valid_frames(&_cell_search, kMaxValidFrames);
204 
205  if (srsran_ue_sync_init_multi(&_ue_sync, MAX_PRB, false, receive_callback, _rx_channels,
206  this) != 0) {
207  spdlog::error("Cannot init ue_sync");
208  return false;
209  }
210 
211  if (srsran_ue_mib_sync_init_multi_prb(&_mib_sync, receive_callback, _rx_channels, this,
212  _cs_nof_prb) != 0) {
213  spdlog::error("Cannot init ue_mib_sync");
214  return false;
215  }
216 
217  if (srsran_ue_mib_init(&_mib, _mib_buffer[0], MAX_PRB) != 0) {
218  spdlog::error("Cannot init ue_mib");
219  return false;
220  }
221 
222  return true;
223 }
const uint32_t kMaxScannedFrames
Definition: Phy.cpp:42
const uint32_t kMaxValidFrames
Definition: Phy.cpp:43
static auto receive_callback(void *obj, cf_t *data[SRSRAN_MAX_CHANNELS], uint32_t nsamples, srsran_timestamp_t *rx_time) -> int
Definition: Phy.cpp:29
constexpr unsigned int MAX_PRB
Definition: Phy.h:35
bool _search_extended_cp
Definition: Phy.h:321

◆ is_cas_subframe()

auto Phy::is_cas_subframe ( unsigned  tti)

Definition at line 308 of file Phy.cpp.

309 {
310  if (_cell.mbms_dedicated) {
311  // This is subframe 0 in a radio frame divisible by 4, and hence a CAS frame.
312  return tti%40 == 0;
313  } else {
314  unsigned sfn = tti / 10;
315  return (tti%10 == 0 || tti%10 == 5);
316  }
317 }
uint32_t tti()
Get the current subframe TTI.
Definition: Phy.h:103

◆ is_mbsfn_subframe()

auto Phy::is_mbsfn_subframe ( unsigned  tti)

Definition at line 319 of file Phy.cpp.

320 {
321  if (_cell.mbms_dedicated) {
322  // This is subframe 0 in a radio frame divisible by 4, and hence a CAS frame.
323  return !is_cas_subframe(tti);
324  } else {
325  return !is_cas_subframe(tti) &&
326  (tti%10 == 1 || tti%10 == 2 || tti%10 == 3 || tti%10 == 6 || tti%10 == 7 || tti%10 == 8);
327  }
328 }
bool is_cas_subframe(unsigned tti)
Definition: Phy.cpp:308

◆ mbsfn_area_id()

uint8_t Phy::mbsfn_area_id ( )
inline

Returns the current MBSFN area ID.

Definition at line 138 of file Phy.h.

138 { return _sib13.mbsfn_area_info_list[0].mbsfn_area_id; }
srsran::sib13_t _sib13
Definition: Phy.h:308

◆ mbsfn_config_for_tti()

auto Phy::mbsfn_config_for_tti ( uint32_t  tti,
unsigned &  area 
)

Returns the MBSFN configuration (MCS, etc) for the subframe with the passed TTI.

Definition at line 329 of file Phy.cpp.

330  {
331  srsran_mbsfn_cfg_t cfg;
332  cfg.enable = false;
333  cfg.is_mcch = false;
334 
335  if (!_mcch_configured) {
336  {
337  return cfg;
338  }
339  }
340 
341  uint32_t sfn = tti / 10;
342  uint8_t sf = tti % 10;
343 
344  srsran::mbsfn_area_info_t& area_info = _sib13.mbsfn_area_info_list[0];
345 
346  cfg.mbsfn_area_id = area_info.mbsfn_area_id;
347  cfg.non_mbsfn_region_length = enum_to_number(area_info.non_mbsfn_region_len);
348 
349  if (sfn % enum_to_number(area_info.mcch_cfg.mcch_repeat_period) == area_info.mcch_cfg.mcch_offset &&
350  _mcch_table[sf] == 1) {
351  // MCCH
352  if (_decode_mcch) {
353  cfg.mbsfn_mcs = enum_to_number(area_info.mcch_cfg.sig_mcs);
354  cfg.enable = true;
355  cfg.is_mcch = true;
356  }
357  } else if (sfn % enum_to_number(area_info.mcch_cfg.mcch_repeat_period) == area_info.mcch_cfg.mcch_offset &&
358  sf == 1) {
359  cfg.mbsfn_mcs = enum_to_number(area_info.mcch_cfg.sig_mcs);
360  cfg.enable = true;
361  cfg.is_mcch = false;
362  } else {
363  if (_mch_configured) {
364  cfg.mbsfn_area_id = area_info.mbsfn_area_id;
365 
366  for (uint32_t i = 0; i < _mcch.nof_pmch_info; i++) {
367  unsigned fn_in_scheduling_period = sfn % enum_to_number(_mcch.pmch_info_list[i].mch_sched_period);
368  unsigned sf_idx = fn_in_scheduling_period * 10 + sf
369  - (fn_in_scheduling_period / 4) // minus 1 CAS SF per 4 SFNs
370  - 1; // minus 1 MCCH SF per scheduling period;
371 
372  spdlog::debug("i {}, tti {}, fn_in_ {}, sf_idx {}", i, tti, fn_in_scheduling_period, sf_idx);
373 
374  if (sf_idx <= _mcch.pmch_info_list[i].sf_alloc_end) {
375  area = i;
376  if ((i == 0 && fn_in_scheduling_period == 0 && sf == 1) ||
377  (i > 0 && _mcch.pmch_info_list[i-1].sf_alloc_end + 1 == sf_idx)) {
378  spdlog::debug("assigning sig_mcs {}, mch_idx is {}", area_info.mcch_cfg.sig_mcs, area);
379  cfg.mbsfn_mcs = enum_to_number(area_info.mcch_cfg.sig_mcs);
380  } else {
381  spdlog::debug("assigning pmch_mcs {}, mch_idx is {}", _mcch.pmch_info_list[i].data_mcs, area);
382  cfg.mbsfn_mcs = _mcch.pmch_info_list[i].data_mcs;
383  }
384  cfg.enable = true;
385  break;
386  }
387  }
388  }
389  }
390  return cfg;
391 }
bool _mcch_configured
Definition: Phy.h:307
uint8_t _mcch_table[10]
Definition: Phy.h:306
srsran::mcch_msg_t _mcch
Definition: Phy.h:309
bool _mch_configured
Definition: Phy.h:311
bool _decode_mcch
Definition: Phy.h:300

◆ mbsfn_subcarrier_spacing()

SubcarrierSpacing Phy::mbsfn_subcarrier_spacing ( )
inline

Definition at line 263 of file Phy.h.

263  {
264  if (_cell.mbms_dedicated) {
265  switch (_sib13.mbsfn_area_info_list[0].subcarrier_spacing) {
266  case srsran::mbsfn_area_info_t::subcarrier_spacing_t::khz_1dot25: return SubcarrierSpacing::df_1kHz25;
267  case srsran::mbsfn_area_info_t::subcarrier_spacing_t::khz_7dot5: return SubcarrierSpacing::df_7kHz5;
268  default: return SubcarrierSpacing::df_15kHz;
269  }
270  } else {
272  }
273  }

◆ mbsfn_subcarrier_spacing_khz()

float Phy::mbsfn_subcarrier_spacing_khz ( )
inline

Definition at line 275 of file Phy.h.

275  {
276  if (_cell.mbms_dedicated) {
277  switch (_sib13.mbsfn_area_info_list[0].subcarrier_spacing) {
278  case srsran::mbsfn_area_info_t::subcarrier_spacing_t::khz_1dot25: return 1.25;
279  case srsran::mbsfn_area_info_t::subcarrier_spacing_t::khz_7dot5: return 7.5;
280  default: return 15;
281  }
282  } else {
283  return 15;
284  }
285  }

◆ mcch()

srsran::mcch_msg_t& Phy::mcch ( )
inline

Definition at line 287 of file Phy.h.

287 { return _mcch; }

◆ mcch_configured()

bool Phy::mcch_configured ( )
inline

Return true if MCCH has been configured.

Definition at line 133 of file Phy.h.

133 { return _mcch_configured; }

◆ mch_info()

const std::vector< mch_info_t>& Phy::mch_info ( )
inline

Definition at line 253 of file Phy.h.

253 { return _mch_info; }
std::vector< mch_info_t > _mch_info
Definition: Phy.h:315

◆ nof_mbsfn_prb()

uint8_t Phy::nof_mbsfn_prb ( )
inline

Get number of PRB in MBSFN/PMCH.

Definition at line 153 of file Phy.h.

153 { return _cell.mbsfn_prb; }

◆ nr_prb()

unsigned Phy::nr_prb ( )
inline

Get the current number of PRB.

Definition at line 98 of file Phy.h.

98 { return _cell.nof_prb; }

◆ reset()

void Phy::reset ( )
inline

Clear configuration values.

Definition at line 128 of file Phy.h.

128 { _mcch_configured = _mch_configured = false; }

◆ set_cell()

auto Phy::set_cell ( )

Definition at line 188 of file Phy.cpp.

188  {
189  if (srsran_ue_sync_set_cell(&_ue_sync, cell()) != 0) {
190  spdlog::error("Phy: failed to set cell.\n");
191  }
192  if (srsran_ue_mib_set_cell(&_mib, cell()) != 0) {
193  spdlog::error("Phy: Error setting UE MIB cell");
194  }
195 }

◆ set_cfo_from_channel_estimation()

void Phy::set_cfo_from_channel_estimation ( float  cfo)
inline

Set the CFO value from channel estimation.

Definition at line 113 of file Phy.h.

113 { srsran_ue_sync_set_cfo_ref(&_ue_sync, cfo); }

◆ set_decode_mcch()

void Phy::set_decode_mcch ( bool  d)
inline

Enable MCCH decoding.

Definition at line 148 of file Phy.h.

148 { _decode_mcch = d; }

◆ set_dest_for_lcid()

void Phy::set_dest_for_lcid ( uint32_t  mch_idx,
int  lcid,
std::string  dest 
)
inline

Definition at line 255 of file Phy.h.

255 { _dests[mch_idx][lcid] = dest; }
std::map< uint32_t, std::map< int, std::string > > _dests
Definition: Phy.h:317

◆ set_mbsfn_config()

void Phy::set_mbsfn_config ( const srsran::mcch_msg_t &  mcch)

Set MBSFN configuration values.

Definition at line 265 of file Phy.cpp.

265  {
266  _mcch = mcch;
267  _mch_configured = true;
268 
269  _mch_info.clear();
270  for (uint32_t i = 0; i < _mcch.nof_pmch_info; i++) {
271  mch_info_t mch_info;
272  mch_info.mcs = _mcch.pmch_info_list[i].data_mcs;
273 
274  for (uint32_t j = 0; j < _mcch.pmch_info_list[i].nof_mbms_session_info; j++) {
275  mtch_info_t mtch_info;
276  mtch_info.lcid = _mcch.pmch_info_list[i].mbms_session_info_list[j].lc_ch_id;
277  char tmgi[20]; // NOLINT
278  /* acc to TS24.008 10.5.6.13:
279  * MCC 1,2,3: 901 -> 9, 0, 1
280  * MNC 3,1,2: 56 -> (F), 5, 6
281  * HEX 0x09F165
282  *
283  * -------------+-------------+---------
284  * MCC digit 2 | MCC digit 1 | Octet 6*
285  * -------------+-------------+---------
286  * MNC digit 3 | MCC digit 3 | Octet 7*
287  * -------------+-------------+---------
288  * MNC digit 2 | MNC digit 1 | Octet 8*
289  * -------------+-------------+---------
290  */
291  sprintf (tmgi, "%06x%02x%02x%02x",
292  _mcch.pmch_info_list[i].mbms_session_info_list[j].tmgi.serviced_id[2] |
293  _mcch.pmch_info_list[i].mbms_session_info_list[j].tmgi.serviced_id[1] << 8 |
294  _mcch.pmch_info_list[i].mbms_session_info_list[j].tmgi.serviced_id[0] << 16 ,
295  _mcch.pmch_info_list[i].mbms_session_info_list[j].tmgi.plmn_id.explicit_value.mcc[1] << 4 | mcch.pmch_info_list[i].mbms_session_info_list[j].tmgi.plmn_id.explicit_value.mcc[0],
296  ( _mcch.pmch_info_list[i].mbms_session_info_list[j].tmgi.plmn_id.explicit_value.nof_mnc_digits == 2 ? 0xF : _mcch.pmch_info_list[i].mbms_session_info_list[j].tmgi.plmn_id.explicit_value.mnc[2] ) << 4 | _mcch.pmch_info_list[i].mbms_session_info_list[j].tmgi.plmn_id.explicit_value.mcc[2] ,
297  _mcch.pmch_info_list[i].mbms_session_info_list[j].tmgi.plmn_id.explicit_value.mnc[1] << 4 | _mcch.pmch_info_list[i].mbms_session_info_list[j].tmgi.plmn_id.explicit_value.mnc[0]
298  );
299  mtch_info.tmgi = tmgi;
300  mtch_info.dest = _dests[i][mtch_info.lcid];
301  mch_info.mtchs.push_back(mtch_info);
302  }
303 
304  _mch_info.push_back(mch_info);
305  }
306 }
const std::vector< mch_info_t > & mch_info()
Definition: Phy.h:253
srsran::mcch_msg_t & mcch()
Definition: Phy.h:287

◆ set_mch_scheduling_info()

void Phy::set_mch_scheduling_info ( const srsran::sib13_t &  sib13)

Set the values received in SIB13.

Definition at line 229 of file Phy.cpp.

229  {
230  if (sib13.nof_mbsfn_area_info > 1) {
231  spdlog::warn("SIB13 has {} MBSFN area info elements - only 1 supported", sib13.nof_mbsfn_area_info);
232  }
233 
234  if (sib13.mbsfn_area_info_list[0].pmch_bandwidth != 0) {
235  _cell.mbsfn_prb = sib13.mbsfn_area_info_list[0].pmch_bandwidth;
236  }
237 
238  if (sib13.nof_mbsfn_area_info > 0) {
239  _sib13 = sib13;
240 
241  bzero(&_mcch_table[0], sizeof(uint8_t) * 10);
242  if (sib13.mbsfn_area_info_list[0].mcch_cfg.sf_alloc_info_is_r16) {
243  generate_mcch_table_r16(
244  &_mcch_table[0],
245  static_cast<uint32_t>(
246  sib13.mbsfn_area_info_list[0].mcch_cfg.sf_alloc_info));
247  } else {
248  generate_mcch_table(
249  &_mcch_table[0],
250  static_cast<uint32_t>(
251  sib13.mbsfn_area_info_list[0].mcch_cfg.sf_alloc_info));
252  }
253 
254  std::stringstream ss;
255  ss << "|";
256  for (unsigned char j : _mcch_table) {
257  ss << static_cast<int>(j) << "|";
258  }
259  spdlog::debug("MCCH table: {}", ss.str());
260 
261  _mcch_configured = true;
262  }
263 }

◆ set_nof_mbsfn_prb()

void Phy::set_nof_mbsfn_prb ( uint8_t  prb)
inline

Override number of PRB in MBSFN/PMCH.

Definition at line 158 of file Phy.h.

158 { _cell.mbsfn_prb = prb; }

◆ set_ue_sync_cfo_loop_bw_pss()

void Phy::set_ue_sync_cfo_loop_bw_pss ( float  bw)
inline

Set the factor for the PSS loopback.

When the CFO is estimated, _ue_sync takes the previous value and ads it to the current estimated CFO, this parameters is the weight of the previous value, from 0 (nothing) to 1 (all).

Definition at line 172 of file Phy.h.

172 { _ue_sync.cfo_loop_bw_pss = bw; };

◆ set_ue_sync_find_cfo_correct_enable()

void Phy::set_ue_sync_find_cfo_correct_enable ( bool  enable)
inline

Enables the CFO correction while finding the synchronization from previous estimations.

Definition at line 190 of file Phy.h.

190  {
191  _ue_sync.cfo_correct_enable_find = enable;
192  }

◆ set_ue_sync_find_cfo_ema()

void Phy::set_ue_sync_find_cfo_ema ( float  ema)
inline

Sets the ema alpha value used for the tracking of the CFO in the trackin sync object, both in CP and PSS CFO estimation.

Definition at line 210 of file Phy.h.

210 { srsran_sync_set_cfo_ema_alpha(&_ue_sync.sfind, ema); };

◆ set_ue_sync_find_cfo_pss_enable()

void Phy::set_ue_sync_find_cfo_pss_enable ( bool  enable)
inline

Enables or disables the CFO estimation from the PSS in the finding stage.

Definition at line 178 of file Phy.h.

178 { srsran_sync_set_cfo_pss_enable(&_ue_sync.sfind, enable); };

◆ set_ue_sync_pss_cfo_ema_find()

void Phy::set_ue_sync_pss_cfo_ema_find ( float  ema)
inline

Sets the weight factor alpha for the exponential moving average of the PSS correlation output

Definition at line 222 of file Phy.h.

222 { srsran_sync_set_em_alpha(&_ue_sync.sfind, ema); };

◆ set_ue_sync_pss_cfo_ema_track()

void Phy::set_ue_sync_pss_cfo_ema_track ( float  ema)
inline

Sets the weight factor alpha for the exponential moving average of the PSS correlation output

Definition at line 228 of file Phy.h.

228 { srsran_sync_set_em_alpha(&_ue_sync.strack, ema); };

◆ set_ue_sync_threshold_find()

void Phy::set_ue_sync_threshold_find ( float  threshold)
inline

Sets the threshold of the peak found while searching for synchronization.


Definition at line 240 of file Phy.h.

240 { srsran_sync_set_threshold(&_ue_sync.sfind, threshold); };

◆ set_ue_sync_threshold_track()

void Phy::set_ue_sync_threshold_track ( float  threshold)
inline

Sets the threshold of the peak found while tracking for synchronization.


Definition at line 234 of file Phy.h.

234 { srsran_sync_set_threshold(&_ue_sync.strack, threshold); };

◆ set_ue_sync_track_cfo_correct_enable()

void Phy::set_ue_sync_track_cfo_correct_enable ( bool  enable)
inline

Enables the CFO correction while tracking the synchronization from previous estimations.

Definition at line 198 of file Phy.h.

198 { _ue_sync.cfo_correct_enable_track = enable; }

◆ set_ue_sync_track_cfo_ema()

void Phy::set_ue_sync_track_cfo_ema ( float  ema)
inline

Sets the ema alpha value used for the tracking of the CFO in the trackin sync object, both in CP and PSS CFO estimation.

Definition at line 204 of file Phy.h.

204 { srsran_ue_sync_set_cfo_ema(&_ue_sync, ema); };

◆ set_ue_sync_track_cfo_pss_enable()

void Phy::set_ue_sync_track_cfo_pss_enable ( bool  enable)
inline

Enables or disables the CFO estimation from the PSS in the tracking stage.

Definition at line 184 of file Phy.h.

184 { srsran_sync_set_cfo_pss_enable(&_ue_sync.strack, enable); };

◆ set_ue_sync_track_sfo_ema()

void Phy::set_ue_sync_track_sfo_ema ( float  ema)
inline

Sets the ema alpha value used for the tracking of the SFO in ue_sync in the function track_peak_ok.

Definition at line 216 of file Phy.h.

216 { srsran_ue_sync_set_sfo_ema(&_ue_sync, ema); };

◆ synchronize_subframe()

auto Phy::synchronize_subframe ( )

Synchronizes PSS/SSS and tries to deocode the MIB.

Returns true on success, false otherwise.

Definition at line 64 of file Phy.cpp.

64  {
65 
66  int ret = srsran_ue_sync_zerocopy(&_ue_sync, _mib_buffer, _buffer_max_samples); // NOLINT
67  if (ret < 0) {
68  spdlog::error("SYNC: Error calling ue_sync_get_buffer.\n");
69  return false;
70  }
71 
72  if (ret == 1) {
73  std::array<uint8_t, SRSRAN_BCH_PAYLOAD_LEN> bch_payload = {};
74  if (srsran_ue_sync_get_sfidx(&_ue_sync) == 0) {
75  int sfn_offset = 0;
76  int n =
77  srsran_ue_mib_decode(&_mib, bch_payload.data(), nullptr, &sfn_offset);
78  if (n == 1) {
79  uint32_t sfn = 0;
80  if (_cell.mbms_dedicated) {
81  srsran_pbch_mib_mbms_unpack(bch_payload.data(), &_cell, &sfn, nullptr,
83  sfn = (sfn + sfn_offset * kSfnOffset) % kMaxSfn;
84  } else {
85  srsran_pbch_mib_unpack(bch_payload.data(), &_cell, &sfn);
86  sfn = (sfn + sfn_offset) % kMaxSfn;
87  }
88  _tti = sfn * kSubframesPerFrame;
89  return true;
90  }
91  }
92  }
93  return false;
94 }
const uint32_t kMaxSfn
Definition: Phy.cpp:36
const uint32_t kSfnOffset
Definition: Phy.cpp:37
const uint32_t kSubframesPerFrame
Definition: Phy.cpp:38
uint32_t _tti
Definition: Phy.h:304

◆ tti()

uint32_t Phy::tti ( )
inline

Get the current subframe TTI.

Definition at line 103 of file Phy.h.

103 { return _tti; }

Member Data Documentation

◆ _buffer_max_samples

uint32_t Phy::_buffer_max_samples = 0
private

Definition at line 303 of file Phy.h.

◆ _cell

srsran_cell_t Phy::_cell = {}
private

Definition at line 298 of file Phy.h.

◆ _cell_search

srsran_ue_cellsearch_t Phy::_cell_search = {}
private

Definition at line 295 of file Phy.h.

◆ _cfg

const libconfig::Config& Phy::_cfg
private

Definition at line 293 of file Phy.h.

◆ _cs_nof_prb

uint8_t Phy::_cs_nof_prb
private

Definition at line 313 of file Phy.h.

◆ _decode_mcch

bool Phy::_decode_mcch = false
private

Definition at line 300 of file Phy.h.

◆ _dests

std::map< uint32_t, std::map< int, std::string > > Phy::_dests
private

Definition at line 317 of file Phy.h.

◆ _mcch

srsran::mcch_msg_t Phy::_mcch = {}
private

Definition at line 309 of file Phy.h.

◆ _mcch_configured

bool Phy::_mcch_configured = false
private

Definition at line 307 of file Phy.h.

◆ _mcch_table

uint8_t Phy::_mcch_table[10] = {}
private

Definition at line 306 of file Phy.h.

◆ _mch_configured

bool Phy::_mch_configured = false
private

Definition at line 311 of file Phy.h.

◆ _mch_info

std::vector< mch_info_t > Phy::_mch_info
private

Definition at line 315 of file Phy.h.

◆ _mcs

int Phy::_mcs = 0

Definition at line 289 of file Phy.h.

◆ _mib

srsran_ue_mib_t Phy::_mib = {}
private

Definition at line 297 of file Phy.h.

◆ _mib_buffer

cf_t* Phy::_mib_buffer[SRSRAN_MAX_CHANNELS] = {}
private

Definition at line 302 of file Phy.h.

◆ _mib_sync

srsran_ue_mib_sync_t Phy::_mib_sync = {}
private

Definition at line 296 of file Phy.h.

◆ _override_nof_prb

int8_t Phy::_override_nof_prb
private

Definition at line 319 of file Phy.h.

◆ _rx_channels

uint8_t Phy::_rx_channels
private

Definition at line 320 of file Phy.h.

◆ _sample_cb

get_samples_t Phy::_sample_cb

Definition at line 290 of file Phy.h.

◆ _search_extended_cp

bool Phy::_search_extended_cp = true
private

Definition at line 321 of file Phy.h.

◆ _sib13

srsran::sib13_t Phy::_sib13 = {}
private

Definition at line 308 of file Phy.h.

◆ _tti

uint32_t Phy::_tti = 0
private

Definition at line 304 of file Phy.h.

◆ _ue_sync

srsran_ue_sync_t Phy::_ue_sync = {}
private

Definition at line 294 of file Phy.h.


The documentation for this class was generated from the following files: