SEBA-397 Add support for mib upload of TCONT MEs.

Also update openolt.proto to match voltha master (compatible with voltha 1.6)

Change-Id: Ib7ac1a2cdea6e67c4e59fa25819790973d4630e6
diff --git a/core/grpc_service.go b/core/grpc_service.go
index 2175a75..05a3d85 100644
--- a/core/grpc_service.go
+++ b/core/grpc_service.go
@@ -89,6 +89,16 @@
 	return new(openolt.Empty), nil
 }
 
+func (s *Server) CreateTconts(c context.Context, tconts *openolt.Tconts) (*openolt.Empty, error) {
+	logger.Debug("OLT receives CreateTconts()")
+	return new(openolt.Empty), nil
+}
+
+func (s *Server) RemoveTconts(c context.Context, tconts *openolt.Tconts) (*openolt.Empty, error) {
+	logger.Debug("OLT receives RemoveTconts()")
+	return new(openolt.Empty), nil
+}
+
 func (s *Server) DeactivateOnu(c context.Context, onu *openolt.Onu) (*openolt.Empty, error) {
 	logger.Debug("OLT receives DeactivateONU()")
 	return new(openolt.Empty), nil
diff --git a/core/omci.go b/core/omci.go
index d74ef92..c9860c2 100644
--- a/core/omci.go
+++ b/core/omci.go
@@ -88,18 +88,19 @@
 	Content       OmciContent
 }
 
-const NumMibUploads byte = 18
+const NumMibUploads byte = 26
 
 type OnuKey struct {
 	IntfId, OnuId uint32
 }
 
 type OnuOmciState struct {
-	gemPortId    uint16
-	mibUploadCtr uint16
-	uniGInstance uint8
-	pptpInstance uint8
-	init         istate
+	gemPortId     uint16
+	mibUploadCtr  uint16
+	uniGInstance  uint8
+	tcontInstance uint8
+	pptpInstance  uint8
+	init          istate
 }
 
 type istate int
