blob: e94c28222bf60f73fdf21baf143daabdd99c1755 [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/******************************************************************************
2 *
3 * <:copyright-BRCM:2016:DUAL/GPL:standard
4 *
5 * Copyright (c) 2016 Broadcom
6 * All Rights Reserved
7 *
8 * Unless you and Broadcom execute a separate written software license
9 * agreement governing use of this software, this software is licensed
10 * to you under the terms of the GNU General Public License version 2
11 * (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
12 * with the following added to such license:
13 *
14 * As a special exception, the copyright holders of this software give
15 * you permission to link this software with independent modules, and
16 * to copy and distribute the resulting executable under terms of your
17 * choice, provided that you also meet, for each linked independent
18 * module, the terms and conditions of the license of that module.
19 * An independent module is a module which is not derived from this
20 * software. The special exception does not apply to any modifications
21 * of the software.
22 *
23 * Not withstanding the above, under no circumstances may you combine
24 * this software in any way with any other Broadcom software provided
25 * under a license other than the GPL, without Broadcom's express prior
26 * written consent.
27 *
28 * :>
29 *
30 *****************************************************************************/
31
32/**
33 * @file bal_mac_util_loopback.c
34 *
35 * @brief mac util handling for MAC in loopback mode
36 *
37 * The loopback mode is handled like a mac protocol, with loopback specific handling
38 * done as sub-routine calls from the top level handler functions.
39 *
40 * @addtogroup mac_util
41 */
42
43/*@{*/
44
45#include <bal_mac_util.h>
46#include <bal_mac_util_common_itu_pon.h>
47#include <bal_worker.h>
48
49
50/**
51 * @brief access terminal set for loopback
52 */
53bcmos_errno mac_util_access_terminal_set_for_loopback (acc_term_inst *p_acc_term, bal_util_oper_acc_term op_type, bcmolt_devid device_id)
54{
55 bcmos_errno rc = BCM_ERR_OK;
56
57 bcmos_usleep(1000000);
58 mac_util_report_acc_term_event(BCMOLT_DEVICE_AUTO_ID_CONNECTION_COMPLETE);
59
60 return rc;
61}
62
63
64/**
65 * @brief set interface for loopback mode
66 *
67 * @param p_interface_inst Pointer to interface instance
68 * @param op_type Operation type on access terminal/interface instance
69 *
70 * @return bcmos_errno
71 *
72 */
73bcmos_errno mac_util_interface_set_for_loopback(acc_term_interface *p_interface_inst, bal_util_oper_if op_type)
74{
75 bcmos_errno rc = BCM_ERR_OK;
76 bcmbal_interface_key intf_key = p_interface_inst->api_req_int_obj_info.key;
77 bcmbal_interface_cfg *p_interface_req = &(p_interface_inst->api_req_int_obj_info);
78
79 p_interface_req = &(p_interface_inst->api_req_int_obj_info);
80
81 /* If the user didn't specify a transceiver, then use the default */
82 if (BCMOS_FALSE == BCMBAL_CFG_PROP_IS_SET(p_interface_req, interface, transceiver_type))
83 {
84 BCMBAL_CFG_PROP_SET(p_interface_req, interface, transceiver_type, BCMBAL_MAC_UTIL_TRX_TYPE_DEFAULT_GPON);
85 }
86
87 mac_util_report_if_event(intf_key.intf_id,
88 intf_key.intf_type,
89 BCM_ERR_OK, BCMOLT_RESULT_SUCCESS,
90 ((BAL_UTIL_OPER_IF_UP == op_type) ? BCMOLT_PON_STATE_ACTIVE_WORKING : BCMOLT_PON_STATE_INACTIVE));
91
92
93 return rc;
94}
95
96
97/**
98 * @brief Set subscriber terminal for loopback mode
99 *
100 * @param p_sub_term_inst A pointer to a subscriber terminal instance
101 * @param op_type Type of operation being performed on the subscriber terminal instance
102 * @param is_post_discovery Used for ADD, indicates if this request is after a ONU Discovery
103 *
104 * @return bcmos_errno
105 */
106bcmos_errno mac_util_subscriber_terminal_set_for_loopback(sub_term_inst *p_sub_term_inst, bal_util_oper_sub_term op_type, bcmos_bool is_post_discovery)
107{
108 bcmos_errno rc = BCM_ERR_OK;
109 bcmbal_subscriber_terminal_cfg *p_sub_term_req = &p_sub_term_inst->api_req_sub_term_info;
110
111
112 mac_util_report_sub_term_event(p_sub_term_req->key.intf_id,
113 p_sub_term_req->key.sub_term_id,
114 (bcmolt_serial_number *)NULL,
115 (BAL_UTIL_OPER_SUB_TERM_ADD == op_type ? BAL_UTIL_OPER_SUB_TERM_ADD : BAL_UTIL_OPER_SUB_TERM_REMOVE),
116 BCM_ERR_OK, BCMOLT_RESULT_SUCCESS,
117 (BAL_UTIL_OPER_SUB_TERM_ADD == op_type ? BCMOLT_ACTIVATION_FAIL_REASON_NONE : BCMOLT_RESULT_SUCCESS), BCMBAL_INVALID_TUNNEL_ID);
118
119 return rc;
120}
121
122
123/**
124 * @brief set flow for loopback mode
125 */
126bcmos_errno mac_util_flow_set_for_loopback(bcmbal_flow_cfg *p_flow_req, bal_util_oper_flow op_type, flow_inst *p_flow_core)
127{
128 bcmos_errno rc = BCM_ERR_OK;
129
130 if (BAL_UTIL_OPER_FLOW_ADD == op_type)
131 {
132 mac_util_report_flow_add_success(p_flow_req->key, p_flow_req->data.access_int_id);
133 }
134 else if ((BAL_UTIL_OPER_FLOW_REMOVE == op_type) || (BAL_UTIL_OPER_FLOW_CLEAR == op_type))
135 {
136 mac_util_report_flow_remove_success(p_flow_req->key, p_flow_req->data.access_int_id, op_type);
137 }
138 else
139 {
140 rc = BCM_ERR_INVALID_OP;
141 }
142
143
144 return rc;
145}
146
147
148
149/*@}*/