From: Gavin Li <gav...@nvidia.com>

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

Signed-off-by: Gavin Li <gav...@nvidia.com>
Reviewed-by: Roi Dayan <r...@nvidia.com>
Reviewed-by: Simon Horman <simon.hor...@corigine.com>
---
 lib/odp-util.c | 5 +++--
 lib/odp-util.h | 5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index f62dc86c5f9e..d2414eb559ba 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -3278,10 +3278,11 @@ tun_key_to_attr(struct ofpbuf *a, const struct flow_tnl 
*tun_key,
     if ((!tnl_type || !strcmp(tnl_type, "vxlan")) &&
         (tun_key->gbp_flags || tun_key->gbp_id)) {
         size_t vxlan_opts_ofs;
+        uint32_t gbp_raw;
 
         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));
+        gbp_raw = odp_encode_gbp_raw(tun_key->gbp_flags, tun_key->gbp_id);
+        nl_msg_put_u32(a, OVS_VXLAN_EXT_GBP, gbp_raw);
         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

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to