const struct cls_rule *wild, int field_idx);
/* Converts the flow in 'flow' into a cls_rule in 'rule', with the given
- * 'wildcards' and 'priority'.
- *
- * Rules without wildcards always have the maximum priority 65535. */
+ * 'wildcards' and 'priority'.*/
void
cls_rule_from_flow(struct cls_rule *rule, const flow_t *flow,
- uint32_t wildcards, uint16_t priority)
+ uint32_t wildcards, unsigned int priority)
{
assert(flow->reserved == 0);
rule->flow = *flow;
flow_wildcards_init(&rule->wc, wildcards);
- rule->priority = rule->wc.wildcards ? priority : UINT16_MAX;
+ rule->priority = priority;
rule->table_idx = table_idx_from_wildcards(rule->wc.wildcards);
}
* 'priority'. */
void
cls_rule_from_match(struct cls_rule *rule, const struct ofp_match *match,
- uint16_t priority)
+ unsigned int priority)
{
uint32_t wildcards;
flow_from_match(&rule->flow, &wildcards, match);
void
cls_rule_print(const struct cls_rule *rule)
{
- printf("wildcards=%x priority=%d ", rule->wc.wildcards, rule->priority);
+ printf("wildcards=%x priority=%u ", rule->wc.wildcards, rule->priority);
flow_print(stdout, &rule->flow);
putc('\n', stdout);
}
struct cls_rule *
classifier_find_rule_exactly(const struct classifier *cls,
const flow_t *target, uint32_t wildcards,
- uint16_t priority)
+ unsigned int priority)
{
struct cls_bucket *bucket;
int table_idx;
uint32_t hash;
if (!wildcards) {
- /* Ignores 'priority', should we check that it is UINT16_MAX? */
+ /* Ignores 'priority'. */
return search_exact_table(cls, flow_hash(target, 0), target);
}
} node;
flow_t flow; /* All field values. */
struct flow_wildcards wc; /* Wildcards for fields. */
- uint16_t priority; /* Larger numbers are higher priorities. */
- unsigned short table_idx; /* Index into struct classifier 'tables'. */
+ unsigned int priority; /* Larger numbers are higher priorities. */
+ unsigned int table_idx; /* Index into struct classifier 'tables'. */
};
void cls_rule_from_flow(struct cls_rule *, const flow_t *, uint32_t wildcards,
- uint16_t priority);
+ unsigned int priority);
void cls_rule_from_match(struct cls_rule *, const struct ofp_match *,
- uint16_t priority);
+ unsigned int priority);
void cls_rule_print(const struct cls_rule *);
void cls_rule_moved(struct classifier *,
struct cls_rule *old, struct cls_rule *new);
struct cls_rule *classifier_find_rule_exactly(const struct classifier *,
const flow_t *target,
uint32_t wildcards,
- uint16_t priority);
+ unsigned int priority);
#endif /* classifier.h */
{
size_t i;
- assert(rule->cls_rule.wc.wildcards
- || rule->cls_rule.priority == UINT16_MAX);
+ assert(rule->cls_rule.wc.wildcards || rule->cls_rule.priority == UINT_MAX);
for (i = 0; i < tcls->n_rules; i++) {
const struct cls_rule *pos = &tcls->rules[i]->cls_rule;
if (pos->priority == rule->cls_rule.priority
}
static struct test_rule *
-make_rule(int wc_fields, int priority, int value_pat)
+make_rule(int wc_fields, unsigned int priority, int value_pat)
{
const struct cls_field *f;
struct test_rule *rule;
}
static void
-shuffle(int *p, size_t n)
+shuffle(unsigned int *p, size_t n)
{
for (; n > 1; n--, p++) {
- int *q = &p[rand() % n];
- int tmp = *p;
+ unsigned int *q = &p[rand() % n];
+ unsigned int tmp = *p;
*p = *q;
*q = tmp;
}
struct test_rule *displaced_rule;
struct classifier cls;
struct tcls tcls;
- int pri1, pri2;
+ unsigned int pri1, pri2;
int wcf1, wcf2;
if (table != CLS_F_IDX_EXACT) {
} else {
/* This classifier always puts exact-match rules at
* maximum priority. */
- pri1 = pri2 = UINT16_MAX;
+ pri1 = pri2 = UINT_MAX;
/* No wildcard fields. */
wcf1 = wcf2 = 0;
struct test_rule *rule2, *tcls_rule2;
struct classifier cls;
struct tcls tcls;
- int pri1, pri2;
+ unsigned int pri1, pri2;
int wcf1, wcf2;
int value_mask, value_pat1, value_pat2;
int i;
struct test_rule *rule2, *tcls_rule2;
struct classifier cls;
struct tcls tcls;
- int pri1, pri2;
+ unsigned int pri1, pri2;
int wcf1, wcf2;
/* We must use unique priorities in this test because the
for (iteration = 0; iteration < 3; iteration++) {
for (table = 0; table <= CLS_N_FIELDS; table++) {
- int priorities[MAX_RULES];
+ unsigned int priorities[MAX_RULES];
struct classifier cls;
struct tcls tcls;
int i;
for (i = 0; i < MAX_RULES; i++) {
struct test_rule *rule;
- int priority = priorities[i];
+ unsigned int priority = priorities[i];
int wcf;
wcf = random_wcf_in_table(table, priority);
for (iteration = 0; iteration < 3; iteration++) {
for (table = 0; table < CLS_N_FIELDS; table++) {
- int priorities[MAX_RULES];
+ unsigned int priorities[MAX_RULES];
struct classifier cls;
struct tcls tcls;
int i;
for (i = 0; i < MAX_RULES; i++) {
struct test_rule *rule;
- int priority = priorities[i];
+ unsigned int priority = priorities[i];
int wcf;
wcf = random_wcf_in_table(table, priority);
int iteration;
for (iteration = 0; iteration < 30; iteration++) {
- int priorities[MAX_RULES];
+ unsigned int priorities[MAX_RULES];
struct classifier cls;
struct tcls tcls;
int i;
for (i = 0; i < MAX_RULES; i++) {
struct test_rule *rule;
- int priority = priorities[i];
+ unsigned int priority = priorities[i];
int table = rand() % (CLS_N_FIELDS + 1);
int wcf = random_wcf_in_table(table, rand());
int value_pat = rand() & ((1u << CLS_N_FIELDS) - 1);