mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
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>
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user