Skip to content

Commit 9b7594f

Browse files
committed
Implementation of kernelspace support for DDR BW
1 parent 9234ea5 commit 9b7594f

File tree

11 files changed

+581
-43
lines changed

11 files changed

+581
-43
lines changed

include/pmu_ddr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@
2828
#define MAX_NUM_DDR_CONTROLLERS (16)
2929

3030

31-
31+
//structs for ddr
3232
struct ddr_s {
3333
uint64_t rd_last_update[MAX_NUM_DDR_CONTROLLERS];
3434
uint64_t wr_last_update[MAX_NUM_DDR_CONTROLLERS];
3535
char *mmap[MAX_NUM_DDR_CONTROLLERS]; //ddr ch 0, 1, ...
3636
int mem_file; //file desc
3737
uint64_t bar_address;
3838
int ddr_interface_type;
39+
int num_ddr_controllers;
3940
};
4041

4142
int pmu_ddr_init(struct ddr_s *ddr, int kernel_mode);

include/user_api.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define __USER_API_H
33

44
#include <stdint.h>
5-
#define PROC_DEVICE "/proc/dpf_monitor"
5+
#define PROC_DEVICE "/proc/dynamicPrefetch"
66

77
int kernel_mode_init(void);
88
int kernel_core_range(uint32_t start, uint32_t end);
@@ -16,5 +16,5 @@ int kernel_pmu_read(uint32_t core_id, uint64_t *pmu_values);
1616
int kernel_log_msr_values(uint32_t core_id);
1717
int kernel_log_pmu_values(uint32_t core_id);
1818
int kernel_set_ddr_config(struct ddr_s *ddr);
19-
19+
int kernel_log_ddr_bw();
2020
#endif /* __USER_API_H */

kernelmod/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
obj-m += dpf.o
2-
dpf-objs := kernel_dpf.o kernel_common.o kernel_primitive.o
2+
dpf-objs := kernel_dpf.o kernel_common.o kernel_primitive.o kernel_pmu_ddr.o
33

44
PWD := $(CURDIR)
55

kernelmod/kernel_common.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,84 +59,99 @@ enum dpf_msg_type {
5959
DPF_MSG_TUNING = 4, // Tuning control
6060
DPF_MSG_MSR_READ = 5, // Read MSR values
6161
DPF_MSG_PMU_READ = 6, // Read PMU values
62-
DPF_MSG_DDR_CONFIG = 7 // DDR configuration
62+
DPF_MSG_DDR_CONFIG = 7, // DDR configuration
63+
DPF_MSG_DDR_BW_READ = 8 //DDR BW READ
6364
};
6465

65-
// Message structures
66+
// Common message header
6667
struct dpf_msg_header {
6768
__u32 type; // Message type (from dpf_msg_type)
6869
__u32 payload_size; // Size of payload following the header
6970
};
7071

72+
// Request structure for API version
7173
struct dpf_req_init {
7274
struct dpf_msg_header header;
7375
};
7476

77+
// Response structure for API version
7578
struct dpf_resp_init {
7679
struct dpf_msg_header header;
7780
__u32 version; // Returned API version
7881
};
7982

83+
// Request structure for core range
8084
struct dpf_core_range {
8185
struct dpf_msg_header header;
8286
__u32 core_start; // First core in range
8387
__u32 core_end; // Last core in range
8488
};
8589

90+
// Response structure for core range
8691
struct dpf_resp_core_range {
8792
struct dpf_msg_header header;
8893
__u32 core_start; // Confirmed first core
8994
__u32 core_end; // Confirmed last core
9095
__u32 thread_count; // Number of threads (cores) in range
9196
};
9297

98+
// Request structure for core weights
9399
struct dpf_core_weight {
94100
struct dpf_msg_header header;
95101
__u32 count; // Number of weights
96102
__u32 weights[]; // Flexible array of core weights
97103
};
98104

105+
// Response structure for core weights
99106
struct dpf_resp_core_weight {
100107
struct dpf_msg_header header;
101108
__u32 count; // Number of confirmed weights
102109
__u32 confirmed_weights[]; // Flexible array of confirmed weights
103110
};
104111

112+
// Request structure for tuning
105113
struct dpf_req_tuning {
106114
struct dpf_msg_header header;
107115
__u32 enable; // Enable tuning (non-zero) or disable (0)
108116
};
109117

118+
// Response structure for tuning
110119
struct dpf_resp_tuning {
111120
struct dpf_msg_header header;
112121
__u32 status; // Tuning status (e.g., enabled/disabled)
113122
};
114123

124+
// Request structure for DDR bandwidth setting
115125
struct dpf_ddrbw_set {
116126
struct dpf_msg_header header;
117127
__u32 set_value; // DDR bandwidth value to set (MB/s)
118128
};
119129

130+
// Response structure for DDR bandwidth setting
120131
struct dpf_resp_ddrbw_set {
121132
struct dpf_msg_header header;
122133
__u32 confirmed_value; // Confirmed DDR bandwidth value
123134
};
124135

136+
// Request structure for MSR read
125137
struct dpf_msr_read {
126138
struct dpf_msg_header header;
127139
__u32 core_id; // Core ID to read MSRs from
128140
};
129141

142+
// Response structure for MSR read
130143
struct dpf_resp_msr_read {
131144
struct dpf_msg_header header;
132145
__u64 msr_values[NR_OF_MSR]; // Array of MSR values
133146
};
134147

148+
// Request structure for PMU read
135149
struct dpf_pmu_read {
136150
struct dpf_msg_header header;
137151
__u32 core_id; // Core ID to read PMU from
138152
};
139153

154+
// Response structure for PMU read
140155
struct dpf_resp_pmu_read {
141156
struct dpf_msg_header header;
142157
__u64 pmu_values[PMU_COUNTERS]; // Array of PMU counter values
@@ -147,6 +162,7 @@ struct dpf_ddr_config {
147162
struct dpf_msg_header header;
148163
__u64 bar_address; // BAR address for DDR config space
149164
__u32 cpu_type; // CPU type (e.g., DDR_CLIENT, DDR_GRR_SRF)
165+
__u32 num_controllers; // Number of DDR controllers
150166
};
151167

152168
// Response structure for DDR configuration
@@ -156,6 +172,18 @@ struct dpf_resp_ddr_config {
156172
__u32 confirmed_type; // Confirmed CPU type
157173
};
158174

175+
// Request structure for reading DDR bandwidth
176+
struct dpf_ddr_bw_read {
177+
struct dpf_msg_header header;
178+
};
179+
180+
// Response structure for reading DDR bandwidth
181+
struct dpf_resp_ddr_bw_read {
182+
struct dpf_msg_header header;
183+
uint64_t read_bw;
184+
uint64_t write_bw;
185+
};
186+
159187
// Core state structure
160188
struct core_state_s {
161189
uint64_t pmu_result[PMU_COUNTERS]; // Delta since last PMU read (mapped to pmu_metrics)
@@ -175,6 +203,7 @@ int msr_load(int core_id);
175203
int msr_update(int core_id);
176204
int pmu_update(int core_id);
177205

206+
// Functions for reading and writing MSRs
178207
int msr_set_l2xq(int core_id, int value);
179208
int msr_get_l2xq(int core_id);
180209
int msr_set_l3xq(int core_id, int value);

0 commit comments

Comments
 (0)