Change agg_port_id to alloc_id and remove sched_id from openolt.proto

Change-Id: I83bac16bec9b2c4ac3de71360ddd1d15444d3126
diff --git a/common/core.h b/common/core.h
index feb33bc..78cbb0f 100644
--- a/common/core.h
+++ b/common/core.h
@@ -31,12 +31,12 @@
 Status Enable_(int argc, char *argv[]);
 Status ActivateOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific, uint32_t pir,
-    uint32_t agg_port_id, uint32_t alloc_id);
+    uint32_t alloc_id);
 Status DeactivateOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific);
 Status DeleteOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific,
-    uint32_t agg_port_id, uint32_t alloc_id);
+    uint32_t alloc_id);
 Status EnablePonIf_(uint32_t intf_id);
 Status DisablePonIf_(uint32_t intf_id);
 Status EnableUplinkIf_(uint32_t intf_id);
diff --git a/common/server.cc b/common/server.cc
index 433ecd5..e40f0cf 100644
--- a/common/server.cc
+++ b/common/server.cc
@@ -68,8 +68,7 @@
             request->onu_id(),
             ((request->serial_number()).vendor_id()).c_str(),
             ((request->serial_number()).vendor_specific()).c_str(),
-            request->pir(), request->agg_port_id(),
-            request->sched_id());
+            request->pir(), request->alloc_id());
     }
 
     Status DeactivateOnu(
@@ -92,7 +91,7 @@
             request->onu_id(),
             ((request->serial_number()).vendor_id()).c_str(),
             ((request->serial_number()).vendor_specific()).c_str(),
-            request->agg_port_id(), request->sched_id());
+            request->alloc_id());
     }
 
     Status OmciMsgOut(
diff --git a/protos/openolt.proto b/protos/openolt.proto
index e9e8007..ac53e6b 100644
--- a/protos/openolt.proto
+++ b/protos/openolt.proto
@@ -218,8 +218,7 @@
     fixed32 onu_id = 2;
     SerialNumber serial_number = 3;
     fixed32 pir = 4;   // peak information rate assigned to onu
-    fixed32 agg_port_id = 5;
-    fixed32 sched_id = 6;
+    fixed32 alloc_id = 5;
 }
 
 message OmciMsg {
diff --git a/src/core.cc b/src/core.cc
index 2923b9d..10ba783 100644
--- a/src/core.cc
+++ b/src/core.cc
@@ -249,7 +249,7 @@
 
 Status ActivateOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific, uint32_t pir,
-    uint32_t agg_port_id, uint32_t sched_id) {
+    uint32_t alloc_id) {
 
     bcmbal_subscriber_terminal_cfg sub_term_obj = {};
     bcmbal_subscriber_terminal_key subs_terminal_key;
@@ -284,10 +284,15 @@
         return bcm_to_grpc_err(err, "Failed to enable ONU");
     }
 
-    if (agg_port_id != 0) {
-        return SchedAdd_(intf_id, onu_id, agg_port_id, sched_id, pir);
+    if (alloc_id != 0) {
+        // Use alloc_id as both agg_port_id and sched_id.
+        // Additional Notes:
+        // The agg_port_id is a BAL nomenclature for alloc_id (TCONT identifier).
+        // The TCONT is associated with its own DBA scheduler with a unique scheduler ID.
+        // Use the alloc_id itself as the DBA Scheduler identifier (sched_id).
+        return SchedAdd_(intf_id, onu_id, alloc_id, alloc_id, pir);
     } else {
-        return SchedAdd_(intf_id, onu_id, mk_agg_port_id(intf_id, onu_id), sched_id, pir);
+        return SchedAdd_(intf_id, onu_id, mk_agg_port_id(intf_id, onu_id), mk_sched_id(intf_id, onu_id), pir);
     }
 
     //return Status::OK;
@@ -318,7 +323,7 @@
 
 Status DeleteOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific,
-    uint32_t agg_port_id, uint32_t sched_id) {
+    uint32_t alloc_id) {
 
     // Need to deactivate before removing it (BAL rules)
 
@@ -328,10 +333,15 @@
     // Without sleep the race condition is lost by ~ 20 ms
     std::this_thread::sleep_for(std::chrono::milliseconds(100));
 
-    if (agg_port_id != 0) {
-        SchedRemove_(intf_id, onu_id, agg_port_id, sched_id);
+    if (alloc_id != 0) {
+        // Use alloc_id as both agg_port_id and sched_id
+        // Additional Notes:
+        // The agg_port_id is a BAL nomenclature for alloc_id (TCONT identifier).
+        // The TCONT is associated with its own DBA scheduler with a unique scheduler ID.
+        // Use the alloc_id itself as the DBA Scheduler identifier (sched_id).
+        SchedRemove_(intf_id, onu_id, alloc_id, alloc_id);
     } else {
-        SchedRemove_(intf_id, onu_id, mk_agg_port_id(intf_id, onu_id), sched_id);
+        SchedRemove_(intf_id, onu_id, mk_agg_port_id(intf_id, onu_id), mk_sched_id(intf_id, onu_id));
     }
 
     bcmos_errno err = BCM_ERR_OK;