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_UTILS_H_ |
| 17 | #define OPENOLT_CORE_UTILS_H_ |
| 18 | #include <string> |
| 19 | #include <unistd.h> |
| 20 | |
| 21 | #include "core.h" |
| 22 | #include "core_data.h" |
| 23 | #include "error_format.h" |
| 24 | |
| 25 | extern "C" |
| 26 | { |
| 27 | #include <bcmolt_api.h> |
| 28 | #include <bcmolt_host_api.h> |
| 29 | #include <bcmolt_api_model_supporting_enums.h> |
| 30 | #include <bcmolt_api_model_supporting_structs.h> |
| 31 | |
| 32 | #include <bcmolt_api_conn_mgr.h> |
| 33 | //CLI header files |
| 34 | #include <bcmcli_session.h> |
| 35 | #include <bcmcli.h> |
| 36 | #include <bcm_api_cli.h> |
| 37 | |
| 38 | #include <bcmos_common.h> |
| 39 | #include <bcm_config.h> |
| 40 | // FIXME : dependency problem |
| 41 | // #include <bcm_common_gpon.h> |
| 42 | // #include <bcm_dev_log_task.h> |
| 43 | } |
| 44 | |
| 45 | |
| 46 | std::string serial_number_to_str(bcmolt_serial_number* serial_number); |
| 47 | std::string vendor_specific_to_str(const char* const serial_number); |
| 48 | uint16_t get_dev_id(void); |
| 49 | int get_default_tm_sched_id(int intf_id, std::string direction); |
| 50 | uint32_t get_tm_sched_id(int pon_intf_id, int onu_id, int uni_id, std::string direction); |
| 51 | void free_tm_sched_id(int pon_intf_id, int onu_id, int uni_id, std::string direction); |
| 52 | bool is_tm_sched_id_present(int pon_intf_id, int onu_id, int uni_id, std::string direction); |
| 53 | bool check_tm_qmp_equality(std::vector<uint32_t> tmq_map_profileA, std::vector<uint32_t> tmq_map_profileB); |
| 54 | std::string* get_valid_queues_pbit_map(std::string *queues_pbit_map, uint32_t size); |
| 55 | std::vector<uint32_t> get_tmq_map_profile(std::string *queues_pbit_map, uint32_t *queues_priority_q, uint32_t size); |
| 56 | int get_tm_qmp_id(std::vector<uint32_t> tmq_map_profile); |
| 57 | void update_sched_qmp_id_map(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, |
| 58 | uint32_t uni_id, int tm_qmp_id); |
| 59 | int get_tm_qmp_id(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, uint32_t uni_id); |
| 60 | int get_tm_qmp_id(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, uint32_t uni_id, |
| 61 | std::vector<uint32_t> tmq_map_profile); |
| 62 | bool free_tm_qmp_id(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, |
| 63 | uint32_t uni_id, int tm_qmp_id); |
| 64 | int get_acl_id(); |
| 65 | void free_acl_id (int acl_id); |
| 66 | std::string get_qos_type_as_string(bcmolt_egress_qos_type qos_type); |
| 67 | bcmolt_egress_qos_type get_qos_type(uint32_t pon_intf_id, uint32_t onu_id, uint32_t uni_id, uint32_t queue_size=0); |
| 68 | void clear_qos_type(uint32_t pon_intf_id, uint32_t onu_id, uint32_t uni_id); |
| 69 | std::string GetDirection(int direction); |
| 70 | bcmos_errno wait_for_alloc_action(uint32_t intf_id, uint32_t alloc_id, AllocCfgAction action); |
| 71 | char* openolt_read_sysinfo(const char* field_name, char* field_val); |
| 72 | Status pushOltOperInd(uint32_t intf_id, const char *type, const char *state); |
| 73 | void openolt_cli_get_prompt_cb(bcmcli_session *session, char *buf, uint32_t max_len); |
| 74 | int _bal_apiend_cli_thread_handler(long data); |
| 75 | bcmos_errno bcm_openolt_api_cli_init(bcmcli_entry *parent_dir, bcmcli_session *session); |
| 76 | bcmos_errno bcm_cli_quit(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t n_parms); |
| 77 | int get_status_bcm_cli_quit(void); |
| 78 | bcmos_errno bcmolt_apiend_cli_init(); |
| 79 | bcmos_errno get_pon_interface_status(bcmolt_interface pon_ni, bcmolt_interface_state *state); |
| 80 | bcmos_errno bcmolt_cfg_get_mult_retry(bcmolt_oltid olt, bcmolt_cfg *cfg); |
| 81 | unsigned NumNniIf_(); |
| 82 | unsigned NumPonIf_(); |
| 83 | bcmos_errno get_nni_interface_status(bcmolt_interface id, bcmolt_interface_state *state); |
| 84 | Status install_gem_port(int32_t intf_id, int32_t onu_id, int32_t gemport_id); |
| 85 | Status remove_gem_port(int32_t intf_id, int32_t gemport_id); |
| 86 | Status update_acl_interface(int32_t intf_id, bcmolt_interface_type intf_type, uint32_t access_control_id, |
| 87 | bcmolt_members_update_command acl_cmd); |
| 88 | Status install_acl(const acl_classifier_key acl_key); |
| 89 | Status remove_acl(int acl_id); |
| 90 | void formulate_acl_classifier_key(acl_classifier_key *key, const ::openolt::Classifier& classifier); |
| 91 | Status handle_acl_rule_install(int32_t onu_id, uint32_t flow_id, |
| 92 | const std::string flow_type, int32_t access_intf_id, |
| 93 | int32_t network_intf_id, int32_t gemport_id, |
| 94 | const ::openolt::Classifier& classifier); |
| 95 | void clear_gem_port(int gemport_id, int access_intf_id); |
| 96 | Status handle_acl_rule_cleanup(int16_t acl_id, int32_t gemport_id, int32_t intf_id, const std::string flow_type); |
| 97 | Status check_bal_ready(); |
| 98 | Status check_connection(); |
| 99 | #endif // OPENOLT_CORE_UTILS_H_ |
| 100 | |
| 101 | |