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

portmod_common.h (15393B)


      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 #ifndef _PORTMOD_COMMON_H_
     11 #define _PORTMOD_COMMON_H_
     12 
     13 #include <soc/phyctrl.h>
     14 #include <soc/portmod/portmod_internal.h>
     15 #include <shared/port.h>
     16 
     17 #define  PORTMOD_PORT_PHY_LANE_CONFIG_DFE_SET(lane_config)        _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_DFE_SET(lane_config)
     18 #define  PORTMOD_PORT_PHY_LANE_CONFIG_DFE_CLEAR(lane_config)      _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_DFE_CLEAR(lane_config)
     19 #define  PORTMOD_PORT_PHY_LANE_CONFIG_DFE_GET(lane_config)        _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_DFE_GET(lane_config)
     20 #define  PORTMOD_PORT_PHY_LANE_CONFIG_LP_DFE_SET(lane_config)     _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_LP_DFE_SET(lane_config)
     21 #define  PORTMOD_PORT_PHY_LANE_CONFIG_LP_DFE_CLEAR(lane_config)   _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_LP_DFE_CLEAR(lane_config)
     22 #define  PORTMOD_PORT_PHY_LANE_CONFIG_LP_DFE_GET(lane_config)     _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_LP_DFE_GET(lane_config)
     23 #define  PORTMOD_PORT_PHY_LANE_CONFIG_BR_DFE_SET(lane_config)     _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_BR_DFE_SET(lane_config)
     24 #define  PORTMOD_PORT_PHY_LANE_CONFIG_BR_DFE_CLEAR(lane_config)   _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_BR_DFE_CLEAR(lane_config)
     25 #define  PORTMOD_PORT_PHY_LANE_CONFIG_BR_DFE_GET(lane_config)     _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_BR_DFE_GET(lane_config)
     26 #define  PORTMOD_PORT_PHY_LANE_CONFIG_MEDIUM_SET(lane_config, medium_type) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_MEDIUM_SET(lane_config, medium_type)
     27 #define  PORTMOD_PORT_PHY_LANE_CONFIG_MEDIUM_GET(lane_config)     _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_MEDIUM_GET(lane_config)
     28 #define  PORTMOD_PORT_PHY_LANE_CONFIG_MEDIUM_CLEAR(lane_config)   _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_MEDIUM_CLEAR(lane_config)
     29 #define  PORTMOD_PORT_PHY_LANE_CONFIG_UNRELIABLE_LOS_SET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_UNRELIABLE_LOS_SET(lane_config)
     30 #define  PORTMOD_PORT_PHY_LANE_CONFIG_UNRELIABLE_LOS_CLEAR(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_UNRELIABLE_LOS_CLEAR(lane_config)
     31 #define  PORTMOD_PORT_PHY_LANE_CONFIG_UNRELIABLE_LOS_GET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_UNRELIABLE_LOS_GET(lane_config)
     32 #define  PORTMOD_PORT_PHY_LANE_CONFIG_SCRAMBLING_DISABLE_SET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_SCRAMBLING_DISABLE_SET(lane_config)
     33 #define  PORTMOD_PORT_PHY_LANE_CONFIG_SCRAMBLING_DISABLE_CLEAR(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_SCRAMBLING_DISABLE_CLEAR(lane_config)
     34 #define  PORTMOD_PORT_PHY_LANE_CONFIG_SCRAMBLING_DISABLE_GET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_SCRAMBLING_DISABLE_GET(lane_config)
     35 #define  PORTMOD_PORT_PHY_LANE_CONFIG_CL72_POLARITY_AUTO_EN_SET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_CL72_POLARITY_AUTO_EN_SET(lane_config)
     36 #define  PORTMOD_PORT_PHY_LANE_CONFIG_CL72_POLARITY_AUTO_EN_CLEAR(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_CL72_POLARITY_AUTO_EN_CLEAR(lane_config)
     37 #define  PORTMOD_PORT_PHY_LANE_CONFIG_CL72_POLARITY_AUTO_EN_GET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_CL72_POLARITY_AUTO_EN_GET(lane_config)
     38 #define  PORTMOD_PORT_PHY_LANE_CONFIG_CL72_RESTART_TIMEOUT_EN_SET(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_CL72_RESTART_TIMEOUT_EN_SET(lane_config)
     39 #define  PORTMOD_PORT_PHY_LANE_CONFIG_CL72_RESTART_TIMEOUT_EN_CLEAR(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_CL72_RESTART_TIMEOUT_EN_CLEAR(lane_config)
     40 #define  PORTMOD_PORT_PHY_LANE_CONFIG_CL72_RESTART_TIMEOUT_EN_GET(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_CL72_RESTART_TIMEOUT_EN_GET(lane_config)
     41 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_ES_SET(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_ES_SET(lane_config)
     42 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_ES_CLEAR(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_ES_CLEAR(lane_config)
     43 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_ES_GET(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_ES_GET(lane_config)
     44 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_NS_SET(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_NS_SET(lane_config)
     45 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_NS_CLEAR(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_NS_CLEAR(lane_config)
     46 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_NS_GET(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_NS_GET(lane_config)
     47 #define  PORTMOD_PORT_PHY_LANE_CONFIG_LP_PREC_EN_SET(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_LP_PREC_EN_SET(lane_config)
     48 #define  PORTMOD_PORT_PHY_LANE_CONFIG_LP_PREC_EN_CLEAR(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_LP_PREC_EN_CLEAR(lane_config)
     49 #define  PORTMOD_PORT_PHY_LANE_CONFIG_LP_PREC_EN_GET(lane_config)  _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_LP_PREC_EN_GET(lane_config)
     50 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_PAM4_SET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_PAM4_SET(lane_config)
     51 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_PAM4_CLEAR(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_PAM4_CLEAR(lane_config)
     52 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_PAM4_GET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_PAM4_GET(lane_config)
     53 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_NRZ_SET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_NRZ_SET(lane_config)
     54 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_NRZ_CLEAR(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_NRZ_CLEAR(lane_config)
     55 #define  PORTMOD_PORT_PHY_LANE_CONFIG_FORCE_NRZ_GET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_FORCE_NRZ_GET(lane_config)
     56 #define  PORTMOD_PORT_PHY_LANE_CONFIG_PAM4_CHANNEL_LOSS_SET(lane_config, channel_loss) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_PAM4_CHANNEL_LOSS_SET(lane_config, channel_loss)
     57 #define  PORTMOD_PORT_PHY_LANE_CONFIG_PAM4_CHANNEL_LOSS_GET(lane_config) _SHR_PORT_RESOURCE_PHY_LANE_CONFIG_PAM4_CHANNEL_LOSS_GET(lane_config)
     58 
     59 
     60 int portmod_port_chain_core_access_get(int unit, int port, pm_info_t pm_info, phymod_core_access_t* core_access_arr, int max_buf, int* nof_cores);
     61 int portmod_port_chain_phy_access_get(int unit, int port, pm_info_t pm_info, phymod_phy_access_t* core_access_arr, int max_buf, int* nof_cores);
     62 
     63 int portmod_common_phy_prbs_config_set(int unit, int port, pm_info_t pm_info, int flags, const phymod_prbs_t* config);
     64 int portmod_common_phy_prbs_config_get(int unit, int port, pm_info_t pm_info, int flags, phymod_prbs_t* config);
     65 int portmod_common_phy_prbs_enable_set(int unit, int port, pm_info_t pm_info, int flags, int enable);
     66 int portmod_common_phy_prbs_enable_get(int unit, int port, pm_info_t pm_info, int flags, int* enable);
     67 int portmod_common_phy_prbs_status_get(int unit, int port, pm_info_t pm_info, int flags, phymod_prbs_status_t* status);
     68 int portmod_common_phy_loopback_set(int unit, int port, pm_info_t pm_info, portmod_loopback_mode_t loopback_type, int enable);
     69 int portmod_common_phy_loopback_get(int unit, int port, pm_info_t pm_info, portmod_loopback_mode_t loopback_type, int *enable);
     70 int portmod_common_phy_firmware_mode_set(int unit, int port, phymod_firmware_mode_t fw_mode);
     71 int portmod_common_phy_firmware_mode_get(int unit, int port, phymod_firmware_mode_t *fw_mode);
     72 
     73 int portmod_common_pmd_lane_config_encode(portmod_pmd_lane_config_t* portmod_lane_config, uint32_t* lane_config);
     74 int portmod_common_pmd_lane_config_decode(uint32_t lane_config, portmod_pmd_lane_config_t* portmod_lane_config);
     75 
     76 int portmod_common_phy_sbus_reg_write(soc_mem_t reg_access_mem, void* user_acc, uint32_t core_addr, uint32_t reg_addr, uint32_t val);
     77 int portmod_common_phy_sbus_reg_read(soc_mem_t reg_access_mem, void* user_acc, uint32_t core_addr, uint32_t reg_addr, uint32_t *val);
     78 int portmod_common_mutex_take(void* user_acc);
     79 int portmod_common_mutex_give(void* user_acc);
     80 
     81 int portmod_commmon_portmod_to_phymod_loopback_type(int unit, portmod_loopback_mode_t loopback_type, phymod_loopback_mode_t *phymod_lb_type);
     82 
     83 void portmod_common_phy_to_port_ability (phymod_autoneg_ability_t *phyAbility,
     84                                          portmod_port_ability_t *portAbility);
     85 void portmod_common_port_to_phy_ability (portmod_port_ability_t *portAbility,
     86                                          phymod_autoneg_ability_t *phyAbility,
     87                                          int port_num_lanes,
     88                                          int line_interface,
     89                                          int cx4_10g,
     90                                          int an_cl72,
     91                                          int an_fec,
     92                                          int hg_mode);
     93 
     94 /* Redirect Functions */
     95 int portmod_port_redirect_loopback_set(int unit, soc_port_t port,
     96                                    int phyn, int phy_lane,
     97                                    int sys_side, uint32 enable);
     98 int portmod_port_redirect_loopback_get(int unit, soc_port_t port,
     99                                    int phyn, int phy_lane,
    100                                    int sys_side, uint32 *enable);
    101 
    102 int portmod_port_redirect_autoneg_set(int unit, soc_port_t port,
    103                                    int phyn, int phy_lane,
    104                                    int sys_side, phymod_autoneg_control_t* an);
    105 int portmod_port_redirect_autoneg_get(int unit, soc_port_t port,
    106                                    int phyn, int phy_lane,
    107                                    int sys_side, phymod_autoneg_control_t* an);
    108 
    109 /* FIRMWARE LOAD */
    110 
    111 typedef enum portmod_ucode_buf_order_e {
    112     portmod_ucode_buf_order_straight = 0,
    113     portmod_ucode_buf_order_half,
    114     portmod_ucode_buf_order_reversed
    115 } portmod_ucode_buf_order_t;
    116 
    117 typedef struct portmod_ucode_buf_s {
    118     void        *ucode_dma_buf;  /* DMA buffer for firmware load */
    119     uint32      ucode_alloc_size; /* DMA buffer firmware size */
    120 } portmod_ucode_buf_t;
    121 
    122 int
    123 portmod_firmware_set(int unit,
    124                      int blk_id,
    125                      const uint8 *array,
    126                      uint32 datalen,
    127                      portmod_ucode_buf_order_t data_swap,
    128                      int bcast_en,
    129                      portmod_ucode_buf_t* buf,
    130                      portmod_ucode_buf_t* buf_2nd,
    131                      soc_mem_t ucmem_data,
    132                      soc_reg_t ucmem_ctrl);
    133 
    134 int portmod_intf_from_phymod_intf (int unit,
    135                                    phymod_interface_t phymod_interface,
    136                                    soc_port_if_t *interface);
    137 int portmod_intf_to_phymod_intf (int unit, int speed, soc_port_if_t interface,
    138                                        phymod_interface_t *phymod_interface);
    139 
    140 int portmod_line_intf_from_config_get(const portmod_port_interface_config_t *config, soc_port_if_t *interface);
    141 
    142 /* Simulator */
    143 extern phymod_bus_t sim_bus;
    144 
    145 /* These 2 functions below are a temporary fix - FIX IT */
    146 int portmod_port_status_notify(int unit, int  port, int link);
    147 int portmod_port_flags_test(int unit, soc_port_t port, int flag);
    148 
    149 #define PORTMOD_CORE_TO_PHY_ACCESS(_phy_access, _core_access) \
    150     do{\
    151         PHYMOD_MEMCPY(&(_phy_access)->access, &(_core_access)->access, sizeof((_phy_access)->access));\
    152         (_phy_access)->type = (_core_access)->type; \
    153     }while(0)
    154 
    155 int portmod_ext_to_int_cmd_set(int unit, int port, portmod_ext_to_int_phy_ctrlcode_t cmd, void *pdata);
    156 int portmod_ext_to_int_cmd_get(int unit, int port, portmod_ext_to_int_phy_ctrlcode_t cmd, void *pdata);
    157 
    158 int portmod_port_is_legacy_ext_phy_present(int unit, int port, int *is_legacy_present);
    159 
    160 
    161 int portmod_port_ext_phy_control_set(int unit, int port, int phyn, int phy_lane, int sys_side,
    162                                      soc_phy_control_t control, uint32 value);
    163 int portmod_port_ext_phy_control_get(int unit, int port, int phyn, int phy_lane, int sys_side,
    164                                      soc_phy_control_t control, uint32* value);
    165 
    166 int portmod_port_ext_phy_mdix_set(int unit, int port, soc_port_mdix_t mode);
    167 int portmod_port_ext_phy_mdix_get(int unit, int port, soc_port_mdix_t *mode);
    168 int portmod_port_ext_phy_mdix_status_get(int unit, soc_port_t port,
    169                                          soc_port_mdix_status_t *status);
    170 
    171 int phy_portmod_dispatch_ability_get(int unit, soc_port_t port, soc_port_ability_t *ability);
    172 int phy_portmod_dispatch_interface_set(int unit, soc_port_t port, soc_port_if_t pif);
    173 int phy_portmod_dispatch_nocxn_interface_get(int unit, soc_port_t port, soc_port_if_t *pif);
    174 
    175 int portmod_pm_phy_control_set(phymod_phy_access_t*, int, soc_phy_control_t, 
    176                                phymod_tx_t*, uint32, uint32 v);
    177 int portmod_pm_phy_control_get(phymod_phy_access_t*, int, soc_phy_control_t, 
    178                                phymod_tx_t*, uint32, uint32 *v);
    179 
    180 int portmod_pm_phy_link_mon_enable_set (phymod_phy_access_t*, int, uint32);
    181 int portmod_pm_phy_link_mon_status_get (phymod_phy_access_t*, int);
    182 
    183 int portmod_pm_phy_ber_proj(phymod_phy_access_t *phy_access, soc_port_phy_ber_proj_params_t *args);
    184 
    185 int portmod_pm_phy_rsfec_symb_err_get(phymod_phy_access_t *phy_access,
    186                                       soc_port_phy_rsfec_symb_errcnt_t *args);
    187 
    188 int portmod_common_timesync_config_set(const phymod_phy_access_t* phy_access,
    189                                        const portmod_phy_timesync_config_t* conf);
    190 int portmod_common_timesync_config_get(const phymod_phy_access_t* phy_access,
    191                                        portmod_phy_timesync_config_t* conf);
    192 int portmod_common_control_phy_timesync_set(const phymod_phy_access_t* phy_access,
    193                                             const portmod_port_control_phy_timesync_t type,
    194                                             const uint64 value);
    195 int portmod_common_control_phy_timesync_get(const phymod_phy_access_t* phy_access,
    196                                             const portmod_port_control_phy_timesync_t type,
    197                                             uint64* value);
    198 int portmod_common_ext_phy_fw_bcst(int unit, pbmp_t *pbmp);
    199 int portmod_common_ext_phy_core_reset_for_fw_load(int unit);
    200 int portmod_common_ext_phy_precondition(int unit);
    201 
    202 int portmod_media_type_from_port_intf(int unit,
    203                                     soc_port_if_t interface,
    204                                     phymod_phy_inf_config_t *phy_interface_config);
    205 int portmod_intf_mode_from_phymod_intf(int unit,
    206                                     phymod_interface_t phymod_interface,
    207                                     phymod_phy_inf_config_t *phy_interface_config);
    208 
    209 /*!
    210  * portmod_port_phy_drv_name_get
    211  *
    212  * @brief Get the phy driver name attached to the port
    213  *
    214  * @param [in]  unit     - unit id
    215  * @param [in]  port     - port num
    216  * @param [out] name     - phy driver name.
    217  * @param [in]  len      - max length of the name buffer.
    218  */
    219 int portmod_port_phy_drv_name_get(int unit, int port, char *name, int len);
    220 
    221 int portmod_common_default_interface_get(portmod_port_interface_config_t* interface_config);
    222 
    223 int portmod_common_serdes_probe(const phymod_dispatch_type_t* type_list,
    224                                 phymod_core_access_t* core_access, int* probe);
    225 int portmod_common_ext_phy_probe(int unit, int port, phymod_core_access_t* core_access, int* probe);
    226 
    227 int portmod_pm_capability_get(int unit, portmod_dispatch_type_t pm_type, portmod_pm_capability_t* pm_cap);
    228 #ifdef FW_BCAST_DOWNLOAD
    229 int portmod_common_serdes_fw_bcst(int unit, pbmp_t pbmp, int crc_enable);
    230 #endif
    231 #endif /*_PORTMOD_COMMON_H_*/