|
9 | 9 | */ |
10 | 10 |
|
11 | 11 | #include "../../../lib/phy/support/resource_grid_impl.h" |
| 12 | +#include "helpers.h" |
12 | 13 | #include "srsran/adt/bounded_bitset.h" |
13 | 14 | #include "srsran/adt/circular_map.h" |
14 | 15 | #include "srsran/ofh/ecpri/ecpri_constants.h" |
@@ -102,39 +103,6 @@ class dummy_ru_error_notifier : public ru_error_notifier |
102 | 103 |
|
103 | 104 | static test_parameters test_params; |
104 | 105 |
|
105 | | -/// Helper function to convert array of port indexes to string. |
106 | | -static std::string port_ids_to_str(span<unsigned> ports) |
107 | | -{ |
108 | | - std::stringstream ss; |
109 | | - ss << "{"; |
110 | | - for (unsigned i = 0, e = ports.size() - 1; i != e; ++i) { |
111 | | - ss << ports[i] << ", "; |
112 | | - } |
113 | | - ss << ports[ports.size() - 1] << "}"; |
114 | | - return ss.str(); |
115 | | -} |
116 | | - |
117 | | -/// Helper function to parse list of ports provided as a string. |
118 | | -static std::vector<unsigned> parse_port_id(const std::string& port_id_str) |
119 | | -{ |
120 | | - std::vector<unsigned> port_ids; |
121 | | - size_t start_pos = port_id_str.find('{'); |
122 | | - size_t end_pos = port_id_str.find('}'); |
123 | | - if (start_pos == std::string::npos || end_pos == std::string::npos) { |
124 | | - return port_ids; |
125 | | - } |
126 | | - std::string ports_comma_separated = port_id_str.substr(start_pos + 1, end_pos - 1); |
127 | | - std::stringstream ss(ports_comma_separated); |
128 | | - int port; |
129 | | - while (ss >> port) { |
130 | | - port_ids.push_back(port); |
131 | | - if (ss.peek() == ',' || ss.peek() == ' ') { |
132 | | - ss.ignore(); |
133 | | - } |
134 | | - } |
135 | | - return port_ids; |
136 | | -} |
137 | | - |
138 | 106 | /// Prints usage information of the app. |
139 | 107 | static void usage(const char* prog) |
140 | 108 | { |
@@ -169,55 +137,6 @@ static void usage(const char* prog) |
169 | 137 | fmt::print("\t-h Show this message\n"); |
170 | 138 | } |
171 | 139 |
|
172 | | -/// Validates the bandwidth argument provided as a user input. |
173 | | -static bool validate_bw(unsigned bandwidth) |
174 | | -{ |
175 | | - switch (bandwidth) { |
176 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz5): |
177 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz5; |
178 | | - break; |
179 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz10): |
180 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz10; |
181 | | - break; |
182 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz15): |
183 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz15; |
184 | | - break; |
185 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz20): |
186 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz20; |
187 | | - break; |
188 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz25): |
189 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz25; |
190 | | - break; |
191 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz30): |
192 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz30; |
193 | | - break; |
194 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz40): |
195 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz40; |
196 | | - break; |
197 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz50): |
198 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz50; |
199 | | - break; |
200 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz60): |
201 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz60; |
202 | | - break; |
203 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz70): |
204 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz70; |
205 | | - break; |
206 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz80): |
207 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz80; |
208 | | - break; |
209 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz90): |
210 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz90; |
211 | | - break; |
212 | | - case bs_channel_bandwidth_to_MHz(bs_channel_bandwidth_fr1::MHz100): |
213 | | - test_params.bw = bs_channel_bandwidth_fr1::MHz100; |
214 | | - break; |
215 | | - default: |
216 | | - return false; |
217 | | - } |
218 | | - return true; |
219 | | -} |
220 | | - |
221 | 140 | /// Parses arguments of the app. |
222 | 141 | static void parse_args(int argc, char** argv) |
223 | 142 | { |
@@ -255,9 +174,11 @@ static void parse_args(int argc, char** argv) |
255 | 174 | break; |
256 | 175 | case 'w': |
257 | 176 | if (optarg != nullptr) { |
258 | | - if (!validate_bw(std::strtol(optarg, nullptr, 10))) { |
| 177 | + if (!is_valid_bw(std::strtol(optarg, nullptr, 10))) { |
259 | 178 | fmt::print("Invalid bandwidth\n"); |
260 | 179 | invalid_arg = true; |
| 180 | + } else { |
| 181 | + test_params.bw = MHz_to_bs_channel_bandwidth(std::strtol(optarg, nullptr, 10)); |
261 | 182 | } |
262 | 183 | } |
263 | 184 | break; |
|
0 commit comments