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

tdm_ap_parse.c (7591B)


      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  * $All Rights Reserved.$
      7  *
      8  * TDM chip based printing and parsing functions
      9  */
     10 #ifdef _TDM_STANDALONE
     11 	#include <tdm_top.h>
     12 #else
     13 	#include <soc/tdm/core/tdm_top.h>
     14 #endif
     15 
     16 
     17 /**
     18 @name: tdm_ap_print_tbl
     19 @param:
     20 
     21 Prints PGW TDM main calendar
     22  */
     23 void
     24 tdm_ap_print_tbl(int *cal, int len, const char* name, int id)
     25 {
     26 	int idx;
     27 	
     28 	for (idx=0; idx<len; idx++) {
     29 		TDM_PRINT4("TDM: Pipe %d, %s, Slot -- #%03d, Port -- #%0d\n", id, name, idx, cal[idx]);
     30 	}
     31 }
     32 
     33 
     34 /**
     35 @name: tdm_ap_print_tbl_ovs
     36 @param:
     37 
     38 Prints PGW TDM calendar oversub scheduling groups
     39  */
     40 void
     41 tdm_ap_print_tbl_ovs(int *cal, int *spc, int len, const char* name, int id)
     42 {
     43 	int idx;
     44 	
     45 	for (idx=0; idx<len; idx++) {
     46 		TDM_PRINT5("TDM: Pipe %d, %s, Slot -- #%03d, Port -- #%0d, Spacing -- #%0d\n", id, name, idx, cal[idx], spc[idx]);
     47 	}
     48 }
     49 
     50 
     51 /**
     52 @name: tdm_ap_print_quad
     53 @param:
     54  */
     55 void
     56 tdm_ap_print_quad(enum port_speed_e *speed, enum port_state_e *state, int len, int idx_start, int idx_end)
     57 {
     58 	int iter, iter2;
     59 	
     60 	if (idx_start>0 && idx_end<=len){
     61 		TDM_BIG_BAR
     62 		TDM_PRINT0("TDM: --- Pipe Config ---: ");
     63 		for (iter=idx_start; iter<=idx_end; iter++) {
     64 			if ((((iter-1)%18)==0)) {
     65 				TDM_PRINT0("\nTDM: ");
     66 			}		
     67 			TDM_PRINT1("{%03d}\t",(iter));
     68 			if (iter%18==0) {
     69 				TDM_PRINT0("\nTDM: ");
     70 				for (iter2=(iter-18); iter2<iter; iter2++) {
     71 					TDM_PRINT1(" %3d \t", speed[iter2+1]/1000);
     72 				}
     73 				TDM_PRINT0("\nTDM: ");
     74 				for (iter2=(iter-18); iter2<iter; iter2++) {
     75 					if (iter2%4==0){
     76 						if(speed[iter2+1]/1000>0){
     77 							switch ((PSBMP_LP_MASK & state[iter2])) {
     78 								case 1:
     79 									TDM_PRINT0("LINE \t --- \t --- \t --- \t");
     80 									break;
     81 								case 2:
     82 									TDM_PRINT0("OVSB \t --- \t --- \t --- \t");
     83 									break;
     84 								default:
     85 									TDM_PRINT0("     \t     \t     \t     \t");
     86 									break;
     87 							}
     88 						}
     89 						else{
     90 							TDM_PRINT0("     \t     \t     \t     \t");
     91 						}
     92 					}
     93 				}
     94 				TDM_PRINT0("\nTDM: ");
     95 				for (iter2=(iter-18); iter2<iter; iter2++) {
     96 					if(iter2%4==0){
     97 						if(speed[iter2+1]/1000>0){
     98 							switch(( PSBMP_ENCAP_HIGIG & state[iter2])){
     99 								case 0:
    100 									TDM_PRINT0("  EN \t --- \t --- \t --- \t");
    101 									break;
    102 								case 4:
    103 									TDM_PRINT0("  HG \t --- \t --- \t --- \t");
    104 									break;
    105 								default:
    106 									TDM_PRINT0("     \t     \t     \t     \t");
    107 									break;
    108 							}
    109 						}
    110 						else{
    111 							TDM_PRINT0("     \t     \t     \t     \t");
    112 						}
    113 					}
    114 				}
    115 			}
    116 		}
    117 		TDM_PRINT0("\n");
    118 		TDM_BIG_BAR
    119 	}
    120 
    121 }
    122 
    123 
    124 
    125 
    126 /**
    127 @name: tdm_ap_parse_mmu_tdm_tbl
    128 @param:
    129  */
    130 int
    131 tdm_ap_parse_mmu_tdm_tbl( tdm_mod_t *_tdm )
    132 {
    133 	const char *name;
    134 	int j, k=512, m=0,
    135 		*mmu_tdm_tbl, *mmu_tdm_ovs_1, *mmu_tdm_ovs_2, *mmu_tdm_ovs_3, *mmu_tdm_ovs_4, *mmu_tdm_ovs_5, *mmu_tdm_ovs_6,
    136 		bw=_tdm->_chip_data.soc_pkg.clk_freq;
    137 	  tdm_calendar_t *cal;
    138 	
    139 	switch (_tdm->_core_data.vars_pkg.cal_id) {
    140 		case 0:	cal=(&(_tdm->_chip_data.cal_0)); break;
    141 		case 1:	cal=(&(_tdm->_chip_data.cal_1)); break;
    142 		case 2:	cal=(&(_tdm->_chip_data.cal_2)); break;
    143 		case 3:	cal=(&(_tdm->_chip_data.cal_3)); break;
    144 		case 4:	cal=(&(_tdm->_chip_data.cal_4)); break;
    145 		case 5:	cal=(&(_tdm->_chip_data.cal_5)); break;
    146 		case 6:	cal=(&(_tdm->_chip_data.cal_6)); break;
    147 		case 7:	cal=(&(_tdm->_chip_data.cal_7)); break;
    148 		default:													
    149 			TDM_PRINT1("Invalid calendar ID - %0d\n",_tdm->_core_data.vars_pkg.cal_id);		
    150 			return (TDM_EXEC_CORE_SIZE+1);							
    151 	}
    152 	switch (_tdm->_core_data.vars_pkg.cal_id) {
    153 		case 2: name = "X-PIPE"; break;
    154 		default: name = "UNKNOWN"; break;
    155 	}	
    156 	mmu_tdm_tbl = cal->cal_main;
    157 	mmu_tdm_ovs_1 = cal->cal_grp[0];
    158 	mmu_tdm_ovs_2 = cal->cal_grp[1];
    159 	mmu_tdm_ovs_3 = cal->cal_grp[2];
    160 	mmu_tdm_ovs_4 = cal->cal_grp[3];
    161 	mmu_tdm_ovs_5 = cal->cal_grp[4];
    162 	mmu_tdm_ovs_6 = cal->cal_grp[5];
    163 
    164 /*for (j=0; j<16; j++) {
    165 		if (mmu_tdm_ovs_1[j]!=TD2P_NUM_EXT_PORTS || mmu_tdm_ovs_2[j]!=TD2P_NUM_EXT_PORTS || mmu_tdm_ovs_3[j]!=TD2P_NUM_EXT_PORTS || mmu_tdm_ovs_4[j]!=TD2P_NUM_EXT_PORTS) {
    166 			oversub=BOOL_TRUE;
    167 		}
    168 	}*/
    169 	/* Allocate slots for MGMT, CMIC/LPBK, ANCL and RERESH among available AP_ANCL_TOKENs */
    170 	for (j=0; j<k; j++) {
    171 		if (mmu_tdm_tbl[j]!=AP_ANCL_TOKEN) {
    172 			TDM_PRINT3("PIPE: %s, MMU TDM TABLE, element #%0d, contains physical port #%0d\n", name, j, mmu_tdm_tbl[j]);
    173 		}
    174 	 	else {
    175 			TDM_PRINT2("PIPE: %s, MMU TDM TABLE, element #%0d, CONTAINS ACCESSORY TOKEN - assigned as ", name, j);
    176 			m++;
    177 			if (bw==933) {
    178 				if (_tdm->_core_data.vars_pkg.cal_id==AP_XPIPE_CAL_ID) {
    179 					switch (m) {
    180 						case 1: case 3: case 5: case 7:
    181 							AP_ANCL(j)
    182 						case 2: case 6: 
    183 							AP_CMIC(j)
    184             case 4: case 9:
    185 							AP_LPBK(j)
    186             case 8:
    187 							AP_SBUS(j)
    188 					}
    189 				}
    190 			}
    191 			else if (bw==840) {
    192 				if (_tdm->_core_data.vars_pkg.cal_id==AP_XPIPE_CAL_ID) {
    193 					switch (m) {
    194 						case 1: case 3: case 5: case 7:
    195 							AP_ANCL(j)
    196 						case 2: case 6: 
    197 							AP_CMIC(j)
    198             case 4: case 9:
    199 							AP_LPBK(j)
    200             case 8:
    201 							AP_SBUS(j)
    202 					}
    203 				}
    204 			}
    205 			else if (bw==793 || bw==794 || bw==795 || bw==796 || bw==797) {
    206 				if (_tdm->_core_data.vars_pkg.cal_id==AP_XPIPE_CAL_ID) {
    207 					switch (m) {
    208 						case 1: case 3: case 5: case 7: case 9: case 11: case 13: case 15: case 17:
    209 							AP_ANCL(j)
    210 						case 2: case 6: case 10: case 14: 
    211 							AP_LPBK(j)
    212             case 4: case 8: case 12: case 16:
    213 							AP_CMIC(j)
    214             case 18:
    215 							AP_SBUS(j)
    216 					}
    217 				}
    218 			}
    219 			else if (bw==575) {
    220 				if (_tdm->_core_data.vars_pkg.cal_id==AP_XPIPE_CAL_ID) {
    221 					switch (m) {
    222 						case 1: case 5: 
    223 							AP_CMIC(j)
    224 						case 2: case 4: case 6: case 8:
    225 							AP_ANCL(j)
    226             case 3: case 7:
    227               AP_LPBK(j)
    228             case 9:
    229 							AP_SBUS(j)
    230 					}
    231 				}
    232 			}
    233 			else if (bw==510) {
    234 				if (_tdm->_core_data.vars_pkg.cal_id==AP_XPIPE_CAL_ID) {
    235 					switch (m) {
    236 						case 1: case 3: case 5: case 7: case 9:
    237 							AP_CMIC(j)
    238 						case 2: case 4: case 6: case 8:
    239 							AP_ANCL(j)
    240             case 10:
    241 							AP_SBUS(j)
    242 					}
    243 				}
    244 			}
    245 		  else if (bw==435) { 
    246 			  if (_tdm->_core_data.vars_pkg.cal_id==AP_XPIPE_CAL_ID) {
    247 					switch (m) {
    248 						case 1: case 3: case 6: case 8:
    249 							AP_ANCL(j)
    250             case 2: case 5: case 7:
    251               AP_LPBK(j)
    252 						case 4: case 9: 
    253 							AP_CMIC(j)
    254             case 10:
    255 							AP_SBUS(j)
    256 					}
    257         }
    258       }
    259 			else {
    260 				TDM_PRINT0("INVALID PARAMETERS\n");
    261 			}
    262 		}
    263 	}
    264 
    265 	for (j=0; j<AP_OS_VBS_GRP_LEN; j++) {
    266 		TDM_PRINT3("PIPE: %s, MMU OVS BUCKET 0, element #%0d, contains physical port #%0d\n", name, j, mmu_tdm_ovs_1[j]);
    267 	}
    268 	for (j=0; j<AP_OS_VBS_GRP_LEN; j++) {
    269 		TDM_PRINT3("PIPE: %s, MMU OVS BUCKET 1, element #%0d, contains physical port #%0d\n", name, j, mmu_tdm_ovs_2[j]);
    270 	}
    271 	for (j=0; j<AP_OS_VBS_GRP_LEN; j++) {
    272 		TDM_PRINT3("PIPE: %s, MMU OVS BUCKET 2, element #%0d, contains physical port #%0d\n", name, j, mmu_tdm_ovs_3[j]);
    273 	}
    274 	for (j=0; j<AP_OS_VBS_GRP_LEN; j++) {
    275 		TDM_PRINT3("PIPE: %s, MMU OVS BUCKET 3, element #%0d, contains physical port #%0d\n", name, j, mmu_tdm_ovs_4[j]);
    276 	}
    277 	for (j=0; j<AP_OS_VBS_GRP_LEN; j++) {
    278 		TDM_PRINT3("PIPE: %s, MMU OVS BUCKET 4, element #%0d, contains physical port #%0d\n", name, j, mmu_tdm_ovs_5[j]);
    279 	}
    280 	for (j=0; j<AP_OS_VBS_GRP_LEN; j++) {
    281 		TDM_PRINT3("PIPE: %s, MMU OVS BUCKET 5, element #%0d, contains physical port #%0d\n", name, j, mmu_tdm_ovs_6[j]);
    282 	}
    283 	
    284 	return ( ( _tdm->_core_exec[TDM_CORE_EXEC__POST]( _tdm ) ) );
    285 }