10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 53434Sesaxe * Common Development and Distribution License (the "License"). 63434Sesaxe * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 223434Sesaxe * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <sys/types.h> 290Sstevel@tonic-gate #include <sys/machsystm.h> 300Sstevel@tonic-gate #include <sys/cmp.h> 314606Sesaxe #include <sys/cmt.h> 320Sstevel@tonic-gate 330Sstevel@tonic-gate /* 340Sstevel@tonic-gate * Note: For now assume the chip ID as 0 for all the cpus until additional 350Sstevel@tonic-gate * information is available via machine description table 360Sstevel@tonic-gate */ 370Sstevel@tonic-gate 380Sstevel@tonic-gate /* 390Sstevel@tonic-gate * Returns 1 if cpuid is CMP-capable, 0 otherwise. 400Sstevel@tonic-gate */ 410Sstevel@tonic-gate /*ARGSUSED*/ 420Sstevel@tonic-gate int 430Sstevel@tonic-gate cmp_cpu_is_cmp(processorid_t cpuid) 440Sstevel@tonic-gate { 450Sstevel@tonic-gate return (0); 460Sstevel@tonic-gate } 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* 490Sstevel@tonic-gate * Indicate that this core (cpuid) resides on the chip indicated by chipid. 500Sstevel@tonic-gate * Called during boot and DR add. 510Sstevel@tonic-gate */ 520Sstevel@tonic-gate /*ARGSUSED*/ 530Sstevel@tonic-gate void 540Sstevel@tonic-gate cmp_add_cpu(chipid_t chipid, processorid_t cpuid) 550Sstevel@tonic-gate { 560Sstevel@tonic-gate } 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* 590Sstevel@tonic-gate * Indicate that this core (cpuid) is being DR removed. 600Sstevel@tonic-gate */ 610Sstevel@tonic-gate /*ARGSUSED*/ 620Sstevel@tonic-gate void 630Sstevel@tonic-gate cmp_delete_cpu(processorid_t cpuid) 640Sstevel@tonic-gate { 650Sstevel@tonic-gate } 660Sstevel@tonic-gate 670Sstevel@tonic-gate /* 680Sstevel@tonic-gate * Called when cpuid is being onlined or offlined. If the offlined 690Sstevel@tonic-gate * processor is CMP-capable then current target of the CMP Error Steering 700Sstevel@tonic-gate * Register is set to either the lowest numbered on-line sibling core, if 710Sstevel@tonic-gate * one exists, or else to this core. 720Sstevel@tonic-gate */ 730Sstevel@tonic-gate /*ARGSUSED*/ 740Sstevel@tonic-gate void 750Sstevel@tonic-gate cmp_error_resteer(processorid_t cpuid) 760Sstevel@tonic-gate { 770Sstevel@tonic-gate } 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* 800Sstevel@tonic-gate * Return 0, shortterm workaround until MD table is updated 810Sstevel@tonic-gate * to provide cpu-chip mapping 820Sstevel@tonic-gate */ 830Sstevel@tonic-gate 840Sstevel@tonic-gate /*ARGSUSED*/ 850Sstevel@tonic-gate chipid_t 860Sstevel@tonic-gate cmp_cpu_to_chip(processorid_t cpuid) 870Sstevel@tonic-gate { 884732Sdavemq return (cpu[cpuid]->cpu_m.cpu_chip); 890Sstevel@tonic-gate } 900Sstevel@tonic-gate 913434Sesaxe /*ARGSUSED*/ 923434Sesaxe int 933434Sesaxe pg_plat_hw_shared(cpu_t *cp, pghw_type_t hw) 940Sstevel@tonic-gate { 953434Sesaxe switch (hw) { 963434Sesaxe case PGHW_IPIPE: 973434Sesaxe return (1); 983434Sesaxe case PGHW_FPU: 993434Sesaxe return (1); 1004769Sdp78419 case PGHW_MPIPE: 1013434Sesaxe return (1); 1023434Sesaxe } 1033434Sesaxe return (0); 1040Sstevel@tonic-gate } 1050Sstevel@tonic-gate 1063434Sesaxe int 1073434Sesaxe pg_plat_cpus_share(cpu_t *cpu_a, cpu_t *cpu_b, pghw_type_t hw) 1080Sstevel@tonic-gate { 1093434Sesaxe if (pg_plat_hw_shared(cpu_a, hw) == 0 || 1103434Sesaxe pg_plat_hw_shared(cpu_b, hw) == 0) 1113434Sesaxe return (0); 1123434Sesaxe 1133434Sesaxe return (pg_plat_hw_instance_id(cpu_a, hw) == 1143434Sesaxe pg_plat_hw_instance_id(cpu_b, hw)); 1153434Sesaxe } 1160Sstevel@tonic-gate 1173434Sesaxe id_t 1183434Sesaxe pg_plat_hw_instance_id(cpu_t *cpu, pghw_type_t hw) 1193434Sesaxe { 1203434Sesaxe switch (hw) { 1213434Sesaxe case PGHW_IPIPE: 1223434Sesaxe return (cpu->cpu_m.cpu_ipipe); 123*5079Sjc25722 case PGHW_CHIP: 124*5079Sjc25722 return (cpu->cpu_m.cpu_chip); 1254769Sdp78419 case PGHW_MPIPE: 1264769Sdp78419 return (cpu->cpu_m.cpu_mpipe); 1273434Sesaxe case PGHW_FPU: 1283434Sesaxe return (cpu->cpu_m.cpu_fpu); 1293434Sesaxe default: 1303434Sesaxe return (-1); 1313434Sesaxe } 1320Sstevel@tonic-gate } 133220Sesaxe 134220Sesaxe /* 1353434Sesaxe * Order the relevant hw sharing relationships 1363434Sesaxe * from least, to greatest physical scope. 1373434Sesaxe * 1383434Sesaxe * The hierarchy *must* be defined for all hw that 1393434Sesaxe * pg_plat_hw_shared() returns non-zero. 140220Sesaxe */ 1413434Sesaxe int 1423434Sesaxe pg_plat_hw_level(pghw_type_t hw) 1433434Sesaxe { 1443434Sesaxe int i; 1453434Sesaxe static pghw_type_t hw_hier[] = { 1463434Sesaxe PGHW_IPIPE, 1473434Sesaxe PGHW_FPU, 1484769Sdp78419 PGHW_MPIPE, 1493434Sesaxe PGHW_NUM_COMPONENTS 1503434Sesaxe }; 1513434Sesaxe 1523434Sesaxe for (i = 0; hw_hier[i] != PGHW_NUM_COMPONENTS; i++) { 1533434Sesaxe if (hw_hier[i] == hw) 1543434Sesaxe return (i); 1553434Sesaxe } 1563434Sesaxe return (-1); 1573434Sesaxe } 158220Sesaxe 1594606Sesaxe /* 1604606Sesaxe * Return 1 if CMT load balancing policies should be 1614606Sesaxe * implemented across instances of the specified hardware 1624606Sesaxe * sharing relationship. 1634606Sesaxe */ 1644606Sesaxe int 1654606Sesaxe pg_plat_cmt_load_bal_hw(pghw_type_t hw) 1664606Sesaxe { 1674606Sesaxe if (hw == PGHW_IPIPE || 1684606Sesaxe hw == PGHW_FPU || 1694769Sdp78419 hw == PGHW_MPIPE) 1704606Sesaxe return (1); 1714606Sesaxe else 1724606Sesaxe return (0); 1734606Sesaxe } 1744606Sesaxe 1754606Sesaxe 1764606Sesaxe /* 1774606Sesaxe * Return 1 if thread affinity polices should be implemented 1784606Sesaxe * for instances of the specifed hardware sharing relationship. 1794606Sesaxe */ 1804606Sesaxe int 1814606Sesaxe pg_plat_cmt_affinity_hw(pghw_type_t hw) 1824606Sesaxe { 1834606Sesaxe if (hw == PGHW_CACHE) 1844606Sesaxe return (1); 1854606Sesaxe else 1864606Sesaxe return (0); 1874606Sesaxe } 1884606Sesaxe 189220Sesaxe id_t 1903434Sesaxe pg_plat_get_core_id(cpu_t *cpu) 191220Sesaxe { 1923434Sesaxe return (cpu->cpu_m.cpu_core); 193220Sesaxe } 1943434Sesaxe 1953434Sesaxe void 1963434Sesaxe cmp_set_nosteal_interval(void) 1973434Sesaxe { 1983434Sesaxe nosteal_nsec = 0; 1993434Sesaxe } 2004769Sdp78419 /* 2014769Sdp78419 * Return 1 if CMT load balancing policies should be 2024769Sdp78419 * implemented across instances of the specified hardware 2034769Sdp78419 * sharing relationship. 2044769Sdp78419 */ 2054769Sdp78419 int 2064769Sdp78419 pg_cmt_load_bal_hw(pghw_type_t hw) 2074769Sdp78419 { 2084769Sdp78419 if (hw == PGHW_IPIPE || 2094769Sdp78419 hw == PGHW_FPU || 2104769Sdp78419 hw == PGHW_MPIPE) 2114769Sdp78419 return (1); 2124769Sdp78419 else 2134769Sdp78419 return (0); 2144769Sdp78419 } 2154769Sdp78419 /* 2164769Sdp78419 * Return 1 if thread affinity polices should be implemented 2174769Sdp78419 * for instances of the specifed hardware sharing relationship. 2184769Sdp78419 */ 2194769Sdp78419 int 2204769Sdp78419 pg_cmt_affinity_hw(pghw_type_t hw) 2214769Sdp78419 { 2224769Sdp78419 if (hw == PGHW_CACHE) 2234769Sdp78419 return (1); 2244769Sdp78419 else 2254769Sdp78419 return (0); 2264769Sdp78419 } 227