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

qmod_diagnostics.c (9561B)


      1 /* 
      2  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      3  * 
      4  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      5  */ 
      6 
      7 #ifndef _DV_TB_
      8  #define _SDK_QMOD_ 1 
      9 #endif
     10 
     11 #ifdef _DV_TB_
     12 #include "qmod_phyreg.h"
     13 #include <stdint.h>
     14 #include "qmod_main.h"
     15 #include "qmod_enum_defines.h"
     16 #include "qmod.h"
     17 #include "qmod_defines.h"
     18 #include "qmod_phyreg.h"
     19 #include "qePCSRegEnums.h"
     20 #include "phy_tsc_iblk.h"
     21 #endif
     22 
     23 #ifdef _SDK_QMOD_
     24 #include "phy_tsc_iblk.h"
     25 #include <phymod/phymod.h>
     26 #include <phymod/phymod_system.h>
     27 #include <phymod/phymod_util.h>
     28 #include <phymod/phymod_debug.h>
     29 #include <phymod/chip/bcmi_qtce_xgxs_defs.h>
     30 #include "qmod_enum_defines.h"
     31 #include "qmod.h"
     32 #include "qmod_device.h"
     33 #include "qmod_sc_lkup_table.h"
     34 #include "qePCSRegEnums.h"
     35 #endif
     36 
     37 #define _TRGO_(a,l) PHYMOD_DEBUG_ERROR(("<< PHY_TRG: Adr:%06d Ln:%02d\n",a,l));
     38 #define _TRGC_(a,l) PHYMOD_DEBUG_ERROR((">> PHY TRG: Adr:%06d Ln:%02d\n",a,l));
     39 #ifndef PHYMOD_ST
     40 #ifdef _SDK_QMOD_
     41   #define PHYMOD_ST phymod_access_t
     42   #define _TRG_OPN(a) _TRGO_(a->addr, a->lane_mask)
     43   #define _TRG_CLS(a) _TRGC_(a->addr, a->lane_mask)
     44 #endif /*_SDK_QMOD_ */
     45 #endif /* PHYMOD_ST */
     46 
     47 #ifdef _DV_TB_
     48   #define PHYMOD_ST  qmod_st
     49   #define _TRG_OPN(a) _TRGO_(a->prt_ad, a->this_lane)
     50   #define _TRG_CLS(a) _TRGC_(a->prt_ad, a->this_lane)
     51 #endif
     52 
     53 int _get_no_of_pcs_lane(PHYMOD_ST* ws);
     54 int qmod_diag_link(PHYMOD_ST *ws);
     55 int qmod_diag_st(PHYMOD_ST *ws, int resolved_speed);
     56 
     57 /**
     58 @brief   Field OVR diagnostic function
     59 @param   pc handle to current TSCE context (#PHYMOD_ST)
     60 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
     61 @details Field OVR Details
     62    Check if the field OVR is set, and if OVR enabled, print the OVR value
     63 */
     64 
     65 int qmod_diag_field_or(PHYMOD_ST *ws)
     66 {
     67    return PHYMOD_E_NONE;
     68 }
     69 
     70 /**
     71 @brief   pmd pcs lane cfg diagnostic function
     72 @param   pc handle to current TSCE context (#PHYMOD_ST)
     73 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
     74 @details Get the uc controls for pmd lane cfg
     75   Read the pcs_lane_cfg information from uc RAM. To check if the pmd is to be
     76   programmed from pcs lane cfg.
     77  */
     78 int qmod_diag_pmd_pcs_lane_cfg(PHYMOD_ST *ws, int lane)
     79 {
     80   return PHYMOD_E_NONE ;
     81 } /* qmod_diag_pmd_pcs_lane_cfg */
     82 
     83 /**
     84 @brief   Speed diagnostic function
     85 @param   pc handle to current TSCE context (#PHYMOD_ST)
     86 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
     87 @details Speed Details
     88  1. Get the Speed set
     89  2. Get the Speed valis and Speed Done Status
     90  3. Get the final stats of the speed
     91  */
     92 int qmod_diag_speed(PHYMOD_ST *ws)
     93 {
     94   return PHYMOD_E_NONE;
     95 }
     96 
     97 /**
     98 @brief   Autoneg diagnostic function
     99 @param   pc handle to current TSCE context (#PHYMOD_ST)
    100 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
    101 @details Autoneg diags
    102  1.  Get the AN complete status for AN37/73
    103  2.  Get the resolved HCD
    104  3.  Get the link up status after AN
    105 */
    106 int qmod_diag_autoneg(PHYMOD_ST *ws)
    107 {
    108   return PHYMOD_E_NONE;
    109 }
    110 
    111 /**
    112 @brief   Topology diagnostic function.
    113 @param   pc handle to current TSCE context (#PHYMOD_ST)
    114 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
    115 @details Get the topology details
    116 1. LoopBack
    117    a. Remote Loopback - RX loopback
    118       i.  PCS loopback
    119       ii. PMD loopback  //Not tested in TSCE
    120    b. Local loopback/gloop - TX loopback
    121       i.  PCS loopback
    122       ii. PMD loopback
    123 2. LaneSwap
    124    a. PCS LaneSwap(RX)
    125    b. PMD LaneSwap(TX)
    126 3. Polarity Inversion
    127    a. tx
    128    b. rx
    129 4. Master PortNum, port mode and single port mode
    130 */
    131 
    132 int qmod_diag_topology(PHYMOD_ST *ws)
    133 {
    134   MAIN_LPBK_CTLr_t pcs_loopback_ctrl;
    135   TLB_RX_DIG_LPBK_CFGr_t pmd_loopback_dig;
    136   TLB_TX_RMT_LPBK_CFGr_t pmd_loopback_remote;
    137   MAIN_LN_SWPr_t pcs_lane_swap;
    138   DIG_TX_LN_MAP_3_N_LN_ADDR_0_1r_t pmd_lane_addr_swap_1;
    139   DIG_LN_ADDR_2_3r_t pmd_lane_addr_swap_2;
    140   DIG_TX_LN_MAP_0_1_2r_t pmd_lane_addr_swap_3;
    141   TLB_TX_TLB_TX_MISC_CFGr_t tx_pol_inv;
    142   TLB_RX_TLB_RX_MISC_CFGr_t rx_pol_inv;
    143   MAIN_SETUPr_t reg_main0_setup;
    144  
    145   /* Main0 Setup Register */
    146   /*1. Loopback  */
    147   READ_MAIN_LPBK_CTLr(ws, &pcs_loopback_ctrl);
    148  
    149   READ_TLB_RX_DIG_LPBK_CFGr(ws, &pmd_loopback_dig);
    150  
    151   READ_TLB_TX_RMT_LPBK_CFGr(ws, &pmd_loopback_remote);
    152  
    153    /*2. LaneSwap  */
    154   READ_MAIN_LN_SWPr(ws, &pcs_lane_swap);
    155  
    156   READ_DIG_TX_LN_MAP_3_N_LN_ADDR_0_1r(ws, &pmd_lane_addr_swap_1);
    157   READ_DIG_LN_ADDR_2_3r(ws, &pmd_lane_addr_swap_2);
    158   READ_DIG_TX_LN_MAP_0_1_2r(ws, &pmd_lane_addr_swap_3);
    159  
    160   /*3.Polarity Inversion */
    161   READ_TLB_TX_TLB_TX_MISC_CFGr(ws, &tx_pol_inv);
    162   READ_TLB_RX_TLB_RX_MISC_CFGr(ws, &rx_pol_inv);
    163  
    164    /* 4. Master PortNum */
    165   READ_MAIN_SETUPr(ws, &reg_main0_setup);
    166  
    167   return PHYMOD_E_NONE;
    168 }
    169 
    170 /**
    171 @brief   Get the link status
    172 @param   pc handle to current TSCE context (#PHYMOD_ST)
    173 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
    174 @details Call all the Diags
    175 */
    176 int qmod_diag_general(PHYMOD_ST *ws)
    177 {
    178   qmod_diag_topology(ws);
    179   qmod_diag_link(ws);
    180   qmod_diag_autoneg(ws);
    181   qmod_diag_speed(ws);
    182 
    183   return (PHYMOD_E_NONE);
    184 }
    185 
    186 /**
    187 @brief   Get the link status
    188 @param   pc handle to current TSCE context (#PHYMOD_ST)
    189 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
    190 @details Print the link status.
    191 1. pmd_live_status
    192    a. pll_lock_sts : PMD PLL lock indication
    193    //b. tx_clk_vld_sts : The txclk is valid Don't see a need for this now, so will not check this bit
    194 2a. pmd_lane_live_status
    195    a. signal_detect_sts : The signal detected on the lane
    196    b. rx_lock_sts : The recovery clock locked for the rx lane
    197    //c. rx_clk_vld_sts : The rxclk is valid for the lane. Don't see a need for this now, so will not check this bit
    198 2b. pmd_lane_latched_status
    199 3a. pcs_live_status
    200    a. sync status : per port: Live Sync Status indicator for cl36, cl48, brcm mode. Comma detect/code sync
    201                     per lane: Live Block Lock Status indicator for cl49, cl82.Sync bits locked, on the 2 sync bits of the 66 bits(of 64/66 encoding)
    202    b. link_status : Link status for that port
    203 3b. pcs_latched_status
    204 */
    205 int qmod_diag_link(PHYMOD_ST *ws)
    206 {
    207 
    208    return PHYMOD_E_NONE;
    209 }
    210 
    211 /**
    212 @brief   Internal Tfc info (PRTP. vs. PktGen vs. MAC dataetc.).
    213 @param   pc handle to current TSCE context (#PHYMOD_ST)
    214 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_ERROR else.
    215 @details Print the Internal Tfc types.
    216 */
    217 int qmod_diag_internal_tfc(PHYMOD_ST *ws)
    218 {
    219   return PHYMOD_E_NONE;
    220 }
    221 
    222 /**
    223 @brief   Soft Table diagnostic function
    224 @param   pc handle to current TSCE context (#PHYMOD_ST)
    225 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
    226 @details ST diags
    227  Print the soft table enteries
    228  if the resolved_speed is not set, then all the table enteries are displayed
    229 */
    230 int qmod_diag_st(PHYMOD_ST *ws, int resolved_speed)
    231 {
    232   return PHYMOD_E_NONE;
    233 } /*qmod_diag_st */
    234 
    235 /**
    236 @brief   AN Timers diagnostic function
    237 @param   pc handle to current TSCE context (#PHYMOD_ST)
    238 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
    239 @details Prints the AN timers
    240 */
    241 int qmod_diag_an_timers(PHYMOD_ST* ws)
    242 {
    243   return PHYMOD_E_NONE;
    244 }
    245 
    246 /**
    247 @brief   Prints out the debug state register
    248 @param   pc handle to current TSCE context (#PHYMOD_ST)
    249 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
    250 @details Prints the debug state regs.
    251 */
    252 int qmod_diag_state(PHYMOD_ST* ws)
    253 {
    254   return PHYMOD_E_NONE;
    255 }
    256 
    257 /**
    258 @brief  TBD
    259 @param   pc handle to current TSCE context (#PHYMOD_ST)
    260 @returns PHYMOD_E_NONE if no errors. PHYMOD_E_FAIL else.
    261 @details  Misc debug
    262 */
    263 int qmod_diag_debug(PHYMOD_ST* ws)
    264 {
    265   return PHYMOD_E_NONE;
    266 }
    267 
    268 int qmod_diag_g_rd_ram(PHYMOD_ST *ws, int mode, int lane)
    269 {
    270   return PHYMOD_E_NONE ;
    271 }
    272 
    273 int qmod_diag_g_rd_uC(PHYMOD_ST *ws, int lane)
    274 {
    275   return PHYMOD_E_NONE ;
    276 }
    277 
    278 int qmod_diag_g_info(PHYMOD_ST *ws)
    279 {
    280   return PHYMOD_E_NONE ;
    281 }
    282 
    283 int qmod_diag_ieee(PHYMOD_ST *ws)
    284 {
    285   return PHYMOD_E_NONE;
    286 }
    287 
    288 /* get the no of pcs lanes */
    289 int _get_no_of_pcs_lane(PHYMOD_ST* ws)
    290 {
    291   return 0;
    292 }
    293 
    294 /*!
    295 
    296 */
    297 int qmod_diag(PHYMOD_ST *pc, qmod_diag_type diag_type)
    298 {
    299   int rv;
    300   rv = PHYMOD_E_NONE;
    301 
    302   PHYMOD_DEBUG_ERROR(("+------------------------------------------------------------------------------+\n"));
    303   if(diag_type & QMOD_DIAG_GENERAL)    rv |= qmod_diag_general(pc);
    304   if(diag_type & QMOD_DIAG_TOPOLOGY)   rv |= qmod_diag_topology(pc);
    305   if(diag_type & QMOD_DIAG_LINK)       rv |= qmod_diag_link(pc);
    306   if(diag_type & QMOD_DIAG_SPEED)      rv |= qmod_diag_speed(pc);
    307   if(diag_type & QMOD_DIAG_ANEG)       rv |= qmod_diag_autoneg(pc);
    308   if(diag_type & QMOD_DIAG_TFC)        rv |= qmod_diag_internal_tfc(pc);
    309   if(diag_type & QMOD_DIAG_AN_TIMERS)  rv |= qmod_diag_an_timers(pc);
    310   if(diag_type & QMOD_DIAG_STATE)      rv |= qmod_diag_state(pc);
    311   if(diag_type & QMOD_DIAG_DEBUG)      rv |= qmod_diag_debug(pc);
    312   return rv;
    313 }
    314 
    315 /*!
    316 */
    317 int qmod_diag_disp(PHYMOD_ST *pc, const char* cmd_str)
    318 {
    319     qmod_diag_type type;
    320 
    321     if (!cmd_str)
    322         type = QMOD_DIAG_GENERAL;
    323     else if (!PHYMOD_STRCMP(cmd_str, "topo"))
    324         type = QMOD_DIAG_TOPOLOGY;
    325     else if (!PHYMOD_STRCMP(cmd_str, "link"))
    326         type = QMOD_DIAG_LINK;
    327     else if (!PHYMOD_STRCMP(cmd_str, "speed"))
    328         type = QMOD_DIAG_SPEED;
    329     else if (!PHYMOD_STRCMP(cmd_str, "aneg"))
    330         type = QMOD_DIAG_ANEG;
    331     else if (!PHYMOD_STRCMP(cmd_str, "tfc"))
    332         type = QMOD_DIAG_TFC;
    333     else if (!PHYMOD_STRCMP(cmd_str, "antimers"))
    334         type = QMOD_DIAG_AN_TIMERS;
    335     else if (!PHYMOD_STRCMP(cmd_str, "state"))
    336         type = QMOD_DIAG_STATE;
    337     else if (!PHYMOD_STRCMP(cmd_str, "debug"))
    338         type = QMOD_DIAG_DEBUG;
    339     else
    340         type = QMOD_DIAG_GENERAL;
    341 
    342     return (qmod_diag(pc, type));
    343 }
    344 
    345 
    346