-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ovsp4rt] Implement journaling api and client
- Created JournalClient, a subclass of Client that is instrumented to record interactions between OVS and the P4Runtime server. - Created a variant of the public API that uses JournalClient objects. Signed-off-by: Derek Foster <justffoulkes@gmail.com>
- Loading branch information
Showing
6 changed files
with
234 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "ovsp4rt_journal_client.h" | ||
|
||
namespace ovsp4rt { | ||
|
||
absl::StatusOr<::p4::v1::ReadResponse> JournalClient::sendReadRequest( | ||
const p4::v1::ReadRequest& request) { | ||
#if 0 | ||
_journal.recordReadRequest(request); | ||
auto response = Client::sendReadRequest(request); | ||
_journal.recordReadResponse(response); | ||
#else | ||
return Client::sendReadRequest(request); | ||
#endif | ||
} | ||
|
||
absl::Status JournalClient::sendWriteRequest( | ||
const p4::v1::WriteRequest& request) { | ||
#if 0 | ||
_journal.recordWriteRequest(request); | ||
auto response = Client::sendWriteRequest(request); | ||
_journal.recordWriteResponse(response); | ||
#else | ||
return Client::sendWriteRequest(request); | ||
#endif | ||
} | ||
|
||
} // namespace ovsp4rt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef OVSP4RT_JOURNAL_CLIENT_H_ | ||
#define OVSP4RT_JOURNAL_CLIENT_H_ | ||
|
||
#include "absl/status/status.h" | ||
#include "absl/status/statusor.h" | ||
#include "client/ovsp4rt_client.h" | ||
#include "journal/ovsp4rt_journal.h" | ||
#include "p4/v1/p4runtime.pb.h" | ||
|
||
namespace ovsp4rt { | ||
|
||
class JournalClient : public Client { | ||
public: | ||
JournalClient() {} | ||
virtual ~JournalClient() = default; | ||
|
||
// Sends a Read Table Entry request to the P4Runtime server. | ||
absl::StatusOr<p4::v1::ReadResponse> sendReadRequest( | ||
const p4::v1::ReadRequest& request) override; | ||
|
||
// Sends a Write Table Entry request to the P4Runtime server. | ||
absl::Status sendWriteRequest(const p4::v1::WriteRequest& request) override; | ||
|
||
// Returns a reference to the Journal object. | ||
Journal& journal() { return journal_; } | ||
|
||
private: | ||
// Journal object. | ||
Journal journal_; | ||
}; | ||
|
||
} // namespace ovsp4rt | ||
|
||
#endif // OVSP4RT_JOURNAL_CLIENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
// Copyright 2022-2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Implements the C API using the JournalClient class. | ||
|
||
#include "client/ovsp4rt_journal_client.h" | ||
#include "ovsp4rt/ovs-p4rt.h" | ||
#include "ovsp4rt_cc_api.h" | ||
|
||
//---------------------------------------------------------------------- | ||
// ovsp4rt_config_fdb_entry (DPDK, ES2K) | ||
//---------------------------------------------------------------------- | ||
void ovsp4rt_config_fdb_entry(struct mac_learning_info learn_info, | ||
bool insert_entry, const char* grpc_addr) { | ||
using namespace ovsp4rt; | ||
|
||
JournalClient client; | ||
client.journal().recordInput(__func__, learn_info, insert_entry); | ||
|
||
ConfigFdbEntry(client, learn_info, insert_entry, grpc_addr); | ||
} | ||
|
||
//---------------------------------------------------------------------- | ||
// ovsp4rt_config_tunnel_entry (DPDK, ES2K) | ||
//---------------------------------------------------------------------- | ||
void ovsp4rt_config_tunnel_entry(struct tunnel_info tunnel_info, | ||
bool insert_entry, const char* grpc_addr) { | ||
using namespace ovsp4rt; | ||
|
||
JournalClient client; | ||
client.journal().recordInput(__func__, tunnel_info, insert_entry); | ||
|
||
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) | ||
|
||
//---------------------------------------------------------------------- | ||
// Unimplemented functions (DPDK) | ||
//---------------------------------------------------------------------- | ||
void ovsp4rt_config_rx_tunnel_src_entry(struct tunnel_info tunnel_info, | ||
bool insert_entry, | ||
const char* grpc_addr) {} | ||
|
||
void ovsp4rt_config_vlan_entry(uint16_t vlan_id, bool insert_entry, | ||
const char* grpc_addr) {} | ||
|
||
void ovsp4rt_config_tunnel_src_port_entry(struct src_port_info tnl_sp, | ||
bool insert_entry, | ||
const char* grpc_addr) {} | ||
|
||
void ovsp4rt_config_src_port_entry(struct src_port_info vsi_sp, | ||
bool insert_entry, const char* grpc_addr) {} | ||
|
||
void ovsp4rt_config_ip_mac_map_entry(struct ip_mac_map_info ip_info, | ||
bool insert_entry, const char* grpc_addr) { | ||
} | ||
|
||
#elif defined(ES2K_TARGET) | ||
|
||
//---------------------------------------------------------------------- | ||
// ovsp4rt_config_ip_mac_map_entry (ES2K) | ||
//---------------------------------------------------------------------- | ||
void ovsp4rt_config_ip_mac_map_entry(struct ip_mac_map_info ip_info, | ||
bool insert_entry, const char* grpc_addr) { | ||
using namespace ovsp4rt; | ||
|
||
JournalClient client; | ||
client.journal().recordInput(_func__, ip_info, insert_entry); | ||
|
||
ConfigIpMacMapEntry(client, ip_info, insert_entry, grpc_addr); | ||
} | ||
|
||
//---------------------------------------------------------------------- | ||
// ovsp4rt_config_rx_tunnel_src_entry (ES2K) | ||
//---------------------------------------------------------------------- | ||
void ovsp4rt_config_rx_tunnel_src_entry(struct tunnel_info tunnel_info, | ||
bool insert_entry, | ||
const char* grpc_addr) { | ||
using namespace ovsp4rt; | ||
|
||
JournalClient client; | ||
client.journal().recordInput(__func__, tunnel_info, insert_entry); | ||
|
||
ConfigRxTunnelSrcEntry(client, tunnel_info, insert_entry, grpc_addr); | ||
} | ||
|
||
//---------------------------------------------------------------------- | ||
// ovsp4rt_config_src_port_entry (ES2K) | ||
//---------------------------------------------------------------------- | ||
void ovsp4rt_config_src_port_entry(struct src_port_info vsi_sp, | ||
bool insert_entry, const char* grpc_addr) { | ||
using namespace ovsp4rt; | ||
|
||
JournalClient client; | ||
client.journal().recordInput(__func__, vsi_sp, insert_entry); | ||
|
||
ConfigSrcPortEntry(client, vsi_sp, insert_entry, grpc_addr); | ||
} | ||
|
||
//---------------------------------------------------------------------- | ||
// ovsp4rt_config_tunnel_src_port_entry (ES2K) | ||
//---------------------------------------------------------------------- | ||
void ovsp4rt_config_tunnel_src_port_entry(struct src_port_info tnl_sp, | ||
bool insert_entry, | ||
const char* grpc_addr) { | ||
using namespace ovsp4rt; | ||
|
||
JournalClient client; | ||
client.journal().recordInput(__func__, tnl_sp, insert_entry); | ||
|
||
ConfigTunnelSrcPortEntry(client, tnl_sp, insert_entry, grpc_addr); | ||
} | ||
|
||
//---------------------------------------------------------------------- | ||
// ovsp4rt_config_vlan_entry (ES2K) | ||
//---------------------------------------------------------------------- | ||
void ovsp4rt_config_vlan_entry(uint16_t vlan_id, bool insert_entry, | ||
const char* grpc_addr) { | ||
using namespace ovsp4rt; | ||
|
||
JournalClient client; | ||
client.journal().recordInput(__func__, tnl_sp, insert_entry); | ||
|
||
ConfigVlanEntry(client, vlan_id, insert_entry, grpc_addr); | ||
} | ||
|
||
#endif // ES2K_TARGET |