Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract Es2kPrepareEncapTableEntry function #42

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions ovs-p4rt/sidecar/newovsp4rt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1548,20 +1548,11 @@ void PrepareV6TunnelTermTableEntry(p4::v1::TableEntry* table_entry,
}
#endif // ES2K_TARGET

// called-by: DoConfigTunnelEntry (common)
absl::Status ConfigEncapTableEntry(ClientInterface& client,
const struct tunnel_info& tunnel_info,
const ::p4::config::v1::P4Info& p4info,
bool insert_entry) {
::p4::v1::WriteRequest write_request;
::p4::v1::TableEntry* table_entry;

table_entry = client.initWriteRequest(&write_request, insert_entry);

#if defined(DPDK_TARGET)
PrepareEncapTableEntry(table_entry, tunnel_info, p4info, insert_entry);

#elif defined(ES2K_TARGET)
#if defined(ES2K_TARGET)
void Es2kPrepareEncapTableEntry(p4::v1::TableEntry* table_entry,
const struct tunnel_info& tunnel_info,
const ::p4::config::v1::P4Info& p4info,
bool insert_entry) {
if (tunnel_info.local_ip.family == AF_INET &&
tunnel_info.remote_ip.family == AF_INET) {
if (tunnel_info.vlan_info.port_vlan_mode == P4_PORT_VLAN_NATIVE_UNTAGGED) {
Expand All @@ -1578,7 +1569,26 @@ absl::Status ConfigEncapTableEntry(ClientInterface& client,
} else {
PrepareV6EncapTableEntry(table_entry, tunnel_info, p4info, insert_entry);
}
} else {
// TODO(derek): error case?
}
}
#endif // ES2K_TARGET

// called-by: DoConfigTunnelEntry (common)
absl::Status ConfigEncapTableEntry(ClientInterface& client,
const struct tunnel_info& tunnel_info,
const ::p4::config::v1::P4Info& p4info,
bool insert_entry) {
::p4::v1::WriteRequest write_request;
::p4::v1::TableEntry* table_entry;

table_entry = client.initWriteRequest(&write_request, insert_entry);

#if defined(DPDK_TARGET)
PrepareEncapTableEntry(table_entry, tunnel_info, p4info, insert_entry);
#elif defined(ES2K_TARGET)
Es2kPrepareEncapTableEntry(table_entry, tunnel_info, p4info, insert_entry);
#else
#error "ASSERT: Unknown TARGET type!"
#endif
Expand Down
4 changes: 4 additions & 0 deletions ovs-p4rt/sidecar/ovsp4rt_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ extern void PrepareTunnelTermTableEntry(p4::v1::TableEntry* table_entry,
//----------------------------------------------------------------------

#if defined(ES2K_TARGET)
extern void Es2kPrepareEncapTableEntry(p4::v1::TableEntry* table_entry,
const struct tunnel_info& tunnel_info,
const ::p4::config::v1::P4Info& p4info,
bool insert_entry);

extern void PrepareDstIpMacMapTableEntry(p4::v1::TableEntry* table_entry,
const struct ip_mac_map_info& ip_info,
Expand Down
Loading