blob: 07926c5c626eaa39eb779644c08ec92c0ad0ee75 [file] [log] [blame]
Scott Baker2c1c4822019-10-16 11:02:41 -07001/*
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 Scandolo866ac582020-11-09 12:18:31 -080019 "fmt"
Girish Gowdra89c985b2020-10-14 15:02:09 -070020 "github.com/opencord/voltha-lib-go/v4/pkg/db"
Neha Sharma130ac6d2020-04-08 08:46:32 +000021 "time"
Scott Baker2c1c4822019-10-16 11:02:41 -070022)
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
Scott Baker2c1c4822019-10-16 11:02:41 -070031 defaultPbits = "0b11111111"
32
Neha Sharma130ac6d2020-04-08 08:46:32 +000033 defaultKVStoreTimeout = 5 * time.Second //in seconds
Scott Baker2c1c4822019-10-16 11:02:41 -070034
35 // Tech profile path prefix in kv store
Matteo Scandolo866ac582020-11-09 12:18:31 -080036 defaultKVPathPrefix = "%s/technology_profiles"
Scott Baker2c1c4822019-10-16 11:02:41 -070037
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 Suzuki98cd2b92020-03-13 14:50:08 -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"
Scott Baker2c1c4822019-10-16 11:02:41 -070093)
94
95// TechprofileFlags represents the set of configurations used
96type TechProfileFlags struct {
Neha Sharmadd9af392020-04-28 09:03:57 +000097 KVStoreAddress string
Scott Baker2c1c4822019-10-16 11:02:41 -070098 KVStoreType string
Neha Sharma130ac6d2020-04-08 08:46:32 +000099 KVStoreTimeout time.Duration
sbarbari1e3e29c2019-11-05 10:06:50 -0500100 KVBackend *db.Backend
Scott Baker2c1c4822019-10-16 11:02:41 -0700101 TPKVPathPrefix string
102 TPFileKVPath string
103 TPInstanceKVPath string
104 DefaultTPName string
105 TPVersion int
106 NumGemPorts uint32
Scott Baker2c1c4822019-10-16 11:02:41 -0700107 DefaultPbits []string
108 LogLevel int
109 DefaultTechProfileID uint32
110 DefaultNumGemPorts uint32
Scott Baker2c1c4822019-10-16 11:02:41 -0700111}
112
Matteo Scandolo866ac582020-11-09 12:18:31 -0800113func NewTechProfileFlags(KVStoreType string, KVStoreAddress string, basePathKvStore string) *TechProfileFlags {
Scott Baker2c1c4822019-10-16 11:02:41 -0700114 // initialize with default values
115 var techProfileFlags = TechProfileFlags{
116 KVBackend: nil,
Neha Sharmadd9af392020-04-28 09:03:57 +0000117 KVStoreAddress: KVStoreAddress,
Scott Baker2c1c4822019-10-16 11:02:41 -0700118 KVStoreType: KVStoreType,
119 KVStoreTimeout: defaultKVStoreTimeout,
120 DefaultTPName: defaultTechProfileName,
Matteo Scandolo866ac582020-11-09 12:18:31 -0800121 TPKVPathPrefix: fmt.Sprintf(defaultKVPathPrefix, basePathKvStore),
Scott Baker2c1c4822019-10-16 11:02:41 -0700122 TPVersion: defaultVersion,
123 TPFileKVPath: defaultTechProfileKVPath,
124 TPInstanceKVPath: defaultTPInstanceKVPath,
125 DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID,
126 DefaultNumGemPorts: defaultGemportsCount,
Scott Baker2c1c4822019-10-16 11:02:41 -0700127 DefaultPbits: []string{defaultPbits},
128 LogLevel: defaultLogLevel,
129 }
130
131 return &techProfileFlags
132}