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

pfc_deadlock.h (10030B)


      1 /*
      2  * 
      3  *
      4  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5  * 
      6  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      7  *
      8  * PFC Deadlock Detection & Recovery
      9  */
     10 
     11 #ifndef _BCM_INT_PFC_DEADLOCK_H
     12 #define _BCM_INT_PFC_DEADLOCK_H
     13 
     14 #include <bcm/cosq.h>
     15 #include <bcm_int/esw/cosq.h>
     16 
     17 #define _BCM_PFC_DEADLOCK_F_ENABLE          0x1 /* Flag to indicate if feature
     18                                                  * enabled for given cos/pri */
     19 
     20 #define PFC_DEADLOCK_MAX_COS BCM_COS_COUNT
     21 
     22 typedef int (*_bcm_cosq_inv_mapping_get_f)(int unit, bcm_gport_t gport,
     23                                        bcm_cos_queue_t cosq, uint32 flags,
     24                                        bcm_port_t *port, bcm_cos_t *priority);
     25 typedef enum _bcm_pfc_deadlock_oper_e {
     26     _bcmPfcDeadlockOperGet = 0, /* For Get operation */
     27     _bcmPfcDeadlockOperSet = 1, /* For Set operation */
     28     _bcmPfcDeadlockOperCount = 2 /* Max Value */
     29 } _bcm_pfc_deadlock_oper_t;
     30 
     31 /* _bcm_pfc_deadlock_config_t will be cached for WB recovery.
     32  * Hence adding new members will cause increase in Cache size, which needs to be
     33  * taken care while allocating space.
     34  */
     35 typedef struct _bcm_pfc_deadlock_config_s {
     36     uint8 flags; /* Flags to carry additional info regarding the config */
     37     uint16 port_recovery_count[SOC_MAX_NUM_PORTS]; /* port recovery count */
     38     bcm_cos_t priority; /* Priority for the current config */
     39     uint32 detection_timer; /* Detection timer for declaring deadlock */
     40     uint32 recovery_timer; /* Recovery timer for Action */
     41     bcm_pbmp_t enabled_ports; /* Bitmap of Enabled ports */
     42     bcm_pbmp_t deadlock_ports; /* Bitmap of Ports currently in Deadlock state */
     43 } _bcm_pfc_deadlock_config_t;
     44 
     45 /* Below structure to contain register/field name specific to chip */
     46 typedef struct _bcm_pfc_hw_resorces_s {
     47     soc_reg_t timer_count[PFC_DEADLOCK_MAX_COS];
     48     soc_reg_t timer_status[PFC_DEADLOCK_MAX_COS];
     49     soc_reg_t timer_mask[PFC_DEADLOCK_MAX_COS];
     50     soc_reg_t timer_en[PFC_DEADLOCK_MAX_COS];
     51     soc_reg_t chip_config[2];
     52     soc_reg_t port_config;
     53     soc_field_t cos_field[PFC_DEADLOCK_MAX_COS];
     54     soc_field_t time_init_val[PFC_DEADLOCK_MAX_COS];
     55     soc_field_t time_unit_field;
     56     soc_field_t recovery_action_field;
     57     soc_field_t deadlock_status_field;
     58 } _bcm_pfc_hw_resorces_t;
     59 
     60 typedef struct _bcm_pfc_deadlock_control_s {
     61     uint8 pfc_deadlock_cos_max;  /* Max COS supported for PFC Deadlock
     62                                   * Detection and Recovery */
     63     uint8 pfc_deadlock_cos_used; /* Total COS configured for PFC Deadlock
     64                                   * Detection and Recovery */
     65     uint8 hw_cos_idx_inuse[2];   /* Boolean for used Cos indices */
     66     uint8 cb_enabled;            /* Indicator if CB is enabled */
     67     bcm_switch_pfc_deadlock_detection_interval_t time_unit; /* 0 - 100ms,
     68                                                              * 1 - 10ms */
     69     uint32 cb_interval;          /* CB interval duration */
     70     bcm_cos_t pfc_pri2cos[PFC_DEADLOCK_MAX_COS]; /* Mapping to reduce run-time
     71                                            * computation */
     72     bcm_cos_t pfc_cos2pri[PFC_DEADLOCK_MAX_COS]; /* Mapping to reduce run-time
     73                                            * computation */
     74     _bcm_pfc_deadlock_config_t cos_config[PFC_DEADLOCK_MAX_COS];
     75     _bcm_pfc_hw_resorces_t hw_regs_fields;
     76     bcm_switch_pfc_deadlock_action_t recovery_action;
     77     uint32 cb_count; /* Debug ctr to keep track of #times CB fn is called */
     78     _bcm_cosq_inv_mapping_get_f cosq_inv_mapping_get; /* Function to retrieve
     79                                                        * Port/Priority from a
     80                                                        * given Gport */
     81 } _bcm_pfc_deadlock_control_t;
     82 
     83 typedef struct _bcm_pfc_deadlock_cb_s {
     84     bcm_cosq_pfc_deadlock_recovery_event_cb_t pfc_deadlock_cb;
     85     void * pfc_deadlock_userdata;
     86 } _bcm_pfc_deadlock_cb_t;
     87 
     88 
     89 #define _BCM_PFC_DEADLOCK_HW_RES_INIT(deadlock_hw)            \
     90     do {                                                      \
     91         int i = 0;                                            \
     92         for (i = 0; i < PFC_DEADLOCK_MAX_COS; i++) {          \
     93             (deadlock_hw)->timer_count[i] = (INVALIDr);       \
     94             (deadlock_hw)->timer_status[i] = (INVALIDr);      \
     95             (deadlock_hw)->timer_mask[i] = (INVALIDr);        \
     96             (deadlock_hw)->timer_en[i] = (INVALIDr);          \
     97             (deadlock_hw)->cos_field[i] = (INVALIDf);         \
     98             (deadlock_hw)->time_init_val[i] = (INVALIDf);     \
     99         }                                                     \
    100         (deadlock_hw)->port_config = (INVALIDr);              \
    101         (deadlock_hw)->chip_config[0] = (INVALIDr);           \
    102         (deadlock_hw)->chip_config[1] = (INVALIDr);           \
    103         (deadlock_hw)->time_unit_field = (INVALIDf);          \
    104         (deadlock_hw)->recovery_action_field = (INVALIDf);    \
    105         (deadlock_hw)->deadlock_status_field = (INVALIDf);    \
    106     } while(0);
    107 
    108 extern _bcm_pfc_deadlock_control_t *_bcm_pfc_deadlock_control[BCM_MAX_NUM_UNITS];
    109 extern _bcm_pfc_deadlock_cb_t *_bcm_pfc_deadlock_cb[BCM_MAX_NUM_UNITS];
    110 
    111 #define _BCM_UNIT_PFC_DEADLOCK_CONTROL(u) _bcm_pfc_deadlock_control[(u)]
    112 #define _BCM_UNIT_PFC_DEADLOCK_CB(u) _bcm_pfc_deadlock_cb[(u)]
    113 #define _BCM_PFC_DEADLOCK_CONFIG(u,cos) \
    114             (&((_bcm_pfc_deadlock_control[(u)])->cos_config[(cos)]))
    115 #define _BCM_PFC_DEADLOCK_COS_ENABLED(u,cos) \
    116             ((((_bcm_pfc_deadlock_control[(u)])->cos_config[(cos)].flags) & \
    117               _BCM_PFC_DEADLOCK_F_ENABLE) ? TRUE : FALSE)
    118 #define _BCM_PFC_DEADLOCK_CB_INTERVAL(u) \
    119             ((_bcm_pfc_deadlock_control[(u)])->cb_interval)
    120 #define _BCM_PFC_DEADLOCK_CB_ENABLED(u) \
    121             (((_bcm_pfc_deadlock_control[(u)])->cb_enabled) ? (TRUE) : (FALSE))
    122 #define _BCM_PFC_DEADLOCK_CB_COUNT(u) \
    123             ((_bcm_pfc_deadlock_control[(u)])->cb_count)
    124 #define _BCM_PFC_DEADLOCK_TIME_UNIT(u) \
    125             ((_bcm_pfc_deadlock_control[(u)])->time_unit)
    126 #define _BCM_PFC_DEADLOCK_RECOVERY_ACTION(u) \
    127             ((_bcm_pfc_deadlock_control[(u)])->recovery_action)
    128 
    129 extern int _bcm_pfc_deadlock_init(int unit);
    130 extern int _bcm_pfc_deadlock_deinit(int unit);
    131 #ifdef BCM_WARM_BOOT_SUPPORT
    132 extern int _bcm_pfc_deadlock_alloc_size(int unit);
    133 extern int _bcm_pfc_deadlock_reinit(int unit);
    134 #endif /* BCM_WARM_BOOT_SUPPORT */
    135 extern int _bcm_pfc_deadlock_recovery_reset(int unit);
    136 extern int _bcm_pfc_deadlock_config_set(int unit, bcm_cos_t priority,
    137                             bcm_cosq_pfc_deadlock_config_t *config);
    138 extern int _bcm_pfc_deadlock_config_get(int unit, bcm_cos_t priority,
    139                             bcm_cosq_pfc_deadlock_config_t *config);
    140 extern int _bcm_pfc_deadlock_queue_config_set(int unit, bcm_gport_t gport,
    141                             bcm_cosq_pfc_deadlock_queue_config_t *config);
    142 extern int _bcm_pfc_deadlock_queue_config_get(int unit, bcm_gport_t gport,
    143                             bcm_cosq_pfc_deadlock_queue_config_t *config);
    144 extern int _bcm_pfc_deadlock_queue_status_get(int unit, bcm_gport_t gport,
    145                                               uint8 *enable);
    146 extern int _bcm_pfc_deadlock_info_get(int unit, bcm_cos_t priority,
    147                             bcm_cosq_pfc_deadlock_info_t *pfc_deadlock_info);
    148 extern int _bcm_pfc_deadlock_control_set(int unit, bcm_switch_control_t type,
    149                                          int arg);
    150 extern int _bcm_pfc_deadlock_control_get(int unit, bcm_switch_control_t type,
    151                                          int *arg);
    152 extern int _bcm_pfc_deadlock_max_cos_get(int unit, int *entries);
    153 extern int _bcm_pfc_deadlock_update_cos_used(int unit);
    154 extern int _bcm_td3_pfc_deadlock_update_cos_used(int unit);
    155 extern int _bcm_hr4_pfc_deadlock_update_cos_used(int unit);
    156 extern int _bcm_hx5_pfc_deadlock_update_cos_used(int unit);
    157 extern int _bcm_fb6_pfc_deadlock_update_cos_used(int unit);
    158 extern int _bcm_pfc_deadlock_recovery_update(int unit, int cos);
    159 extern int _bcm_pfc_deadlock_ignore_pfc_xoff_gen(int unit, int priority,
    160                             bcm_port_t port, uint32 *rval32);
    161 extern int _bcm_pfc_deadlock_ignore_pfc_xoff_clear(int unit, int cos,
    162                             bcm_port_t port);
    163 extern int _bcm_cosq_pfc_deadlock_recovery_event_register(int unit, 
    164                   bcm_cosq_pfc_deadlock_recovery_event_cb_t callback, 
    165                   void *userdata);
    166 extern int _bcm_cosq_pfc_deadlock_recovery_event_unregister(int unit, 
    167                      bcm_cosq_pfc_deadlock_recovery_event_cb_t callback, 
    168                      void *userdata);
    169 #ifdef BCM_TOMAHAWK3_SUPPORT
    170 extern int _bcm_th3_pfc_deadlock_recovery_event_register(
    171     int unit,
    172     bcm_cosq_pfc_deadlock_recovery_event_cb_t callback,
    173     void *userdata);
    174 extern int _bcm_th3_pfc_deadlock_recovery_event_unregister(
    175     int unit,
    176     bcm_cosq_pfc_deadlock_recovery_event_cb_t callback,
    177     void *userdata);
    178 extern int _bcm_th3_pfc_deadlock_info_get(int unit, int priority,
    179                                bcm_cosq_pfc_deadlock_info_t *pfc_deadlock_info);
    180 extern int _bcm_th3_pfc_deadlock_init(int unit);
    181 extern int _bcm_th3_pfc_deadlock_deinit(int unit);
    182 extern int _bcm_th3_pfc_deadlock_port_detach(int unit, bcm_port_t port);
    183 
    184 extern int _bcm_th3_pfc_deadlock_port_status_get
    185                        (int unit, bcm_gport_t gport, uint8 *deadlock_status);
    186 extern int _bcm_th3_pfc_switch_control_set
    187                     (int unit, bcm_switch_control_t type, int arg);
    188 extern int _bcm_th3_pfc_switch_control_get
    189                     (int unit, bcm_switch_control_t type, int *arg);
    190 
    191 extern int _bcm_th3_pfc_deadlock_recovery_reset(int unit);
    192 
    193 extern int _bcm_th3_pfc_deadlock_reinit(int unit, uint8 **scache_ptr, uint16 recov_ver);
    194 extern int
    195 bcm_th3_pfc_deadlock_recovery_start(int unit, int port, int pfc_priority);
    196 extern int
    197 bcm_th3_pfc_deadlock_recovery_exit(int unit, int port, int pfc_priority);
    198 
    199 #endif
    200 #endif /* _BCM_INT_PFC_DEADLOCK_H */