blob: 4af2bd50c7d6eced5cb21b24113a5d706cbab060 [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"
Matt Jeanneretcab955f2019-04-10 15:45:57 -040020)
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
Matt Jeanneretcab955f2019-04-10 15:45:57 -040029 defaultPbits = "0b11111111"
30
Matt Jeannereta93dbed2019-05-17 12:40:05 -040031 defaultKVStoreTimeout = 5 //in seconds
Matt Jeanneretcab955f2019-04-10 15:45:57 -040032
33 // Tech profile path prefix in kv store
34 defaultKVPathPrefix = "service/voltha/technology_profiles"
35
36 // Tech profile path in kv store
37 defaultTechProfileKVPath = "%s/%d" // <technology>/<tech_profile_tableID>
38
39 // Tech profile instance path in kv store
40 // Format: <technology>/<tech_profile_tableID>/<uni_port_name>
41 defaultTPInstanceKVPath = "%s/%d/%s"
42)
43
44//Tech-Profile JSON String Keys
45// NOTE: Tech profile templeate JSON file should comply with below keys
46const (
47 NAME = "name"
48 PROFILE_TYPE = "profile_type"
49 VERSION = "version"
50 NUM_GEM_PORTS = "num_gem_ports"
51 INSTANCE_CONTROL = "instance_control"
52 US_SCHEDULER = "us_scheduler"
53 DS_SCHEDULER = "ds_scheduler"
54 UPSTREAM_GEM_PORT_ATTRIBUTE_LIST = "upstream_gem_port_attribute_list"
55 DOWNSTREAM_GEM_PORT_ATTRIBUTE_LIST = "downstream_gem_port_attribute_list"
56 ONU = "onu"
57 UNI = "uni"
58 MAX_GEM_PAYLOAD_SIZE = "max_gem_payload_size"
59 DIRECTION = "direction"
60 ADDITIONAL_BW = "additional_bw"
61 PRIORITY = "priority"
62 Q_SCHED_POLICY = "q_sched_policy"
63 WEIGHT = "weight"
64 PBIT_MAP = "pbit_map"
65 DISCARD_CONFIG = "discard_config"
66 MAX_THRESHOLD = "max_threshold"
67 MIN_THRESHOLD = "min_threshold"
68 MAX_PROBABILITY = "max_probability"
69 DISCARD_POLICY = "discard_policy"
70 PRIORITY_Q = "priority_q"
71 SCHEDULING_POLICY = "scheduling_policy"
72 MAX_Q_SIZE = "max_q_size"
73 AES_ENCRYPTION = "aes_encryption"
74)
75
76// TechprofileFlags represents the set of configurations used
77type TechProfileFlags struct {
78 KVStoreHost string
79 KVStorePort int
80 KVStoreType string
81 KVStoreTimeout int
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
Matt Jeannereta93dbed2019-05-17 12:40:05 -040095func NewTechProfileFlags(KVStoreType string, KVStoreHost string, KVStorePort int) *TechProfileFlags {
Matt Jeanneretcab955f2019-04-10 15:45:57 -040096 // initialize with default values
97 var techProfileFlags = TechProfileFlags{
98 KVBackend: nil,
Matt Jeannereta93dbed2019-05-17 12:40:05 -040099 KVStoreHost: KVStoreHost,
100 KVStorePort: KVStorePort,
101 KVStoreType: KVStoreType,
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400102 KVStoreTimeout: defaultKVStoreTimeout,
103 DefaultTPName: defaultTechProfileName,
104 TPKVPathPrefix: defaultKVPathPrefix,
105 TPVersion: defaultVersion,
106 TPFileKVPath: defaultTechProfileKVPath,
107 TPInstanceKVPath: defaultTPInstanceKVPath,
108 DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID,
109 DefaultNumGemPorts: defaultGemportsCount,
Matt Jeanneretcab955f2019-04-10 15:45:57 -0400110 DefaultPbits: []string{defaultPbits},
111 LogLevel: defaultLogLevel,
112 }
113
114 return &techProfileFlags
115}