diff mbox

[ovs-dev,v9,2/7] flow: add miniflow_pad_from_64

Message ID 1453270506-10643-3-git-send-email-simon.horman@netronome.com
State Accepted
Headers show

Commit Message

Simon Horman Jan. 20, 2016, 6:15 a.m. UTC
Provide leading padding to allow pushing a value to a miniflow where
the value is not aligned to 64 bytes and no value has already been
pushed to the same word.

This will be used by a follow-up patch to allow layer 3 packet - that is
packets without an ethernet header - to be represented in flows.

Signed-off-by: Simon Horman <simon.horman@netronome.com>

---
v9
* New patch
---
 lib/flow.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Jarno Rajahalme Feb. 23, 2016, 12:04 a.m. UTC | #1
Sorry for the delay,

Acked-by: Jarno Rajahalme <jarno@ovn.org>

> On Jan 19, 2016, at 10:15 PM, Simon Horman <simon.horman@netronome.com> wrote:
> 
> Provide leading padding to allow pushing a value to a miniflow where
> the value is not aligned to 64 bytes and no value has already been
> pushed to the same word.
> 
> This will be used by a follow-up patch to allow layer 3 packet - that is
> packets without an ethernet header - to be represented in flows.
> 
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
> 
> ---
> v9
> * New patch
> ---
> lib/flow.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
> 
> diff --git a/lib/flow.c b/lib/flow.c
> index f09c32523899..2a7116b675da 100644
> --- a/lib/flow.c
> +++ b/lib/flow.c
> @@ -225,6 +225,16 @@ BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
>     MF.data++;                                                  \
> }
> 
> +#define miniflow_pad_from_64_(MF, OFS)                          \
> +{                                                               \
> +    MINIFLOW_ASSERT(MF.data < MF.end);                          \
> +                                                                \
> +    MINIFLOW_ASSERT((OFS) % 8 != 0);                            \
> +    miniflow_set_map(MF, OFS / 8);                              \
> +                                                                \
> +    memset((uint8_t *)MF.data, 0, (OFS) % 8);                   \
> +}
> +
> #define miniflow_push_be16_(MF, OFS, VALUE)                     \
>     miniflow_push_uint16_(MF, OFS, (OVS_FORCE uint16_t)VALUE);
> 
> @@ -288,6 +298,9 @@ BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
> #define miniflow_pad_to_64(MF, FIELD)                       \
>     miniflow_pad_to_64_(MF, OFFSETOFEND(struct flow, FIELD))
> 
> +#define miniflow_pad_from_64(MF, FIELD)                       \
> +    miniflow_pad_from_64_(MF, offsetof(struct flow, FIELD))
> +
> #define miniflow_push_words(MF, FIELD, VALUEP, N_WORDS)                 \
>     miniflow_push_words_(MF, offsetof(struct flow, FIELD), VALUEP, N_WORDS)
> 
> -- 
> 2.1.4
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
Simon Horman Feb. 24, 2016, 5:20 a.m. UTC | #2
On Mon, Feb 22, 2016 at 04:04:42PM -0800, Jarno Rajahalme wrote:
> > On Jan 19, 2016, at 10:15 PM, Simon Horman <simon.horman@netronome.com> wrote:
> > 
> > Provide leading padding to allow pushing a value to a miniflow where
> > the value is not aligned to 64 bytes and no value has already been
> > pushed to the same word.
> > 
> > This will be used by a follow-up patch to allow layer 3 packet - that is
> > packets without an ethernet header - to be represented in flows.
> > 
> > Signed-off-by: Simon Horman <simon.horman@netronome.com>
>
> Sorry for the delay,
>
> Acked-by: Jarno Rajahalme <jarno@ovn.org>

Thanks, I have applied this to master.
diff mbox

Patch

diff --git a/lib/flow.c b/lib/flow.c
index f09c32523899..2a7116b675da 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -225,6 +225,16 @@  BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
     MF.data++;                                                  \
 }
 
+#define miniflow_pad_from_64_(MF, OFS)                          \
+{                                                               \
+    MINIFLOW_ASSERT(MF.data < MF.end);                          \
+                                                                \
+    MINIFLOW_ASSERT((OFS) % 8 != 0);                            \
+    miniflow_set_map(MF, OFS / 8);                              \
+                                                                \
+    memset((uint8_t *)MF.data, 0, (OFS) % 8);                   \
+}
+
 #define miniflow_push_be16_(MF, OFS, VALUE)                     \
     miniflow_push_uint16_(MF, OFS, (OVS_FORCE uint16_t)VALUE);
 
@@ -288,6 +298,9 @@  BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
 #define miniflow_pad_to_64(MF, FIELD)                       \
     miniflow_pad_to_64_(MF, OFFSETOFEND(struct flow, FIELD))
 
+#define miniflow_pad_from_64(MF, FIELD)                       \
+    miniflow_pad_from_64_(MF, offsetof(struct flow, FIELD))
+
 #define miniflow_push_words(MF, FIELD, VALUEP, N_WORDS)                 \
     miniflow_push_words_(MF, offsetof(struct flow, FIELD), VALUEP, N_WORDS)