oam.c (3489B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 */ 7 #include <shared/bsl.h> 8 9 #include <soc/drv.h> 10 #include <soc/phy/drv.h> 11 12 /* 13 * Function: 14 * soc_port_config_phy_oam_set 15 * Purpose: 16 * Update PHY's phy_oam config 17 * Parameters: 18 * unit - SOC Unit #. 19 * port - Port number. 20 * conf - Config 21 * Returns: 22 * SOC_E_XXX 23 */ 24 int 25 soc_port_config_phy_oam_set(int unit, soc_port_t port, soc_port_config_phy_oam_t *conf) 26 { 27 int rv; 28 phy_ctrl_t *pc; 29 30 rv = SOC_E_UNAVAIL; 31 32 pc = EXT_PHY_SW_STATE(unit, port); 33 34 if (NULL != pc) { 35 INT_MCU_LOCK(unit); 36 rv = PHY_OAM_CONFIG_SET(pc->pd, unit, port, conf); 37 INT_MCU_UNLOCK(unit); 38 } 39 40 if (SOC_FAILURE(rv)) { 41 LOG_WARN(BSL_LS_SOC_COMMON, 42 (BSL_META_U(unit, 43 "soc_port_config_phy_oam_set failed %d\n"), rv)); 44 } 45 return rv; 46 } 47 48 /* 49 * Function: 50 * soc_port_config_phy_oam_get 51 * Purpose: 52 * Retrive PHY's phy_oam config 53 * Parameters: 54 * unit - SOC Unit #. 55 * port - Port number. 56 * conf - Config 57 * Returns: 58 * SOC_E_XXX 59 */ 60 int 61 soc_port_config_phy_oam_get(int unit, soc_port_t port, soc_port_config_phy_oam_t *conf) 62 { 63 int rv; 64 phy_ctrl_t *pc; 65 66 rv = SOC_E_UNAVAIL; 67 68 pc = EXT_PHY_SW_STATE(unit, port); 69 70 if (NULL != pc) { 71 INT_MCU_LOCK(unit); 72 rv = PHY_OAM_CONFIG_GET(pc->pd, unit, port, conf); 73 INT_MCU_UNLOCK(unit); 74 } 75 76 if (SOC_FAILURE(rv)) { 77 LOG_WARN(BSL_LS_SOC_COMMON, 78 (BSL_META_U(unit, 79 "soc_port_config_phy_oam_get failed %d\n"), rv)); 80 } 81 return rv; 82 } 83 84 /* 85 * Function: 86 * soc_port_control_phy_oam_set 87 * Purpose: 88 * Update PHY's phy_oam parameter 89 * Parameters: 90 * unit - SOC Unit #. 91 * port - Port number. 92 * type - operation 93 * value - parameter 94 * Returns: 95 * SOC_E_XXX 96 */ 97 int 98 soc_port_control_phy_oam_set(int unit, soc_port_t port, soc_port_control_phy_oam_t type, uint64 value) 99 { 100 int rv; 101 phy_ctrl_t *pc; 102 103 rv = SOC_E_UNAVAIL; 104 105 pc = EXT_PHY_SW_STATE(unit, port); 106 107 if (NULL != pc) { 108 INT_MCU_LOCK(unit); 109 rv = PHY_OAM_CONTROL_SET(pc->pd, unit, port, type, value); 110 INT_MCU_UNLOCK(unit); 111 } 112 113 if (SOC_FAILURE(rv)) { 114 LOG_WARN(BSL_LS_SOC_COMMON, 115 (BSL_META_U(unit, 116 "soc_port_control_phy_oam_set failed %d\n"), rv)); 117 } 118 return rv; 119 } 120 121 /* 122 * Function: 123 * soc_port_control_phy_oam_get 124 * Purpose: 125 * Retrive PHY's phy_oam parameter 126 * Parameters: 127 * unit - SOC Unit #. 128 * port - Port number. 129 * type - operation 130 * value - *parameter 131 * Returns: 132 * SOC_E_XXX 133 */ 134 int 135 soc_port_control_phy_oam_get(int unit, soc_port_t port, soc_port_control_phy_oam_t type, uint64 *value) 136 { 137 int rv; 138 phy_ctrl_t *pc; 139 140 rv = SOC_E_UNAVAIL; 141 142 pc = EXT_PHY_SW_STATE(unit, port); 143 144 if (NULL != pc) { 145 INT_MCU_LOCK(unit); 146 rv = PHY_OAM_CONTROL_GET(pc->pd, unit, port, type, value); 147 INT_MCU_UNLOCK(unit); 148 } 149 150 if (SOC_FAILURE(rv)) { 151 LOG_WARN(BSL_LS_SOC_COMMON, 152 (BSL_META_U(unit, 153 "soc_port_control_phy_oam_get failed %d\n"), rv)); 154 } 155 return rv; 156 }