Skip to content

Commit

Permalink
[ovsp4rt] Extract ovsp4rt_str_to_tunnel_type() (#735)
Browse files Browse the repository at this point in the history
- Moved ovsp4rt_str_to_tunnel_type() to a separate source
  file for C api functions that are not wrappers.

Signed-off-by: Derek Foster <justffoulkes@gmail.com>
  • Loading branch information
ffoulkes authored Jan 9, 2025
1 parent 4a92a84 commit 78c712b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 35 deletions.
2 changes: 2 additions & 0 deletions ovs-p4rt/sidecar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ if(BUILD_CLIENT)
target_sources(ovs_sidecar_o PRIVATE
ovsp4rt_internal_api.h
ovsp4rt_journal_api.cc
ovsp4rt_simple_api.cc
)
else()
target_sources(ovs_sidecar_o PRIVATE
ovsp4rt_internal_api.h
ovsp4rt_simple_api.cc
ovsp4rt_standard_api.cc
)
endif()
Expand Down
17 changes: 0 additions & 17 deletions ovs-p4rt/sidecar/ovsp4rt_journal_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,6 @@ void ovsp4rt_config_tunnel_entry(struct tunnel_info tunnel_info,
ConfigTunnelEntry(client, tunnel_info, insert_entry, grpc_addr);
}

//----------------------------------------------------------------------
// ovsp4rt_str_to_tunnel_type (DPDK, ES2K)
//
// It is unclear whether this function belongs here or in a separate
// file.
//----------------------------------------------------------------------
enum ovs_tunnel_type ovsp4rt_str_to_tunnel_type(const char* tnl_type) {
if (tnl_type) {
if (strcmp(tnl_type, "vxlan") == 0) {
return OVS_TUNNEL_VXLAN;
} else if (strcmp(tnl_type, "geneve") == 0) {
return OVS_TUNNEL_GENEVE;
}
}
return OVS_TUNNEL_UNKNOWN;
}

#if defined(DPDK_TARGET)

//----------------------------------------------------------------------
Expand Down
22 changes: 22 additions & 0 deletions ovs-p4rt/sidecar/ovsp4rt_simple_api.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2022-2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

// ovsprt C API functions that do not have a C++ implementation.

#include <string.h>

#include "ovsp4rt/ovs-p4rt.h"

//----------------------------------------------------------------------
// ovsp4rt_str_to_tunnel_type (common)
//----------------------------------------------------------------------
enum ovs_tunnel_type ovsp4rt_str_to_tunnel_type(const char* tnl_type) {
if (tnl_type) {
if (strcmp(tnl_type, "vxlan") == 0) {
return OVS_TUNNEL_VXLAN;
} else if (strcmp(tnl_type, "geneve") == 0) {
return OVS_TUNNEL_GENEVE;
}
}
return OVS_TUNNEL_UNKNOWN;
}
19 changes: 1 addition & 18 deletions ovs-p4rt/sidecar/ovsp4rt_standard_api.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2024 Intel Corporation
// Copyright 2022-2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

// Standard implementation of the ovsp4rt C API.
Expand Down Expand Up @@ -31,23 +31,6 @@ void ovsp4rt_config_tunnel_entry(struct tunnel_info tunnel_info,
ConfigTunnelEntry(client, tunnel_info, insert_entry, grpc_addr);
}

//----------------------------------------------------------------------
// ovsp4rt_str_to_tunnel_type (DPDK, ES2K)
//
// It is unclear whether this function belongs here or in a separate
// file.
//----------------------------------------------------------------------
enum ovs_tunnel_type ovsp4rt_str_to_tunnel_type(const char* tnl_type) {
if (tnl_type) {
if (strcmp(tnl_type, "vxlan") == 0) {
return OVS_TUNNEL_VXLAN;
} else if (strcmp(tnl_type, "geneve") == 0) {
return OVS_TUNNEL_GENEVE;
}
}
return OVS_TUNNEL_UNKNOWN;
}

#if defined(DPDK_TARGET)

//----------------------------------------------------------------------
Expand Down

0 comments on commit 78c712b

Please sign in to comment.