hwpmc: Move 4 bits of mode to extend class size to 8

Since r289025 we have had at least 5 bits class size.
Before that it was even 16 bits, but macro handling conversion between
pmcid and set of CPU, MODE, CLASS, ROWINDEX still use 4 bits class size
and 8 bits mode size.

This breaks some libpmc API methods, like pmc_capabilities.

Since we only have 4 modes and MODE field is a number (not a bitfield)
this patch moves 4 bits of mode to extend the CLASS field.

Reviewed by:	mhorne, emaste
Sponsored by:	Ampere Computing LLC
Submitted by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D30047
This commit is contained in:
Aleksandr Rybalko 2021-05-26 18:39:00 +00:00 committed by Allan Jude
parent c358f1857f
commit 198566e04a

View File

@ -404,7 +404,7 @@ typedef uint64_t pmc_value_t;
* | CPU | PMC MODE | CLASS | ROW INDEX |
* +-----------------------+-------+-----------+
*
* where CPU is 12 bits, MODE 8, CLASS 4, and ROW INDEX 8 Field 'CPU'
* where CPU is 12 bits, MODE 4, CLASS 8, and ROW INDEX 8 Field 'CPU'
* is set to the requested CPU for system-wide PMCs or PMC_CPU_ANY for
* process-mode PMCs. Field 'PMC MODE' is the allocated PMC mode.
* Field 'PMC CLASS' is the class of the PMC. Field 'ROW INDEX' is the
@ -415,12 +415,12 @@ typedef uint64_t pmc_value_t;
*/
#define PMC_ID_TO_ROWINDEX(ID) ((ID) & 0xFF)
#define PMC_ID_TO_CLASS(ID) (((ID) & 0xF00) >> 8)
#define PMC_ID_TO_MODE(ID) (((ID) & 0xFF000) >> 12)
#define PMC_ID_TO_CLASS(ID) (((ID) & 0xFF00) >> 8)
#define PMC_ID_TO_MODE(ID) (((ID) & 0xF0000) >> 16)
#define PMC_ID_TO_CPU(ID) (((ID) & 0xFFF00000) >> 20)
#define PMC_ID_MAKE_ID(CPU,MODE,CLASS,ROWINDEX) \
((((CPU) & 0xFFF) << 20) | (((MODE) & 0xFF) << 12) | \
(((CLASS) & 0xF) << 8) | ((ROWINDEX) & 0xFF))
((((CPU) & 0xFFF) << 20) | (((MODE) & 0xF) << 16) | \
(((CLASS) & 0xFF) << 8) | ((ROWINDEX) & 0xFF))
/*
* Data structures for system calls supported by the pmc driver.