blob: 17980fa5c4f7931bd080df33b6055331f1659c77 [file] [log] [blame]
khenaidoo106c61a2021-08-11 18:05:46 -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 (
19 "fmt"
20 "time"
21
22 "github.com/opencord/voltha-lib-go/v7/pkg/db"
23)
24
25// tech profile default constants
26const (
27 defaultTechProfileName = "Default_1tcont_1gem_Profile"
28 DEFAULT_TECH_PROFILE_TABLE_ID = 64
29 defaultVersion = 1.0
30 defaultLogLevel = 0
31 defaultGemportsCount = 1
32 defaultPbits = "0b11111111"
33
34 defaultKVStoreTimeout = 5 * time.Second //in seconds
35
36 // Tech profile path prefix in kv store (for the TP template)
37 // NOTE that this hardcoded to service/voltha as the TP template is shared across stacks
38 defaultTpKvPathPrefix = "service/voltha/technology_profiles"
39
40 // Tech profile path prefix in kv store (for TP instances)
41 defaultKVPathPrefix = "%s/technology_profiles"
42
43 // Resource instance path prefix in KV store (for Resource Instances)
44 defaultResourceInstancePathPrefix = "%s/resource_instances"
45
46 // Tech profile path in kv store
47 defaultTechProfileKVPath = "%s/%d" // <technology>/<tech_profile_tableID>
48
49)
50
51//Tech-Profile JSON String Keys
52// NOTE: Tech profile templeate JSON file should comply with below keys
53const (
54 NAME = "name"
55 PROFILE_TYPE = "profile_type"
56 VERSION = "version"
57 NUM_GEM_PORTS = "num_gem_ports"
58 INSTANCE_CONTROL = "instance_control"
59 US_SCHEDULER = "us_scheduler"
60 DS_SCHEDULER = "ds_scheduler"
61 UPSTREAM_GEM_PORT_ATTRIBUTE_LIST = "upstream_gem_port_attribute_list"
62 DOWNSTREAM_GEM_PORT_ATTRIBUTE_LIST = "downstream_gem_port_attribute_list"
63 ONU = "onu"
64 UNI = "uni"
65 MAX_GEM_PAYLOAD_SIZE = "max_gem_payload_size"
66 DIRECTION = "direction"
67 ADDITIONAL_BW = "additional_bw"
68 PRIORITY = "priority"
69 Q_SCHED_POLICY = "q_sched_policy"
70 WEIGHT = "weight"
71 PBIT_MAP = "pbit_map"
72 DISCARD_CONFIG = "discard_config"
73 MAX_THRESHOLD = "max_threshold"
74 MIN_THRESHOLD = "min_threshold"
75 MAX_PROBABILITY = "max_probability"
76 DISCARD_POLICY = "discard_policy"
77 PRIORITY_Q = "priority_q"
78 SCHEDULING_POLICY = "scheduling_policy"
79 MAX_Q_SIZE = "max_q_size"
80 AES_ENCRYPTION = "aes_encryption"
81 // String Keys for EPON
82 EPON_ATTRIBUTE = "epon_attribute"
83 PACKAGE_TYPE = "package_type"
84 TRAFFIC_TYPE = "traffic type"
85 UNSOLICITED_GRANT_SIZE = "unsolicited_grant_size"
86 NOMINAL_INTERVAL = "nominal_interval"
87 TOLERATED_POLL_JITTER = "tolerated_poll_jitter"
88 REQUEST_TRANSMISSION_POLICY = "request_transmission_policy"
89 NUM_Q_SETS = "num_q_sets"
90 Q_THRESHOLDS = "q_thresholds"
91 Q_THRESHOLD1 = "q_threshold1"
92 Q_THRESHOLD2 = "q_threshold2"
93 Q_THRESHOLD3 = "q_threshold3"
94 Q_THRESHOLD4 = "q_threshold4"
95 Q_THRESHOLD5 = "q_threshold5"
96 Q_THRESHOLD6 = "q_threshold6"
97 Q_THRESHOLD7 = "q_threshold7"
98)
99
100// TechprofileFlags represents the set of configurations used
101type TechProfileFlags struct {
102 KVStoreAddress string
103 KVStoreType string
104 KVStoreTimeout time.Duration
105 KVBackend *db.Backend // this is the backend used to store TP instances
106 DefaultTpKVBackend *db.Backend // this is the backend used to read the TP profile
107 ResourceInstanceKVBacked *db.Backend // this is the backed used to read/write Resource Instances
108 TPKVPathPrefix string
109 defaultTpKvPathPrefix string
110 TPFileKVPath string
111 ResourceInstanceKVPathPrefix string
112 DefaultTPName string
113 TPVersion uint32
114 NumGemPorts uint32
115 DefaultPbits []string
116 LogLevel int
117 DefaultTechProfileID uint32
118 DefaultNumGemPorts uint32
119}
120
121func NewTechProfileFlags(KVStoreType string, KVStoreAddress string, basePathKvStore string) *TechProfileFlags {
122 // initialize with default values
123 var techProfileFlags = TechProfileFlags{
124 KVBackend: nil,
125 KVStoreAddress: KVStoreAddress,
126 KVStoreType: KVStoreType,
127 KVStoreTimeout: defaultKVStoreTimeout,
128 DefaultTPName: defaultTechProfileName,
129 TPKVPathPrefix: fmt.Sprintf(defaultKVPathPrefix, basePathKvStore),
130 defaultTpKvPathPrefix: defaultTpKvPathPrefix,
131 TPVersion: defaultVersion,
132 TPFileKVPath: defaultTechProfileKVPath,
133 ResourceInstanceKVPathPrefix: fmt.Sprintf(defaultResourceInstancePathPrefix, basePathKvStore),
134 DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID,
135 DefaultNumGemPorts: defaultGemportsCount,
136 DefaultPbits: []string{defaultPbits},
137 LogLevel: defaultLogLevel,
138 }
139
140 return &techProfileFlags
141}