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

prbs.h (4111B)


      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  * File:       prbs.h
      8  */
      9 
     10 #ifndef _PRBS_H_
     11 #define _PRBS_H_
     12 
     13 #include "types.h"
     14 #include "error.h"
     15 #include "bcm_utils.h"
     16 
     17 
     18 /*!
     19  * @enum bcm_pe_prbs_poly_e
     20  * @brief PRBS polynomial 
     21  */ 
     22 typedef enum bcm_pe_prbs_poly_e {
     23     PrbsPoly7 = 0,
     24     PrbsPoly9,
     25     PrbsPoly11,
     26     PrbsPoly15,
     27     PrbsPoly23,
     28     PrbsPoly31,
     29     PrbsPoly58,
     30     PrbsPolyCount
     31 } bcm_pe_prbs_poly_t;
     32 
     33 /** PRBS Checker Mode Enum */
     34 typedef enum srds_prbs_checker_mode_e {
     35   PRBS_SELF_SYNC_HYSTERESIS       = 0,
     36   PRBS_INITIAL_SEED_HYSTERESIS    = 1,
     37   PRBS_INITIAL_SEED_NO_HYSTERESIS = 2
     38 } srds_prbs_checker_mode_t;
     39 
     40 /*!
     41  * @enum bcm_pe_prbs_action_e
     42  * @brief PRBS action 
     43  */ 
     44 typedef enum bcm_pe_prbs_action_e {
     45     PrbsActionSet = 0,
     46     PrbsActionGet,
     47     PrbsActionClear,
     48     PrbsActionCount
     49 } bcm_pe_prbs_action_t;
     50 
     51 /*!
     52  * @enum bcm_pe_prbs_dir_e
     53  * @brief PRBS direction 
     54  */ 
     55 typedef enum bcm_pe_prbs_dir_e {
     56     PrbsDirTxRx = 0,
     57     PrbsDirRx,
     58     PrbsDirTx,
     59     PrbsDirCount
     60 } bcm_pe_prbs_dir_t;
     61 
     62 /*! 
     63  * @brief RX/TX selector. no flags means both 
     64  */ 
     65 #define BCM_PE_PRBS_DIRECTION_RX 0x1 /**< Config RX */
     66 #define BCM_PE_PRBS_DIRECTION_TX 0x2 /**< Config TX */
     67 
     68 #define BCM_PE_PRBS_DIRECTION_RX_SET(flags) (flags |= BCM_PE_PRBS_DIRECTION_RX)
     69 #define BCM_PE_PRBS_DIRECTION_TX_SET(flags) (flags |= BCM_PE_PRBS_DIRECTION_TX)
     70 
     71 #define BCM_PE_PRBS_DIRECTION_RX_CLR(flags) (flags &= ~BCM_PE_PRBS_DIRECTION_RX)
     72 #define BCM_PE_PRBS_DIRECTION_TX_CLR(flags) (flags &= ~BCM_PE_PRBS_DIRECTION_TX)
     73 
     74 #define BCM_PE_PRBS_DIRECTION_RX_GET(flags) (flags & BCM_PE_PRBS_DIRECTION_RX ? 1 : 0)
     75 #define BCM_PE_PRBS_DIRECTION_TX_GET(flags) (flags & BCM_PE_PRBS_DIRECTION_TX ? 1 : 0)
     76 
     77 /*!
     78  * @struct bcm_pe_prbs_s
     79  * @brief PRBS control 
     80  */ 
     81 typedef struct bcm_pe_prbs_s {
     82     bcm_pe_prbs_poly_t  poly;
     83     uint32              invert;
     84 } bcm_pe_prbs_t;
     85 
     86 /*!
     87  * @struct bcm_pe_prbs_status_s
     88  * @brief PRBS status 
     89  */ 
     90 typedef struct bcm_pe_prbs_status_s {
     91     uint32 prbs_lock;       /**< Whether PRBS is currently locked */
     92     uint32 prbs_lock_loss;  /**< Whether PRBS was unlocked since last call */
     93     uint32 error_count;     /**< PRBS errors count */
     94 } bcm_pe_prbs_status_t;
     95 
     96 
     97 
     98 /*! 
     99  * bcm_pe_prbs_config_set
    100  *
    101  * @brief set/get PRBS configuration 
    102  *
    103  * @param [in]  pa              - phy access information
    104  * @param [in]  flags           - see BCM_PE_PRBS_DIRECTION_
    105  * @param [in]  prbs            - PRBS configuration to set
    106  */
    107 int bcm_pe_prbs_config_set(phy_ctrl_t *pa, uint32 flags , bcm_pe_prbs_t *prbs);
    108 
    109 /*! 
    110  * bcm_pe_prbs_config_get
    111  *
    112  * @brief set/get PRBS configuration 
    113  *
    114  * @param [in]  pa              - phy access information
    115  * @param [in]  flags           - see BCM_PE_PRBS_DIRECTION_
    116  * @param [out]  prbs           - PRBS configuration
    117  */
    118 int bcm_pe_prbs_config_get(phy_ctrl_t *pa, uint32 flags , bcm_pe_prbs_t *prbs);
    119 
    120 /*! 
    121  * bcm_pe_prbs_enable_set
    122  *
    123  * @brief Set/get PRBS enable state 
    124  *
    125  * @param [in]  pa              - phy access information
    126  * @param [in]  flags           - see BCM_PE_PRBS_DIRECTION_
    127  * @param [in]  enable          - Enable \ disable PRBS
    128  */
    129 int bcm_pe_prbs_enable_set(phy_ctrl_t *pa, uint32 flags , uint32 enable);
    130 
    131 /*! 
    132  * bcm_pe_prbs_enable_get
    133  *
    134  * @brief Set/get PRBS enable state 
    135  *
    136  * @param [in]  pa              - phy access information
    137  * @param [in]  flags           - see BCM_PE_PRBS_DIRECTION_
    138  * @param [out]  enable         - PRBS state
    139  */
    140 int bcm_pe_prbs_enable_get(phy_ctrl_t *pa, uint32 flags , uint32 *enable);
    141 
    142 /*! 
    143  * bcm_pe_prbs_status_get
    144  *
    145  * @brief Get PRBS Status 
    146  *
    147  * @param [in]  pa              - phy access information
    148  * @param [in]  flags           - see BCM_PE_PRBS_DIRECTION_
    149  * @param [out]  prbs_status    - PRBS status
    150  */
    151 int bcm_pe_prbs_status_get(phy_ctrl_t *pa, uint32 flags, bcm_pe_prbs_status_t *prbs_status);
    152 
    153 int bcm_do_prbs(phy_ctrl_t *pc, int sys_port, int action, int dir, int poly, int invert);
    154 
    155 
    156 #endif /* _PRBS_H_ */
    157