Thread (19 messages) 19 messages, 4 authors, 2011-10-08

[net-next 09/11] ixgbe: cleanup some register reads

flat view
STALE5492d SUPERSEDED: 1 (0M)

From: Jeff Kirsher <hidden>
Date: 2011-09-17 02:16:01
Subsystem: intel ethernet drivers, networking drivers, the rest · Maintainers: Tony Nguyen, Przemek Kitszel, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Revision v1 of 127 in this series; 1 review trailer.

Revisions (127)
  1. v1
  2. v2 [diff vs current]
  3. v1
  4. v1
  5. v1
  6. v1
  7. v1
  8. v1 current
  9. v1
  10. v1
  11. v3 [diff vs current]
  12. v1
  13. v1
  14. v1
  15. v2 [diff vs current]
  16. v2 [diff vs current]
  17. v1
  18. v1
  19. v1
  20. v1
  21. v1
  22. v1
  23. v1
  24. v1
  25. v1
  26. v1
  27. v1
  28. v1
  29. v1
  30. v1
  31. v1
  32. v1
  33. v1
  34. v1
  35. v1
  36. v1
  37. v1
  38. v1
  39. v1
  40. v1
  41. v1
  42. v2 [diff vs current]
  43. v1
  44. v1
  45. v1
  46. v1
  47. v2 [diff vs current]
  48. v1
  49. v1
  50. v2 [diff vs current]
  51. v1
  52. v2 [diff vs current]
  53. v1
  54. v1
  55. v1
  56. v1
  57. v1
  58. v1
  59. v1
  60. v1
  61. v2 [diff vs current]
  62. v1
  63. v1
  64. v2 [diff vs current]
  65. v1
  66. v1
  67. v1
  68. v1
  69. v2 [diff vs current]
  70. v1
  71. v2 [diff vs current]
  72. v1
  73. v2 [diff vs current]
  74. v1
  75. v1
  76. v1
  77. v1
  78. v2 [diff vs current]
  79. v1
  80. v1
  81. v1
  82. v1
  83. v1
  84. v1
  85. v2 [diff vs current]
  86. v1
  87. v1
  88. v2 [diff vs current]
  89. v3 [diff vs current]
  90. v4 [diff vs current]
  91. v1
  92. v2 [diff vs current]
  93. v5 [diff vs current]
  94. v1
  95. v1
  96. v1
  97. v2 [diff vs current]
  98. v1
  99. v1
  100. v2 [diff vs current]
  101. v3 [diff vs current]
  102. v1
  103. v2 [diff vs current]
  104. v1
  105. v1
  106. v2 [diff vs current]
  107. v1
  108. v2 [diff vs current]
  109. v1
  110. v2 [diff vs current]
  111. v3 [diff vs current]
  112. v1
  113. v1
  114. v1
  115. v2 [diff vs current]
  116. v1
  117. v1
  118. v1
  119. v1
  120. v1
  121. v2 [diff vs current]
  122. v1
  123. v1
  124. v1
  125. v2 [diff vs current]
  126. v1
  127. v1
From: Emil Tantilov <redacted>

Remove duplicate inc of hwstats->ruc
Introduce separate loops for 8 and 16 register reads.
Consolidate mac checks under one case.
Make sure registers are cleared on read.

Reported-by: Jonathan Lynch <redacted>
Signed-off-by: Emil Tantilov <redacted>
CC: Jonathan Lynch <redacted>
Tested-by: Phil Schmitt <redacted>
Signed-off-by: Jeff Kirsher <redacted>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |   30 +++++++++++++++++-------
 1 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index a4103ef..1e72c00 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -5463,20 +5463,21 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
 	netdev->stats.tx_packets = packets;
 
 	hwstats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
+
+	/* 8 register reads */
 	for (i = 0; i < 8; i++) {
 		/* for packet buffers not used, the register should read 0 */
 		mpc = IXGBE_READ_REG(hw, IXGBE_MPC(i));
 		missed_rx += mpc;
 		hwstats->mpc[i] += mpc;
 		total_mpc += hwstats->mpc[i];
-		if (hw->mac.type == ixgbe_mac_82598EB)
-			hwstats->rnbc[i] += IXGBE_READ_REG(hw, IXGBE_RNBC(i));
-		hwstats->qptc[i] += IXGBE_READ_REG(hw, IXGBE_QPTC(i));
-		hwstats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC(i));
-		hwstats->qprc[i] += IXGBE_READ_REG(hw, IXGBE_QPRC(i));
-		hwstats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC(i));
+		hwstats->pxontxc[i] += IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
+		hwstats->pxofftxc[i] += IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
 		switch (hw->mac.type) {
 		case ixgbe_mac_82598EB:
+			hwstats->rnbc[i] += IXGBE_READ_REG(hw, IXGBE_RNBC(i));
+			hwstats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC(i));
+			hwstats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC(i));
 			hwstats->pxonrxc[i] +=
 				IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
 			break;
@@ -5488,9 +5489,21 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
 		default:
 			break;
 		}
-		hwstats->pxontxc[i] += IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
-		hwstats->pxofftxc[i] += IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
 	}
+
+	/*16 register reads */
+	for (i = 0; i < 16; i++) {
+		hwstats->qptc[i] += IXGBE_READ_REG(hw, IXGBE_QPTC(i));
+		hwstats->qprc[i] += IXGBE_READ_REG(hw, IXGBE_QPRC(i));
+		if ((hw->mac.type == ixgbe_mac_82599EB) ||
+		    (hw->mac.type == ixgbe_mac_X540)) {
+			hwstats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
+			IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)); /* to clear */
+			hwstats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i));
+			IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)); /* to clear */
+		}
+	}
+
 	hwstats->gprc += IXGBE_READ_REG(hw, IXGBE_GPRC);
 	/* work around hardware counting issue */
 	hwstats->gprc -= missed_rx;
@@ -5550,7 +5563,6 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
 	hwstats->lxontxc += lxon;
 	lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
 	hwstats->lxofftxc += lxoff;
-	hwstats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
 	hwstats->gptc += IXGBE_READ_REG(hw, IXGBE_GPTC);
 	hwstats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
 	/*
-- 
1.7.6
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help