Code to verify whether gem is already encrypted

Change-Id: I124b8a4ad3b4dce699890154acac3558a4ea9bd6
diff --git a/agent/src/core_utils.cc b/agent/src/core_utils.cc
index c2f3016..a80b8d6 100644
--- a/agent/src/core_utils.cc
+++ b/agent/src/core_utils.cc
@@ -1105,6 +1105,17 @@
     };
 
     BCMOLT_CFG_INIT(&cfg, itupon_gem, key);
+    BCMOLT_MSG_FIELD_GET(&cfg, encryption_mode);
+    err = bcmolt_cfg_get(dev_id, &cfg.hdr);
+    if (err != BCM_ERR_OK) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "GEM port get encryption_mode failed\n");
+        return bcm_to_grpc_err(err, "GEM port get encryption_mode failed");
+    }
+
+    if (cfg.data.encryption_mode == BCMOLT_CONTROL_STATE_ENABLE) {
+        OPENOLT_LOG(INFO, openolt_log_id, "gem port already encrypted = %d\n", gemport_id);
+        return Status::OK;
+    }
 
     bcmolt_control_state encryption_mode;
     encryption_mode = BCMOLT_CONTROL_STATE_ENABLE;