VOL-767 Enable/Disable PON interface

Change-Id: I5dde5ec5c9d90fc509a4c93abb848be3d5b6dd86
diff --git a/protos/openolt.proto b/protos/openolt.proto
index 56d87f4..0cb6192 100644
--- a/protos/openolt.proto
+++ b/protos/openolt.proto
@@ -60,6 +60,19 @@
         };
     }
 
+    rpc EnablePonIf(Interface) returns (Empty) {
+        option (google.api.http) = {
+            post: "/v1/EnablePonIf"
+            body: "*"
+        };
+    }
+
+    rpc DisablePonIf(Interface) returns (Empty) {
+        option (google.api.http) = {
+            post: "/v1/DisablePonIf"
+            body: "*"
+        };
+    }
 
     rpc EnableIndication(Empty) returns (stream Indication) {}
 }
@@ -136,6 +149,10 @@
     bytes pkt = 4;
 }
 
+message Interface {
+    fixed32 intf_id = 1;
+}
+
 message Heartbeat {
     fixed32 heartbeat_signature = 1;
 }
diff --git a/src/core.cc b/src/core.cc
index c77048c..5bf3a62 100644
--- a/src/core.cc
+++ b/src/core.cc
@@ -71,6 +71,24 @@
     return Status::OK;
 }
 
+Status DisablePonIf_(uint32_t intf_id) {
+    bcmbal_interface_cfg interface_obj;
+    bcmbal_interface_key interface_key;
+
+    interface_key.intf_id = intf_id;
+    interface_key.intf_type = BCMBAL_INTF_TYPE_PON;
+
+    BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
+    BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_DOWN);
+
+    if (bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr))) {
+        std::cout << "ERROR: Failed to disable PON interface: " << intf_id << std::endl;
+        return Status(grpc::StatusCode::INTERNAL, "Failed to disable PON interface");
+    }
+
+    return Status::OK;
+}
+
 Status ActivateOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific) {
 
diff --git a/src/core.h b/src/core.h
index ad92cf3..38e02ba 100644
--- a/src/core.h
+++ b/src/core.h
@@ -26,6 +26,7 @@
 Status ActivateOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific);
 Status EnablePonIf_(uint32_t intf_id);
+Status DisablePonIf_(uint32_t intf_id);
 Status OmciMsgOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt);
 Status OnuPacketOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt);
 Status UplinkPacketOut_(uint32_t intf_id, const std::string pkt);
diff --git a/src/server.cc b/src/server.cc
index ae2cd56..606e9cb 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -132,6 +132,21 @@
         return Status::OK;
     }
 
+    Status EnablePonIf(
+            ServerContext* context,
+            const openolt::Interface* request,
+            openolt::Empty* response) override {
+
+        return EnablePonIf_(request->intf_id());
+    }
+
+    Status DisablePonIf(
+            ServerContext* context,
+            const openolt::Interface* request,
+            openolt::Empty* response) override {
+
+        return DisablePonIf_(request->intf_id());
+    }
 
 };