瀏覽代碼

[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 年之前
父節點
當前提交
d08547309b
共有 1 個文件被更改,包括 33 次插入1 次删除
  1. 33
    1
      src/drivers/net/vmxnet3.c

+ 33
- 1
src/drivers/net/vmxnet3.c 查看文件

@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
26 26
 #include <ipxe/pci.h>
27 27
 #include <ipxe/io.h>
28 28
 #include <ipxe/malloc.h>
29
+#include <ipxe/profile.h>
29 30
 #include <ipxe/iobuf.h>
30 31
 #include <ipxe/netdevice.h>
31 32
 #include <ipxe/if_ether.h>
@@ -39,6 +40,22 @@ FILE_LICENCE ( GPL2_OR_LATER );
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 60
  * Issue command
44 61
  *
@@ -48,10 +65,16 @@ FILE_LICENCE ( GPL2_OR_LATER );
48 65
  */
49 66
 static inline uint32_t vmxnet3_command ( struct vmxnet3_nic *vmxnet,
50 67
 					 uint32_t command ) {
68
+	uint32_t result;
51 69
 
52 70
 	/* Issue command */
71
+	profile_start ( &vmxnet3_vm_command_profiler );
53 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,8 +115,11 @@ static int vmxnet3_transmit ( struct net_device *netdev,
92 115
 
93 116
 	/* Hand over descriptor to NIC */
94 117
 	wmb();
118
+	profile_start ( &vmxnet3_vm_tx_profiler );
95 119
 	writel ( ( vmxnet->count.tx_prod % VMXNET3_NUM_TX_DESC ),
96 120
 		 ( vmxnet->pt + VMXNET3_PT_TXPROD ) );
121
+	profile_stop ( &vmxnet3_vm_tx_profiler );
122
+	profile_exclude ( &vmxnet3_vm_tx_profiler );
97 123
 
98 124
 	return 0;
99 125
 }
@@ -212,8 +238,11 @@ static void vmxnet3_refill_rx ( struct net_device *netdev ) {
212 238
 	/* Hand over any new descriptors to NIC */
213 239
 	if ( vmxnet->count.rx_prod != orig_rx_prod ) {
214 240
 		wmb();
241
+		profile_start ( &vmxnet3_vm_refill_profiler );
215 242
 		writel ( ( vmxnet->count.rx_prod % VMXNET3_NUM_RX_DESC ),
216 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,7 +360,10 @@ static void vmxnet3_poll_events ( struct net_device *netdev ) {
331 360
 	events = le32_to_cpu ( vmxnet->dma->shared.ecr );
332 361
 
333 362
 	/* Acknowledge these events */
363
+	profile_start ( &vmxnet3_vm_event_profiler );
334 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 368
 	/* Check for link state change */
337 369
 	if ( events & VMXNET3_ECR_LINK ) {

Loading…
取消
儲存