@@ -894,10 +894,10 @@ enum OVS_PACKED_ENUM mf_field_id {
/* "xreg<N>".
*
* OpenFlow 1.5 ``extended register". Each extended register
- * overlays two of the Nicira extension 32-bit registers: xreg0 overlays
- * reg0 and reg1, with reg0 supplying the most-significant bits of xreg0
- * and reg1 the least-significant. xreg1 similarly overlays reg2 and reg3,
- * and so on.
+ * overlays two of the Open vSwitch extension 32-bit registers:
+ * xreg0 overlays reg0 and reg1, with reg0 supplying the
+ * most-significant bits of xreg0 and reg1 the least-significant.
+ * xreg1 similarly overlays reg2 and reg3, and so on.
*
* These registers were introduced in OpenFlow 1.5, but EXT-244 in the ONF
* JIRA also publishes them as a (draft) OpenFlow extension to OpenFlow
@@ -927,8 +927,8 @@ enum OVS_PACKED_ENUM mf_field_id {
/* "xxreg<N>".
*
* ``extended-extended register". Each of these extended registers
- * overlays four of the Nicira extension 32-bit registers: xxreg0
- * overlays reg0 through reg3, with reg0 supplying the
+ * overlays four of the Open vSwitch extension 32-bit registers:
+ * xxreg0 overlays reg0 through reg3, with reg0 supplying the
* most-significant bits of xxreg0 and reg3 the least-significant.
* xxreg1 similarly overlays reg4 and reg7.
*
@@ -103,6 +103,7 @@ typedef union {
/* MSVC2015 doesn't support designated initializers when compiling C++,
* and doesn't support ternary operators with non-designated initializers.
* So we use these static definitions rather than using initializer macros. */
+static const ovs_u128 OVS_U128_ZERO = { { 0, 0, 0, 0 } };
static const ovs_u128 OVS_U128_MAX = { { UINT32_MAX, UINT32_MAX,
UINT32_MAX, UINT32_MAX } };
static const ovs_be128 OVS_BE128_MAX OVS_UNUSED = { { OVS_BE32_MAX, OVS_BE32_MA
@@ -124,10 +124,10 @@ flow_get_xxreg(const struct flow *flow, int idx)
{
ovs_u128 value;
- value.u32[3] = flow->regs[idx * 4];
- value.u32[2] = flow->regs[idx * 4 + 1];
- value.u32[1] = flow->regs[idx * 4 + 2];
- value.u32[0] = flow->regs[idx * 4 + 3];
+ value.u64.hi = (uint64_t) flow->regs[idx * 4] << 32;
+ value.u64.hi |= flow->regs[idx * 4 + 1];
+ value.u64.lo = (uint64_t) flow->regs[idx * 4 + 2] << 32;
+ value.u64.lo |= flow->regs[idx * 4 + 3];
return value;
}
@@ -135,10 +135,10 @@ flow_get_xxreg(const struct flow *flow, int idx)
static inline void
flow_set_xxreg(struct flow *flow, int idx, ovs_u128 value)
{
- flow->regs[idx * 4] = value.u32[3];
- flow->regs[idx * 4 + 1] = value.u32[2];
- flow->regs[idx * 4 + 2] = value.u32[1];
- flow->regs[idx * 4 + 3] = value.u32[0];
+ flow->regs[idx * 4] = value.u64.hi >> 32;
+ flow->regs[idx * 4 + 1] = value.u64.hi;
+ flow->regs[idx * 4 + 2] = value.u64.lo >> 32;
+ flow->regs[idx * 4 + 3] = value.u64.lo;
}
static inline int
@@ -1616,8 +1616,8 @@ mf_set_wild(const struct mf_field *mf, struct match *match
break;
CASE_MFF_XXREGS: {
- ovs_u128 u_zero = {.u64.hi = 0, .u64.lo = 0};
- match_set_xxreg_masked(match, mf->id - MFF_XXREG0, u_zero, u_zero);
+ match_set_xxreg_masked(match, mf->id - MFF_XXREG0, OVS_U128_ZERO,
+ OVS_U128_ZERO);
break;
}