diff mbox series

[ovs-dev,v3,3/7] odp-util: Extract vxlan gbp option encoding to a function

Message ID 20230515082356.3471136-4-roid@nvidia.com
State Changes Requested
Delegated to: Simon Horman
Headers show
Series Add vxlan gbp offload with TC | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Roi Dayan May 15, 2023, 8:23 a.m. UTC
From: Gavin Li <gavinl@nvidia.com>

Extract vxlan gbp option encoding to odp_encode_gbp_raw to be used in
following commits.

Signed-off-by: Gavin Li <gavinl@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
---
 lib/odp-util.c | 2 +-
 lib/odp-util.h | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Eelco Chaudron May 26, 2023, 9:10 a.m. UTC | #1
On 15 May 2023, at 10:23, Roi Dayan wrote:

> From: Gavin Li <gavinl@nvidia.com>
>
> Extract vxlan gbp option encoding to odp_encode_gbp_raw to be used in
> following commits.
>
> Signed-off-by: Gavin Li <gavinl@nvidia.com>
> Reviewed-by: Roi Dayan <roid@nvidia.com>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> ---
>  lib/odp-util.c | 2 +-
>  lib/odp-util.h | 5 +++++
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/lib/odp-util.c b/lib/odp-util.c
> index f62dc86c5f9e..bf34c61fec58 100644
> --- a/lib/odp-util.c
> +++ b/lib/odp-util.c
> @@ -3281,7 +3281,7 @@ tun_key_to_attr(struct ofpbuf *a, const struct flow_tnl *tun_key,
>
>          vxlan_opts_ofs = nl_msg_start_nested(a, OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS);
>          nl_msg_put_u32(a, OVS_VXLAN_EXT_GBP,
> -                       (tun_key->gbp_flags << 16) | ntohs(tun_key->gbp_id));
> +                       odp_encode_gbp_raw(tun_key->gbp_flags, tun_key->gbp_id));

One small nit, this is over 79 chars.

>          nl_msg_end_nested(a, vxlan_opts_ofs);
>      }
>
> diff --git a/lib/odp-util.h b/lib/odp-util.h
> index cf762bdc3547..163efe7a87b5 100644
> --- a/lib/odp-util.h
> +++ b/lib/odp-util.h
> @@ -382,6 +382,11 @@ static inline void odp_decode_gbp_raw(uint32_t gbp_raw,
>      *flags = (gbp_raw >> 16) & 0xFF;
>  }
>
> +static inline uint32_t odp_encode_gbp_raw(uint8_t flags, ovs_be16 id)
> +{
> +    return (flags << 16) | ntohs(id);
> +}
> +
>  struct attr_len_tbl {
>      int len;
>      const struct attr_len_tbl *next;
> -- 
> 2.38.0
Gavin Li May 30, 2023, 8:14 a.m. UTC | #2
On 5/26/2023 5:10 PM, Eelco Chaudron wrote:
> External email: Use caution opening links or attachments
>
>
> On 15 May 2023, at 10:23, Roi Dayan wrote:
>
>> From: Gavin Li <gavinl@nvidia.com>
>>
>> Extract vxlan gbp option encoding to odp_encode_gbp_raw to be used in
>> following commits.
>>
>> Signed-off-by: Gavin Li <gavinl@nvidia.com>
>> Reviewed-by: Roi Dayan <roid@nvidia.com>
>> Reviewed-by: Simon Horman <simon.horman@corigine.com>
>> ---
>>   lib/odp-util.c | 2 +-
>>   lib/odp-util.h | 5 +++++
>>   2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/odp-util.c b/lib/odp-util.c
>> index f62dc86c5f9e..bf34c61fec58 100644
>> --- a/lib/odp-util.c
>> +++ b/lib/odp-util.c
>> @@ -3281,7 +3281,7 @@ tun_key_to_attr(struct ofpbuf *a, const struct flow_tnl *tun_key,
>>
>>           vxlan_opts_ofs = nl_msg_start_nested(a, OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS);
>>           nl_msg_put_u32(a, OVS_VXLAN_EXT_GBP,
>> -                       (tun_key->gbp_flags << 16) | ntohs(tun_key->gbp_id));
>> +                       odp_encode_gbp_raw(tun_key->gbp_flags, tun_key->gbp_id));
> One small nit, this is over 79 chars.
ACK
>
>>           nl_msg_end_nested(a, vxlan_opts_ofs);
>>       }
>>
>> diff --git a/lib/odp-util.h b/lib/odp-util.h
>> index cf762bdc3547..163efe7a87b5 100644
>> --- a/lib/odp-util.h
>> +++ b/lib/odp-util.h
>> @@ -382,6 +382,11 @@ static inline void odp_decode_gbp_raw(uint32_t gbp_raw,
>>       *flags = (gbp_raw >> 16) & 0xFF;
>>   }
>>
>> +static inline uint32_t odp_encode_gbp_raw(uint8_t flags, ovs_be16 id)
>> +{
>> +    return (flags << 16) | ntohs(id);
>> +}
>> +
>>   struct attr_len_tbl {
>>       int len;
>>       const struct attr_len_tbl *next;
>> --
>> 2.38.0
diff mbox series

Patch

diff --git a/lib/odp-util.c b/lib/odp-util.c
index f62dc86c5f9e..bf34c61fec58 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -3281,7 +3281,7 @@  tun_key_to_attr(struct ofpbuf *a, const struct flow_tnl *tun_key,
 
         vxlan_opts_ofs = nl_msg_start_nested(a, OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS);
         nl_msg_put_u32(a, OVS_VXLAN_EXT_GBP,
-                       (tun_key->gbp_flags << 16) | ntohs(tun_key->gbp_id));
+                       odp_encode_gbp_raw(tun_key->gbp_flags, tun_key->gbp_id));
         nl_msg_end_nested(a, vxlan_opts_ofs);
     }
 
diff --git a/lib/odp-util.h b/lib/odp-util.h
index cf762bdc3547..163efe7a87b5 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -382,6 +382,11 @@  static inline void odp_decode_gbp_raw(uint32_t gbp_raw,
     *flags = (gbp_raw >> 16) & 0xFF;
 }
 
+static inline uint32_t odp_encode_gbp_raw(uint8_t flags, ovs_be16 id)
+{
+    return (flags << 16) | ntohs(id);
+}
+
 struct attr_len_tbl {
     int len;
     const struct attr_len_tbl *next;