| 1659 | } |
| 1660 | |
| 1661 | static int |
| 1662 | test_u32_range(void) |
| 1663 | { |
| 1664 | int32_t rc; |
| 1665 | uint32_t i, k, max, min; |
| 1666 | struct rte_acl_ctx *acx; |
| 1667 | struct acl_ipv4vlan_rule r; |
| 1668 | struct ipv4_7tuple test_data[64]; |
| 1669 | |
| 1670 | acx = rte_acl_create(&acl_param); |
| 1671 | if (acx == NULL) { |
| 1672 | printf("%s#%i: Error creating ACL context!\n", |
| 1673 | __func__, __LINE__); |
| 1674 | return -1; |
| 1675 | } |
| 1676 | |
| 1677 | for (i = 0; i != RTE_DIM(acl_u32_range_test_rules); i++) { |
| 1678 | convert_rule(&acl_u32_range_test_rules[i], &r); |
| 1679 | rc = rte_acl_add_rules(acx, (struct rte_acl_rule *)&r, 1); |
| 1680 | if (rc != 0) { |
| 1681 | printf("%s#%i: Adding rule to ACL context " |
| 1682 | "failed with error code: %d\n", |
| 1683 | __func__, __LINE__, rc); |
| 1684 | rte_acl_free(acx); |
| 1685 | return rc; |
| 1686 | } |
| 1687 | } |
| 1688 | |
| 1689 | rc = build_convert_rules(acx, convert_config_2, 0); |
| 1690 | if (rc != 0) { |
| 1691 | printf("%s#%i Error @ build_convert_rules!\n", |
| 1692 | __func__, __LINE__); |
| 1693 | rte_acl_free(acx); |
| 1694 | return rc; |
| 1695 | } |
| 1696 | |
| 1697 | max = get_u32_range_max(); |
| 1698 | min = get_u32_range_min(); |
| 1699 | |
| 1700 | max = RTE_MAX(max, max + 1); |
| 1701 | min = RTE_MIN(min, min - 1); |
| 1702 | |
| 1703 | printf("%s#%d starting range test from %u to %u\n", |
| 1704 | __func__, __LINE__, min, max); |
| 1705 | |
| 1706 | for (i = min; i <= max; i += k) { |
| 1707 | |
| 1708 | k = RTE_MIN(max - i + 1, RTE_DIM(test_data)); |
| 1709 | |
| 1710 | memset(test_data, 0, sizeof(test_data)); |
| 1711 | fill_u32_range_data(test_data, i, k); |
| 1712 | |
| 1713 | rc = test_classify_run(acx, test_data, k); |
| 1714 | if (rc != 0) { |
| 1715 | printf("%s#%d failed at [%u, %u) interval\n", |
| 1716 | __func__, __LINE__, i, i + k); |
| 1717 | break; |
| 1718 | } |
no test coverage detected