+static uint32_t
+get_u32_range_max(void)
+{
+ uint32_t i, max;
+
+ max = 0;
+ for (i = 0; i != RTE_DIM(acl_u32_range_test_rules); i++)
+ max = RTE_MAX(max, acl_u32_range_test_rules[i].src_mask_len);
+ return max;
+}
+
+static uint32_t
+get_u32_range_min(void)
+{
+ uint32_t i, min;
+
+ min = UINT32_MAX;
+ for (i = 0; i != RTE_DIM(acl_u32_range_test_rules); i++)
+ min = RTE_MIN(min, acl_u32_range_test_rules[i].src_addr);
+ return min;
+}
+
+static const struct rte_acl_ipv4vlan_rule *
+find_u32_range_rule(uint32_t val)
+{
+ uint32_t i;
+
+ for (i = 0; i != RTE_DIM(acl_u32_range_test_rules); i++) {
+ if (val >= acl_u32_range_test_rules[i].src_addr &&
+ val <= acl_u32_range_test_rules[i].src_mask_len)
+ return acl_u32_range_test_rules + i;
+ }
+ return NULL;
+}
+
+static void
+fill_u32_range_data(struct ipv4_7tuple tdata[], uint32_t start, uint32_t num)
+{
+ uint32_t i;
+ const struct rte_acl_ipv4vlan_rule *r;
+
+ for (i = 0; i != num; i++) {
+ tdata[i].ip_src = start + i;
+ r = find_u32_range_rule(start + i);
+ if (r != NULL)
+ tdata[i].allow = r->data.userdata;
+ }
+}
+
+static int
+test_u32_range(void)
+{
+ int32_t rc;
+ uint32_t i, k, max, min;
+ struct rte_acl_ctx *acx;
+ struct acl_ipv4vlan_rule r;
+ struct ipv4_7tuple test_data[64];
+
+ acx = rte_acl_create(&acl_param);
+ if (acx == NULL) {
+ printf("%s#%i: Error creating ACL context!\n",
+ __func__, __LINE__);
+ return -1;
+ }
+
+ for (i = 0; i != RTE_DIM(acl_u32_range_test_rules); i++) {
+ convert_rule(&acl_u32_range_test_rules[i], &r);
+ rc = rte_acl_add_rules(acx, (struct rte_acl_rule *)&r, 1);
+ if (rc != 0) {
+ printf("%s#%i: Adding rule to ACL context "
+ "failed with error code: %d\n",
+ __func__, __LINE__, rc);
+ rte_acl_free(acx);
+ return rc;
+ }
+ }
+
+ rc = build_convert_rules(acx, convert_config_2, 0);
+ if (rc != 0) {
+ printf("%s#%i Error @ build_convert_rules!\n",
+ __func__, __LINE__);
+ rte_acl_free(acx);
+ return rc;
+ }
+
+ max = get_u32_range_max();
+ min = get_u32_range_min();
+
+ max = RTE_MAX(max, max + 1);
+ min = RTE_MIN(min, min - 1);
+
+ printf("%s#%d starting range test from %u to %u\n",
+ __func__, __LINE__, min, max);
+
+ for (i = min; i <= max; i += k) {
+
+ k = RTE_MIN(max - i + 1, RTE_DIM(test_data));
+
+ memset(test_data, 0, sizeof(test_data));
+ fill_u32_range_data(test_data, i, k);
+
+ rc = test_classify_run(acx, test_data, k);
+ if (rc != 0) {
+ printf("%s#%d failed at [%u, %u) interval\n",
+ __func__, __LINE__, i, i + k);
+ break;
+ }
+ }
+
+ rte_acl_free(acx);
+ return rc;
+}
+