furia_diagnostics.c (10805B)
1 /* 2 * 3 * 4 * 5 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 6 * 7 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 8 */ 9 10 #include <phymod/phymod_diagnostics.h> 11 #include <phymod/phymod_diagnostics_dispatch.h> 12 13 14 #ifdef PHYMOD_FURIA_SUPPORT 15 16 #include "../../furia/tier1/furia_types.h" 17 #include "../../furia/tier1/furia_cfg_seq.h" 18 /** Convert PHYMOD poly to falcon poly type 19 * This function converts PHYMOD polynomial type to falcon polynomial type 20 * 21 * @param phymod_poly phymod polynomial type 22 * @param falcon_poly falcon polynomial type 23 * 24 * @return PHYMOD_E_NONE successful function execution 25 */ 26 STATIC 27 int _furia_prbs_poly_phymod_to_falcon(phymod_prbs_poly_t phymod_poly, 28 enum srds_prbs_polynomial_enum *falcon_poly) 29 { 30 switch(phymod_poly) { 31 case phymodPrbsPoly7: 32 *falcon_poly= PRBS7; 33 break; 34 case phymodPrbsPoly9: 35 *falcon_poly= PRBS9; 36 break; 37 case phymodPrbsPoly11: 38 *falcon_poly= PRBS11; 39 break; 40 case phymodPrbsPoly15: 41 *falcon_poly= PRBS15; 42 break; 43 case phymodPrbsPoly23: 44 *falcon_poly= PRBS23; 45 break; 46 case phymodPrbsPoly31: 47 *falcon_poly= PRBS31; 48 break; 49 case phymodPrbsPoly58: 50 *falcon_poly= PRBS58; 51 break; 52 default: 53 PHYMOD_RETURN_WITH_ERR 54 (PHYMOD_E_PARAM,\ 55 (_PHYMOD_MSG("unsupported poly for furia"))); 56 break; 57 } 58 return PHYMOD_E_NONE; 59 } 60 61 /** Convert falcon poly to PHYMOD poly type 62 * This function converts falcon polynomial type to PHYMOD polynomial type 63 * 64 * @param falcon_poly falcon polynomial type 65 * @param phymod_poly phymod polynomial type 66 * 67 * @return PHYMOD_E_NONE successful function execution 68 */ 69 STATIC 70 int _furia_prbs_poly_falcon_to_phymod(enum srds_prbs_polynomial_enum falcon_poly, 71 phymod_prbs_poly_t *phymod_poly) 72 { 73 switch(falcon_poly) { 74 case PRBS7: 75 *phymod_poly = phymodPrbsPoly7; 76 break; 77 case PRBS9: 78 *phymod_poly = phymodPrbsPoly9; 79 break; 80 case PRBS11: 81 *phymod_poly = phymodPrbsPoly11; 82 break; 83 case PRBS15: 84 *phymod_poly = phymodPrbsPoly15; 85 break; 86 case PRBS23: 87 *phymod_poly = phymodPrbsPoly23; 88 break; 89 case PRBS31: 90 *phymod_poly = phymodPrbsPoly31; 91 break; 92 case PRBS58: 93 *phymod_poly = phymodPrbsPoly58; 94 break; 95 default: 96 PHYMOD_RETURN_WITH_ERR 97 (PHYMOD_E_INTERNAL,\ 98 (_PHYMOD_MSG("uknown poly"))); 99 break; 100 } 101 return PHYMOD_E_NONE; 102 } 103 104 /** Set PRBS configuration 105 * This function configures PRBS generator and checker with user provided 106 * PRBS configuration such as type of polynomial, invert data 107 * 108 * @param phy Pointer to phymod phy access structure 109 * @param flags Currently unused and reserved for future use 110 * @param prbs Pointer to phymod prbs structure which has 111 * user provide polynomial and invert data info 112 * 113 * @return PHYMOD_E_NONE successful function execution 114 */ 115 int furia_phy_prbs_config_set(const phymod_phy_access_t* phy, uint32_t flags, 116 const phymod_prbs_t* prbs) 117 { 118 enum srds_prbs_polynomial_enum falcon_poly; 119 PHYMOD_IF_ERR_RETURN 120 (_furia_prbs_poly_phymod_to_falcon(prbs->poly, &falcon_poly)); 121 PHYMOD_IF_ERR_RETURN 122 (furia_prbs_config_set(&phy->access, flags, falcon_poly, prbs->invert)); 123 return PHYMOD_E_NONE; 124 } 125 126 /** Get PRBS configuration 127 * This function retrieves PRBS generator and checker configuration (type 128 * of polynomial and invert data from furia device 129 * 130 * @param phy Pointer to phymod phy access structure 131 * @param flags Currently unused and reserved for future use 132 * @param prbs Pointer to phymod prbs structure 133 * which will be populated with polynomial 134 * and invert data info 135 * 136 * @return PHYMOD_E_NONE successful function execution 137 */ 138 int furia_phy_prbs_config_get(const phymod_phy_access_t* phy, uint32_t flags, 139 phymod_prbs_t* prbs) 140 { 141 phymod_prbs_t config_tmp; 142 enum srds_prbs_polynomial_enum falcon_poly; 143 PHYMOD_IF_ERR_RETURN 144 (furia_prbs_config_get(&phy->access, flags, &falcon_poly, &config_tmp.invert)); 145 PHYMOD_IF_ERR_RETURN 146 (_furia_prbs_poly_falcon_to_phymod(falcon_poly, &config_tmp.poly)); 147 prbs->invert = config_tmp.invert; 148 prbs->poly = config_tmp.poly; 149 return PHYMOD_E_NONE; 150 } 151 152 /** Enable PRBS 153 * This function enables PRBS checker and generator of furia device 154 * 155 * @param phy Pointer to phymod phy access structure 156 * @param flags Currently unused and reserved for future use 157 * @param enable Enable or Disable supplied by user 158 * 159 * @return PHYMOD_E_NONE successful function execution 160 */ 161 int furia_phy_prbs_enable_set(const phymod_phy_access_t* phy, uint32_t flags, 162 uint32_t enable) 163 { 164 PHYMOD_IF_ERR_RETURN 165 (furia_prbs_enable_set(&phy->access, flags, enable)); 166 return PHYMOD_E_NONE; 167 } 168 169 /** PRBS Enable get 170 * This function retreives the status of PRBS checker and generator of 171 * furia device i.e.., whether or not enabled 172 * 173 * @param phy Pointer to phymod phy access structure 174 * @param flags Currently unused and reserved for future use 175 * @param enable Enable or Disable read from the device 176 * 177 * @return PHYMOD_E_NONE successful function execution 178 */ 179 int furia_phy_prbs_enable_get(const phymod_phy_access_t* phy, uint32_t flags, 180 uint32_t *enable) 181 { 182 PHYMOD_IF_ERR_RETURN 183 (furia_prbs_enable_get(&phy->access, flags, enable)); 184 return PHYMOD_E_NONE; 185 } 186 187 /** Get PRBS lock and error status 188 * This function retreives the status of PRBS lock, loss of lock and 189 * PRBS error count of the furia device 190 * 191 * @param phy Pointer to phymod phy access structure 192 * @param flags Currently unused and reserved for future use 193 * @param prbs_status PRBS status structure will be populated with 194 * PRBS lock, loss of lock and error count 195 * 196 * @return PHYMOD_E_NONE successful function execution 197 */ 198 int furia_phy_prbs_status_get(const phymod_phy_access_t* phy, uint32_t flags, 199 phymod_prbs_status_t* prbs_status) 200 { 201 PHYMOD_IF_ERR_RETURN 202 (furia_prbs_status_get(&phy->access, 203 &prbs_status->prbs_lock, 204 &prbs_status->prbs_lock_loss, 205 &prbs_status->error_count)); 206 return PHYMOD_E_NONE; 207 } 208 209 /** Display eyescan 210 * This function used to display eye diagram from given lane 211 * 212 * @param phy Pointer to phymod phy access structure 213 * 214 * @return PHYMOD_E_NONE successful function execution 215 */ 216 int furia_phy_eyescan_run( const phymod_phy_access_t *phy, uint32_t flags, 217 phymod_eyescan_mode_t mode, const phymod_phy_eyescan_options_t* eyescan_options) 218 { 219 /* Added condition to solve printing eye trice from PHYMOD layer*/ 220 if (PHYMOD_EYESCAN_F_DONE_GET(flags)) { 221 switch(mode) { 222 case phymodEyescanModeFast: 223 return furia_display_eye_scan(&phy->access); 224 break; 225 case phymodEyescanModeBERProj: 226 return furia_ber_proj(&phy->access, eyescan_options); 227 break; 228 default: 229 return furia_display_eye_scan(&phy->access); 230 break; 231 } 232 233 } else { 234 return PHYMOD_E_NONE; 235 } 236 } 237 /** Diagnostics get 238 * This function used to get the diagnostics of a given lane 239 * 240 * @param phy Pointer to phymod phy access structure 241 * @param diag Diagnostics attributes 242 * 243 * @return PHYMOD_E_NONE successful function execution 244 */ 245 int furia_phy_diagnostics_get(const phymod_phy_access_t* phy, phymod_phy_diagnostics_t* diag) 246 { 247 return _furia_phy_diagnostics_get(&phy->access, diag); 248 } 249 250 /** FC/PCS checker enable set 251 * This function is used to enable or disable FC/PCS checker 252 * 253 * @param phy Pointer to phymod phy access structure 254 * @param fcpcs_chkr_mode FC/PCS checker mode 255 * @param enable Enable or disable 256 * 1 - enable 257 * 0 - disable 258 * 259 * @return PHYMOD_E_NONE successful function execution 260 */ 261 int furia_phy_link_mon_enable_set(const phymod_phy_access_t* phy, phymod_link_monitor_mode_t fcpcs_chkr_mode, uint32_t enable) 262 { 263 return furia_fc_pcs_chkr_enable_set(&phy->access, fcpcs_chkr_mode, enable); 264 } 265 /** FC/PCS checker enable get 266 * This function is used to check whether or not FC/PCS checker enabled 267 * 268 * @param phy Pointer to phymod phy access structure 269 * @param fcpcs_chkr_mode FC/PCS checker mode 270 * @param enable Enable or disable 271 * 1 - enable 272 * 0 - disable 273 * 274 * @return PHYMOD_E_NONE successful function execution 275 */ 276 int furia_phy_link_mon_enable_get(const phymod_phy_access_t* phy, phymod_link_monitor_mode_t fcpcs_chkr_mode, uint32_t *enable) 277 { 278 return furia_fc_pcs_chkr_enable_get(&phy->access, fcpcs_chkr_mode, enable); 279 } 280 /** FC/PCS checker status get 281 * This function is used to lock, loss of lock, error count status of the FC/PCS checker 282 * 283 * @param phy Pointer to phymod phy access structure 284 * @param lock_status Live lock status 285 * 1 - Locked 286 * 0 - Not locked 287 * @param lock_lost_lh Loss of lock 288 * 1 - Loss of lock happened 289 * 0 - No Loss of lock happended 290 * @param error_count Error count 291 * 292 * @return PHYMOD_E_NONE successful function execution 293 */ 294 int furia_phy_link_mon_status_get(const phymod_phy_access_t* phy, uint32_t* lock_status, uint32_t* lock_lost_lh, uint32_t* error_count) 295 { 296 return furia_fc_pcs_chkr_status_get(&phy->access, lock_status, lock_lost_lh, error_count); 297 } 298 299 int furia_phy_pmd_info_dump(const phymod_phy_access_t* phy, const char* type) 300 { 301 return _furia_phy_status_dump(&phy->access); 302 } 303 #endif /* PHYMOD_FURIA_SUPPORT */