diff options
author | Jarno Rajahalme <jarno@ovn.org> | 2016-08-31 08:43:48 -0700 |
---|---|---|
committer | Jarno Rajahalme <jarno@ovn.org> | 2016-08-31 08:43:48 -0700 |
commit | 128684a6613a4f97c12a35b686c658c189238bfa (patch) | |
tree | 05a70572e75d7f62197aba3e99aefc2b6fe7b7a0 /include | |
parent | dfe191d5faa60d34a64e3bd1040fd6fa02b4889c (diff) | |
download | openvswitch-128684a6613a4f97c12a35b686c658c189238bfa.tar.gz |
ofp-actions: Waste less memory in set field and load actions.
Change the value and mask to be added to the end of the set field
action without any extra bytes, exept for the usual ofp-actions
padding to 8 bytes. Together with some structure member packing this
saves on average about to 256 bytes for each set field and load action
(as set field internal representation is also used for load actions).
On a specific production data set each flow entry uses on average
about 4.2 load or set field actions. This means that with this patch
an average of more than 1kb can be saved for each flow with such a
flow table.
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/openvswitch/ofp-actions.h | 34 | ||||
-rw-r--r-- | include/ovn/actions.h | 8 |
2 files changed, 28 insertions, 14 deletions
diff --git a/include/openvswitch/ofp-actions.h b/include/openvswitch/ofp-actions.h index b30b270e7..e92b41398 100644 --- a/include/openvswitch/ofp-actions.h +++ b/include/openvswitch/ofp-actions.h @@ -479,12 +479,23 @@ struct ofpact_stack { * * Used for NXAST_REG_LOAD and OFPAT12_SET_FIELD. */ struct ofpact_set_field { - struct ofpact ofpact; - const struct mf_field *field; - bool flow_has_vlan; /* VLAN present at action validation time. */ - union mf_value value; - union mf_value mask; + OFPACT_PADDED_MEMBERS( + struct ofpact ofpact; + bool flow_has_vlan; /* VLAN present at action validation time. */ + const struct mf_field *field; + ); + union mf_value value[]; /* Significant value bytes followed by + * significant mask bytes. */ }; +BUILD_ASSERT_DECL(offsetof(struct ofpact_set_field, value) + % OFPACT_ALIGNTO == 0); +BUILD_ASSERT_DECL(offsetof(struct ofpact_set_field, value) + == sizeof(struct ofpact_set_field)); + +/* Use macro to not have to deal with constness. */ +#define ofpact_set_field_mask(SF) \ + ALIGNED_CAST(union mf_value *, \ + (uint8_t *)(SF)->value + (SF)->field->n_bytes) /* OFPACT_PUSH_VLAN/MPLS/PBB * @@ -1058,7 +1069,18 @@ OFPACTS #undef OFPACT /* Additional functions for composing ofpacts. */ -struct ofpact_set_field *ofpact_put_reg_load(struct ofpbuf *ofpacts); +struct ofpact_set_field *ofpact_put_set_field(struct ofpbuf *ofpacts, + const struct mf_field *, + const void *value, + const void *mask); +struct ofpact_set_field *ofpact_put_reg_load(struct ofpbuf *ofpacts, + const struct mf_field *, + const void *value, + const void *mask); +struct ofpact_set_field *ofpact_put_reg_load2(struct ofpbuf *ofpacts, + const struct mf_field *, + const void *value, + const void *mask); /* OpenFlow 1.1 instructions. * The order is sorted in execution order. Not in the value of OFPIT11_xxx. diff --git a/include/ovn/actions.h b/include/ovn/actions.h index e2a716a8d..6f6f85851 100644 --- a/include/ovn/actions.h +++ b/include/ovn/actions.h @@ -27,7 +27,6 @@ #include "util.h" struct lexer; -struct ofpact_set_field; struct ofpbuf; struct shash; struct simap; @@ -151,13 +150,6 @@ struct ovnact_load { union expr_constant imm; }; -void ovnact_load_to_ofpact_set_field(const struct ovnact_load *, - bool (*lookup_port)(const void *aux, - const char *port_name, - unsigned int *portp), - const void *aux, - struct ofpact_set_field *); - /* OVNACT_MOVE, OVNACT_EXCHANGE. */ struct ovnact_move { struct ovnact ovnact; |