Matteo Scandolo | 1100699 | 2019-08-28 11:29:46 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 17 | package devices |
| 18 | |
| 19 | import ( |
| 20 | "context" |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 21 | "encoding/hex" |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 22 | "fmt" |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame^] | 23 | "github.com/opencord/bbsim/internal/bbsim/responders/dhcp" |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 24 | "github.com/opencord/voltha-protos/v4/go/ext/config" |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 25 | "net" |
| 26 | "sync" |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 27 | "time" |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 28 | |
Matteo Scandolo | 47e69bb | 2019-08-28 15:41:12 -0700 | [diff] [blame] | 29 | "github.com/google/gopacket" |
| 30 | "github.com/google/gopacket/layers" |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 31 | "github.com/looplab/fsm" |
Matteo Scandolo | f6f3a7f | 2019-10-11 11:19:29 -0700 | [diff] [blame] | 32 | "github.com/opencord/bbsim/internal/bbsim/packetHandlers" |
Zdravko Bozakov | 3ddb245 | 2019-11-29 14:33:41 +0100 | [diff] [blame] | 33 | "github.com/opencord/bbsim/internal/common" |
William Kurkian | 9dadc5b | 2019-10-22 13:51:57 -0400 | [diff] [blame] | 34 | omcisim "github.com/opencord/omci-sim" |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 35 | common_protos "github.com/opencord/voltha-protos/v4/go/common" |
| 36 | "github.com/opencord/voltha-protos/v4/go/openolt" |
| 37 | "github.com/opencord/voltha-protos/v4/go/tech_profile" |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 38 | log "github.com/sirupsen/logrus" |
| 39 | "google.golang.org/grpc" |
Pragya Arya | 8bdb453 | 2020-03-02 17:08:09 +0530 | [diff] [blame] | 40 | "google.golang.org/grpc/codes" |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 41 | "google.golang.org/grpc/reflection" |
Pragya Arya | 8bdb453 | 2020-03-02 17:08:09 +0530 | [diff] [blame] | 42 | "google.golang.org/grpc/status" |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 43 | ) |
| 44 | |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 45 | var oltLogger = log.WithFields(log.Fields{ |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 46 | "module": "OLT", |
| 47 | }) |
| 48 | |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 49 | type OltDevice struct { |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 50 | sync.Mutex |
| 51 | |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 52 | // BBSIM Internals |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 53 | ID int |
| 54 | SerialNumber string |
| 55 | NumNni int |
| 56 | NumPon int |
| 57 | NumOnuPerPon int |
| 58 | InternalState *fsm.FSM |
| 59 | channel chan Message |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame^] | 60 | dhcpServer dhcp.DHCPServerIf |
Pragya Arya | 8bdb453 | 2020-03-02 17:08:09 +0530 | [diff] [blame] | 61 | Flows map[FlowKey]openolt.Flow |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 62 | Delay int |
| 63 | ControlledActivation mode |
Pragya Arya | 324337e | 2020-02-20 14:35:08 +0530 | [diff] [blame] | 64 | EventChannel chan common.Event |
| 65 | PublishEvents bool |
Pragya Arya | 996a089 | 2020-03-09 21:47:52 +0530 | [diff] [blame] | 66 | PortStatsInterval int |
Matteo Scandolo | e33447a | 2019-10-31 12:38:23 -0700 | [diff] [blame] | 67 | |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 68 | Pons []*PonPort |
| 69 | Nnis []*NniPort |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 70 | |
| 71 | // OLT Attributes |
| 72 | OperState *fsm.FSM |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 73 | |
| 74 | enableContext context.Context |
| 75 | enableContextCancel context.CancelFunc |
Pragya Arya | 1cbefa4 | 2020-01-13 12:15:29 +0530 | [diff] [blame] | 76 | |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 77 | OpenoltStream openolt.Openolt_EnableIndicationServer |
Anand S Katti | 0954135 | 2020-01-29 15:54:01 +0530 | [diff] [blame] | 78 | enablePerf bool |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 79 | } |
| 80 | |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 81 | var olt OltDevice |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 82 | var oltServer *grpc.Server |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 83 | |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 84 | func GetOLT() *OltDevice { |
| 85 | return &olt |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 88 | func CreateOLT(options common.GlobalConfig, services []common.ServiceYaml, isMock bool) *OltDevice { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 89 | oltLogger.WithFields(log.Fields{ |
Pragya Arya | 996a089 | 2020-03-09 21:47:52 +0530 | [diff] [blame] | 90 | "ID": options.Olt.ID, |
| 91 | "NumNni": options.Olt.NniPorts, |
| 92 | "NumPon": options.Olt.PonPorts, |
| 93 | "NumOnuPerPon": options.Olt.OnusPonPort, |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 94 | }).Debug("CreateOLT") |
| 95 | |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 96 | olt = OltDevice{ |
Pragya Arya | 996a089 | 2020-03-09 21:47:52 +0530 | [diff] [blame] | 97 | ID: options.Olt.ID, |
| 98 | SerialNumber: fmt.Sprintf("BBSIM_OLT_%d", options.Olt.ID), |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 99 | OperState: getOperStateFSM(func(e *fsm.Event) { |
| 100 | oltLogger.Debugf("Changing OLT OperState from %s to %s", e.Src, e.Dst) |
| 101 | }), |
Pragya Arya | 996a089 | 2020-03-09 21:47:52 +0530 | [diff] [blame] | 102 | NumNni: int(options.Olt.NniPorts), |
| 103 | NumPon: int(options.Olt.PonPorts), |
| 104 | NumOnuPerPon: int(options.Olt.OnusPonPort), |
| 105 | Pons: []*PonPort{}, |
| 106 | Nnis: []*NniPort{}, |
| 107 | Delay: options.BBSim.Delay, |
| 108 | Flows: make(map[FlowKey]openolt.Flow), |
| 109 | enablePerf: options.BBSim.EnablePerf, |
| 110 | PublishEvents: options.BBSim.Events, |
| 111 | PortStatsInterval: options.Olt.PortStatsInterval, |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame^] | 112 | dhcpServer: dhcp.NewDHCPServer(), |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Pragya Arya | 996a089 | 2020-03-09 21:47:52 +0530 | [diff] [blame] | 115 | if val, ok := ControlledActivationModes[options.BBSim.ControlledActivation]; ok { |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 116 | olt.ControlledActivation = val |
| 117 | } else { |
Matteo Scandolo | adc72a8 | 2020-09-08 18:46:08 -0700 | [diff] [blame] | 118 | // FIXME throw an error if the ControlledActivation is not valid |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 119 | oltLogger.Warn("Unknown ControlledActivation Mode given, running in Default mode") |
| 120 | olt.ControlledActivation = Default |
| 121 | } |
| 122 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 123 | // OLT State machine |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 124 | // NOTE do we need 2 state machines for the OLT? (InternalState and OperState) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 125 | olt.InternalState = fsm.NewFSM( |
| 126 | "created", |
| 127 | fsm.Events{ |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 128 | {Name: "initialize", Src: []string{"created", "deleted"}, Dst: "initialized"}, |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 129 | {Name: "enable", Src: []string{"initialized", "disabled"}, Dst: "enabled"}, |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 130 | {Name: "disable", Src: []string{"enabled"}, Dst: "disabled"}, |
Matteo Scandolo | 635b2bf | 2020-09-04 10:23:40 -0700 | [diff] [blame] | 131 | // delete event in enabled state below is for reboot OLT case. |
Mahir Gunyel | 6dad445 | 2020-01-06 12:59:04 -0800 | [diff] [blame] | 132 | {Name: "delete", Src: []string{"disabled", "enabled"}, Dst: "deleted"}, |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 133 | }, |
| 134 | fsm.Callbacks{ |
| 135 | "enter_state": func(e *fsm.Event) { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 136 | oltLogger.Debugf("Changing OLT InternalState from %s to %s", e.Src, e.Dst) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 137 | }, |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 138 | "enter_initialized": func(e *fsm.Event) { olt.InitOlt() }, |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 139 | }, |
| 140 | ) |
| 141 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 142 | if !isMock { |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 143 | // create NNI Port |
| 144 | nniPort, err := CreateNNI(&olt) |
| 145 | if err != nil { |
| 146 | oltLogger.Fatalf("Couldn't create NNI Port: %v", err) |
| 147 | } |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 148 | |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 149 | olt.Nnis = append(olt.Nnis, &nniPort) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 150 | } |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 151 | |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 152 | // Create device and Services |
| 153 | |
| 154 | nextCtag := map[string]int{} |
| 155 | nextStag := map[string]int{} |
| 156 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 157 | // create PON ports |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 158 | for i := 0; i < olt.NumPon; i++ { |
| 159 | p := CreatePonPort(&olt, uint32(i)) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 160 | |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 161 | // create ONU devices |
| 162 | for j := 0; j < olt.NumOnuPerPon; j++ { |
| 163 | delay := time.Duration(olt.Delay*j) * time.Millisecond |
| 164 | o := CreateONU(&olt, p, uint32(j+1), delay, isMock) |
Matteo Scandolo | f65e687 | 2020-04-15 15:18:43 -0700 | [diff] [blame] | 165 | |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 166 | for k, s := range common.Services { |
| 167 | |
| 168 | // find the correct cTag for this service |
| 169 | if _, ok := nextCtag[s.Name]; !ok { |
| 170 | // it's the first time we iterate over this service, |
| 171 | // so we start from the config value |
| 172 | nextCtag[s.Name] = s.CTag |
| 173 | } else { |
| 174 | // we have a previous value, so we check it |
| 175 | // if Allocation is unique, we increment, |
| 176 | // otherwise (shared) we do nothing |
| 177 | if s.CTagAllocation == common.TagAllocationUnique.String() { |
| 178 | nextCtag[s.Name] = nextCtag[s.Name] + 1 |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | // find the correct sTag for this service |
| 183 | if _, ok := nextStag[s.Name]; !ok { |
| 184 | nextStag[s.Name] = s.STag |
| 185 | } else { |
| 186 | if s.STagAllocation == common.TagAllocationUnique.String() { |
| 187 | nextStag[s.Name] = nextStag[s.Name] + 1 |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | mac := net.HardwareAddr{0x2e, 0x60, byte(olt.ID), byte(p.ID), byte(o.ID), byte(k)} |
| 192 | service, err := NewService(s.Name, mac, o, nextCtag[s.Name], nextStag[s.Name], |
| 193 | s.NeedsEapol, s.NeedsDchp, s.NeedsIgmp, s.TechnologyProfileID, s.UniTagMatch, |
| 194 | s.ConfigureMacAddress, s.UsPonCTagPriority, s.UsPonSTagPriority, s.DsPonCTagPriority, s.DsPonSTagPriority) |
| 195 | |
| 196 | if err != nil { |
| 197 | oltLogger.WithFields(log.Fields{ |
| 198 | "Err": err.Error(), |
| 199 | }).Fatal("Can't create Service") |
| 200 | } |
| 201 | |
| 202 | o.Services = append(o.Services, service) |
Matteo Scandolo | f65e687 | 2020-04-15 15:18:43 -0700 | [diff] [blame] | 203 | } |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 204 | p.Onus = append(p.Onus, o) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 205 | } |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 206 | olt.Pons = append(olt.Pons, p) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 207 | } |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 208 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 209 | if !isMock { |
Matteo Scandolo | d32c382 | 2019-11-26 15:57:46 -0700 | [diff] [blame] | 210 | if err := olt.InternalState.Event("initialize"); err != nil { |
| 211 | log.Errorf("Error initializing OLT: %v", err) |
| 212 | return nil |
| 213 | } |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 214 | } |
| 215 | |
Pragya Arya | 324337e | 2020-02-20 14:35:08 +0530 | [diff] [blame] | 216 | if olt.PublishEvents { |
| 217 | log.Debugf("BBSim event publishing is enabled") |
| 218 | // Create a channel to write event messages |
| 219 | olt.EventChannel = make(chan common.Event, 100) |
| 220 | } |
| 221 | |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 222 | return &olt |
| 223 | } |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 224 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 225 | func (o *OltDevice) InitOlt() { |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 226 | |
| 227 | if oltServer == nil { |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 228 | oltServer, _ = o.newOltServer() |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 229 | } else { |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 230 | // FIXME there should never be a server running if we are initializing the OLT |
| 231 | oltLogger.Fatal("OLT server already running.") |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | // create new channel for processOltMessages Go routine |
| 235 | o.channel = make(chan Message) |
| 236 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 237 | // FIXME we are assuming we have only one NNI |
| 238 | if o.Nnis[0] != nil { |
Matteo Scandolo | 401503a | 2019-12-11 14:48:14 -0800 | [diff] [blame] | 239 | // NOTE we want to make sure the state is down when we initialize the OLT, |
| 240 | // the NNI may be in a bad state after a disable/reboot as we are not disabling it for |
| 241 | // in-band management |
| 242 | o.Nnis[0].OperState.SetState("down") |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 243 | } |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 246 | func (o *OltDevice) RestartOLT() error { |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 247 | |
Matteo Scandolo | 635b2bf | 2020-09-04 10:23:40 -0700 | [diff] [blame] | 248 | softReboot := false |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 249 | rebootDelay := common.Config.Olt.OltRebootDelay |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 250 | |
| 251 | oltLogger.WithFields(log.Fields{ |
| 252 | "oltId": o.ID, |
| 253 | }).Infof("Simulating OLT restart... (%ds)", rebootDelay) |
| 254 | |
Matteo Scandolo | 635b2bf | 2020-09-04 10:23:40 -0700 | [diff] [blame] | 255 | if o.InternalState.Is("enabled") { |
| 256 | oltLogger.WithFields(log.Fields{ |
| 257 | "oltId": o.ID, |
| 258 | }).Info("This is an OLT soft reboot") |
| 259 | softReboot = true |
| 260 | } |
| 261 | |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 262 | // transition internal state to deleted |
| 263 | if err := o.InternalState.Event("delete"); err != nil { |
| 264 | oltLogger.WithFields(log.Fields{ |
| 265 | "oltId": o.ID, |
| 266 | }).Errorf("Error deleting OLT: %v", err) |
| 267 | return err |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | // TODO handle hard poweroff (i.e. no indications sent to Voltha) vs soft poweroff |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 271 | time.Sleep(1 * time.Second) // we need to give the OLT the time to respond to all the pending gRPC request before stopping the server |
| 272 | if err := o.StopOltServer(); err != nil { |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 273 | oltLogger.Errorf("Error in stopping OLT server") |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 274 | return err |
| 275 | } |
| 276 | |
Matteo Scandolo | 635b2bf | 2020-09-04 10:23:40 -0700 | [diff] [blame] | 277 | if softReboot { |
| 278 | for _, pon := range o.Pons { |
| 279 | if pon.InternalState.Current() == "enabled" { |
| 280 | // disable PONs |
| 281 | msg := Message{ |
| 282 | Type: PonIndication, |
| 283 | Data: PonIndicationMessage{ |
| 284 | OperState: DOWN, |
| 285 | PonPortID: pon.ID, |
| 286 | }, |
| 287 | } |
| 288 | o.channel <- msg |
| 289 | } |
| 290 | |
| 291 | for _, onu := range pon.Onus { |
| 292 | _ = onu.InternalState.Event("disable") |
| 293 | } |
| 294 | } |
| 295 | } else { |
| 296 | // PONs are already handled in the Disable call |
| 297 | for _, pon := range olt.Pons { |
| 298 | // ONUs are not automatically disabled when a PON goes down |
| 299 | // as it's possible that it's an admin down and in that case the ONUs need to keep their state |
| 300 | for _, onu := range pon.Onus { |
| 301 | _ = onu.InternalState.Event("disable") |
| 302 | } |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 303 | } |
| 304 | } |
| 305 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 306 | // terminate the OLT's processOltMessages go routine |
| 307 | close(o.channel) |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame^] | 308 | |
Matteo Scandolo | e9f5a6b | 2020-09-16 15:54:38 -0700 | [diff] [blame] | 309 | o.enableContextCancel() |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 310 | |
Zdravko Bozakov | 3ddb245 | 2019-11-29 14:33:41 +0100 | [diff] [blame] | 311 | time.Sleep(time.Duration(rebootDelay) * time.Second) |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 312 | |
| 313 | if err := o.InternalState.Event("initialize"); err != nil { |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 314 | oltLogger.WithFields(log.Fields{ |
| 315 | "oltId": o.ID, |
| 316 | }).Errorf("Error initializing OLT: %v", err) |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 317 | return err |
| 318 | } |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 319 | oltLogger.WithFields(log.Fields{ |
| 320 | "oltId": o.ID, |
| 321 | }).Info("OLT restart completed") |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 322 | return nil |
| 323 | } |
| 324 | |
| 325 | // newOltServer launches a new grpc server for OpenOLT |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 326 | func (o *OltDevice) newOltServer() (*grpc.Server, error) { |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 327 | address := common.Config.BBSim.OpenOltAddress |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 328 | lis, err := net.Listen("tcp", address) |
| 329 | if err != nil { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 330 | oltLogger.Fatalf("OLT failed to listen: %v", err) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 331 | } |
| 332 | grpcServer := grpc.NewServer() |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 333 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 334 | openolt.RegisterOpenoltServer(grpcServer, o) |
| 335 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 336 | reflection.Register(grpcServer) |
Matteo Scandolo | 47e69bb | 2019-08-28 15:41:12 -0700 | [diff] [blame] | 337 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 338 | go func() { _ = grpcServer.Serve(lis) }() |
Zdravko Bozakov | 958d81c | 2019-12-13 22:09:48 +0100 | [diff] [blame] | 339 | oltLogger.Debugf("OLT listening on %v", address) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 340 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 341 | return grpcServer, nil |
| 342 | } |
| 343 | |
| 344 | // StopOltServer stops the OpenOLT grpc server |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 345 | func (o *OltDevice) StopOltServer() error { |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 346 | // TODO handle poweroff vs graceful shutdown |
| 347 | if oltServer != nil { |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 348 | oltLogger.WithFields(log.Fields{ |
| 349 | "oltId": o.SerialNumber, |
| 350 | }).Warnf("Stopping OLT gRPC server") |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 351 | oltServer.Stop() |
| 352 | oltServer = nil |
Matteo Scandolo | 47e69bb | 2019-08-28 15:41:12 -0700 | [diff] [blame] | 353 | } |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 354 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 355 | return nil |
| 356 | } |
| 357 | |
| 358 | // Device Methods |
| 359 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 360 | // Enable implements the OpenOLT EnableIndicationServer functionality |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 361 | func (o *OltDevice) Enable(stream openolt.Openolt_EnableIndicationServer) { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 362 | oltLogger.Debug("Enable OLT called") |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 363 | rebootFlag := false |
Matteo Scandolo | 84f7d48 | 2019-08-08 19:00:47 -0700 | [diff] [blame] | 364 | |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 365 | // If enabled has already been called then an enabled context has |
| 366 | // been created. If this is the case then we want to cancel all the |
| 367 | // proessing loops associated with that enable before we recreate |
| 368 | // new ones |
| 369 | o.Lock() |
| 370 | if o.enableContext != nil && o.enableContextCancel != nil { |
Matteo Scandolo | 635b2bf | 2020-09-04 10:23:40 -0700 | [diff] [blame] | 371 | oltLogger.Info("This is an OLT reboot") |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 372 | o.enableContextCancel() |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 373 | rebootFlag = true |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 374 | } |
| 375 | o.enableContext, o.enableContextCancel = context.WithCancel(context.TODO()) |
| 376 | o.Unlock() |
| 377 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 378 | wg := sync.WaitGroup{} |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 379 | wg.Add(3) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 380 | |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 381 | o.OpenoltStream = stream |
Pragya Arya | 1cbefa4 | 2020-01-13 12:15:29 +0530 | [diff] [blame] | 382 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 383 | // create Go routine to process all OLT events |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 384 | go o.processOltMessages(o.enableContext, stream, &wg) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 385 | |
| 386 | // enable the OLT |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 387 | oltMsg := Message{ |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 388 | Type: OltIndication, |
| 389 | Data: OltIndicationMessage{ |
| 390 | OperState: UP, |
| 391 | }, |
| 392 | } |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 393 | o.channel <- oltMsg |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 394 | |
| 395 | // send NNI Port Indications |
| 396 | for _, nni := range o.Nnis { |
| 397 | msg := Message{ |
| 398 | Type: NniIndication, |
| 399 | Data: NniIndicationMessage{ |
| 400 | OperState: UP, |
| 401 | NniPortID: nni.ID, |
| 402 | }, |
| 403 | } |
| 404 | o.channel <- msg |
| 405 | } |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 406 | |
Matteo Scandolo | df3f85d | 2020-01-15 12:50:48 -0800 | [diff] [blame] | 407 | go o.processOmciMessages(o.enableContext, stream, &wg) |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 408 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 409 | if rebootFlag { |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 410 | for _, pon := range o.Pons { |
| 411 | if pon.InternalState.Current() == "disabled" { |
| 412 | msg := Message{ |
| 413 | Type: PonIndication, |
| 414 | Data: PonIndicationMessage{ |
| 415 | OperState: UP, |
| 416 | PonPortID: pon.ID, |
| 417 | }, |
| 418 | } |
| 419 | o.channel <- msg |
Matteo Scandolo | e60a505 | 2020-02-07 00:31:14 +0000 | [diff] [blame] | 420 | } |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 421 | } |
| 422 | } else { |
| 423 | |
| 424 | // 1. controlledActivation == Default: Send both PON and ONUs indications |
| 425 | // 2. controlledActivation == only-onu: that means only ONUs will be controlled activated, so auto send PON indications |
| 426 | |
| 427 | if o.ControlledActivation == Default || o.ControlledActivation == OnlyONU { |
| 428 | // send PON Port indications |
| 429 | for _, pon := range o.Pons { |
| 430 | msg := Message{ |
| 431 | Type: PonIndication, |
| 432 | Data: PonIndicationMessage{ |
| 433 | OperState: UP, |
| 434 | PonPortID: pon.ID, |
| 435 | }, |
| 436 | } |
| 437 | o.channel <- msg |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 438 | } |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 439 | } |
| 440 | } |
| 441 | |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 442 | oltLogger.Debug("Enable OLT Done") |
Pragya Arya | 996a089 | 2020-03-09 21:47:52 +0530 | [diff] [blame] | 443 | |
| 444 | if !o.enablePerf { |
| 445 | // Start a go routine to send periodic port stats to openolt adapter |
| 446 | go o.periodicPortStats(o.enableContext) |
| 447 | } |
| 448 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 449 | wg.Wait() |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 450 | } |
| 451 | |
Matteo Scandolo | df3f85d | 2020-01-15 12:50:48 -0800 | [diff] [blame] | 452 | func (o *OltDevice) processOmciMessages(ctx context.Context, stream openolt.Openolt_EnableIndicationServer, wg *sync.WaitGroup) { |
William Kurkian | 9dadc5b | 2019-10-22 13:51:57 -0400 | [diff] [blame] | 453 | ch := omcisim.GetChannel() |
| 454 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 455 | oltLogger.Debug("Starting OMCI Indication Channel") |
William Kurkian | 9dadc5b | 2019-10-22 13:51:57 -0400 | [diff] [blame] | 456 | |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 457 | loop: |
| 458 | for { |
| 459 | select { |
| 460 | case <-ctx.Done(): |
| 461 | oltLogger.Debug("OMCI processing canceled via context") |
| 462 | break loop |
| 463 | case message, ok := <-ch: |
| 464 | if !ok || ctx.Err() != nil { |
| 465 | oltLogger.Debug("OMCI processing canceled via channel close") |
| 466 | break loop |
| 467 | } |
Matteo Scandolo | df3f85d | 2020-01-15 12:50:48 -0800 | [diff] [blame] | 468 | |
| 469 | oltLogger.WithFields(log.Fields{ |
| 470 | "messageType": message.Type, |
| 471 | "OnuId": message.Data.OnuId, |
| 472 | "IntfId": message.Data.IntfId, |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 473 | }).Debug("Received message on OMCI Sim channel") |
Matteo Scandolo | df3f85d | 2020-01-15 12:50:48 -0800 | [diff] [blame] | 474 | |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 475 | onuId := message.Data.OnuId |
| 476 | intfId := message.Data.IntfId |
| 477 | onu, err := o.FindOnuById(intfId, onuId) |
| 478 | if err != nil { |
| 479 | oltLogger.Errorf("Failed to find onu: %v", err) |
| 480 | continue |
| 481 | } |
Matteo Scandolo | df3f85d | 2020-01-15 12:50:48 -0800 | [diff] [blame] | 482 | go onu.processOmciMessage(message, stream) |
William Kurkian | 9dadc5b | 2019-10-22 13:51:57 -0400 | [diff] [blame] | 483 | } |
William Kurkian | 9dadc5b | 2019-10-22 13:51:57 -0400 | [diff] [blame] | 484 | } |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 485 | |
| 486 | wg.Done() |
William Kurkian | 9dadc5b | 2019-10-22 13:51:57 -0400 | [diff] [blame] | 487 | } |
| 488 | |
Pragya Arya | 996a089 | 2020-03-09 21:47:52 +0530 | [diff] [blame] | 489 | func (o *OltDevice) periodicPortStats(ctx context.Context) { |
| 490 | var portStats *openolt.PortStatistics |
| 491 | for { |
| 492 | select { |
| 493 | case <-time.After(time.Duration(o.PortStatsInterval) * time.Second): |
| 494 | // send NNI port stats |
| 495 | for _, port := range o.Nnis { |
| 496 | incrementStat := true |
| 497 | if port.OperState.Current() == "down" { |
| 498 | incrementStat = false |
| 499 | } |
| 500 | portStats, port.PacketCount = getPortStats(port.PacketCount, incrementStat) |
| 501 | o.sendPortStatsIndication(portStats, port.ID, port.Type) |
| 502 | } |
| 503 | |
| 504 | // send PON port stats |
| 505 | for _, port := range o.Pons { |
| 506 | incrementStat := true |
| 507 | // do not increment port stats if PON port is down or no ONU is activated on PON port |
| 508 | if port.OperState.Current() == "down" || port.GetNumOfActiveOnus() < 1 { |
| 509 | incrementStat = false |
| 510 | } |
| 511 | portStats, port.PacketCount = getPortStats(port.PacketCount, incrementStat) |
| 512 | o.sendPortStatsIndication(portStats, port.ID, port.Type) |
| 513 | } |
| 514 | case <-ctx.Done(): |
| 515 | log.Debug("Stop sending port stats") |
| 516 | return |
| 517 | } |
| 518 | |
| 519 | } |
| 520 | } |
| 521 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 522 | // Helpers method |
| 523 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 524 | func (o *OltDevice) GetPonById(id uint32) (*PonPort, error) { |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 525 | for _, pon := range o.Pons { |
| 526 | if pon.ID == id { |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 527 | return pon, nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 528 | } |
| 529 | } |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 530 | return nil, fmt.Errorf("Cannot find PonPort with id %d in OLT %d", id, o.ID) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 531 | } |
| 532 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 533 | func (o *OltDevice) getNniById(id uint32) (*NniPort, error) { |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 534 | for _, nni := range o.Nnis { |
| 535 | if nni.ID == id { |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 536 | return nni, nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 537 | } |
| 538 | } |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 539 | return nil, fmt.Errorf("Cannot find NniPort with id %d in OLT %d", id, o.ID) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 540 | } |
| 541 | |
Scott Baker | 41724b8 | 2020-01-21 19:54:53 -0800 | [diff] [blame] | 542 | func (o *OltDevice) sendAlarmIndication(alarmInd *openolt.AlarmIndication, stream openolt.Openolt_EnableIndicationServer) { |
| 543 | data := &openolt.Indication_AlarmInd{AlarmInd: alarmInd} |
| 544 | if err := stream.Send(&openolt.Indication{Data: data}); err != nil { |
| 545 | oltLogger.Errorf("Failed to send Alarm Indication: %v", err) |
| 546 | return |
| 547 | } |
| 548 | |
| 549 | oltLogger.WithFields(log.Fields{ |
| 550 | "AlarmIndication": alarmInd, |
| 551 | }).Debug("Sent Indication_AlarmInd") |
| 552 | } |
| 553 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 554 | func (o *OltDevice) sendOltIndication(msg OltIndicationMessage, stream openolt.Openolt_EnableIndicationServer) { |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 555 | data := &openolt.Indication_OltInd{OltInd: &openolt.OltIndication{OperState: msg.OperState.String()}} |
| 556 | if err := stream.Send(&openolt.Indication{Data: data}); err != nil { |
Matteo Scandolo | 1100699 | 2019-08-28 11:29:46 -0700 | [diff] [blame] | 557 | oltLogger.Errorf("Failed to send Indication_OltInd: %v", err) |
Matteo Scandolo | 08badf4 | 2019-12-12 11:21:50 -0800 | [diff] [blame] | 558 | return |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 559 | } |
| 560 | |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 561 | oltLogger.WithFields(log.Fields{ |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 562 | "OperState": msg.OperState, |
| 563 | }).Debug("Sent Indication_OltInd") |
| 564 | } |
| 565 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 566 | func (o *OltDevice) sendNniIndication(msg NniIndicationMessage, stream openolt.Openolt_EnableIndicationServer) { |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 567 | nni, _ := o.getNniById(msg.NniPortID) |
Matteo Scandolo | 401503a | 2019-12-11 14:48:14 -0800 | [diff] [blame] | 568 | if msg.OperState == UP { |
| 569 | if err := nni.OperState.Event("enable"); err != nil { |
| 570 | log.WithFields(log.Fields{ |
| 571 | "Type": nni.Type, |
| 572 | "IntfId": nni.ID, |
| 573 | "OperState": nni.OperState.Current(), |
| 574 | }).Errorf("Can't move NNI Port to enabled state: %v", err) |
| 575 | } |
| 576 | } else if msg.OperState == DOWN { |
| 577 | if err := nni.OperState.Event("disable"); err != nil { |
| 578 | log.WithFields(log.Fields{ |
| 579 | "Type": nni.Type, |
| 580 | "IntfId": nni.ID, |
| 581 | "OperState": nni.OperState.Current(), |
| 582 | }).Errorf("Can't move NNI Port to disable state: %v", err) |
| 583 | } |
| 584 | } |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 585 | // NOTE Operstate may need to be an integer |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 586 | operData := &openolt.Indication_IntfOperInd{IntfOperInd: &openolt.IntfOperIndication{ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 587 | Type: nni.Type, |
| 588 | IntfId: nni.ID, |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 589 | OperState: nni.OperState.Current(), |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 590 | }} |
| 591 | |
| 592 | if err := stream.Send(&openolt.Indication{Data: operData}); err != nil { |
Matteo Scandolo | 1100699 | 2019-08-28 11:29:46 -0700 | [diff] [blame] | 593 | oltLogger.Errorf("Failed to send Indication_IntfOperInd for NNI: %v", err) |
Matteo Scandolo | 08badf4 | 2019-12-12 11:21:50 -0800 | [diff] [blame] | 594 | return |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 595 | } |
| 596 | |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 597 | oltLogger.WithFields(log.Fields{ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 598 | "Type": nni.Type, |
| 599 | "IntfId": nni.ID, |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 600 | "OperState": nni.OperState.Current(), |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 601 | }).Debug("Sent Indication_IntfOperInd for NNI") |
| 602 | } |
| 603 | |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 604 | func (o *OltDevice) sendPonIndication(ponPortID uint32) { |
| 605 | |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 606 | stream := o.OpenoltStream |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 607 | pon, _ := o.GetPonById(ponPortID) |
| 608 | // Send IntfIndication for PON port |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 609 | discoverData := &openolt.Indication_IntfInd{IntfInd: &openolt.IntfIndication{ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 610 | IntfId: pon.ID, |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 611 | OperState: pon.OperState.Current(), |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 612 | }} |
| 613 | |
| 614 | if err := stream.Send(&openolt.Indication{Data: discoverData}); err != nil { |
Matteo Scandolo | 1100699 | 2019-08-28 11:29:46 -0700 | [diff] [blame] | 615 | oltLogger.Errorf("Failed to send Indication_IntfInd: %v", err) |
Matteo Scandolo | 08badf4 | 2019-12-12 11:21:50 -0800 | [diff] [blame] | 616 | return |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 617 | } |
| 618 | |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 619 | oltLogger.WithFields(log.Fields{ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 620 | "IntfId": pon.ID, |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 621 | "OperState": pon.OperState.Current(), |
Matteo Scandolo | 75ed5b9 | 2020-09-03 09:03:16 -0700 | [diff] [blame] | 622 | }).Debug("Sent Indication_IntfInd for PON") |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 623 | |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 624 | // Send IntfOperIndication for PON port |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 625 | operData := &openolt.Indication_IntfOperInd{IntfOperInd: &openolt.IntfOperIndication{ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 626 | Type: pon.Type, |
| 627 | IntfId: pon.ID, |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 628 | OperState: pon.OperState.Current(), |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 629 | }} |
| 630 | |
| 631 | if err := stream.Send(&openolt.Indication{Data: operData}); err != nil { |
Matteo Scandolo | 1100699 | 2019-08-28 11:29:46 -0700 | [diff] [blame] | 632 | oltLogger.Errorf("Failed to send Indication_IntfOperInd for PON: %v", err) |
Matteo Scandolo | 08badf4 | 2019-12-12 11:21:50 -0800 | [diff] [blame] | 633 | return |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 634 | } |
| 635 | |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 636 | oltLogger.WithFields(log.Fields{ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 637 | "Type": pon.Type, |
| 638 | "IntfId": pon.ID, |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 639 | "OperState": pon.OperState.Current(), |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 640 | }).Debug("Sent Indication_IntfOperInd for PON") |
| 641 | } |
| 642 | |
Pragya Arya | 996a089 | 2020-03-09 21:47:52 +0530 | [diff] [blame] | 643 | func (o *OltDevice) sendPortStatsIndication(stats *openolt.PortStatistics, portID uint32, portType string) { |
Shrey Baid | 55f328c | 2020-07-07 19:20:42 +0530 | [diff] [blame] | 644 | if o.InternalState.Current() == "enabled" { |
| 645 | oltLogger.WithFields(log.Fields{ |
| 646 | "Type": portType, |
| 647 | "IntfId": portID, |
| 648 | }).Trace("Sending port stats") |
| 649 | stats.IntfId = InterfaceIDToPortNo(portID, portType) |
| 650 | data := &openolt.Indication_PortStats{ |
| 651 | PortStats: stats, |
| 652 | } |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 653 | stream := o.OpenoltStream |
Shrey Baid | 55f328c | 2020-07-07 19:20:42 +0530 | [diff] [blame] | 654 | if err := stream.Send(&openolt.Indication{Data: data}); err != nil { |
| 655 | oltLogger.Errorf("Failed to send PortStats: %v", err) |
| 656 | return |
| 657 | } |
Pragya Arya | 996a089 | 2020-03-09 21:47:52 +0530 | [diff] [blame] | 658 | } |
| 659 | } |
| 660 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 661 | // processOltMessages handles messages received over the OpenOLT interface |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 662 | func (o *OltDevice) processOltMessages(ctx context.Context, stream openolt.Openolt_EnableIndicationServer, wg *sync.WaitGroup) { |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 663 | oltLogger.Debug("Starting OLT Indication Channel") |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 664 | ch := o.channel |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 665 | |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 666 | loop: |
| 667 | for { |
| 668 | select { |
| 669 | case <-ctx.Done(): |
| 670 | oltLogger.Debug("OLT Indication processing canceled via context") |
| 671 | break loop |
| 672 | case message, ok := <-ch: |
| 673 | if !ok || ctx.Err() != nil { |
| 674 | oltLogger.Debug("OLT Indication processing canceled via closed channel") |
| 675 | break loop |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 676 | } |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 677 | |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 678 | oltLogger.WithFields(log.Fields{ |
| 679 | "oltId": o.ID, |
| 680 | "messageType": message.Type, |
| 681 | }).Trace("Received message") |
| 682 | |
| 683 | switch message.Type { |
| 684 | case OltIndication: |
| 685 | msg, _ := message.Data.(OltIndicationMessage) |
| 686 | if msg.OperState == UP { |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 687 | _ = o.InternalState.Event("enable") |
| 688 | _ = o.OperState.Event("enable") |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 689 | } else if msg.OperState == DOWN { |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 690 | _ = o.InternalState.Event("disable") |
| 691 | _ = o.OperState.Event("disable") |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 692 | } |
| 693 | o.sendOltIndication(msg, stream) |
Scott Baker | 41724b8 | 2020-01-21 19:54:53 -0800 | [diff] [blame] | 694 | case AlarmIndication: |
| 695 | alarmInd, _ := message.Data.(*openolt.AlarmIndication) |
| 696 | o.sendAlarmIndication(alarmInd, stream) |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 697 | case NniIndication: |
| 698 | msg, _ := message.Data.(NniIndicationMessage) |
| 699 | o.sendNniIndication(msg, stream) |
| 700 | case PonIndication: |
| 701 | msg, _ := message.Data.(PonIndicationMessage) |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 702 | pon, _ := o.GetPonById(msg.PonPortID) |
| 703 | if msg.OperState == UP { |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 704 | if err := pon.OperState.Event("enable"); err != nil { |
| 705 | oltLogger.WithFields(log.Fields{ |
| 706 | "IntfId": msg.PonPortID, |
Matteo Scandolo | 5ff8008 | 2019-12-20 13:20:57 -0800 | [diff] [blame] | 707 | "Err": err, |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 708 | }).Error("Can't Enable Oper state for PON Port") |
| 709 | } |
| 710 | if err := pon.InternalState.Event("enable"); err != nil { |
| 711 | oltLogger.WithFields(log.Fields{ |
| 712 | "IntfId": msg.PonPortID, |
Matteo Scandolo | 5ff8008 | 2019-12-20 13:20:57 -0800 | [diff] [blame] | 713 | "Err": err, |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 714 | }).Error("Can't Enable Internal state for PON Port") |
| 715 | } |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 716 | } else if msg.OperState == DOWN { |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 717 | if err := pon.OperState.Event("disable"); err != nil { |
| 718 | oltLogger.WithFields(log.Fields{ |
| 719 | "IntfId": msg.PonPortID, |
Matteo Scandolo | 5ff8008 | 2019-12-20 13:20:57 -0800 | [diff] [blame] | 720 | "Err": err, |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 721 | }).Error("Can't Disable Oper state for PON Port") |
| 722 | } |
| 723 | if err := pon.InternalState.Event("disable"); err != nil { |
| 724 | oltLogger.WithFields(log.Fields{ |
| 725 | "IntfId": msg.PonPortID, |
Matteo Scandolo | 5ff8008 | 2019-12-20 13:20:57 -0800 | [diff] [blame] | 726 | "Err": err, |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 727 | }).Error("Can't Disable Internal state for PON Port") |
| 728 | } |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 729 | } |
David Bainbridge | 103cf02 | 2019-12-16 20:11:35 +0000 | [diff] [blame] | 730 | default: |
| 731 | oltLogger.Warnf("Received unknown message data %v for type %v in OLT Channel", message.Data, message.Type) |
| 732 | } |
| 733 | } |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 734 | } |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 735 | wg.Done() |
| 736 | oltLogger.Warn("Stopped handling OLT Indication Channel") |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 737 | } |
| 738 | |
Matteo Scandolo | f6f3a7f | 2019-10-11 11:19:29 -0700 | [diff] [blame] | 739 | // returns an ONU with a given Serial Number |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 740 | func (o *OltDevice) FindOnuBySn(serialNumber string) (*Onu, error) { |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 741 | // TODO this function can be a performance bottleneck when we have many ONUs, |
Matteo Scandolo | f6f3a7f | 2019-10-11 11:19:29 -0700 | [diff] [blame] | 742 | // memoizing it will remove the bottleneck |
Matteo Scandolo | 10f965c | 2019-09-24 10:40:46 -0700 | [diff] [blame] | 743 | for _, pon := range o.Pons { |
| 744 | for _, onu := range pon.Onus { |
| 745 | if onu.Sn() == serialNumber { |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 746 | return onu, nil |
Matteo Scandolo | 10f965c | 2019-09-24 10:40:46 -0700 | [diff] [blame] | 747 | } |
| 748 | } |
| 749 | } |
| 750 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 751 | return &Onu{}, fmt.Errorf("cannot-find-onu-by-serial-number-%s", serialNumber) |
Matteo Scandolo | f6f3a7f | 2019-10-11 11:19:29 -0700 | [diff] [blame] | 752 | } |
| 753 | |
William Kurkian | 9dadc5b | 2019-10-22 13:51:57 -0400 | [diff] [blame] | 754 | // returns an ONU with a given interface/Onu Id |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 755 | func (o *OltDevice) FindOnuById(intfId uint32, onuId uint32) (*Onu, error) { |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 756 | // TODO this function can be a performance bottleneck when we have many ONUs, |
William Kurkian | 9dadc5b | 2019-10-22 13:51:57 -0400 | [diff] [blame] | 757 | // memoizing it will remove the bottleneck |
| 758 | for _, pon := range o.Pons { |
| 759 | if pon.ID == intfId { |
| 760 | for _, onu := range pon.Onus { |
| 761 | if onu.ID == onuId { |
| 762 | return onu, nil |
| 763 | } |
| 764 | } |
| 765 | } |
| 766 | } |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 767 | return &Onu{}, fmt.Errorf("cannot-find-onu-by-id-%v-%v", intfId, onuId) |
William Kurkian | 9dadc5b | 2019-10-22 13:51:57 -0400 | [diff] [blame] | 768 | } |
| 769 | |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 770 | // returns a Service with a given Mac Address |
| 771 | func (o *OltDevice) FindServiceByMacAddress(mac net.HardwareAddr) (ServiceIf, error) { |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 772 | // TODO this function can be a performance bottleneck when we have many ONUs, |
Matteo Scandolo | f6f3a7f | 2019-10-11 11:19:29 -0700 | [diff] [blame] | 773 | // memoizing it will remove the bottleneck |
| 774 | for _, pon := range o.Pons { |
| 775 | for _, onu := range pon.Onus { |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 776 | s, err := onu.findServiceByMacAddress(mac) |
| 777 | if err == nil { |
| 778 | return s, nil |
Matteo Scandolo | f6f3a7f | 2019-10-11 11:19:29 -0700 | [diff] [blame] | 779 | } |
| 780 | } |
| 781 | } |
| 782 | |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 783 | return nil, fmt.Errorf("cannot-find-service-by-mac-address-%s", mac) |
Matteo Scandolo | 10f965c | 2019-09-24 10:40:46 -0700 | [diff] [blame] | 784 | } |
| 785 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 786 | // GRPC Endpoints |
| 787 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 788 | func (o *OltDevice) ActivateOnu(context context.Context, onu *openolt.Onu) (*openolt.Empty, error) { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 789 | oltLogger.WithFields(log.Fields{ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 790 | "OnuSn": onuSnToString(onu.SerialNumber), |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 791 | }).Info("Received ActivateOnu call from VOLTHA") |
Pragya Arya | 324337e | 2020-02-20 14:35:08 +0530 | [diff] [blame] | 792 | publishEvent("ONU-activate-indication-received", int32(onu.IntfId), int32(onu.OnuId), onuSnToString(onu.SerialNumber)) |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 793 | |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 794 | pon, _ := o.GetPonById(onu.IntfId) |
| 795 | _onu, _ := pon.GetOnuBySn(onu.SerialNumber) |
William Kurkian | 0418bc8 | 2019-11-06 12:16:24 -0500 | [diff] [blame] | 796 | _onu.SetID(onu.OnuId) |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 797 | |
Matteo Scandolo | 10f965c | 2019-09-24 10:40:46 -0700 | [diff] [blame] | 798 | if err := _onu.OperState.Event("enable"); err != nil { |
| 799 | oltLogger.WithFields(log.Fields{ |
| 800 | "IntfId": _onu.PonPortID, |
| 801 | "OnuSn": _onu.Sn(), |
| 802 | "OnuId": _onu.ID, |
| 803 | }).Infof("Failed to transition ONU.OperState to enabled state: %s", err.Error()) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 804 | } |
Matteo Scandolo | 10f965c | 2019-09-24 10:40:46 -0700 | [diff] [blame] | 805 | if err := _onu.InternalState.Event("enable"); err != nil { |
| 806 | oltLogger.WithFields(log.Fields{ |
| 807 | "IntfId": _onu.PonPortID, |
| 808 | "OnuSn": _onu.Sn(), |
| 809 | "OnuId": _onu.ID, |
| 810 | }).Infof("Failed to transition ONU to enabled state: %s", err.Error()) |
| 811 | } |
| 812 | |
| 813 | // NOTE we need to immediately activate the ONU or the OMCI state machine won't start |
| 814 | |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 815 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 816 | } |
| 817 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 818 | func (o *OltDevice) DeactivateOnu(context.Context, *openolt.Onu) (*openolt.Empty, error) { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 819 | oltLogger.Error("DeactivateOnu not implemented") |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 820 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 821 | } |
| 822 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 823 | func (o *OltDevice) DeleteOnu(_ context.Context, onu *openolt.Onu) (*openolt.Empty, error) { |
Pragya Arya | 1cbefa4 | 2020-01-13 12:15:29 +0530 | [diff] [blame] | 824 | oltLogger.WithFields(log.Fields{ |
| 825 | "IntfId": onu.IntfId, |
| 826 | "OnuId": onu.OnuId, |
| 827 | }).Info("Received DeleteOnu call from VOLTHA") |
| 828 | |
| 829 | pon, err := o.GetPonById(onu.IntfId) |
| 830 | if err != nil { |
| 831 | oltLogger.WithFields(log.Fields{ |
| 832 | "OnuId": onu.OnuId, |
| 833 | "IntfId": onu.IntfId, |
| 834 | "err": err, |
| 835 | }).Error("Can't find PonPort") |
| 836 | } |
| 837 | _onu, err := pon.GetOnuById(onu.OnuId) |
| 838 | if err != nil { |
| 839 | oltLogger.WithFields(log.Fields{ |
| 840 | "OnuId": onu.OnuId, |
| 841 | "IntfId": onu.IntfId, |
| 842 | "err": err, |
| 843 | }).Error("Can't find Onu") |
| 844 | } |
| 845 | |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 846 | if err := _onu.InternalState.Event("disable"); err != nil { |
Pragya Arya | 1cbefa4 | 2020-01-13 12:15:29 +0530 | [diff] [blame] | 847 | oltLogger.WithFields(log.Fields{ |
| 848 | "IntfId": _onu.PonPortID, |
| 849 | "OnuSn": _onu.Sn(), |
| 850 | "OnuId": _onu.ID, |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 851 | }).Infof("Failed to transition ONU to disabled state: %s", err.Error()) |
| 852 | } |
| 853 | |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 854 | // ONU Re-Discovery |
| 855 | if o.InternalState.Current() == "enabled" && pon.InternalState.Current() == "enabled" { |
Hardik Windlass | 7b3405b | 2020-07-08 15:10:05 +0530 | [diff] [blame] | 856 | go _onu.ReDiscoverOnu() |
Pragya Arya | 1cbefa4 | 2020-01-13 12:15:29 +0530 | [diff] [blame] | 857 | } |
| 858 | |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 859 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 860 | } |
| 861 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 862 | func (o *OltDevice) DisableOlt(context.Context, *openolt.Empty) (*openolt.Empty, error) { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 863 | // NOTE when we disable the OLT should we disable NNI, PONs and ONUs altogether? |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 864 | oltLogger.WithFields(log.Fields{ |
| 865 | "oltId": o.ID, |
| 866 | }).Info("Disabling OLT") |
Pragya Arya | 324337e | 2020-02-20 14:35:08 +0530 | [diff] [blame] | 867 | publishEvent("OLT-disable-received", -1, -1, "") |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 868 | |
Matteo Scandolo | 401503a | 2019-12-11 14:48:14 -0800 | [diff] [blame] | 869 | for _, pon := range o.Pons { |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 870 | if pon.InternalState.Current() == "enabled" { |
| 871 | // disable PONs |
| 872 | msg := Message{ |
| 873 | Type: PonIndication, |
| 874 | Data: PonIndicationMessage{ |
| 875 | OperState: DOWN, |
| 876 | PonPortID: pon.ID, |
| 877 | }, |
| 878 | } |
| 879 | o.channel <- msg |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 880 | } |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 881 | } |
| 882 | |
Matteo Scandolo | 401503a | 2019-12-11 14:48:14 -0800 | [diff] [blame] | 883 | // Note that we are not disabling the NNI as the real OLT does not. |
| 884 | // The reason for that is in-band management |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 885 | |
| 886 | // disable OLT |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 887 | oltMsg := Message{ |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 888 | Type: OltIndication, |
| 889 | Data: OltIndicationMessage{ |
| 890 | OperState: DOWN, |
| 891 | }, |
| 892 | } |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 893 | o.channel <- oltMsg |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 894 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 895 | } |
| 896 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 897 | func (o *OltDevice) DisablePonIf(_ context.Context, intf *openolt.Interface) (*openolt.Empty, error) { |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 898 | oltLogger.Infof("DisablePonIf request received for PON %d", intf.IntfId) |
Andrea Campanella | 340b9ea | 2020-04-28 18:34:01 +0200 | [diff] [blame] | 899 | ponID := intf.GetIntfId() |
| 900 | pon, _ := o.GetPonById(intf.IntfId) |
Andrea Campanella | 340b9ea | 2020-04-28 18:34:01 +0200 | [diff] [blame] | 901 | |
| 902 | msg := Message{ |
| 903 | Type: PonIndication, |
| 904 | Data: PonIndicationMessage{ |
| 905 | OperState: DOWN, |
| 906 | PonPortID: ponID, |
| 907 | }, |
| 908 | } |
| 909 | o.channel <- msg |
| 910 | |
| 911 | for _, onu := range pon.Onus { |
| 912 | |
| 913 | onuIndication := OnuIndicationMessage{ |
| 914 | OperState: DOWN, |
| 915 | PonPortID: ponID, |
| 916 | OnuID: onu.ID, |
| 917 | OnuSN: onu.SerialNumber, |
| 918 | } |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 919 | onu.sendOnuIndication(onuIndication, o.OpenoltStream) |
Andrea Campanella | 340b9ea | 2020-04-28 18:34:01 +0200 | [diff] [blame] | 920 | |
| 921 | } |
| 922 | |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 923 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 924 | } |
| 925 | |
Zdravko Bozakov | 681364d | 2019-11-10 14:28:46 +0100 | [diff] [blame] | 926 | func (o *OltDevice) EnableIndication(_ *openolt.Empty, stream openolt.Openolt_EnableIndicationServer) error { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 927 | oltLogger.WithField("oltId", o.ID).Info("OLT receives EnableIndication call from VOLTHA") |
Pragya Arya | 324337e | 2020-02-20 14:35:08 +0530 | [diff] [blame] | 928 | publishEvent("OLT-enable-received", -1, -1, "") |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 929 | o.Enable(stream) |
| 930 | return nil |
| 931 | } |
| 932 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 933 | func (o *OltDevice) EnablePonIf(_ context.Context, intf *openolt.Interface) (*openolt.Empty, error) { |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 934 | oltLogger.Infof("EnablePonIf request received for PON %d", intf.IntfId) |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 935 | ponID := intf.GetIntfId() |
Andrea Campanella | 340b9ea | 2020-04-28 18:34:01 +0200 | [diff] [blame] | 936 | pon, _ := o.GetPonById(intf.IntfId) |
Andrea Campanella | 340b9ea | 2020-04-28 18:34:01 +0200 | [diff] [blame] | 937 | |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 938 | msg := Message{ |
| 939 | Type: PonIndication, |
| 940 | Data: PonIndicationMessage{ |
| 941 | OperState: UP, |
| 942 | PonPortID: ponID, |
| 943 | }, |
| 944 | } |
| 945 | o.channel <- msg |
| 946 | |
Andrea Campanella | 340b9ea | 2020-04-28 18:34:01 +0200 | [diff] [blame] | 947 | for _, onu := range pon.Onus { |
| 948 | |
| 949 | onuIndication := OnuIndicationMessage{ |
| 950 | OperState: UP, |
| 951 | PonPortID: ponID, |
| 952 | OnuID: onu.ID, |
| 953 | OnuSN: onu.SerialNumber, |
| 954 | } |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 955 | onu.sendOnuIndication(onuIndication, o.OpenoltStream) |
Andrea Campanella | 340b9ea | 2020-04-28 18:34:01 +0200 | [diff] [blame] | 956 | |
| 957 | } |
| 958 | |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 959 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 960 | } |
| 961 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 962 | func (o *OltDevice) FlowAdd(ctx context.Context, flow *openolt.Flow) (*openolt.Empty, error) { |
Matteo Scandolo | 3bc7374 | 2019-08-20 14:04:04 -0700 | [diff] [blame] | 963 | oltLogger.WithFields(log.Fields{ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 964 | "IntfId": flow.AccessIntfId, |
| 965 | "OnuId": flow.OnuId, |
| 966 | "EthType": fmt.Sprintf("%x", flow.Classifier.EthType), |
Matteo Scandolo | 3bc7374 | 2019-08-20 14:04:04 -0700 | [diff] [blame] | 967 | "InnerVlan": flow.Classifier.IVid, |
| 968 | "OuterVlan": flow.Classifier.OVid, |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 969 | "FlowType": flow.FlowType, |
| 970 | "FlowId": flow.FlowId, |
| 971 | "UniID": flow.UniId, |
| 972 | "PortNo": flow.PortNo, |
Pragya Arya | 8bdb453 | 2020-03-02 17:08:09 +0530 | [diff] [blame] | 973 | }).Tracef("OLT receives FlowAdd") |
| 974 | |
| 975 | flowKey := FlowKey{} |
| 976 | if !o.enablePerf { |
| 977 | flowKey = FlowKey{ID: flow.FlowId, Direction: flow.FlowType} |
| 978 | olt.Flows[flowKey] = *flow |
| 979 | } |
Matteo Scandolo | 3bc7374 | 2019-08-20 14:04:04 -0700 | [diff] [blame] | 980 | |
| 981 | if flow.AccessIntfId == -1 { |
| 982 | oltLogger.WithFields(log.Fields{ |
| 983 | "FlowId": flow.FlowId, |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 984 | }).Debug("Adding OLT flow") |
Jonathan Hart | b5fc46a | 2020-03-31 16:42:31 -0700 | [diff] [blame] | 985 | } else if flow.FlowType == "multicast" { |
| 986 | oltLogger.WithFields(log.Fields{ |
Matteo Scandolo | 618a658 | 2020-09-09 12:21:29 -0700 | [diff] [blame] | 987 | "Cookie": flow.Cookie, |
| 988 | "DstPort": flow.Classifier.DstPort, |
| 989 | "EthType": fmt.Sprintf("%x", flow.Classifier.EthType), |
| 990 | "FlowId": flow.FlowId, |
| 991 | "FlowType": flow.FlowType, |
| 992 | "GemportId": flow.GemportId, |
| 993 | "InnerVlan": flow.Classifier.IVid, |
| 994 | "IntfId": flow.AccessIntfId, |
| 995 | "IpProto": flow.Classifier.IpProto, |
| 996 | "OnuId": flow.OnuId, |
| 997 | "OuterVlan": flow.Classifier.OVid, |
| 998 | "PortNo": flow.PortNo, |
| 999 | "SrcPort": flow.Classifier.SrcPort, |
| 1000 | "UniID": flow.UniId, |
| 1001 | "ClassifierOPbits": flow.Classifier.OPbits, |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 1002 | }).Debug("Adding OLT multicast flow") |
Matteo Scandolo | 3bc7374 | 2019-08-20 14:04:04 -0700 | [diff] [blame] | 1003 | } else { |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 1004 | pon, err := o.GetPonById(uint32(flow.AccessIntfId)) |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 1005 | if err != nil { |
| 1006 | oltLogger.WithFields(log.Fields{ |
| 1007 | "OnuId": flow.OnuId, |
| 1008 | "IntfId": flow.AccessIntfId, |
| 1009 | "err": err, |
| 1010 | }).Error("Can't find PonPort") |
| 1011 | } |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 1012 | onu, err := pon.GetOnuById(uint32(flow.OnuId)) |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 1013 | if err != nil { |
| 1014 | oltLogger.WithFields(log.Fields{ |
| 1015 | "OnuId": flow.OnuId, |
| 1016 | "IntfId": flow.AccessIntfId, |
| 1017 | "err": err, |
| 1018 | }).Error("Can't find Onu") |
Jonathan Hart | b5fc46a | 2020-03-31 16:42:31 -0700 | [diff] [blame] | 1019 | return nil, err |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 1020 | } |
Pragya Arya | 8bdb453 | 2020-03-02 17:08:09 +0530 | [diff] [blame] | 1021 | if !o.enablePerf { |
| 1022 | onu.Flows = append(onu.Flows, flowKey) |
Pragya Arya | 1d5ffb8 | 2020-03-20 18:51:37 +0530 | [diff] [blame] | 1023 | // Generate event on first flow for ONU |
| 1024 | if len(onu.Flows) == 1 { |
| 1025 | publishEvent("Flow-add-received", int32(onu.PonPortID), int32(onu.ID), onuSnToString(onu.SerialNumber)) |
| 1026 | } |
Pragya Arya | 8bdb453 | 2020-03-02 17:08:09 +0530 | [diff] [blame] | 1027 | } |
Matteo Scandolo | 3bc7374 | 2019-08-20 14:04:04 -0700 | [diff] [blame] | 1028 | |
| 1029 | msg := Message{ |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 1030 | Type: FlowAdd, |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1031 | Data: OnuFlowUpdateMessage{ |
| 1032 | PonPortID: pon.ID, |
| 1033 | OnuID: onu.ID, |
| 1034 | Flow: flow, |
Matteo Scandolo | 3bc7374 | 2019-08-20 14:04:04 -0700 | [diff] [blame] | 1035 | }, |
| 1036 | } |
Matteo Scandolo | 10f965c | 2019-09-24 10:40:46 -0700 | [diff] [blame] | 1037 | onu.Channel <- msg |
Matteo Scandolo | 3bc7374 | 2019-08-20 14:04:04 -0700 | [diff] [blame] | 1038 | } |
| 1039 | |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1040 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1041 | } |
| 1042 | |
Pragya Arya | 8bdb453 | 2020-03-02 17:08:09 +0530 | [diff] [blame] | 1043 | // FlowRemove request from VOLTHA |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1044 | func (o *OltDevice) FlowRemove(_ context.Context, flow *openolt.Flow) (*openolt.Empty, error) { |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 1045 | |
Pragya Arya | 8bdb453 | 2020-03-02 17:08:09 +0530 | [diff] [blame] | 1046 | oltLogger.WithFields(log.Fields{ |
Shrey Baid | 55f328c | 2020-07-07 19:20:42 +0530 | [diff] [blame] | 1047 | "FlowId": flow.FlowId, |
| 1048 | "FlowType": flow.FlowType, |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 1049 | }).Debug("OLT receives FlowRemove") |
Pragya Arya | 8bdb453 | 2020-03-02 17:08:09 +0530 | [diff] [blame] | 1050 | |
| 1051 | if !o.enablePerf { // remove only if flow were stored |
| 1052 | flowKey := FlowKey{ |
| 1053 | ID: flow.FlowId, |
| 1054 | Direction: flow.FlowType, |
| 1055 | } |
| 1056 | |
| 1057 | // Check if flow exists |
| 1058 | storedFlow, ok := o.Flows[flowKey] |
| 1059 | if !ok { |
| 1060 | oltLogger.Errorf("Flow %v not found", flow) |
| 1061 | return new(openolt.Empty), status.Errorf(codes.NotFound, "Flow not found") |
| 1062 | } |
| 1063 | |
| 1064 | // if its ONU flow remove it from ONU also |
| 1065 | if storedFlow.AccessIntfId != -1 { |
| 1066 | pon := o.Pons[uint32(storedFlow.AccessIntfId)] |
| 1067 | onu, err := pon.GetOnuById(uint32(storedFlow.OnuId)) |
| 1068 | if err != nil { |
| 1069 | oltLogger.WithFields(log.Fields{ |
| 1070 | "OnuId": storedFlow.OnuId, |
| 1071 | "IntfId": storedFlow.AccessIntfId, |
| 1072 | "err": err, |
| 1073 | }).Error("ONU not found") |
| 1074 | return new(openolt.Empty), nil |
| 1075 | } |
| 1076 | onu.DeleteFlow(flowKey) |
Pragya Arya | 1d5ffb8 | 2020-03-20 18:51:37 +0530 | [diff] [blame] | 1077 | publishEvent("Flow-remove-received", int32(onu.PonPortID), int32(onu.ID), onuSnToString(onu.SerialNumber)) |
Pragya Arya | 8bdb453 | 2020-03-02 17:08:09 +0530 | [diff] [blame] | 1078 | } |
| 1079 | |
| 1080 | // delete from olt flows |
| 1081 | delete(o.Flows, flowKey) |
| 1082 | } |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 1083 | |
| 1084 | if flow.AccessIntfId == -1 { |
| 1085 | oltLogger.WithFields(log.Fields{ |
| 1086 | "FlowId": flow.FlowId, |
| 1087 | }).Debug("Removing OLT flow") |
| 1088 | } else if flow.FlowType == "multicast" { |
| 1089 | oltLogger.WithFields(log.Fields{ |
| 1090 | "FlowId": flow.FlowId, |
| 1091 | }).Debug("Removing OLT multicast flow") |
| 1092 | } else { |
| 1093 | |
| 1094 | onu, err := o.GetOnuByFlowId(flow.FlowId) |
| 1095 | if err != nil { |
| 1096 | oltLogger.WithFields(log.Fields{ |
| 1097 | "OnuId": flow.OnuId, |
| 1098 | "IntfId": flow.AccessIntfId, |
| 1099 | "err": err, |
| 1100 | }).Error("Can't find Onu") |
| 1101 | return nil, err |
| 1102 | } |
| 1103 | |
| 1104 | msg := Message{ |
| 1105 | Type: FlowRemoved, |
| 1106 | Data: OnuFlowUpdateMessage{ |
Shrey Baid | 55f328c | 2020-07-07 19:20:42 +0530 | [diff] [blame] | 1107 | Flow: flow, |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 1108 | }, |
| 1109 | } |
| 1110 | onu.Channel <- msg |
| 1111 | } |
| 1112 | |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1113 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1114 | } |
| 1115 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1116 | func (o *OltDevice) HeartbeatCheck(context.Context, *openolt.Empty) (*openolt.Heartbeat, error) { |
Matteo Scandolo | 1885985 | 2020-01-15 13:33:57 -0800 | [diff] [blame] | 1117 | res := openolt.Heartbeat{HeartbeatSignature: uint32(time.Now().Unix())} |
| 1118 | oltLogger.WithFields(log.Fields{ |
| 1119 | "signature": res.HeartbeatSignature, |
| 1120 | }).Trace("HeartbeatCheck") |
| 1121 | return &res, nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1122 | } |
| 1123 | |
Matteo Scandolo | 4f4ac79 | 2020-10-01 16:33:21 -0700 | [diff] [blame] | 1124 | func (o *OltDevice) GetOnuByFlowId(flowId uint64) (*Onu, error) { |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 1125 | for _, pon := range o.Pons { |
| 1126 | for _, onu := range pon.Onus { |
| 1127 | for _, fId := range onu.FlowIds { |
| 1128 | if fId == flowId { |
| 1129 | return onu, nil |
| 1130 | } |
| 1131 | } |
| 1132 | } |
| 1133 | } |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1134 | return nil, fmt.Errorf("Cannot find Onu by flowId %d", flowId) |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 1135 | } |
| 1136 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1137 | func (o *OltDevice) GetDeviceInfo(context.Context, *openolt.Empty) (*openolt.DeviceInfo, error) { |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1138 | |
Matteo Scandolo | da9cbe2 | 2019-08-19 16:05:10 -0700 | [diff] [blame] | 1139 | oltLogger.WithFields(log.Fields{ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1140 | "oltId": o.ID, |
Matteo Scandolo | da9cbe2 | 2019-08-19 16:05:10 -0700 | [diff] [blame] | 1141 | "PonPorts": o.NumPon, |
| 1142 | }).Info("OLT receives GetDeviceInfo call from VOLTHA") |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1143 | devinfo := new(openolt.DeviceInfo) |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 1144 | devinfo.Vendor = common.Config.Olt.Vendor |
| 1145 | devinfo.Model = common.Config.Olt.Model |
| 1146 | devinfo.HardwareVersion = common.Config.Olt.HardwareVersion |
| 1147 | devinfo.FirmwareVersion = common.Config.Olt.FirmwareVersion |
| 1148 | devinfo.Technology = common.Config.Olt.Technology |
Matteo Scandolo | da9cbe2 | 2019-08-19 16:05:10 -0700 | [diff] [blame] | 1149 | devinfo.PonPorts = uint32(o.NumPon) |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1150 | devinfo.OnuIdStart = 1 |
| 1151 | devinfo.OnuIdEnd = 255 |
| 1152 | devinfo.AllocIdStart = 1024 |
| 1153 | devinfo.AllocIdEnd = 16383 |
| 1154 | devinfo.GemportIdStart = 1024 |
| 1155 | devinfo.GemportIdEnd = 65535 |
| 1156 | devinfo.FlowIdStart = 1 |
| 1157 | devinfo.FlowIdEnd = 16383 |
Matteo Scandolo | 8df63df | 2019-09-12 10:34:32 -0700 | [diff] [blame] | 1158 | devinfo.DeviceSerialNumber = o.SerialNumber |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 1159 | devinfo.DeviceId = common.Config.Olt.DeviceId |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1160 | |
| 1161 | return devinfo, nil |
| 1162 | } |
| 1163 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1164 | func (o *OltDevice) OmciMsgOut(ctx context.Context, omci_msg *openolt.OmciMsg) (*openolt.Empty, error) { |
Jonathan Hart | acfa20e | 2020-03-31 15:20:14 -0700 | [diff] [blame] | 1165 | pon, err := o.GetPonById(omci_msg.IntfId) |
| 1166 | if err != nil { |
| 1167 | oltLogger.WithFields(log.Fields{ |
Matteo Scandolo | f65e687 | 2020-04-15 15:18:43 -0700 | [diff] [blame] | 1168 | "error": err, |
Jonathan Hart | acfa20e | 2020-03-31 15:20:14 -0700 | [diff] [blame] | 1169 | "onu_id": omci_msg.OnuId, |
| 1170 | "pon_id": omci_msg.IntfId, |
| 1171 | }).Error("pon ID not found") |
| 1172 | return nil, err |
| 1173 | } |
| 1174 | |
| 1175 | onu, err := pon.GetOnuById(omci_msg.OnuId) |
| 1176 | if err != nil { |
| 1177 | oltLogger.WithFields(log.Fields{ |
Matteo Scandolo | f65e687 | 2020-04-15 15:18:43 -0700 | [diff] [blame] | 1178 | "error": err, |
Jonathan Hart | acfa20e | 2020-03-31 15:20:14 -0700 | [diff] [blame] | 1179 | "onu_id": omci_msg.OnuId, |
| 1180 | "pon_id": omci_msg.IntfId, |
| 1181 | }).Error("onu ID not found") |
| 1182 | return nil, err |
| 1183 | } |
| 1184 | |
Matteo Scandolo | 10f965c | 2019-09-24 10:40:46 -0700 | [diff] [blame] | 1185 | oltLogger.WithFields(log.Fields{ |
| 1186 | "IntfId": onu.PonPortID, |
| 1187 | "OnuId": onu.ID, |
| 1188 | "OnuSn": onu.Sn(), |
| 1189 | }).Tracef("Received OmciMsgOut") |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 1190 | msg := Message{ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1191 | Type: OMCI, |
| 1192 | Data: OmciMessage{ |
| 1193 | OnuSN: onu.SerialNumber, |
| 1194 | OnuID: onu.ID, |
| 1195 | omciMsg: omci_msg, |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 1196 | }, |
| 1197 | } |
Matteo Scandolo | 10f965c | 2019-09-24 10:40:46 -0700 | [diff] [blame] | 1198 | onu.Channel <- msg |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1199 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1200 | } |
| 1201 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1202 | func (o *OltDevice) OnuPacketOut(ctx context.Context, onuPkt *openolt.OnuPacket) (*openolt.Empty, error) { |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 1203 | pon, err := o.GetPonById(onuPkt.IntfId) |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 1204 | if err != nil { |
| 1205 | oltLogger.WithFields(log.Fields{ |
| 1206 | "OnuId": onuPkt.OnuId, |
| 1207 | "IntfId": onuPkt.IntfId, |
| 1208 | "err": err, |
| 1209 | }).Error("Can't find PonPort") |
| 1210 | } |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 1211 | onu, err := pon.GetOnuById(onuPkt.OnuId) |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 1212 | if err != nil { |
| 1213 | oltLogger.WithFields(log.Fields{ |
| 1214 | "OnuId": onuPkt.OnuId, |
| 1215 | "IntfId": onuPkt.IntfId, |
| 1216 | "err": err, |
| 1217 | }).Error("Can't find Onu") |
| 1218 | } |
Matteo Scandolo | 47e69bb | 2019-08-28 15:41:12 -0700 | [diff] [blame] | 1219 | |
Matteo Scandolo | 075b189 | 2019-10-07 12:11:07 -0700 | [diff] [blame] | 1220 | oltLogger.WithFields(log.Fields{ |
| 1221 | "IntfId": onu.PonPortID, |
| 1222 | "OnuId": onu.ID, |
| 1223 | "OnuSn": onu.Sn(), |
Matteo Scandolo | adc72a8 | 2020-09-08 18:46:08 -0700 | [diff] [blame] | 1224 | "Packet": hex.EncodeToString(onuPkt.Pkt), |
Matteo Scandolo | 75ed5b9 | 2020-09-03 09:03:16 -0700 | [diff] [blame] | 1225 | }).Trace("Received OnuPacketOut") |
Matteo Scandolo | 075b189 | 2019-10-07 12:11:07 -0700 | [diff] [blame] | 1226 | |
Matteo Scandolo | 47e69bb | 2019-08-28 15:41:12 -0700 | [diff] [blame] | 1227 | rawpkt := gopacket.NewPacket(onuPkt.Pkt, layers.LayerTypeEthernet, gopacket.Default) |
Matteo Scandolo | 618a658 | 2020-09-09 12:21:29 -0700 | [diff] [blame] | 1228 | |
| 1229 | pktType, err := packetHandlers.GetPktType(rawpkt) |
Matteo Scandolo | adc72a8 | 2020-09-08 18:46:08 -0700 | [diff] [blame] | 1230 | if err != nil { |
| 1231 | onuLogger.WithFields(log.Fields{ |
| 1232 | "IntfId": onu.PonPortID, |
| 1233 | "OnuId": onu.ID, |
| 1234 | "OnuSn": onu.Sn(), |
Matteo Scandolo | 618a658 | 2020-09-09 12:21:29 -0700 | [diff] [blame] | 1235 | "Pkt": hex.EncodeToString(rawpkt.Data()), |
Matteo Scandolo | adc72a8 | 2020-09-08 18:46:08 -0700 | [diff] [blame] | 1236 | }).Error("Can't find pktType in packet, droppint it") |
| 1237 | return new(openolt.Empty), nil |
| 1238 | } |
Matteo Scandolo | 47e69bb | 2019-08-28 15:41:12 -0700 | [diff] [blame] | 1239 | |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 1240 | pktMac, err := packetHandlers.GetDstMacAddressFromPacket(rawpkt) |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 1241 | if err != nil { |
Matteo Scandolo | adc72a8 | 2020-09-08 18:46:08 -0700 | [diff] [blame] | 1242 | onuLogger.WithFields(log.Fields{ |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 1243 | "IntfId": onu.PonPortID, |
| 1244 | "OnuId": onu.ID, |
| 1245 | "OnuSn": onu.Sn(), |
| 1246 | "Pkt": rawpkt.Data(), |
| 1247 | }).Error("Can't find Dst MacAddress in packet, droppint it") |
| 1248 | return new(openolt.Empty), nil |
| 1249 | } |
| 1250 | |
Matteo Scandolo | 075b189 | 2019-10-07 12:11:07 -0700 | [diff] [blame] | 1251 | msg := Message{ |
| 1252 | Type: OnuPacketOut, |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 1253 | Data: OnuPacketMessage{ |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 1254 | IntfId: onuPkt.IntfId, |
| 1255 | OnuId: onuPkt.OnuId, |
| 1256 | Packet: rawpkt, |
| 1257 | Type: pktType, |
| 1258 | MacAddress: pktMac, |
Matteo Scandolo | 075b189 | 2019-10-07 12:11:07 -0700 | [diff] [blame] | 1259 | }, |
Matteo Scandolo | 47e69bb | 2019-08-28 15:41:12 -0700 | [diff] [blame] | 1260 | } |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 1261 | |
Matteo Scandolo | 075b189 | 2019-10-07 12:11:07 -0700 | [diff] [blame] | 1262 | onu.Channel <- msg |
| 1263 | |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1264 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1265 | } |
| 1266 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1267 | func (o *OltDevice) Reboot(context.Context, *openolt.Empty) (*openolt.Empty, error) { |
Matteo Scandolo | 635b2bf | 2020-09-04 10:23:40 -0700 | [diff] [blame] | 1268 | |
| 1269 | // OLT Reboot is called in two cases: |
| 1270 | // - when an OLT is being removed (voltctl device disable -> voltctl device delete are called, then a new voltctl device create -> voltctl device enable will be issued) |
| 1271 | // - when an OLT needs to be rebooted (voltcl device reboot) |
| 1272 | |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 1273 | oltLogger.WithFields(log.Fields{ |
| 1274 | "oltId": o.ID, |
| 1275 | }).Info("Shutting down") |
Pragya Arya | 324337e | 2020-02-20 14:35:08 +0530 | [diff] [blame] | 1276 | publishEvent("OLT-reboot-received", -1, -1, "") |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1277 | go func() { _ = o.RestartOLT() }() |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1278 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1279 | } |
| 1280 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1281 | func (o *OltDevice) ReenableOlt(context.Context, *openolt.Empty) (*openolt.Empty, error) { |
Pragya Arya | 6a708d6 | 2020-01-01 17:17:20 +0530 | [diff] [blame] | 1282 | oltLogger.WithFields(log.Fields{ |
| 1283 | "oltId": o.ID, |
| 1284 | }).Info("Received ReenableOlt request from VOLTHA") |
Pragya Arya | 324337e | 2020-02-20 14:35:08 +0530 | [diff] [blame] | 1285 | publishEvent("OLT-reenable-received", -1, -1, "") |
Pragya Arya | 6a708d6 | 2020-01-01 17:17:20 +0530 | [diff] [blame] | 1286 | |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 1287 | // enable OLT |
| 1288 | oltMsg := Message{ |
| 1289 | Type: OltIndication, |
| 1290 | Data: OltIndicationMessage{ |
| 1291 | OperState: UP, |
| 1292 | }, |
Pragya Arya | 1881df0 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 1293 | } |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 1294 | o.channel <- oltMsg |
Pragya Arya | 6a708d6 | 2020-01-01 17:17:20 +0530 | [diff] [blame] | 1295 | |
Pragya Arya | 2225f20 | 2020-01-29 18:05:01 +0530 | [diff] [blame] | 1296 | for _, pon := range o.Pons { |
| 1297 | if pon.InternalState.Current() == "disabled" { |
| 1298 | msg := Message{ |
| 1299 | Type: PonIndication, |
| 1300 | Data: PonIndicationMessage{ |
| 1301 | OperState: UP, |
| 1302 | PonPortID: pon.ID, |
| 1303 | }, |
| 1304 | } |
| 1305 | o.channel <- msg |
| 1306 | } |
| 1307 | } |
Matteo Scandolo | e60a505 | 2020-02-07 00:31:14 +0000 | [diff] [blame] | 1308 | |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1309 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1310 | } |
| 1311 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1312 | func (o *OltDevice) UplinkPacketOut(context context.Context, packet *openolt.UplinkPacket) (*openolt.Empty, error) { |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1313 | pkt := gopacket.NewPacket(packet.Pkt, layers.LayerTypeEthernet, gopacket.Default) |
| 1314 | |
Matteo Scandolo | 90d08f6 | 2020-10-29 12:06:55 -0700 | [diff] [blame^] | 1315 | err := o.Nnis[0].handleNniPacket(pkt) // FIXME we are assuming we have only one NNI |
| 1316 | |
| 1317 | if err != nil { |
| 1318 | return nil, err |
| 1319 | } |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1320 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1321 | } |
| 1322 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1323 | func (o *OltDevice) CollectStatistics(context.Context, *openolt.Empty) (*openolt.Empty, error) { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 1324 | oltLogger.Error("CollectStatistics not implemented") |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1325 | return new(openolt.Empty), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1326 | } |
| 1327 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1328 | func (o *OltDevice) GetOnuInfo(context context.Context, packet *openolt.Onu) (*openolt.OnuIndication, error) { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 1329 | oltLogger.Error("GetOnuInfo not implemented") |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1330 | return new(openolt.OnuIndication), nil |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1331 | } |
| 1332 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1333 | func (o *OltDevice) GetPonIf(context context.Context, packet *openolt.Interface) (*openolt.IntfIndication, error) { |
Matteo Scandolo | 9a3518c | 2019-08-13 14:36:01 -0700 | [diff] [blame] | 1334 | oltLogger.Error("GetPonIf not implemented") |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1335 | return new(openolt.IntfIndication), nil |
Matteo Scandolo | d54283a | 2019-08-13 16:22:31 -0700 | [diff] [blame] | 1336 | } |
| 1337 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1338 | func (s *OltDevice) CreateTrafficQueues(context.Context, *tech_profile.TrafficQueues) (*openolt.Empty, error) { |
Matteo Scandolo | c559ef1 | 2019-08-20 13:24:21 -0700 | [diff] [blame] | 1339 | oltLogger.Info("received CreateTrafficQueues") |
Matteo Scandolo | d54283a | 2019-08-13 16:22:31 -0700 | [diff] [blame] | 1340 | return new(openolt.Empty), nil |
| 1341 | } |
| 1342 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1343 | func (s *OltDevice) RemoveTrafficQueues(context.Context, *tech_profile.TrafficQueues) (*openolt.Empty, error) { |
Matteo Scandolo | c559ef1 | 2019-08-20 13:24:21 -0700 | [diff] [blame] | 1344 | oltLogger.Info("received RemoveTrafficQueues") |
Matteo Scandolo | d54283a | 2019-08-13 16:22:31 -0700 | [diff] [blame] | 1345 | return new(openolt.Empty), nil |
| 1346 | } |
| 1347 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1348 | func (s *OltDevice) CreateTrafficSchedulers(context context.Context, trafficSchedulers *tech_profile.TrafficSchedulers) (*openolt.Empty, error) { |
Anand S Katti | 0954135 | 2020-01-29 15:54:01 +0530 | [diff] [blame] | 1349 | oltLogger.WithFields(log.Fields{ |
| 1350 | "OnuId": trafficSchedulers.OnuId, |
| 1351 | "IntfId": trafficSchedulers.IntfId, |
| 1352 | "OnuPortNo": trafficSchedulers.PortNo, |
| 1353 | }).Info("received CreateTrafficSchedulers") |
| 1354 | |
| 1355 | if !s.enablePerf { |
| 1356 | pon, err := s.GetPonById(trafficSchedulers.IntfId) |
| 1357 | if err != nil { |
| 1358 | oltLogger.Errorf("Error retrieving PON by IntfId: %v", err) |
| 1359 | return new(openolt.Empty), err |
| 1360 | } |
| 1361 | onu, err := pon.GetOnuById(trafficSchedulers.OnuId) |
| 1362 | if err != nil { |
| 1363 | oltLogger.Errorf("Error retrieving ONU from pon by OnuId: %v", err) |
| 1364 | return new(openolt.Empty), err |
| 1365 | } |
| 1366 | onu.TrafficSchedulers = trafficSchedulers |
| 1367 | } |
Matteo Scandolo | d54283a | 2019-08-13 16:22:31 -0700 | [diff] [blame] | 1368 | return new(openolt.Empty), nil |
| 1369 | } |
| 1370 | |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1371 | func (s *OltDevice) RemoveTrafficSchedulers(context context.Context, trafficSchedulers *tech_profile.TrafficSchedulers) (*openolt.Empty, error) { |
Anand S Katti | 0954135 | 2020-01-29 15:54:01 +0530 | [diff] [blame] | 1372 | oltLogger.WithFields(log.Fields{ |
| 1373 | "OnuId": trafficSchedulers.OnuId, |
| 1374 | "IntfId": trafficSchedulers.IntfId, |
| 1375 | "OnuPortNo": trafficSchedulers.PortNo, |
| 1376 | }).Info("received RemoveTrafficSchedulers") |
| 1377 | if !s.enablePerf { |
| 1378 | pon, err := s.GetPonById(trafficSchedulers.IntfId) |
| 1379 | if err != nil { |
| 1380 | oltLogger.Errorf("Error retrieving PON by IntfId: %v", err) |
| 1381 | return new(openolt.Empty), err |
| 1382 | } |
| 1383 | onu, err := pon.GetOnuById(trafficSchedulers.OnuId) |
| 1384 | if err != nil { |
| 1385 | oltLogger.Errorf("Error retrieving ONU from pon by OnuId: %v", err) |
| 1386 | return new(openolt.Empty), err |
| 1387 | } |
| 1388 | |
| 1389 | onu.TrafficSchedulers = nil |
| 1390 | } |
Matteo Scandolo | d54283a | 2019-08-13 16:22:31 -0700 | [diff] [blame] | 1391 | return new(openolt.Empty), nil |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 1392 | } |
Scott Baker | 41724b8 | 2020-01-21 19:54:53 -0800 | [diff] [blame] | 1393 | |
| 1394 | // assumes caller has properly formulated an openolt.AlarmIndication |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 1395 | func (o *OltDevice) SendAlarmIndication(context context.Context, ind *openolt.AlarmIndication) error { |
Scott Baker | 41724b8 | 2020-01-21 19:54:53 -0800 | [diff] [blame] | 1396 | msg := Message{ |
| 1397 | Type: AlarmIndication, |
| 1398 | Data: ind, |
| 1399 | } |
| 1400 | |
| 1401 | o.channel <- msg |
| 1402 | return nil |
| 1403 | } |
Matteo Scandolo | 618a658 | 2020-09-09 12:21:29 -0700 | [diff] [blame] | 1404 | |
| 1405 | func (o *OltDevice) PerformGroupOperation(ctx context.Context, group *openolt.Group) (*openolt.Empty, error) { |
| 1406 | oltLogger.WithFields(log.Fields{ |
| 1407 | "GroupId": group.GroupId, |
| 1408 | "Command": group.Command, |
| 1409 | "Members": group.Members, |
| 1410 | "Action": group.Action, |
| 1411 | }).Debug("received PerformGroupOperation") |
| 1412 | return &openolt.Empty{}, nil |
| 1413 | } |
| 1414 | |
| 1415 | func (o *OltDevice) DeleteGroup(ctx context.Context, group *openolt.Group) (*openolt.Empty, error) { |
| 1416 | oltLogger.WithFields(log.Fields{ |
| 1417 | "GroupId": group.GroupId, |
| 1418 | "Command": group.Command, |
| 1419 | "Members": group.Members, |
| 1420 | "Action": group.Action, |
| 1421 | }).Debug("received PerformGroupOperation") |
| 1422 | return &openolt.Empty{}, nil |
| 1423 | } |
| 1424 | |
| 1425 | func (o *OltDevice) GetExtValue(ctx context.Context, in *openolt.ValueParam) (*common_protos.ReturnValues, error) { |
| 1426 | return &common_protos.ReturnValues{}, nil |
| 1427 | } |
| 1428 | |
| 1429 | func (o *OltDevice) OnuItuPonAlarmSet(ctx context.Context, in *config.OnuItuPonAlarm) (*openolt.Empty, error) { |
| 1430 | return &openolt.Empty{}, nil |
| 1431 | } |
| 1432 | |
| 1433 | func (o *OltDevice) GetLogicalOnuDistanceZero(ctx context.Context, in *openolt.Onu) (*openolt.OnuLogicalDistance, error) { |
| 1434 | return &openolt.OnuLogicalDistance{}, nil |
| 1435 | } |
| 1436 | |
| 1437 | func (o *OltDevice) GetLogicalOnuDistance(ctx context.Context, in *openolt.Onu) (*openolt.OnuLogicalDistance, error) { |
| 1438 | return &openolt.OnuLogicalDistance{}, nil |
| 1439 | } |