15
15
16
16
static int interleave_arithmetic ;
17
17
18
+ #define FAKE_QTG_ID 42
19
+
18
20
#define NR_CXL_HOST_BRIDGES 2
19
21
#define NR_CXL_SINGLE_HOST 1
20
22
#define NR_CXL_RCH 1
@@ -209,7 +211,7 @@ static struct {
209
211
.granularity = 4 ,
210
212
.restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
211
213
ACPI_CEDT_CFMWS_RESTRICT_VOLATILE ,
212
- .qtg_id = 0 ,
214
+ .qtg_id = FAKE_QTG_ID ,
213
215
.window_size = SZ_256M * 4UL ,
214
216
},
215
217
.target = { 0 },
@@ -224,7 +226,7 @@ static struct {
224
226
.granularity = 4 ,
225
227
.restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
226
228
ACPI_CEDT_CFMWS_RESTRICT_VOLATILE ,
227
- .qtg_id = 1 ,
229
+ .qtg_id = FAKE_QTG_ID ,
228
230
.window_size = SZ_256M * 8UL ,
229
231
},
230
232
.target = { 0 , 1 , },
@@ -239,7 +241,7 @@ static struct {
239
241
.granularity = 4 ,
240
242
.restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
241
243
ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
242
- .qtg_id = 2 ,
244
+ .qtg_id = FAKE_QTG_ID ,
243
245
.window_size = SZ_256M * 4UL ,
244
246
},
245
247
.target = { 0 },
@@ -254,7 +256,7 @@ static struct {
254
256
.granularity = 4 ,
255
257
.restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
256
258
ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
257
- .qtg_id = 3 ,
259
+ .qtg_id = FAKE_QTG_ID ,
258
260
.window_size = SZ_256M * 8UL ,
259
261
},
260
262
.target = { 0 , 1 , },
@@ -269,7 +271,7 @@ static struct {
269
271
.granularity = 4 ,
270
272
.restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
271
273
ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
272
- .qtg_id = 4 ,
274
+ .qtg_id = FAKE_QTG_ID ,
273
275
.window_size = SZ_256M * 4UL ,
274
276
},
275
277
.target = { 2 },
@@ -284,7 +286,7 @@ static struct {
284
286
.granularity = 4 ,
285
287
.restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
286
288
ACPI_CEDT_CFMWS_RESTRICT_VOLATILE ,
287
- .qtg_id = 5 ,
289
+ .qtg_id = FAKE_QTG_ID ,
288
290
.window_size = SZ_256M ,
289
291
},
290
292
.target = { 3 },
@@ -301,7 +303,7 @@ static struct {
301
303
.granularity = 4 ,
302
304
.restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
303
305
ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
304
- .qtg_id = 0 ,
306
+ .qtg_id = FAKE_QTG_ID ,
305
307
.window_size = SZ_256M * 8UL ,
306
308
},
307
309
.target = { 0 , },
@@ -317,7 +319,7 @@ static struct {
317
319
.granularity = 0 ,
318
320
.restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
319
321
ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
320
- .qtg_id = 1 ,
322
+ .qtg_id = FAKE_QTG_ID ,
321
323
.window_size = SZ_256M * 8UL ,
322
324
},
323
325
.target = { 0 , 1 , },
@@ -333,7 +335,7 @@ static struct {
333
335
.granularity = 0 ,
334
336
.restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
335
337
ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
336
- .qtg_id = 0 ,
338
+ .qtg_id = FAKE_QTG_ID ,
337
339
.window_size = SZ_256M * 16UL ,
338
340
},
339
341
.target = { 0 , 1 , 0 , 1 , },
@@ -976,6 +978,48 @@ static int mock_cxl_port_enumerate_dports(struct cxl_port *port)
976
978
return 0 ;
977
979
}
978
980
981
+ /*
982
+ * Faking the cxl_dpa_perf for the memdev when appropriate.
983
+ */
984
+ static void dpa_perf_setup (struct cxl_port * endpoint , struct range * range ,
985
+ struct cxl_dpa_perf * dpa_perf )
986
+ {
987
+ dpa_perf -> qos_class = FAKE_QTG_ID ;
988
+ dpa_perf -> dpa_range = * range ;
989
+ dpa_perf -> coord .read_latency = 500 ;
990
+ dpa_perf -> coord .write_latency = 500 ;
991
+ dpa_perf -> coord .read_bandwidth = 1000 ;
992
+ dpa_perf -> coord .write_bandwidth = 1000 ;
993
+ }
994
+
995
+ static void mock_cxl_endpoint_parse_cdat (struct cxl_port * port )
996
+ {
997
+ struct cxl_root * cxl_root __free (put_cxl_root ) =
998
+ find_cxl_root (port );
999
+ struct cxl_memdev * cxlmd = to_cxl_memdev (port -> uport_dev );
1000
+ struct cxl_dev_state * cxlds = cxlmd -> cxlds ;
1001
+ struct cxl_memdev_state * mds = to_cxl_memdev_state (cxlds );
1002
+ struct range pmem_range = {
1003
+ .start = cxlds -> pmem_res .start ,
1004
+ .end = cxlds -> pmem_res .end ,
1005
+ };
1006
+ struct range ram_range = {
1007
+ .start = cxlds -> ram_res .start ,
1008
+ .end = cxlds -> ram_res .end ,
1009
+ };
1010
+
1011
+ if (!cxl_root )
1012
+ return ;
1013
+
1014
+ if (range_len (& ram_range ))
1015
+ dpa_perf_setup (port , & ram_range , & mds -> ram_perf );
1016
+
1017
+ if (range_len (& pmem_range ))
1018
+ dpa_perf_setup (port , & pmem_range , & mds -> pmem_perf );
1019
+
1020
+ cxl_memdev_update_perf (cxlmd );
1021
+ }
1022
+
979
1023
static struct cxl_mock_ops cxl_mock_ops = {
980
1024
.is_mock_adev = is_mock_adev ,
981
1025
.is_mock_bridge = is_mock_bridge ,
@@ -989,6 +1033,7 @@ static struct cxl_mock_ops cxl_mock_ops = {
989
1033
.devm_cxl_setup_hdm = mock_cxl_setup_hdm ,
990
1034
.devm_cxl_add_passthrough_decoder = mock_cxl_add_passthrough_decoder ,
991
1035
.devm_cxl_enumerate_decoders = mock_cxl_enumerate_decoders ,
1036
+ .cxl_endpoint_parse_cdat = mock_cxl_endpoint_parse_cdat ,
992
1037
.list = LIST_HEAD_INIT (cxl_mock_ops .list ),
993
1038
};
994
1039
0 commit comments