Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [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 | #ifndef OPENOLT_CORE_DATA_H_ |
| 17 | #define OPENOLT_CORE_DATA_H_ |
| 18 | |
| 19 | #include <bitset> |
| 20 | |
| 21 | #include "core.h" |
| 22 | #include "Queue.h" |
| 23 | |
| 24 | extern "C" |
| 25 | { |
| 26 | #include <bcmolt_api.h> |
| 27 | #include <bcmolt_api_model_supporting_enums.h> |
| 28 | |
| 29 | #include <bcmolt_api_conn_mgr.h> |
| 30 | //CLI header files |
| 31 | #include <bcmcli_session.h> |
| 32 | #include <bcmcli.h> |
| 33 | #include <bcm_api_cli.h> |
| 34 | |
| 35 | #include <bcmos_common.h> |
| 36 | #include <bcm_config.h> |
| 37 | // FIXME : dependency problem |
| 38 | // #include <bcm_common_gpon.h> |
| 39 | // #include <bcm_dev_log_task.h> |
| 40 | } |
| 41 | |
| 42 | #define ALLOC_CFG_COMPLETE_WAIT_TIMEOUT 1000 // in milli-seconds |
| 43 | |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 44 | #define ONU_DEACTIVATE_COMPLETE_WAIT_TIMEOUT 1000 // in milli-seconds |
| 45 | |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 46 | #define MIN_ALLOC_ID_GPON 256 |
| 47 | #define MIN_ALLOC_ID_XGSPON 1024 |
| 48 | |
| 49 | #define MAX_ACL_ID 33 |
| 50 | |
| 51 | // **************************************// |
| 52 | // Enums and structures used by the core // |
| 53 | // **************************************// |
| 54 | enum FLOW_CFG { |
| 55 | ONU_ID = 0, |
| 56 | FLOW_TYPE = 1, |
| 57 | SVC_PORT_ID = 2, |
| 58 | PRIORITY = 3, |
| 59 | COOKIE = 4, |
| 60 | INGRESS_INTF_TYPE= 5, |
| 61 | EGRESS_INTF_TYPE= 6, |
| 62 | INGRESS_INTF_ID = 7, |
| 63 | EGRESS_INTF_ID = 8, |
| 64 | CLASSIFIER_O_VID = 9, |
| 65 | CLASSIFIER_O_PBITS = 10, |
| 66 | CLASSIFIER_I_VID = 11, |
| 67 | CLASSIFIER_I_PBITS = 12, |
| 68 | CLASSIFIER_ETHER_TYPE = 13, |
| 69 | CLASSIFIER_IP_PROTO =14, |
| 70 | CLASSIFIER_SRC_PORT = 15, |
| 71 | CLASSIFIER_DST_PORT = 16, |
| 72 | CLASSIFIER_PKT_TAG_TYPE = 17, |
| 73 | EGRESS_QOS_TYPE = 18, |
| 74 | EGRESS_QOS_QUEUE_ID = 19, |
| 75 | EGRESS_QOS_TM_SCHED_ID = 20, |
| 76 | ACTION_CMDS_BITMASK = 21, |
| 77 | ACTION_O_VID = 22, |
| 78 | ACTION_O_PBITS = 23, |
| 79 | ACTION_I_VID = 24, |
| 80 | ACTION_I_PBITS = 25, |
| 81 | STATE = 26, |
| 82 | GROUP_ID = 27 |
| 83 | }; |
| 84 | |
| 85 | enum AllocCfgAction { |
| 86 | ALLOC_OBJECT_CREATE, |
| 87 | ALLOC_OBJECT_DELETE |
| 88 | }; |
| 89 | |
| 90 | enum AllocObjectState { |
| 91 | ALLOC_OBJECT_STATE_NOT_CONFIGURED, |
| 92 | ALLOC_OBJECT_STATE_INACTIVE, |
| 93 | ALLOC_OBJECT_STATE_PROCESSING, |
| 94 | ALLOC_OBJECT_STATE_ACTIVE |
| 95 | }; |
| 96 | |
| 97 | enum AllocCfgStatus { |
| 98 | ALLOC_CFG_STATUS_SUCCESS, |
| 99 | ALLOC_CFG_STATUS_FAIL |
| 100 | }; |
| 101 | |
| 102 | typedef struct { |
| 103 | uint32_t pon_intf_id; |
| 104 | uint32_t alloc_id; |
| 105 | AllocObjectState state; |
| 106 | AllocCfgStatus status; |
| 107 | } alloc_cfg_complete_result; |
| 108 | |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 109 | typedef struct { |
| 110 | uint32_t pon_intf_id; |
| 111 | uint32_t onu_id; |
| 112 | bcmolt_result result; |
| 113 | bcmolt_deactivation_fail_reason reason; |
| 114 | } onu_deactivate_complete_result; |
| 115 | |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 116 | // key for map used for tracking ITU PON Alloc Configuration results from BAL |
| 117 | typedef std::tuple<uint32_t, uint32_t> alloc_cfg_compltd_key; |
| 118 | |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 119 | // key for map used for tracking Onu Deactivation Completed Indication |
| 120 | typedef std::tuple<uint32_t, uint32_t> onu_deact_compltd_key; |
| 121 | |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 122 | // The elements in this acl_classifier_key structure constitute key to |
| 123 | // acl_classifier_to_acl_id_map. |
| 124 | // Fill invalid values in the acl_classifier_key structure to -1. |
| 125 | typedef struct acl_classifier_key { |
| 126 | int32_t ether_type; |
| 127 | int16_t ip_proto; |
| 128 | int32_t src_port; |
| 129 | int32_t dst_port; |
| 130 | // Add more classifiers elements as needed here |
| 131 | // For now, ACLs will be classified only based on |
| 132 | // above elements. |
| 133 | } acl_classifier_key; |
| 134 | |
| 135 | // *******************************************************// |
| 136 | // Extern Variable/Constant declarations used by the core // |
| 137 | // *******************************************************// |
| 138 | extern State state; |
| 139 | |
| 140 | extern dev_log_id openolt_log_id; |
| 141 | extern dev_log_id omci_log_id; |
| 142 | |
| 143 | extern unsigned int num_of_nni_ports; |
| 144 | extern unsigned int num_of_pon_ports; |
| 145 | |
| 146 | extern const uint32_t tm_upstream_sched_id_start; |
| 147 | extern const uint32_t tm_downstream_sched_id_start; |
| 148 | |
| 149 | extern const uint32_t queue_id_list[8]; |
| 150 | |
| 151 | extern const std::string upstream; |
| 152 | extern const std::string downstream; |
| 153 | extern const std::string multicast; |
| 154 | extern bcmolt_oltid dev_id; |
| 155 | |
| 156 | extern const uint32_t BAL_API_RETRY_TIME_IN_USECS; |
| 157 | extern const uint32_t MAX_BAL_API_RETRY_COUNT; |
| 158 | |
| 159 | extern const unsigned int OPENOLT_FIELD_LEN; |
| 160 | |
| 161 | /* Current session */ |
| 162 | extern bcmcli_session *current_session; |
| 163 | extern bcmcli_entry *api_parent_dir; |
| 164 | extern bcmos_bool status_bcm_cli_quit; |
| 165 | extern bcmos_task bal_cli_thread; |
| 166 | extern const char *bal_cli_thread_name; |
| 167 | extern uint16_t flow_id_counters; |
| 168 | |
| 169 | extern std::map<uint32_t, uint32_t> flowid_to_port; // For mapping upstream flows to logical ports |
| 170 | extern std::map<uint32_t, uint32_t> flowid_to_gemport; // For mapping downstream flows into gemports |
| 171 | extern std::map<uint32_t, std::set<uint32_t> > port_to_flows; // For mapping logical ports to downstream flows |
| 172 | |
| 173 | /* This represents the Key to 'sched_map' map. |
| 174 | Represents (pon_intf_id, onu_id, uni_id, direction) */ |
| 175 | typedef std::tuple<uint32_t, uint32_t, uint32_t, std::string> sched_map_key_tuple; |
| 176 | /* 'sched_map' maps sched_map_key_tuple to DBA (Upstream) or |
| 177 | Subscriber (Downstream) Scheduler ID */ |
| 178 | extern std::map<sched_map_key_tuple, int> sched_map; |
| 179 | |
| 180 | /* Flow control is for flow_id and flow_type */ |
| 181 | typedef std::pair<uint16_t, uint16_t> flow_pair; |
| 182 | extern std::map<flow_pair, int32_t> flow_map; |
| 183 | |
| 184 | /* This represents the Key to 'qos_type_map' map. |
| 185 | Represents (pon_intf_id, onu_id, uni_id) */ |
| 186 | typedef std::tuple<uint32_t, uint32_t, uint32_t> qos_type_map_key_tuple; |
| 187 | /* 'qos_type_map' maps qos_type_map_key_tuple to qos_type*/ |
| 188 | extern std::map<qos_type_map_key_tuple, bcmolt_egress_qos_type> qos_type_map; |
| 189 | |
| 190 | /* This represents the Key to 'sched_qmp_id_map' map. |
| 191 | Represents (sched_id, pon_intf_id, onu_id, uni_id) */ |
| 192 | typedef std::tuple<uint32_t, uint32_t, uint32_t, uint32_t> sched_qmp_id_map_key_tuple; |
| 193 | /* 'sched_qmp_id_map' maps sched_qmp_id_map_key_tuple to TM Queue Mapping Profile ID */ |
| 194 | extern std::map<sched_qmp_id_map_key_tuple, int> sched_qmp_id_map; |
| 195 | /* 'qmp_id_to_qmp_map' maps TM Queue Mapping Profile ID to TM Queue Mapping Profile */ |
| 196 | extern std::map<int, std::vector < uint32_t > > qmp_id_to_qmp_map; |
| 197 | |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 198 | // Map used to track response from BAL for ITU PON Alloc Configuration. |
| 199 | // The key is alloc_cfg_compltd_key and value is a concurrent thread-safe queue which is |
| 200 | // used for pushing (from BAL) and popping (at application) the results. |
| 201 | extern std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *> alloc_cfg_compltd_map; |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 202 | // Map used to track response from BAL for Onu Deactivation Completed Indication |
| 203 | // The key is alloc_cfg_compltd_key and value is a concurrent thread-safe queue which is |
| 204 | // used for pushing (from BAL) and popping (at application) the results. |
| 205 | extern std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *> onu_deact_compltd_map; |
| 206 | |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 207 | // Lock to protect critical section data structure used for handling AllocObject configuration response. |
| 208 | extern bcmos_fastlock alloc_cfg_wait_lock; |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 209 | // Lock to protect critical section data structure used for handling Onu deactivation completed Indication |
| 210 | extern bcmos_fastlock onu_deactivate_wait_lock; |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 211 | |
| 212 | |
| 213 | /*** ACL Handling related data start ***/ |
| 214 | |
| 215 | extern std::map<acl_classifier_key, uint16_t> acl_classifier_to_acl_id_map; |
| 216 | extern bool operator<(const acl_classifier_key& a1, const acl_classifier_key& a2); |
| 217 | |
| 218 | typedef std::tuple<uint16_t, std::string> flow_id_flow_direction; |
| 219 | typedef std::tuple<int16_t, uint16_t, int32_t> acl_id_gem_id_intf_id; |
| 220 | extern std::map<flow_id_flow_direction, acl_id_gem_id_intf_id> flow_to_acl_map; |
| 221 | |
| 222 | // Keeps a reference count of how many flows are referencing a given ACL ID. |
| 223 | // Key represents the ACL-ID and value is number of flows referencing the given ACL-ID. |
| 224 | // When there is at least one flow referencing the ACL-ID, the ACL should be installed. |
| 225 | // When there are no flows referencing the ACL-ID, the ACL should be removed. |
| 226 | extern std::map<uint16_t, uint16_t> acl_ref_cnt; |
| 227 | |
| 228 | typedef std::tuple<uint16_t, uint16_t> gem_id_intf_id; // key to gem_ref_cnt |
| 229 | // Keeps a reference count of how many ACL related flows are referencing a given (gem-id, pon_intf_id). |
| 230 | // When there is at least on flow, we should install the gem. When there are no flows |
| 231 | // the gem should be removed. |
| 232 | extern std::map<gem_id_intf_id, uint16_t> gem_ref_cnt; |
| 233 | |
| 234 | // Needed to keep track of how many flows for a given acl_id, intf_id and intf_type are |
| 235 | // installed. When there is at least on flow for this key, we should have interface registered |
| 236 | // for the given ACL-ID. When there are no flows, the intf should unregister itself from |
| 237 | // the ACL-ID. |
| 238 | typedef std::tuple<uint16_t, uint8_t, std::string> acl_id_intf_id_intf_type; |
| 239 | extern std::map<acl_id_intf_id_intf_type, uint16_t> intf_acl_registration_ref_cnt; |
| 240 | |
| 241 | extern std::bitset<MAX_ACL_ID> acl_id_bitset; |
| 242 | |
| 243 | /*** ACL Handling related data end ***/ |
| 244 | |
| 245 | extern std::bitset<MAX_TM_SCHED_ID> tm_sched_bitset; |
| 246 | extern std::bitset<MAX_TM_QMP_ID> tm_qmp_bitset; |
| 247 | |
| 248 | extern Queue<openolt::Indication> oltIndQ; |
| 249 | |
| 250 | extern bcmos_fastlock data_lock; |
| 251 | |
| 252 | |
| 253 | #endif // OPENOLT_CORE_DATA_H_ |