blob: fe3e4a22635b269f85523ee0c46e1824da40342e [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 (
Esin Karamanccb714b2019-11-29 15:02:06 +000019 "github.com/opencord/voltha-lib-go/v3/pkg/db"
Neha Sharmacc656962020-04-14 14:26:11 +000020 "time"
Matt Jeanneretcab955f2019-04-10 15:45:57 -040021)
22
23// tech profile default constants
24const (
25 defaultTechProfileName = "Default_1tcont_1gem_Profile"
26 DEFAULT_TECH_PROFILE_TABLE_ID = 64
27 defaultVersion = 1.0
28 defaultLogLevel = 0
29 defaultGemportsCount = 1
Matt Jeanneretcab955f2019-04-10 15:45:57 -040030 defaultPbits = "0b11111111"
31
Neha Sharmacc656962020-04-14 14:26:11 +000032 defaultKVStoreTimeout = 5 * time.Second //in seconds
Matt Jeanneretcab955f2019-04-10 15:45:57 -040033
34 // Tech profile path prefix in kv store
35 defaultKVPathPrefix = "service/voltha/technology_profiles"
36
37 // Tech profile path in kv store
38 defaultTechProfileKVPath = "%s/%d" // <technology>/<tech_profile_tableID>
39
40 // Tech profile instance path in kv store
41 // Format: <technology>/<tech_profile_tableID>/<uni_port_name>
42 defaultTPInstanceKVPath = "%s/%d/%s"
43)
44
45//Tech-Profile JSON String Keys
46// NOTE: Tech profile templeate JSON file should comply with below keys
47const (
48 NAME = "name"
49 PROFILE_TYPE = "profile_type"
50 VERSION = "version"
51 NUM_GEM_PORTS = "num_gem_ports"
52 INSTANCE_CONTROL = "instance_control"
53 US_SCHEDULER = "us_scheduler"
54 DS_SCHEDULER = "ds_scheduler"
55 UPSTREAM_GEM_PORT_ATTRIBUTE_LIST = "upstream_gem_port_attribute_list"
56 DOWNSTREAM_GEM_PORT_ATTRIBUTE_LIST = "downstream_gem_port_attribute_list"
57 ONU = "onu"
58 UNI = "uni"
59 MAX_GEM_PAYLOAD_SIZE = "max_gem_payload_size"
60 DIRECTION = "direction"
61 ADDITIONAL_BW = "additional_bw"
62 PRIORITY = "priority"
63 Q_SCHED_POLICY = "q_sched_policy"
64 WEIGHT = "weight"
65 PBIT_MAP = "pbit_map"
66 DISCARD_CONFIG = "discard_config"
67 MAX_THRESHOLD = "max_threshold"
68 MIN_THRESHOLD = "min_threshold"
69 MAX_PROBABILITY = "max_probability"
70 DISCARD_POLICY = "discard_policy"
71 PRIORITY_Q = "priority_q"
72 SCHEDULING_POLICY = "scheduling_policy"
73 MAX_Q_SIZE = "max_q_size"
74 AES_ENCRYPTION = "aes_encryption"
75)
76
77// TechprofileFlags represents the set of configurations used
78type TechProfileFlags struct {
Neha Sharma3f221ae2020-04-29 19:02:12 +000079 KVStoreAddress string
Matt Jeanneretcab955f2019-04-10 15:45:57 -040080 KVStoreType string
Neha Sharmacc656962020-04-14 14:26:11 +000081 KVStoreTimeout time.Duration
sbarbaria8910ba2019-11-05 10:12:23 -050082 KVBackend *db.Backend
Matt Jeanneretcab955f2019-04-10 15:45:57 -040083 TPKVPathPrefix string
84 TPFileKVPath string
85 TPInstanceKVPath string
86 DefaultTPName string
87 TPVersion int
88 NumGemPorts uint32
Matt Jeanneretcab955f2019-04-10 15:45:57 -040089 DefaultPbits []string
90 LogLevel int
91 DefaultTechProfileID uint32
92 DefaultNumGemPorts uint32
Matt Jeanneretcab955f2019-04-10 15:45:57 -040093}
94
Neha Sharma3f221ae2020-04-29 19:02:12 +000095func NewTechProfileFlags(KVStoreType string, KVStoreAddress string) *TechProfileFlags {
Matt Jeanneretcab955f2019-04-10 15:45:57 -040096 // initialize with default values
97 var techProfileFlags = TechProfileFlags{
98 KVBackend: nil,
Neha Sharma3f221ae2020-04-29 19:02:12 +000099 KVStoreAddress: KVStoreAddress,
Matt Jeannereta93dbed2019-05-17 12:40:05 -0400100 KVStoreType: KVStoreType,
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400101 KVStoreTimeout: defaultKVStoreTimeout,
102 DefaultTPName: defaultTechProfileName,
103 TPKVPathPrefix: defaultKVPathPrefix,
104 TPVersion: defaultVersion,
105 TPFileKVPath: defaultTechProfileKVPath,
106 TPInstanceKVPath: defaultTPInstanceKVPath,
107 DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID,
108 DefaultNumGemPorts: defaultGemportsCount,
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400109 DefaultPbits: []string{defaultPbits},
110 LogLevel: defaultLogLevel,
111 }
112
113 return &techProfileFlags
114}