| /* |
| <:copyright-BRCM:2016:DUAL/GPL:standard |
| |
| Broadcom Proprietary and Confidential.(c) 2016 Broadcom |
| All Rights Reserved |
| |
| Unless you and Broadcom execute a separate written software license |
| agreement governing use of this software, this software is licensed |
| to you under the terms of the GNU General Public License version 2 |
| (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, |
| with the following added to such license: |
| |
| As a special exception, the copyright holders of this software give |
| you permission to link this software with independent modules, and |
| to copy and distribute the resulting executable under terms of your |
| choice, provided that you also meet, for each linked independent |
| module, the terms and conditions of the license of that module. |
| An independent module is a module which is not derived from this |
| software. The special exception does not apply to any modifications |
| of the software. |
| |
| Not withstanding the above, under no circumstances may you combine |
| this software in any way with any other Broadcom software provided |
| under a license other than the GPL, without Broadcom's express prior |
| written consent. |
| |
| :> |
| */ |
| |
| #include <bcmolt_msg.h> |
| #include <bcmolt_api.h> |
| #include <bcmcli.h> |
| #include <bcm_api_cli.h> |
| #include <bcm_api_cli_helpers.h> |
| #include <bcm_dev_log.h> |
| #include "bcmolt_user_appl_ex_cli.h" |
| |
| #ifdef ENABLE_LOG |
| static dev_log_id user_appl_ex_log_id; |
| |
| static void user_appl_general_indication_cb(bcmolt_devid olt, bcmolt_msg *msg) |
| { |
| bcm_dev_log_log(user_appl_ex_log_id, DEV_LOG_LEVEL_DEBUG, BCM_LOG_FLAG_NO_HEADER, |
| "[-- Dev %u: Indication Received --]\n", olt); |
| switch (msg->obj_type) |
| { |
| case BCMOLT_OBJ_ID_DEBUG: |
| break; |
| case BCMOLT_OBJ_ID_GPON_NI: |
| switch (msg->subgroup) |
| { |
| case BCMOLT_GPON_NI_AUTO_ID_LOS: |
| break; |
| case BCMOLT_GPON_NI_AUTO_ID_STATE_CHANGE_COMPLETED: |
| { |
| bcmolt_gpon_ni_state_change_completed *ind = (bcmolt_gpon_ni_state_change_completed*)msg; |
| bcm_dev_log_log(user_appl_ex_log_id, DEV_LOG_LEVEL_DEBUG, BCM_LOG_FLAG_NO_HEADER, |
| "Dev %u: pon ni state changed new_state %d, prev state %d, result %d \n", |
| olt, ind->data.new_state, ind->data.previous_state, ind->data.result); |
| break; |
| } |
| |
| default: |
| break; |
| /* ... */ |
| } |
| break; |
| case BCMOLT_OBJ_ID_GPON_ONU: |
| break; |
| default: |
| break; |
| /* ... */ |
| } |
| bcmolt_msg_free(msg); |
| } |
| |
| static void user_appl_pon_ni_indication_cb(bcmolt_devid olt, bcmolt_msg *msg) |
| { |
| bcm_dev_log_log(user_appl_ex_log_id, DEV_LOG_LEVEL_DEBUG, BCM_LOG_FLAG_NO_HEADER, |
| "[-- Dev %u: Pon NI Indication Received --]\n", olt); |
| switch (msg->obj_type) |
| { |
| case BCMOLT_OBJ_ID_GPON_NI: |
| switch (msg->subgroup) |
| { |
| case BCMOLT_GPON_NI_AUTO_ID_LOS: |
| break; |
| case BCMOLT_GPON_NI_AUTO_ID_STATE_CHANGE_COMPLETED: |
| { |
| bcmolt_gpon_ni_state_change_completed *ind = (bcmolt_gpon_ni_state_change_completed*)msg; |
| bcm_dev_log_log(user_appl_ex_log_id, DEV_LOG_LEVEL_DEBUG, BCM_LOG_FLAG_NO_HEADER, |
| "Dev %u: pon ni state changed new_state %d, prev state %d, result %d \n", |
| olt, ind->data.new_state, ind->data.previous_state, ind->data.result); |
| break; |
| } |
| default: |
| break; |
| } |
| break; |
| default: |
| bcm_dev_log_log(user_appl_ex_log_id, DEV_LOG_LEVEL_DEBUG, BCM_LOG_FLAG_NO_HEADER, |
| "[-- Dev %u: some other indication --]\n", olt); |
| break; |
| /* ... */ |
| } |
| bcmolt_msg_free(msg); |
| } |
| |
| static void user_appl_device_logger_indication_cb(bcmolt_devid olt, bcmolt_msg *msg) |
| { |
| if (msg->subgroup == BCMOLT_DEBUG_AUTO_ID_CLI_OUTPUT) |
| { |
| bcmolt_debug_cli_output *ind = (bcmolt_debug_cli_output *)msg; |
| bcm_dev_log_log(user_appl_ex_log_id, DEV_LOG_LEVEL_DEBUG, BCM_LOG_FLAG_NO_HEADER, |
| "Dev %u: [device logger] %s\n", olt, ind->data.data.val); |
| } |
| } |
| |
| static bcmos_errno user_appl_indication_handler(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_rx_cfg rx_cfg; |
| bcmos_errno rc; |
| |
| rx_cfg.obj_type = BCMOLT_OBJ_ID_DEBUG; |
| rx_cfg.rx_cb =user_appl_device_logger_indication_cb; |
| rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| rc = bcmolt_auto_rx_cb_set(current_device, &rx_cfg); |
| if (rc != BCM_ERR_OK) |
| { |
| return rc; |
| } |
| |
| rx_cfg.obj_type = BCMOLT_OBJ_ID_GPON_NI; |
| rx_cfg.rx_cb = user_appl_pon_ni_indication_cb; |
| rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| rc = bcmolt_auto_rx_cb_set(current_device, &rx_cfg); |
| if (rc != BCM_ERR_OK) |
| { |
| return rc; |
| } |
| |
| rx_cfg.obj_type = BCMOLT_OBJECT_ANY; |
| rx_cfg.rx_cb = user_appl_general_indication_cb; |
| rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| return bcmolt_auto_rx_cb_set(current_device, &rx_cfg); |
| } |
| |
| static bcmos_errno user_appl_log_entry_set(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmos_errno err; |
| bcmolt_log_entry_cfg cfg; /**< declare main API struct */ |
| bcmolt_log_entry_key key = {.log_id= 0}; /**< declare key */ |
| |
| /* init the API struct */ |
| BCMOLT_CFG_INIT(&cfg, log_entry, key); |
| |
| BCMOLT_CFG_PROP_SET(&cfg, log_entry, log_level_print, BCMOLT_LOG_LEVEL_INFO); |
| BCMOLT_CFG_PROP_SET(&cfg, log_entry, log_level_save, BCMOLT_LOG_LEVEL_DEBUG); |
| /* call API */ |
| err = bcmolt_cfg_set(0, &cfg.hdr); |
| return err; |
| } |
| |
| static bcmos_errno user_appl_gpon_ni_disable_indication (bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmos_errno err; |
| bcmolt_gpon_ni_auto_cfg cfg; /**< declare main API struct */ |
| bcmolt_gpon_ni_key key = {.pon_ni= 0}; /**< declare key */ |
| |
| /* init the API struct */ |
| BCMOLT_AUTO_CFG_INIT(&cfg, gpon_ni, key); |
| |
| BCMOLT_AUTO_CFG_PROP_SET(&cfg, gpon_ni, serial_number_acquisition_cycle_start, BCMOS_FALSE); |
| BCMOLT_AUTO_CFG_PROP_SET(&cfg, gpon_ni, stat_alarm_cleared, BCMOS_FALSE); |
| /* call API */ |
| err = bcmolt_auto_cfg_set(0, &cfg.hdr); |
| return err; |
| } |
| |
| static bcmos_errno user_appl_redirect_device_logger (bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_debug_cfg cfg; |
| bcmolt_debug_key key = {}; |
| |
| BCMOLT_CFG_INIT(&cfg, debug, key); |
| BCMOLT_CFG_PROP_SET(&cfg, debug, console_redirection, BCMOLT_CONSOLE_REDIRECTION_CLONE); |
| bcmolt_cfg_set(0, &cfg.hdr); |
| |
| return BCM_ERR_OK; |
| } |
| |
| static bcmos_errno user_appl_gpon_device_init(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_device_cfg cfg; |
| bcmos_errno err; |
| bcmolt_device_key key = {.reserved = 0}; |
| bcmolt_device_nni_speed nni_speed = {}; /**< Device network interface speed configuration */ |
| bcmolt_device_connect oper; |
| |
| nni_speed.first_half = BCMOLT_NNI_SPEED_GBPS_1; |
| nni_speed.second_half = BCMOLT_NNI_SPEED_GBPS_1; |
| |
| BCMOLT_CFG_INIT(&cfg, device, key); |
| BCMOLT_CFG_PROP_SET(&cfg, device, system_mode, BCMOLT_SYSTEM_MODE_GPON__16_X); |
| BCMOLT_CFG_PROP_SET(&cfg, device, keepalive_interval, 5); |
| BCMOLT_CFG_PROP_SET(&cfg, device, keepalive_tolerance, 5); |
| BCMOLT_CFG_PROP_SET(&cfg, device, nni_speed, nni_speed); |
| err = bcmolt_cfg_set(0, &cfg.hdr); |
| if (err != BCM_ERR_OK) |
| { |
| return err; |
| } |
| |
| BCMOLT_OPER_INIT(&oper, device, connect, key); |
| err = bcmolt_oper_submit(0, &oper.hdr); |
| return err; |
| } |
| |
| static bcmos_errno user_appl_gpon_set_trx(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_trx_cfg cfg; |
| bcmolt_gpon_trx_key key = {.pon_ni = 0}; |
| |
| BCMOLT_CFG_INIT(&cfg, gpon_trx, key); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_trx, transceiver_type, BCMOLT_TRX_TYPE_SOURCE_PHOTONICS); |
| return bcmolt_cfg_set(0, &cfg.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_set_interworking_mode(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_iwf_cfg cfg; |
| bcmolt_gpon_iwf_key key = {.pon_ni = 0}; |
| |
| BCMOLT_CFG_INIT(&cfg, gpon_iwf, key); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf, iwf_mode, BCMOLT_IWF_MODE_PER_FLOW_MODE); |
| return bcmolt_cfg_set(0, &cfg.hdr); |
| |
| } |
| |
| static bcmos_errno user_appl_gpon_set_mac_table_config(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_iwf_cfg cfg_iwf; |
| bcmolt_gpon_iwf_key key_iwf = {.pon_ni = 0}; |
| bcmolt_mac_table_configuration mac_table_configuration; |
| mac_table_configuration.aging_time = 10000; |
| mac_table_configuration.automatic_mac_aging = BCMOLT_CONTROL_STATE_DISABLE; |
| mac_table_configuration.automatic_mac_learning = BCMOLT_CONTROL_STATE_DISABLE; |
| mac_table_configuration.automatic_mac_move = BCMOLT_CONTROL_STATE_DISABLE; |
| mac_table_configuration.automatic_static_mode = BCMOLT_CONTROL_STATE_DISABLE; |
| mac_table_configuration.default_flow_id = 600; |
| mac_table_configuration.learning_mode = BCMOLT_MAC_TABLE_LEARNING_MODE_NORMAL; |
| mac_table_configuration.miss_fallback = BCMOLT_MAC_TABLE_MISS_FALLBACK_DEFAULT_FLOW; |
| |
| BCMOLT_CFG_INIT(&cfg_iwf, gpon_iwf, key_iwf); |
| BCMOLT_CFG_PROP_SET(&cfg_iwf, gpon_iwf, mac_table_configuration, mac_table_configuration); |
| /* must set the IWF to per fow for mac table mapping to work */ |
| BCMOLT_CFG_PROP_SET(&cfg_iwf, gpon_iwf, iwf_mode, BCMOLT_IWF_MODE_PER_FLOW_MODE); |
| return bcmolt_cfg_set(0, &cfg_iwf.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_activate_pon(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_ni_set_pon_state oper_ni; |
| bcmolt_gpon_ni_key key_ni = {.pon_ni = 0}; |
| |
| BCMOLT_OPER_INIT(&oper_ni, gpon_ni, set_pon_state, key_ni); |
| BCMOLT_OPER_PROP_SET(&oper_ni, gpon_ni, set_pon_state, pon_state, BCMOLT_PON_OPERATION_ACTIVE_WORKING); |
| return bcmolt_oper_submit(0, &oper_ni.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_start_sn_acquisition(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_ni_cfg cfg_ni; |
| bcmolt_gpon_ni_key key_ni = {.pon_ni = 0}; |
| bcmolt_gpon_sn_acquisition sn_acquisition; |
| |
| sn_acquisition.control = BCMOLT_CONTROL_STATE_ENABLE; |
| sn_acquisition.interval = 77000; |
| sn_acquisition.onu_post_discovery_mode = BCMOLT_ONU_POST_DISCOVERY_MODE_DISABLE; |
| |
| BCMOLT_CFG_INIT(&cfg_ni, gpon_ni, key_ni); |
| BCMOLT_CFG_PROP_SET(&cfg_ni, gpon_ni, sn_acquisition, sn_acquisition); |
| return bcmolt_cfg_set(0, &cfg_ni.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_ni_get_stats(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_ni_stat stat; /**< declare main API struct */ |
| bcmolt_gpon_ni_key key = {}; /**< declare key */ |
| |
| /* init the API struct */ |
| BCMOLT_STAT_INIT(&stat, gpon_ni, key); |
| BCMOLT_STAT_PROP_GET(&stat, gpon_ni, all_properties); |
| return bcmolt_stat_get(0, &stat.hdr, BCMOS_TRUE); |
| } |
| |
| static bcmos_errno user_appl_gpon_onu_config(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_onu_cfg cfg; |
| bcmolt_gpon_onu_key key = {.pon_ni = 0, .onu_id = 2}; |
| bcmolt_serial_number serial_number = {.vendor_id = {0x00,0x00,0x00, 0x00}, .vendor_specific = {0x00,0x00,0x00, 0x02}}; |
| bcmolt_arr_u8_10 password = {.arr = {0x00,0x00,0x00, 0x00, 0x00,0x00,0x00, 0x00, 0x00, 0x00}}; |
| |
| BCMOLT_CFG_INIT(&cfg, gpon_onu, key); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_onu, serial_number, serial_number); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_onu, password, password); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_onu, auto_password_learning, BCMOS_TRUE); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_onu, us_fec, BCMOS_FALSE); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_onu, omci_port_id, 2); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_onu, ds_ber_reporting_interval, 5000); |
| return bcmolt_cfg_set(0, &cfg.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_activate_onu(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_onu_set_onu_state oper; |
| bcmolt_gpon_onu_key key = {.pon_ni = 0, .onu_id = 2}; |
| |
| BCMOLT_OPER_INIT(&oper, gpon_onu, set_onu_state, key); |
| BCMOLT_OPER_PROP_SET(&oper, gpon_onu, set_onu_state, onu_state, BCMOLT_ONU_OPERATION_ACTIVE); |
| return bcmolt_oper_submit(0, &oper.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_alloc_id_config(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_alloc_cfg cfg; |
| bcmolt_gpon_alloc_key key = {.pon_ni = 0, .alloc_id = 320}; |
| |
| bcmolt_pon_alloc_sla sla; /**< Alloc ID SLA. */ |
| |
| sla.additional_bw_eligibility = BCMOLT_ADDITIONAL_BW_ELIGIBILITY_NON_ASSURED; |
| sla.cbr_rt_bw = 0; |
| sla.cbr_nrt_bw = 140000000; |
| sla.guaranteed_bw = 140000000; |
| sla.maximum_bw = 140000000; |
| sla.alloc_type = BCMOLT_ALLOC_TYPE_NSR; |
| sla.cbr_rt_compensation = BCMOS_FALSE; |
| sla.cbr_nrt_ap_index = 0; |
| sla.cbr_rt_ap_index = 0; |
| sla.weight = 0; |
| sla.priority = 0; |
| |
| BCMOLT_CFG_INIT(&cfg, gpon_alloc, key); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_alloc, onu_id, 2); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_alloc, sla, sla); |
| return bcmolt_cfg_set(0, &cfg.hdr); |
| } |
| |
| /* Configure a GEM - for DS or bidirectional traffic */ |
| static bcmos_errno user_appl_gpon_gem_port_config(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_gem_port_cfg cfg; |
| bcmolt_gpon_gem_port_key key = {.pon_ni = 0, .gem_port_id = 320}; |
| |
| bcmolt_gem_port_configuration configuration = {.direction = BCMOLT_GEM_PORT_DIRECTION_BIDIRECTIONAL, .type = BCMOLT_GEM_PORT_TYPE_UNICAST}; |
| BCMOLT_CFG_INIT(&cfg, gpon_gem_port, key); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_gem_port, onu_id, 2); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_gem_port, downstream_encryption_mode, BCMOLT_CONTROL_STATE_DISABLE); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_gem_port, configuration, configuration); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_gem_port, upstream_destination_queue, BCMOLT_US_GEM_PORT_DESTINATION_DATA); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_gem_port, control, BCMOLT_CONTROL_STATE_ENABLE); |
| return bcmolt_cfg_set(0, &cfg.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_ds_gem_port_modify(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| /* this can only be called in PER flow mode */ |
| /* set DS port mapping initial GEM 300, final GEM 320 */ |
| bcmolt_gpon_iwf_ds_egress_flow_key key = {.pon_ni = 0, .flow_id = 300}; |
| bcmolt_gpon_iwf_ds_egress_flow_cfg cfg; |
| |
| BCMOLT_CFG_INIT(&cfg, gpon_iwf_ds_egress_flow, key); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf_ds_egress_flow, gem_port, 320); |
| return bcmolt_cfg_set(0, &cfg.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_set_ds_per_vlan_mapping_method(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| /* When working with per flow mode the user must add an entry for each VID (flow) this way */ |
| bcmolt_gpon_iwf_ds_ingress_flow_key key = {.pon_ni = 0, .vlan_id = 300}; |
| bcmolt_gpon_iwf_ds_ingress_flow_cfg cfg; |
| |
| BCMOLT_CFG_INIT(&cfg, gpon_iwf_ds_ingress_flow, key); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf_ds_ingress_flow, mapping_method, BCMOLT_VLAN_TO_FLOW_MAPPING_METHOD_VID); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf_ds_ingress_flow, mapping_tag, BCMOLT_MAPPING_TAG_METHOD_OUTER_VID); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf_ds_ingress_flow, vlan_action, BCMOLT_DS_VLAN_ACTION_TRANSPARENT); |
| return bcmolt_cfg_set(0, &cfg.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_send_omci_packet(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_onu_cpu_packets proxy; /**< declare main API struct */ |
| bcmolt_gpon_onu_key key = {.pon_ni = 0, .onu_id = 2}; /**< declare key */ |
| bcmolt_u8_list_u32_max_2048 buffer; |
| uint8_t cpu_buf[100]; |
| buffer.len = 48; |
| buffer.val = cpu_buf; |
| |
| /* init the API struct */ |
| BCMOLT_PROXY_INIT(&proxy, gpon_onu, cpu_packets, key); |
| BCMOLT_PROXY_PROP_SET(&proxy, gpon_onu, cpu_packets, packet_type, BCMOLT_PACKET_TYPE_OMCI); |
| BCMOLT_PROXY_PROP_SET(&proxy, gpon_onu, cpu_packets, calc_crc, BCMOS_TRUE); |
| BCMOLT_PROXY_PROP_SET(&proxy, gpon_onu, cpu_packets, number_of_packets, 1); |
| BCMOLT_PROXY_PROP_SET(&proxy, gpon_onu, cpu_packets, packet_size, 48); |
| BCMOLT_PROXY_PROP_SET(&proxy, gpon_onu, cpu_packets, buffer, buffer); |
| |
| /* call API */ |
| return bcmolt_proxy_send(0, &proxy.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_send_cpu_packets_over_gem_ports(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_ni_cpu_packets proxy; /**< declare main API struct */ |
| bcmolt_gpon_ni_key key = {.pon_ni = 0}; /**< declare key */ |
| bcmolt_gpon_gem_id gem_port_id_array[10]; |
| bcmolt_gpon_gem_id_list_u8_max_16 gem_port_list; |
| bcmolt_u8_list_u32_max_2048 buffer; |
| uint8_t cpu_buf[100]; |
| buffer.len = 96; |
| buffer.val = cpu_buf; |
| |
| gem_port_list.len = 10; |
| gem_port_list.val = gem_port_id_array; |
| |
| /* init the API struct */ |
| BCMOLT_PROXY_INIT(&proxy, gpon_ni, cpu_packets, key); |
| BCMOLT_PROXY_PROP_SET(&proxy, gpon_ni, cpu_packets, packet_type, BCMOLT_PACKET_TYPE_CPU); |
| BCMOLT_PROXY_PROP_SET(&proxy, gpon_ni, cpu_packets, calc_crc, BCMOS_TRUE); |
| BCMOLT_PROXY_PROP_SET(&proxy, gpon_ni, cpu_packets, gem_port_list, gem_port_list); |
| BCMOLT_PROXY_PROP_SET(&proxy, gpon_ni, cpu_packets, buffer, buffer); |
| |
| /* call API */ |
| return bcmolt_proxy_send(0, &proxy.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_add_mac_entry(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| /* this can only be called in per flow mode. */ |
| /* In order to pass traffic you must also add an entry to IWF ingress port as described in _gpon_set_per_vlan_mapping_method */ |
| bcmolt_gpon_iwf_mac_table_cfg cfg; |
| bcmolt_gpon_iwf_mac_table_key key = {.pon_ni = 0, .mac_address.u8 = {0x00,0x00,0x00, 0x00, 0x00,0x00}, .vlan = 320}; |
| |
| BCMOLT_CFG_INIT(&cfg, gpon_iwf_mac_table, key); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf_mac_table, flow_id, 320); |
| return bcmolt_cfg_set(0, &cfg.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_dump_mac_table(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| const uint16_t max_msgs_per_call = 10; |
| const bcmolt_devid device = 0; |
| const uint16_t pon = 0; |
| |
| bcmos_errno err; |
| bcmolt_msg_set *msg_set; |
| bcmolt_gpon_iwf_mac_table_cfg filter; |
| uint16_t i; |
| uint16_t count = 0; |
| |
| /* a key of all Fs means "start from the beginning" */ |
| bcmolt_gpon_iwf_mac_table_key wildcard_key = |
| { .pon_ni = pon, .mac_address.u8 = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, .vlan = 0xFFFF }; |
| |
| /* allocate space for the return values */ |
| err = bcmolt_msg_set_alloc(BCMOLT_OBJ_ID_GPON_IWF_MAC_TABLE, BCMOLT_MGT_GROUP_CFG, max_msgs_per_call, &msg_set); |
| if (err != BCM_ERR_OK) |
| { |
| return err; |
| } |
| |
| /* initialize the filter structure and ask to read the flow ID / static flag */ |
| BCMOLT_CFG_INIT(&filter, gpon_iwf_mac_table, wildcard_key); |
| BCMOLT_MSGSET_CFG_PROP_GET(msg_set, gpon_iwf_mac_table, flow_id); |
| BCMOLT_MSGSET_CFG_PROP_GET(msg_set, gpon_iwf_mac_table, stat); |
| |
| /* filter to only include non-static entries (you could also filter on flow ID, or omit this to include all) */ |
| BCMOLT_CFG_PROP_SET(&filter, gpon_iwf_mac_table, stat, BCMOS_FALSE); |
| |
| do |
| { |
| /* call get multiple objects API function */ |
| err = bcmolt_cfg_get_multi(device, &filter.hdr, BCMOLT_FILTER_FLAGS_NONE, msg_set); |
| if (err != BCM_ERR_OK) |
| { |
| bcmcli_session_print(session, "bcmolt_cfg_get_multi returned error: %s (%d)\n", bcmos_strerror(err), err); |
| break; |
| } |
| |
| /* print each key/config structure that was received */ |
| for (i = 0; i < msg_set->num_instances; i++) |
| { |
| bcmolt_gpon_iwf_mac_table_cfg *cfg = (bcmolt_gpon_iwf_mac_table_cfg *)msg_set->msg[i]; |
| bcmcli_session_print( |
| session, |
| "entry[%d] MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", |
| count, |
| cfg->key.mac_address.u8[0], |
| cfg->key.mac_address.u8[1], |
| cfg->key.mac_address.u8[2], |
| cfg->key.mac_address.u8[3], |
| cfg->key.mac_address.u8[4], |
| cfg->key.mac_address.u8[5]); |
| bcmcli_session_print(session, "entry[%d] VID: %d\n", count, cfg->key.vlan); |
| bcmcli_session_print(session, "entry[%d] flow ID: %d\n", count, cfg->data.flow_id); |
| bcmcli_session_print(session, "entry[%d] static: %s\n", count, cfg->data.stat ? "yes" : "no"); |
| count++; |
| } |
| |
| /* update the key for next call */ |
| filter.key = *((bcmolt_gpon_iwf_mac_table_key *)msg_set->next_key); |
| |
| /* keep calling the function until we have retrieved all entries */ |
| } while (msg_set->more); |
| |
| bcmolt_msg_set_free(msg_set); |
| return BCM_ERR_OK; |
| } |
| |
| static bcmos_errno user_appl_gpon_set_us_flow_configuration(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_gpon_iwf_us_flow_cfg cfg; |
| bcmolt_gpon_iwf_us_flow_key key = {.pon_ni = 0, .gem_port_id = 320}; |
| bcmolt_vlan_tag vlan_tag; |
| |
| /* vlad tag parameters for the add vlan */ |
| vlan_tag.pbit = 9; |
| vlan_tag.vlan_id = 300; |
| |
| BCMOLT_CFG_INIT(&cfg, gpon_iwf_us_flow, key); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf_us_flow, flow_id, 320); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf_us_flow, mac_learning, BCMOS_FALSE); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf_us_flow, vlan_action, BCMOLT_US_VLAN_ACTION_ADD); |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf_us_flow, vlan_tag, vlan_tag); |
| /* what is the tpid index */ |
| BCMOLT_CFG_PROP_SET(&cfg, gpon_iwf_us_flow, tpid_index, 0); |
| return bcmolt_cfg_set(0, &cfg.hdr); |
| } |
| |
| static bcmos_errno user_appl_gpon_configure_and_activate_pon(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| /* TRX and PON Link configuration structures + PON control operation */ |
| bcmos_errno rc; |
| bcmolt_gpon_ni_key key_ni = {.pon_ni = 0}; |
| bcmolt_gpon_ni_cfg cfg_ni; |
| bcmolt_gpon_ni_set_pon_state oper_ni; |
| |
| bcmolt_gpon_sn_acquisition sn_acquisition = {.control = BCMOLT_CONTROL_STATE_ENABLE, .interval = 10000, .onu_post_discovery_mode = BCMOLT_ONU_POST_DISCOVERY_MODE_NONE}; |
| bcmolt_pon_drift_control drift_control = {.drift_interval = 1000, .drift_limit = 4, .transmission_control_limit = 8}; |
| bcmolt_ber_monitor_params ber_monitor = {.us_ber_interval = 1000, .sd_threshold = 5, .sf_threshold = 3}; |
| bcmolt_gpon_trx_key key_trx = {.pon_ni = 0}; |
| bcmolt_gpon_trx_cfg cfg_trx; |
| bcmolt_trx_delimiter delimiter = {}; |
| |
| /* overide only the relevant parameters */ |
| delimiter.pattern[0] = 0x0B; |
| delimiter.pattern[1] = 0x59; |
| delimiter.pattern[2] = 0x83; |
| delimiter.size = 3; |
| delimiter.window_size = 124; |
| |
| BCMOLT_CFG_INIT(&cfg_trx, gpon_trx, key_trx); |
| BCMOLT_CFG_PROP_SET(&cfg_trx, gpon_trx, transceiver_type, BCMOLT_TRX_TYPE_SOURCE_PHOTONICS); |
| BCMOLT_CFG_PROP_SET(&cfg_trx, gpon_trx, delimiter, delimiter); |
| rc = bcmolt_cfg_set(0, &cfg_trx.hdr); |
| if (rc != BCM_ERR_OK) |
| { |
| bcm_dev_log_log(user_appl_ex_log_id, DEV_LOG_LEVEL_DEBUG, BCM_LOG_FLAG_NO_HEADER, |
| "Error in set trx %d", rc); |
| } |
| |
| /* Initialize and configure PON */ |
| BCMOLT_CFG_INIT(&cfg_ni, gpon_ni, key_ni); |
| BCMOLT_CFG_PROP_SET(&cfg_ni, gpon_ni, sn_acquisition, sn_acquisition); |
| BCMOLT_CFG_PROP_SET(&cfg_ni, gpon_ni, drift_control, drift_control); |
| BCMOLT_CFG_PROP_SET(&cfg_ni, gpon_ni, ber_monitor, ber_monitor); |
| BCMOLT_CFG_PROP_SET(&cfg_ni, gpon_ni, ds_ber_reporting_interval, 1000); |
| BCMOLT_CFG_PROP_SET(&cfg_ni, gpon_ni, preassigned_equalization_delay, 0); |
| rc = bcmolt_cfg_set(0, &cfg_ni.hdr); |
| if (rc != BCM_ERR_OK) |
| { |
| return rc; |
| } |
| |
| BCMOLT_OPER_INIT(&oper_ni, gpon_ni, set_pon_state, key_ni); |
| BCMOLT_OPER_PROP_SET(&oper_ni, gpon_ni, set_pon_state, pon_state, BCMOLT_PON_OPERATION_ACTIVE_WORKING); |
| return bcmolt_oper_submit(0, &oper_ni.hdr); |
| } |
| |
| static bcmos_errno gpon_add_activate_onu (bcmolt_devid dev, bcmolt_gpon_ni pon_ni, bcmolt_gpon_onu_id onu_id, bcmolt_serial_number serial_number) |
| { |
| bcmolt_gpon_onu_cfg onu_cfg; |
| bcmolt_gpon_onu_key onu_key = {.pon_ni = pon_ni, .onu_id = onu_id}; |
| bcmolt_gpon_onu_set_onu_state onu_oper; |
| bcmolt_arr_u8_10 password = {.arr = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}}; |
| bcmolt_gpon_gem_port_cfg gem_cfg; |
| bcmolt_gpon_gem_port_key gem_key = {.pon_ni = pon_ni, .gem_port_id = onu_id}; |
| bcmos_errno rc; |
| |
| BCMOLT_CFG_INIT(&onu_cfg, gpon_onu, onu_key); |
| BCMOLT_CFG_PROP_SET(&onu_cfg, gpon_onu, serial_number, serial_number); |
| BCMOLT_CFG_PROP_SET(&onu_cfg, gpon_onu, password, password); |
| BCMOLT_CFG_PROP_SET(&onu_cfg, gpon_onu, auto_password_learning, BCMOS_TRUE); |
| BCMOLT_CFG_PROP_SET(&onu_cfg, gpon_onu, us_fec, BCMOS_TRUE); |
| BCMOLT_CFG_PROP_SET(&onu_cfg, gpon_onu, omci_port_id, 2); |
| BCMOLT_CFG_PROP_SET(&onu_cfg, gpon_onu, ds_ber_reporting_interval, 5000); |
| rc = bcmolt_cfg_set(dev, &onu_cfg.hdr); |
| if (rc) |
| { |
| return rc; |
| } |
| |
| BCMOLT_CFG_INIT(&gem_cfg, gpon_gem_port, gem_key); |
| BCMOLT_CFG_PROP_SET(&gem_cfg, gpon_gem_port, downstream_encryption_mode, BCMOLT_CONTROL_STATE_ENABLE); |
| rc = bcmolt_cfg_set(dev, &gem_cfg.hdr); |
| if (rc) |
| { |
| return rc; |
| } |
| |
| BCMOLT_OPER_INIT(&onu_oper, gpon_onu, set_onu_state, onu_key); |
| BCMOLT_OPER_PROP_SET(&onu_oper, gpon_onu, set_onu_state, onu_state, BCMOLT_ONU_OPERATION_ACTIVE); |
| rc = bcmolt_oper_submit(dev, &onu_oper.hdr); |
| return rc; |
| } |
| |
| static bcmos_errno user_appl_gpon_config_and_activate_onu (bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t nparms) |
| { |
| bcmolt_serial_number serial_number = {.vendor_id = {0x00,0x00,0x00, 0x00}, .vendor_specific = {0x00,0x00,0x00, 0x02}}; |
| return gpon_add_activate_onu(0, 0, 2, serial_number); |
| } |
| |
| static bcmos_errno user_appl_epon_get_all_link_alarms(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t nparms) |
| { |
| const uint16_t max_msgs_per_call = 10; |
| const bcmolt_devid device_id = 0; |
| const uint16_t pon = 0; |
| /* configure filter to select only links which do NOT have all alarms off */ |
| const bcmolt_filter_flags flags = BCMOLT_FILTER_FLAGS_INVERT_SELECTION; |
| const bcmolt_epon_link_alarm_state alarm_state_filter = |
| { |
| .invalid_mpcp_report_received = BCMOLT_STATUS_OFF, |
| .key_exchange_failure = BCMOLT_STATUS_OFF, |
| .mpcp_report_timeout = BCMOLT_STATUS_OFF, |
| .oam_keepalive_timeout = BCMOLT_STATUS_OFF, |
| }; |
| |
| bcmos_errno err = BCM_ERR_OK; |
| bcmolt_msg_set *msg_set; |
| bcmolt_epon_link_cfg filter; |
| bcmolt_epon_link_key wildcard_key; |
| uint16_t i; |
| |
| /* retrieve the EPON NI MAC address */ |
| bcmolt_epon_ni_cfg pon_cfg; |
| bcmolt_epon_ni_key pon_key = { .epon_ni = pon }; |
| |
| BCMOLT_CFG_INIT(&pon_cfg, epon_ni, pon_key); |
| BCMOLT_CFG_PROP_GET(&pon_cfg, epon_ni, mac_address); |
| err = bcmolt_cfg_get(device_id, &pon_cfg.hdr); |
| if (BCM_ERR_OK != err) |
| { |
| bcmcli_session_print(session, "Failed to retrieve EPON NI MAC address!\n"); |
| return err; |
| } |
| |
| /* a key with the EPON NI MAC address means "start from the beginning" */ |
| wildcard_key.epon_ni = pon; |
| wildcard_key.mac_address = pon_cfg.data.mac_address; |
| |
| /* allocate space for the return values */ |
| err = bcmolt_msg_set_alloc(BCMOLT_OBJ_ID_EPON_LINK, BCMOLT_MGT_GROUP_CFG, max_msgs_per_call, &msg_set); |
| if (BCM_ERR_OK != err) |
| { |
| bcmcli_session_print(session, "Failed to allocate space for return!\n"); |
| return err; |
| } |
| |
| /* initialize the filter structure and ask to read the alarm state */ |
| BCMOLT_CFG_INIT(&filter, epon_link, wildcard_key); |
| BCMOLT_MSGSET_CFG_PROP_GET(msg_set, epon_link, alarm_state); |
| |
| /* apply filter */ |
| BCMOLT_CFG_PROP_SET(&filter, epon_link, alarm_state, alarm_state_filter); |
| |
| do |
| { |
| /* call get multiple objects API function */ |
| err = bcmolt_cfg_get_multi(device_id, &filter.hdr, flags, msg_set); |
| if (BCM_ERR_OK != err) |
| { |
| bcmcli_session_print(session, "bcmolt_cfg_get_multi returned error: %s (%d)\n", bcmos_strerror(err), err); |
| break; |
| } |
| |
| /* print each key/config that was received */ |
| for (i = 0; i < msg_set->num_instances; i++) |
| { |
| bcmolt_epon_link_cfg *cfg = (bcmolt_epon_link_cfg*)msg_set->msg[i]; |
| bcmcli_session_print(session, "Link: NI %u, MAC %02x%02x%02x%02x%02x%02x\n", |
| cfg->key.epon_ni, |
| cfg->key.mac_address.u8[0], |
| cfg->key.mac_address.u8[1], |
| cfg->key.mac_address.u8[2], |
| cfg->key.mac_address.u8[3], |
| cfg->key.mac_address.u8[4], |
| cfg->key.mac_address.u8[5]); |
| bcmcli_session_print(session, "\tInvalid MPCP Report Received: %u\n", |
| cfg->data.alarm_state.invalid_mpcp_report_received); |
| bcmcli_session_print(session, "\tKey Exchange failure: %u\n", |
| cfg->data.alarm_state.key_exchange_failure); |
| bcmcli_session_print(session, "\tMPCP Report Timeout: %u\n", |
| cfg->data.alarm_state.mpcp_report_timeout); |
| bcmcli_session_print(session, "\tOAM Keepalive Timeout: %u\n", |
| cfg->data.alarm_state.oam_keepalive_timeout); |
| } |
| |
| /* update the key for next call */ |
| filter.key = *((bcmolt_epon_link_key*)msg_set->next_key); |
| |
| /* keep calling the function until we have retrieved all entries */ |
| } while (msg_set->more); |
| |
| bcmolt_msg_set_free(msg_set); |
| return err; |
| } |
| #endif |
| |
| bcmos_errno bcmolt_user_appl_ex_cli_init(void) |
| { |
| bcmcli_entry *parent = bcmcli_dir_find(NULL, "user"); |
| bcmcli_entry *dir; |
| |
| #ifdef ENABLE_LOG |
| user_appl_ex_log_id = bcm_dev_log_id_register("user_appl_ex", DEV_LOG_LEVEL_DEBUG, DEV_LOG_ID_TYPE_BOTH); |
| #endif |
| |
| dir = bcmcli_dir_add(parent, "example", "User application", BCMCLI_ACCESS_ADMIN, NULL); |
| BCMOS_CHECK_RETURN_ERROR(!dir, BCM_ERR_NOMEM); |
| #ifdef ENABLE_LOG |
| |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_device_init", "gpon device init", user_appl_gpon_device_init); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "indication_handler", "indication handler", user_appl_indication_handler); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "log_entry_set", "log enrty set", user_appl_log_entry_set); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "redirect_device_logger", "redirect device logger", user_appl_redirect_device_logger); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_ni_disable_indication", "gpon_ni_disable_indication", user_appl_gpon_ni_disable_indication); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_ni_get_stats", "gpon_ni_get_stats", user_appl_gpon_ni_get_stats); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_start_sn_acquisition", "gpon start sn acquisition", user_appl_gpon_start_sn_acquisition); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_set_mac_table_config", "gpon set mac table config", user_appl_gpon_set_mac_table_config); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_set_interworking_mode", "gpon set interworking mode", user_appl_gpon_set_interworking_mode); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_set_trx", "gpon set trx", user_appl_gpon_set_trx); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_activate_pon", "gpon activate pon", user_appl_gpon_activate_pon); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_onu_config", "gpon onu config", user_appl_gpon_onu_config); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_activate_onu", "gpon activate onu", user_appl_gpon_activate_onu); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_alloc_id_config", "gpon alloc config", user_appl_gpon_alloc_id_config); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_gem_port_config", "gpon gem port config", user_appl_gpon_gem_port_config); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_add_mac_entry", "gpon add mac entry", user_appl_gpon_add_mac_entry); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_dump_mac_table", "print entire GPON MAC table", user_appl_gpon_dump_mac_table); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_ds_gem_port_modify", " gpon ds gem port modify", user_appl_gpon_ds_gem_port_modify); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_set_per_vlan_mapping_method", "gpon set per vlan mapping method", user_appl_gpon_set_ds_per_vlan_mapping_method); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_set_us_flow_configuration", "gpon set us flow configuration", user_appl_gpon_set_us_flow_configuration); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_send_omci_packet", "appl gpon send omci packet", user_appl_gpon_send_omci_packet); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_send_cpu_packets_over_gem_ports", "gpon send cpu packets over gem ports", user_appl_gpon_send_cpu_packets_over_gem_ports); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_configure_and_activate_pon", "configure and activate pon", user_appl_gpon_configure_and_activate_pon); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "gpon_config_and_activate_onu", "config and activate onu", user_appl_gpon_config_and_activate_onu); |
| BCMCLI_MAKE_CMD_NOPARM(dir, "epon_get_all_link_alarms", "retrieve all link alarms", user_appl_epon_get_all_link_alarms); |
| #endif |
| return BCM_ERR_OK; |
| } |
| |