summaryrefslogtreecommitdiff
path: root/include/openvswitch/meta-flow.h
diff options
context:
space:
mode:
authorJarno Rajahalme <jarno@ovn.org>2016-08-31 08:43:48 -0700
committerJarno Rajahalme <jarno@ovn.org>2016-08-31 08:43:48 -0700
commitdfe191d5faa60d34a64e3bd1040fd6fa02b4889c (patch)
treecbed0e4dc2384d2a97ab211d540e61b1370cfda0 /include/openvswitch/meta-flow.h
parent47bf118665a3d0f3c153d1fe80e9af02ac9a4e9c (diff)
downloadopenvswitch-dfe191d5faa60d34a64e3bd1040fd6fa02b4889c.tar.gz
ofp-actions: Waste less memory in learn actions.
Make the immediate data member 'src_imm' of a learn spec allocated at the end of the action for just the right size. This, together with some structure packing saves on average of ~128 bytes for each learn spec in each learn action. Typical learn actions have about 4 specs each, so this amounts to saving about 0.5kb for each learn action. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'include/openvswitch/meta-flow.h')
-rw-r--r--include/openvswitch/meta-flow.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/openvswitch/meta-flow.h b/include/openvswitch/meta-flow.h
index 23f991608..966ff7ff3 100644
--- a/include/openvswitch/meta-flow.h
+++ b/include/openvswitch/meta-flow.h
@@ -19,6 +19,7 @@
#include <limits.h>
#include <stdarg.h>
+#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
@@ -2044,6 +2045,16 @@ int mf_subvalue_width(const union mf_subvalue *);
void mf_subvalue_shift(union mf_subvalue *, int n);
void mf_subvalue_format(const union mf_subvalue *, struct ds *);
+static inline void mf_subvalue_from_value(const struct mf_subfield *sf,
+ union mf_subvalue *sv,
+ const void *value)
+{
+ unsigned int n_bytes = DIV_ROUND_UP(sf->n_bits, 8);
+ memset(sv, 0, sizeof *sv - n_bytes);
+ memcpy(&sv->u8[sizeof sv->u8 - n_bytes], value, n_bytes);
+}
+
+
/* Set of field values. 'values' only includes the actual data bytes for each
* field for which is used, as marked by 1-bits in 'used'. */
struct field_array {
@@ -2115,6 +2126,9 @@ void mf_write_subfield_flow(const struct mf_subfield *,
const union mf_subvalue *, struct flow *);
void mf_write_subfield(const struct mf_subfield *, const union mf_subvalue *,
struct match *);
+void mf_write_subfield_value(const struct mf_subfield *, const void *src,
+ struct match *);
+
void mf_mask_subfield(const struct mf_field *,
const union mf_subvalue *value,
const union mf_subvalue *mask,