@@ -216,7 +217,7 @@
 }
 
 func NewOnuOmciState() *OnuOmciState {
-	return &OnuOmciState{gemPortId: 0, mibUploadCtr: 0, uniGInstance: 1, pptpInstance: 1}
+	return &OnuOmciState{gemPortId: 0, mibUploadCtr: 0, uniGInstance: 1, tcontInstance: 0, pptpInstance: 1}
 }
 
 func mibReset(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
@@ -255,10 +256,10 @@
 func mibUploadNext(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
 	var pkt []byte
 
-	logger.Debug("Omci MibUploadNext")
-
 	state := OnuOmciStateMap[key]
 
+	logger.Debug("Omci MibUploadNext %d", state.mibUploadCtr)
+
 	switch state.mibUploadCtr {
 	case 0:
 		// ONT Data (2)
@@ -335,33 +336,14 @@
 	case 8:
 		// Circuit Pack (6) - #8
 		pkt = []byte{
-			0x00, 0x0f, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x06, 0x01, 0x80, 0x00, 0x04, 0x00, 0x00,
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-	case 9:
-		// ANI-G
-		pkt = []byte{
-			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
-			0x01, 0x07, 0x80, 0x01, 0xff, 0xff, 0x01, 0x00,
-			0x08, 0x00, 0x30, 0x00, 0x00, 0x05, 0x09, 0x00,
-			0x00, 0xe0, 0x54, 0xff, 0xff, 0x00, 0x00, 0x0c,
-			0x63, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00,
-			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-	case 10, 11, 12, 13:
-		// UNI-G
-		pkt = []byte{
-			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
-			0x01, 0x08, 0x01, 0x01, 0xf8, 0x00, 0x00, 0x00,
-			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-		pkt[11] = state.uniGInstance // ME Instance
-		state.uniGInstance++
-	case 14, 15, 16, 17:
+	case 9, 10, 11, 12:
+		// PPTP (11)
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x0b, 0x01, 0x01, 0xff, 0xfe, 0x00, 0x2f,
@@ -371,6 +353,37 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 		pkt[11] = state.pptpInstance // ME Instance
 		state.pptpInstance++
+	case 13, 14, 15, 16, 17, 18, 19, 20:
+		// T-CONT (262)
+		pkt = []byte{
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+			0x01, 0x06, 0x80, 0x00, 0xe0, 0x00, 0xff, 0xff,
+			0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+		pkt[11] = state.tcontInstance // TCONT ME Instance
+		state.tcontInstance++
+	case 21:
+		// ANI-G (263)
+		pkt = []byte{
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+			0x01, 0x07, 0x80, 0x01, 0xff, 0xff, 0x01, 0x00,
+			0x08, 0x00, 0x30, 0x00, 0x00, 0x05, 0x09, 0x00,
+			0x00, 0xe0, 0x54, 0xff, 0xff, 0x00, 0x00, 0x0c,
+			0x63, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+	case 22, 23, 24, 25:
+		// UNI-G (264)
+		pkt = []byte{
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+			0x01, 0x08, 0x01, 0x01, 0xf8, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+		pkt[11] = state.uniGInstance // UNI-G ME Instance
+		state.uniGInstance++
 	default:
 		logger.Error("Invalid MibUpload request %d", state.mibUploadCtr)
 		return nil, errors.New("Invalid MibUpload request")
diff --git a/openolt.proto b/openolt.proto
index 60bab72..ddc8f74 100644
--- a/openolt.proto
+++ b/openolt.proto
@@ -130,6 +130,20 @@
         };
     }
 
+    rpc CreateTconts(Tconts) returns (Empty) {
+        option (google.api.http) = {
+            post: "/v1/CreateTconts"
+            body: "*"
+        };
+    }
+
+    rpc RemoveTconts(Tconts) returns (Empty) {
+        option (google.api.http) = {
+            post: "/v1/RemoveTconts"
+            body: "*"
+        };
+    }
+
     rpc EnableIndication(Empty) returns (stream Indication) {}
 }
 
@@ -203,6 +217,8 @@
     fixed32 intf_id = 1;
     fixed32 gemport_id = 2;
     fixed32 flow_id = 3;
+    fixed32 port_no = 6;
+    fixed64 cookie = 7;
     bytes pkt = 4;
 }
 
@@ -219,7 +235,6 @@
     fixed32 onu_id = 2;
     SerialNumber serial_number = 3;
     fixed32 pir = 4;   // peak information rate assigned to onu
-    fixed32 alloc_id = 5;
 }
 
 message OmciMsg {
@@ -231,6 +246,7 @@
 message OnuPacket {
     fixed32 intf_id = 1;
     fixed32 onu_id = 2;
+    fixed32 port_no = 4;
     bytes pkt = 3;
 }
 
@@ -244,6 +260,8 @@
     string model = 2;
     string hardware_version = 3;
     string firmware_version = 4;
+    string device_id = 16;
+    string device_serial_number = 17;
 
     // Total number of pon intf ports on the device
     fixed32 pon_ports = 12;
@@ -278,7 +296,7 @@
 
             enum SharingType {
                 DEDICATED_PER_INTF = 0;
-                SHARED_BY_ALL_INTF_ALL_TECH = 1; // Shared across all interfaces in all technologiesi in all ranges
+                SHARED_BY_ALL_INTF_ALL_TECH = 1; // Shared across all interfaces in all technologies in all ranges
                 SHARED_BY_ALL_INTF_SAME_TECH = 2; // Shared across all interfaces of the same technology used in this range
             }
 
@@ -329,6 +347,7 @@
 message Flow {
     sfixed32 access_intf_id = 1;
     sfixed32 onu_id = 2;
+    sfixed32 uni_id = 11;
     fixed32 flow_id = 3;
     string flow_type = 4;	// upstream, downstream, broadcast, multicast
     sfixed32 alloc_id = 10;
@@ -337,6 +356,8 @@
     Classifier classifier = 7;
     Action action = 8;
     sfixed32 priority = 9;
+    fixed64 cookie = 12; // must be provided for any flow with trap_to_host action. Returned in PacketIndication
+    fixed32 port_no = 13; // must be provided for any flow with trap_to_host action. Returned in PacketIndication
 }
 
 message SerialNumber {
@@ -443,5 +464,93 @@
     fixed32 onu_id = 2;
 }
 
+enum Direction {
+    UPSTREAM = 0;
+    DOWNSTREAM = 1;
+    BIDIRECTIONAL = 2;
+}
+
+enum SchedulingPolicy {
+    WRR = 0;
+    StrictPriority = 1;
+    Hybrid = 2;
+}
+
+enum AdditionalBW {
+    AdditionalBW_None = 0;
+    AdditionalBW_NA = 1;
+    AdditionalBW_BestEffort = 2;
+    AdditionalBW_Auto = 3;
+}
+
+enum DiscardPolicy {
+    TailDrop = 0;
+    WTailDrop = 1;
+    Red = 2;
+    WRed = 3;
+}
+
+enum InferredAdditionBWIndication {
+    InferredAdditionBWIndication_None = 0;
+    InferredAdditionBWIndication_Assured = 1;
+    InferredAdditionBWIndication_BestEffort = 2;
+}
+
+message Scheduler {
+    Direction direction = 1;
+    AdditionalBW additional_bw = 2; // Valid on for “direction == Upstream”.
+    fixed32 priority = 3;
+    fixed32 weight = 4;
+    SchedulingPolicy sched_policy = 5;
+}
+
+message TrafficShapingInfo {
+    fixed32 cir = 1;
+    fixed32 cbs = 2;
+    fixed32 pir = 3;
+    fixed32 pbs = 4;
+    fixed32 gir = 5; // only if “direction == Upstream ”
+    InferredAdditionBWIndication add_bw_ind = 6; // only if “direction == Upstream”
+}
+
+message Tcont {
+    Direction direction = 1;
+    fixed32 alloc_id = 2; // valid only if “direction == Upstream ”
+    Scheduler scheduler = 3;
+    TrafficShapingInfo traffic_shaping_info = 4;
+}
+
+message Tconts {
+    fixed32 intf_id = 1;
+    fixed32 onu_id = 2;
+    fixed32 uni_id = 4;
+    fixed32 port_no = 5;
+    repeated Tcont tconts = 3;
+}
+
+message TailDropDiscardConfig {
+    fixed32 queue_size = 1;
+}
+
+message RedDiscardConfig {
+    fixed32 min_threshold = 1;
+    fixed32 max_threshold = 2;
+    fixed32 max_probability = 3;
+}
+
+message WRedDiscardConfig {
+    RedDiscardConfig green = 1;
+    RedDiscardConfig yellow = 2;
+    RedDiscardConfig red = 3;
+}
+
+message DiscardConfig {
+    DiscardPolicy discard_policy = 1;
+    oneof discard_config {
+        TailDropDiscardConfig tail_drop_discard_config = 2;
+        RedDiscardConfig red_discard_config = 3;
+        WRedDiscardConfig wred_discard_config = 4;
+    }
+}
 
 message Empty {}