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

stat.c (2272B)


      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:        port.c
      8  * Purpose:     Port driver.
      9  */
     10 
     11 #include <soc/defs.h>
     12 
     13 #if defined(BCM_TRIDENT2PLUS_SUPPORT)
     14 #include <shared/bsl.h>
     15 #include <soc/drv.h>
     16 #include <soc/types.h>
     17 #include <soc/td2_td2p.h>
     18 #include <bcm_int/esw_dispatch.h>
     19 #include <bcm_int/esw/trident2plus.h>
     20 #include <bcm/error.h>
     21 #include <bcm_int/esw/stat.h>
     22 
     23 /*
     24  * Function:
     25  *  bcmi_td2p_stat_port_attach
     26  * Description:
     27  *  Initializes the BCM stat module for the new port that has been flexed
     28  * Parameters:
     29  *  unit - StrataSwitch PCI device unit number (driver internal).
     30  *  port - port number
     31  * Returns:
     32  *  BCM_E_NONE - Success.
     33  *  BCM_E_INTERNAL - Chip access failure.
     34  */
     35 
     36 int
     37 bcmi_td2p_stat_port_attach(int unit, bcm_port_t port)
     38 {
     39     pbmp_t      pbmp;
     40     int         config_threshold;
     41 
     42     config_threshold = soc_property_get(unit, spn_BCM_STAT_JUMBO, 1518);
     43     if ((config_threshold < 1518) ||
     44         (config_threshold > 0x3fff) ) {
     45         config_threshold = 1518;
     46     }
     47 
     48     BCM_IF_ERROR_RETURN    
     49         (_bcm_esw_stat_ovr_threshold_set(unit, port, config_threshold));
     50 
     51     /* Adding the new port to bitmap and passing it to 
     52        counter_set32_by_port as it takes only bitmap as argument */
     53        SOC_PBMP_CLEAR(pbmp);
     54        SOC_PBMP_PORT_ADD(pbmp, port);
     55        SOC_IF_ERROR_RETURN(soc_counter_set32_by_port(unit, pbmp, 0));
     56        
     57     /* Note: Assuming soc_counter_start would be called later after
     58              all the modules for the new port are initialised */
     59     
     60 
     61    return BCM_E_NONE;
     62 }
     63 /*
     64  * Function:
     65  *  bcmi_td2p_stat_port_detach
     66  * Description:
     67  *  Clear the port based statistics from the StrataSwitch port.
     68  * Parameters:
     69  *  unit - StrataSwitch PCI device unit number (driver internal).
     70  *  port - port number
     71  * Returns:
     72  *  BCM_E_NONE - Success.
     73  */
     74 
     75 int
     76 bcmi_td2p_stat_port_detach(int unit, bcm_port_t port)
     77 {
     78     pbmp_t      pbm;
     79     
     80     SOC_PBMP_CLEAR(pbm);
     81     SOC_PBMP_PORT_ADD(pbm, port);
     82     BCM_IF_ERROR_RETURN(soc_counter_set32_by_port(unit, pbm, 0));
     83     
     84     return(BCM_E_NONE);
     85     
     86 }
     87 #endif /* BCM_TRIDENT2PLUS_SUPPORT */