Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 1 | /* |
Nicolas Palpacuer | b78def4 | 2018-06-07 12:55:26 -0400 | [diff] [blame] | 2 | Copyright (C) 2018 Open Networking Foundation |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 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 | |
| 18 | #ifndef OPENOLT_CORE_H_ |
| 19 | #define OPENOLT_CORE_H_ |
| 20 | |
| 21 | #include <grpc++/grpc++.h> |
| 22 | using grpc::Status; |
| 23 | #include <openolt.grpc.pb.h> |
| 24 | |
Shad Ansari | edef213 | 2018-08-10 22:14:50 +0000 | [diff] [blame] | 25 | #include "state.h" |
| 26 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 27 | #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 Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 42 | #define COLLECTION_PERIOD 15 |
| 43 | |
Shad Ansari | edef213 | 2018-08-10 22:14:50 +0000 | [diff] [blame] | 44 | extern State state; |
| 45 | |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 46 | enum FLOW_CFG { |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 47 | ONU_ID = 0, |
| 48 | FLOW_TYPE = 1, |
| 49 | SVC_PORT_ID = 2, |
| 50 | PRIORITY = 3, |
| 51 | COOKIE = 4, |
| 52 | INGRESS_INTF_TYPE= 5, |
| 53 | EGRESS_INTF_TYPE= 6, |
| 54 | INGRESS_INTF_ID = 7, |
| 55 | EGRESS_INTF_ID = 8, |
| 56 | CLASSIFIER_O_VID = 9, |
| 57 | CLASSIFIER_O_PBITS = 10, |
| 58 | CLASSIFIER_I_VID = 11, |
| 59 | CLASSIFIER_I_PBITS = 12, |
| 60 | CLASSIFIER_ETHER_TYPE = 13, |
| 61 | CLASSIFIER_IP_PROTO =14, |
| 62 | CLASSIFIER_SRC_PORT = 15, |
| 63 | CLASSIFIER_DST_PORT = 16, |
| 64 | CLASSIFIER_PKT_TAG_TYPE = 17, |
| 65 | EGRESS_QOS_TYPE = 18, |
| 66 | EGRESS_QOS_QUEUE_ID = 19, |
| 67 | EGRESS_QOS_TM_SCHED_ID = 20, |
| 68 | ACTION_CMDS_BITMASK = 21, |
| 69 | ACTION_O_VID = 22, |
| 70 | ACTION_O_PBITS = 23, |
| 71 | ACTION_I_VID = 24, |
| 72 | ACTION_I_PBITS = 25, |
| 73 | STATE = 26 |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 74 | }; |
| 75 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 76 | Status Enable_(int argc, char *argv[]); |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 77 | Status ActivateOnu_(uint32_t intf_id, uint32_t onu_id, |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 78 | const char *vendor_id, const char *vendor_specific, uint32_t pir); |
Jonathan Davis | 70c2181 | 2018-07-19 15:32:10 -0400 | [diff] [blame] | 79 | Status DeactivateOnu_(uint32_t intf_id, uint32_t onu_id, |
| 80 | const char *vendor_id, const char *vendor_specific); |
| 81 | Status DeleteOnu_(uint32_t intf_id, uint32_t onu_id, |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 82 | const char *vendor_id, const char *vendor_specific); |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 83 | Status EnablePonIf_(uint32_t intf_id); |
Nicolas Palpacuer | 05ea0ea | 2018-07-06 11:47:21 -0400 | [diff] [blame] | 84 | Status DisablePonIf_(uint32_t intf_id); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 85 | Status SetStateUplinkIf_(uint32_t intf_id, bool set_state); |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 86 | unsigned NumNniIf_(); |
| 87 | unsigned NumPonIf_(); |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 88 | Status OmciMsgOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt); |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 89 | Status OnuPacketOut_(uint32_t intf_id, uint32_t onu_id, uint32_t port_no, uint32_t gemport_id, const std::string pkt); |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 90 | Status ProbeDeviceCapabilities_(); |
| 91 | Status ProbePonIfTechnology_(); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 92 | Status UplinkPacketOut_(uint32_t intf_id, const std::string pkt, uint16_t flow_id); |
Craig Lutgen | 967a1d0 | 2018-11-27 10:41:51 -0600 | [diff] [blame] | 93 | Status FlowAdd_(int32_t access_intf_id, int32_t onu_id, int32_t uni_id, uint32_t port_no, |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 94 | uint32_t flow_id, const std::string flow_type, |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 95 | int32_t alloc_id, int32_t network_intf_id, |
| 96 | int32_t gemport_id, const ::openolt::Classifier& classifier, |
Craig Lutgen | 967a1d0 | 2018-11-27 10:41:51 -0600 | [diff] [blame] | 97 | const ::openolt::Action& action, int32_t priority_value, uint64_t cookie); |
Nicolas Palpacuer | edfaa0c | 2018-07-05 15:05:27 -0400 | [diff] [blame] | 98 | Status FlowRemove_(uint32_t flow_id, const std::string flow_type); |
Nicolas Palpacuer | e3fc0d2 | 2018-08-02 16:51:05 -0400 | [diff] [blame] | 99 | Status Disable_(); |
| 100 | Status Reenable_(); |
Nicolas Palpacuer | dff9679 | 2018-09-06 14:59:32 -0400 | [diff] [blame] | 101 | Status GetDeviceInfo_(openolt::DeviceInfo* device_info); |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 102 | Status CreateTrafficSchedulers_(const tech_profile::TrafficSchedulers *traffic_scheds); |
| 103 | Status RemoveTrafficSchedulers_(const tech_profile::TrafficSchedulers *traffic_scheds); |
| 104 | Status CreateTrafficQueues_(const tech_profile::TrafficQueues *traffic_queues); |
| 105 | Status RemoveTrafficQueues_(const tech_profile::TrafficQueues *traffic_queues); |
Craig Lutgen | 967a1d0 | 2018-11-27 10:41:51 -0600 | [diff] [blame] | 106 | uint32_t GetPortNum_(uint32_t flow_id); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 107 | int get_status_bcm_cli_quit(void); |
| 108 | uint16_t get_dev_id(void); |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 109 | Status pushOltOperInd(uint32_t intf_id, const char *type, const char *state); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 110 | uint64_t get_flow_status(uint16_t flow_id, uint16_t flow_type, uint16_t data_id); |
Nicolas Palpacuer | e3fc0d2 | 2018-08-02 16:51:05 -0400 | [diff] [blame] | 111 | |
Nicolas Palpacuer | 6a63ea9 | 2018-09-05 17:21:37 -0400 | [diff] [blame] | 112 | void stats_collection(); |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 113 | #endif |