#include <errno.h>
#include <fcntl.h>
#include <linux/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
Go to the source code of this file.
 | 
| struct   | csr_batch_op | 
|   | Structure holding information for a single read/write operation to an uncore register.  More...
  | 
|   | 
| struct   | csr_batch_array | 
|   | Structure holding multiple read/write operations to various MSRs.  More...
  | 
|   | 
 | 
| int  | init_csr (void) | 
|   | Open the module file descriptors exposed in the /dev filesystem.  
  | 
|   | 
| int  | finalize_csr (void) | 
|   | Close the module file descriptors exposed in the /dev filesystem.  
  | 
|   | 
| int  | csr_batch_storage (struct csr_batch_array **batchsel, const int batchnum, unsigned **opssize) | 
|   | Allocate space for uncore batch arrays.  
  | 
|   | 
| int  | allocate_csr_batch (const int batchnum, size_t bsize) | 
|   | Allocate space for new uncore batch operation.  
  | 
|   | 
| int  | free_csr_batch (const int batchnum) | 
|   | Deallocate memory for specific set of uncore batch operations.  
  | 
|   | 
| int  | create_csr_batch_op (off_t csr, uint8_t bus, uint8_t device, uint8_t function, uint8_t socket, uint8_t isread, size_t opsize, uint64_t **dest, const int batchnum) | 
|   | Create new uncore batch operation.  
  | 
|   | 
| int  | do_csr_batch_op (const int batchnum) | 
|   | Execute read/write batch operation on a specific set of batch uncore registers.  
  | 
|   | 
      
        
          | #define CSR_FILENAME_SIZE   128 | 
        
      
 
 
      
        
          | #define CSR_MODULE   "/dev/cpu/csr_safe" | 
        
      
 
 
      
        
          | #define CSRSAFE_8086_BATCH   _IOWR('a', 0x05, struct csr_batch_array) | 
        
      
 
 
Enum encompassing type of data being read to/written from uncore registers. 
- Enumerator: 
 
| CSR_IMC_CTRS  | 
 Integrated memory controller counter measurements.  
 | 
| CSR_IMC_EVTS  | 
 Integrated memory controller performance event measurements.  
 | 
| CSR_IMC_PMONUNITCTRL  | 
 UBox PMON global control data for integrated memory controller.  
 | 
| CSR_IMC_PMONUNITSTAT  | 
 UBox PMON global status data for integrated memory controller.  
 | 
 
 
 
      
        
          | int allocate_csr_batch  | 
          ( | 
          const int  | 
          batchnum,  | 
        
        
           | 
           | 
          size_t  | 
          bsize  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Allocate space for new uncore batch operation. 
- Parameters
 - 
  
    | [in] | batchnum | csr_data_type_e data type of batch operation. | 
    | [in] | bsize | Size of batch operation. | 
  
   
- Returns
 - 0 if allocation was a success, else -1 if csr_batch_storage() fails. 
 
 
 
      
        
          | int create_csr_batch_op  | 
          ( | 
          off_t  | 
          csr,  | 
        
        
           | 
           | 
          uint8_t  | 
          bus,  | 
        
        
           | 
           | 
          uint8_t  | 
          device,  | 
        
        
           | 
           | 
          uint8_t  | 
          function,  | 
        
        
           | 
           | 
          uint8_t  | 
          socket,  | 
        
        
           | 
           | 
          uint8_t  | 
          isread,  | 
        
        
           | 
           | 
          size_t  | 
          opsize,  | 
        
        
           | 
           | 
          uint64_t **  | 
          dest,  | 
        
        
           | 
           | 
          const int  | 
          batchnum  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Create new uncore batch operation. 
- Parameters
 - 
  
    | [in] | csr | Address of uncore register for which operation will take place. | 
    | [in] | bus | Bus where batch operation will take place. | 
    | [in] | device | Device where batch operation will take place. | 
    | [in] | function | Function where batch operation will take place. | 
    | [in] | socket | Socket where batch operation will take place. | 
    | [in] | isread | Indicates read or write to uncore register. | 
    | [in] | opsize | Size of operation. | 
    | [in] | dest | Stores data resulting from read or necessary for write to uncore register. | 
    | [in] | batchnum | csr_data_type_e data type of batch operation. | 
  
   
- Returns
 - 0 if creation was a success, else -1 if csr_batch_storage() fails or if the number of batch operations exceeds the allocated size. 
 
 
 
      
        
          | int csr_batch_storage  | 
          ( | 
          struct csr_batch_array **  | 
          batchsel,  | 
        
        
           | 
           | 
          const int  | 
          batchnum,  | 
        
        
           | 
           | 
          unsigned **  | 
          opssize  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Allocate space for uncore batch arrays. 
- Parameters
 - 
  
    | [out] | batchsel | Storage for uncore batch operations. | 
    | [in] | batchnum | csr_data_type_e data type of batch operation. | 
    | [out] | opssize | Size of specific set of batch operations. | 
  
   
- Returns
 - 0 if successful, else NULL pointer as a result of libmsr_calloc() or libmsr_realloc(). 
 
 
 
      
        
          | int do_csr_batch_op  | 
          ( | 
          const int  | 
          batchnum | ) | 
           | 
        
      
 
Execute read/write batch operation on a specific set of batch uncore registers. 
- Parameters
 - 
  
    | [in] | batchnum | csr_data_type_e data type of batch operation. | 
  
   
- Returns
 - 0 if successful, else -1 if csr_batch_storage() fails or if batch allocation is for 0 or less operations. 
 
- Todo:
 - Debug stuff here. 
 
 
 
      
        
          | int finalize_csr  | 
          ( | 
          void  | 
           | ) | 
           | 
        
      
 
Close the module file descriptors exposed in the /dev filesystem. 
- Returns
 - 0 if finalization was a success, else -1 if could not close file descriptors. 
 
 
 
      
        
          | int free_csr_batch  | 
          ( | 
          const int  | 
          batchnum | ) | 
           | 
        
      
 
Deallocate memory for specific set of uncore batch operations. 
- Parameters
 - 
  
    | [in] | batchnum | csr_data_type_e data type of batch operation. | 
  
   
- Returns
 - 0 if successful, else -1 if csr_batch_storage() fails. 
 
 
 
Open the module file descriptors exposed in the /dev filesystem. 
- Returns
 - 0 if initialization was a success, else -1 if could not stat file descriptors or open any csr module.