blob: 60ddd80476c69f4869136387c2e4642ac9645124 [file] [log] [blame]
William Kurkian3687c572019-10-11 15:29:17 -04001/*
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
Zdravko Bozakov3d762142019-07-15 16:57:17 +020017package core
18
19type PerformanceMonitoringHistoryData int
20
21const (
22 _ = iota
23 IntervalEndTime PerformanceMonitoringHistoryData = 0x8000
24 ThresholdDataId PerformanceMonitoringHistoryData = 0x4000
25 FCSErrors PerformanceMonitoringHistoryData = 0x2000
26 ExcessiveCollisionCounter PerformanceMonitoringHistoryData = 0x1000
27 LateCollisionCounter PerformanceMonitoringHistoryData = 0x0800
28 FrameTooLong PerformanceMonitoringHistoryData = 0x0400
29 BufferOverflowOnReceive PerformanceMonitoringHistoryData = 0x0200
30 BufferOverflowOnTransmit PerformanceMonitoringHistoryData = 0x0100
31 SingleCollisionFrameCounter PerformanceMonitoringHistoryData = 0x0080
32 MultipleCollisionFrameCounter PerformanceMonitoringHistoryData = 0x0040
33 SQECounter PerformanceMonitoringHistoryData = 0x0020
34 DeferredTransmissionCounter PerformanceMonitoringHistoryData = 0x0010
35 InternalMACTransmitErrorCounter PerformanceMonitoringHistoryData = 0x0008
36 CarrierSenseErrorCounter PerformanceMonitoringHistoryData = 0x0004
37 AllignmentErrorCounter PerformanceMonitoringHistoryData = 0x0002
38 InternalMACReceiveErrorCounter PerformanceMonitoringHistoryData = 0x0001
39)
40
41type PMHistoryAttributeHandler func(*uint, []byte) ([]byte, error)
42
43var PMHistoryAttributeHandlers = map[PerformanceMonitoringHistoryData]ANIGAttributeHandler{
44 IntervalEndTime : GetIntervalEndTime,
45 ThresholdDataId: GetThresholdDataId,
46 FCSErrors: GetFCSErrors,
47 ExcessiveCollisionCounter: GetExcessiveCollisionCounter,
48 LateCollisionCounter: GetLateCollisionCounter,
49 FrameTooLong: GetFrameTooLong,
50 BufferOverflowOnReceive: GetBufferOverflowOnReceive,
51 BufferOverflowOnTransmit: GetBufferOverflowOnTransmit,
52 SingleCollisionFrameCounter: GetSingleCollisionFrameCounter,
53 MultipleCollisionFrameCounter: GetMultipleCollisionFrameCounter,
54 SQECounter: GetSQECounter,
55 DeferredTransmissionCounter: GetDeferredTransmissionCounter,
56 InternalMACTransmitErrorCounter: GetInternalMACTransmitErrorCounter,
57 CarrierSenseErrorCounter: GetCarrierSenseErrorCounter,
58 AllignmentErrorCounter: GetAllignmentErrorCounter,
59 InternalMACReceiveErrorCounter: GetInternalMACReceiveErrorCounter,
60}
61
62func GetEthernetPMHistoryDataAttributes(pos *uint, pkt []byte, content OmciContent) ([]byte, error) {
63 AttributesMask := getAttributeMask(content)
64
65 for index := uint(16); index>=1 ; index-- {
66 Attribute := 1 << (index - 1)
67 reqAttribute := Attribute & AttributesMask
68
69 if reqAttribute != 0 {
70 pkt, _ = PMHistoryAttributeHandlers[PerformanceMonitoringHistoryData(reqAttribute)](pos, pkt)
71 }
72 }
73
74 pkt[8] = 0x00 // Command Processed Successfully
75 pkt[9] = uint8(AttributesMask >> 8)
76 pkt[10] = uint8(AttributesMask & 0x00FF)
77
78 return pkt, nil
79
80}
81
82func GetIntervalEndTime(pos *uint, pkt []byte) ([]byte, error) {
83 // With the hardware, it is seen that all attributes are 0x00
84 // Nevertheless these functions are made to provide specific values in future if required
85 *pos++
86 return pkt, nil
87}
88
89func GetThresholdDataId(pos *uint, pkt []byte) ([]byte, error) {
90 *pos++
91 *pos++
92 return pkt, nil
93}
94
95func GetFCSErrors(pos *uint, pkt []byte) ([]byte, error) {
96 *pos++
97 *pos++
98 *pos++
99 *pos++
100 return pkt, nil
101}
102
103func GetExcessiveCollisionCounter(pos *uint, pkt []byte) ([]byte, error) {
104 *pos++
105 *pos++
106 *pos++
107 *pos++
108 return pkt, nil
109}
110
111func GetLateCollisionCounter(pos *uint, pkt []byte) ([]byte, error) {
112 *pos++
113 *pos++
114 *pos++
115 *pos++
116 return pkt, nil
117}
118
119func GetFrameTooLong(pos *uint, pkt []byte) ([]byte, error) {
120 *pos++
121 *pos++
122 *pos++
123 *pos++
124 return pkt, nil
125}
126
127func GetBufferOverflowOnReceive(pos *uint, pkt []byte) ([]byte, error) {
128 *pos++
129 *pos++
130 *pos++
131 *pos++
132 return pkt, nil
133}
134
135func GetBufferOverflowOnTransmit(pos *uint, pkt []byte) ([]byte, error) {
136 *pos++
137 *pos++
138 *pos++
139 *pos++
140 return pkt, nil
141}
142
143func GetSingleCollisionFrameCounter(pos *uint, pkt []byte) ([]byte, error) {
144 *pos++
145 *pos++
146 *pos++
147 *pos++
148 return pkt, nil
149}
150
151func GetMultipleCollisionFrameCounter(pos *uint, pkt []byte) ([]byte, error) {
152 *pos++
153 *pos++
154 *pos++
155 *pos++
156 return pkt, nil
157}
158
159func GetSQECounter(pos *uint, pkt []byte) ([]byte, error) {
160 *pos++
161 *pos++
162 *pos++
163 *pos++
164 return pkt, nil
165}
166
167func GetDeferredTransmissionCounter(pos *uint, pkt []byte) ([]byte, error) {
168 *pos++
169 *pos++
170 *pos++
171 *pos++
172 return pkt, nil
173}
174
175func GetInternalMACTransmitErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
176 *pos++
177 *pos++
178 *pos++
179 *pos++
180 return pkt, nil
181}
182
183func GetCarrierSenseErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
184 *pos++
185 *pos++
186 *pos++
187 *pos++
188 return pkt, nil
189}
190
191func GetAllignmentErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
192 *pos++
193 *pos++
194 *pos++
195 *pos++
196 return pkt, nil
197}
198
199func GetInternalMACReceiveErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
200 *pos++
201 *pos++
202 *pos++
203 *pos++
204 return pkt, nil
205}
206
207