blob: 23d2e99ea018c37e9cfc0609ca39386039c14017 [file] [log] [blame]
Matteo Scandoloef4e8f82021-05-17 11:20:49 -07001/*
2 * Copyright 2018-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
17package omci
18
19import (
Matteo Scandolo8a574812021-05-20 15:18:53 -070020 "bytes"
Matteo Scandoloef4e8f82021-05-17 11:20:49 -070021 "encoding/binary"
22 "encoding/hex"
Matteo Scandolocfedba42022-02-14 16:08:54 -080023 "github.com/google/gopacket"
Elia Battistonb7bea222022-02-18 16:25:00 +010024 "github.com/opencord/bbsim/internal/common"
Matteo Scandolocfedba42022-02-14 16:08:54 -080025 "github.com/opencord/omci-lib-go/v2"
Andrea Campanella10426e22021-10-15 17:58:04 +020026 me "github.com/opencord/omci-lib-go/v2/generated"
Matteo Scandoloef4e8f82021-05-17 11:20:49 -070027)
28
Matteo Scandolocfedba42022-02-14 16:08:54 -080029// MibDbEntry contains all the information needed to build a
30// MibUploadNextResponse packet.
31// if Packet has a value all the other fields are ignored and the packet is sent as is.
Matteo Scandoloef4e8f82021-05-17 11:20:49 -070032type MibDbEntry struct {
33 classId me.ClassID
34 entityId EntityID
35 params me.AttributeValueMap
Matteo Scandolocfedba42022-02-14 16:08:54 -080036 packet []byte
Matteo Scandoloef4e8f82021-05-17 11:20:49 -070037}
38
39type MibDb struct {
40 NumberOfCommands uint16
41 items []MibDbEntry
42}
43
44type EntityID []byte
45
46func (e EntityID) ToString() string {
47 return hex.EncodeToString(e)
48}
49
50func (e EntityID) ToUint16() uint16 {
51 return binary.BigEndian.Uint16(e)
52}
53
54func (e EntityID) ToUint32() uint32 {
55 return binary.BigEndian.Uint32(e)
56}
57
Matteo Scandolo8a574812021-05-20 15:18:53 -070058func (e EntityID) FromUint16(id uint16) EntityID {
59 buff := new(bytes.Buffer)
60 err := binary.Write(buff, binary.BigEndian, id)
61 if err != nil {
62 panic(err)
63 }
64
65 return buff.Bytes()
66}
67
68func (e EntityID) Equals(i EntityID) bool {
69 if res := bytes.Compare(e, i); res == 0 {
70 return true
71 }
72 return false
73}
74
Matteo Scandoloef4e8f82021-05-17 11:20:49 -070075const (
76 cardHolderOnuType byte = 0x01 // ONU is a single piece of integrated equipment
77 ethernetUnitType byte = 0x2f // Ethernet BASE-T
78 xgsPonUnitType byte = 0xee // XG-PON10G10
Elia Battistonb7bea222022-02-18 16:25:00 +010079 gPonUnitType byte = 0xf5 // GPON12441244
Elia Battistonac63b112022-01-12 18:40:49 +010080 potsUnitType byte = 0x20 // POTS
Matteo Scandoloef4e8f82021-05-17 11:20:49 -070081 cardHolderSlotID byte = 0x01
82 tcontSlotId byte = 0x80 // why is this not the same as the cardHolderSlotID, it does not point to anything
83 aniGId byte = 0x01
84
85 upstreamPriorityQueues = 8 // Number of queues for each T-CONT
86 downstreamPriorityQueues = 16 // Number of queues for each PPTP
87 tconts = 8 // NOTE will we ever need to configure this?
88 // trafficSchedulers = 8 // NOTE will we ever need to configure this?
89)
90
91var (
92 cardHolderEntityID = EntityID{cardHolderOnuType, cardHolderSlotID}
93 circuitPackEntityID = cardHolderEntityID // is the same as that of the cardholder ME containing this circuit pack instance
94)
95
96func GenerateUniPortEntityId(id uint32) EntityID {
97 return EntityID{cardHolderSlotID, byte(id)}
98}
99
100// creates a MIB database for a ONU
101// CircuitPack and CardHolder are static, everything else can be configured
Elia Battistonb7bea222022-02-18 16:25:00 +0100102func GenerateMibDatabase(ethUniPortCount int, potsUniPortCount int, technology common.PonTechnology) (*MibDb, error) {
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700103
104 mibDb := MibDb{
105 items: []MibDbEntry{},
106 }
107
108 // the first element to return is the ONU-Data
109 mibDb.items = append(mibDb.items, MibDbEntry{
110 me.OnuDataClassID,
111 EntityID{0x00, 0x00},
Elia Battiston9bfe1102022-02-03 10:38:03 +0100112 me.AttributeValueMap{me.OnuData_MibDataSync: 0}, // FIXME this needs to be parametrized before sending the response
Matteo Scandolocfedba42022-02-14 16:08:54 -0800113 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700114 })
115
116 // then we report the CardHolder
117 // NOTE we have not report it till now, so leave it commented out
118 //mibDb.items = append(mibDb.items, MibDbEntry{
119 // me.CardholderClassID,
120 // cardHolderEntityID,
121 // me.AttributeValueMap{
122 // "ActualPlugInUnitType": cardHolderOnuType,
123 // "ExpectedPlugInUnitType": ethernetUnitType,
124 // },
125 //})
126
Elia Battistonb7bea222022-02-18 16:25:00 +0100127 // ANI circuitPack
128 var aniCPType byte
129
130 switch technology {
131 case common.XGSPON:
132 aniCPType = xgsPonUnitType
133 case common.GPON:
134 aniCPType = gPonUnitType
135 }
136
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700137 mibDb.items = append(mibDb.items, MibDbEntry{
138 me.CircuitPackClassID,
139 circuitPackEntityID,
140 me.AttributeValueMap{
Elia Battistonb7bea222022-02-18 16:25:00 +0100141 me.CircuitPack_Type: aniCPType,
Elia Battiston9bfe1102022-02-03 10:38:03 +0100142 me.CircuitPack_NumberOfPorts: 1, // NOTE is this the ANI port? must be
143 me.CircuitPack_SerialNumber: ToOctets("BBSM-Circuit-Pack-ani", 20),
144 me.CircuitPack_Version: ToOctets("v0.0.1", 20),
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700145 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800146 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700147 })
148 mibDb.items = append(mibDb.items, MibDbEntry{
149 me.CircuitPackClassID,
150 circuitPackEntityID,
151 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100152 me.CircuitPack_VendorId: ToOctets("ONF", 4),
153 me.CircuitPack_AdministrativeState: 0,
154 me.CircuitPack_OperationalState: 0,
155 me.CircuitPack_BridgedOrIpInd: 0,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700156 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800157 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700158 })
159 mibDb.items = append(mibDb.items, MibDbEntry{
160 me.CircuitPackClassID,
161 circuitPackEntityID,
162 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100163 me.CircuitPack_EquipmentId: ToOctets("BBSM-Circuit-Pack", 20),
164 me.CircuitPack_CardConfiguration: 0,
165 me.CircuitPack_TotalTContBufferNumber: 8,
166 me.CircuitPack_TotalPriorityQueueNumber: 8,
167 me.CircuitPack_TotalTrafficSchedulerNumber: 0,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700168 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800169 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700170 })
171 mibDb.items = append(mibDb.items, MibDbEntry{
172 me.CircuitPackClassID,
173 circuitPackEntityID,
174 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100175 me.CircuitPack_PowerShedOverride: uint32(0),
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700176 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800177 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700178 })
179
180 // ANI-G
181 mibDb.items = append(mibDb.items, MibDbEntry{
182 me.AniGClassID,
183 EntityID{tcontSlotId, aniGId},
184 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100185 me.AniG_Arc: 0,
186 me.AniG_ArcInterval: 0,
187 me.AniG_Deprecated: 0,
188 me.AniG_GemBlockLength: 48,
189 me.AniG_LowerOpticalThreshold: 255,
190 me.AniG_LowerTransmitPowerThreshold: 129,
191 me.AniG_OnuResponseTime: 0,
192 me.AniG_OpticalSignalLevel: 57428,
193 me.AniG_PiggybackDbaReporting: 0,
194 me.AniG_SignalDegradeThreshold: 9,
195 me.AniG_SignalFailThreshold: 5,
196 me.AniG_SrIndication: 1,
197 me.AniG_TotalTcontNumber: 8,
198 me.AniG_TransmitOpticalLevel: 3171,
199 me.AniG_UpperOpticalThreshold: 255,
200 me.AniG_UpperTransmitPowerThreshold: 129,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700201 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800202 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700203 })
204
205 // circuitPack Ethernet
206 // NOTE the circuit pack is divided in multiple messages as too big to fit in a single one
207 mibDb.items = append(mibDb.items, MibDbEntry{
208 me.CircuitPackClassID,
209 circuitPackEntityID,
210 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100211 me.CircuitPack_Type: ethernetUnitType,
212 me.CircuitPack_NumberOfPorts: ethUniPortCount,
213 me.CircuitPack_SerialNumber: ToOctets("BBSM-Circuit-Pack", 20),
214 me.CircuitPack_Version: ToOctets("v0.0.1", 20),
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700215 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800216 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700217 })
218 mibDb.items = append(mibDb.items, MibDbEntry{
219 me.CircuitPackClassID,
220 circuitPackEntityID,
221 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100222 me.CircuitPack_VendorId: ToOctets("ONF", 4),
223 me.CircuitPack_AdministrativeState: 0,
224 me.CircuitPack_OperationalState: 0,
225 me.CircuitPack_BridgedOrIpInd: 0,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700226 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800227 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700228 })
229 mibDb.items = append(mibDb.items, MibDbEntry{
230 me.CircuitPackClassID,
231 circuitPackEntityID,
232 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100233 me.CircuitPack_EquipmentId: ToOctets("BBSM-Circuit-Pack", 20),
234 me.CircuitPack_CardConfiguration: 0,
235 me.CircuitPack_TotalTContBufferNumber: 8,
236 me.CircuitPack_TotalPriorityQueueNumber: 8,
237 me.CircuitPack_TotalTrafficSchedulerNumber: 16,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700238 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800239 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700240 })
241 mibDb.items = append(mibDb.items, MibDbEntry{
242 me.CircuitPackClassID,
243 circuitPackEntityID,
244 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100245 me.CircuitPack_PowerShedOverride: uint32(0),
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700246 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800247 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700248 })
249
Elia Battistonac63b112022-01-12 18:40:49 +0100250 if potsUniPortCount > 0 {
251 // circuitPack POTS
252 // NOTE the circuit pack is divided in multiple messages as too big to fit in a single one
253 mibDb.items = append(mibDb.items, MibDbEntry{
254 me.CircuitPackClassID,
255 circuitPackEntityID,
256 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100257 me.CircuitPack_Type: potsUnitType,
258 me.CircuitPack_NumberOfPorts: potsUniPortCount,
259 me.CircuitPack_SerialNumber: ToOctets("BBSM-Circuit-Pack", 20),
260 me.CircuitPack_Version: ToOctets("v0.0.1", 20),
Elia Battistonac63b112022-01-12 18:40:49 +0100261 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800262 nil,
Elia Battistonac63b112022-01-12 18:40:49 +0100263 })
264 mibDb.items = append(mibDb.items, MibDbEntry{
265 me.CircuitPackClassID,
266 circuitPackEntityID,
267 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100268 me.CircuitPack_VendorId: ToOctets("ONF", 4),
269 me.CircuitPack_AdministrativeState: 0,
270 me.CircuitPack_OperationalState: 0,
271 me.CircuitPack_BridgedOrIpInd: 0,
Elia Battistonac63b112022-01-12 18:40:49 +0100272 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800273 nil,
Elia Battistonac63b112022-01-12 18:40:49 +0100274 })
275 mibDb.items = append(mibDb.items, MibDbEntry{
276 me.CircuitPackClassID,
277 circuitPackEntityID,
278 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100279 me.CircuitPack_EquipmentId: ToOctets("BBSM-Circuit-Pack", 20),
280 me.CircuitPack_CardConfiguration: 0,
281 me.CircuitPack_TotalTContBufferNumber: 8,
282 me.CircuitPack_TotalPriorityQueueNumber: 8,
283 me.CircuitPack_TotalTrafficSchedulerNumber: 16,
Elia Battistonac63b112022-01-12 18:40:49 +0100284 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800285 nil,
Elia Battistonac63b112022-01-12 18:40:49 +0100286 })
287 mibDb.items = append(mibDb.items, MibDbEntry{
288 me.CircuitPackClassID,
289 circuitPackEntityID,
290 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100291 me.CircuitPack_PowerShedOverride: uint32(0),
Elia Battistonac63b112022-01-12 18:40:49 +0100292 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800293 nil,
Elia Battistonac63b112022-01-12 18:40:49 +0100294 })
295 }
296
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700297 // PPTP and UNI-Gs
298 // NOTE this are dependent on the number of UNI this ONU supports
299 // Through an identical ID, the UNI-G ME is implicitly linked to an instance of a PPTP
Elia Battistonac63b112022-01-12 18:40:49 +0100300 totalPortsCount := ethUniPortCount + potsUniPortCount
301 for i := 1; i <= totalPortsCount; i++ {
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700302 uniEntityId := GenerateUniPortEntityId(uint32(i))
303
Elia Battistonac63b112022-01-12 18:40:49 +0100304 if i <= ethUniPortCount {
305 // first, create the correct amount of ethernet UNIs, the same is done in onu.go
306 mibDb.items = append(mibDb.items, MibDbEntry{
307 me.PhysicalPathTerminationPointEthernetUniClassID,
308 uniEntityId,
309 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100310 me.PhysicalPathTerminationPointEthernetUni_ExpectedType: 0,
311 me.PhysicalPathTerminationPointEthernetUni_SensedType: ethernetUnitType,
312 me.PhysicalPathTerminationPointEthernetUni_AutoDetectionConfiguration: 0,
313 me.PhysicalPathTerminationPointEthernetUni_EthernetLoopbackConfiguration: 0,
314 me.PhysicalPathTerminationPointEthernetUni_AdministrativeState: 0,
315 me.PhysicalPathTerminationPointEthernetUni_OperationalState: 0,
316 me.PhysicalPathTerminationPointEthernetUni_ConfigurationInd: 3,
317 me.PhysicalPathTerminationPointEthernetUni_MaxFrameSize: 1518,
318 me.PhysicalPathTerminationPointEthernetUni_DteOrDceInd: 0,
319 me.PhysicalPathTerminationPointEthernetUni_PauseTime: 0,
320 me.PhysicalPathTerminationPointEthernetUni_BridgedOrIpInd: 2,
321 me.PhysicalPathTerminationPointEthernetUni_Arc: 0,
322 me.PhysicalPathTerminationPointEthernetUni_ArcInterval: 0,
323 me.PhysicalPathTerminationPointEthernetUni_PppoeFilter: 0,
324 me.PhysicalPathTerminationPointEthernetUni_PowerControl: 0,
Elia Battistonac63b112022-01-12 18:40:49 +0100325 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800326 nil,
Elia Battistonac63b112022-01-12 18:40:49 +0100327 })
328 } else {
329 // the remaining ones are pots UNIs, the same is done in onu.go
330 mibDb.items = append(mibDb.items, MibDbEntry{
331 me.PhysicalPathTerminationPointPotsUniClassID,
332 uniEntityId,
333 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100334 me.PhysicalPathTerminationPointPotsUni_AdministrativeState: 0,
335 me.PhysicalPathTerminationPointPotsUni_Deprecated: 0,
336 me.PhysicalPathTerminationPointPotsUni_Arc: 0,
337 me.PhysicalPathTerminationPointPotsUni_ArcInterval: 0,
338 me.PhysicalPathTerminationPointPotsUni_Impedance: 0,
339 me.PhysicalPathTerminationPointPotsUni_TransmissionPath: 0,
340 me.PhysicalPathTerminationPointPotsUni_RxGain: 0,
341 me.PhysicalPathTerminationPointPotsUni_TxGain: 0,
342 me.PhysicalPathTerminationPointPotsUni_OperationalState: 0,
343 me.PhysicalPathTerminationPointPotsUni_HookState: 0,
344 me.PhysicalPathTerminationPointPotsUni_PotsHoldoverTime: 0,
345 me.PhysicalPathTerminationPointPotsUni_NominalFeedVoltage: 0,
346 me.PhysicalPathTerminationPointPotsUni_LossOfSoftswitch: 0,
Elia Battistonac63b112022-01-12 18:40:49 +0100347 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800348 nil,
Elia Battistonac63b112022-01-12 18:40:49 +0100349 })
350 }
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700351
352 mibDb.items = append(mibDb.items, MibDbEntry{
353 me.UniGClassID,
354 uniEntityId,
355 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100356 me.UniG_AdministrativeState: 0,
357 me.UniG_Deprecated: 0,
358 me.UniG_ManagementCapability: 0,
359 me.UniG_NonOmciManagementIdentifier: 0,
360 me.UniG_RelayAgentOptions: 0,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700361 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800362 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700363 })
364
365 // Downstream Queues (related to PPTP)
366 // 16 priorities queues for each UNI Ports
367 // EntityID = cardHolderSlotID + Uni EntityID (0101)
368 for j := 1; j <= downstreamPriorityQueues; j++ {
369 queueEntityId := EntityID{cardHolderSlotID, byte(j)}
370
371 // we first report the PriorityQueue without any attribute
372 mibDb.items = append(mibDb.items, MibDbEntry{
373 me.PriorityQueueClassID,
374 queueEntityId, //was not reported in the original implementation
375 me.AttributeValueMap{},
Matteo Scandolocfedba42022-02-14 16:08:54 -0800376 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700377 })
378
379 // then we report it with the required attributes
380 // In the downstream direction, the first byte is the slot number and the second byte is the port number of the queue's destination port.
381 relatedPort := append(uniEntityId, 0x00, byte(j))
382 mibDb.items = append(mibDb.items, MibDbEntry{
383 me.PriorityQueueClassID,
384 queueEntityId, //was not reported in the original implementation
385 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100386 me.PriorityQueue_QueueConfigurationOption: 0,
387 me.PriorityQueue_MaximumQueueSize: 100,
388 me.PriorityQueue_AllocatedQueueSize: 100,
389 me.PriorityQueue_DiscardBlockCounterResetInterval: 0,
390 me.PriorityQueue_ThresholdValueForDiscardedBlocksDueToBufferOverflow: 0,
391 me.PriorityQueue_RelatedPort: relatedPort.ToUint32(),
392 me.PriorityQueue_TrafficSchedulerPointer: 0, //it was hardcoded to 0x0108 in the current implementation
393 me.PriorityQueue_Weight: 1,
394 me.PriorityQueue_BackPressureOperation: 1,
395 me.PriorityQueue_BackPressureTime: 0,
396 me.PriorityQueue_BackPressureOccurQueueThreshold: 0,
397 me.PriorityQueue_BackPressureClearQueueThreshold: 0,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700398 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800399 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700400 })
401 }
402 }
403
404 // T-CONTS and Traffic Schedulers
405 for i := 1; i <= tconts; i++ {
406 tcontEntityId := EntityID{tcontSlotId, byte(i)}
407
408 mibDb.items = append(mibDb.items, MibDbEntry{
409 me.TContClassID,
410 tcontEntityId,
411 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100412 me.TCont_AllocId: 65535,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700413 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800414 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700415 })
416
417 tsEntityId := EntityID{cardHolderSlotID, byte(i)}
418 mibDb.items = append(mibDb.items, MibDbEntry{
419 me.TrafficSchedulerClassID,
420 tsEntityId, //was not reported in the original implementation
421 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100422 me.TrafficScheduler_TContPointer: tcontEntityId.ToUint16(), // was hardcoded to a non-existing t-cont
423 me.TrafficScheduler_TrafficSchedulerPointer: 0,
424 me.TrafficScheduler_Policy: 02,
425 me.TrafficScheduler_PriorityWeight: 0,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700426 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800427 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700428 })
429
430 for j := 1; j <= upstreamPriorityQueues; j++ {
431 queueEntityId := EntityID{tcontSlotId, byte(j)}
432 // Upstream Queues (related to traffic schedulers)
433 // 8 priorities queues per TCONT
434 // EntityID = tcontSlotId + Uni EntityID (8001)
435
436 // we first report the PriorityQueue without any attribute
437 mibDb.items = append(mibDb.items, MibDbEntry{
438 me.PriorityQueueClassID,
439 queueEntityId, //was not reported in the original implementation
440 me.AttributeValueMap{},
Matteo Scandolocfedba42022-02-14 16:08:54 -0800441 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700442 })
443
444 // then we report it with the required attributes
445 // In the upstream direction, the first 2 bytes are the ME ID of the associated T- CONT, the first byte of which is a slot number, the second byte a T-CONT number.
446 relatedPort := append(tcontEntityId, 0x00, byte(j))
447 mibDb.items = append(mibDb.items, MibDbEntry{
448 me.PriorityQueueClassID,
449 queueEntityId, //was not reported in the original implementation
450 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100451 me.PriorityQueue_QueueConfigurationOption: 0,
452 me.PriorityQueue_MaximumQueueSize: 100,
453 me.PriorityQueue_AllocatedQueueSize: 100,
454 me.PriorityQueue_DiscardBlockCounterResetInterval: 0,
455 me.PriorityQueue_ThresholdValueForDiscardedBlocksDueToBufferOverflow: 0,
456 me.PriorityQueue_RelatedPort: relatedPort.ToUint32(),
457 me.PriorityQueue_TrafficSchedulerPointer: tsEntityId.ToUint16(), //it was hardcoded to 0x0108 in the current implementation
458 me.PriorityQueue_Weight: 1,
459 me.PriorityQueue_BackPressureOperation: 1,
460 me.PriorityQueue_BackPressureTime: 0,
461 me.PriorityQueue_BackPressureOccurQueueThreshold: 0,
462 me.PriorityQueue_BackPressureClearQueueThreshold: 0,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700463 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800464 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700465 })
466 }
467 }
468
469 // ONU-2g
470 mibDb.items = append(mibDb.items, MibDbEntry{
471 me.Onu2GClassID,
472 EntityID{0x00, 0x00},
473 me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100474 me.Onu2G_ConnectivityCapability: 127,
475 me.Onu2G_CurrentConnectivityMode: 0,
476 me.Onu2G_Deprecated: 1,
477 me.Onu2G_PriorityQueueScaleFactor: 1,
478 me.Onu2G_QualityOfServiceQosConfigurationFlexibility: 63,
479 me.Onu2G_Sysuptime: 0,
480 me.Onu2G_TotalGemPortIdNumber: 8,
481 me.Onu2G_TotalPriorityQueueNumber: 64,
482 me.Onu2G_TotalTrafficSchedulerNumber: 8,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700483 },
Matteo Scandolocfedba42022-02-14 16:08:54 -0800484 nil,
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700485 })
486
Matteo Scandolocfedba42022-02-14 16:08:54 -0800487 if common.Config.BBSim.InjectOmciUnknownAttributes {
488 // NOTE the TxID is actually replaced
489 // by SetTxIdInEncodedPacket in CreateMibUploadNextResponse
490 txId := uint16(33066)
491
492 b := make([]byte, 4)
493 binary.BigEndian.PutUint16(b, txId)
494 b[2] = byte(omci.MibUploadNextResponseType)
495 b[3] = byte(omci.BaselineIdent)
496 omciHdr := hex.EncodeToString(b)
497
498 //omciHdr := "00032e0a"
499 msgHdr := "00020000"
500 reportedMeHdr := "002500018000"
501 attr := "0102030405060708090A0B0C0D0E0F101112131415161718191A"
502 trailer := "0000002828ce00e2"
503 msg := omciHdr + msgHdr + reportedMeHdr + attr + trailer
504 data, err := hex.DecodeString(msg)
505 if err != nil {
506 omciLogger.Fatal("cannot-create-custom-packet")
507 }
508
509 packet := gopacket.NewPacket(data, omci.LayerTypeOMCI, gopacket.Lazy)
510
511 mibDb.items = append(mibDb.items, MibDbEntry{
512 me.ClassID(37), // G.988 "Intentionally left blank"
513 nil,
514 me.AttributeValueMap{},
515 packet.Data(),
516 })
517 }
518
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700519 mibDb.NumberOfCommands = uint16(len(mibDb.items))
520
521 return &mibDb, nil
522}