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

l2_learn.h (7428B)


      1 /**
      2  * \file bcm_int/dnx/l2/l2_learn.h
      3  * Internal DNX L2 APIs
      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 
      9 #ifndef L2_LEARN_H_INCLUDED
     10 /*
     11  * {
     12  */
     13 #define L2_LEARN_H_INCLUDED
     14 
     15 #ifndef BCM_DNX_SUPPORT
     16 #error "This file is for use by DNX (JR2) family only!"
     17 #endif
     18 
     19 /*
     20  * Include files.
     21  * {
     22  */
     23 #include <bcm/l2.h>
     24 #include <bcm_int/dnx/algo/l2/algo_l2.h>
     25 #include <soc/dnx/dbal/dbal.h>
     26 /*
     27  * }
     28  */
     29 /*
     30  * STRUCTS
     31  * {
     32  */
     33 /**
     34  * \brief
     35  *   This structure is created in order to hold information about the CPU learn dedicated thread
     36  */
     37 typedef struct l2_cpu_learn_fifodma_mact_thread_info_s
     38 {
     39     /** Thread control */
     40     /*
     41      * Semaphore for l2 CPU learning thread
     42      */
     43     volatile sal_sem_t sem;
     44     /*
     45      *  l2 CPU learning thread id
     46      */
     47     volatile sal_thread_t tid;
     48     /*
     49      * l2 CPU learning thread active or terminated
     50      */
     51     volatile uint8 is_active;
     52 } l2_cpu_learn_fifodma_mact_thread_info_t;
     53 
     54 typedef enum dnx_learn_mode_e
     55 {
     56     LEARN_MODE_DISTRIBUTED,
     57     LEARN_MODE_CENTRALIZED,
     58     LEARN_MODE_DMA
     59 } dnx_learn_mode_t;
     60 
     61 typedef enum dnx_learn_limit_mode_e
     62 {
     63     LEARN_LIMIT_MODE_VLAN,
     64     LEARN_LIMIT_MODE_VLAN_PORT,
     65     LEARN_LIMIT_MODE_TUNNEL
     66 } dnx_learn_limit_mode_t;
     67 
     68 /*
     69  * }
     70  */
     71 /*
     72  * GLOBALS
     73  * {
     74  */
     75 /** Holds the l2 CPU learning information per unit */
     76 l2_cpu_learn_fifodma_mact_thread_info_t dnx_l2_cpu_learn_thread_info[SOC_MAX_NUM_DEVICES];
     77 /*
     78  * }
     79  */
     80 /*
     81  * DEFINES
     82  * {
     83  */
     84 
     85 #define BCM_DNX_L2_LEARN_SUPPORTED_FLAGS (BCM_L2_LEARN_LIMIT_SYSTEM | BCM_L2_LEARN_LIMIT_VLAN | BCM_L2_LEARN_LIMIT_PORT)
     86 
     87 /** TOOD Replace it by string from DNX_DATA */
     88 #define LEARN_LIMIT_MODE_NAME(unit)          \
     89             ((dnx_data_l2.general.l2_learn_limit_mode_get(unit) == LEARN_LIMIT_MODE_VLAN) ? "VLAN" : "VLAN_PORT")
     90 
     91 /** Size of index to the table that maps VSI(or other field in MACT entry to profile) 17 means 128k entries */
     92 #define MACT_VSI_TO_PROFILE_IND_SIZE   17
     93 
     94 /*
     95  * MACT Entry and Key Sizes
     96  */
     97 #define MACT_ENTRY_SIZE         150
     98 #define MACT_KEY_SIZE           80
     99 
    100 
    101 #define MACT_ENTRY_VSI_OFFSET           48
    102 #define WA_MACT_ENTRY_VSI_OFFSET       (MACT_ENTRY_VSI_OFFSET + MACT_ENTRY_SIZE - MACT_KEY_SIZE)
    103 
    104 /* MACT Payload is MSB aligned in the entry, and is adjusted to 6b VMV
    105  * | 6b VMV | Payload type(6b) | 4b Entry Grouping | 2b Learn Strength | 21b Dst | 22b OutLif
    106  */
    107 #define MACT_ENTRY_OUTLIF_OFFSET       (MACT_ENTRY_SIZE - 6 - 6 - 4 -2 -21 -22)
    108 
    109 /** Default age profile */
    110 #define MACT_DEFAULT_AGE_PROFILE 0
    111 
    112 /** Number of LEM entries for one learn MAC entry */
    113 #define MACT_EM_NOF_ENTRIES     4
    114 
    115 /** CPU learning thread priority*/
    116 #define FIFO_DMA_THREAD_PRIO     50
    117 /*
    118  * }
    119  */
    120 
    121 /**
    122  * \brief - configures learn mode with its default values. The function is called from bcm_dnx_switch_control_set.
    123  * The function resets the OLP events' distribution to the defaults of the learn mode.
    124  * VSI learning profiles are reset to their defaults. Aging profiles are reset to their learn mode's default.
    125  * Specific VSI configurations that are different for the default like aging info, OLP events' distribution etc. should be configured againg.
    126  * The pipe is configured for ingress/egress learning according to the learn mode.
    127  *
    128  * \param [in] unit - unit id
    129  * \param [in] bcm_learn_mode - learn mode type.
    130  * learn mode type:
    131  * BCM_L2_INGRESS_CENT - Ingress and centralized learning
    132  * BCM_L2_INGRESS_DIST - Ingress and distributed learning
    133  * BCM_L2_EGRESS_DIST - Egress and distributed learning
    134  * BCM_L2_EGRESS_CENT - Egress and centralized learning
    135  * BCM_L2_LEARN_CPU - Learning events handled by CPU callbacks. DMA copying the event to the CPU's memory
    136  * BCM_L2_LEARN_DISABLE - Disabled learning
    137  *
    138  * \return
    139  *   shr_error_e
    140  *
    141  * \remark
    142  *   * None
    143  * \see
    144  *   * None
    145  */
    146 shr_error_e dnx_l2_learn_mode_set(
    147     int unit,
    148     int bcm_learn_mode);
    149 
    150 /**
    151  * \brief - Gets the current learn mode. The function is called from bcm_dnx_switch_control_get.
    152  *
    153  * \param [in] unit - unit id
    154  * \param [out] bcm_learn_mode - learn mode type
    155  *
    156  * learn mode type:
    157  * BCM_L2_INGRESS_CENT - Ingress and centralized learning
    158  * BCM_L2_INGRESS_DIST - Ingress and distributed learning
    159  * BCM_L2_EGRESS_DIST - Egress and distributed learning
    160  * BCM_L2_EGRESS_CENT - Egress and centralized learning
    161  * BCM_L2_LEARN_CPU - Learning events handled by CPU callbacks. DMA copying the event to the CPU's memory
    162  * BCM_L2_LEARN_DISABLE - Disabled learning
    163  *
    164  * \return
    165  *   shr_error_e
    166  *
    167  * \remark
    168  *   * None
    169  * \see
    170  *   * None
    171  */
    172 shr_error_e dnx_l2_learn_mode_get(
    173     int unit,
    174     int *bcm_learn_mode);
    175 
    176 /**
    177  * \brief
    178  * Initialize the learn limits default configurations.
    179  */
    180 int dnx_l2_init_learn_limits(
    181     int unit);
    182 
    183 int dnx_l2_learn_init_olp(
    184     int unit);
    185 
    186 /**
    187  * \brief
    188  * Initialize the CPU learn thread information holder.
    189  *
    190  * \param [in]  unit - pointer to the unit id
    191  */
    192 void dnx_l2_learn_mact_fifodma_cpu_learn_thread_info_init(
    193     int unit);
    194 
    195 /**
    196  * \brief -
    197  * This function kills the cpu dedicated thread.
    198  *
    199  * \param [in]  unit - pointer to the unit id
    200  *
    201  * \return
    202  *   void
    203  *
    204  * \remark
    205  *   In the case that the above thread is not initiated the function will not perform any action
    206  *
    207  * \see
    208  *   None
    209  */
    210 shr_error_e dnx_l2_learn_mact_fifodma_cpu_learn_cleanup(
    211     int unit);
    212 
    213 int dnx_l2_init_learn_payload_context(
    214     int unit);
    215 
    216 int dnx_l2_init_learn_key_context(
    217     int unit);
    218 
    219 shr_error_e dnx_vsi_learning_profile_id_get(
    220     int unit,
    221     int vsi,
    222     int *vsi_profile);
    223 
    224 shr_error_e dnx_vsi_learning_profile_hw_update(
    225     int unit,
    226     int vsi,
    227     int old_vsi_learning_profile,
    228     int new_vsi_learning_profile,
    229     uint8 is_first,
    230     uint8 is_last,
    231     dnx_vsi_learning_profile_info_t * vsi_learning_profile_info);
    232 
    233 /**
    234  * \brief - Init the DMA channel of the OLP
    235  *
    236  * \param [in] unit - unit id
    237  *
    238  * \return
    239  *   shr_error_e
    240  *
    241  * \remark
    242  *   * None
    243  * \see
    244  *   * None
    245  */
    246 shr_error_e dnx_l2_olp_dma_init(
    247     int unit);
    248 
    249 /**
    250  * \brief - Stop and free the dma channel of the olp
    251  *
    252  * \param [in] unit - unit id
    253  *
    254  * \return
    255  *   shr_error_e
    256  *
    257  * \remark
    258  *   * None
    259  * \see
    260  *   * None
    261  */
    262 shr_error_e dnx_l2_olp_dma_deinit(
    263     int unit);
    264 
    265 void dnx_olp_dma_handler(
    266     int unit,
    267     void *entry,
    268     int entry_size,
    269     int entry_number_unused,
    270     int total_amount_of_entries_unused,
    271     void **user_data_unused);
    272 
    273 /**
    274  * \brief - Update the OLP events distribution of a given VSI.
    275  *
    276  * \param [in] unit - unit ID
    277  * \param [in] vsi - vsi to update
    278  * \param [in] is_lif - event configuration per LIF
    279  * \param [in] event_forwarding_profile_info - info to set in the event_forwarding_profile
    280  *
    281  * \return
    282  *   shr_error_e
    283  *
    284  * \remark
    285  *   * None
    286  * \see
    287  *   * None
    288  */
    289 shr_error_e dnx_event_forwarding_profile_update(
    290     int unit,
    291     int vsi,
    292     int is_lif,
    293     dnx_event_forwarding_profile_info_t * event_forwarding_profile_info);
    294 
    295 /**
    296  * \brief
    297  *  Verify l2 learn mode and event configuration.
    298  * \param [in] unit - The unit number.
    299  * \param [in] is_lif - event configuration per LIF.
    300  * \return
    301  *   \retval Zero if no error was encountered
    302  *   \retval Non-zero in case of an error.
    303  * \remark
    304  *   * None
    305  * \see
    306  *   * None
    307  */
    308 shr_error_e dnx_l2_learn_mode_verify(
    309     int unit,
    310     int is_lif);
    311 
    312 /*
    313  * }
    314  */
    315 #endif /* L2_LEARN_H_INCLUDED */