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> |
Thiyagarajan Subramani | 03bc66f | 2020-04-01 15:58:53 +0530 | [diff] [blame] | 20 | #include <ifaddrs.h> |
| 21 | #include <arpa/inet.h> |
Humera Kouser | 6143c9e | 2020-06-17 22:37:31 +0530 | [diff] [blame] | 22 | #include <sys/ioctl.h> |
| 23 | #include <net/if.h> |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 24 | |
| 25 | #include "core.h" |
| 26 | #include "core_data.h" |
| 27 | #include "error_format.h" |
| 28 | |
| 29 | extern "C" |
| 30 | { |
| 31 | #include <bcmolt_api.h> |
| 32 | #include <bcmolt_host_api.h> |
| 33 | #include <bcmolt_api_model_supporting_enums.h> |
| 34 | #include <bcmolt_api_model_supporting_structs.h> |
| 35 | |
| 36 | #include <bcmolt_api_conn_mgr.h> |
| 37 | //CLI header files |
| 38 | #include <bcmcli_session.h> |
| 39 | #include <bcmcli.h> |
| 40 | #include <bcm_api_cli.h> |
| 41 | |
| 42 | #include <bcmos_common.h> |
| 43 | #include <bcm_config.h> |
| 44 | // FIXME : dependency problem |
| 45 | // #include <bcm_common_gpon.h> |
| 46 | // #include <bcm_dev_log_task.h> |
| 47 | } |
| 48 | |
| 49 | |
| 50 | std::string serial_number_to_str(bcmolt_serial_number* serial_number); |
| 51 | std::string vendor_specific_to_str(const char* const serial_number); |
| 52 | uint16_t get_dev_id(void); |
| 53 | int get_default_tm_sched_id(int intf_id, std::string direction); |
Burak Gurdag | 2f2618c | 2020-04-23 13:20:30 +0000 | [diff] [blame] | 54 | uint32_t get_tm_sched_id(int pon_intf_id, int onu_id, int uni_id, std::string direction, int tech_profile_id); |
| 55 | void free_tm_sched_id(int pon_intf_id, int onu_id, int uni_id, std::string direction, int tech_profile_id); |
| 56 | bool is_tm_sched_id_present(int pon_intf_id, int onu_id, int uni_id, std::string direction, int tech_profile_id); |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 57 | bool check_tm_qmp_equality(std::vector<uint32_t> tmq_map_profileA, std::vector<uint32_t> tmq_map_profileB); |
| 58 | std::string* get_valid_queues_pbit_map(std::string *queues_pbit_map, uint32_t size); |
| 59 | std::vector<uint32_t> get_tmq_map_profile(std::string *queues_pbit_map, uint32_t *queues_priority_q, uint32_t size); |
| 60 | int get_tm_qmp_id(std::vector<uint32_t> tmq_map_profile); |
| 61 | void update_sched_qmp_id_map(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, |
| 62 | uint32_t uni_id, int tm_qmp_id); |
| 63 | int get_tm_qmp_id(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, uint32_t uni_id); |
| 64 | int get_tm_qmp_id(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, uint32_t uni_id, |
| 65 | std::vector<uint32_t> tmq_map_profile); |
| 66 | bool free_tm_qmp_id(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, |
| 67 | uint32_t uni_id, int tm_qmp_id); |
| 68 | int get_acl_id(); |
| 69 | void free_acl_id (int acl_id); |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 70 | uint16_t get_flow_id(); |
| 71 | bool get_flow_ids(int num_of_flow_ids, uint16_t *flow_ids); |
| 72 | void free_flow_id (uint16_t flow_id); |
| 73 | void free_flow_ids(uint8_t num_flows, uint16_t *flow_ids); |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 74 | std::string get_qos_type_as_string(bcmolt_egress_qos_type qos_type); |
| 75 | 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); |
| 76 | void clear_qos_type(uint32_t pon_intf_id, uint32_t onu_id, uint32_t uni_id); |
| 77 | std::string GetDirection(int direction); |
| 78 | bcmos_errno wait_for_alloc_action(uint32_t intf_id, uint32_t alloc_id, AllocCfgAction action); |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 79 | bcmos_errno wait_for_onu_deactivate_complete(uint32_t intf_id, uint32_t onu_id); |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 80 | char* openolt_read_sysinfo(const char* field_name, char* field_val); |
| 81 | Status pushOltOperInd(uint32_t intf_id, const char *type, const char *state); |
| 82 | void openolt_cli_get_prompt_cb(bcmcli_session *session, char *buf, uint32_t max_len); |
| 83 | int _bal_apiend_cli_thread_handler(long data); |
| 84 | bcmos_errno bcm_openolt_api_cli_init(bcmcli_entry *parent_dir, bcmcli_session *session); |
| 85 | bcmos_errno bcm_cli_quit(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t n_parms); |
| 86 | int get_status_bcm_cli_quit(void); |
| 87 | bcmos_errno bcmolt_apiend_cli_init(); |
Thiyagarajan Subramani | ad46323 | 2020-02-28 19:10:43 +0530 | [diff] [blame] | 88 | bcmos_errno get_pon_interface_status(bcmolt_interface pon_ni, bcmolt_interface_state *state, bcmolt_status *los_status); |
| 89 | bcmos_errno get_onu_status(bcmolt_interface pon_ni, int onu_id, bcmolt_onu_state *onu_state); |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 90 | bcmos_errno bcmolt_cfg_get_mult_retry(bcmolt_oltid olt, bcmolt_cfg *cfg); |
| 91 | unsigned NumNniIf_(); |
| 92 | unsigned NumPonIf_(); |
| 93 | bcmos_errno get_nni_interface_status(bcmolt_interface id, bcmolt_interface_state *state); |
| 94 | Status install_gem_port(int32_t intf_id, int32_t onu_id, int32_t gemport_id); |
| 95 | Status remove_gem_port(int32_t intf_id, int32_t gemport_id); |
| 96 | Status update_acl_interface(int32_t intf_id, bcmolt_interface_type intf_type, uint32_t access_control_id, |
| 97 | bcmolt_members_update_command acl_cmd); |
| 98 | Status install_acl(const acl_classifier_key acl_key); |
| 99 | Status remove_acl(int acl_id); |
| 100 | void formulate_acl_classifier_key(acl_classifier_key *key, const ::openolt::Classifier& classifier); |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 101 | Status handle_acl_rule_install(int32_t onu_id, uint64_t flow_id, int32_t gemport_id, |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 102 | const std::string flow_type, int32_t access_intf_id, |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 103 | int32_t network_intf_id, |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 104 | const ::openolt::Classifier& classifier); |
| 105 | void clear_gem_port(int gemport_id, int access_intf_id); |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 106 | Status handle_acl_rule_cleanup(int16_t acl_id, int32_t intf_id, const std::string flow_type); |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 107 | Status check_bal_ready(); |
| 108 | Status check_connection(); |
Thiyagarajan Subramani | 03bc66f | 2020-04-01 15:58:53 +0530 | [diff] [blame] | 109 | std::string get_ip_address(const char* nw_intf); |
Jason Huang | 1d9cfce | 2020-05-20 22:58:47 +0800 | [diff] [blame] | 110 | bcmos_errno getOnuMaxLogicalDistance(uint32_t intf_id, uint32_t *mld); |
Humera Kouser | 6143c9e | 2020-06-17 22:37:31 +0530 | [diff] [blame] | 111 | char* get_intf_mac(const char* intf_name, char* mac_address, unsigned int max_size_of_mac_address); |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 112 | void update_voltha_flow_to_cache(uint64_t voltha_flow_id, device_flow dev_flow); |
| 113 | void remove_voltha_flow_from_cache(uint64_t voltha_flow_id); |
| 114 | bool is_voltha_flow_installed(uint64_t voltha_flow_id ); |
| 115 | const device_flow* get_device_flow(uint64_t voltha_flow_id); |
| 116 | const device_flow_params* get_device_flow_params(uint64_t voltha_flow_id); |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 117 | trap_to_host_packet_type get_trap_to_host_packet_type(const ::openolt::Classifier& classifier); |
| 118 | bool is_packet_allowed(bcmolt_access_control_receive_eth_packet_data *data, int32_t gemport_id); |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 119 | #endif // OPENOLT_CORE_UTILS_H_ |