summaryrefslogtreecommitdiff
path: root/xen/include/asm-x86/psr.h
blob: c2257da7fc7817fd4fdd2371784947e06a29c4e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 * psr.h: Platform Shared Resource related service for guest.
 *
 * Copyright (c) 2014, Intel Corporation
 * Author: Dongxiao Xu <dongxiao.xu@intel.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 */
#ifndef __ASM_PSR_H__
#define __ASM_PSR_H__

#include <xen/types.h>

/* CAT cpuid level */
#define PSR_CPUID_LEVEL_CAT             0x10

/* Resource Type Enumeration */
#define PSR_RESOURCE_TYPE_L3            0x2
#define PSR_RESOURCE_TYPE_L2            0x4
#define PSR_RESOURCE_TYPE_MBA           0x8

/* L3 Monitoring Features */
#define PSR_CMT_L3_OCCUPANCY            0x1

/* CDP Capability */
#define PSR_CAT_CDP_CAPABILITY          (1u << 2)

/* L3 CDP Enable bit*/
#define PSR_L3_QOS_CDP_ENABLE_BIT       0x0

/* Used by psr_get_info() */
#define PSR_INFO_IDX_COS_MAX            0
#define PSR_INFO_IDX_CAT_CBM_LEN        1
#define PSR_INFO_IDX_CAT_FLAGS          2
#define PSR_INFO_IDX_MBA_THRTL_MAX      1
#define PSR_INFO_IDX_MBA_FLAGS          2
#define PSR_INFO_ARRAY_SIZE             3

struct psr_cmt_l3 {
    unsigned int features;
    unsigned int upscaling_factor;
    unsigned int rmid_max;
};

struct psr_cmt {
    unsigned int rmid_max;
    unsigned int features;
    domid_t *rmid_to_dom;
    struct psr_cmt_l3 l3;
};

enum psr_type {
    PSR_TYPE_L3_CBM,
    PSR_TYPE_L3_CODE,
    PSR_TYPE_L3_DATA,
    PSR_TYPE_L2_CBM,
    PSR_TYPE_MBA_THRTL,
    PSR_TYPE_UNKNOWN,
};

extern struct psr_cmt *psr_cmt;

static inline bool_t psr_cmt_enabled(void)
{
    return !!psr_cmt;
}

int psr_alloc_rmid(struct domain *d);
void psr_free_rmid(struct domain *d);
void psr_ctxt_switch_to(struct domain *d);

int psr_get_info(unsigned int socket, enum psr_type type,
                 uint32_t data[], unsigned int array_len);
int psr_get_val(struct domain *d, unsigned int socket,
                uint32_t *val, enum psr_type type);
int psr_set_val(struct domain *d, unsigned int socket,
                uint64_t val, enum psr_type type);

void psr_domain_init(struct domain *d);
void psr_domain_free(struct domain *d);

#endif /* __ASM_PSR_H__ */

/*
 * Local variables:
 * mode: C
 * c-file-style: "BSD"
 * c-basic-offset: 4
 * tab-width: 4
 * indent-tabs-mode: nil
 * End:
 */