* Test ACL lookup (selected alg). */
| 279 | * Test ACL lookup (selected alg). |
| 280 | */ |
| 281 | static int |
| 282 | test_classify_alg(struct rte_acl_ctx *acx, struct ipv4_7tuple test_data[], |
| 283 | const uint8_t *data[], size_t dim, enum rte_acl_classify_alg alg) |
| 284 | { |
| 285 | int32_t ret; |
| 286 | uint32_t i, result, count; |
| 287 | uint32_t results[dim * RTE_ACL_MAX_CATEGORIES]; |
| 288 | |
| 289 | /* set given classify alg, skip test if alg is not supported */ |
| 290 | ret = rte_acl_set_ctx_classify(acx, alg); |
| 291 | if (ret != 0) |
| 292 | return (ret == -ENOTSUP) ? 0 : ret; |
| 293 | |
| 294 | /** |
| 295 | * these will run quite a few times, it's necessary to test code paths |
| 296 | * from num=0 to num>8 |
| 297 | */ |
| 298 | for (count = 0; count <= dim; count++) { |
| 299 | ret = rte_acl_classify(acx, data, results, |
| 300 | count, RTE_ACL_MAX_CATEGORIES); |
| 301 | if (ret != 0) { |
| 302 | printf("Line %i: classify(alg=%d) failed!\n", |
| 303 | __LINE__, alg); |
| 304 | return ret; |
| 305 | } |
| 306 | |
| 307 | /* check if we allow everything we should allow */ |
| 308 | for (i = 0; i < count; i++) { |
| 309 | result = |
| 310 | results[i * RTE_ACL_MAX_CATEGORIES + ACL_ALLOW]; |
| 311 | if (result != test_data[i].allow) { |
| 312 | printf("Line %i: Error in allow results at %i " |
| 313 | "(expected %"PRIu32" got %"PRIu32")!\n", |
| 314 | __LINE__, i, test_data[i].allow, |
| 315 | result); |
| 316 | return -EINVAL; |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | /* check if we deny everything we should deny */ |
| 321 | for (i = 0; i < count; i++) { |
| 322 | result = results[i * RTE_ACL_MAX_CATEGORIES + ACL_DENY]; |
| 323 | if (result != test_data[i].deny) { |
| 324 | printf("Line %i: Error in deny results at %i " |
| 325 | "(expected %"PRIu32" got %"PRIu32")!\n", |
| 326 | __LINE__, i, test_data[i].deny, |
| 327 | result); |
| 328 | return -EINVAL; |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | /* restore default classify alg */ |
| 334 | return rte_acl_set_ctx_classify(acx, RTE_ACL_CLASSIFY_DEFAULT); |
| 335 | } |
| 336 | |
| 337 | /* |
| 338 | * Test ACL lookup (all possible methods). |
no test coverage detected