Gemport config is synchronous in XGSPON hence wait for gemport cfg complete indication is enabled only for GPON.

Change-Id: I04dc4b3c9d743e81c51a3159a23fec9d912aa841
diff --git a/VERSION b/VERSION
index 4f5e697..1cf8253 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.4.5
+3.4.6
diff --git a/agent/src/core_api_handler.cc b/agent/src/core_api_handler.cc
index 14d3386..0e195d9 100644
--- a/agent/src/core_api_handler.cc
+++ b/agent/src/core_api_handler.cc
@@ -2075,7 +2075,7 @@
     */
     if (aes_enabled && (access_intf_id >= 0) && (gemport_id >= GEM_PORT_ID_START) && (key.flow_type == BCMOLT_FLOW_TYPE_DOWNSTREAM)) {
         OPENOLT_LOG(INFO, openolt_log_id, "Setting encryption on pon = %d gem_port = %d through flow_id = %d\n", access_intf_id, gemport_id, flow_id);
-        enable_encryption_for_gem_port(access_intf_id, gemport_id);
+        enable_encryption_for_gem_port(access_intf_id, gemport_id, board_technology);
     } else {
         OPENOLT_LOG(WARNING, openolt_log_id, "Flow config for flow_id = %d is not suitable for setting downstream encryption on pon = %d gem_port = %d. No action taken.\n", flow_id, access_intf_id, gemport_id);
     }
