blob: 1caf3cc727b4de87af1418544dad98eb061c6b20 [file] [log] [blame]
Shad Ansarib7b0ced2018-05-11 21:53:32 +00001/*
Nicolas Palpacuerb78def42018-06-07 12:55:26 -04002 Copyright (C) 2018 Open Networking Foundation
Shad Ansarib7b0ced2018-05-11 21:53:32 +00003
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
18#ifndef OPENOLT_CORE_H_
19#define OPENOLT_CORE_H_
20
21#include <grpc++/grpc++.h>
22using grpc::Status;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000023#include <voltha_protos/openolt.grpc.pb.h>
Shad Ansarib7b0ced2018-05-11 21:53:32 +000024
Shad Ansariedef2132018-08-10 22:14:50 +000025#include "state.h"
26
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000027#define NONE "\033[m"
28#define LIGHT_RED "\033[1;31m"
29#define BROWN "\033[0;33m"
30#define LIGHT_GREEN "\033[1;32m"
31#define OPENOLT_LOG(level, id, fmt, ...) \
32 if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_ERROR) \
33 BCM_LOG(level, id, "%s" fmt "%s", LIGHT_RED, ##__VA_ARGS__, NONE); \
34 else if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_INFO) \
35 BCM_LOG(level, id, "%s" fmt "%s", NONE, ##__VA_ARGS__, NONE); \
36 else if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_WARNING) \
37 BCM_LOG(level, id, "%s" fmt "%s", BROWN, ##__VA_ARGS__, NONE); \
38 else if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_DEBUG) \
39 BCM_LOG(level, id, "%s" fmt "%s", LIGHT_GREEN, ##__VA_ARGS__, NONE); \
40 else \
41 BCM_LOG(INFO, id, fmt, ##__VA_ARGS__);
Shad Ansari627b5782018-08-13 22:49:32 +000042#define COLLECTION_PERIOD 15
Girish Gowdru376b33c2019-05-06 21:46:31 -070043#define BAL_DYNAMIC_LIST_BUFFER_SIZE (32 * 1024)
44#define MAX_REGID_LENGTH 36
Shad Ansari627b5782018-08-13 22:49:32 +000045
Shad Ansariedef2132018-08-10 22:14:50 +000046extern State state;
47
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000048enum FLOW_CFG {
49 ONU_ID = 0,
50 FLOW_TYPE = 1,
51 SVC_PORT_ID = 2,
52 PRIORITY = 3,
53 COOKIE = 4,
54 INGRESS_INTF_TYPE= 5,
55 EGRESS_INTF_TYPE= 6,
56 INGRESS_INTF_ID = 7,
57 EGRESS_INTF_ID = 8,
58 CLASSIFIER_O_VID = 9,
59 CLASSIFIER_O_PBITS = 10,
60 CLASSIFIER_I_VID = 11,
61 CLASSIFIER_I_PBITS = 12,
62 CLASSIFIER_ETHER_TYPE = 13,
63 CLASSIFIER_IP_PROTO =14,
64 CLASSIFIER_SRC_PORT = 15,
65 CLASSIFIER_DST_PORT = 16,
66 CLASSIFIER_PKT_TAG_TYPE = 17,
67 EGRESS_QOS_TYPE = 18,
68 EGRESS_QOS_QUEUE_ID = 19,
69 EGRESS_QOS_TM_SCHED_ID = 20,
70 ACTION_CMDS_BITMASK = 21,
71 ACTION_O_VID = 22,
72 ACTION_O_PBITS = 23,
73 ACTION_I_VID = 24,
74 ACTION_I_PBITS = 25,
75 STATE = 26
76};
77
Shad Ansari627b5782018-08-13 22:49:32 +000078Status Enable_(int argc, char *argv[]);
Shad Ansarib7b0ced2018-05-11 21:53:32 +000079Status ActivateOnu_(uint32_t intf_id, uint32_t onu_id,
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -070080 const char *vendor_id, const char *vendor_specific, uint32_t pir);
Jonathan Davis70c21812018-07-19 15:32:10 -040081Status DeactivateOnu_(uint32_t intf_id, uint32_t onu_id,
82 const char *vendor_id, const char *vendor_specific);
83Status DeleteOnu_(uint32_t intf_id, uint32_t onu_id,
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -070084 const char *vendor_id, const char *vendor_specific);
Shad Ansarib7b0ced2018-05-11 21:53:32 +000085Status EnablePonIf_(uint32_t intf_id);
Nicolas Palpacuer05ea0ea2018-07-06 11:47:21 -040086Status DisablePonIf_(uint32_t intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000087Status SetStateUplinkIf_(uint32_t intf_id, bool set_state);
Craig Lutgen88a22ad2018-10-04 12:30:46 -050088unsigned NumNniIf_();
89unsigned NumPonIf_();
Shad Ansarib7b0ced2018-05-11 21:53:32 +000090Status OmciMsgOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt);
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -080091Status OnuPacketOut_(uint32_t intf_id, uint32_t onu_id, uint32_t port_no, uint32_t gemport_id, const std::string pkt);
Craig Lutgen88a22ad2018-10-04 12:30:46 -050092Status ProbeDeviceCapabilities_();
93Status ProbePonIfTechnology_();
Nicolas Palpacuerb78def42018-06-07 12:55:26 -040094Status UplinkPacketOut_(uint32_t intf_id, const std::string pkt);
Craig Lutgen967a1d02018-11-27 10:41:51 -060095Status FlowAdd_(int32_t access_intf_id, int32_t onu_id, int32_t uni_id, uint32_t port_no,
Shad Ansarib7b0ced2018-05-11 21:53:32 +000096 uint32_t flow_id, const std::string flow_type,
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -070097 int32_t alloc_id, int32_t network_intf_id,
98 int32_t gemport_id, const ::openolt::Classifier& classifier,
Craig Lutgen967a1d02018-11-27 10:41:51 -060099 const ::openolt::Action& action, int32_t priority_value, uint64_t cookie);
Nicolas Palpacueredfaa0c2018-07-05 15:05:27 -0400100Status FlowRemove_(uint32_t flow_id, const std::string flow_type);
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400101Status Disable_();
102Status Reenable_();
Nicolas Palpacuerdff96792018-09-06 14:59:32 -0400103Status GetDeviceInfo_(openolt::DeviceInfo* device_info);
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -0800104Status CreateTrafficSchedulers_(const tech_profile::TrafficSchedulers *traffic_scheds);
105Status RemoveTrafficSchedulers_(const tech_profile::TrafficSchedulers *traffic_scheds);
106Status CreateTrafficQueues_(const tech_profile::TrafficQueues *traffic_queues);
107Status RemoveTrafficQueues_(const tech_profile::TrafficQueues *traffic_queues);
Craig Lutgen967a1d02018-11-27 10:41:51 -0600108uint32_t GetPortNum_(uint32_t flow_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000109int get_status_bcm_cli_quit(void);
110uint16_t get_dev_id(void);
111Status pushOltOperInd(uint32_t intf_id, const char *type, const char *state);
112uint64_t get_flow_status(uint16_t flow_id, uint16_t flow_type, uint16_t data_id);
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400113
Nicolas Palpacuer6a63ea92018-09-05 17:21:37 -0400114void stats_collection();
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000115#endif