Skip to content
Open
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
2 changes: 1 addition & 1 deletion control_plane/algo/algo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bf_status_t inNetworkCCAlgo(std::fstream &outfile, bool &algo_running){

while(algo_running){
status = bfrt.get_queuing_info(egressPort, currentAvgQdepth, currentWorkingCopy);
printf("%i\n",currentRwnd);
printf("Current Rwnd: %i\n",currentRwnd);
if(currentAvgQdepth > upperQdepthThreshold){ // multiplicative decrement
currentRwnd = max_rwnd(minimumRwnd, currentRwnd / rwndDecrement);
status = bfrt.set_rwnd(egressPort, currentRwnd);
Expand Down
49 changes: 46 additions & 3 deletions control_plane/bfrt/bfrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void Bfruntime::init(){
void Bfruntime::initBfRtTablesRegisters(){

bf_status_t status;
bfrt::BfRtIdleTmoExpiryCb idle_time_callback = fetch_rtt_mul_and_ws_aging_cb_wrapper;

/* // Register working_copy
status = bf_rt_info->bfrtTableFromNameGet("SwitchEgressControl.working_copy", &working_copy);
Expand Down Expand Up @@ -194,8 +195,12 @@ void Bfruntime::initBfRtTablesRegisters(){
fflush(stdout);
status = fetch_rtt_mul_and_ws->dataFieldIdGet("ws", set_rtt_mul_and_ws_action_id, &set_rtt_mul_and_ws_action_field_ws_id);
CHECK_BF_STATUS(status);
status = fetch_rtt_mul_and_ws->dataFieldIdGet("$ENTRY_TTL", set_rtt_mul_and_ws_action_id, &set_rtt_mul_and_ws_action_field_entry_ttl_id);
CHECK_BF_STATUS(status);
printf("WS datafield ID is %u\n", set_rtt_mul_and_ws_action_field_ws_id);
fflush(stdout);


// Allocate and reset key objects
status = fetch_rtt_mul_and_ws->keyAllocate(&fetch_rtt_mul_and_ws_key1);
CHECK_BF_STATUS(status);
Expand All @@ -215,6 +220,13 @@ void Bfruntime::initBfRtTablesRegisters(){
status = fetch_rtt_mul_and_ws->dataReset(set_rtt_mul_and_ws_action_id, fetch_rtt_mul_and_ws_data2.get());
CHECK_BF_STATUS(status);

status = fetch_rtt_mul_and_ws->attributeAllocate(bfrt::TableAttributesType::IDLE_TABLE_RUNTIME, bfrt::TableAttributesIdleTableMode::NOTIFY_MODE, &fetch_rtt_mul_and_ws_attributes);
CHECK_BF_STATUS(status);
status = fetch_rtt_mul_and_ws_attributes->idleTableNotifyModeSet(true, idle_time_callback, Bfruntime::fetch_rtt_mul_and_ws_key_ttl_query_interval, Bfruntime::fetch_rtt_mul_and_ws_key_max_ttl, Bfruntime::fetch_rtt_mul_and_ws_key_min_ttl, Bfruntime::fetch_rtt_mul_and_ws_key_cookie);
CHECK_BF_STATUS(status);
status = fetch_rtt_mul_and_ws->tableAttributesSet(*session, dev_tgt, *fetch_rtt_mul_and_ws_attributes);
CHECK_BF_STATUS(status);

// set consistent initial currentWorkingCopy in CP and DP
this->currentWorkingCopy = 0;
this->set_working_copy(this->currentWorkingCopy);
Expand Down Expand Up @@ -430,7 +442,7 @@ bf_status_t Bfruntime::get_queuing_info(port_t egressPort, uint64_t &avgQdepth,
bf_status_t Bfruntime::add_rtt_ws_entry_pair(const rtt_ws_entry_pair_info_t &info){

bf_status_t status;

// Prepare key1
status = fetch_rtt_mul_and_ws_key1->setValue(fetch_rtt_mul_and_ws_key_ipv4_src_id, static_cast<uint64_t>(info.srcIP));
CHECK_BF_STATUS(status);
Expand All @@ -447,7 +459,8 @@ bf_status_t Bfruntime::add_rtt_ws_entry_pair(const rtt_ws_entry_pair_info_t &inf
CHECK_BF_STATUS(status);
status = fetch_rtt_mul_and_ws_data1->setValue(set_rtt_mul_and_ws_action_field_ws_id, static_cast<uint64_t>(info.srcWS));
CHECK_BF_STATUS(status);

status = fetch_rtt_mul_and_ws_data1->setValue(set_rtt_mul_and_ws_action_field_entry_ttl_id, static_cast<uint64_t>(Bfruntime::fetch_rtt_mul_and_ws_common_timeout));
CHECK_BF_STATUS(status);

// Prepare key2
status = fetch_rtt_mul_and_ws_key2->setValue(fetch_rtt_mul_and_ws_key_ipv4_src_id, static_cast<uint64_t>(info.dstIP));
Expand All @@ -464,7 +477,9 @@ bf_status_t Bfruntime::add_rtt_ws_entry_pair(const rtt_ws_entry_pair_info_t &inf
CHECK_BF_STATUS(status);
status = fetch_rtt_mul_and_ws_data2->setValue(set_rtt_mul_and_ws_action_field_ws_id, static_cast<uint64_t>(info.dstWS));
CHECK_BF_STATUS(status);

status = fetch_rtt_mul_and_ws_data2->setValue(set_rtt_mul_and_ws_action_field_entry_ttl_id, static_cast<uint64_t>(Bfruntime::fetch_rtt_mul_and_ws_common_timeout));
CHECK_BF_STATUS(status);

// status = pcpp_session->beginBatch();CHECK_BF_STATUS(status);

status = fetch_rtt_mul_and_ws->tableEntryAdd(*pcpp_session, dev_tgt, *fetch_rtt_mul_and_ws_key1, *fetch_rtt_mul_and_ws_data1);
Expand All @@ -477,3 +492,31 @@ bf_status_t Bfruntime::add_rtt_ws_entry_pair(const rtt_ws_entry_pair_info_t &inf

return status;
}

void Bfruntime::fetch_rtt_mul_and_ws_aging_cb(const bf_rt_target_t &dev_tgt, const bfrt::BfRtTableKey *table_key, void *cookie){
bf_status_t status;
uint64_t srcIP;
uint64_t dstIP;
uint64_t srcPort;
uint64_t dstPort;

status = table_key->getValue(fetch_rtt_mul_and_ws_key_ipv4_dst_id, &dstIP); CHECK_BF_STATUS(status);
status = table_key->getValue(fetch_rtt_mul_and_ws_key_ipv4_src_id, &srcIP); CHECK_BF_STATUS(status);
status = table_key->getValue(fetch_rtt_mul_and_ws_key_tcp_dst_port_id, &srcPort); CHECK_BF_STATUS(status);
status = table_key->getValue(fetch_rtt_mul_and_ws_key_tcp_src_port_id, &dstPort); CHECK_BF_STATUS(status);
(void) cookie;

printf("Aging out <srcIP:0x%08lX, dstIP:0x%08lX, srcPort:0x%04lX, dstPort:0x%04lX> entry.\n", srcIP, dstIP, srcPort, dstPort);

try{
status = fetch_rtt_mul_and_ws->tableEntryDel(*pcpp_session, dev_tgt, *table_key); CHECK_BF_STATUS(status);
}catch(...){
printf("WARNING: Could not find the matching entry");
}
status = this->pcpp_session->sessionCompleteOperations(); CHECK_BF_STATUS(status);
}

void fetch_rtt_mul_and_ws_aging_cb_wrapper(const bf_rt_target_t &dev_tgt, const bfrt::BfRtTableKey *key, void *cookie){
Bfruntime &bfrt = Bfruntime::getInstance();
bfrt.fetch_rtt_mul_and_ws_aging_cb(dev_tgt, key, cookie);
}
19 changes: 16 additions & 3 deletions control_plane/bfrt/bfrt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ struct rtt_ws_entry_pair_info_t {
rtt_t rtt_mul;
};

void fetch_rtt_mul_and_ws_aging_cb_wrapper(const bf_rt_target_t &dev_tgt, const bfrt::BfRtTableKey *key, void *cookie);

class Bfruntime {
private:

Expand Down Expand Up @@ -59,17 +61,24 @@ class Bfruntime {
std::unique_ptr<bfrt::BfRtTableKey> fetch_rtt_mul_and_ws_key2;
std::unique_ptr<bfrt::BfRtTableData> fetch_rtt_mul_and_ws_data1;
std::unique_ptr<bfrt::BfRtTableData> fetch_rtt_mul_and_ws_data2;
std::unique_ptr<bfrt::BfRtTableAttributes> fetch_rtt_mul_and_ws_attributes;

bf_rt_id_t fetch_rtt_mul_and_ws_key_ipv4_src_id = 0;
bf_rt_id_t fetch_rtt_mul_and_ws_key_ipv4_dst_id = 0;
bf_rt_id_t fetch_rtt_mul_and_ws_key_tcp_src_port_id = 0;
bf_rt_id_t fetch_rtt_mul_and_ws_key_tcp_dst_port_id = 0;
bf_rt_id_t set_rtt_mul_and_ws_action_id = 0;
bf_rt_id_t set_rtt_mul_and_ws_action_field_rtt_mul_id = 0;
bf_rt_id_t set_rtt_mul_and_ws_action_field_ws_id = 0;
bf_rt_id_t set_rtt_mul_and_ws_action_field_entry_ttl_id = 0;

const uint32_t fetch_rtt_mul_and_ws_key_ttl_query_interval = 250;
const uint32_t fetch_rtt_mul_and_ws_key_max_ttl = 5000;
const uint32_t fetch_rtt_mul_and_ws_key_min_ttl = 1000;
const uint32_t fetch_rtt_mul_and_ws_common_timeout = 1000;
const void * fetch_rtt_mul_and_ws_key_cookie;

working_copy_t currentWorkingCopy = 0;

/*
Private constructor and destructor to avoid them being
called by clients.
Expand All @@ -92,8 +101,10 @@ class Bfruntime {

// Swaps the working copy (of qdepth sum/count registers)
bf_status_t update_working_copy(working_copy_t &currentWorkingCopy);


/******************/
/* Public Section */
/******************/
public:

/* Provides access to the unique instance of the singleton */
Expand All @@ -106,11 +117,13 @@ class Bfruntime {
bf_status_t get_queuing_info(port_t egressPort, uint64_t &avgQdepth, working_copy_t &currentWorkingCopy);

bf_status_t add_rtt_ws_entry_pair(const rtt_ws_entry_pair_info_t &rtt_ws_entry_pair_info);
// static void fetch_rtt_mul_and_ws_aging_cb(const bf_rt_target_t &dev_tgt, const bfrt::BfRtTableKey *table_key, void *cookie);

void fetch_rtt_mul_and_ws_aging_cb(const bf_rt_target_t &dev_tgt, const bfrt::BfRtTableKey *table_key, void *cookie);

/* Singleton should not be clonable or assignable */
Bfruntime(Bfruntime &other) = delete;
void operator=(const Bfruntime &) = delete;

};


Expand Down
1 change: 1 addition & 0 deletions p4src/adjust_rwnd.p4
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ control adjustRWND(inout header_t hdr, inout ingress_metadata_t ig_meta){
}
default_action = miss_rtt_ws_lookup;
size = 65536;
idle_timeout = true;
}

action set_log_rwnd(bit<16> result) {
Expand Down