blob: 1b2b3dd5d51f26d0dbaa2118c049264ffb153a06 [file] [log] [blame]
Shad Ansarib7b0ced2018-05-11 21:53:32 +00001/*
Girish Gowdraa707e7c2019-11-07 11:36:13 +05302 * Copyright 2018-present Open Networking Foundation
Shad Ansarib7b0ced2018-05-11 21:53:32 +00003
Girish Gowdraa707e7c2019-11-07 11:36:13 +05304 * 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
Shad Ansarib7b0ced2018-05-11 21:53:32 +00007
Girish Gowdraa707e7c2019-11-07 11:36:13 +05308 * http://www.apache.org/licenses/LICENSE-2.0
Shad Ansarib7b0ced2018-05-11 21:53:32 +00009
Girish Gowdraa707e7c2019-11-07 11:36:13 +053010 * 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 */
Shad Ansarib7b0ced2018-05-11 21:53:32 +000016
17#ifndef OPENOLT_CORE_H_
18#define OPENOLT_CORE_H_
19
20#include <grpc++/grpc++.h>
21using grpc::Status;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000022#include <voltha_protos/openolt.grpc.pb.h>
Shad Ansarib7b0ced2018-05-11 21:53:32 +000023
Shad Ansariedef2132018-08-10 22:14:50 +000024#include "state.h"
25
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000026#define NONE "\033[m"
27#define LIGHT_RED "\033[1;31m"
28#define BROWN "\033[0;33m"
29#define LIGHT_GREEN "\033[1;32m"
30#define OPENOLT_LOG(level, id, fmt, ...) \
31 if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_ERROR) \
32 BCM_LOG(level, id, "%s" fmt "%s", LIGHT_RED, ##__VA_ARGS__, NONE); \
33 else if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_INFO) \
34 BCM_LOG(level, id, "%s" fmt "%s", NONE, ##__VA_ARGS__, NONE); \
35 else if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_WARNING) \
36 BCM_LOG(level, id, "%s" fmt "%s", BROWN, ##__VA_ARGS__, NONE); \
37 else if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_DEBUG) \
38 BCM_LOG(level, id, "%s" fmt "%s", LIGHT_GREEN, ##__VA_ARGS__, NONE); \
39 else \
40 BCM_LOG(INFO, id, fmt, ##__VA_ARGS__);
Girish Gowdra96461052019-11-22 20:13:59 +053041#define COLLECTION_PERIOD 15 // in seconds
Girish Gowdru376b33c2019-05-06 21:46:31 -070042#define BAL_DYNAMIC_LIST_BUFFER_SIZE (32 * 1024)
43#define MAX_REGID_LENGTH 36
Shad Ansari627b5782018-08-13 22:49:32 +000044
Shad Ansariedef2132018-08-10 22:14:50 +000045extern State state;
46
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000047enum FLOW_CFG {
48 ONU_ID = 0,
49 FLOW_TYPE = 1,
50 SVC_PORT_ID = 2,
51 PRIORITY = 3,
52 COOKIE = 4,
53 INGRESS_INTF_TYPE= 5,
54 EGRESS_INTF_TYPE= 6,
55 INGRESS_INTF_ID = 7,
56 EGRESS_INTF_ID = 8,
57 CLASSIFIER_O_VID = 9,
58 CLASSIFIER_O_PBITS = 10,
59 CLASSIFIER_I_VID = 11,
60 CLASSIFIER_I_PBITS = 12,
61 CLASSIFIER_ETHER_TYPE = 13,
62 CLASSIFIER_IP_PROTO =14,
63 CLASSIFIER_SRC_PORT = 15,
64 CLASSIFIER_DST_PORT = 16,
65 CLASSIFIER_PKT_TAG_TYPE = 17,
66 EGRESS_QOS_TYPE = 18,
67 EGRESS_QOS_QUEUE_ID = 19,
68 EGRESS_QOS_TM_SCHED_ID = 20,
69 ACTION_CMDS_BITMASK = 21,
70 ACTION_O_VID = 22,
71 ACTION_O_PBITS = 23,
72 ACTION_I_VID = 24,
73 ACTION_I_PBITS = 25,
Burak Gurdagc78b9e12019-11-29 11:14:51 +000074 STATE = 26,
75 GROUP_ID = 27
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000076};
77
Girish Gowdra96461052019-11-22 20:13:59 +053078enum AllocCfgAction {
79 ALLOC_OBJECT_CREATE,
80 ALLOC_OBJECT_DELETE
81};
82
83enum AllocObjectState {
84 ALLOC_OBJECT_STATE_NOT_CONFIGURED,
85 ALLOC_OBJECT_STATE_INACTIVE,
86 ALLOC_OBJECT_STATE_PROCESSING,
87 ALLOC_OBJECT_STATE_ACTIVE
88};
89
90enum AllocCfgStatus {
91 ALLOC_CFG_STATUS_SUCCESS,
92 ALLOC_CFG_STATUS_FAIL
93};
94
95typedef struct {
96 uint32_t pon_intf_id;
97 uint32_t alloc_id;
98 AllocObjectState state;
99 AllocCfgStatus status;
100} alloc_cfg_complete_result;
101
102// key for map used for tracking ITU PON Alloc Configuration results from BAL
103typedef std::tuple<uint32_t, uint32_t> alloc_cfg_compltd_key;
104
Shad Ansari627b5782018-08-13 22:49:32 +0000105Status Enable_(int argc, char *argv[]);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000106Status ActivateOnu_(uint32_t intf_id, uint32_t onu_id,
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700107 const char *vendor_id, const char *vendor_specific, uint32_t pir);
Jonathan Davis70c21812018-07-19 15:32:10 -0400108Status DeactivateOnu_(uint32_t intf_id, uint32_t onu_id,
109 const char *vendor_id, const char *vendor_specific);
110Status DeleteOnu_(uint32_t intf_id, uint32_t onu_id,
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700111 const char *vendor_id, const char *vendor_specific);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000112Status EnablePonIf_(uint32_t intf_id);
Nicolas Palpacuer05ea0ea2018-07-06 11:47:21 -0400113Status DisablePonIf_(uint32_t intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000114Status SetStateUplinkIf_(uint32_t intf_id, bool set_state);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500115unsigned NumNniIf_();
116unsigned NumPonIf_();
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000117Status OmciMsgOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt);
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -0800118Status 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 -0500119Status ProbeDeviceCapabilities_();
120Status ProbePonIfTechnology_();
Nicolas Palpacuerb78def42018-06-07 12:55:26 -0400121Status UplinkPacketOut_(uint32_t intf_id, const std::string pkt);
Craig Lutgen967a1d02018-11-27 10:41:51 -0600122Status 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 +0000123 uint32_t flow_id, const std::string flow_type,
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700124 int32_t alloc_id, int32_t network_intf_id,
125 int32_t gemport_id, const ::openolt::Classifier& classifier,
Burak Gurdagc78b9e12019-11-29 11:14:51 +0000126 const ::openolt::Action& action, int32_t priority_value,
127 uint64_t cookie, int32_t group_id);
Nicolas Palpacueredfaa0c2018-07-05 15:05:27 -0400128Status FlowRemove_(uint32_t flow_id, const std::string flow_type);
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400129Status Disable_();
130Status Reenable_();
Nicolas Palpacuerdff96792018-09-06 14:59:32 -0400131Status GetDeviceInfo_(openolt::DeviceInfo* device_info);
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -0800132Status CreateTrafficSchedulers_(const tech_profile::TrafficSchedulers *traffic_scheds);
133Status RemoveTrafficSchedulers_(const tech_profile::TrafficSchedulers *traffic_scheds);
134Status CreateTrafficQueues_(const tech_profile::TrafficQueues *traffic_queues);
135Status RemoveTrafficQueues_(const tech_profile::TrafficQueues *traffic_queues);
Burak Gurdagc78b9e12019-11-29 11:14:51 +0000136Status PerformGroupOperation_(const openolt::Group *group_cfg);
Craig Lutgen967a1d02018-11-27 10:41:51 -0600137uint32_t GetPortNum_(uint32_t flow_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000138int get_status_bcm_cli_quit(void);
Jason Huangbf45ffb2019-10-30 17:29:02 +0800139uint16_t get_dev_id(void);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000140Status pushOltOperInd(uint32_t intf_id, const char *type, const char *state);
141uint64_t get_flow_status(uint16_t flow_id, uint16_t flow_type, uint16_t data_id);
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400142
Nicolas Palpacuer6a63ea92018-09-05 17:21:37 -0400143void stats_collection();
Jason Huangbf45ffb2019-10-30 17:29:02 +0800144Status check_connection();
145Status check_bal_ready();
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000146#endif