blob: 4e461fabeb413484ee185382aa5dea313bb9d5bc [file] [log] [blame]
Shad Ansari01b0e652018-04-05 21:02:53 +00001/*
2 Copyright (C) 2018 Open Networking Foundation
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include <iostream>
Craig Lutgen88a22ad2018-10-04 12:30:46 -050018#include <unistd.h>
Shad Ansari01b0e652018-04-05 21:02:53 +000019
Shad Ansari01b0e652018-04-05 21:02:53 +000020#include "server.h"
Shad Ansarib7b0ced2018-05-11 21:53:32 +000021#include "core.h"
Shad Ansari01b0e652018-04-05 21:02:53 +000022
Shad Ansari01b0e652018-04-05 21:02:53 +000023int main(int argc, char** argv) {
24
Shad Ansari627b5782018-08-13 22:49:32 +000025 Status status = Enable_(argc, argv);
Shad Ansari01b0e652018-04-05 21:02:53 +000026 if (!status.ok()) {
27 std::cout << "ERROR: Enable_ failed - "
28 << status.error_code() << ": " << status.error_message()
29 << std::endl;
30 return 1;
31 }
32
Craig Lutgen88a22ad2018-10-04 12:30:46 -050033 // Wait for successful activation before allowing VOLTHA to connect.
34 // This is necessary to allow the device topology to be dynamically
35 // queried from driver after initialization and activation is complete.
36 int maxTrials = 300;
37 while (!state.is_activated()) {
38 sleep(1);
39 if (--maxTrials == 0) {
40 std::cout << "ERROR: OLT/PON Activation failed" << std::endl;
41 return 1;
42 }
43 }
44
Jason Huangb1fad572019-05-28 19:02:30 +080045 ProbeDeviceCapabilities_();
46 sleep(2);
Jason Huangb1fad572019-05-28 19:02:30 +080047 // Enable all PON interfaces.
48 for (int i = 0; i < NumPonIf_(); i++) {
49 status = EnablePonIf_(i);
50 if (!status.ok()) {
Jason Huang88795222019-06-13 19:28:44 +080051 // raise alarm to report error in enabling PON
52 pushOltOperInd(i, "pon", "down");
Jason Huangb1fad572019-05-28 19:02:30 +080053 }
Jason Huang88795222019-06-13 19:28:44 +080054 else
55 pushOltOperInd(i, "pon", "up");
Jason Huangb1fad572019-05-28 19:02:30 +080056 }
57 sleep(2);
58 // Enable all NNI interfaces.
Jason Huangb6843dc2019-07-22 17:46:06 +080059#if 0
Jason Huangb1fad572019-05-28 19:02:30 +080060 for (int i = 0; i < NumNniIf_(); i++) {
61 status = EnableUplinkIf_(i);
62 if (!status.ok()) {
Jason Huang88795222019-06-13 19:28:44 +080063 // raise alarm to report error in enabling PON
64 pushOltOperInd(i, "nni", "down");
Jason Huangb1fad572019-05-28 19:02:30 +080065 }
Jason Huang88795222019-06-13 19:28:44 +080066 else
67 pushOltOperInd(i, "nni", "up");
Jason Huangb1fad572019-05-28 19:02:30 +080068 }
Jason Huangb6843dc2019-07-22 17:46:06 +080069#endif
70 //only for nni-65536 mapping to intf_id 0
71 status = SetStateUplinkIf_(0, true);
72 if (!status.ok()) {
73 // raise alarm to report error in enabling NNI
74 pushOltOperInd(0, "nni", "down");
75 }
76 else
77 pushOltOperInd(0, "nni", "up");
Shad Ansari01b0e652018-04-05 21:02:53 +000078 RunServer();
79
Shad Ansari627b5782018-08-13 22:49:32 +000080 return 0;
Shad Ansari01b0e652018-04-05 21:02:53 +000081}