Browse Source

[vmxnet3] Add profiling code to exclude time spent in the hypervisor

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
d08547309b
1 changed files with 33 additions and 1 deletions
  1. 33
    1
      src/drivers/net/vmxnet3.c

+ 33
- 1
src/drivers/net/vmxnet3.c View File

26
 #include <ipxe/pci.h>
26
 #include <ipxe/pci.h>
27
 #include <ipxe/io.h>
27
 #include <ipxe/io.h>
28
 #include <ipxe/malloc.h>
28
 #include <ipxe/malloc.h>
29
+#include <ipxe/profile.h>
29
 #include <ipxe/iobuf.h>
30
 #include <ipxe/iobuf.h>
30
 #include <ipxe/netdevice.h>
31
 #include <ipxe/netdevice.h>
31
 #include <ipxe/if_ether.h>
32
 #include <ipxe/if_ether.h>
39
  *
40
  *
40
  */
41
  */
41
 
42
 
43
+/** VM command profiler */
44
+static struct profiler vmxnet3_vm_command_profiler __profiler =
45
+	{ .name = "vmxnet3.vm_command" };
46
+
47
+/** VM transmit profiler */
48
+static struct profiler vmxnet3_vm_tx_profiler __profiler =
49
+	{ .name = "vmxnet3.vm_tx" };
50
+
51
+/** VM receive refill profiler */
52
+static struct profiler vmxnet3_vm_refill_profiler __profiler =
53
+	{ .name = "vmxnet3.vm_refill" };
54
+
55
+/** VM event profiler */
56
+static struct profiler vmxnet3_vm_event_profiler __profiler =
57
+	{ .name = "vmxnet3.vm_event" };
58
+
42
 /**
59
 /**
43
  * Issue command
60
  * Issue command
44
  *
61
  *
48
  */
65
  */
49
 static inline uint32_t vmxnet3_command ( struct vmxnet3_nic *vmxnet,
66
 static inline uint32_t vmxnet3_command ( struct vmxnet3_nic *vmxnet,
50
 					 uint32_t command ) {
67
 					 uint32_t command ) {
68
+	uint32_t result;
51
 
69
 
52
 	/* Issue command */
70
 	/* Issue command */
71
+	profile_start ( &vmxnet3_vm_command_profiler );
53
 	writel ( command, ( vmxnet->vd + VMXNET3_VD_CMD ) );
72
 	writel ( command, ( vmxnet->vd + VMXNET3_VD_CMD ) );
54
-	return readl ( vmxnet->vd + VMXNET3_VD_CMD );
73
+	result = readl ( vmxnet->vd + VMXNET3_VD_CMD );
74
+	profile_stop ( &vmxnet3_vm_command_profiler );
75
+	profile_exclude ( &vmxnet3_vm_command_profiler );
76
+
77
+	return result;
55
 }
78
 }
56
 
79
 
57
 /**
80
 /**
92
 
115
 
93
 	/* Hand over descriptor to NIC */
116
 	/* Hand over descriptor to NIC */
94
 	wmb();
117
 	wmb();
118
+	profile_start ( &vmxnet3_vm_tx_profiler );
95
 	writel ( ( vmxnet->count.tx_prod % VMXNET3_NUM_TX_DESC ),
119
 	writel ( ( vmxnet->count.tx_prod % VMXNET3_NUM_TX_DESC ),
96
 		 ( vmxnet->pt + VMXNET3_PT_TXPROD ) );
120
 		 ( vmxnet->pt + VMXNET3_PT_TXPROD ) );
121
+	profile_stop ( &vmxnet3_vm_tx_profiler );
122
+	profile_exclude ( &vmxnet3_vm_tx_profiler );
97
 
123
 
98
 	return 0;
124
 	return 0;
99
 }
125
 }
212
 	/* Hand over any new descriptors to NIC */
238
 	/* Hand over any new descriptors to NIC */
213
 	if ( vmxnet->count.rx_prod != orig_rx_prod ) {
239
 	if ( vmxnet->count.rx_prod != orig_rx_prod ) {
214
 		wmb();
240
 		wmb();
241
+		profile_start ( &vmxnet3_vm_refill_profiler );
215
 		writel ( ( vmxnet->count.rx_prod % VMXNET3_NUM_RX_DESC ),
242
 		writel ( ( vmxnet->count.rx_prod % VMXNET3_NUM_RX_DESC ),
216
 			 ( vmxnet->pt + VMXNET3_PT_RXPROD ) );
243
 			 ( vmxnet->pt + VMXNET3_PT_RXPROD ) );
244
+		profile_stop ( &vmxnet3_vm_refill_profiler );
245
+		profile_exclude ( &vmxnet3_vm_refill_profiler );
217
 	}
246
 	}
218
 }
247
 }
219
 
248
 
331
 	events = le32_to_cpu ( vmxnet->dma->shared.ecr );
360
 	events = le32_to_cpu ( vmxnet->dma->shared.ecr );
332
 
361
 
333
 	/* Acknowledge these events */
362
 	/* Acknowledge these events */
363
+	profile_start ( &vmxnet3_vm_event_profiler );
334
 	writel ( events, ( vmxnet->vd + VMXNET3_VD_ECR ) );
364
 	writel ( events, ( vmxnet->vd + VMXNET3_VD_ECR ) );
365
+	profile_stop ( &vmxnet3_vm_event_profiler );
366
+	profile_exclude ( &vmxnet3_vm_event_profiler );
335
 
367
 
336
 	/* Check for link state change */
368
 	/* Check for link state change */
337
 	if ( events & VMXNET3_ECR_LINK ) {
369
 	if ( events & VMXNET3_ECR_LINK ) {

Loading…
Cancel
Save