blob: f9655a8969349db7cd2034c1a74a87ecb126ac69 [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 (
19 "github.com/opencord/voltha-lib-go/pkg/db/model"
20)
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
86 KVBackend *model.Backend
87 TPKVPathPrefix string
88 TPFileKVPath string
89 TPInstanceKVPath string
90 DefaultTPName string
91 TPVersion int
92 NumGemPorts uint32
93 NumTconts uint32
94 DefaultPbits []string
95 LogLevel int
96 DefaultTechProfileID uint32
97 DefaultNumGemPorts uint32
98 DefaultNumTconts uint32
99}
100
101func NewTechProfileFlags(KVStoreType string, KVStoreHost string, KVStorePort int) *TechProfileFlags {
102 // initialize with default values
103 var techProfileFlags = TechProfileFlags{
104 KVBackend: nil,
105 KVStoreHost: KVStoreHost,
106 KVStorePort: KVStorePort,
107 KVStoreType: KVStoreType,
108 KVStoreTimeout: defaultKVStoreTimeout,
109 DefaultTPName: defaultTechProfileName,
110 TPKVPathPrefix: defaultKVPathPrefix,
111 TPVersion: defaultVersion,
112 TPFileKVPath: defaultTechProfileKVPath,
113 TPInstanceKVPath: defaultTPInstanceKVPath,
114 DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID,
115 DefaultNumGemPorts: defaultGemportsCount,
116 DefaultNumTconts: defaultNumTconts,
117 DefaultPbits: []string{defaultPbits},
118 LogLevel: defaultLogLevel,
119 }
120
121 return &techProfileFlags
122}