VOL-4499: Update 'device_flow' struct to have the flow_type. This
will enable the voltha openolt adapter to just send the voltha-flow-id
and the agent can retrieve the flow_type automatically from the
device_flow struct.

VOL-4520: Allow configurability of MAC Device Activation delay time.
With BAL3.10.2.2 it is observed the Edgecore OLTs sometimes need more
time to do the Maple/Aspen download procedure as part of MAC activation.
The current 200ms delay has recomendded to increase to 2s as a
workaround by Edgecore (ticket #19146). This patch makes this delay
configurable on a per platform basis.

Version bumped to 3.6.3

Change-Id: I3bac3af423aa6374c10302519cd21a481d5a4a86
diff --git a/VERSION b/VERSION
index b727628..4a788a0 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.6.2
+3.6.3
diff --git a/agent/device/asfvolt16/vendor.h b/agent/device/asfvolt16/vendor.h
index 7cadd9b..f63142e 100644
--- a/agent/device/asfvolt16/vendor.h
+++ b/agent/device/asfvolt16/vendor.h
@@ -42,4 +42,6 @@
 #define MAX_FLOW_ID FLOW_ID_END
 #define INVALID_FLOW_ID 0
 
+#define MAC_DEVICE_ACTIVATION_DELAY 2000000 // in microseconds
+
 #endif
diff --git a/agent/device/asgvolt64/vendor.h b/agent/device/asgvolt64/vendor.h
index 3b5c844..89a4bff 100644
--- a/agent/device/asgvolt64/vendor.h
+++ b/agent/device/asgvolt64/vendor.h
@@ -42,4 +42,6 @@
 #define MAX_FLOW_ID FLOW_ID_END
 #define INVALID_FLOW_ID 0
 
+#define MAC_DEVICE_ACTIVATION_DELAY 2000000 // in microseconds
+
 #endif
diff --git a/agent/device/generic/vendor.h b/agent/device/generic/vendor.h
index 4a94df1..8d2a5a0 100644
--- a/agent/device/generic/vendor.h
+++ b/agent/device/generic/vendor.h
@@ -36,4 +36,6 @@
 #define MAX_FLOW_ID 65535
 #define INVALID_FLOW_ID 0
 
+#define MAC_DEVICE_ACTIVATION_DELAY 200000 // in microseconds
+
 #endif
diff --git a/agent/device/rlt-1600g-w/vendor.h b/agent/device/rlt-1600g-w/vendor.h
index a126063..2a62bcb 100644
--- a/agent/device/rlt-1600g-w/vendor.h
+++ b/agent/device/rlt-1600g-w/vendor.h
@@ -42,4 +42,6 @@
 #define MAX_FLOW_ID FLOW_ID_END
 #define INVALID_FLOW_ID 0
 
+#define MAC_DEVICE_ACTIVATION_DELAY 200000 // in microseconds
+
 #endif
diff --git a/agent/device/rlt-1600x-w/vendor.h b/agent/device/rlt-1600x-w/vendor.h
index 80410a3..ec6b5c6 100644
--- a/agent/device/rlt-1600x-w/vendor.h
+++ b/agent/device/rlt-1600x-w/vendor.h
@@ -42,4 +42,6 @@
 #define MAX_FLOW_ID FLOW_ID_END
 #define INVALID_FLOW_ID 0
 
+#define MAC_DEVICE_ACTIVATION_DELAY 200000 // in microseconds
+
 #endif
diff --git a/agent/device/rlt-3200g-w/vendor.h b/agent/device/rlt-3200g-w/vendor.h
index 761bb53..b55cc02 100644
--- a/agent/device/rlt-3200g-w/vendor.h
+++ b/agent/device/rlt-3200g-w/vendor.h
@@ -42,4 +42,6 @@
 #define MAX_FLOW_ID FLOW_ID_END
 #define INVALID_FLOW_ID 0
 
+#define MAC_DEVICE_ACTIVATION_DELAY 200000 // in microseconds
+
 #endif
diff --git a/agent/device/sim/vendor.h b/agent/device/sim/vendor.h
index 3cecd88..1dbc9cd 100644
--- a/agent/device/sim/vendor.h
+++ b/agent/device/sim/vendor.h
@@ -42,4 +42,6 @@
 #define MAX_FLOW_ID FLOW_ID_END
 #define INVALID_FLOW_ID 0
 
+#define MAC_DEVICE_ACTIVATION_DELAY 200000 // in microseconds
+
 #endif
diff --git a/agent/src/core_api_handler.cc b/agent/src/core_api_handler.cc
index 6fb6ba2..7bd9908 100644
--- a/agent/src/core_api_handler.cc
+++ b/agent/src/core_api_handler.cc
@@ -454,7 +454,7 @@
                             return Status(grpc::StatusCode::INTERNAL, "Failed to activate all PON ports");
                         }
                     }
