blob: d0761c5f313927cdc54bed533486f3d45839e343 [file] [log] [blame]
Girish Gowdraddf9a162020-01-27 12:56:27 +05301/*
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
24extern "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
Girish Gowdra5057a3d2020-05-29 18:49:56 -070042#define ALLOC_CFG_COMPLETE_WAIT_TIMEOUT 5000 // in milli-seconds
Girish Gowdraddf9a162020-01-27 12:56:27 +053043
Girish Gowdra5057a3d2020-05-29 18:49:56 -070044#define ONU_DEACTIVATE_COMPLETE_WAIT_TIMEOUT 5000 // in milli-seconds
Girish Gowdra7a79dae2020-02-10 18:22:11 +053045
Girish Gowdraddf9a162020-01-27 12:56:27 +053046#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// **************************************//
54enum 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
85enum AllocCfgAction {
86 ALLOC_OBJECT_CREATE,
87 ALLOC_OBJECT_DELETE
88};
89
90enum AllocObjectState {
91 ALLOC_OBJECT_STATE_NOT_CONFIGURED,
92 ALLOC_OBJECT_STATE_INACTIVE,
93 ALLOC_OBJECT_STATE_PROCESSING,
94 ALLOC_OBJECT_STATE_ACTIVE
95};
96
97enum AllocCfgStatus {
98 ALLOC_CFG_STATUS_SUCCESS,
99 ALLOC_CFG_STATUS_FAIL
100};
101
102typedef 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 Gowdra7a79dae2020-02-10 18:22:11 +0530109typedef 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 Gowdraddf9a162020-01-27 12:56:27 +0530116// key for map used for tracking ITU PON Alloc Configuration results from BAL
117typedef std::tuple<uint32_t, uint32_t> alloc_cfg_compltd_key;
118
Girish Gowdra7a79dae2020-02-10 18:22:11 +0530119// key for map used for tracking Onu Deactivation Completed Indication
120typedef std::tuple<uint32_t, uint32_t> onu_deact_compltd_key;
121
Girish Gowdraddf9a162020-01-27 12:56:27 +0530122// 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.
125typedef 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// *******************************************************//
138extern State state;
139
140extern dev_log_id openolt_log_id;
141extern dev_log_id omci_log_id;
142
143extern unsigned int num_of_nni_ports;
144extern unsigned int num_of_pon_ports;
145
146extern const uint32_t tm_upstream_sched_id_start;
147extern const uint32_t tm_downstream_sched_id_start;
148
149extern const uint32_t queue_id_list[8];
150
151extern const std::string upstream;
152extern const std::string downstream;
153extern const std::string multicast;
154extern bcmolt_oltid dev_id;
155
156extern const uint32_t BAL_API_RETRY_TIME_IN_USECS;
157extern const uint32_t MAX_BAL_API_RETRY_COUNT;
158
159extern const unsigned int OPENOLT_FIELD_LEN;
160
161/* Current session */
162extern bcmcli_session *current_session;
163extern bcmcli_entry *api_parent_dir;
164extern bcmos_bool status_bcm_cli_quit;
165extern bcmos_task bal_cli_thread;
166extern const char *bal_cli_thread_name;
167extern uint16_t flow_id_counters;
168
169extern std::map<uint32_t, uint32_t> flowid_to_port; // For mapping upstream flows to logical ports
170extern std::map<uint32_t, uint32_t> flowid_to_gemport; // For mapping downstream flows into gemports
171extern 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.
Burak Gurdag2f2618c2020-04-23 13:20:30 +0000174 Represents (pon_intf_id, onu_id, uni_id, direction, tech_profile_id) */
175typedef std::tuple<uint32_t, uint32_t, uint32_t, std::string, uint32_t> sched_map_key_tuple;
Girish Gowdraddf9a162020-01-27 12:56:27 +0530176/* 'sched_map' maps sched_map_key_tuple to DBA (Upstream) or
177 Subscriber (Downstream) Scheduler ID */
178extern std::map<sched_map_key_tuple, int> sched_map;
179
180/* Flow control is for flow_id and flow_type */
181typedef std::pair<uint16_t, uint16_t> flow_pair;
182extern 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) */
186typedef 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*/
188extern 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.
191Represents (sched_id, pon_intf_id, onu_id, uni_id) */
192typedef 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 */
194extern 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 */
196extern std::map<int, std::vector < uint32_t > > qmp_id_to_qmp_map;
197
Girish Gowdraddf9a162020-01-27 12:56:27 +0530198// 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.
201extern std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *> alloc_cfg_compltd_map;
Girish Gowdra7a79dae2020-02-10 18:22:11 +0530202// 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.
205extern std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *> onu_deact_compltd_map;
206
Girish Gowdraddf9a162020-01-27 12:56:27 +0530207// Lock to protect critical section data structure used for handling AllocObject configuration response.
208extern bcmos_fastlock alloc_cfg_wait_lock;
Girish Gowdra7a79dae2020-02-10 18:22:11 +0530209// Lock to protect critical section data structure used for handling Onu deactivation completed Indication
210extern bcmos_fastlock onu_deactivate_wait_lock;
Girish Gowdraddf9a162020-01-27 12:56:27 +0530211
212
213/*** ACL Handling related data start ***/
214
215extern std::map<acl_classifier_key, uint16_t> acl_classifier_to_acl_id_map;
216extern bool operator<(const acl_classifier_key& a1, const acl_classifier_key& a2);
217
218typedef std::tuple<uint16_t, std::string> flow_id_flow_direction;
219typedef std::tuple<int16_t, uint16_t, int32_t> acl_id_gem_id_intf_id;
220extern 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.
226extern std::map<uint16_t, uint16_t> acl_ref_cnt;
227
228typedef 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.
232extern 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.
238typedef std::tuple<uint16_t, uint8_t, std::string> acl_id_intf_id_intf_type;
239extern std::map<acl_id_intf_id_intf_type, uint16_t> intf_acl_registration_ref_cnt;
240
241extern std::bitset<MAX_ACL_ID> acl_id_bitset;
242
243/*** ACL Handling related data end ***/
244
245extern std::bitset<MAX_TM_SCHED_ID> tm_sched_bitset;
246extern std::bitset<MAX_TM_QMP_ID> tm_qmp_bitset;
247
248extern Queue<openolt::Indication> oltIndQ;
249
250extern bcmos_fastlock data_lock;
251
Humera Kouser6143c9e2020-06-17 22:37:31 +0530252// Interface name on which grpc server is running on
253// and this can be used to get the mac adress based on interface name.
254extern char* grpc_server_interface_name;
Girish Gowdraddf9a162020-01-27 12:56:27 +0530255#endif // OPENOLT_CORE_DATA_H_