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

port.c (10390B)


      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 
      8 #include <soc/mem.h>
      9 #include <soc/debug.h>
     10 #include <soc/cm.h>
     11 #include <soc/drv.h>
     12 #include <soc/register.h>
     13 #include <soc/memory.h>
     14 #include <soc/ll.h>
     15 #include <soc/ptable.h>
     16 #ifdef BCM_ESW_SUPPORT
     17 #include <soc/tucana.h>
     18 #endif
     19 #include <bcm/port.h>
     20 #include <bcm/vlan.h>
     21 #include <bcm/error.h>
     22 #include <bcm/link.h>
     23 #include <bcm/stack.h>
     24 #include <bcm/stg.h>
     25 #include <bcm/rate.h>
     26 
     27 
     28 /*
     29 * Function:
     30 *      bcm_port_tpid_class_t_init
     31 * Purpose:
     32 *      Initialize the bcm_port_tpid_class_t structure
     33 * Parameters:
     34 *      info - Pointer to the structure which should be initialized
     35 * Returns:
     36 *      NONE
     37 */
     38 void 
     39 bcm_port_tpid_class_t_init(bcm_port_tpid_class_t *tpid_class)
     40 {
     41     if (NULL != tpid_class) {
     42         sal_memset(tpid_class, 0, sizeof (*tpid_class));
     43     }
     44     return;
     45 }
     46 
     47 /*
     48 * Function:
     49 *      bcm_port_info_t_init
     50 * Purpose:
     51 *      Initialize the bcm_port_info_t structure
     52 * Parameters:
     53 *      info - Pointer to structure which should be initialized
     54 * Returns:
     55 *      NONE
     56 */
     57 void 
     58 bcm_port_info_t_init(bcm_port_info_t *info)
     59 {
     60     if (NULL != info) {
     61         sal_memset(info, 0, sizeof (*info));
     62     }
     63     return;
     64 }
     65 
     66 /*
     67  * Function:
     68  *      bcm_port_config_t_init
     69  * Purpose:
     70  *      Initialize a Port config object struct.
     71  * Parameters:
     72  *      pconfig - Pointer to the Port Config object struct.
     73  * Returns:
     74  *      NONE
     75  */
     76 void
     77 bcm_port_config_t_init(bcm_port_config_t *pconfig)
     78 {
     79     if (pconfig != NULL) {
     80         sal_memset(pconfig, 0, sizeof (*pconfig));
     81     }
     82     return;
     83 }
     84 
     85 
     86 /*
     87  * Function:
     88  *      bcm_port_interface_config_t_init
     89  * Purpose:
     90  *      Initialize a Port interface config object struct.
     91  * Parameters:
     92  *      pconfig - Pointer to the Port Interface Config object struct.
     93  * Returns:
     94  *      NONE
     95  */
     96 void
     97 bcm_port_interface_config_t_init(bcm_port_interface_config_t *pconfig)
     98 {
     99     if (pconfig != NULL) {
    100         sal_memset(pconfig, 0, sizeof (*pconfig));
    101     }
    102     return;
    103 }
    104 
    105 
    106 /*
    107  * Function:
    108  *      bcm_port_ability_t_init
    109  * Purpose:
    110  *      Initialize a Port ability object struct.
    111  * Parameters:
    112  *      pconfig - Pointer to the Port ability object struct.
    113  * Returns:
    114  *      NONE
    115  */
    116 void
    117 bcm_port_ability_t_init(bcm_port_ability_t *pability)
    118 {
    119     if (pability != NULL) {
    120         sal_memset(pability, 0, sizeof (*pability));
    121     }
    122     return;
    123 }
    124 
    125 /*
    126  * Function:
    127  *      bcm_phy_config_t_init
    128  * Purpose:
    129  *      Initialize a PHY config object struct.
    130  * Parameters:
    131  *      pconfig - Pointer to the Port ability object struct.
    132  * Returns:
    133  *      NONE
    134  */
    135 void
    136 bcm_phy_config_t_init(bcm_phy_config_t *pconfig)
    137 {
    138     if (pconfig != NULL) {
    139         sal_memset(pconfig, 0, sizeof (*pconfig));
    140     }
    141     return;
    142 }
    143 
    144 /*
    145  * Function:
    146  *      bcm_port_encap_config_t_init
    147  * Purpose:
    148  *      Initialize a Port encapsulation config object struct.
    149  * Parameters:
    150  *      encap_config - Pointer to the Port encapsultation config object struct.
    151  * Returns:
    152  *      NONE
    153  */
    154 void
    155 bcm_port_encap_config_t_init(bcm_port_encap_config_t *encap_config)
    156 {
    157     if (encap_config != NULL) {
    158         sal_memset(encap_config, 0, sizeof (*encap_config));
    159     }
    160     return;
    161 }
    162 
    163 /*
    164  * Function:
    165  *      bcm_port_congestion_config_t_init
    166  * Purpose:
    167  *      Initialize a Port congestion config object struct.
    168  * Parameters:
    169  *      config - Pointer to the Port congestion config object struct.
    170  * Returns:
    171  *      NONE
    172  */
    173 void
    174 bcm_port_congestion_config_t_init(bcm_port_congestion_config_t *config)
    175 {
    176     if (config != NULL) {
    177         sal_memset(config, 0, sizeof (*config));
    178     }
    179     return;
    180 }
    181 
    182 /* 
    183  * Function:
    184  *      bcm_port_match_info_t_init
    185  * Purpose:
    186  *      Initialize the port_match_info struct
    187  * Parameters: 
    188  *      port_match_info - Pointer to the struct to be init'ed
    189  */
    190 void
    191 bcm_port_match_info_t_init(bcm_port_match_info_t *port_match_info)
    192 {   
    193     if (port_match_info != NULL) {
    194         sal_memset(port_match_info, 0, sizeof(*port_match_info));
    195     }
    196     return;
    197 }
    198 
    199 /*
    200  * Function:
    201  *      bcm_port_timesync_config_t_init
    202  * Purpose:
    203  *      Initialize a Port config object struct.
    204  * Parameters:
    205  *      pconfig - Pointer to the Port Config object struct.
    206  * Returns:
    207  *      NONE
    208  */
    209 void
    210 bcm_port_timesync_config_t_init(bcm_port_timesync_config_t *pconfig)
    211 {
    212     if (pconfig != NULL) {
    213         sal_memset(pconfig, 0, sizeof (*pconfig));
    214     }
    215     return;
    216 }
    217 
    218 /*
    219  * Function:
    220  *      bcm_port_phy_timesync_config_t_init
    221  * Purpose:
    222  *      Initialize a Port config object struct.
    223  * Parameters:
    224  *      pconfig - Pointer to the Port Config object struct.
    225  * Returns:
    226  *      NONE
    227  */
    228 void
    229 bcm_port_phy_timesync_config_t_init(bcm_port_phy_timesync_config_t *pconfig)
    230 {
    231     if (pconfig != NULL) {
    232         sal_memset(pconfig, 0, sizeof (*pconfig));
    233     }
    234     return;
    235 }
    236 
    237 /*
    238  * Function:
    239  *      bcm_port_mapping_info_t_init
    240  * Purpose:
    241  *      Initialize structure bcm_port_mapping_info_t
    242  * Parameters:
    243  *      mapping - Pointer to the struct.
    244  * Returns:
    245  *      NONE
    246  */
    247 void bcm_port_mapping_info_t_init(
    248     bcm_port_mapping_info_t *mapping)
    249 {
    250     if (mapping != NULL) {
    251         sal_memset(mapping, 0, sizeof (*mapping));
    252         mapping->pp_port = -1;
    253     }
    254     return;
    255 }
    256 
    257 /*
    258  * Function:
    259  *      bcm_priority_mapping_t_init
    260  * Purpose:
    261  *      Initialize a port vlan priority mapping struct.
    262  * Parameters:
    263  *      pri_map - Pointer to the pri_map struct.
    264  * Returns:
    265  *      NONE
    266  */
    267 void
    268 bcm_priority_mapping_t_init(bcm_priority_mapping_t *pri_map)
    269 {
    270     if (pri_map != NULL) {
    271         sal_memset(pri_map, 0, sizeof (*pri_map));
    272     }
    273     return;
    274 }
    275 
    276 /*
    277  * Function:
    278  *      bcm_port_extender_mapping_info_t_init
    279  * Purpose:
    280  *      Initialize a port extender mapping struct.
    281  * Parameters:
    282  *      mapping_info - Pointer to the port extender mapping struct.
    283  * Returns:
    284  *      NONE
    285  */
    286 void
    287 bcm_port_extender_mapping_info_t_init(bcm_port_extender_mapping_info_t *mapping_info)
    288 {
    289     if (mapping_info != NULL) {
    290         sal_memset(mapping_info, 0, sizeof (*mapping_info));
    291     }
    292     return;
    293 }
    294 
    295 /*
    296  * Function:
    297  *      bcm_port_resource_t_init
    298  * Purpose:
    299  *      Initialize a Port Resource data structure.
    300  * Parameters:
    301  *      resource - Pointer to Port Resource data structure to 
    302  *                 be initialized.
    303  * Returns:
    304  *      None
    305  */
    306 void
    307 bcm_port_resource_t_init(bcm_port_resource_t *resource)
    308 {
    309     if (resource != NULL) {
    310         sal_memset(resource, 0, sizeof (*resource));
    311 
    312         resource->speed = BCM_PORT_RESOURCE_DEFAULT_REQUEST;
    313         resource->fec_type = BCM_PORT_RESOURCE_DEFAULT_REQUEST;
    314         resource->link_training = BCM_PORT_RESOURCE_DEFAULT_REQUEST;
    315         resource->phy_lane_config = BCM_PORT_RESOURCE_DEFAULT_REQUEST;
    316     }
    317 
    318     return;
    319 }
    320 
    321 /*
    322  * Function:
    323  *      bcm_port_priority_group_config_t_init
    324  * Purpose:
    325  *      Initialize a Port Priority Group configuration struct.
    326  * Parameters:
    327  *      prigrp_config - Pointer to the priority group configuration struct.
    328  * Returns:
    329  *      None
    330  */
    331 void
    332 bcm_port_priority_group_config_t_init(bcm_port_priority_group_config_t *prigrp_config)
    333 {
    334     if (prigrp_config != NULL) {
    335         sal_memset(prigrp_config, 0, sizeof (*prigrp_config));
    336     }
    337 
    338     return;
    339 }
    340 
    341 /*
    342  * Function:
    343  *      bcm_port_redirect_config_t_init
    344  * Purpose:
    345  *      Initialize the redirection config structure
    346  * Parameters:
    347  *      unit             - (IN) device id.
    348  *      redirect_config  - (IN) Pointer to the redirection config structure
    349  * Returns:
    350  *      None
    351  */
    352 void
    353 bcm_port_redirect_config_t_init(bcm_port_redirect_config_t *redirect_config)
    354 {
    355     /* Sanity check */
    356     if(redirect_config == NULL) {
    357         return;
    358     }
    359 
    360     /* Memset the struct */
    361     sal_memset(redirect_config, 0, sizeof(bcm_port_redirect_config_t));
    362 
    363     /* Intiialize the config struct fields to defaults */
    364     redirect_config->flags = BCM_PORT_REDIRECT_SOURCE_USE_ORIGINAL_SOURCE;
    365     redirect_config->buffer_priority = BCM_PORT_REDIRECT_BUFFER_PRIORITY_LOW;
    366     redirect_config->destination = -1;
    367 
    368     return;
    369 }
    370 
    371 /*
    372  * Description:
    373  *        Initialize a bcm_port_e2efc_remote_module_config_t structure.
    374  * Parameter:
    375  *        e2efc_rmod_cfg - Pointer to bcm_port_e2efc_remote_module_config_t
    376  */
    377 void
    378 bcm_port_e2efc_remote_module_config_t_init(
    379     bcm_port_e2efc_remote_module_config_t *e2efc_rmod_cfg)
    380 {
    381     if (e2efc_rmod_cfg != NULL) {
    382         sal_memset(e2efc_rmod_cfg, 0, sizeof (*e2efc_rmod_cfg));
    383     }
    384 
    385     return;
    386 }
    387 
    388 /*
    389  * Description:
    390  *        Initialize a bcm_port_e2efc_remote_port_config_t structure.
    391  * Parameter:
    392  *        e2efc_rport_cfg - Pointer to bcm_port_e2efc_remote_port_config_t
    393  */
    394 void
    395 bcm_port_e2efc_remote_port_config_t_init(
    396     bcm_port_e2efc_remote_port_config_t *e2efc_rport_cfg)
    397 {
    398     if (e2efc_rport_cfg != NULL) {
    399         sal_memset(e2efc_rport_cfg, 0, sizeof (*e2efc_rport_cfg));
    400     }
    401 
    402     return;
    403 }
    404 
    405 /*
    406  * Function:
    407  *      bcm_port_phy_tx_t_init
    408  * Purpose:
    409  *      Initialize a TX FIR parameters data structure.
    410  * Parameters:
    411  *      tx - Pointer to TX FIR parameters data structure to 
    412  *                 be initialized.
    413  * Returns:
    414  *      None
    415  */
    416 void
    417 bcm_port_phy_tx_t_init(bcm_port_phy_tx_t *tx)
    418 {
    419     if (tx != NULL) {
    420         sal_memset(tx, 0, sizeof (*tx));
    421     }
    422     return;
    423 }
    424 
    425 /*
    426  * Function:
    427  *      bcm_port_rlm_config_t_init
    428  * Purpose:
    429  *      Initialize rlm_config parameters data structure.
    430  * Parameters:
    431  *      rlm_config - Pointer to bcm_port_rlm_config_t data structure to 
    432  *                 be initialized.
    433  * Returns:
    434  *      None
    435  */
    436 void
    437 bcm_port_rlm_config_t_init(bcm_port_rlm_config_t *rlm_config)
    438 {
    439     if (rlm_config != NULL) {
    440         sal_memset(rlm_config, 0, sizeof (*rlm_config));
    441     }
    442     return;
    443 }
    444 
    445 /**
    446  * \brief -
    447  *  Initialize a bcm_port_flood_group_t structure.
    448  *
    449  * \param [in] flood_groups - Pointer to bcm_port_flood_group_t.
    450  *
    451  * \return
    452  *   bcm_error_t
    453  *
    454  * \remark
    455  *   * None
    456  * \see
    457  *   * None
    458  */
    459 void
    460 bcm_port_flood_group_t_init(bcm_port_flood_group_t *flood_groups)
    461 {
    462     if (flood_groups != NULL) {
    463         sal_memset(flood_groups, 0, sizeof (*flood_groups));
    464         flood_groups->unknown_unicast_group = BCM_GPORT_INVALID;
    465         flood_groups->unknown_multicast_group= BCM_GPORT_INVALID;
    466         flood_groups->broadcast_group= BCM_GPORT_INVALID;
    467     }
    468 
    469     return;
    470 }
    471 
    472