blob: 6b0acf19350ff91ed3c527fe7a8c1c27197b5b89 [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/*
2<:copyright-BRCM:2016:DUAL/GPL:standard
3
4 Broadcom Proprietary and Confidential.(c) 2016 Broadcom
5 All Rights Reserved
6
7Unless you and Broadcom execute a separate written software license
8agreement governing use of this software, this software is licensed
9to you under the terms of the GNU General Public License version 2
10(the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
11with the following added to such license:
12
13 As a special exception, the copyright holders of this software give
14 you permission to link this software with independent modules, and
15 to copy and distribute the resulting executable under terms of your
16 choice, provided that you also meet, for each linked independent
17 module, the terms and conditions of the license of that module.
18 An independent module is a module which is not derived from this
19 software. The special exception does not apply to any modifications
20 of the software.
21
22Not withstanding the above, under no circumstances may you combine
23this software in any way with any other Broadcom software provided
24under a license other than the GPL, without Broadcom's express prior
25written consent.
26
27:>
28*/
29
30/* This file contains the pieces of the OAM negotiation state machine that are specific to DPoE OAM. */
31
32#include "bcmolt_eon_private.h"
33#include "../oam_common.h"
34#include "dpoe.h"
35
36/* Org specific TLV to send to the ONU */
37static const bcmolt_epon_oam_organization_specific_info dpoe_tx_tlv =
38{
39 .oui = BCMOLT_EPON_OAM_WELL_KNOWN_OUI_DPOE,
40 .u =
41 {
42 .dpoe =
43 {
44 .dpoe_info_tlv =
45 {
46 .type = BCMOLT_EPON_OAM_DPOE_INFO_TLV_TYPE_DPOE_OAM_SUPPORT,
47 .u =
48 {
49 .dpoe_oam_support =
50 {
51 .dpoe_oam_version = 0x11
52 }
53 }
54 }
55 }
56 }
57};
58
59void dpoe_tx_add_tlv(eon_link_state *link_state, bcmolt_epon_oam_oam_pdu_content *oam)
60{
61 if ((LOCAL_EVAL_REMOTE_EVAL == link_state->oam_state) ||
62 (LOCAL_STABLE_REMOTE_EVAL == link_state->oam_state))
63 {
64 oam->u.info.tlvs[oam->u.info.tlvs_count].type = BCMOLT_EPON_OAM_INFO_TLV_TYPE_ORGANIZATION_SPECIFIC;
65 oam->u.info.tlvs[oam->u.info.tlvs_count].u.organization_specific.value = dpoe_tx_tlv;
66 oam->u.info.tlvs_count++;
67 }
68}
69
70void dpoe_rx_tlv(
71 eon_link_state *link_state,
72 bcmolt_epon_oam_organization_specific_info *org_spec,
73 bcmos_errno *rc)
74{
75 if (link_state->oam_state == LOCAL_STABLE_REMOTE_STABLE)
76 {
77 if (NULL != org_spec)
78 {
79 EON_LINK_LOG(INFO, &link_state->link_key, "Got unexpected organization specific TLV\n");
80 *rc = BCM_ERR_ONU_ERR_RESP;
81 }
82 }
83 else
84 {
85 if ((NULL == org_spec) ||
86 (BCMOLT_EPON_OAM_WELL_KNOWN_OUI_DPOE != org_spec->oui) ||
87 (BCMOLT_EPON_OAM_DPOE_INFO_TLV_TYPE_DPOE_OAM_SUPPORT != org_spec->u.dpoe.dpoe_info_tlv.type))
88 {
89 EON_LINK_LOG(INFO, &link_state->link_key, "Didn't get DPoE TLV\n");
90 *rc = BCM_ERR_ONU_ERR_RESP;
91 }
92 else
93 {
94 switch (org_spec->u.dpoe.dpoe_info_tlv.u.dpoe_oam_support.dpoe_oam_version)
95 {
96 case 0x22:
97 case 0x21:
98 case 0x20:
99 case 0x11: /* DPoE v1.0 I05 and higher */
100 break;
101 case 0x01: /* backwards compatibility, same as 0x10 */
102 case 0x02: /* pre-DPoE OAM, no Certificate Authority support */
103 case 0x03: /* pre-DPoE OAM, with Certificate Authority support */
104 case 0x10: /* DPoE v1.0 I04 and lower */
105 EON_LINK_LOG(
106 WARNING, &link_state->link_key,
107 "DPoE TLV contained old version: %u (some features may not work)\n",
108 org_spec->u.dpoe.dpoe_info_tlv.u.dpoe_oam_support.dpoe_oam_version);
109 break;
110 case 0x00: /* workaround for EASW-17839 */
111 break;
112 default:
113 EON_LINK_LOG(
114 ERROR, &link_state->link_key, "DPoE TLV contained bad version: %u\n",
115 org_spec->u.dpoe.dpoe_info_tlv.u.dpoe_oam_support.dpoe_oam_version);
116 *rc = BCM_ERR_NOT_SUPPORTED;
117 break;
118 }
119 }
120 }
121}
122