compat_6514.c (4251B)
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 * RPC Compatibility with sdk-6.5.14 routines 8 */ 9 10 #ifdef BCM_RPC_SUPPORT 11 #include <shared/alloc.h> 12 #include <bcm/error.h> 13 #include <bcm_int/compat/compat_6514.h> 14 15 #ifdef INCLUDE_TCB 16 /* 17 * Function: 18 * _bcm_compat6514in_cosq_tcb_config_t 19 * Purpose: 20 * Convert the bcm_cosq_tcb_config_t datatype from <=6.5.14 to 21 * SDK 6.5.14+ 22 * Parameters: 23 * from - (IN) The <=6.5.14 version of the datatype 24 * to - (OUT) The SDK 6.5.14+ version of the datatype 25 * Returns: 26 * Nothing 27 */ 28 STATIC void 29 _bcm_compat6514in_cosq_tcb_config_t( 30 bcm_compat6514_cosq_tcb_config_t *from, 31 bcm_cosq_tcb_config_t *to) 32 { 33 bcm_cosq_tcb_config_t_init(to); 34 to->scope_type = from->scope_type; 35 to->gport = from->gport; 36 to->cosq = from->cosq; 37 to->trigger_reason = from->trigger_reason; 38 to->pre_freeze_capture_num = from->pre_freeze_capture_num; 39 to->pre_freeze_capture_time = from->pre_freeze_capture_time; 40 to->post_sample_probability = from->post_sample_probability; 41 to->pre_sample_probability = from->pre_sample_probability; 42 } 43 44 /* 45 * Function: 46 * _bcm_compat6514out_cosq_tcb_config_t 47 * Purpose: 48 * Convert the bcm_cosq_tcb_config_t datatype from 6.5.14+ to 49 * <=SDK 6.5.14 50 * Parameters: 51 * from - (IN) The SDK 6.5.14+ version of the datatype 52 * to - (OUT) The <=6.5.14 version of the datatype 53 * Returns: 54 * Nothing 55 */ 56 STATIC void 57 _bcm_compat6514out_cosq_tcb_config_t( 58 bcm_cosq_tcb_config_t *from, 59 bcm_compat6514_cosq_tcb_config_t *to) 60 { 61 to->scope_type = from->scope_type; 62 to->gport = from->gport; 63 to->cosq = from->cosq; 64 to->trigger_reason = from->trigger_reason; 65 to->pre_freeze_capture_num = from->pre_freeze_capture_num; 66 to->pre_freeze_capture_time = from->pre_freeze_capture_time; 67 to->post_sample_probability = from->post_sample_probability; 68 to->pre_sample_probability = from->pre_sample_probability; 69 } 70 71 /* 72 * Function: 73 * bcm_compat6514_cosq_tcb_config_get 74 * Purpose: 75 * Compatibility function for RPC call to bcm_cosq_tcb_config_get. 76 * Parameters: 77 * unit - (IN) BCM device number. 78 * buffer_id - (IN) TCB buffer id. 79 * config - (OUT) TCB config information 80 * Returns: 81 * BCM_E_XXX 82 */ 83 int 84 bcm_compat6514_cosq_tcb_config_get( 85 int unit, 86 bcm_cosq_buffer_id_t buffer_id, 87 bcm_compat6514_cosq_tcb_config_t *config) 88 { 89 int rv; 90 bcm_cosq_tcb_config_t *new_config = NULL; 91 92 if (config != NULL) { 93 new_config = (bcm_cosq_tcb_config_t*) 94 sal_alloc(sizeof(bcm_cosq_tcb_config_t), "New cosq tcb config"); 95 if (new_config == NULL) { 96 return BCM_E_MEMORY; 97 } 98 99 _bcm_compat6514in_cosq_tcb_config_t(config, new_config); 100 } 101 102 rv = bcm_cosq_tcb_config_get(unit, buffer_id, new_config); 103 104 if (new_config != NULL) { 105 _bcm_compat6514out_cosq_tcb_config_t(new_config, config); 106 sal_free(new_config); 107 } 108 109 return rv; 110 } 111 112 /* 113 * Function: 114 * bcm_compat6514_cosq_tcb_config_set 115 * Purpose: 116 * Compatibility function for RPC call to bcm_cosq_tcb_config_set. 117 * Parameters: 118 * unit - (IN) BCM device number. 119 * buffer_id - (IN) TCB buffer id. 120 * config - (OUT) TCB config information 121 * Returns: 122 * BCM_E_XXX 123 */ 124 int 125 bcm_compat6514_cosq_tcb_config_set( 126 int unit, 127 bcm_cosq_buffer_id_t buffer_id, 128 bcm_compat6514_cosq_tcb_config_t *config) 129 { 130 int rv; 131 bcm_cosq_tcb_config_t *new_config = NULL; 132 133 if (config != NULL) { 134 new_config = (bcm_cosq_tcb_config_t*) 135 sal_alloc(sizeof(bcm_cosq_tcb_config_t), "New cosq tcb config"); 136 if (new_config == NULL) { 137 return BCM_E_MEMORY; 138 } 139 140 _bcm_compat6514in_cosq_tcb_config_t(config, new_config); 141 } 142 143 rv = bcm_cosq_tcb_config_set(unit, buffer_id, new_config); 144 145 if (new_config != NULL) { 146 _bcm_compat6514out_cosq_tcb_config_t(new_config, config); 147 sal_free(new_config); 148 } 149 150 return rv; 151 } 152 #endif 153 #endif /* BCM_RPC_SUPPORT */