case MFF_METADATA:
return !wc->metadata_mask;
-#if FLOW_N_REGS > 0
- case MFF_REG0:
-#endif
-#if FLOW_N_REGS > 1
- case MFF_REG1:
-#endif
-#if FLOW_N_REGS > 2
- case MFF_REG2:
-#endif
-#if FLOW_N_REGS > 3
- case MFF_REG3:
-#endif
-#if FLOW_N_REGS > 4
- case MFF_REG4:
-#endif
-#if FLOW_N_REGS > 5
- case MFF_REG5:
-#endif
-#if FLOW_N_REGS > 6
- case MFF_REG6:
-#endif
-#if FLOW_N_REGS > 7
- case MFF_REG7:
-#endif
-#if FLOW_N_REGS > 8
-#error
-#endif
+ CASE_MFF_REGS:
return !wc->reg_masks[mf->id - MFF_REG0];
case MFF_ETH_SRC:
mask->be64 = wc->metadata_mask;
break;
-#if FLOW_N_REGS > 0
- case MFF_REG0:
-#endif
-#if FLOW_N_REGS > 1
- case MFF_REG1:
-#endif
-#if FLOW_N_REGS > 2
- case MFF_REG2:
-#endif
-#if FLOW_N_REGS > 3
- case MFF_REG3:
-#endif
-#if FLOW_N_REGS > 4
- case MFF_REG4:
-#endif
-#if FLOW_N_REGS > 5
- case MFF_REG5:
-#endif
-#if FLOW_N_REGS > 6
- case MFF_REG6:
-#endif
-#if FLOW_N_REGS > 7
- case MFF_REG7:
-#endif
-#if FLOW_N_REGS > 8
-#error
-#endif
+ CASE_MFF_REGS:
mask->be32 = htonl(wc->reg_masks[mf->id - MFF_REG0]);
break;
case MFF_TUN_ID:
case MFF_METADATA:
case MFF_IN_PORT:
-#if FLOW_N_REGS > 0
- case MFF_REG0:
-#endif
-#if FLOW_N_REGS > 1
- case MFF_REG1:
-#endif
-#if FLOW_N_REGS > 2
- case MFF_REG2:
-#endif
-#if FLOW_N_REGS > 3
- case MFF_REG3:
-#endif
-#if FLOW_N_REGS > 4
- case MFF_REG4:
-#endif
-#if FLOW_N_REGS > 5
- case MFF_REG5:
-#endif
-#if FLOW_N_REGS > 6
- case MFF_REG6:
-#endif
-#if FLOW_N_REGS > 7
- case MFF_REG7:
-#endif
-#if FLOW_N_REGS > 8
-#error
-#endif
+ CASE_MFF_REGS:
case MFF_ETH_SRC:
case MFF_ETH_DST:
case MFF_ETH_TYPE:
value->be16 = htons(flow->in_port);
break;
-#if FLOW_N_REGS > 0
- case MFF_REG0:
-#endif
-#if FLOW_N_REGS > 1
- case MFF_REG1:
-#endif
-#if FLOW_N_REGS > 2
- case MFF_REG2:
-#endif
-#if FLOW_N_REGS > 3
- case MFF_REG3:
-#endif
-#if FLOW_N_REGS > 4
- case MFF_REG4:
-#endif
-#if FLOW_N_REGS > 5
- case MFF_REG5:
-#endif
-#if FLOW_N_REGS > 6
- case MFF_REG6:
-#endif
-#if FLOW_N_REGS > 7
- case MFF_REG7:
-#endif
-#if FLOW_N_REGS > 8
-#error
-#endif
+ CASE_MFF_REGS:
value->be32 = htonl(flow->regs[mf->id - MFF_REG0]);
break;
cls_rule_set_in_port(rule, ntohs(value->be16));
break;
-#if FLOW_N_REGS > 0
- case MFF_REG0:
-#endif
-#if FLOW_N_REGS > 1
- case MFF_REG1:
-#endif
-#if FLOW_N_REGS > 2
- case MFF_REG2:
-#endif
-#if FLOW_N_REGS > 3
- case MFF_REG3:
-#endif
-#if FLOW_N_REGS > 4
- case MFF_REG4:
-#endif
-#if FLOW_N_REGS > 5
- case MFF_REG5:
-#endif
-#if FLOW_N_REGS > 6
- case MFF_REG6:
-#endif
-#if FLOW_N_REGS > 7
- case MFF_REG7:
-#endif
-#if FLOW_N_REGS > 8
-#error
-#endif
-#if FLOW_N_REGS > 0
+ CASE_MFF_REGS:
cls_rule_set_reg(rule, mf->id - MFF_REG0, ntohl(value->be32));
break;
-#endif
case MFF_ETH_SRC:
cls_rule_set_dl_src(rule, value->mac);
flow->in_port = ntohs(value->be16);
break;
-#if FLOW_N_REGS > 0
- case MFF_REG0:
-#endif
-#if FLOW_N_REGS > 1
- case MFF_REG1:
-#endif
-#if FLOW_N_REGS > 2
- case MFF_REG2:
-#endif
-#if FLOW_N_REGS > 3
- case MFF_REG3:
-#endif
-#if FLOW_N_REGS > 4
- case MFF_REG4:
-#endif
-#if FLOW_N_REGS > 5
- case MFF_REG5:
-#endif
-#if FLOW_N_REGS > 6
- case MFF_REG6:
-#endif
-#if FLOW_N_REGS > 7
- case MFF_REG7:
-#endif
-#if FLOW_N_REGS > 8
-#error
-#endif
-#if FLOW_N_REGS > 0
+ CASE_MFF_REGS:
flow->regs[mf->id - MFF_REG0] = ntohl(value->be32);
break;
-#endif
case MFF_ETH_SRC:
memcpy(flow->dl_src, value->mac, ETH_ADDR_LEN);
rule->flow.in_port = 0;
break;
-#if FLOW_N_REGS > 0
- case MFF_REG0:
- cls_rule_set_reg_masked(rule, 0, 0, 0);
- break;
-#endif
-#if FLOW_N_REGS > 1
- case MFF_REG1:
- cls_rule_set_reg_masked(rule, 1, 0, 0);
- break;
-#endif
-#if FLOW_N_REGS > 2
- case MFF_REG2:
- cls_rule_set_reg_masked(rule, 2, 0, 0);
- break;
-#endif
-#if FLOW_N_REGS > 3
- case MFF_REG3:
- cls_rule_set_reg_masked(rule, 3, 0, 0);
- break;
-#endif
-#if FLOW_N_REGS > 4
- case MFF_REG4:
- cls_rule_set_reg_masked(rule, 4, 0, 0);
- break;
-#endif
-#if FLOW_N_REGS > 5
- case MFF_REG5:
- cls_rule_set_reg_masked(rule, 5, 0, 0);
- break;
-#endif
-#if FLOW_N_REGS > 6
- case MFF_REG6:
- cls_rule_set_reg_masked(rule, 6, 0, 0);
+ CASE_MFF_REGS:
+ cls_rule_set_reg_masked(rule, mf->id - MFF_REG0, 0, 0);
break;
-#endif
-#if FLOW_N_REGS > 7
- case MFF_REG7:
- cls_rule_set_reg_masked(rule, 7, 0, 0);
- break;
-#endif
-#if FLOW_N_REGS > 8
-#error
-#endif
case MFF_ETH_SRC:
memset(rule->flow.dl_src, 0, ETH_ADDR_LEN);
cls_rule_set_metadata_masked(rule, value->be64, mask->be64);
break;
-#if FLOW_N_REGS > 0
- case MFF_REG0:
-#endif
-#if FLOW_N_REGS > 1
- case MFF_REG1:
-#endif
-#if FLOW_N_REGS > 2
- case MFF_REG2:
-#endif
-#if FLOW_N_REGS > 3
- case MFF_REG3:
-#endif
-#if FLOW_N_REGS > 4
- case MFF_REG4:
-#endif
-#if FLOW_N_REGS > 5
- case MFF_REG5:
-#endif
-#if FLOW_N_REGS > 6
- case MFF_REG6:
-#endif
-#if FLOW_N_REGS > 7
- case MFF_REG7:
-#endif
-#if FLOW_N_REGS > 8
-#error
-#endif
+ CASE_MFF_REGS:
cls_rule_set_reg_masked(rule, mf->id - MFF_REG0,
ntohl(value->be32), ntohl(mask->be32));
break;
case MFF_TUN_ID:
case MFF_METADATA:
case MFF_IN_PORT:
-#if FLOW_N_REGS > 0
- case MFF_REG0:
-#endif
-#if FLOW_N_REGS > 1
- case MFF_REG1:
-#endif
-#if FLOW_N_REGS > 2
- case MFF_REG2:
-#endif
-#if FLOW_N_REGS > 3
- case MFF_REG3:
-#endif
-#if FLOW_N_REGS > 4
- case MFF_REG4:
-#endif
-#if FLOW_N_REGS > 5
- case MFF_REG5:
-#endif
-#if FLOW_N_REGS > 6
- case MFF_REG6:
-#endif
-#if FLOW_N_REGS > 7
- case MFF_REG7:
-#endif
-#if FLOW_N_REGS > 8
-#error
-#endif
+ CASE_MFF_REGS:
case MFF_ETH_SRC:
case MFF_ETH_DST:
case MFF_ETH_TYPE:
#endif
#if FLOW_N_REGS > 7
MFF_REG7, /* be32 */
-#endif
-#if FLOW_N_REGS > 8
-#error
#endif
/* L2. */
MFF_N_IDS
};
+/* Use this macro as CASE_MFF_REGS: in a switch statement to choose all of the
+ * MFF_REGx cases. */
+#if FLOW_N_REGS == 1
+# define CASE_MFF_REGS \
+ case MFF_REG0
+#elif FLOW_N_REGS == 2
+# define CASE_MFF_REGS \
+ case MFF_REG0: case MFF_REG1
+#elif FLOW_N_REGS == 3
+# define CASE_MFF_REGS \
+ case MFF_REG0: case MFF_REG1: case MFF_REG2
+#elif FLOW_N_REGS == 4
+# define CASE_MFF_REGS \
+ case MFF_REG0: case MFF_REG1: case MFF_REG2: case MFF_REG3
+#elif FLOW_N_REGS == 5
+# define CASE_MFF_REGS \
+ case MFF_REG0: case MFF_REG1: case MFF_REG2: case MFF_REG3: \
+ case MFF_REG4
+#elif FLOW_N_REGS == 6
+# define CASE_MFF_REGS \
+ case MFF_REG0: case MFF_REG1: case MFF_REG2: case MFF_REG3: \
+ case MFF_REG4: case MFF_REG5
+#elif FLOW_N_REGS == 7
+# define CASE_MFF_REGS \
+ case MFF_REG0: case MFF_REG1: case MFF_REG2: case MFF_REG3: \
+ case MFF_REG4: case MFF_REG5: case MFF_REG6
+#elif FLOW_N_REGS == 8
+# define CASE_MFF_REGS \
+ case MFF_REG0: case MFF_REG1: case MFF_REG2: case MFF_REG3: \
+ case MFF_REG4: case MFF_REG5: case MFF_REG6: case MFF_REG7
+#else
+# error
+#endif
+
/* Prerequisites for matching a field.
*
* A field may only be matched if the correct lower-level protocols are also