| 169 | } |
| 170 | |
| 171 | static int |
| 172 | complete_distrib(uint8_t depth_lim, const uint32_t n, uint8_t rpd[], |
| 173 | uint32_t nrpd[]) |
| 174 | { |
| 175 | uint8_t depth; |
| 176 | uint32_t nr = 0; |
| 177 | uint8_t m = 0; |
| 178 | |
| 179 | /* |
| 180 | * complete number of routes for every depth |
| 181 | * that was configured with ratio |
| 182 | */ |
| 183 | for (depth = 0; depth <= depth_lim; depth++) { |
| 184 | if (rpd[depth] != 0) { |
| 185 | if (rpd[depth] == UINT8_MAX) |
| 186 | config.nb_routes_per_depth[depth] = |
| 187 | nrpd[depth]; |
| 188 | else |
| 189 | config.nb_routes_per_depth[depth] = |
| 190 | (n * rpd[depth]) / 100; |
| 191 | |
| 192 | nr += config.nb_routes_per_depth[depth]; |
| 193 | m++; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | if (nr > n) { |
| 198 | printf("Too much configured routes\n"); |
| 199 | return -1; |
| 200 | } |
| 201 | |
| 202 | /*complete number of routes for every unspecified depths*/ |
| 203 | for (depth = 0; depth <= depth_lim; depth++) { |
| 204 | if (rpd[depth] == 0) { |
| 205 | /*we don't need more than two /1 routes*/ |
| 206 | uint64_t max_routes_per_depth = |
| 207 | 1ULL << RTE_MIN(depth, 63); |
| 208 | uint32_t avg_routes_left = (n - nr) / |
| 209 | (depth_lim + 1 - m++); |
| 210 | config.nb_routes_per_depth[depth] = |
| 211 | RTE_MIN(max_routes_per_depth, avg_routes_left); |
| 212 | nr += config.nb_routes_per_depth[depth]; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | return 0; |
| 217 | } |
| 218 | |
| 219 | static int |
| 220 | parse_distrib(uint8_t depth_lim, const uint32_t n) |
no test coverage detected