3030
3131struct log_ctx log_ctx ;
3232
33+ static inline void work_sub_rate_test_iter (struct tcfg_cpu * tcpu , void * dest ,
34+ struct dsa_hw_desc * desc )
35+ {
36+ struct tcfg * tcfg = tcpu -> tcfg ;
37+ volatile uint32_t * wq_ptr ;
38+
39+ if (tcfg -> misc_flags & (TEST_M64 | TEST_M64MEM ))
40+ movdir64b (dest , desc );
41+ else if (tcfg -> misc_flags & (TEST_ENQ | TEST_ENQMEM ))
42+ enqcmd (dest , desc );
43+ else if (tcfg -> misc_flags & TEST_DB ) {
44+ wq_ptr = dest ;
45+ /* UC doorbell */
46+ * (wq_ptr ) = 1 ;
47+ }
48+ }
49+
3350static inline void
3451work_sub_rate_test (struct tcfg_cpu * tcpu )
3552{
3653 struct tcfg * tcfg = tcpu -> tcfg ;
37- struct dsa_hw_desc * desc ;
3854 struct dsa_completion_record * comp ;
3955 uint32_t it ;
4056 uint64_t cyc ;
41- char * wq_ptr ;
4257 uint32_t max_iter = tcfg -> iter ;
43- char * mdest ;
58+ char * mdest , * dest , * orig_dest ;
4459
4560 printf ("%s using nop\n" , __func__ );
4661
47- desc = tcpu -> desc ;
4862 comp = tcpu -> comp ;
4963 comp -> status = 0 ;
5064 __builtin_ia32_sfence ();
@@ -58,54 +72,26 @@ work_sub_rate_test(struct tcfg_cpu *tcpu)
5872 } else
5973 mdest = NULL ;
6074
61- cyc = rdtsc ();
62-
63- if (tcfg -> misc_flags & (TEST_M64 | TEST_M64MEM )) {
64- char * dest = tcpu -> wq ;
65- char * orig_dest ;
66-
67- if (mdest )
68- dest = mdest ;
69- orig_dest = dest ;
75+ dest = mdest ? mdest : tcpu -> wq ;
76+ orig_dest = dest ;
7077
78+ if (tcfg -> misc_flags & (TEST_M64 | TEST_M64MEM ))
7179 printf ("Measure MOVDIR64B throughput to %s\n" , mdest ? "Memory" : "IO" );
72- for (it = 0 ; it < max_iter ; it ++ ) {
73- movdir64b (dest , desc );
74- if (tcfg -> var_mmio ) {
75- dest = dest + CACHE_LINE_SIZE ;
76- if (dest == orig_dest + 0x1000 )
77- dest = orig_dest ;
78- }
79- }
80- } else if (tcfg -> misc_flags & (TEST_ENQ | TEST_ENQMEM )) {
81- char * dest = tcpu -> wq ;
82- char * orig_dest ;
83-
84- if (mdest )
85- dest = mdest ;
86- orig_dest = dest ;
87-
80+ else if (tcfg -> misc_flags & (TEST_ENQ | TEST_ENQMEM ))
8881 printf ("Measure ENQCMD throughput to %s\n" , mdest ? "Memory" : "IO" );
89- for (it = 0 ; it < max_iter ; it ++ ) {
90- enqcmd (dest , desc );
91- if (tcfg -> var_mmio ) {
92- dest = dest + CACHE_LINE_SIZE ;
93- if (dest == orig_dest + 0x1000 )
94- dest = orig_dest ;
95- }
96- }
97- } else if (tcfg -> misc_flags & TEST_DB ) {
82+ else
9883 printf ("Measure UC Doorbell write throughput\n" );
99- wq_ptr = tcpu -> wq ;
100- for (it = 0 ; it < max_iter ; it ++ ) {
101- /* UC doorbell */
102- * ((volatile uint32_t * )wq_ptr ) = 1 ;
103- if (tcfg -> var_mmio ) {
104- wq_ptr = wq_ptr + 64 ;
105- if (wq_ptr == ((char * )tcpu -> wq + 0x1000 ))
106- wq_ptr = tcpu -> wq ;
107- }
84+
85+ cyc = rdtsc ();
86+
87+ for (it = 0 ; it < max_iter ; it ++ ) {
88+ if (tcfg -> var_mmio ) {
89+ dest = dest + CACHE_LINE_SIZE ;
90+ if (dest == orig_dest + 0x1000 )
91+ dest = orig_dest ;
10892 }
93+
94+ work_sub_rate_test_iter (tcpu , dest , tcpu -> desc );
10995 }
11096
11197 tcpu -> cycles += rdtsc () - cyc ;
0 commit comments