| /* |
| <: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 "bcmos_system.h" |
| #include "bcmolt_math.h" |
| #include "bcm_dev_log.h" |
| #include "bcmolt_api.h" |
| #include "bcmolt_model_types.h" |
| #include "bcmolt_user_appl_epon_oam.h" |
| #include "bcmolt_user_appl_epon_oam_cli.h" |
| #include "bcmolt_epon_oam_types.h" |
| |
| static bcmos_errno epon_oam_dpoe_get_critical_info_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| |
| return epon_oam_dpoe_get_critical_info(current_device, epon, &mac); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_set_oam_rate_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| uint8_t min = (uint8_t)bcmcli_find_named_parm(session, "min")->value.unumber; |
| uint8_t max = (uint8_t)bcmcli_find_named_parm(session, "max")->value.unumber; |
| |
| return epon_oam_dpoe_set_oam_rate(current_device, epon, &mac, min, max); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_set_report_thresholds_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| bcmcli_cmd_parm *queue_set_parms[MAX_QUEUE_SETS]; |
| |
| /* OAM stuff */ |
| bcmolt_epon_oam_queue_sets queue_sets; |
| uint8_t i, j, num_queue_sets = 0; |
| |
| /* process input */ |
| queue_set_parms[0] = bcmcli_find_named_parm(session, "queue_0"); |
| queue_set_parms[1] = bcmcli_find_named_parm(session, "queue_1"); |
| queue_set_parms[2] = bcmcli_find_named_parm(session, "queue_2"); |
| queue_set_parms[3] = bcmcli_find_named_parm(session, "queue_3"); |
| for (i = 0; i < MAX_QUEUE_SETS; i++) |
| { |
| if (NULL != queue_set_parms[i]) |
| { |
| num_queue_sets++; |
| if (queue_set_parms[i]->array_size != queue_set_parms[0]->array_size) |
| { |
| bcmcli_session_print(session, "All queue sets must have the same number of report thresholds!\n"); |
| return BCM_ERR_PARM; |
| } |
| for (j = 0; j < queue_set_parms[i]->array_size; j++) |
| { |
| if (queue_set_parms[i]->values[j].unumber > 65535) |
| { |
| bcmcli_session_print(session, "Queue Set %u, Threshold %u: %lu is not a valid report threshold!\n", |
| i, j, queue_set_parms[i]->values[j].unumber); |
| return BCM_ERR_PARM; |
| } |
| queue_sets[i][j] = (uint16_t)queue_set_parms[i]->values[j].unumber; |
| } |
| } |
| else |
| { |
| for (j = i + 1; j < MAX_QUEUE_SETS; j++) |
| { |
| if (NULL != queue_set_parms[j]) |
| { |
| bcmcli_session_print(session, "Included queue sets must be sequential from 0!\n"); |
| return BCM_ERR_PARM; |
| } |
| } |
| } |
| } |
| |
| return epon_oam_dpoe_set_report_thresholds(current_device, |
| epon, |
| &mac, |
| queue_set_parms[0]->array_size, |
| queue_sets, |
| num_queue_sets); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_clear_ingress_rules_network_pon_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| |
| return epon_oam_dpoe_clear_ingress_rules_network_pon(current_device, epon, &mac); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_clear_ingress_rules_user_port_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| |
| return epon_oam_dpoe_clear_ingress_rules_user_port(current_device, epon, &mac); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_clear_ingress_rules_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| |
| return epon_oam_dpoe_clear_ingress_rules(current_device, epon, &mac); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_set_basic_queue_config_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| uint8_t up_queue_size = (uint8_t)bcmcli_find_named_parm(session, "up_size")->value.unumber; |
| uint8_t dn_queue_size = (uint8_t)bcmcli_find_named_parm(session, "dn_size")->value.unumber; |
| |
| return epon_oam_dpoe_set_basic_queue_config(current_device, epon, &mac, up_queue_size, dn_queue_size); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_add_ingress_rules_network_pon_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| |
| return epon_oam_dpoe_add_ingress_rules_network_pon(current_device, epon, &mac, DPOE_RULE_VLAN_MODE_NONE, NULL); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_add_ingress_rules_user_port_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| |
| return epon_oam_dpoe_add_ingress_rules_user_port(current_device, epon, &mac, DPOE_RULE_VLAN_MODE_NONE, NULL); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_add_ingress_rules_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| |
| return epon_oam_dpoe_add_ingress_rules(current_device, epon, &mac); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_add_ingress_rules_with_vlan_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| uint32_t vlan = bcmcli_find_named_parm(session, "vlan")->value.unumber; |
| uint8_t vlan_tag[4]; |
| |
| vlan = BCMOS_ENDIAN_CPU_TO_BIG_U32(vlan); |
| vlan_tag[0] = (vlan >> 24) & 0xff; |
| vlan_tag[1] = (vlan >> 16) & 0xff; |
| vlan_tag[2] = (vlan >> 8) & 0xff; |
| vlan_tag[3] = (vlan >> 0) & 0xff; |
| |
| return epon_oam_dpoe_add_ingress_rules_with_vlan(current_device, epon, &mac, vlan_tag); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_enable_user_traffic_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| |
| return epon_oam_dpoe_enable_user_traffic(current_device, epon, &mac); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_start_upgrade_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| const char *fw_file = bcmcli_find_named_parm(session, "fw_file")->value.string; |
| /* This should be based on the negotiated PDU size! */ |
| uint16_t block_size = (uint16_t)bcmcli_find_named_parm(session, "block_size")->value.unumber; |
| uint8_t timeout = (uint8_t)bcmcli_find_named_parm(session, "timeout")->value.unumber; |
| |
| return epon_oam_dpoe_start_upgrade(current_device, epon, &mac, fw_file, block_size, timeout); |
| } |
| |
| static bcmos_errno epon_oam_dpoe_reset_onu_cli(bcmcli_session *session, |
| const bcmcli_cmd_parm parm[], |
| uint16_t n_parms) |
| { |
| bcmolt_epon_ni epon = (bcmolt_epon_ni)bcmcli_find_named_parm(session, "epon_ni")->value.unumber; |
| bcmos_mac_address mac = bcmcli_find_named_parm(session, "mac_address")->value.mac; |
| |
| return epon_oam_dpoe_reset_onu(current_device, epon, &mac); |
| } |
| |
| void bcmolt_user_appl_epon_oam_cli_init(bcmcli_entry *top_dir) |
| { |
| #ifdef ENABLE_CLI |
| static const char *dir_name = "epon_oam"; |
| |
| if (bcmcli_dir_find(top_dir, dir_name)) |
| { |
| return; |
| } |
| |
| bcmcli_entry *oam_dir = bcmcli_dir_add(top_dir, dir_name, "EPON OAM", BCMCLI_ACCESS_ADMIN, NULL); |
| BUG_ON(NULL == oam_dir); |
| |
| static bcmcli_parm_value queue_0[MAX_REPORT_THRESHOLDS]; |
| static bcmcli_parm_value queue_1[MAX_REPORT_THRESHOLDS]; |
| static bcmcli_parm_value queue_2[MAX_REPORT_THRESHOLDS]; |
| static bcmcli_parm_value queue_3[MAX_REPORT_THRESHOLDS]; |
| |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_get_critical_info", "DPoE get ONU ID and max links", |
| epon_oam_dpoe_get_critical_info_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0)); |
| |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_set_oam_rate", "DPoE set OAM rate", |
| epon_oam_dpoe_set_oam_rate_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0), |
| BCMCLI_MAKE_PARM("min", "Minimum OAM rate", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("max", "Maximum OAM rate", BCMCLI_PARM_UNUMBER, 0)); |
| |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_set_report_thresholds", "DPoE set report threhsolds", |
| epon_oam_dpoe_set_report_thresholds_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0), |
| BCMCLI_MAKE_PARM_ARRAY("queue_0", |
| "Report threhsold for queue set 0", |
| BCMCLI_PARM_UNUMBER, |
| BCMCLI_PARM_FLAG_NONE, |
| MAX_REPORT_THRESHOLDS, |
| queue_0), |
| BCMCLI_MAKE_PARM_ARRAY("queue_1", |
| "Report threhsold for queue set 0", |
| BCMCLI_PARM_UNUMBER, |
| BCMCLI_PARM_FLAG_OPTIONAL, |
| MAX_REPORT_THRESHOLDS, |
| queue_1), |
| BCMCLI_MAKE_PARM_ARRAY("queue_2", |
| "Report threhsold for queue set 0", |
| BCMCLI_PARM_UNUMBER, |
| BCMCLI_PARM_FLAG_OPTIONAL, |
| MAX_REPORT_THRESHOLDS, |
| queue_2), |
| BCMCLI_MAKE_PARM_ARRAY("queue_3", |
| "Report threhsold for queue set 0", |
| BCMCLI_PARM_UNUMBER, |
| BCMCLI_PARM_FLAG_OPTIONAL, |
| MAX_REPORT_THRESHOLDS, |
| queue_3)); |
| |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_clear_ingress_rules_network_pon", "DPoE clear ingress rules for network PON", |
| epon_oam_dpoe_clear_ingress_rules_network_pon_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0)); |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_clear_ingress_rules_user_port", "DPoE clear ingress rules for user port", |
| epon_oam_dpoe_clear_ingress_rules_user_port_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0)); |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_clear_ingress_rules", "DPoE clear ingress rules", |
| epon_oam_dpoe_clear_ingress_rules_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0)); |
| |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_set_basic_queue_config", "DPoE set basic queue config for 1 link/1 port", |
| epon_oam_dpoe_set_basic_queue_config_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0), |
| BCMCLI_MAKE_PARM("up_size", "upstream queue size", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("dn_size", "downstream queue size", BCMCLI_PARM_UNUMBER, 0)); |
| |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_add_ingress_rules_network_pon", "DPoE add ingress rules for network PON", |
| epon_oam_dpoe_add_ingress_rules_network_pon_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0)); |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_add_ingress_rules_user_port", "DPoE add ingress rules for user port", |
| epon_oam_dpoe_add_ingress_rules_user_port_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0)); |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_add_ingress_rules", "DPoE add ingress rules", |
| epon_oam_dpoe_add_ingress_rules_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0)); |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_add_ingress_rules_with_vlan", "DPoE add ingress rules with VLAN", |
| epon_oam_dpoe_add_ingress_rules_with_vlan_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0), |
| BCMCLI_MAKE_PARM("vlan", "VLAN", BCMCLI_PARM_UNUMBER, 0)); |
| |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_enable_user_traffic", "DPoE enable user traffic", |
| epon_oam_dpoe_enable_user_traffic_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0)); |
| |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_fw_upgrade", "DPoE firwmare upgrade", |
| epon_oam_dpoe_start_upgrade_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0), |
| BCMCLI_MAKE_PARM("fw_file", "Firmware file", BCMCLI_PARM_STRING, 0), |
| BCMCLI_MAKE_PARM("block_size", "Block size", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("timeout", "Timeout in seconds", BCMCLI_PARM_UNUMBER, 0)); |
| |
| BCMCLI_MAKE_CMD(oam_dir, "dpoe_reset_onu", "DPoE reset ONU", |
| epon_oam_dpoe_reset_onu_cli, |
| BCMCLI_MAKE_PARM("epon_ni", "EPON NI", BCMCLI_PARM_UNUMBER, 0), |
| BCMCLI_MAKE_PARM("mac_address", "link MAC", BCMCLI_PARM_MAC, 0)); |
| #endif |
| } |
| |