blob: 03cd0a1413f477ec1e6fbc858406c0ca723afb8a [file] [log] [blame]
Zack Williams477ba092018-10-17 10:50:06 -07001/*
Girish Gowdraa707e7c2019-11-07 11:36:13 +05302 * Copyright 2018-present Open Networking Foundation
Zack Williams477ba092018-10-17 10:50:06 -07003
Girish Gowdraa707e7c2019-11-07 11:36:13 +05304 * 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
Zack Williams477ba092018-10-17 10:50:06 -07007
Girish Gowdraa707e7c2019-11-07 11:36:13 +05308 * http://www.apache.org/licenses/LICENSE-2.0
Zack Williams477ba092018-10-17 10:50:06 -07009
Girish Gowdraa707e7c2019-11-07 11:36:13 +053010 * 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 */
Zack Williams477ba092018-10-17 10:50:06 -070016
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000017#include <string.h>
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040018#include "translation.h"
19
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000020int interface_key_to_port_no(bcmolt_interface_id intf_id,
21 bcmolt_interface_type intf_type) {
22 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Burak Gurdag676c4922020-05-15 16:31:50 +000023 return (0x1 << 20) + intf_id;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040024 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000025 if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
26 return (0x2 << 28) + intf_id;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040027 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000028 return intf_id;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040029}
30
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000031std::string alarm_status_to_string(bcmolt_status status) {
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040032 switch (status) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000033 case BCMOLT_STATUS_OFF:
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040034 return "off";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000035 case BCMOLT_STATUS_ON:
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040036 return "on";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000037 case BCMOLT_STATUS_NO_CHANGE:
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040038 return "no_change";
39 }
40 return "unknown";
41}
Craig Lutgenb2601f02018-10-23 13:04:31 -050042
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053043std::string bcmolt_result_to_string(bcmolt_result result) {
44 switch (result) {
45 case BCMOLT_RESULT_SUCCESS:
46 return "success";
47 case BCMOLT_RESULT_FAIL:
48 return "fail";
49 default:
50 return "unknown";
51 }
52}
53