openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

merlin16_diagnostics.c (3878B)


      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.h>
     11 #include <phymod/phymod_system.h>
     12 #include <phymod/phymod_diagnostics.h>
     13 #include <phymod/phymod_diagnostics_dispatch.h>
     14 #include "merlin16/tier1/merlin16_diag.h"
     15 #include "merlin16/tier1/merlin16_config.h"
     16 
     17 
     18 #ifdef PHYMOD_MERLIN16_SUPPORT
     19 
     20 
     21 STATIC int merlin16_diagnostics_eyescan_run_uc(const phymod_phy_access_t* phy, uint32_t flags)
     22 {
     23     int                 rc = PHYMOD_E_NONE;
     24     uint32_t            stripe[64];
     25     uint16_t            status;
     26     int                 i,ii;
     27     phymod_phy_access_t phy_copy;
     28     struct merlin16_uc_core_config_st core_cfg;
     29 
     30     PHYMOD_MEMCPY(&phy_copy, phy, sizeof(phy_copy));
     31 
     32     /* do not run eyescan for 10Gx4 case */
     33     if ((PHYMOD_EYESCAN_F_ENABLE_GET(flags)) ||
     34         (PHYMOD_EYESCAN_F_PROCESS_GET(flags))) {
     35         PHYMOD_IF_ERR_RETURN(merlin16_get_uc_core_config(&(phy_copy.access), &core_cfg));
     36         if ((core_cfg.vco_rate_in_Mhz == 12500) && (phy->access.lane_mask == 0xf)) {
     37             PHYMOD_RETURN_WITH_ERR(PHYMOD_E_FAIL, (_PHYMOD_MSG("eyescan is not supported")));
     38         }
     39     }
     40 
     41     for (i = 0; i < PHYMOD_CONFIG_MAX_LANES_PER_CORE; i++) { /* Loop for all lanes. */
     42         if ((phy->access.lane_mask & (1 << i)) == 0) continue;
     43 
     44         phy_copy.access.lane_mask = (phy->access.lane_mask & (1 << i));
     45 
     46         if (PHYMOD_EYESCAN_F_ENABLE_GET(flags)) {
     47             rc = merlin16_meas_eye_scan_start(&(phy_copy.access), EYE_SCAN_HORIZ);
     48             if (rc != PHYMOD_E_NONE) {
     49                 PHYMOD_IF_ERR_RETURN(merlin16_meas_eye_scan_done(&(phy_copy.access)));
     50             }
     51             if (!PHYMOD_EYESCAN_F_ENABLE_DONT_WAIT_GET(flags)) {
     52                 PHYMOD_USLEEP(100000);
     53             }
     54         }
     55 
     56         if (PHYMOD_EYESCAN_F_PROCESS_GET(flags)) {
     57             for (ii = 31; ii >= -31; ii = ii-1) {
     58                 if (ii == 31) {
     59                     PHYMOD_DIAG_OUT(("\n\n\n"));
     60                     PHYMOD_DIAG_OUT(("    +--------------------------------------------------------------------+\n"));
     61                     PHYMOD_DIAG_OUT(("    | EYESCAN Phy: 0x%03x lane_mask: 0x%02x                                 |\n", phy_copy.access.addr, phy_copy.access.lane_mask));
     62                     PHYMOD_DIAG_OUT(("    +--------------------------------------------------------------------+\n"));
     63                     /*display eyescan header*/
     64                     PHYMOD_IF_ERR_RETURN(merlin16_display_eye_scan_header(1));
     65                 }
     66 
     67                 rc  = merlin16_read_eye_scan_stripe(&(phy_copy.access), stripe, &status);
     68                 if (rc != PHYMOD_E_NONE) {
     69                     PHYMOD_IF_ERR_RETURN(rc);
     70                 }
     71                 PHYMOD_IF_ERR_RETURN(merlin16_display_eye_scan_stripe(&(phy_copy.access), ii, &stripe[0]));
     72 
     73                 PHYMOD_DIAG_OUT(("\n"));
     74             }
     75 
     76             if (rc == PHYMOD_E_NONE) {
     77                 PHYMOD_IF_ERR_RETURN(merlin16_display_eye_scan_footer(1));
     78                 PHYMOD_DIAG_OUT(("\n"));
     79             }
     80         }
     81 
     82         if (PHYMOD_EYESCAN_F_DONE_GET(flags)) {
     83             PHYMOD_IF_ERR_RETURN(merlin16_meas_eye_scan_done(&(phy_copy.access)));
     84         }
     85     }
     86 
     87     return PHYMOD_E_NONE;
     88 }
     89 
     90 int merlin16_phy_eyescan_run(const phymod_phy_access_t* phy, uint32_t flags, phymod_eyescan_mode_t mode, const phymod_phy_eyescan_options_t* eyescan_options)
     91 {        
     92 
     93     switch(mode) {
     94         case phymodEyescanModeFast:
     95              return merlin16_diagnostics_eyescan_run_uc(phy, flags);
     96         default:
     97             PHYMOD_RETURN_WITH_ERR(PHYMOD_E_PARAM, (_PHYMOD_MSG("unsupported eyescan mode %u"), mode));
     98     }
     99         
    100     return PHYMOD_E_NONE;
    101     
    102 }
    103 
    104 #endif /* PHYMOD_MERLIN16_SUPPORT */