tas.h (7213B)
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-2020 Broadcom Inc. All rights reserved. 6 * 7 * File: tas.h 8 * Purpose: Definitions for TAS. 9 */ 10 11 #ifndef _BCM_INT_TAS_H_ 12 #define _BCM_INT_TAS_H_ 13 14 #include <bcm/types.h> 15 #include <bcm/cosq.h> 16 17 #ifdef BCM_TAS_SUPPORT 18 /* 19 * Macro: 20 * TAS_ALLOC 21 * Purpose: 22 * Generic memory allocation routine. 23 * Parameters: 24 * _unit_ - Unit. 25 * _ptr_ - Pointer to allocated memory. 26 * _ptype_ - Pointer type. 27 * _size_ - Size of heap memory to be allocated. 28 * _descr_ - Information about this memory allocation. 29 * _dma_ - use sal_alloc or soc_cm_alloc. 30 * _rv_ - return value 31 */ 32 #define TAS_ALLOC(_unit_, _ptr_, _ptype_, _size_, _descr_, _dma_, _rv_) \ 33 do { \ 34 if (NULL == (_ptr_)) { \ 35 if (0 == (_dma_)) { \ 36 (_ptr_) = (_ptype_ *) sal_alloc((_size_), (_descr_)); \ 37 } else { \ 38 (_ptr_) = (_ptype_ *)soc_cm_salloc((_unit_), (_size_), \ 39 (_descr_)); \ 40 } \ 41 if ((_ptr_) != NULL) { \ 42 sal_memset((_ptr_), 0, (_size_)); \ 43 _rv_ = BCM_E_NONE; \ 44 } else { \ 45 LOG_ERROR(BSL_LS_BCM_TAS, \ 46 (BSL_META("TAS Error: Allocation failure "\ 47 "%s\n"), (_descr_))); \ 48 _rv_ = BCM_E_MEMORY; \ 49 } \ 50 }\ 51 } while (0) 52 53 #define TAS_FREE(_unit_, _ptr_, _dma_) \ 54 do {\ 55 if (0 == (_dma_)) { \ 56 sal_free((_ptr_)); \ 57 } else { \ 58 soc_cm_sfree((_unit_), (_ptr_)); \ 59 }\ 60 } while (0) 61 62 /* Define maximum nanosecond value is 10^9 */ 63 #define TAS_PTP_TIME_NANOSEC_MAX (1000000000) 64 65 /* TAS profile event type */ 66 typedef enum { 67 bcmiTASProfileEventTODWindow = 0, 68 bcmiTASProfileEventProfileChange = 1, 69 bcmiTASProfileEventECCErr = 2, 70 bcmiTASProfileEventNextCycleTimeErr = 3, 71 bcmiTASProfileEventBaseTimeErr = 4, 72 bcmiTASProfileEventPtrErr = 5, 73 bcmiTASProfileEventTASDisable = 6, 74 bcmiTASProfileEventCount = 7 75 } bcmi_tas_profile_event_type_t; 76 77 /* Callback function to notify the config_change_time when the profile state 78 from comitted to pending */ 79 typedef int (*profile_commit_cb_fn)(int unit, bcm_port_t lport, 80 bcm_ptp_timestamp_t config_change_time, 81 void *fn_data); 82 83 /* Callback function to nofity the profile event */ 84 typedef int (*profile_event_cb_fn)(int unit, bcm_port_t lport, 85 bcmi_tas_profile_event_type_t event); 86 87 typedef struct tas_drv_s { 88 int (*tas_control_set)(int, bcm_port_t, bcm_cosq_tas_control_t, int); 89 int (*tas_control_get)(int, bcm_port_t, bcm_cosq_tas_control_t, int *); 90 int (*tas_status_get)(int, bcm_port_t, bcm_cosq_tas_status_t, int *); 91 int (*tas_profile_init)(int unit, profile_event_cb_fn cb); 92 int (*tas_profile_deinit)(int unit); 93 int (*tas_profile_param_check)(int unit, bcm_cosq_tas_profile_t *profile); 94 int (*tas_profile_basetime_check)(int unit, bcm_ptp_timestamp_t basetime); 95 int (*tas_profile_delay_param_get)(int unit, 96 int tas_delay_param, 97 bcm_port_t port, uint32 qmap, 98 int *value); 99 int (*tas_profile_idx_get)(int unit, bcm_port_t lport, int *config_idx); 100 int (*tas_profile_entries_write)(int unit, bcm_port_t lport, int config_idx, 101 bcm_cosq_tas_entry_t *entries, 102 int num_entries); 103 int (*tas_profile_schedule_config)(int unit, bcm_port_t lport, 104 bcm_ptp_timestamp_t base_time, 105 uint32 cycle_time, 106 uint32 cycle_extension, 107 profile_commit_cb_fn cb, 108 void *fn_data); 109 int (*tas_profile_change)(int unit, bcm_port_t lport); 110 #ifdef BCM_WARM_BOOT_SUPPORT 111 int (*tas_profile_sync)(int unit); 112 #endif 113 } tas_drv_t; 114 115 #ifdef BCM_WARM_BOOT_SUPPORT 116 extern int 117 bcmi_esw_tas_sync(int unit); 118 #endif /* BCM_WARM_BOOT_SUPPORT */ 119 120 extern int 121 bcmi_esw_tas_init(int unit); 122 123 extern int 124 bcmi_esw_tas_deinit(int unit); 125 126 extern int 127 bcmi_esw_tas_status_get( 128 int unit, 129 bcm_gport_t port, 130 bcm_cosq_tas_status_t type, 131 int *arg); 132 133 extern int 134 bcmi_esw_tas_control_get( 135 int unit, 136 bcm_gport_t port, 137 bcm_cosq_tas_control_t type, 138 int *arg); 139 140 extern int 141 bcmi_esw_tas_control_set( 142 int unit, 143 bcm_gport_t port, 144 bcm_cosq_tas_control_t type, 145 int arg); 146 147 extern int 148 bcmi_esw_tas_profile_create( 149 int unit, 150 bcm_gport_t port, 151 bcm_cosq_tas_profile_t *profile, 152 bcm_cosq_tas_profile_id_t *pid); 153 154 extern int 155 bcmi_esw_tas_profile_commit( 156 int unit, 157 bcm_gport_t port, 158 bcm_cosq_tas_profile_id_t pid); 159 160 extern int 161 bcmi_esw_tas_profile_destroy( 162 int unit, 163 bcm_gport_t port, 164 bcm_cosq_tas_profile_id_t pid); 165 166 extern int 167 bcmi_esw_tas_profile_destroy_all( 168 int unit, 169 bcm_gport_t port); 170 171 extern int 172 bcmi_esw_tas_profile_get( 173 int unit, 174 bcm_gport_t port, 175 bcm_cosq_tas_profile_id_t pid, 176 bcm_cosq_tas_profile_t *profile); 177 178 extern int 179 bcmi_esw_tas_profile_set( 180 int unit, 181 bcm_gport_t port, 182 bcm_cosq_tas_profile_id_t pid, 183 bcm_cosq_tas_profile_t *profile); 184 185 extern int 186 bcmi_esw_tas_profile_traverse( 187 int unit, 188 bcm_gport_t port, 189 bcm_cosq_tas_profile_traverse_cb cb, 190 void *user_data); 191 192 extern int 193 bcmi_esw_tas_profile_status_get( 194 int unit, 195 bcm_gport_t port, 196 bcm_cosq_tas_profile_id_t pid, 197 bcm_cosq_tas_profile_status_t *status); 198 199 /* TAS property types */ 200 /* spn_TAS_CALENDAR_AUTO_ADJUST_FOR_TXOVERRUN */ 201 #define TAS_PROP_TXOVERRUN (0x1) 202 /* spn_TAS_CALENDAR_AUTO_ADJUST_FOR_HOLDADVANCE */ 203 #define TAS_PROP_HOLDADVANCE (0x2) 204 /* spn_TAS_CALENDAR_AUTO_ADJUST_REF_MAXSDU */ 205 #define TAS_PROP_MAXSDU (0x3) 206 extern int 207 bcmi_esw_tas_property_get( 208 int unit, 209 int tas_prop, 210 int port, 211 int cos, 212 int *value); 213 214 /* TAS delay paramters */ 215 #define TAS_DPARAM_TGCR_FIXED (0x1) /* Tgcr value independent from queue */ 216 #define TAS_DPARAM_TGCR_DYNAMIC (0x2) /* Tgcr value depends on queue */ 217 #define TAS_DPARAM_THA (0x3) /* Tha value */ 218 extern int 219 bcmi_esw_tas_profile_delay_param_get( 220 int unit, 221 int tas_delay_param, 222 bcm_port_t port, 223 uint32 qmap, 224 int *value); 225 226 extern int 227 bcmi_tas_current_time(int unit, bcm_ptp_timestamp_t *current_time); 228 229 extern uint64 230 bcmi_tas_ptp_to_ns(bcm_ptp_timestamp_t ptp_time); 231 232 extern void 233 bcmi_tas_ns_to_ptp(uint64 ns, bcm_ptp_timestamp_t *ptp_time); 234 235 #endif /* BCM_TAS_SUPPORT */ 236 #endif /* _BCM_INT_TAS_H_ */