diff mbox series

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

Message ID 20230515082356.3471136-3-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 success apply and check: success
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 decoding to odp_decode_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 | 9 +++------
 lib/odp-util.h | 8 ++++++++
 2 files changed, 11 insertions(+), 6 deletions(-)

Comments

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

> From: Gavin Li <gavinl@nvidia.com>
>
> Extract vxlan gbp option decoding to odp_decode_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>

The changes look good to me.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
diff mbox series

Patch

diff --git a/lib/odp-util.c b/lib/odp-util.c
index 2ec889c417e5..f62dc86c5f9e 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -3162,8 +3162,7 @@  odp_tun_key_from_attr__(const struct nlattr *attr, bool is_mask,
             if (ext[OVS_VXLAN_EXT_GBP]) {
                 uint32_t gbp = nl_attr_get_u32(ext[OVS_VXLAN_EXT_GBP]);
 
-                tun->gbp_id = htons(gbp & 0xFFFF);
-                tun->gbp_flags = (gbp >> 16) & 0xFF;
+                odp_decode_gbp_raw(gbp, &tun->gbp_id, &tun->gbp_flags);
             }
 
             break;
@@ -3753,12 +3752,10 @@  format_odp_tun_vxlan_opt(const struct nlattr *attr,
             ovs_be16 id, id_mask;
             uint8_t flags, flags_mask = 0;
 
-            id = htons(key & 0xFFFF);
-            flags = (key >> 16) & 0xFF;
+            odp_decode_gbp_raw(key, &id, &flags);
             if (ma) {
                 uint32_t mask = nl_attr_get_u32(ma);
-                id_mask = htons(mask & 0xFFFF);
-                flags_mask = (mask >> 16) & 0xFF;
+                odp_decode_gbp_raw(mask, &id_mask, &flags_mask);
             }
 
             ds_put_cstr(ds, "gbp(");
diff --git a/lib/odp-util.h b/lib/odp-util.h
index a1d0d0fba5de..cf762bdc3547 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -374,6 +374,14 @@  void odp_put_push_eth_action(struct ofpbuf *odp_actions,
                              const struct eth_addr *eth_src,
                              const struct eth_addr *eth_dst);
 
+static inline void odp_decode_gbp_raw(uint32_t gbp_raw,
+                                      ovs_be16 *id,
+                                      uint8_t *flags)
+{
+    *id = htons(gbp_raw & 0xFFFF);
+    *flags = (gbp_raw >> 16) & 0xFF;
+}
+
 struct attr_len_tbl {
     int len;
     const struct attr_len_tbl *next;