blob: 438ea4a99b03bd4bcc8682084b38648fb1509357 [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
Matteo Scandolof34d9082020-11-24 13:56:34 -080035 // Tech profile path prefix in kv store (for the TP template)
36 // NOTE that this hardcoded to service/voltha as the TP template is shared across stacks
37 defaultTpKvPathPrefix = "service/voltha/technology_profiles"
38
39 // Tech profile path prefix in kv store (for TP instances)
Matteo Scandolo866ac582020-11-09 12:18:31 -080040 defaultKVPathPrefix = "%s/technology_profiles"
Scott Baker2c1c4822019-10-16 11:02:41 -070041
42 // Tech profile path in kv store
43 defaultTechProfileKVPath = "%s/%d" // <technology>/<tech_profile_tableID>
44
45 // Tech profile instance path in kv store
46 // Format: <technology>/<tech_profile_tableID>/<uni_port_name>
47 defaultTPInstanceKVPath = "%s/%d/%s"
48)
49
50//Tech-Profile JSON String Keys
51// NOTE: Tech profile templeate JSON file should comply with below keys
52const (
53 NAME = "name"
54 PROFILE_TYPE = "profile_type"
55 VERSION = "version"
56 NUM_GEM_PORTS = "num_gem_ports"
57 INSTANCE_CONTROL = "instance_control"
58 US_SCHEDULER = "us_scheduler"
59 DS_SCHEDULER = "ds_scheduler"
60 UPSTREAM_GEM_PORT_ATTRIBUTE_LIST = "upstream_gem_port_attribute_list"
61 DOWNSTREAM_GEM_PORT_ATTRIBUTE_LIST = "downstream_gem_port_attribute_list"
62 ONU = "onu"
63 UNI = "uni"
64 MAX_GEM_PAYLOAD_SIZE = "max_gem_payload_size"
65 DIRECTION = "direction"
66 ADDITIONAL_BW = "additional_bw"
67 PRIORITY = "priority"
68 Q_SCHED_POLICY = "q_sched_policy"
69 WEIGHT = "weight"
70 PBIT_MAP = "pbit_map"
71 DISCARD_CONFIG = "discard_config"
72 MAX_THRESHOLD = "max_threshold"
73 MIN_THRESHOLD = "min_threshold"
74 MAX_PROBABILITY = "max_probability"
75 DISCARD_POLICY = "discard_policy"
76 PRIORITY_Q = "priority_q"
77 SCHEDULING_POLICY = "scheduling_policy"
78 MAX_Q_SIZE = "max_q_size"
79 AES_ENCRYPTION = "aes_encryption"
Takahiro Suzuki98cd2b92020-03-13 14:50:08 -070080 // String Keys for EPON
81 EPON_ATTRIBUTE = "epon_attribute"
82 PACKAGE_TYPE = "package_type"
83 TRAFFIC_TYPE = "traffic type"
84 UNSOLICITED_GRANT_SIZE = "unsolicited_grant_size"
85 NOMINAL_INTERVAL = "nominal_interval"
86 TOLERATED_POLL_JITTER = "tolerated_poll_jitter"
87 REQUEST_TRANSMISSION_POLICY = "request_transmission_policy"
88 NUM_Q_SETS = "num_q_sets"
89 Q_THRESHOLDS = "q_thresholds"
90 Q_THRESHOLD1 = "q_threshold1"
91 Q_THRESHOLD2 = "q_threshold2"
92 Q_THRESHOLD3 = "q_threshold3"
93 Q_THRESHOLD4 = "q_threshold4"
94 Q_THRESHOLD5 = "q_threshold5"
95 Q_THRESHOLD6 = "q_threshold6"
96 Q_THRESHOLD7 = "q_threshold7"
Scott Baker2c1c4822019-10-16 11:02:41 -070097)
98
99// TechprofileFlags represents the set of configurations used
100type TechProfileFlags struct {
Matteo Scandolof34d9082020-11-24 13:56:34 -0800101 KVStoreAddress string
102 KVStoreType string
103 KVStoreTimeout time.Duration
104 KVBackend *db.Backend // this is the backend used to store TP instances
105 DefaultTpKVBackend *db.Backend // this is the backend used to read the TP profile
106 TPKVPathPrefix string
107 defaultTpKvPathPrefix string
108 TPFileKVPath string
109 TPInstanceKVPath string
110 DefaultTPName string
111 TPVersion int
112 NumGemPorts uint32
113 DefaultPbits []string
114 LogLevel int
115 DefaultTechProfileID uint32
116 DefaultNumGemPorts uint32
Scott Baker2c1c4822019-10-16 11:02:41 -0700117}
118
Matteo Scandolo866ac582020-11-09 12:18:31 -0800119func NewTechProfileFlags(KVStoreType string, KVStoreAddress string, basePathKvStore string) *TechProfileFlags {
Scott Baker2c1c4822019-10-16 11:02:41 -0700120 // initialize with default values
121 var techProfileFlags = TechProfileFlags{
Matteo Scandolof34d9082020-11-24 13:56:34 -0800122 KVBackend: nil,
123 KVStoreAddress: KVStoreAddress,
124 KVStoreType: KVStoreType,
125 KVStoreTimeout: defaultKVStoreTimeout,
126 DefaultTPName: defaultTechProfileName,
127 TPKVPathPrefix: fmt.Sprintf(defaultKVPathPrefix, basePathKvStore),
128 defaultTpKvPathPrefix: defaultTpKvPathPrefix,
129 TPVersion: defaultVersion,
130 TPFileKVPath: defaultTechProfileKVPath,
131 TPInstanceKVPath: defaultTPInstanceKVPath,
132 DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID,
133 DefaultNumGemPorts: defaultGemportsCount,
134 DefaultPbits: []string{defaultPbits},
135 LogLevel: defaultLogLevel,
Scott Baker2c1c4822019-10-16 11:02:41 -0700136 }
137
138 return &techProfileFlags
139}