Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package techprofile |
| 17 | |
| 18 | import ( |
serkant.uluderya | b38671c | 2019-11-01 09:35:38 -0700 | [diff] [blame] | 19 | "github.com/opencord/voltha-lib-go/v3/pkg/db" |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 20 | ) |
| 21 | |
| 22 | // tech profile default constants |
| 23 | const ( |
| 24 | defaultTechProfileName = "Default_1tcont_1gem_Profile" |
| 25 | DEFAULT_TECH_PROFILE_TABLE_ID = 64 |
| 26 | defaultVersion = 1.0 |
| 27 | defaultLogLevel = 0 |
| 28 | defaultGemportsCount = 1 |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 29 | defaultPbits = "0b11111111" |
| 30 | |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 31 | defaultKVStoreTimeout = 5 //in seconds |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 32 | |
| 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 |
| 46 | const ( |
| 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 |
| 77 | type TechProfileFlags struct { |
| 78 | KVStoreHost string |
| 79 | KVStorePort int |
| 80 | KVStoreType string |
| 81 | KVStoreTimeout int |
sbarbari | 1e3e29c | 2019-11-05 10:06:50 -0500 | [diff] [blame] | 82 | KVBackend *db.Backend |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 83 | TPKVPathPrefix string |
| 84 | TPFileKVPath string |
| 85 | TPInstanceKVPath string |
| 86 | DefaultTPName string |
| 87 | TPVersion int |
| 88 | NumGemPorts uint32 |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 89 | DefaultPbits []string |
| 90 | LogLevel int |
| 91 | DefaultTechProfileID uint32 |
| 92 | DefaultNumGemPorts uint32 |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | func NewTechProfileFlags(KVStoreType string, KVStoreHost string, KVStorePort int) *TechProfileFlags { |
| 96 | // initialize with default values |
| 97 | var techProfileFlags = TechProfileFlags{ |
| 98 | KVBackend: nil, |
| 99 | KVStoreHost: KVStoreHost, |
| 100 | KVStorePort: KVStorePort, |
| 101 | KVStoreType: KVStoreType, |
| 102 | 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, |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 110 | DefaultPbits: []string{defaultPbits}, |
| 111 | LogLevel: defaultLogLevel, |
| 112 | } |
| 113 | |
| 114 | return &techProfileFlags |
| 115 | } |