-                    bcmos_usleep(200000);
+                    bcmos_usleep(MAC_DEVICE_ACTIVATION_DELAY);
                 }
                 else {
                     OPENOLT_LOG(WARNING, openolt_log_id, "PON device %d already connected\n", dev);
@@ -1632,6 +1632,7 @@
             dev_fl.is_flow_replicated = false;
             dev_fl.symmetric_voltha_flow_id = symmetric_voltha_flow_id;
             dev_fl.voltha_flow_id = voltha_flow_id;
+            dev_fl.flow_type = flow_type;
             memcpy(dev_fl.params, dev_fl_symm_params, sizeof(device_flow_params));
             // update voltha flow to cache
             update_voltha_flow_to_cache(voltha_flow_id, dev_fl);
@@ -1664,6 +1665,7 @@
             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.flow_type = flow_type;
             memcpy(dev_fl.params, dev_fl_symm_params, sizeof(device_flow_params)*NUMBER_OF_REPLICATED_FLOWS);
             // update voltha flow to cache
             update_voltha_flow_to_cache(voltha_flow_id, dev_fl);
@@ -1685,6 +1687,7 @@
                 dev_fl.is_flow_replicated = false;
                 dev_fl.symmetric_voltha_flow_id = INVALID_FLOW_ID; // Invalid
                 dev_fl.voltha_flow_id = voltha_flow_id;
+                dev_fl.flow_type = flow_type;
                 dev_fl.params[0].flow_id = flow_id;
                 dev_fl.params[0].gemport_id = gemport_id;
                 dev_fl.params[0].pbit = classifier.o_pbits();
@@ -1708,6 +1711,7 @@
                 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.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];
                     dev_fl.params[cnt].pbit = it->first;
@@ -2138,7 +2142,6 @@
     int32_t onu_id = request->onu_id();
     int32_t uni_id = request->uni_id();
     uint32_t tech_profile_id = request->tech_profile_id();
-    const std::string flow_type = request->flow_type();
     uint64_t voltha_flow_id = request->flow_id();
     Status st;
 
@@ -2156,14 +2159,14 @@
     if (dev_fl->is_flow_replicated) {
         // Note: Here we are ignoring FlowRemove failures
         for (int i=0; i<NUMBER_OF_REPLICATED_FLOWS; i++) {
-            st = FlowRemove_(dev_fl->params[i].flow_id, flow_type);
+            st = FlowRemove_(dev_fl->params[i].flow_id, dev_fl->flow_type);
             if (st.error_code() == grpc::StatusCode::OK) {
                 free_flow_id(dev_fl->params[i].flow_id);
             }
         }
     } else {
         // Note: Here we are ignoring FlowRemove failures
-        st = FlowRemove_(dev_fl->params[0].flow_id, flow_type);
+        st = FlowRemove_(dev_fl->params[0].flow_id, dev_fl->flow_type);
         if (st.error_code() == grpc::StatusCode::OK) {
             free_flow_id(dev_fl->params[0].flow_id);
         }
@@ -2171,7 +2174,7 @@
     // remove the flow from cache on voltha flow removal
     remove_voltha_flow_from_cache(voltha_flow_id);
 
-    symmetric_datapath_flow_id_map_key key(access_intf_id, onu_id, uni_id, tech_profile_id, flow_type);
+    symmetric_datapath_flow_id_map_key key(access_intf_id, onu_id, uni_id, tech_profile_id, dev_fl->flow_type);
     // Remove onu-uni mapping for the pon-gem key
     bcmos_fastlock_lock(&symmetric_datapath_flow_id_lock);
     symmetric_datapath_flow_id_map.erase(key);
diff --git a/agent/src/core_data.h b/agent/src/core_data.h
index 576c248..d7405fb 100644
--- a/agent/src/core_data.h
+++ b/agent/src/core_data.h
@@ -191,6 +191,7 @@
                                        // 0 value means invalid or not-applicable
                                        // Applicable for bi-directional data path flows (one flow per direction)
                                        // Symmetric flows should share the same device_flow_id.
+    std::string flow_type; // upstream, downstream, multicast
 
 } device_flow;