1111#include " pusch_processor_validator_impl.h"
1212#include " pusch_processor_impl.h"
1313#include " srsran/ran/transform_precoding/transform_precoding_helpers.h"
14+ #include " srsran/ran/uci/uci_formatters.h"
1415
1516using namespace srsran ;
1617
@@ -31,115 +32,137 @@ pusch_processor_validator_impl::pusch_processor_validator_impl(
3132 nof_tx_layers_range);
3233}
3334
34- bool pusch_processor_validator_impl::is_valid (const pusch_processor::pdu_t & pdu) const
35+ error_type<std::string> pusch_processor_validator_impl::is_valid (const pusch_processor::pdu_t & pdu) const
3536{
3637 using namespace units ::literals;
3738 unsigned nof_symbols_slot = get_nsymb_per_slot (pdu.cp );
3839
3940 // The BWP size exceeds the grid size.
4041 if ((pdu.bwp_start_rb + pdu.bwp_size_rb ) > ce_dims.nof_prb ) {
41- return false ;
42+ return make_unexpected (fmt::format (
43+ " The sum of the BWP start (i.e., {}) and size (i.e., {}) exceeds the maximum grid size (i.e., {} PRB)." ,
44+ pdu.bwp_start_rb ,
45+ pdu.bwp_size_rb ,
46+ ce_dims.nof_prb ));
4247 }
4348
4449 // The implementation only works with a single transmit layer.
4550 if (pdu.nof_tx_layers > ce_dims.nof_tx_layers ) {
46- return false ;
51+ return make_unexpected (fmt::format (" The number of transmit layers (i.e., {}) is out of the range {}." ,
52+ pdu.nof_tx_layers ,
53+ interval<unsigned , true >(1 , ce_dims.nof_tx_layers )));
4754 }
4855
4956 // The number of receive ports cannot exceed the maximum dimensions.
5057 if (pdu.rx_ports .size () > ce_dims.nof_rx_ports ) {
51- return false ;
58+ return make_unexpected (
59+ fmt::format (" The number of receive ports (i.e., {}) exceeds the maximum number of receive ports (i.e., {})." ,
60+ pdu.rx_ports .size (),
61+ ce_dims.nof_rx_ports ));
5262 }
5363
5464 // The frequency allocation is not compatible with the BWP parameters.
5565 if (!pdu.freq_alloc .is_bwp_valid (pdu.bwp_start_rb , pdu.bwp_size_rb )) {
56- return false ;
66+ return make_unexpected ( fmt::format ( " Invalid BWP configuration {}:{}. " , pdu. bwp_start_rb , pdu. bwp_size_rb )) ;
5767 }
5868
5969 // Currently, none of the UCI field sizes can exceed 11 bit.
6070 static constexpr unsigned max_uci_len = 11 ;
6171 if ((pdu.uci .nof_harq_ack > max_uci_len) || (pdu.uci .nof_csi_part1 > max_uci_len)) {
62- return false ;
63- }
64-
65- // CSI Part 2 must not be present if CSI Part 1 is not present.
66- if ((pdu.uci .nof_csi_part1 == 0 ) && !pdu.uci .csi_part2_size .entries .empty ()) {
67- return false ;
72+ return make_unexpected (fmt::format (" UCI field sizes in bits ({}, {}), exceed the maximum bit size, i.e., {}." ,
73+ pdu.uci .nof_harq_ack ,
74+ pdu.uci .nof_csi_part1 ,
75+ max_uci_len));
6876 }
6977
7078 // CSI Part 2 size parameters must be compatible with the CSI Part 1 number of bits.
7179 if (!pdu.uci .csi_part2_size .is_valid (pdu.uci .nof_csi_part1 )) {
72- return false ;
80+ return make_unexpected (
81+ fmt::format (" CSI Part 1 UCI field length (i.e., {}) does not correspond with the CSI Part 2 (i.e., {})." ,
82+ pdu.uci .nof_csi_part1 ,
83+ pdu.uci .csi_part2_size ));
7384 }
7485
7586 // The limited buffer for rate matching size must not be zero.
7687 if (pdu.tbs_lbrm == 0_bytes) {
77- return false ;
88+ return make_unexpected ( " Invalid LBRM size (0 bytes). " ) ;
7889 }
7990
8091 // The number of OFDM symbols in the DM-RS mask must be equal to the number of OFDM symbols in a slot.
8192 if (pdu.dmrs_symbol_mask .size () != nof_symbols_slot) {
82- return false ;
93+ return make_unexpected (fmt::format (" The DM-RS symbol mask size (i.e., {}) must be the same as the number of "
94+ " symbols allocated to the transmission within the slot (i.e., {})." ,
95+ pdu.dmrs_symbol_mask .size (),
96+ nof_symbols_slot));
8397 }
8498
8599 // The number of symbols carrying DM-RS must be greater than zero.
86100 if (pdu.dmrs_symbol_mask .none ()) {
87- return false ;
101+ return make_unexpected ( " The number of OFDM symbols carrying DM-RS RE must be greater than zero. " ) ;
88102 }
89103
90104 // The index of the first OFDM symbol carrying DM-RS shall be equal to or greater than the first symbol allocated to
91105 // transmission.
92106 int first_dmrs_symbol_index = pdu.dmrs_symbol_mask .find_lowest (true );
93107 if (static_cast <unsigned >(first_dmrs_symbol_index) < pdu.start_symbol_index ) {
94- return false ;
108+ return make_unexpected (fmt::format (" The index of the first OFDM symbol carrying DM-RS (i.e., {}) must be equal to "
109+ " or greater than the first symbol allocated to transmission (i.e., {})." ,
110+ first_dmrs_symbol_index,
111+ pdu.start_symbol_index ));
95112 }
96113
97114 // The index of the last OFDM symbol carrying DM-RS shall not be larger than the last symbol allocated to
98115 // transmission.
99116 int last_dmrs_symbol_index = pdu.dmrs_symbol_mask .find_highest (true );
100117 if (static_cast <unsigned >(last_dmrs_symbol_index) >= (pdu.start_symbol_index + pdu.nof_symbols )) {
101- return false ;
118+ return make_unexpected (fmt::format (" The index of the last OFDM symbol carrying DM-RS (i.e., {}) must be less than "
119+ " or equal to the last symbol allocated to transmission (i.e., {})." ,
120+ last_dmrs_symbol_index,
121+ (pdu.start_symbol_index + pdu.nof_symbols - 1 )));
102122 }
103123
104124 // None of the occupied symbols must exceed the slot size.
105125 if (nof_symbols_slot < (pdu.start_symbol_index + pdu.nof_symbols )) {
106- return false ;
126+ return make_unexpected (fmt::format (" The occupied symbols (i.e., {}) exceed the slot size (i.e., {})." ,
127+ pdu.start_symbol_index + pdu.nof_symbols ,
128+ nof_symbols_slot));
107129 }
108130
109131 // Check if transform precoding is enabled.
110132 if (std::holds_alternative<pusch_processor::dmrs_configuration>(pdu.dmrs )) {
111- const pusch_processor::dmrs_configuration & dmrs_config = std::get<pusch_processor::dmrs_configuration>(pdu.dmrs );
133+ const auto & dmrs_config = std::get<pusch_processor::dmrs_configuration>(pdu.dmrs );
112134 // Only DM-RS Type 1 is supported.
113135 if (dmrs_config.dmrs != dmrs_type::TYPE1) {
114- return false ;
136+ return make_unexpected ( " Only DM-RS Type 1 is currently supported. " ) ;
115137 }
116138
117139 // Only two CDM groups without data is supported.
118140 if (dmrs_config.nof_cdm_groups_without_data != 2 ) {
119- return false ;
141+ return make_unexpected ( " Only two CDM groups without data are currently supported. " ) ;
120142 }
121143 } else {
122144 // Number of layers must be one.
123145 if (pdu.nof_tx_layers != 1 ) {
124- return false ;
146+ return make_unexpected ( " Transform precoding is only possible with one layer. " ) ;
125147 }
126148
127149 // Frequency allocation must be contiguous.
128150 if (!pdu.freq_alloc .is_contiguous ()) {
129- return false ;
151+ return make_unexpected ( " Transform precoding is only possible with contiguous allocations. " ) ;
130152 }
131153
132154 // Number of PRB must be valid.
133155 if (!is_transform_precoding_nof_prb_valid (pdu.freq_alloc .get_nof_rb ())) {
134- return false ;
156+ return make_unexpected ( " Transform precoding is only possible with a valid number of PRB. " ) ;
135157 }
136158 }
137159
138160 // DC position is outside the channel estimate dimensions.
139161 interval<unsigned > dc_position_range (0 , ce_dims.nof_prb * NRE);
140162 if (pdu.dc_position .has_value () && !dc_position_range.contains (pdu.dc_position .value ())) {
141- return false ;
163+ return make_unexpected (
164+ fmt::format (" DC position (i.e., {}) is out of range {}." , pdu.dc_position .value (), dc_position_range));
142165 }
143166
144- return true ;
167+ return default_success_t () ;
145168}
0 commit comments