algo_cal.h (5591B)
1 /* 2 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 3 * 4 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 5 */ 6 /** 7 * \file algo_cal.h 8 * Reserved.$ 9 */ 10 11 #ifndef _DNX_ALGO_CAL__H__INCLUDED_ 12 #define _DNX_ALGO_CAL__H__INCLUDED_ 13 14 #ifndef BCM_DNX_SUPPORT 15 #error "This file is for use by DNX (JR2) family only!" 16 #endif 17 18 #include <shared/shrextend/shrextend_error.h> 19 #include <bcm/types.h> 20 #include <bcm_int/dnx/cosq/egress/egq_ofp_rates.h> 21 22 #define DNX_ALGO_CAL_ILLEGAL_OBJECT_ID (0xffffffff) 23 24 /* 25 * \brief - 26 * Given calendar type, rate per each active port, and length of calendar, get 27 * the corresponding calendar with 'calendar_len' slots (but see 'add_dummy_tail'). 28 * \param [in] unit - 29 * HW identifier of unit. 30 * \param [in] core - 31 * Core to use for getting required info.. 32 * \param [in] cal_info - 33 * Pointer to dnx_ofp_rates_cal_info_t. The following elements are input: 34 * cal_info->cal_type (dnx_ofp_rates_egq_cal_type_e) - May be: 35 * DNX_OFP_RATES_EGQ_CAL_CHAN_ARB 36 * All other calendar types 37 * The following are also used, but only for 'channelized calendar' (CAL_CHAN_ARB): 38 * cal_info->chan_arb_id (used to calculate 'offest', key into table). 39 * \param [in] ports_rates - 40 * Pointer to array of uint32. Dimension of array is dnx_data_egr_queuing.params.nof_q_pairs 41 * (currently 512). Each entry indicates the rate assigned to indicated port, in kilo 42 * bits per second. A port, whose rate is '0', is assumed to be inactive. 43 * \param [in] calendar_len - 44 * uint32. Number of slots in calendar. Each slot refers to one port. 45 * \param [in] add_dummy_tail - 46 * uint8. Flag. If set then number of slots, in 'calendar', loaded by rate, is 47 * not 'calendar_len' but 'calendar_len - 1'. 48 * \param [in,out] calendar - 49 * Pointer to dnx_ofp_rates_cal_egq_t. 'calendar' is made out of an array of 'slots'. Each 50 * slot is represented by two parameters: 'base qpair' (= port index) and its corresponding number 51 * of 'credit's that the system is supposed to supply to that port when its turn comes. 52 * Of these two parameters, 'base qpair' is INPUT and 'credit' is OUTPUT of this procedure. 53 * Caller is responsible to set 'calendar' with enough space to accommodate 'calendar_length' 54 * slots. 55 * \return 56 * If zero (_SHR_E_NONE), then no error was encountered. 57 * Otherwise, see shr_error_e 58 * \remark 59 * * None 60 * \see 61 * * dnx_ofp_rates_from_egq_ports_rates_to_generic_calendar 62 */ 63 int dnx_algo_ofp_rates_fill_shaper_generic_calendar_credits( 64 int unit, 65 int core, 66 dnx_ofp_rates_cal_info_t * cal_info, 67 uint32 *ports_rates, 68 /* 69 * Actual Calendar length 70 */ 71 uint32 calendar_len, 72 /* 73 * Indicate if last entry is dummy or not 74 */ 75 uint8 add_dummy_tail, 76 dnx_ofp_rates_cal_egq_t * calendar); 77 /** 78 * \brief 79 * build calendar for provided slotes-per-object and provided calendar length. 80 * 81 * The algorith works as the following. 82 * 83 * Each time algoritm selects object with maximal number of slots. It allocates slots for this object using 84 * two sizes of hopes. 85 * The hope sizes are : (cal_len/nof_slots_of_max_object + 1) and (cal_len/nof_slots_of_max_object). 86 * This results in calendar as spaced as possible without having any leftover while still going over all the calendar. 87 * 88 * \param [in] unit - unit id 89 * \param [in] slots_per_object - number of slots to allocate to each object 90 * \param [in] nof_objects - total number of objects - size of slots_per_object 91 * \param [in] calendar_len - length of the required calendar 92 * \param [in] max_calendar_len - maximal possible calendar length 93 * \param [out] calendar - the result calendar 94 * 95 * \return 96 * shr_error_e - Error Type 97 * \remark 98 * 99 * \see 100 * * None 101 */ 102 shr_error_e dnx_algo_cal_simple_fixed_len_cal_build( 103 int unit, 104 uint32 *slots_per_object, 105 uint32 nof_objects, 106 uint32 calendar_len, 107 uint32 max_calendar_len, 108 uint32 *calendar); 109 110 /** 111 * \brief 112 * build best calendar for provided object rates, total bandwidth and maximal calendar length 113 * 114 * \param [in] unit - unit id 115 * \param [in] rates_per_object - rate of each object port 116 * \param [in] nof_objects - number of objects - length of rates_per_object 117 * \param [in] total_bandwidth - total bandwidth of the whole calendar 118 * \param [in] max_calendar_len - maximal possible calendar length 119 * \param [out] calendar_slots - the result calendar 120 * \param [out] calendar_len - the length of the result calendar 121 * 122 * \return 123 * shr_error_e - Error Type 124 * \remark 125 * 126 * \see 127 * * None 128 */ 129 shr_error_e dnx_algo_cal_simple_from_rates_to_calendar( 130 int unit, 131 uint32 *rates_per_object, 132 uint32 nof_objects, 133 uint32 total_bandwidth, 134 uint32 max_calendar_len, 135 uint32 *calendar_slots, 136 uint32 *calendar_len); 137 138 /** 139 * \brief 140 * get rate of the provided object (object_id) in the provided calendar 141 * 142 * \param [in] unit - unit id 143 * \param [in] calendar - the input calendar 144 * \param [in] calendar_len - the length of the calendar 145 * \param [in] total_cal_rate - total bandwidth of the whole calendar 146 * \param [in] object_id - object ID 147 * \param [out] object_rate - the rate of the object in the calendar 148 * 149 * \return 150 * shr_error_e - Error Type 151 * \remark 152 * 153 * \see 154 * * None 155 */ 156 shr_error_e dnx_algo_cal_simple_object_rate_get( 157 int unit, 158 uint32 *calendar, 159 uint32 calendar_len, 160 uint32 total_cal_rate, 161 int object_id, 162 uint32 *object_rate); 163 164 #endif