[VOL-1624]
Tech profile changes in openolt adapter 2.x.

[VOL-1623]
Support for meter update

Change-Id: I98f2dd9848ce2b330dfbc536b06559c071e8cd8c
diff --git a/protos/voltha_protos/logical_device.proto b/protos/voltha_protos/logical_device.proto
index f5e2fd8..84e7ec5 100644
--- a/protos/voltha_protos/logical_device.proto
+++ b/protos/voltha_protos/logical_device.proto
@@ -55,6 +55,10 @@
     // flow groups configured on the logical device
     openflow_13.FlowGroups flow_groups = 130 [(child_node) = {}];
 
+    // meters configured on the logical device
+    openflow_13.Meters meters = 131 [(child_node) = {}];
+
+
 }
 
 message LogicalDevices {
diff --git a/protos/voltha_protos/openflow_13.proto b/protos/voltha_protos/openflow_13.proto
index 6b3ba8a..2a0eec2 100644
--- a/protos/voltha_protos/openflow_13.proto
+++ b/protos/voltha_protos/openflow_13.proto
@@ -2092,6 +2092,12 @@
     uint32    max_color = 5;    /* Maximum color value */
 };
 
+message ofp_meter_entry {
+    ofp_meter_config config=1 [(common.yang_inline_node).id = 'config',
+                              (common.yang_inline_node).type = 'openflow_13-ofp_meter_config'];
+    ofp_meter_stats stats=2;
+}
+
 /* Body for ofp_multipart_request/reply of type OFPMP_EXPERIMENTER. */
 message ofp_experimenter_multipart_header {
     uint32 experimenter = 1;   /* Experimenter ID which takes the same form
@@ -2268,7 +2274,7 @@
 }
 
 message Meters {
-    repeated ofp_meter_config items = 1;
+    repeated ofp_meter_entry items = 1;
 }
 
 message FlowGroups {
diff --git a/protos/voltha_protos/openolt.proto b/protos/voltha_protos/openolt.proto
index 57ea9c2..eb37d98 100644
--- a/protos/voltha_protos/openolt.proto
+++ b/protos/voltha_protos/openolt.proto
@@ -18,6 +18,7 @@
 
 package openolt;
 import "google/api/annotations.proto";
+import public "voltha_protos/tech_profile.proto";
 
 service Openolt {
 
@@ -133,16 +134,30 @@
         };
     }
 
-    rpc CreateTconts(Tconts) returns (Empty) {
+    rpc CreateTrafficSchedulers(tech_profile.TrafficSchedulers) returns (Empty) {
         option (google.api.http) = {
-            post: "/v1/CreateTconts"
+            post: "/v1/CreateTrafficSchedulers"
             body: "*"
         };
     }
 
-    rpc RemoveTconts(Tconts) returns (Empty) {
+    rpc RemoveTrafficSchedulers(tech_profile.TrafficSchedulers) returns (Empty) {
         option (google.api.http) = {
-            post: "/v1/RemoveTconts"
+            post: "/v1/RemoveTrafficSchedulers"
+            body: "*"
+        };
+    }
+
+    rpc CreateTrafficQueues(tech_profile.TrafficQueues) returns (Empty) {
+        option (google.api.http) = {
+            post: "/v1/CreateTrafficQueues"
+            body: "*"
+        };
+    }
+
+    rpc RemoveTrafficQueues(tech_profile.TrafficQueues) returns (Empty) {
+        option (google.api.http) = {
+            post: "/v1/RemoveTrafficQueues"
             body: "*"
         };
     }
@@ -250,6 +265,7 @@
     fixed32 intf_id = 1;
     fixed32 onu_id = 2;
     fixed32 port_no = 4;
+    fixed32 gemport_id = 5;
     bytes pkt = 3;
 }
 
@@ -361,6 +377,7 @@
     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
+    fixed32 group_id = 14;
 }
 
 message SerialNumber {
@@ -467,93 +484,4 @@
     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 {}
diff --git a/protos/voltha_protos/tech_profile.proto b/protos/voltha_protos/tech_profile.proto
new file mode 100644
index 0000000..8aa74b4
--- /dev/null
+++ b/protos/voltha_protos/tech_profile.proto
@@ -0,0 +1,132 @@
+// Copyright (c) 2018 Open Networking Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at:
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+option go_package = "github.com/opencord/voltha-protos/go/tech_profile";
+
+package tech_profile;
+import "google/api/annotations.proto";
+
+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 SchedulerConfig {
+    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 TrafficScheduler {
+    Direction direction = 1;
+    fixed32 alloc_id = 2; // valid only if “direction == Upstream ”
+    SchedulerConfig scheduler = 3;
+    TrafficShapingInfo traffic_shaping_info = 4;
+    fixed32 parent_sched_id = 5; // Used with HQoS, points to interface sched if not present
+}
+
+message TrafficSchedulers {
+    fixed32 intf_id = 1;
+    fixed32 onu_id = 2;
+    fixed32 uni_id = 4;
+    fixed32 port_no = 5;
+    repeated TrafficScheduler traffic_scheds = 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 TrafficQueue {
+    Direction direction = 1;
+    fixed32 gemport_id = 2;
+    string pbit_map = 3;
+    bool aes_encryption = 4;
+    SchedulingPolicy sched_policy = 5; // This can be SP or WRR
+    fixed32 priority = 6;
+    fixed32 weight = 7;
+    DiscardPolicy discard_policy = 8;
+    DiscardConfig discard_config = 9;
+    TrafficShapingInfo shaping_info = 10; // Not used in the current version
+    fixed32 scheduler_id = 11; // Ties the queue to a scheduler
+}
+
+message TrafficQueues {
+    fixed32 intf_id = 1;
+    fixed32 onu_id = 2;
+    fixed32 uni_id = 4;
+    fixed32 port_no = 5;
+    repeated TrafficQueue traffic_queues = 6;
+}
diff --git a/protos/voltha_protos/voltha.proto b/protos/voltha_protos/voltha.proto
index 673fddd..a6f9ee0 100644
--- a/protos/voltha_protos/voltha.proto
+++ b/protos/voltha_protos/voltha.proto
@@ -282,12 +282,13 @@
         };
     }
 
-    // Get all meter stats for logical device
-    rpc GetMeterStatsOfLogicalDevice(common.ID)
-            returns(openflow_13.MeterStatsReply) {
+    // List all meters of a logical device
+    rpc ListLogicalDeviceMeters(common.ID) returns (openflow_13.Meters) {
         option (google.api.http) = {
-            get: "/api/v1/logical_devices/{id}/meters_stats"
+            get: "/api/v1/logical_devices/{id}/meters"
         };
+        option (common.yang_xml_tag).xml_tag = 'meters';
+        option (common.yang_xml_tag).list_items_name = 'items';
     }
 
     // List all flow groups of a logical device
@@ -600,5 +601,6 @@
     }
     rpc Subscribe (OfAgentSubscriber) returns (OfAgentSubscriber) {
     }
+
 }