@@ -2764,7 +2764,7 @@
     }
 
     if (direction == upstream || direction == downstream) {
-        Status st = install_gem_port(access_intf_id, onu_id, uni_id, gemport_id);
+        Status st = install_gem_port(access_intf_id, onu_id, uni_id, gemport_id, board_technology);
         if (st.error_code() != grpc::StatusCode::ALREADY_EXISTS && st.error_code() != grpc::StatusCode::OK) {
             OPENOLT_LOG(ERROR, openolt_log_id, "failed to created gemport=%d, access_intf=%d, onu_id=%d\n", gemport_id, access_intf_id, onu_id);
             return BCM_ERR_INTERNAL;
@@ -2847,7 +2847,7 @@
     // upstream/downstream queue (see CreateQueue function) and it makes sense to delete them when remove the queues.
     // For multicast case we do not manage the install/remove of gem port in agent application. It is managed by BAL.
     if (direction == upstream || direction == downstream) {
-        Status st = remove_gem_port(access_intf_id, onu_id, uni_id, gemport_id);
+        Status st = remove_gem_port(access_intf_id, onu_id, uni_id, gemport_id, board_technology);
         if (st.error_code() != grpc::StatusCode::OK) {
             OPENOLT_LOG(ERROR, openolt_log_id, "failed to remove gemport=%d, access_intf=%d, onu_id=%d\n", gemport_id, access_intf_id, onu_id);
             return BCM_ERR_INTERNAL;
diff --git a/agent/src/core_utils.cc b/agent/src/core_utils.cc
index 6c027d5..c2f3016 100644
--- a/agent/src/core_utils.cc
+++ b/agent/src/core_utils.cc
@@ -953,7 +953,7 @@
     return err;
 }
 
-Status install_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id) {
+Status install_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id, std::string board_technology) {
     gemport_status_map_key_tuple gem_status_key(intf_id, onu_id, uni_id, gemport_id);
 
     bcmos_fastlock_lock(&data_lock);
@@ -1008,10 +1008,12 @@
     }
 
 #ifndef SCALE_AND_PERF
-    err = wait_for_gem_action(intf_id, gemport_id, GEM_OBJECT_CREATE);
-    if (err) {
-        OPENOLT_LOG(ERROR, openolt_log_id, "failed to install gem_port = %d err = %s\n", gemport_id, bcmos_strerror(err));
-        return bcm_to_grpc_err(err, "Access_Control set ITU PON Gem port failed");
+    if (board_technology == "GPON") {
+        err = wait_for_gem_action(intf_id, gemport_id, GEM_OBJECT_CREATE);
+        if (err) {
+            OPENOLT_LOG(ERROR, openolt_log_id, "failed to install gem_port = %d err = %s\n", gemport_id, bcmos_strerror(err));
+            return bcm_to_grpc_err(err, "Access_Control set ITU PON Gem port failed");
+        }
     }
 #endif
 
@@ -1024,7 +1026,7 @@
     return Status::OK;
 }
 
-Status remove_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id) {
+Status remove_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id, std::string board_technology) {
     gemport_status_map_key_tuple gem_status_key(intf_id, onu_id, uni_id, gemport_id);
 
     bcmos_fastlock_lock(&data_lock);
@@ -1053,31 +1055,33 @@
         return bcm_to_grpc_err(err, "Access_Control clear ITU PON Gem port failed");
     }
 
-    err = get_pon_interface_status((bcmolt_interface)intf_id, &state, &los_status);
-    if (err == BCM_ERR_OK) {
-        if (state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING && los_status == BCMOLT_STATUS_OFF) {
+    if (board_technology == "GPON") {
+        err = get_pon_interface_status((bcmolt_interface)intf_id, &state, &los_status);
+        if (err == BCM_ERR_OK) {
+            if (state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING && los_status == BCMOLT_STATUS_OFF) {
 #ifndef SCALE_AND_PERF
-            OPENOLT_LOG(INFO, openolt_log_id, "PON interface: %d is enabled and LoS status is OFF, waiting for gem cfg clear response\n",
-                intf_id);
-            err = wait_for_gem_action(intf_id, gemport_id, GEM_OBJECT_DELETE);
-            if (err) {
-                OPENOLT_LOG(ERROR, openolt_log_id, "failed to remove gem_port = %d err = %s\n", gemport_id, bcmos_strerror(err));
-                return bcm_to_grpc_err(err, "Access_Control clear ITU PON Gem port failed");
-            }
+                OPENOLT_LOG(INFO, openolt_log_id, "PON interface: %d is enabled and LoS status is OFF, waiting for gem cfg clear response\n",
+                    intf_id);
+                err = wait_for_gem_action(intf_id, gemport_id, GEM_OBJECT_DELETE);
+                if (err) {
+                    OPENOLT_LOG(ERROR, openolt_log_id, "failed to remove gem_port = %d err = %s\n", gemport_id, bcmos_strerror(err));
+                    return bcm_to_grpc_err(err, "Access_Control clear ITU PON Gem port failed");
+                }
 #endif
+            }
+            else if (state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING && los_status == BCMOLT_STATUS_ON) {
+                OPENOLT_LOG(INFO, openolt_log_id, "PON interface: %d is enabled but LoS status is ON, not waiting for gem cfg clear response\n",
+                    intf_id);
+            }
+            else if (state == BCMOLT_INTERFACE_STATE_INACTIVE) {
+                OPENOLT_LOG(INFO, openolt_log_id, "PON interface: %d is disabled, not waiting for gem cfg clear response\n",
+                    intf_id);
+            }
+        } else {
+            OPENOLT_LOG(ERROR, openolt_log_id, "Failed to fetch PON interface status, intf_id = %d, err = %s\n",
+                intf_id, bcmos_strerror(err));
+            return bcm_to_grpc_err(err, "Access_Control clear ITU PON Gem port failed");
         }
-        else if (state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING && los_status == BCMOLT_STATUS_ON) {
-            OPENOLT_LOG(INFO, openolt_log_id, "PON interface: %d is enabled but LoS status is ON, not waiting for gem cfg clear response\n",
-                intf_id);
-        }
-        else if (state == BCMOLT_INTERFACE_STATE_INACTIVE) {
-            OPENOLT_LOG(INFO, openolt_log_id, "PON interface: %d is disabled, not waiting for gem cfg clear response\n",
-                intf_id);
-        }
-    } else {
-        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to fetch PON interface status, intf_id = %d, err = %s\n",
-            intf_id, bcmos_strerror(err));
-        return bcm_to_grpc_err(err, "Access_Control clear ITU PON Gem port failed");
     }
 
     OPENOLT_LOG(INFO, openolt_log_id, "gem port removed successfully = %d\n", gemport_id);
@@ -1092,7 +1096,7 @@
     return Status::OK;
 }
 
-Status enable_encryption_for_gem_port(int32_t intf_id, int32_t gemport_id) {
+Status enable_encryption_for_gem_port(int32_t intf_id, int32_t gemport_id, std::string board_technology) {
     bcmos_errno err;
     bcmolt_itupon_gem_cfg cfg;
     bcmolt_itupon_gem_key key = {
@@ -1114,10 +1118,12 @@
     }
 
 #ifndef SCALE_AND_PERF
-    err = wait_for_gem_action(intf_id, gemport_id, GEM_OBJECT_ENCRYPT);
-    if (err) {
-        OPENOLT_LOG(ERROR, openolt_log_id, "failed to enable gemport encryption, gem_port = %d err = %s\n", gemport_id, bcmos_strerror(err));
-        return bcm_to_grpc_err(err, "Access_Control ITU PON Gem port encryption failed");
+    if (board_technology == "GPON") {
+        err = wait_for_gem_action(intf_id, gemport_id, GEM_OBJECT_ENCRYPT);
+        if (err) {
+            OPENOLT_LOG(ERROR, openolt_log_id, "failed to enable gemport encryption, gem_port = %d err = %s\n", gemport_id, bcmos_strerror(err));
+            return bcm_to_grpc_err(err, "Access_Control ITU PON Gem port encryption failed");
+        }
     }
 #endif
 
diff --git a/agent/src/core_utils.h b/agent/src/core_utils.h
index a7a2295..e9ad817 100644
--- a/agent/src/core_utils.h
+++ b/agent/src/core_utils.h
@@ -93,9 +93,9 @@
 unsigned NumNniIf_();
 unsigned NumPonIf_();
 bcmos_errno get_nni_interface_status(bcmolt_interface id, bcmolt_interface_state *state);
-Status install_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id);
-Status remove_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id);
-Status enable_encryption_for_gem_port(int32_t intf_id, int32_t gemport_id);
+Status install_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id, std::string board_technology);
+Status remove_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id, std::string board_technology);
+Status enable_encryption_for_gem_port(int32_t intf_id, int32_t gemport_id, std::string board_technology);
 Status update_acl_interface(int32_t intf_id, bcmolt_interface_type intf_type, uint32_t access_control_id,
                 bcmolt_members_update_command acl_cmd);
 Status install_acl(const acl_classifier_key acl_key);
diff --git a/agent/test/src/test_core.cc b/agent/test/src/test_core.cc
index 6df510b..58e7073 100644
--- a/agent/test/src/test_core.cc
+++ b/agent/test/src/test_core.cc
@@ -2886,7 +2886,7 @@
     pon_cfg.data.state = BCMOLT_INTERFACE_STATE_ACTIVE_WORKING;
     bcmos_errno olt_cfg_get_pon_stub_res = BCM_ERR_OK;
     EXPECT_GLOBAL_CALL(bcmolt_cfg_get__pon_intf_stub, bcmolt_cfg_get__pon_intf_stub(_, _))
-                     .WillOnce(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res)));
+                     .WillRepeatedly(DoAll(SetArg1ToBcmOltPonCfg(pon_cfg), Return(olt_cfg_get_pon_stub_res)));
 
     future<Status> future_res = async(launch::async, RemoveTrafficQueues_, traffic_queues);
     future<int> push_gem_cfg_complt = \