11fa7f10bSFabien Thomas /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 41fa7f10bSFabien Thomas * Copyright (c) 2010 Fabien Thomas 51fa7f10bSFabien Thomas * All rights reserved. 61fa7f10bSFabien Thomas * 71fa7f10bSFabien Thomas * Redistribution and use in source and binary forms, with or without 81fa7f10bSFabien Thomas * modification, are permitted provided that the following conditions 91fa7f10bSFabien Thomas * are met: 101fa7f10bSFabien Thomas * 1. Redistributions of source code must retain the above copyright 111fa7f10bSFabien Thomas * notice, this list of conditions and the following disclaimer. 121fa7f10bSFabien Thomas * 2. Redistributions in binary form must reproduce the above copyright 131fa7f10bSFabien Thomas * notice, this list of conditions and the following disclaimer in the 141fa7f10bSFabien Thomas * documentation and/or other materials provided with the distribution. 151fa7f10bSFabien Thomas * 161fa7f10bSFabien Thomas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 171fa7f10bSFabien Thomas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 181fa7f10bSFabien Thomas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 191fa7f10bSFabien Thomas * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 201fa7f10bSFabien Thomas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 211fa7f10bSFabien Thomas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 221fa7f10bSFabien Thomas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 231fa7f10bSFabien Thomas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 241fa7f10bSFabien Thomas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251fa7f10bSFabien Thomas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 261fa7f10bSFabien Thomas * SUCH DAMAGE. 271fa7f10bSFabien Thomas */ 281fa7f10bSFabien Thomas 291fa7f10bSFabien Thomas #ifndef _DEV_HWPMC_UNCORE_H_ 301fa7f10bSFabien Thomas #define _DEV_HWPMC_UNCORE_H_ 1 311fa7f10bSFabien Thomas 321fa7f10bSFabien Thomas /* 331fa7f10bSFabien Thomas * Fixed-function PMCs. 341fa7f10bSFabien Thomas */ 351fa7f10bSFabien Thomas struct pmc_md_ucf_op_pmcallocate { 361fa7f10bSFabien Thomas uint16_t pm_ucf_flags; /* additional flags */ 371fa7f10bSFabien Thomas }; 381fa7f10bSFabien Thomas 391fa7f10bSFabien Thomas #define UCF_EN 0x1 401fa7f10bSFabien Thomas #define UCF_PMI 0x4 411fa7f10bSFabien Thomas 421fa7f10bSFabien Thomas /* 431fa7f10bSFabien Thomas * Programmable PMCs. 441fa7f10bSFabien Thomas */ 451fa7f10bSFabien Thomas struct pmc_md_ucp_op_pmcallocate { 461a4614a5SAlexander Motin uint64_t pm_ucp_config; 471fa7f10bSFabien Thomas }; 481fa7f10bSFabien Thomas 491fa7f10bSFabien Thomas #define UCP_EVSEL(C) ((C) & 0xFF) 501fa7f10bSFabien Thomas #define UCP_UMASK(C) ((C) & 0xFF00) 511fa7f10bSFabien Thomas #define UCP_CTRR (1 << 17) 521fa7f10bSFabien Thomas #define UCP_EDGE (1 << 18) 531fa7f10bSFabien Thomas #define UCP_INT (1 << 20) 541fa7f10bSFabien Thomas #define UCP_EN (1 << 22) 551fa7f10bSFabien Thomas #define UCP_INV (1 << 23) 561fa7f10bSFabien Thomas #define UCP_CMASK(C) (((C) & 0xFF) << 24) 571fa7f10bSFabien Thomas #ifdef _KERNEL 581fa7f10bSFabien Thomas 591fa7f10bSFabien Thomas #define DCTL_FLAG_UNC_PMI (1ULL << 13) 601fa7f10bSFabien Thomas 611fa7f10bSFabien Thomas /* 621fa7f10bSFabien Thomas * Fixed-function counters. 631fa7f10bSFabien Thomas */ 641fa7f10bSFabien Thomas 651fa7f10bSFabien Thomas #define UCF_MASK 0xF 661fa7f10bSFabien Thomas 671fa7f10bSFabien Thomas #define UCF_CTR0 0x394 681fa7f10bSFabien Thomas 691fa7f10bSFabien Thomas #define UCF_OFFSET 32 7078d763a2SDavide Italiano #define UCF_OFFSET_SB 29 711fa7f10bSFabien Thomas #define UCF_CTRL 0x395 721fa7f10bSFabien Thomas 731fa7f10bSFabien Thomas /* 741fa7f10bSFabien Thomas * Programmable counters. 751fa7f10bSFabien Thomas */ 761fa7f10bSFabien Thomas 771fa7f10bSFabien Thomas #define UCP_PMC0 0x3B0 781fa7f10bSFabien Thomas #define UCP_EVSEL0 0x3C0 791fa7f10bSFabien Thomas #define UCP_OPCODE_MATCH 0x396 8078d763a2SDavide Italiano #define UCP_CB0_EVSEL0 0x700 811fa7f10bSFabien Thomas 821fa7f10bSFabien Thomas /* 831fa7f10bSFabien Thomas * Simplified programming interface in Intel Performance Architecture 841fa7f10bSFabien Thomas * v2 and later. 851fa7f10bSFabien Thomas */ 861fa7f10bSFabien Thomas 871fa7f10bSFabien Thomas #define UC_GLOBAL_STATUS 0x392 881fa7f10bSFabien Thomas #define UC_GLOBAL_CTRL 0x391 891fa7f10bSFabien Thomas #define UC_GLOBAL_OVF_CTRL 0x393 901fa7f10bSFabien Thomas 911fa7f10bSFabien Thomas #define UC_GLOBAL_STATUS_FLAG_CLRCHG (1ULL << 63) 921fa7f10bSFabien Thomas #define UC_GLOBAL_STATUS_FLAG_OVFPMI (1ULL << 61) 931fa7f10bSFabien Thomas #define UC_GLOBAL_CTRL_FLAG_FRZ (1ULL << 63) 941fa7f10bSFabien Thomas #define UC_GLOBAL_CTRL_FLAG_ENPMICORE0 (1ULL << 48) 951fa7f10bSFabien Thomas 963444c31aSFabien Thomas /* 973444c31aSFabien Thomas * Model specific registers. 983444c31aSFabien Thomas */ 993444c31aSFabien Thomas 1003444c31aSFabien Thomas #define MSR_GQ_SNOOP_MESF 0x301 1013444c31aSFabien Thomas 1021fa7f10bSFabien Thomas struct pmc_md_ucf_pmc { 1031fa7f10bSFabien Thomas uint64_t pm_ucf_ctrl; 1041fa7f10bSFabien Thomas }; 1051fa7f10bSFabien Thomas 1061fa7f10bSFabien Thomas struct pmc_md_ucp_pmc { 1071a4614a5SAlexander Motin uint64_t pm_ucp_evsel; 1081fa7f10bSFabien Thomas }; 1091fa7f10bSFabien Thomas 1101fa7f10bSFabien Thomas /* 1111fa7f10bSFabien Thomas * Prototypes. 1121fa7f10bSFabien Thomas */ 1131fa7f10bSFabien Thomas 1141fa7f10bSFabien Thomas int pmc_uncore_initialize(struct pmc_mdep *_md, int _maxcpu); 1151fa7f10bSFabien Thomas void pmc_uncore_finalize(struct pmc_mdep *_md); 1161fa7f10bSFabien Thomas 1171fa7f10bSFabien Thomas int pmc_ucf_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width); 1181fa7f10bSFabien Thomas void pmc_ucf_finalize(struct pmc_mdep *_md); 1191fa7f10bSFabien Thomas 1201fa7f10bSFabien Thomas int pmc_ucp_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width, 1211fa7f10bSFabien Thomas int _flags); 1221fa7f10bSFabien Thomas void pmc_ucp_finalize(struct pmc_mdep *_md); 1231fa7f10bSFabien Thomas 1241fa7f10bSFabien Thomas #endif /* _KERNEL */ 1251fa7f10bSFabien Thomas #endif /* _DEV_HWPMC_UNCORE_H */ 126