libmsr  0.3.0
A friendlier interface to accessing MSRs on Intel platforms
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
csr_core.h
Go to the documentation of this file.
1 /* csr_core.h
2  *
3  * Copyright (c) 2011-2016, Lawrence Livermore National Security, LLC.
4  * LLNL-CODE-645430
5  *
6  * Produced at Lawrence Livermore National Laboratory
7  * Written by Barry Rountree, rountree@llnl.gov
8  * Scott Walker, walker91@llnl.gov
9  * Kathleen Shoga, shoga1@llnl.gov
10  *
11  * All rights reserved.
12  *
13  * This file is part of libmsr.
14  *
15  * libmsr is free software: you can redistribute it and/or modify it under the
16  * terms of the GNU Lesser General Public License as published by the Free
17  * Software Foundation, either version 3 of the License, or (at your option)
18  * any later version.
19  *
20  * libmsr is distributed in the hope that it will be useful, but WITHOUT ANY
21  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
23  * details.
24  *
25  * You should have received a copy of the GNU Lesser General Public License
26  * along with libmsr. If not, see <http://www.gnu.org/licenses/>.
27  *
28  * This material is based upon work supported by the U.S. Department of
29  * Energy's Lawrence Livermore National Laboratory. Office of Science, under
30  * Award number DE-AC52-07NA27344.
31  *
32  */
33 
34 #ifndef CSR_CORE_H_INCLUDE
35 #define CSR_CORE_H_INCLUDE
36 
37 #include <errno.h>
38 #include <fcntl.h>
39 #include <linux/ioctl.h>
40 #include <stdint.h>
41 #include <stdio.h>
42 #include <string.h>
43 #include <sys/mman.h>
44 #include <unistd.h>
45 
46 #define CSRSAFE_8086_BATCH _IOWR('a', 0x05, struct csr_batch_array)
47 #define CSR_FILENAME_SIZE 128
48 #define CSR_MODULE "/dev/cpu/csr_safe"
49 
61  /* Currently unused */
62  //CSR_IMC_MEMCTRA,
63  //CSR_IMC_MEMCTRR,
64  //CSR_IMC_MEMCTRW,
65  //CSR_IMC_IMCCTR,
66  //CSR_QPI_CTRS,
67  //CSR_QPI_EVTS
68 };
69 
72 struct csr_batch_op {
75  uint8_t bus;
78  uint8_t device;
81  uint8_t function;
84  uint8_t socket;
86  uint16_t offset;
88  int err;
90  uint8_t isread;
92  uint64_t csrdata;
94  uint64_t wmask;
96  uint8_t size;
97 };
98 
102  uint32_t numops;
104  struct csr_batch_op *ops;
105 };
106 
111 int init_csr(void);
112 
117 int finalize_csr(void);
118 
129 int csr_batch_storage(struct csr_batch_array **batchsel,
130  const int batchnum,
131  unsigned **opssize);
132 
140 int allocate_csr_batch(const int batchnum,
141  size_t bsize);
142 
148 int free_csr_batch(const int batchnum);
149 
174 int create_csr_batch_op(off_t csr,
175  uint8_t bus,
176  uint8_t device,
177  uint8_t function,
178  uint8_t socket,
179  uint8_t isread,
180  size_t opsize,
181  uint64_t **dest,
182  const int batchnum);
183 
191 int do_csr_batch_op(const int batchnum);
192 
193 #endif