blob: 07926c5c626eaa39eb779644c08ec92c0ad0ee75 [file] [log] [blame]
Matt Jeanneretcab955f2019-04-10 15:45:57 -04001/*
2 * Copyright 2019-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package techprofile
17
18import (
Matteo Scandoloc858ab72020-11-16 12:44:51 -080019 "fmt"
Girish Gowdraa09aeab2020-09-14 16:30:52 -070020 "github.com/opencord/voltha-lib-go/v4/pkg/db"
Neha Sharmacc656962020-04-14 14:26:11 +000021 "time"
Matt Jeanneretcab955f2019-04-10 15:45:57 -040022)
23
24// tech profile default constants
25const (
26 defaultTechProfileName = "Default_1tcont_1gem_Profile"
27 DEFAULT_TECH_PROFILE_TABLE_ID = 64
28 defaultVersion = 1.0
29 defaultLogLevel = 0
30 defaultGemportsCount = 1
Matt Jeanneretcab955f2019-04-10 15:45:57 -040031 defaultPbits = "0b11111111"
32
Neha Sharmacc656962020-04-14 14:26:11 +000033 defaultKVStoreTimeout = 5 * time.Second //in seconds
Matt Jeanneretcab955f2019-04-10 15:45:57 -040034
35 // Tech profile path prefix in kv store
Matteo Scandoloc858ab72020-11-16 12:44:51 -080036 defaultKVPathPrefix = "%s/technology_profiles"
Matt Jeanneretcab955f2019-04-10 15:45:57 -040037
38 // Tech profile path in kv store
39 defaultTechProfileKVPath = "%s/%d" // <technology>/<tech_profile_tableID>
40
41 // Tech profile instance path in kv store
42 // Format: <technology>/<tech_profile_tableID>/<uni_port_name>
43 defaultTPInstanceKVPath = "%s/%d/%s"
44)
45
46//Tech-Profile JSON String Keys
47// NOTE: Tech profile templeate JSON file should comply with below keys
48const (
49 NAME = "name"
50 PROFILE_TYPE = "profile_type"
51 VERSION = "version"
52 NUM_GEM_PORTS = "num_gem_ports"
53 INSTANCE_CONTROL = "instance_control"
54 US_SCHEDULER = "us_scheduler"
55 DS_SCHEDULER = "ds_scheduler"
56 UPSTREAM_GEM_PORT_ATTRIBUTE_LIST = "upstream_gem_port_attribute_list"
57 DOWNSTREAM_GEM_PORT_ATTRIBUTE_LIST = "downstream_gem_port_attribute_list"
58 ONU = "onu"
59 UNI = "uni"
60 MAX_GEM_PAYLOAD_SIZE = "max_gem_payload_size"
61 DIRECTION = "direction"
62 ADDITIONAL_BW = "additional_bw"
63 PRIORITY = "priority"
64 Q_SCHED_POLICY = "q_sched_policy"
65 WEIGHT = "weight"
66 PBIT_MAP = "pbit_map"
67 DISCARD_CONFIG = "discard_config"
68 MAX_THRESHOLD = "max_threshold"
69 MIN_THRESHOLD = "min_threshold"
70 MAX_PROBABILITY = "max_probability"
71 DISCARD_POLICY = "discard_policy"
72 PRIORITY_Q = "priority_q"
73 SCHEDULING_POLICY = "scheduling_policy"
74 MAX_Q_SIZE = "max_q_size"
75 AES_ENCRYPTION = "aes_encryption"
Takahiro Suzuki2ba0e0b2020-06-05 14:23:03 -070076 // String Keys for EPON
77 EPON_ATTRIBUTE = "epon_attribute"
78 PACKAGE_TYPE = "package_type"
79 TRAFFIC_TYPE = "traffic type"
80 UNSOLICITED_GRANT_SIZE = "unsolicited_grant_size"
81 NOMINAL_INTERVAL = "nominal_interval"
82 TOLERATED_POLL_JITTER = "tolerated_poll_jitter"
83 REQUEST_TRANSMISSION_POLICY = "request_transmission_policy"
84 NUM_Q_SETS = "num_q_sets"
85 Q_THRESHOLDS = "q_thresholds"
86 Q_THRESHOLD1 = "q_threshold1"
87 Q_THRESHOLD2 = "q_threshold2"
88 Q_THRESHOLD3 = "q_threshold3"
89 Q_THRESHOLD4 = "q_threshold4"
90 Q_THRESHOLD5 = "q_threshold5"
91 Q_THRESHOLD6 = "q_threshold6"
92 Q_THRESHOLD7 = "q_threshold7"
Matt Jeanneretcab955f2019-04-10 15:45:57 -040093)
94
95// TechprofileFlags represents the set of configurations used
96type TechProfileFlags struct {
Neha Sharma3f221ae2020-04-29 19:02:12 +000097 KVStoreAddress string
Matt Jeanneretcab955f2019-04-10 15:45:57 -040098 KVStoreType string
Neha Sharmacc656962020-04-14 14:26:11 +000099 KVStoreTimeout time.Duration
sbarbaria8910ba2019-11-05 10:12:23 -0500100 KVBackend *db.Backend
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400101 TPKVPathPrefix string
102 TPFileKVPath string
103 TPInstanceKVPath string
104 DefaultTPName string
105 TPVersion int
106 NumGemPorts uint32
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400107 DefaultPbits []string
108 LogLevel int
109 DefaultTechProfileID uint32
110 DefaultNumGemPorts uint32
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400111}
112
Matteo Scandoloc858ab72020-11-16 12:44:51 -0800113func NewTechProfileFlags(KVStoreType string, KVStoreAddress string, basePathKvStore string) *TechProfileFlags {
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400114 // initialize with default values
115 var techProfileFlags = TechProfileFlags{
116 KVBackend: nil,
Neha Sharma3f221ae2020-04-29 19:02:12 +0000117 KVStoreAddress: KVStoreAddress,
Matt Jeannereta93dbed2019-05-17 12:40:05 -0400118 KVStoreType: KVStoreType,
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400119 KVStoreTimeout: defaultKVStoreTimeout,
120 DefaultTPName: defaultTechProfileName,
Matteo Scandoloc858ab72020-11-16 12:44:51 -0800121 TPKVPathPrefix: fmt.Sprintf(defaultKVPathPrefix, basePathKvStore),
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400122 TPVersion: defaultVersion,
123 TPFileKVPath: defaultTechProfileKVPath,
124 TPInstanceKVPath: defaultTPInstanceKVPath,
125 DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID,
126 DefaultNumGemPorts: defaultGemportsCount,
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400127 DefaultPbits: []string{defaultPbits},
128 LogLevel: defaultLogLevel,
129 }
130
131 return &techProfileFlags
132}