Skip to content

api: add DPF_MSG_DDR_CONFIG for DDR management #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified doc/api.docx
Binary file not shown.
9 changes: 5 additions & 4 deletions include/pmu_ddr.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef __PMU_DDR_H
#define __PMU_DDR_H

#include <stdio.h>
#include <stdint.h>

#define DDR_NONE (-1)
#define DDR_CLIENT (1)
Expand Down Expand Up @@ -30,15 +28,18 @@
#define MAX_NUM_DDR_CONTROLLERS (16)



//structs for ddr
struct ddr_s {
uint64_t rd_last_update[MAX_NUM_DDR_CONTROLLERS];
uint64_t wr_last_update[MAX_NUM_DDR_CONTROLLERS];
char *mmap[MAX_NUM_DDR_CONTROLLERS]; //ddr ch 0, 1, ...
int mem_file; //file desc
uint64_t bar_address;
int ddr_interface_type;
int num_ddr_controllers;
};

int pmu_ddr_init(struct ddr_s *ddr);
int pmu_ddr_init(struct ddr_s *ddr, int kernel_mode);
uint64_t pmu_ddr(struct ddr_s *ddr, int type);


Expand Down
6 changes: 3 additions & 3 deletions include/user_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define __USER_API_H

#include <stdint.h>
#define PROC_DEVICE "/proc/dpf_monitor"
#define PROC_DEVICE "/proc/dynamicPrefetch"

int kernel_mode_init(void);
int kernel_core_range(uint32_t start, uint32_t end);
Expand All @@ -15,6 +15,6 @@ int kernel_msr_read(uint32_t core_id, uint64_t *msr_values);
int kernel_pmu_read(uint32_t core_id, uint64_t *pmu_values);
int kernel_log_msr_values(uint32_t core_id);
int kernel_log_pmu_values(uint32_t core_id);


int kernel_set_ddr_config(struct ddr_s *ddr);
int kernel_log_ddr_bw();
#endif /* __USER_API_H */
2 changes: 1 addition & 1 deletion kernelmod/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
obj-m += dpf.o
dpf-objs := kernel_dpf.o kernel_common.o kernel_primitive.o
dpf-objs := kernel_dpf.o kernel_common.o kernel_primitive.o kernel_pmu_ddr.o

PWD := $(CURDIR)

Expand Down
64 changes: 54 additions & 10 deletions kernelmod/kernel_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,95 +52,138 @@ enum pmu_metrics {

// Enum for message types between user space and kernel module
enum dpf_msg_type {
DPF_MSG_INIT = 0, // API version negotiation
DPF_MSG_CORE_RANGE = 1, // Core range configuration
DPF_MSG_DDRBW_SET = 2, // DDR bandwidth setting
DPF_MSG_CORE_WEIGHT = 3,// Core weight assignment
DPF_MSG_TUNING = 4, // Tuning control
DPF_MSG_MSR_READ = 5, // Read MSR values
DPF_MSG_PMU_READ = 6 // Read PMU values
};

// Message structures
DPF_MSG_INIT = 0, // API version negotiation
DPF_MSG_CORE_RANGE = 1, // Core range configuration
DPF_MSG_DDRBW_SET = 2, // DDR bandwidth setting
DPF_MSG_CORE_WEIGHT = 3, // Core weight assignment
DPF_MSG_TUNING = 4, // Tuning control
DPF_MSG_MSR_READ = 5, // Read MSR values
DPF_MSG_PMU_READ = 6, // Read PMU values
DPF_MSG_DDR_CONFIG = 7, // DDR configuration
DPF_MSG_DDR_BW_READ = 8 //DDR BW READ
};

// Common message header
struct dpf_msg_header {
__u32 type; // Message type (from dpf_msg_type)
__u32 payload_size; // Size of payload following the header
};

// Request structure for API version
struct dpf_req_init {
struct dpf_msg_header header;
};

// Response structure for API version
struct dpf_resp_init {
struct dpf_msg_header header;
__u32 version; // Returned API version
};

// Request structure for core range
struct dpf_core_range {
struct dpf_msg_header header;
__u32 core_start; // First core in range
__u32 core_end; // Last core in range
};

// Response structure for core range
struct dpf_resp_core_range {
struct dpf_msg_header header;
__u32 core_start; // Confirmed first core
__u32 core_end; // Confirmed last core
__u32 thread_count; // Number of threads (cores) in range
};

// Request structure for core weights
struct dpf_core_weight {
struct dpf_msg_header header;
__u32 count; // Number of weights
__u32 weights[]; // Flexible array of core weights
};

// Response structure for core weights
struct dpf_resp_core_weight {
struct dpf_msg_header header;
__u32 count; // Number of confirmed weights
__u32 confirmed_weights[]; // Flexible array of confirmed weights
};

// Request structure for tuning
struct dpf_req_tuning {
struct dpf_msg_header header;
__u32 enable; // Enable tuning (non-zero) or disable (0)
};

// Response structure for tuning
struct dpf_resp_tuning {
struct dpf_msg_header header;
__u32 status; // Tuning status (e.g., enabled/disabled)
};

// Request structure for DDR bandwidth setting
struct dpf_ddrbw_set {
struct dpf_msg_header header;
__u32 set_value; // DDR bandwidth value to set (MB/s)
};

// Response structure for DDR bandwidth setting
struct dpf_resp_ddrbw_set {
struct dpf_msg_header header;
__u32 confirmed_value; // Confirmed DDR bandwidth value
};

// Request structure for MSR read
struct dpf_msr_read {
struct dpf_msg_header header;
__u32 core_id; // Core ID to read MSRs from
};

// Response structure for MSR read
struct dpf_resp_msr_read {
struct dpf_msg_header header;
__u64 msr_values[NR_OF_MSR]; // Array of MSR values
};

// Request structure for PMU read
struct dpf_pmu_read {
struct dpf_msg_header header;
__u32 core_id; // Core ID to read PMU from
};

// Response structure for PMU read
struct dpf_resp_pmu_read {
struct dpf_msg_header header;
__u64 pmu_values[PMU_COUNTERS]; // Array of PMU counter values
};

// Request structure for DDR configuration
struct dpf_ddr_config {
struct dpf_msg_header header;
__u64 bar_address; // BAR address for DDR config space
__u32 cpu_type; // CPU type (e.g., DDR_CLIENT, DDR_GRR_SRF)
__u32 num_controllers; // Number of DDR controllers
};

// Response structure for DDR configuration
struct dpf_resp_ddr_config {
struct dpf_msg_header header;
__u64 confirmed_bar; // Confirmed BAR address
__u32 confirmed_type; // Confirmed CPU type
};

// Request structure for reading DDR bandwidth
struct dpf_ddr_bw_read {
struct dpf_msg_header header;
};

// Response structure for reading DDR bandwidth
struct dpf_resp_ddr_bw_read {
struct dpf_msg_header header;
uint64_t read_bw;
uint64_t write_bw;
};

// Core state structure
struct core_state_s {
uint64_t pmu_result[PMU_COUNTERS]; // Delta since last PMU read (mapped to pmu_metrics)
Expand All @@ -160,6 +203,7 @@ int msr_load(int core_id);
int msr_update(int core_id);
int pmu_update(int core_id);

// Functions for reading and writing MSRs
int msr_set_l2xq(int core_id, int value);
int msr_get_l2xq(int core_id);
int msr_set_l3xq(int core_id, int value);
Expand Down
Loading