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" |
Neha Sharma | 130ac6d | 2020-04-08 08:46:32 +0000 | [diff] [blame] | 20 | "time" |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 21 | ) |
| 22 | |
| 23 | // tech profile default constants |
| 24 | const ( |
| 25 | defaultTechProfileName = "Default_1tcont_1gem_Profile" |
| 26 | DEFAULT_TECH_PROFILE_TABLE_ID = 64 |
| 27 | defaultVersion = 1.0 |
| 28 | defaultLogLevel = 0 |
| 29 | defaultGemportsCount = 1 |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 30 | defaultPbits = "0b11111111" |
| 31 | |
Neha Sharma | 130ac6d | 2020-04-08 08:46:32 +0000 | [diff] [blame] | 32 | defaultKVStoreTimeout = 5 * time.Second //in seconds |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 33 | |
| 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 |
| 47 | const ( |
| 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" |
Takahiro Suzuki | 98cd2b9 | 2020-03-13 14:50:08 -0700 | [diff] [blame] | 75 | // String Keys for EPON |
| 76 | EPON_ATTRIBUTE = "epon_attribute" |
| 77 | PACKAGE_TYPE = "package_type" |
| 78 | TRAFFIC_TYPE = "traffic type" |
| 79 | UNSOLICITED_GRANT_SIZE = "unsolicited_grant_size" |
| 80 | NOMINAL_INTERVAL = "nominal_interval" |
| 81 | TOLERATED_POLL_JITTER = "tolerated_poll_jitter" |
| 82 | REQUEST_TRANSMISSION_POLICY = "request_transmission_policy" |
| 83 | NUM_Q_SETS = "num_q_sets" |
| 84 | Q_THRESHOLDS = "q_thresholds" |
| 85 | Q_THRESHOLD1 = "q_threshold1" |
| 86 | Q_THRESHOLD2 = "q_threshold2" |
| 87 | Q_THRESHOLD3 = "q_threshold3" |
| 88 | Q_THRESHOLD4 = "q_threshold4" |
| 89 | Q_THRESHOLD5 = "q_threshold5" |
| 90 | Q_THRESHOLD6 = "q_threshold6" |
| 91 | Q_THRESHOLD7 = "q_threshold7" |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 92 | ) |
| 93 | |
| 94 | // TechprofileFlags represents the set of configurations used |
| 95 | type TechProfileFlags struct { |
Neha Sharma | dd9af39 | 2020-04-28 09:03:57 +0000 | [diff] [blame] | 96 | KVStoreAddress string |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 97 | KVStoreType string |
Neha Sharma | 130ac6d | 2020-04-08 08:46:32 +0000 | [diff] [blame] | 98 | KVStoreTimeout time.Duration |
sbarbari | 1e3e29c | 2019-11-05 10:06:50 -0500 | [diff] [blame] | 99 | KVBackend *db.Backend |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 100 | TPKVPathPrefix string |
| 101 | TPFileKVPath string |
| 102 | TPInstanceKVPath string |
| 103 | DefaultTPName string |
| 104 | TPVersion int |
| 105 | NumGemPorts uint32 |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 106 | DefaultPbits []string |
| 107 | LogLevel int |
| 108 | DefaultTechProfileID uint32 |
| 109 | DefaultNumGemPorts uint32 |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Neha Sharma | dd9af39 | 2020-04-28 09:03:57 +0000 | [diff] [blame] | 112 | func NewTechProfileFlags(KVStoreType string, KVStoreAddress string) *TechProfileFlags { |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 113 | // initialize with default values |
| 114 | var techProfileFlags = TechProfileFlags{ |
| 115 | KVBackend: nil, |
Neha Sharma | dd9af39 | 2020-04-28 09:03:57 +0000 | [diff] [blame] | 116 | KVStoreAddress: KVStoreAddress, |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 117 | KVStoreType: KVStoreType, |
| 118 | KVStoreTimeout: defaultKVStoreTimeout, |
| 119 | DefaultTPName: defaultTechProfileName, |
| 120 | TPKVPathPrefix: defaultKVPathPrefix, |
| 121 | TPVersion: defaultVersion, |
| 122 | TPFileKVPath: defaultTechProfileKVPath, |
| 123 | TPInstanceKVPath: defaultTPInstanceKVPath, |
| 124 | DefaultTechProfileID: DEFAULT_TECH_PROFILE_TABLE_ID, |
| 125 | DefaultNumGemPorts: defaultGemportsCount, |
Scott Baker | 2c1c482 | 2019-10-16 11:02:41 -0700 | [diff] [blame] | 126 | DefaultPbits: []string{defaultPbits}, |
| 127 | LogLevel: defaultLogLevel, |
| 128 | } |
| 129 | |
| 130 | return &techProfileFlags |
| 131 | } |