00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <assert.h>
00029 #include <string.h>
00030 #include "kapi_internal.h"
00031 #include "kapi_util.h"
00032 #include "kapi_error.h"
00033 #include "kapi_bv.h"
00034 #include "kapi_ia64.h"
00035
00036 #define pchNULL_PRINT( pch ) ( ( pch ) ? (pch) : "Null" )
00037
00038
00039
00040
00041
00042
00043
00044 int
00045 KAPI_BundleIssueWidth( void *pConfig, kapi_cluster_t cluster )
00046 {
00047 knobs_t *pknobs = pConfig;
00048 assert ((pknobs->maxBundleIssue!=NULL) && "Bundle issue width information not presnt!\n");
00049
00050 if ( cluster == -1 ) {
00051 int i, total;
00052
00053 total = 0;
00054 for ( i=0; i<pknobs->nclr; i++ ) {
00055 total += pknobs->maxBundleIssue[ i ];
00056 }
00057 return( total );
00058 } else {
00059 return( pknobs->maxBundleIssue[ cluster ] );
00060 }
00061 }
00062
00063 int
00064 KAPI_DisperseCount4syl( void *pConfig, kapi_syl_t syl )
00065 {
00066 knobs_t *pknobs = pConfig;
00067 assert((pknobs->mpnut!=NULL) && "syllable information not present!\n");
00068
00069 switch( syl ) {
00070 case kapi_sylI:
00071 return( pknobs->mpnut[ kapi_utI ] );
00072 case kapi_sylF:
00073 return( pknobs->mpnut[ kapi_utF ] );
00074 case kapi_sylM:
00075 return( pknobs->mpnut[ kapi_utM ] );
00076 case kapi_sylB:
00077 return( pknobs->mpnut[ kapi_utB ] );
00078
00079 case kapi_sylL: {
00080 int iclr, t;
00081
00082 t = 0;
00083 for ( iclr=0; iclr<pknobs->nclr; iclr++ ) {
00084 t += pknobs->maxBundleIssue[ iclr ];
00085 }
00086 return( t );
00087 }
00088 default:
00089 assert( 0 );
00090 return 0;
00091 }
00092 }
00093
00094 int
00095 KAPI_fuCount( void *pConfig )
00096 {
00097 knobs_t *pknobs = pConfig;
00098 return( pknobs->nfuinfoTable );
00099 }
00100
00101
00102
00103 char *
00104 KAPI_fu2fuName( void *pConfig, kapi_fu_t fu, int iVariant )
00105 {
00106 knobs_t *pknobs = (knobs_t *)pConfig;
00107 fuinfo_t *pfuinfo;
00108
00109
00110 assert(fu<pknobs->nfuinfoTable);
00111 pfuinfo = &(pknobs->dmpfuinfoTable[fu]);
00112
00113 assert(pfuinfo != NULL);
00114 assert(pfuinfo->fu == fu);
00115 assert(strcmp(KAPI_EnumName( pknobs, pfuinfo->fu, "fu_t" ),pfuinfo->pchName)==0);
00116
00117 return (pfuinfo->pchName);
00118 }
00119
00120
00121 int KAPI_fuName2fuIndex( void *pConfig, char *fuName )
00122 {
00123 knobs_t *pknobs = (knobs_t *)pConfig;
00124 fuinfo_t *pfuinfo;
00125 int fu;
00126
00127 for (fu=0;fu<pknobs->nfuinfoTable;fu++)
00128 {
00129 pfuinfo = &(pknobs->dmpfuinfoTable[fu]);
00130 assert(pfuinfo != NULL);
00131 if (strcmp(pfuinfo->pchName,fuName)==0)
00132 return (pfuinfo->fu);
00133 }
00134
00135 return (-1);
00136 }
00137
00138 bv32_t KAPI_fuGetMiscInfo(void *pConfig, kapi_fu_t fu)
00139 {
00140 knobs_t *pknobs = (knobs_t *)pConfig;
00141 fuinfo_t *pfuinfo;
00142
00143 pfuinfo = &(pknobs->dmpfuinfoTable[fu]);
00144 assert(pfuinfo != NULL);
00145
00146 return pfuinfo->bv32InfoBits;
00147
00148 }
00149
00150 kapi_latency_type_t KAPI_fuGetLatencyType(void *pConfig, kapi_fu_t fu)
00151 {
00152 knobs_t *pknobs = (knobs_t *)pConfig;
00153 fuinfo_t *pfuinfo;
00154
00155 pfuinfo = &(pknobs->dmpfuinfoTable[fu]);
00156 assert(pfuinfo != NULL);
00157
00158 if (isbv32BITSET(pfuinfo->bv32InfoBits,kapi_fu_info_approximate_latency))
00159 return kapi_latency_type_approximate;
00160 if (isbv32BITSET(pfuinfo->bv32InfoBits,kapi_fu_info_no_latency_info))
00161 return kapi_latency_type_none;
00162 return kapi_latency_type_full;
00163 }
00164
00165 int
00166 KAPI_clusterCount( void *pConfig )
00167 {
00168 knobs_t *pknobs = pConfig;
00169
00170 return( pknobs->nclr );
00171 }
00172
00173
00174 bv32_t
00175 KAPI_cportMask4fu( void *pConfig, kapi_cluster_t cluster, kapi_fu_t fu )
00176 {
00177 int i;
00178 cportinfo_t *pcportinfo;
00179 bv32_t bv32;
00180 knobs_t *pknobs = pConfig;
00181
00182 bv32 = 0;
00183 KAPI_error_attribute = 0;
00184 if ( cluster == -1 ) {
00185 fprintf( stderr, "-1 argument to KAPI_cportMask4fu no longer supported\n" );
00186 fflush( stderr );
00187 assert( 0 );
00188 } else if ( cluster < pknobs->nclr ) {
00189 clr_t *pclr;
00190
00191 pclr = &(pknobs->mpclrTable[ cluster ]);
00192
00193 for ( i=0; i<pclr->ncports; i++ ) {
00194 pcportinfo = pclr->mppcportinfoTable[ i ];
00195
00196 if ( isbvBITSET( &(pcportinfo->bvfuAllowed), fu ) ) {
00197 bv32 |= ( 1 << i );
00198 }
00199 }
00200 } else {
00201 KAPI_error_attribute = -1;
00202 bv32 = 0;
00203 }
00204
00205 return( bv32 );
00206 }
00207
00208 bv32_t
00209 KAPI_cportMask4ut( void *pConfig, kapi_cluster_t cluster, kapi_ut_t ut )
00210 {
00211 knobs_t *pknobs = pConfig;
00212 int i;
00213 cportinfo_t *pcportinfo;
00214 bv32_t bv32;
00215
00216 bv32 = 0;
00217 if ( cluster == -1 ) {
00218 fprintf( stderr, "-1 argument to KAPI_cportMask4ut no longer supported\n" );
00219 fflush( stderr );
00220 assert( 0 );
00221 } else if ( cluster < pknobs->nclr ) {
00222 clr_t *pclr;
00223
00224 pclr = &(pknobs->mpclrTable[ cluster ]);
00225
00226 for ( i=0; i<pclr->ncports; i++ ) {
00227 pcportinfo = pclr->mppcportinfoTable[ i ];
00228 assert( pcportinfo );
00229
00230 if ( pcportinfo->ut == ut) {
00231 bv32 |= ( 1 << i );
00232 }
00233 }
00234 } else {
00235 KAPI_error_attribute = -1;
00236 bv32 = 0;
00237 }
00238
00239 return( bv32 );
00240 }
00241
00242 int
00243 KAPI_cportCount( void *pConfig, kapi_cluster_t cluster )
00244 {
00245 knobs_t *pknobs = pConfig;
00246
00247 if ( cluster == -1 ) {
00248 return( pknobs->nports );
00249 } else if ( cluster >= pknobs->nclr ) {
00250 return( 0 );
00251 } else {
00252 return( pknobs->mpclrTable[ cluster ].ncports );
00253 }
00254 }
00255
00256 int
00257 KAPI_cutportCount( void *pConfig, kapi_cluster_t cluster, kapi_ut_t utIn )
00258 {
00259 knobs_t *pknobs = pConfig;
00260 int cnt;
00261
00262 if ( cluster == -1 ) {
00263 cnt = pknobs->mpnut[ utIn ];
00264 } else if ( cluster >= pknobs->nclr ) {
00265 cnt = 0;
00266 } else {
00267 cnt = pknobs->mpclrTable[ cluster ].mpncutport[ utIn ];
00268 }
00269
00270 return( cnt );
00271 }
00272
00273 int
00274 KAPI_cportCount4fu( void *pConfig, kapi_cluster_t cluster, kapi_fu_t fu )
00275 {
00276 int port, cnt;
00277 cportinfo_t *pcportinfo;
00278 knobs_t *pknobs = pConfig;
00279
00280 if ( cluster >= pknobs->nclr ) {
00281 return( 0 );
00282 }
00283
00284 assert( fu < pknobs->nfuinfoTable );
00285
00286 cnt = 0;
00287 for ( port=0; port<pknobs->nports; port++ ) {
00288 pcportinfo = pknobs->mppportinfoTable[ port ];
00289
00290 assert( pcportinfo && pcportinfo->bvfuAllowed.pint32Data );
00291 if ( isbvBITSET( &(pcportinfo->bvfuAllowed), fu ) ) {
00292 if ( cluster == -1 ||
00293 cluster == pknobs->port2cluster[ port ] ) {
00294 cnt++;
00295 }
00296 }
00297 }
00298
00299 return( cnt );
00300 }
00301
00302
00303 int
00304 KAPI_cportCount4ut( void *pConfig, kapi_cluster_t cluster, kapi_ut_t ut )
00305 {
00306 int port, cnt;
00307 cportinfo_t *pcportinfo;
00308 knobs_t *pknobs = pConfig;
00309
00310 if ( cluster >= pknobs->nclr ) {
00311 return( 0 );
00312 }
00313
00314 assert( ut < pknobs->nfuinfoTable );
00315
00316 cnt = 0;
00317 for ( port=0; port<pknobs->nports; port++ ) {
00318 pcportinfo = pknobs->mppportinfoTable[ port ];
00319
00320 assert( pcportinfo && pcportinfo->bvfuAllowed.pint32Data );
00321 if ( pcportinfo->ut==ut ) {
00322 if ( cluster == -1 ||
00323 cluster == pknobs->port2cluster[ port ] ) {
00324 cnt++;
00325 }
00326 }
00327 }
00328
00329 return( cnt );
00330 }
00331
00332
00333 void
00334 KAPI_portInfo( void *pConfig, kapi_port_t port,
00335 kapi_cluster_t *pcluster, kapi_cport_t *pcport,
00336 kapi_ut_t *put, kapi_cutport_t *pcutport )
00337 {
00338 knobs_t *pknobs = pConfig;
00339 cportinfo_t *pcportTmp;
00340
00341 assert(port != -1 && "Port must be specified!\n");
00342 assert((pknobs->mppportinfoTable!=NULL) && "port info not present!\n");
00343
00344 KAPI_error_attribute = 0;
00345
00346 pcportTmp = pknobs->mppportinfoTable[ port ];
00347
00348 *pcluster = pknobs->port2cluster[ port ];
00349 *pcport = pcportTmp->cport;
00350 *put = pcportTmp->ut;
00351 *pcutport = pcportTmp->cutport;
00352 }
00353
00354
00355 void
00356 KAPI_cportInfo( void *pConfig, kapi_cluster_t cluster, kapi_cport_t cport,
00357 kapi_port_t *pport, kapi_ut_t *put, kapi_cutport_t *pcutport )
00358 {
00359 knobs_t *pknobs = pConfig;
00360 cportinfo_t *pcport;
00361 clr_t *pclr;
00362
00363 assert(cluster != -1 && "Cluster must be specified!\n");
00364 assert(cport != -1 && "Cport must be specified!\n");
00365 assert((pknobs->mpclrTable!=NULL) && "cport info not present!\n");
00366
00367 KAPI_error_attribute = 0;
00368
00369 pclr = &(pknobs->mpclrTable[ cluster ]);
00370
00371 pcport = pclr->mppcportinfoTable[ cport ];
00372
00373 *pport = pclr->cport2port[ cport ];
00374 *put = pcport->ut;
00375 *pcutport = pcport->cutport;
00376 }
00377
00378 void
00379 KAPI_cutportInfo( void *pConfig, kapi_cluster_t cluster,
00380 kapi_ut_t ut, kapi_cutport_t cutport,
00381 kapi_port_t *pport, kapi_cport_t *pcport )
00382 {
00383 knobs_t *pknobs = pConfig;
00384 kapi_cport_t cport;
00385 clr_t *pclr;
00386
00387 assert(cluster != -1 && "Cluster must be specified!\n");
00388 assert(!((ut == -1 && cutport != -1) || (ut != -1 && cutport == -1))
00389 && "ut and cutport must either both be specified or neither specified");
00390
00391 assert((pknobs->mpclrTable!=NULL) && "cport info not present!\n");
00392 pclr = &(pknobs->mpclrTable[ cluster ]);
00393
00394 assert((pclr->dmppcportinfoTable!=NULL) && "cutport info not present!\n");
00395
00396 if (ut == -1 && cutport == -1)
00397 {
00398 *pcport = -1; *pport = -1;
00399 }
00400 else
00401 {
00402 cport = pclr->dmppcportinfoTable[ ut ][ cutport ].cport;
00403
00404 *pcport = cport;
00405 *pport = pclr->cport2port[ cport ];
00406
00407 KAPI_error_attribute = 0;
00408 }
00409 }
00410
00411