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

stk_sys.h (14236B)


      1 /** \file stk/stk_sys.h
      2  *
      3  * Switch system procedures.
      4  *
      5  * FAP_ID, System Ports, Module Ports ...
      6  */
      7 /*
      8  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      9  * 
     10  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
     11  */
     12 #ifndef DNX_STK_SYS_H_INCLUDED
     13 /*
     14  * {
     15  */
     16 #define DNX_STK_SYS_H_INCLUDED
     17 
     18 #ifndef BCM_DNX_SUPPORT
     19 #error "This file is for use by DNX family only!"
     20 #endif
     21 
     22 /*
     23  * }
     24  */
     25 /*
     26  * Include files.
     27  * {
     28  */
     29 #include <bcm/error.h>
     30 #include <bcm/types.h>
     31 #include <bcm/stack.h>
     32 
     33 #include <shared/shrextend/shrextend_debug.h>
     34 #include <soc/dnx/dbal/dbal.h>
     35 
     36 /*
     37  * }
     38  */
     39 
     40 /**
     41  * \brief - Set dedicated FMQ system port. The system port should be mapped to local fap modid since enhanced FMQ
     42  * credits are recieved from local fap.
     43  * \param [in] unit - Unit #
     44  * \param [in] core - Core #
     45  * \param [in] my_modid - Local modid.
     46  */
     47 shr_error_e dnx_stk_sys_fmq_sysport_set(
     48     int unit,
     49     bcm_core_t core,
     50     uint32 my_modid);
     51 
     52 /**
     53  * \brief
     54  * Set core modid (FAP ID).
     55  * Setting modid must be the first step after 'bcm_init()' in user application.
     56  *
     57  * \param [in] unit - Unit #
     58  * \param [in] core - Core #
     59  * \param [in] fap_id_index - Index of FAP ID inside the core
     60  * \param [out] modid - modid.
     61  *
     62  * \return
     63  *     see shr_error_e
     64  * \remark
     65  *   * None
     66  * \see
     67  *   * None
     68  */
     69 shr_error_e dnx_stk_sys_modid_add(
     70     int unit,
     71     bcm_core_t core,
     72     int fap_id_index,
     73     uint32 modid);
     74 
     75 /**
     76  * \brief
     77  * Get core modid (FAP_ID)
     78  *
     79  * \param [in] unit - Unit #
     80  * \param [in] core - Core #
     81  * \param [in] fap_id_index - FAP ID index inside the core #
     82  * \param [out] modid - module id
     83  *
     84  * \return
     85  *     see shr_error_e
     86  * \remark
     87  *   * None
     88  * \see
     89  *   * None
     90  */
     91 shr_error_e dnx_stk_sys_modid_get(
     92     int unit,
     93     bcm_core_t core,
     94     int fap_id_index,
     95     uint32 *modid);
     96 
     97 /**
     98  * \brief
     99  * Get all FAP IDs of specific core
    100  *
    101  * \param [in] unit - Unit #
    102  * \param [in] core - core ID #
    103  * \param [out] modid - array of modid(s)
    104  * \param [out] modid_count - number of returned modid(s)
    105  *
    106  * \return
    107  *     see shr_error_e
    108  * \remark
    109  *   * modid array should be at least of size dnx_data_device.general.max_nof_fap_ids_per_core_get(unit)
    110  * \see
    111  *   * None
    112  */
    113 shr_error_e dnx_stk_sys_modid_get_all(
    114     int unit,
    115     bcm_core_t core,
    116     uint32 *modid,
    117     int *modid_count);
    118 
    119 /**
    120  * \brief
    121  * Get the core set to modid, or -1 if modid is not local.
    122  *
    123  * \param [in] unit - Unit #
    124  * \param [in] modid - required modid #
    125  * \param [out] core - local core # or -1
    126  * \param [out] fap_id_index - index of modid inside the core
    127  *
    128  * \return
    129  *     see shr_error_e
    130  * \remark
    131  *   * None
    132  * \see
    133  *   * None
    134  */
    135 shr_error_e dnx_stk_sys_modid_local_core_get(
    136     int unit,
    137     uint32 modid,
    138     bcm_core_t * core,
    139     int *fap_id_index);
    140 
    141 /**
    142  * \brief
    143  * Return TRUE iff modid is local
    144  *
    145  * \param [in] unit - Unit #
    146  * \param [in] modid - required modid #
    147  * \param [out] is_local - is modid local
    148  *
    149  * \return
    150  *     see shr_error_e
    151  * \remark
    152  *   * None
    153  * \see
    154  *   * None
    155  */
    156 shr_error_e dnx_stk_sys_modid_is_local_get(
    157     int unit,
    158     uint32 modid,
    159     int *is_local);
    160 
    161 /**
    162  * \brief
    163  * Convert core and TM port to modport gport
    164  *
    165  * \param [in] unit - Unit #
    166  * \param [in] core_id - local core #
    167  * \param [in] tm_port - TM port #
    168  * \param [out] modid - modid #
    169  * \param [out] ftmh_pp_dsp - FTMH PP DSP #
    170  *
    171  * \return
    172  *     see shr_error_e
    173  * \remark
    174  *   * None
    175  * \see
    176  *   * None
    177  */
    178 shr_error_e dnx_stk_sys_tm_port_to_modport_convert(
    179     int unit,
    180     bcm_core_t core_id,
    181     int tm_port,
    182     int *modid,
    183     int *ftmh_pp_dsp);
    184 
    185 /**
    186  * \brief
    187  * Convert core and TM port to modport gport
    188  *
    189  * \param [in] unit - Unit #
    190  * \param [in] core_id - local core #
    191  * \param [in] tm_port - TM port #
    192  * \param [out] modport_gport - modport gport #
    193  *
    194  * \return
    195  *     see shr_error_e
    196  * \remark
    197  *   * None
    198  * \see
    199  *   * None
    200  */
    201 shr_error_e dnx_stk_sys_tm_port_to_modport_gport_convert(
    202     int unit,
    203     bcm_core_t core_id,
    204     int tm_port,
    205     bcm_gport_t * modport_gport);
    206 /**
    207  * \brief
    208  * Convert modport gport to core and TM port
    209  *
    210  * \param [in] unit - Unit #
    211  * \param [in] modport_gport - modport gport #
    212  * \param [out] core_id - local core #
    213  * \param [out] tm_port - TM port #
    214  *
    215  * \return
    216  *     see shr_error_e
    217  * \remark
    218  *   * None
    219  * \see
    220  *   * None
    221  */
    222 shr_error_e dnx_stk_sys_modport_gport_to_tm_port_convert(
    223     int unit,
    224     bcm_gport_t modport_gport,
    225     bcm_core_t * core_id,
    226     int *tm_port);
    227 
    228 /**
    229  * \brief
    230  * Convert modport gport to core and TM port
    231  *
    232  * \param [in] unit - Unit #
    233  * \param [in] modid - destination FAP
    234  * \param [in] ftmh_pp_dsp - FTMH PP DSP
    235  * \param [out] core_id - local core #
    236  * \param [out] tm_port - TM port #
    237  *
    238  * \return
    239  *     see shr_error_e
    240  * \remark
    241  *   * None
    242  * \see
    243  *   * None
    244  */
    245 shr_error_e dnx_stk_sys_modport_to_tm_port_convert(
    246     int unit,
    247     int modid,
    248     int ftmh_pp_dsp,
    249     bcm_core_t * core_id,
    250     int *tm_port);
    251 
    252 /**
    253  * \brief
    254  * Map system port to module port.
    255  * This API configures mapping relevant for local ports and mapping relevant for remote ports.
    256  * This API configures both TM and PP mapping.
    257  *
    258  * \param [in] unit - Unit #
    259  * \param [in] core - Core #
    260  * \param [in] sysport - system port (not system gport)
    261  * \param [in] modid - destination FAP
    262  * \param [in] tm_port - destination tm port
    263  *
    264  * \return
    265  *     see shr_error_e
    266  * \remark
    267  *   * None
    268  * \see
    269  *   * None
    270  */
    271 shr_error_e dnx_stk_sys_sysport_modport_map_set(
    272     int unit,
    273     int core,
    274     uint32 sysport,
    275     uint32 modid,
    276     uint32 tm_port);
    277 
    278 /**
    279  * \brief
    280  * Get module port given system port.
    281  *
    282  * \param [in] unit - Unit #
    283  * \param [in] sysport - system port (not system gport)
    284  * \param [out] modid - destination FAP
    285  * \param [out] tm_port - destination tm port
    286  *
    287  * \return
    288  *     see shr_error_e
    289  * \remark
    290  *   * None
    291  * \see
    292  *   * None
    293  */
    294 shr_error_e dnx_stk_sys_sysport_modport_map_get(
    295     int unit,
    296     uint32 sysport,
    297     uint32 *modid,
    298     uint32 *tm_port);
    299 /**
    300  * \brief
    301  * Map logical port to systemport.
    302  *
    303  * \param [in] unit - Unit #
    304  * \param [in] logical_port - logical_port #
    305  * \param [in] sysport - system port (not system gport)
    306  *
    307  * \return
    308  *     see shr_error_e
    309  * \remark
    310  *   * None
    311  * \see
    312  *   * None
    313  */
    314 shr_error_e dnx_stk_sys_logical_port_to_sysport_map_set(
    315     int unit,
    316     bcm_port_t logical_port,
    317     uint32 sysport);
    318 /**
    319  * \brief
    320  * Get system port given a logical port.
    321  *
    322  * \param [in] unit - Unit #
    323  * \param [in] logical_port - logical_port #
    324  * \param [out] sysport - system port (not system gport)
    325  *
    326  * \return
    327  *     see shr_error_e
    328  * \remark
    329  *   * None
    330  * \see
    331  *   * None
    332  */
    333 shr_error_e dnx_stk_sys_logical_port_to_sysport_map_get(
    334     int unit,
    335     bcm_port_t logical_port,
    336     uint32 *sysport);
    337 /**
    338  * \brief
    339  * Clear all local tm ports that mapped to system port.
    340  *
    341  * \param [in] unit - Unit #
    342  * \param [in] sysport - system port (not system gport)
    343  *
    344  * \return
    345  *     see shr_error_e
    346  * \remark
    347  *   * None
    348  * \see
    349  *   * None
    350  */
    351 shr_error_e dnx_stk_sys_sysport_map_clear(
    352     int unit,
    353     uint32 sysport);
    354 
    355 /**
    356  * \brief - Disable device traffic during init sequence (Stop receiving and transmitting traffic).
    357  * This function is used as a wrapper for init sequence since init sequence invokes functions only with
    358  * 'unit' argument.
    359  *
    360  * \param [in] unit - Unit ID
    361  *
    362  * \return
    363  *   shr_error_e
    364  *
    365  * \remark
    366  *  This function should be invoked during init sequence as one of the first steps (before HW is accessed).
    367  *  Meaning that this function should be invoked right after access is initiated.
    368  *  The reason to disable traffic before any access is because some HW configurations must not be done during traffic,
    369  *  so it's expected from the application to re enable traffic after it's done with all the required configurations.
    370  *
    371  * \see
    372  *   * dnx_stk_sys_traffic_enable()
    373  */
    374 shr_error_e dnx_stk_sys_traffic_disable(
    375     int unit);
    376 
    377 /**
    378  * \brief - Enable/Disable device traffic. Stop/Start receiving and transmitting traffic.
    379  *
    380  * \param [in] unit - Unit ID
    381  * \param [in] enable - 0 means disable traffic, 1 means enable
    382  *
    383  * \return
    384  *   shr_error_e
    385  *
    386  * \remark
    387  *  Traffic should be disabled before changing HW configuration that should not be changed during traffic.
    388  *  After the changes are done, the user should re enable traffic.
    389  *
    390  * \see
    391  *   * None
    392  */
    393 shr_error_e dnx_stk_sys_traffic_enable_set(
    394     int unit,
    395     int enable);
    396 
    397 /**
    398  * \brief - Get whether device traffic is Enabled/Disabled.
    399  *
    400  * \param [in] unit - Unit ID
    401  * \param [out] enable - 0 means traffic disabled, 1 means enabled
    402  *
    403  * \return
    404  *   shr_error_e
    405  *
    406  * \remark
    407  *   * None
    408  *
    409  * \see
    410  *   * dnx_stk_sys_traffic_enable_set
    411  */
    412 shr_error_e dnx_stk_sys_traffic_enable_get(
    413     int unit,
    414     int *enable);
    415 
    416 /**
    417  * \brief
    418  *   Exclude/Include modid from all-reachable vector.
    419  *   Up to 16 modids can be excluded.
    420  *   There are 2 ways to exclude modids from all-reachable vector:
    421  *     1. Set maximum modid to be included in the vector. All modids
    422  *        in the range above max won't be included in the vector.
    423  *     2. Exclude specific modids from the vector.
    424  *
    425  *   This function implements option 2 .
    426  * \param [in] unit -
    427  *   The unit number.
    428  * \param [in] module -
    429  *   The module id to be excluded/included.
    430  * \param [in] enable -
    431  *   - True  - Exclude modid from all-reachable vector.
    432  *   - False - Include modid on all-reachable vector.
    433  * \return
    434  *   See \ref shr_error_e
    435  * \remark
    436  *   * None.
    437  * \see
    438  *   * dnx_stk_sys_module_max_all_reachable_set.
    439  */
    440 shr_error_e dnx_stk_sys_module_all_reachable_ignore_id_set(
    441     int unit,
    442     bcm_module_t module,
    443     int enable);
    444 
    445 /**
    446  * \brief
    447  *   Get whether a modid is excluded from all-reachable vector.
    448  * \param [in] unit -
    449  *   The unit number.
    450  * \param [in] module -
    451  *   The module id in question.
    452  * \param [out] enable -
    453  *   True  - Modid is excluded from all-reachable vector.
    454  *   False - Modid is included in all-reachable vector.
    455  * \return
    456  *   See \ref shr_error_e
    457  * \remark
    458  *   * None.
    459  * \see
    460  *   * dnx_stk_sys_module_all_reachable_ignore_id_set.
    461  */
    462 shr_error_e dnx_stk_sys_module_all_reachable_ignore_id_get(
    463     int unit,
    464     bcm_module_t module,
    465     int *enable);
    466 
    467 /**
    468  * \brief
    469  *   Set maximum modid to be included in all-reachable vector.
    470  *   There are 2 ways to exclude modids from all-reachable vector:
    471  *     1. Set maximum modid to be included in the vector. All modids
    472  *        in the range above max won't be included in the vector.
    473  *     2. Exclude specific modids from the vector.
    474  *
    475  *   This function implements option 1 .
    476  * \param [in] unit -
    477  *   The unit number.
    478  * \param [in] max_module -
    479  *   The maximum modid to be included in the all-reachable vector.
    480  * \return
    481  *   See \ref shr_error_e
    482  * \remark
    483  *   * Max module for all-reachable vector must be <= max module in the system.
    484  * \see
    485  *   * dnx_stk_sys_module_all_reachable_ignore_id_set.
    486  */
    487 shr_error_e dnx_stk_sys_module_max_all_reachable_set(
    488     int unit,
    489     bcm_module_t max_module);
    490 
    491 /**
    492  * \brief
    493  *   Get maximum modid to be included in all-reachable vector.
    494  * \param [in] unit -
    495  *   The unit number.
    496  * \param [out] max_module -
    497  *   The maximum modid included in the all-reachable vector.
    498  * \return
    499  *   See \ref shr_error_e
    500  * \remark
    501  *   * None
    502  * \see
    503  *   * dnx_stk_sys_module_max_all_reachable_set.
    504  */
    505 shr_error_e dnx_stk_sys_module_max_all_reachable_get(
    506     int unit,
    507     bcm_module_t * max_module);
    508 
    509 /**
    510  * \brief
    511  *   Set maximum allowed modid in the system.
    512  * \param [in] unit -
    513  *   The unit number.
    514  * \param [in] max_module -
    515  *   The maximum modid to be configured.
    516  * \return
    517  *   See \ref shr_error_e
    518  * \remark
    519  *   * Max modid in the system must be >= max modid in all-reachable vector.
    520  *     If max_module is set to be lower than max modid in all-reachable vector,
    521  *     then max modid in all-reachable vector will be update to be the same as
    522  *     max modid in the system, and a warning will be printed to the user.
    523  * \see
    524  *   * dnx_stk_sys_module_max_all_reachable_set.
    525  */
    526 shr_error_e dnx_stk_sys_module_max_set(
    527     int unit,
    528     bcm_module_t max_module);
    529 
    530 /**
    531  * \brief
    532  *   Get maximum allowed modid in the system.
    533  * \param [in] unit -
    534  *   The unit number.
    535  * \param [out] max_module -
    536  *   The maximum modid allowed in the system.
    537  * \return
    538  *   See \ref shr_error_e
    539  * \remark
    540  *   * None
    541  * \see
    542  *   * dnx_stk_sys_module_max_set.
    543  */
    544 shr_error_e dnx_stk_sys_module_max_get(
    545     int unit,
    546     bcm_module_t * max_module);
    547 
    548 /**
    549  * \brief
    550  *   Initalize Stk Sys module
    551  * \param [in] unit -
    552  *   The unit number.
    553  * \return
    554  *   See \ref shr_error_e
    555  * \remark
    556  *   * None
    557  * \see
    558  *   * None
    559  */
    560 shr_error_e dnx_stk_sys_init(
    561     int unit);
    562 
    563 /**
    564  * \brief
    565  *   Map Fap ID to DQCQ context in mesh mode
    566  * \param [in] unit -
    567  *   The unit number.
    568  * \param [in] fap_id_lsb -
    569  *   LSBs of FAP ID. Used as a key to the table
    570  * \param [in] dqcq_context -
    571  *   DQCQ context to be mapped
    572  * \return
    573  *   See \ref shr_error_e
    574  * \remark
    575  *   * None
    576  * \see
    577  *   * None
    578  */
    579 shr_error_e dnx_stk_sys_mesh_dqcq_map_set(
    580     int unit,
    581     int fap_id_lsb,
    582     dbal_enum_value_field_system_mesh_context_e dqcq_context);
    583 
    584 /**
    585  * \brief
    586  *   Map Fap ID to DQCQ context in clos mode
    587  * \param [in] unit -
    588  *   The unit number.
    589  * \param [in] core -
    590  *   core ID
    591  * \param [in] local_indx -
    592  *   local index. Used as a key to the table
    593  * \param [in]  modid -
    594  *  modid for local index
    595  * \param [in]  mask -
    596  *  mask for local index
    597  * \return
    598  *   See \ref shr_error_e
    599  * \remark
    600  *   * None
    601  * \see
    602  *   * None
    603  */
    604 shr_error_e dnx_stk_sys_clos_dqcq_map_set(
    605     int unit,
    606     bcm_core_t core,
    607     int local_indx,
    608     uint32 modid,
    609     uint32 mask);
    610 
    611 /**
    612  * \brief
    613  *   Get actual number of FAP IDs per core
    614  * \param [in] unit -
    615  *   The unit number.
    616  * \param [out] nof_fap_ids_per_core -
    617  *   number of FAP IDs per core
    618  * \return
    619  *   See \ref shr_error_e
    620  * \remark
    621  *   * None
    622  * \see
    623  *   * None
    624  */
    625 shr_error_e dnx_stk_sys_nof_fap_ids_per_core_get(
    626     int unit,
    627     int *nof_fap_ids_per_core);
    628 
    629 #endif /* DNX_STK_SYS_H_INCLUDED */