diff mbox

[ovs-dev,v9,1/7] flow: add miniflow_push_uint8

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

Commit Message

Simon Horman Jan. 20, 2016, 6:15 a.m. UTC
The motivation is to allow pushing single bytes in
a manner to that already used for 16, 32 and 64 bit integers.

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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Ben Pfaff Feb. 2, 2016, 7:38 p.m. UTC | #1
On Wed, Jan 20, 2016 at 03:15:00PM +0900, Simon Horman wrote:
> The motivation is to allow pushing single bytes in
> a manner to that already used for 16, 32 and 64 bit integers.
> 
> 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>

Jarno, do you want to review patches 1 and 2?
Jarno Rajahalme Feb. 23, 2016, 12:03 a.m. UTC | #2
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:
> 
> The motivation is to allow pushing single bytes in
> a manner to that already used for 16, 32 and 64 bit integers.
> 
> 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 | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
> 
> diff --git a/lib/flow.c b/lib/flow.c
> index 5668d0c5899e..f09c32523899 100644
> --- a/lib/flow.c
> +++ b/lib/flow.c
> @@ -199,6 +199,23 @@ BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
>     }                                           \
> }
> 
> +#define miniflow_push_uint8_(MF, OFS, VALUE)            \
> +{                                                       \
> +    MINIFLOW_ASSERT(MF.data < MF.end);                  \
> +                                                        \
> +    if ((OFS) % 8 == 0) {                               \
> +        miniflow_set_map(MF, OFS / 8);                  \
> +        *(uint8_t *)MF.data = VALUE;                    \
> +    } else if ((OFS) % 8 == 7) {                        \
> +        miniflow_assert_in_map(MF, OFS / 8);            \
> +        *((uint8_t *)MF.data + 7) = VALUE;              \
> +        MF.data++;                                      \
> +    } else {                                            \
> +        miniflow_assert_in_map(MF, OFS / 8);            \
> +        *((uint8_t *)MF.data + ((OFS) % 8)) = VALUE;    \
> +    }                                                   \
> +}
> +
> #define miniflow_pad_to_64_(MF, OFS)                            \
> {                                                               \
>     MINIFLOW_ASSERT((OFS) % 8 != 0);                            \
> @@ -211,6 +228,9 @@ BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
> #define miniflow_push_be16_(MF, OFS, VALUE)                     \
>     miniflow_push_uint16_(MF, OFS, (OVS_FORCE uint16_t)VALUE);
> 
> +#define miniflow_push_be8_(MF, OFS, VALUE)                     \
> +    miniflow_push_uint8_(MF, OFS, (OVS_FORCE uint8_t)VALUE);
> +
> #define miniflow_set_maps(MF, OFS, N_WORDS)                     \
> {                                                               \
>     size_t ofs = (OFS);                                         \
> @@ -262,6 +282,9 @@ BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
> #define miniflow_push_be16(MF, FIELD, VALUE)                        \
>     miniflow_push_be16_(MF, offsetof(struct flow, FIELD), VALUE)
> 
> +#define miniflow_push_uint8(MF, FIELD, VALUE)                      \
> +    miniflow_push_uint8_(MF, offsetof(struct flow, FIELD), VALUE)
> +
> #define miniflow_pad_to_64(MF, FIELD)                       \
>     miniflow_pad_to_64_(MF, OFFSETOFEND(struct flow, FIELD))
> 
> -- 
> 2.1.4
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
Simon Horman Feb. 24, 2016, 5:19 a.m. UTC | #3
On Mon, Feb 22, 2016 at 04:03:59PM -0800, Jarno Rajahalme wrote:
> > On Jan 19, 2016, at 10:15 PM, Simon Horman <simon.horman@netronome.com> wrote:
> > 
> > The motivation is to allow pushing single bytes in
> > a manner to that already used for 16, 32 and 64 bit integers.
> > 
> > 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 5668d0c5899e..f09c32523899 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -199,6 +199,23 @@  BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
     }                                           \
 }
 
+#define miniflow_push_uint8_(MF, OFS, VALUE)            \
+{                                                       \
+    MINIFLOW_ASSERT(MF.data < MF.end);                  \
+                                                        \
+    if ((OFS) % 8 == 0) {                               \
+        miniflow_set_map(MF, OFS / 8);                  \
+        *(uint8_t *)MF.data = VALUE;                    \
+    } else if ((OFS) % 8 == 7) {                        \
+        miniflow_assert_in_map(MF, OFS / 8);            \
+        *((uint8_t *)MF.data + 7) = VALUE;              \
+        MF.data++;                                      \
+    } else {                                            \
+        miniflow_assert_in_map(MF, OFS / 8);            \
+        *((uint8_t *)MF.data + ((OFS) % 8)) = VALUE;    \
+    }                                                   \
+}
+
 #define miniflow_pad_to_64_(MF, OFS)                            \
 {                                                               \
     MINIFLOW_ASSERT((OFS) % 8 != 0);                            \
@@ -211,6 +228,9 @@  BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
 #define miniflow_push_be16_(MF, OFS, VALUE)                     \
     miniflow_push_uint16_(MF, OFS, (OVS_FORCE uint16_t)VALUE);
 
+#define miniflow_push_be8_(MF, OFS, VALUE)                     \
+    miniflow_push_uint8_(MF, OFS, (OVS_FORCE uint8_t)VALUE);
+
 #define miniflow_set_maps(MF, OFS, N_WORDS)                     \
 {                                                               \
     size_t ofs = (OFS);                                         \
@@ -262,6 +282,9 @@  BUILD_MESSAGE("FLOW_WC_SEQ changed: miniflow_extract() will have runtime "
 #define miniflow_push_be16(MF, FIELD, VALUE)                        \
     miniflow_push_be16_(MF, offsetof(struct flow, FIELD), VALUE)
 
+#define miniflow_push_uint8(MF, FIELD, VALUE)                      \
+    miniflow_push_uint8_(MF, offsetof(struct flow, FIELD), VALUE)
+
 #define miniflow_pad_to_64(MF, FIELD)                       \
     miniflow_pad_to_64_(MF, OFFSETOFEND(struct flow, FIELD))