From 87542e21fa88f0e566fdff023410a33f11d164ba Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 17 Nov 2010 10:07:48 -0800 Subject: [PATCH] classifier: New cls_rule functions for setting registers and tun_id. --- lib/classifier.c | 22 ++++++++++++++++++++++ lib/classifier.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/lib/classifier.c b/lib/classifier.c index 52a77d71..ec943855 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -111,6 +111,28 @@ cls_rule_zero_wildcarded_fields(struct cls_rule *rule) zero_wildcards(&rule->flow, &rule->wc); } +void +cls_rule_set_reg(struct cls_rule *rule, unsigned int reg_idx, uint32_t value) +{ + cls_rule_set_reg_masked(rule, reg_idx, value, UINT32_MAX); +} + +void +cls_rule_set_reg_masked(struct cls_rule *rule, unsigned int reg_idx, + uint32_t value, uint32_t mask) +{ + assert(reg_idx < FLOW_N_REGS); + flow_wildcards_set_reg_mask(&rule->wc, reg_idx, mask); + rule->flow.regs[reg_idx] = value & mask; +} + +void +cls_rule_set_tun_id(struct cls_rule *rule, ovs_be32 tun_id) +{ + rule->wc.wildcards &= ~FWW_TUN_ID; + rule->flow.tun_id = tun_id; +} + void cls_rule_set_in_port(struct cls_rule *rule, uint16_t odp_port) { diff --git a/lib/classifier.h b/lib/classifier.h index 2dc0bdf9..5629fc02 100644 --- a/lib/classifier.h +++ b/lib/classifier.h @@ -74,6 +74,10 @@ void cls_rule_init_catchall(struct cls_rule *, unsigned int priority); void cls_rule_zero_wildcarded_fields(struct cls_rule *); +void cls_rule_set_reg(struct cls_rule *, unsigned int reg_idx, uint32_t value); +void cls_rule_set_reg_masked(struct cls_rule *, unsigned int reg_idx, + uint32_t value, uint32_t mask); +void cls_rule_set_tun_id(struct cls_rule *, ovs_be32 tun_id); void cls_rule_set_in_port(struct cls_rule *, uint16_t odp_port); void cls_rule_set_dl_type(struct cls_rule *, ovs_be16); void cls_rule_set_dl_src(struct cls_rule *, const uint8_t[6]); -- 2.30.2