blob: 2df71471bf8b227d0f1a12fa551a5b778bd2af5b [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 (
serkant.uluderyab38671c2019-11-01 09:35:38 -070019 "github.com/opencord/voltha-lib-go/v3/pkg/db"
Scott Baker2c1c4822019-10-16 11:02:41 -070020)
21
22// tech profile default constants
23const (
24 defaultTechProfileName = "Default_1tcont_1gem_Profile"
25 DEFAULT_TECH_PROFILE_TABLE_ID = 64
26 defaultVersion = 1.0
27 defaultLogLevel = 0
28 defaultGemportsCount = 1
29 defaultNumTconts = 1
30 defaultPbits = "0b11111111"
31
32 defaultKVStoreType = "etcd"
33 defaultKVStoreTimeout = 5 //in seconds
34 defaultKVStoreHost = "127.0.0.1"
35 defaultKVStorePort = 2379 // Consul = 8500; Etcd = 2379
36
37 // Tech profile path prefix in kv store
38 defaultKVPathPrefix = "service/voltha/technology_profiles"
39
40 // Tech profile path in kv store
41 defaultTechProfileKVPath = "%s/%d" // <technology>/<tech_profile_tableID>
42
43 // Tech profile instance path in kv store
44 // Format: <technology>/<tech_profile_tableID>/<uni_port_name>
45 defaultTPInstanceKVPath = "%s/%d/%s"
46)
47
48//Tech-Profile JSON String Keys
49// NOTE: Tech profile templeate JSON file should comply with below keys
50const (
51 NAME = "name"
52 PROFILE_TYPE = "profile_type"
53 VERSION = "version"
54 NUM_GEM_PORTS = "num_gem_ports"
55 INSTANCE_CONTROL = "instance_control"
56 US_SCHEDULER = "us_scheduler"
57 DS_SCHEDULER = "ds_scheduler"
58 UPSTREAM_GEM_PORT_ATTRIBUTE_LIST = "upstream_gem_port_attribute_list"
59 DOWNSTREAM_GEM_PORT_ATTRIBUTE_LIST = "downstream_gem_port_attribute_list"
60 ONU = "onu"
61 UNI = "uni"
62 MAX_GEM_PAYLOAD_SIZE = "max_gem_payload_size"
63 DIRECTION = "direction"
64 ADDITIONAL_BW = "additional_bw"
65 PRIORITY = "priority"
66 Q_SCHED_POLICY = "q_sched_policy"
67 WEIGHT = "weight"
68 PBIT_MAP = "pbit_map"
69 DISCARD_CONFIG = "discard_config"
70 MAX_THRESHOLD = "max_threshold"
71 MIN_THRESHOLD = "min_threshold"
72 MAX_PROBABILITY = "max_probability"
73 DISCARD_POLICY = "discard_policy"
74 PRIORITY_Q = "priority_q"
75 SCHEDULING_POLICY = "scheduling_policy"
76 MAX_Q_SIZE = "max_q_size"
77 AES_ENCRYPTION = "aes_encryption"
78)
79
80// TechprofileFlags represents the set of configurations used
81type TechProfileFlags struct {
82 KVStoreHost string
83 KVStorePort int
84 KVStoreType string
85 KVStoreTimeout int
sbarbari1e3e29c2019-11-05 10:06:50 -050086 KVBackend *db.Backend
Scott Baker2c1c4822019-10-16 11:02:41 -070087 TPKVPathPrefix string
88 TPFileKVPath string
89 TPInstanceKVPath string
90 DefaultTPName string
91 TPVersion int
92 NumGemPorts uint32
Scott Baker2c1c4822019-10-16 11:02:41 -070093 DefaultPbits []string
94 LogLevel int
95 DefaultTechProfileID uint32
96 DefaultNumGemPorts uint32
Scott Baker2c1c4822019-10-16 11:02:41 -070097}
98
99func NewTechProfileFlags(KVStoreType string, KVStoreHost string, KVStorePort int) *TechProfileFlags {
100 // initialize with default values
101 var techProfileFlags = TechProfileFlags{
102 KVBackend: nil,
103 KVStoreHost: KVStoreHost,
104 KVStorePort: KVStorePort,
105 KVStoreType: KVStoreType,
106 KVStoreTimeout: defaultKVStoreTimeout,
107 DefaultTPName: defaultTechProfileName,
108 TPKVPathPrefix: defaultKVPathPrefix,
109 TPVersion: defaultVersion,
110 TPFileKVPath: defaultTechProfileKVPath,
111 TPInstanceKVPath: defaultTPInstanceKVPath,
112 DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID,
113 DefaultNumGemPorts: defaultGemportsCount,
Scott Baker2c1c4822019-10-16 11:02:41 -0700114 DefaultPbits: []string{defaultPbits},
115 LogLevel: defaultLogLevel,
116 }
117
118 return &techProfileFlags
119}