VOL-4727: Remove restriction that flows have to be replicated for
8 pbits when replication is enabled
Change-Id: I947315ea6a5f52a2c7fd9491896e73ee8730de84
diff --git a/VERSION b/VERSION
index 0b2eb36..c1e43e6 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.7.2
+3.7.3
diff --git a/agent/common/core.h b/agent/common/core.h
index 4279f35..dafbf97 100644
--- a/agent/common/core.h
+++ b/agent/common/core.h
@@ -174,7 +174,7 @@
#define FILL_ARRAY2(ARRAY,START,END,VALUE) for(int i=START;i<END;ARRAY[i]=VALUE,i+=2);
#define COUNT_OF(array) (sizeof(array) / sizeof(array[0]))
#define NUMBER_OF_PBITS 8
-#define NUMBER_OF_REPLICATED_FLOWS NUMBER_OF_PBITS
+#define MAX_NUMBER_OF_REPLICATED_FLOWS NUMBER_OF_PBITS
#define GRPC_THREAD_POOL_SIZE 150
#define GET_FLOW_INTERFACE_TYPE(type) \
diff --git a/agent/src/core_api_handler.cc b/agent/src/core_api_handler.cc
index 5b7bb74..8f6ea7b 100644
--- a/agent/src/core_api_handler.cc
+++ b/agent/src/core_api_handler.cc
@@ -1669,7 +1669,11 @@
update_voltha_flow_to_cache(voltha_flow_id, dev_fl);
} else { // Flow to be replicated
OPENOLT_LOG(INFO, openolt_log_id,"symmetric flow and replication is needed\n");
- for (uint8_t i=0; i<NUMBER_OF_REPLICATED_FLOWS; i++) {
+ if (pbit_to_gemport.size() > NUMBER_OF_PBITS) {
+ OPENOLT_LOG(ERROR, openolt_log_id, "invalid pbit-to-gemport map size=%lu", pbit_to_gemport.size())
+ return ::Status(grpc::StatusCode::OUT_OF_RANGE, "pbit-to-gemport-map-len-invalid-for-flow-replication");
+ }
+ for (uint8_t i=0; i<pbit_to_gemport.size(); i++) {
::openolt::Classifier cl = ::openolt::Classifier(classifier);
flow_id = dev_fl_symm_params[i].flow_id;
gemport_id = dev_fl_symm_params[i].gemport_id;
@@ -1696,8 +1700,9 @@
dev_fl.is_flow_replicated = true;
dev_fl.symmetric_voltha_flow_id = symmetric_voltha_flow_id;
dev_fl.voltha_flow_id = voltha_flow_id;
+ dev_fl.total_replicated_flows = pbit_to_gemport.size();
dev_fl.flow_type = flow_type;
- memcpy(dev_fl.params, dev_fl_symm_params, sizeof(device_flow_params)*NUMBER_OF_REPLICATED_FLOWS);
+ memcpy(dev_fl.params, dev_fl_symm_params, sizeof(device_flow_params)*dev_fl.total_replicated_flows);
// update voltha flow to cache
update_voltha_flow_to_cache(voltha_flow_id, dev_fl);
}
@@ -1731,17 +1736,18 @@
}
} else { // Flow to be replicated
OPENOLT_LOG(INFO, openolt_log_id,"not a symmetric flow and replication is needed\n");
- if (pbit_to_gemport.size() != NUMBER_OF_PBITS) {
+ if (pbit_to_gemport.size() > NUMBER_OF_PBITS) {
OPENOLT_LOG(ERROR, openolt_log_id, "invalid pbit-to-gemport map size=%lu", pbit_to_gemport.size())
return ::Status(grpc::StatusCode::OUT_OF_RANGE, "pbit-to-gemport-map-len-invalid-for-flow-replication");
}
- uint16_t flow_ids[NUMBER_OF_REPLICATED_FLOWS];
+ uint16_t flow_ids[MAX_NUMBER_OF_REPLICATED_FLOWS];
device_flow dev_fl;
- if (get_flow_ids(NUMBER_OF_REPLICATED_FLOWS, flow_ids)) {
+ if (get_flow_ids(pbit_to_gemport.size(), flow_ids)) {
uint8_t cnt = 0;
dev_fl.is_flow_replicated = true;
dev_fl.voltha_flow_id = voltha_flow_id;
dev_fl.symmetric_voltha_flow_id = INVALID_FLOW_ID; // invalid
+ dev_fl.total_replicated_flows = pbit_to_gemport.size();
dev_fl.flow_type = flow_type;
for (google::protobuf::Map<unsigned int, unsigned int>::const_iterator it=pbit_to_gemport.begin(); it!=pbit_to_gemport.end(); it++) {
dev_fl.params[cnt].flow_id = flow_ids[cnt];
@@ -1766,7 +1772,7 @@
}
}
// Free up all the flow IDs on failure
- free_flow_ids(NUMBER_OF_REPLICATED_FLOWS, flow_ids);
+ free_flow_ids(pbit_to_gemport.size(), flow_ids);
return st;
}
cnt++;
@@ -2198,7 +2204,7 @@
std::string flow_type = dev_fl->flow_type;
if (dev_fl->is_flow_replicated) {
// Note: Here we are ignoring FlowRemove failures
- for (int i=0; i<NUMBER_OF_REPLICATED_FLOWS; i++) {
+ for (int i=0; i<dev_fl->total_replicated_flows; i++) {
st = FlowRemove_(dev_fl->params[i].flow_id, flow_type);
if (st.error_code() == grpc::StatusCode::OK) {
free_flow_id(dev_fl->params[i].flow_id);
diff --git a/agent/src/core_data.h b/agent/src/core_data.h
index 0168f69..ea17d37 100644
--- a/agent/src/core_data.h
+++ b/agent/src/core_data.h
@@ -184,9 +184,10 @@
} device_flow_params;
typedef struct device_flow {
- bool is_flow_replicated; // If true number of replicated flows is to the NUMBER_OF_PBITS, else 1
+ bool is_flow_replicated; // If true number of replicated flows cannot be more than NUMBER_OF_PBITS (i.e., 8)
std::string flow_type; // upstream, downstream, multicast
- device_flow_params params[NUMBER_OF_REPLICATED_FLOWS]; // A voltha-flow cannot be replicated more than the number of pbits
+ device_flow_params params[MAX_NUMBER_OF_REPLICATED_FLOWS]; // There can be a total of MAX_NUMBER_OF_REPLICATED_FLOWS at max
+ uint8_t total_replicated_flows;
uint64_t voltha_flow_id; // This is corresponding voltha flow-id.
uint64_t symmetric_voltha_flow_id; // Is not applicable for trap-to-controller voltha flows.
// 0 value means invalid or not-applicable