diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2006-12-11 18:13:48 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-05 16:58:43 -0500 |
commit | 834324687d08e0f67b167934cb56406aa98ff8c6 (patch) | |
tree | bafd6715f66bf7ad17bcabb4fabfbeffbddd1538 | |
parent | 3e0f75be52605a901165fa1d8acf4ffd37a4857b (diff) |
chelsio: tabulate the update of the statistic counters
Let's try to avoid some code duplication.
- cxgb2
The data are contiguous. Use plain memcpy.
- ixf1010/pm3393/vsc7326
The cast of &mac->stats to (u64 *) is not wonderful but it is not clear
if it is worth to add an ad-hoc union under the struct cmac_statistics.
vsc7326_reg.h suggests that more statistics could be available.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
-rw-r--r-- | drivers/net/chelsio/cxgb2.c | 50 | ||||
-rw-r--r-- | drivers/net/chelsio/ixf1010.c | 87 | ||||
-rw-r--r-- | drivers/net/chelsio/pm3393.c | 83 | ||||
-rw-r--r-- | drivers/net/chelsio/vsc7326.c | 68 | ||||
-rw-r--r-- | drivers/net/chelsio/vsc7326_reg.h | 139 |
5 files changed, 222 insertions, 205 deletions
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c index c3b1648618c8..7d0f24f69777 100644 --- a/drivers/net/chelsio/cxgb2.c +++ b/drivers/net/chelsio/cxgb2.c | |||
@@ -454,51 +454,21 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats, | |||
454 | const struct cmac_statistics *s; | 454 | const struct cmac_statistics *s; |
455 | const struct sge_intr_counts *t; | 455 | const struct sge_intr_counts *t; |
456 | struct sge_port_stats ss; | 456 | struct sge_port_stats ss; |
457 | unsigned int len; | ||
457 | 458 | ||
458 | s = mac->ops->statistics_update(mac, MAC_STATS_UPDATE_FULL); | 459 | s = mac->ops->statistics_update(mac, MAC_STATS_UPDATE_FULL); |
459 | 460 | ||
460 | *data++ = s->TxOctetsOK; | 461 | len = sizeof(u64)*(&s->TxFCSErrors + 1 - &s->TxOctetsOK); |
461 | *data++ = s->TxOctetsBad; | 462 | memcpy(data, &s->TxOctetsOK, len); |
462 | *data++ = s->TxUnicastFramesOK; | 463 | data += len; |
463 | *data++ = s->TxMulticastFramesOK; | 464 | |
464 | *data++ = s->TxBroadcastFramesOK; | 465 | len = sizeof(u64)*(&s->RxFrameTooLongErrors + 1 - &s->RxOctetsOK); |
465 | *data++ = s->TxPauseFrames; | 466 | memcpy(data, &s->RxOctetsOK, len); |
466 | *data++ = s->TxFramesWithDeferredXmissions; | 467 | data += len; |
467 | *data++ = s->TxLateCollisions; | ||
468 | *data++ = s->TxTotalCollisions; | ||
469 | *data++ = s->TxFramesAbortedDueToXSCollisions; | ||
470 | *data++ = s->TxUnderrun; | ||
471 | *data++ = s->TxLengthErrors; | ||
472 | *data++ = s->TxInternalMACXmitError; | ||
473 | *data++ = s->TxFramesWithExcessiveDeferral; | ||
474 | *data++ = s->TxFCSErrors; | ||
475 | |||
476 | *data++ = s->RxOctetsOK; | ||
477 | *data++ = s->RxOctetsBad; | ||
478 | *data++ = s->RxUnicastFramesOK; | ||
479 | *data++ = s->RxMulticastFramesOK; | ||
480 | *data++ = s->RxBroadcastFramesOK; | ||
481 | *data++ = s->RxPauseFrames; | ||
482 | *data++ = s->RxFCSErrors; | ||
483 | *data++ = s->RxAlignErrors; | ||
484 | *data++ = s->RxSymbolErrors; | ||
485 | *data++ = s->RxDataErrors; | ||
486 | *data++ = s->RxSequenceErrors; | ||
487 | *data++ = s->RxRuntErrors; | ||
488 | *data++ = s->RxJabberErrors; | ||
489 | *data++ = s->RxInternalMACRcvError; | ||
490 | *data++ = s->RxInRangeLengthErrors; | ||
491 | *data++ = s->RxOutOfRangeLengthField; | ||
492 | *data++ = s->RxFrameTooLongErrors; | ||
493 | 468 | ||
494 | t1_sge_get_port_stats(adapter->sge, dev->if_port, &ss); | 469 | t1_sge_get_port_stats(adapter->sge, dev->if_port, &ss); |
495 | *data++ = ss.rx_packets; | 470 | memcpy(data, &ss, sizeof(ss)); |
496 | *data++ = ss.rx_cso_good; | 471 | data += sizeof(ss); |
497 | *data++ = ss.tx_packets; | ||
498 | *data++ = ss.tx_cso; | ||
499 | *data++ = ss.tx_tso; | ||
500 | *data++ = ss.vlan_xtract; | ||
501 | *data++ = ss.vlan_insert; | ||
502 | 472 | ||
503 | t = t1_sge_get_intr_counts(adapter->sge); | 473 | t = t1_sge_get_intr_counts(adapter->sge); |
504 | *data++ = t->rx_drops; | 474 | *data++ = t->rx_drops; |
diff --git a/drivers/net/chelsio/ixf1010.c b/drivers/net/chelsio/ixf1010.c index c40a88d18cc4..10b2a9a19006 100644 --- a/drivers/net/chelsio/ixf1010.c +++ b/drivers/net/chelsio/ixf1010.c | |||
@@ -145,48 +145,61 @@ static void disable_port(struct cmac *mac) | |||
145 | t1_tpi_write(mac->adapter, REG_PORT_ENABLE, val); | 145 | t1_tpi_write(mac->adapter, REG_PORT_ENABLE, val); |
146 | } | 146 | } |
147 | 147 | ||
148 | #define RMON_UPDATE(mac, name, stat_name) \ | ||
149 | t1_tpi_read((mac)->adapter, MACREG(mac, REG_##name), &val); \ | ||
150 | (mac)->stats.stat_name += val; | ||
151 | |||
152 | /* | 148 | /* |
153 | * Read the current values of the RMON counters and add them to the cumulative | 149 | * Read the current values of the RMON counters and add them to the cumulative |
154 | * port statistics. The HW RMON counters are cleared by this operation. | 150 | * port statistics. The HW RMON counters are cleared by this operation. |
155 | */ | 151 | */ |
156 | static void port_stats_update(struct cmac *mac) | 152 | static void port_stats_update(struct cmac *mac) |
157 | { | 153 | { |
158 | u32 val; | 154 | static struct { |
155 | unsigned int reg; | ||
156 | unsigned int offset; | ||
157 | } hw_stats[] = { | ||
158 | |||
159 | #define HW_STAT(name, stat_name) \ | ||
160 | { REG_##name, \ | ||
161 | (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL } | ||
162 | |||
163 | /* Rx stats */ | ||
164 | HW_STAT(RxOctetsTotalOK, RxOctetsOK), | ||
165 | HW_STAT(RxOctetsBad, RxOctetsBad), | ||
166 | HW_STAT(RxUCPkts, RxUnicastFramesOK), | ||
167 | HW_STAT(RxMCPkts, RxMulticastFramesOK), | ||
168 | HW_STAT(RxBCPkts, RxBroadcastFramesOK), | ||
169 | HW_STAT(RxJumboPkts, RxJumboFramesOK), | ||
170 | HW_STAT(RxFCSErrors, RxFCSErrors), | ||
171 | HW_STAT(RxAlignErrors, RxAlignErrors), | ||
172 | HW_STAT(RxLongErrors, RxFrameTooLongErrors), | ||
173 | HW_STAT(RxVeryLongErrors, RxFrameTooLongErrors), | ||
174 | HW_STAT(RxPauseMacControlCounter, RxPauseFrames), | ||
175 | HW_STAT(RxDataErrors, RxDataErrors), | ||
176 | HW_STAT(RxJabberErrors, RxJabberErrors), | ||
177 | HW_STAT(RxRuntErrors, RxRuntErrors), | ||
178 | HW_STAT(RxShortErrors, RxRuntErrors), | ||
179 | HW_STAT(RxSequenceErrors, RxSequenceErrors), | ||
180 | HW_STAT(RxSymbolErrors, RxSymbolErrors), | ||
181 | |||
182 | /* Tx stats (skip collision stats as we are full-duplex only) */ | ||
183 | HW_STAT(TxOctetsTotalOK, TxOctetsOK), | ||
184 | HW_STAT(TxOctetsBad, TxOctetsBad), | ||
185 | HW_STAT(TxUCPkts, TxUnicastFramesOK), | ||
186 | HW_STAT(TxMCPkts, TxMulticastFramesOK), | ||
187 | HW_STAT(TxBCPkts, TxBroadcastFramesOK), | ||
188 | HW_STAT(TxJumboPkts, TxJumboFramesOK), | ||
189 | HW_STAT(TxPauseFrames, TxPauseFrames), | ||
190 | HW_STAT(TxExcessiveLengthDrop, TxLengthErrors), | ||
191 | HW_STAT(TxUnderrun, TxUnderrun), | ||
192 | HW_STAT(TxCRCErrors, TxFCSErrors) | ||
193 | }, *p = hw_stats; | ||
194 | u64 *stats = (u64 *) &mac->stats; | ||
195 | unsigned int i; | ||
196 | |||
197 | for (i = 0; i < ARRAY_SIZE(hw_stats); i++) { | ||
198 | u32 val; | ||
159 | 199 | ||
160 | /* Rx stats */ | 200 | t1_tpi_read(mac->adapter, MACREG(mac, p->reg), &val); |
161 | RMON_UPDATE(mac, RxOctetsTotalOK, RxOctetsOK); | 201 | stats[p->offset] += val; |
162 | RMON_UPDATE(mac, RxOctetsBad, RxOctetsBad); | 202 | } |
163 | RMON_UPDATE(mac, RxUCPkts, RxUnicastFramesOK); | ||
164 | RMON_UPDATE(mac, RxMCPkts, RxMulticastFramesOK); | ||
165 | RMON_UPDATE(mac, RxBCPkts, RxBroadcastFramesOK); | ||
166 | RMON_UPDATE(mac, RxJumboPkts, RxJumboFramesOK); | ||
167 | RMON_UPDATE(mac, RxFCSErrors, RxFCSErrors); | ||
168 | RMON_UPDATE(mac, RxAlignErrors, RxAlignErrors); | ||
169 | RMON_UPDATE(mac, RxLongErrors, RxFrameTooLongErrors); | ||
170 | RMON_UPDATE(mac, RxVeryLongErrors, RxFrameTooLongErrors); | ||
171 | RMON_UPDATE(mac, RxPauseMacControlCounter, RxPauseFrames); | ||
172 | RMON_UPDATE(mac, RxDataErrors, RxDataErrors); | ||
173 | RMON_UPDATE(mac, RxJabberErrors, RxJabberErrors); | ||
174 | RMON_UPDATE(mac, RxRuntErrors, RxRuntErrors); | ||
175 | RMON_UPDATE(mac, RxShortErrors, RxRuntErrors); | ||
176 | RMON_UPDATE(mac, RxSequenceErrors, RxSequenceErrors); | ||
177 | RMON_UPDATE(mac, RxSymbolErrors, RxSymbolErrors); | ||
178 | |||
179 | /* Tx stats (skip collision stats as we are full-duplex only) */ | ||
180 | RMON_UPDATE(mac, TxOctetsTotalOK, TxOctetsOK); | ||
181 | RMON_UPDATE(mac, TxOctetsBad, TxOctetsBad); | ||
182 | RMON_UPDATE(mac, TxUCPkts, TxUnicastFramesOK); | ||
183 | RMON_UPDATE(mac, TxMCPkts, TxMulticastFramesOK); | ||
184 | RMON_UPDATE(mac, TxBCPkts, TxBroadcastFramesOK); | ||
185 | RMON_UPDATE(mac, TxJumboPkts, TxJumboFramesOK); | ||
186 | RMON_UPDATE(mac, TxPauseFrames, TxPauseFrames); | ||
187 | RMON_UPDATE(mac, TxExcessiveLengthDrop, TxLengthErrors); | ||
188 | RMON_UPDATE(mac, TxUnderrun, TxUnderrun); | ||
189 | RMON_UPDATE(mac, TxCRCErrors, TxFCSErrors); | ||
190 | } | 203 | } |
191 | 204 | ||
192 | /* No-op interrupt operation as this MAC does not support interrupts */ | 205 | /* No-op interrupt operation as this MAC does not support interrupts */ |
@@ -390,6 +403,10 @@ static int mac_disable(struct cmac *mac, int which) | |||
390 | return 0; | 403 | return 0; |
391 | } | 404 | } |
392 | 405 | ||
406 | #define RMON_UPDATE(mac, name, stat_name) \ | ||
407 | t1_tpi_read((mac)->adapter, MACREG(mac, REG_##name), &val); \ | ||
408 | (mac)->stats.stat_name += val; | ||
409 | |||
393 | /* | 410 | /* |
394 | * This function is called periodically to accumulate the current values of the | 411 | * This function is called periodically to accumulate the current values of the |
395 | * RMON counters into the port statistics. Since the counters are only 32 bits | 412 | * RMON counters into the port statistics. Since the counters are only 32 bits |
diff --git a/drivers/net/chelsio/pm3393.c b/drivers/net/chelsio/pm3393.c index 76a7ca9e0947..69129edeefd6 100644 --- a/drivers/net/chelsio/pm3393.c +++ b/drivers/net/chelsio/pm3393.c | |||
@@ -446,17 +446,51 @@ static void pm3393_rmon_update(struct adapter *adapter, u32 offs, u64 *val, | |||
446 | *val += 1ull << 40; | 446 | *val += 1ull << 40; |
447 | } | 447 | } |
448 | 448 | ||
449 | #define RMON_UPDATE(mac, name, stat_name) \ | ||
450 | pm3393_rmon_update((mac)->adapter, OFFSET(name), \ | ||
451 | &(mac)->stats.stat_name, \ | ||
452 | (ro &((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2))) | ||
453 | |||
454 | |||
455 | static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac, | 449 | static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac, |
456 | int flag) | 450 | int flag) |
457 | { | 451 | { |
452 | static struct { | ||
453 | unsigned int reg; | ||
454 | unsigned int offset; | ||
455 | } hw_stats [] = { | ||
456 | |||
457 | #define HW_STAT(name, stat_name) \ | ||
458 | { name, (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL } | ||
459 | |||
460 | /* Rx stats */ | ||
461 | HW_STAT(RxOctetsReceivedOK, RxOctetsOK), | ||
462 | HW_STAT(RxUnicastFramesReceivedOK, RxUnicastFramesOK), | ||
463 | HW_STAT(RxMulticastFramesReceivedOK, RxMulticastFramesOK), | ||
464 | HW_STAT(RxBroadcastFramesReceivedOK, RxBroadcastFramesOK), | ||
465 | HW_STAT(RxPAUSEMACCtrlFramesReceived, RxPauseFrames), | ||
466 | HW_STAT(RxFrameCheckSequenceErrors, RxFCSErrors), | ||
467 | HW_STAT(RxFramesLostDueToInternalMACErrors, | ||
468 | RxInternalMACRcvError), | ||
469 | HW_STAT(RxSymbolErrors, RxSymbolErrors), | ||
470 | HW_STAT(RxInRangeLengthErrors, RxInRangeLengthErrors), | ||
471 | HW_STAT(RxFramesTooLongErrors , RxFrameTooLongErrors), | ||
472 | HW_STAT(RxJabbers, RxJabberErrors), | ||
473 | HW_STAT(RxFragments, RxRuntErrors), | ||
474 | HW_STAT(RxUndersizedFrames, RxRuntErrors), | ||
475 | HW_STAT(RxJumboFramesReceivedOK, RxJumboFramesOK), | ||
476 | HW_STAT(RxJumboOctetsReceivedOK, RxJumboOctetsOK), | ||
477 | |||
478 | /* Tx stats */ | ||
479 | HW_STAT(TxOctetsTransmittedOK, TxOctetsOK), | ||
480 | HW_STAT(TxFramesLostDueToInternalMACTransmissionError, | ||
481 | TxInternalMACXmitError), | ||
482 | HW_STAT(TxTransmitSystemError, TxFCSErrors), | ||
483 | HW_STAT(TxUnicastFramesTransmittedOK, TxUnicastFramesOK), | ||
484 | HW_STAT(TxMulticastFramesTransmittedOK, TxMulticastFramesOK), | ||
485 | HW_STAT(TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK), | ||
486 | HW_STAT(TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames), | ||
487 | HW_STAT(TxJumboFramesReceivedOK, TxJumboFramesOK), | ||
488 | HW_STAT(TxJumboOctetsReceivedOK, TxJumboOctetsOK) | ||
489 | }, *p = hw_stats; | ||
458 | u64 ro; | 490 | u64 ro; |
459 | u32 val0, val1, val2, val3; | 491 | u32 val0, val1, val2, val3; |
492 | u64 *stats = (u64 *) &mac->stats; | ||
493 | unsigned int i; | ||
460 | 494 | ||
461 | /* Snap the counters */ | 495 | /* Snap the counters */ |
462 | pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL, | 496 | pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL, |
@@ -470,35 +504,14 @@ static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac, | |||
470 | ro = ((u64)val0 & 0xffff) | (((u64)val1 & 0xffff) << 16) | | 504 | ro = ((u64)val0 & 0xffff) | (((u64)val1 & 0xffff) << 16) | |
471 | (((u64)val2 & 0xffff) << 32) | (((u64)val3 & 0xffff) << 48); | 505 | (((u64)val2 & 0xffff) << 32) | (((u64)val3 & 0xffff) << 48); |
472 | 506 | ||
473 | /* Rx stats */ | 507 | for (i = 0; i < ARRAY_SIZE(hw_stats); i++) { |
474 | RMON_UPDATE(mac, RxOctetsReceivedOK, RxOctetsOK); | 508 | unsigned reg = p->reg - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW; |
475 | RMON_UPDATE(mac, RxUnicastFramesReceivedOK, RxUnicastFramesOK); | 509 | |
476 | RMON_UPDATE(mac, RxMulticastFramesReceivedOK, RxMulticastFramesOK); | 510 | pm3393_rmon_update((mac)->adapter, OFFSET(p->reg), |
477 | RMON_UPDATE(mac, RxBroadcastFramesReceivedOK, RxBroadcastFramesOK); | 511 | stats + p->offset, ro & (reg >> 2)); |
478 | RMON_UPDATE(mac, RxPAUSEMACCtrlFramesReceived, RxPauseFrames); | 512 | } |
479 | RMON_UPDATE(mac, RxFrameCheckSequenceErrors, RxFCSErrors); | 513 | |
480 | RMON_UPDATE(mac, RxFramesLostDueToInternalMACErrors, | 514 | |
481 | RxInternalMACRcvError); | ||
482 | RMON_UPDATE(mac, RxSymbolErrors, RxSymbolErrors); | ||
483 | RMON_UPDATE(mac, RxInRangeLengthErrors, RxInRangeLengthErrors); | ||
484 | RMON_UPDATE(mac, RxFramesTooLongErrors , RxFrameTooLongErrors); | ||
485 | RMON_UPDATE(mac, RxJabbers, RxJabberErrors); | ||
486 | RMON_UPDATE(mac, RxFragments, RxRuntErrors); | ||
487 | RMON_UPDATE(mac, RxUndersizedFrames, RxRuntErrors); | ||
488 | RMON_UPDATE(mac, RxJumboFramesReceivedOK, RxJumboFramesOK); | ||
489 | RMON_UPDATE(mac, RxJumboOctetsReceivedOK, RxJumboOctetsOK); | ||
490 | |||
491 | /* Tx stats */ | ||
492 | RMON_UPDATE(mac, TxOctetsTransmittedOK, TxOctetsOK); | ||
493 | RMON_UPDATE(mac, TxFramesLostDueToInternalMACTransmissionError, | ||
494 | TxInternalMACXmitError); | ||
495 | RMON_UPDATE(mac, TxTransmitSystemError, TxFCSErrors); | ||
496 | RMON_UPDATE(mac, TxUnicastFramesTransmittedOK, TxUnicastFramesOK); | ||
497 | RMON_UPDATE(mac, TxMulticastFramesTransmittedOK, TxMulticastFramesOK); | ||
498 | RMON_UPDATE(mac, TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK); | ||
499 | RMON_UPDATE(mac, TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames); | ||
500 | RMON_UPDATE(mac, TxJumboFramesReceivedOK, TxJumboFramesOK); | ||
501 | RMON_UPDATE(mac, TxJumboOctetsReceivedOK, TxJumboOctetsOK); | ||
502 | 515 | ||
503 | return &mac->stats; | 516 | return &mac->stats; |
504 | } | 517 | } |
diff --git a/drivers/net/chelsio/vsc7326.c b/drivers/net/chelsio/vsc7326.c index 31a67f522597..534ffa0f616e 100644 --- a/drivers/net/chelsio/vsc7326.c +++ b/drivers/net/chelsio/vsc7326.c | |||
@@ -589,40 +589,46 @@ static void rmon_update(struct cmac *mac, unsigned int addr, u64 *stat) | |||
589 | 589 | ||
590 | static void port_stats_update(struct cmac *mac) | 590 | static void port_stats_update(struct cmac *mac) |
591 | { | 591 | { |
592 | int port = mac->instance->index; | 592 | struct { |
593 | unsigned int reg; | ||
594 | unsigned int offset; | ||
595 | } hw_stats[] = { | ||
596 | |||
597 | #define HW_STAT(reg, stat_name) \ | ||
598 | { reg, (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL } | ||
599 | |||
600 | /* Rx stats */ | ||
601 | HW_STAT(RxUnicast, RxUnicastFramesOK), | ||
602 | HW_STAT(RxMulticast, RxMulticastFramesOK), | ||
603 | HW_STAT(RxBroadcast, RxBroadcastFramesOK), | ||
604 | HW_STAT(Crc, RxFCSErrors), | ||
605 | HW_STAT(RxAlignment, RxAlignErrors), | ||
606 | HW_STAT(RxOversize, RxFrameTooLongErrors), | ||
607 | HW_STAT(RxPause, RxPauseFrames), | ||
608 | HW_STAT(RxJabbers, RxJabberErrors), | ||
609 | HW_STAT(RxFragments, RxRuntErrors), | ||
610 | HW_STAT(RxUndersize, RxRuntErrors), | ||
611 | HW_STAT(RxSymbolCarrier, RxSymbolErrors), | ||
612 | HW_STAT(RxSize1519ToMax, RxJumboFramesOK), | ||
613 | |||
614 | /* Tx stats (skip collision stats as we are full-duplex only) */ | ||
615 | HW_STAT(TxUnicast, TxUnicastFramesOK), | ||
616 | HW_STAT(TxMulticast, TxMulticastFramesOK), | ||
617 | HW_STAT(TxBroadcast, TxBroadcastFramesOK), | ||
618 | HW_STAT(TxPause, TxPauseFrames), | ||
619 | HW_STAT(TxUnderrun, TxUnderrun), | ||
620 | HW_STAT(TxSize1519ToMax, TxJumboFramesOK), | ||
621 | }, *p = hw_stats; | ||
622 | unsigned int port = mac->instance->index; | ||
623 | u64 *stats = (u64 *)&mac->stats; | ||
624 | unsigned int i; | ||
625 | |||
626 | for (i = 0; i < ARRAY_SIZE(hw_stats); i++) | ||
627 | rmon_update(mac, CRA(0x4, port, p->reg), stats + p->offset); | ||
593 | 628 | ||
594 | /* Rx stats */ | 629 | rmon_update(mac, REG_TX_OK_BYTES(port), &mac->stats.TxOctetsOK); |
595 | rmon_update(mac, REG_RX_OK_BYTES(port), &mac->stats.RxOctetsOK); | 630 | rmon_update(mac, REG_RX_OK_BYTES(port), &mac->stats.RxOctetsOK); |
596 | rmon_update(mac, REG_RX_BAD_BYTES(port), &mac->stats.RxOctetsBad); | 631 | rmon_update(mac, REG_RX_BAD_BYTES(port), &mac->stats.RxOctetsBad); |
597 | rmon_update(mac, REG_RX_UNICAST(port), &mac->stats.RxUnicastFramesOK); | ||
598 | rmon_update(mac, REG_RX_MULTICAST(port), | ||
599 | &mac->stats.RxMulticastFramesOK); | ||
600 | rmon_update(mac, REG_RX_BROADCAST(port), | ||
601 | &mac->stats.RxBroadcastFramesOK); | ||
602 | rmon_update(mac, REG_CRC(port), &mac->stats.RxFCSErrors); | ||
603 | rmon_update(mac, REG_RX_ALIGNMENT(port), &mac->stats.RxAlignErrors); | ||
604 | rmon_update(mac, REG_RX_OVERSIZE(port), | ||
605 | &mac->stats.RxFrameTooLongErrors); | ||
606 | rmon_update(mac, REG_RX_PAUSE(port), &mac->stats.RxPauseFrames); | ||
607 | rmon_update(mac, REG_RX_JABBERS(port), &mac->stats.RxJabberErrors); | ||
608 | rmon_update(mac, REG_RX_FRAGMENTS(port), &mac->stats.RxRuntErrors); | ||
609 | rmon_update(mac, REG_RX_UNDERSIZE(port), &mac->stats.RxRuntErrors); | ||
610 | rmon_update(mac, REG_RX_SYMBOL_CARRIER(port), | ||
611 | &mac->stats.RxSymbolErrors); | ||
612 | rmon_update(mac, REG_RX_SIZE_1519_TO_MAX(port), | ||
613 | &mac->stats.RxJumboFramesOK); | ||
614 | |||
615 | /* Tx stats (skip collision stats as we are full-duplex only) */ | ||
616 | rmon_update(mac, REG_TX_OK_BYTES(port), &mac->stats.TxOctetsOK); | ||
617 | rmon_update(mac, REG_TX_UNICAST(port), &mac->stats.TxUnicastFramesOK); | ||
618 | rmon_update(mac, REG_TX_MULTICAST(port), | ||
619 | &mac->stats.TxMulticastFramesOK); | ||
620 | rmon_update(mac, REG_TX_BROADCAST(port), | ||
621 | &mac->stats.TxBroadcastFramesOK); | ||
622 | rmon_update(mac, REG_TX_PAUSE(port), &mac->stats.TxPauseFrames); | ||
623 | rmon_update(mac, REG_TX_UNDERRUN(port), &mac->stats.TxUnderrun); | ||
624 | rmon_update(mac, REG_TX_SIZE_1519_TO_MAX(port), | ||
625 | &mac->stats.TxJumboFramesOK); | ||
626 | } | 632 | } |
627 | 633 | ||
628 | /* | 634 | /* |
diff --git a/drivers/net/chelsio/vsc7326_reg.h b/drivers/net/chelsio/vsc7326_reg.h index 491bcf75c4fb..479edbcabe68 100644 --- a/drivers/net/chelsio/vsc7326_reg.h +++ b/drivers/net/chelsio/vsc7326_reg.h | |||
@@ -192,73 +192,84 @@ | |||
192 | #define REG_HDX(pn) CRA(0x1,pn,0x19) /* Half-duplex config */ | 192 | #define REG_HDX(pn) CRA(0x1,pn,0x19) /* Half-duplex config */ |
193 | 193 | ||
194 | /* Statistics */ | 194 | /* Statistics */ |
195 | /* CRA(0x4,pn,reg) */ | ||
196 | /* reg below */ | ||
195 | /* pn = port number, 0-a, a = 10GbE */ | 197 | /* pn = port number, 0-a, a = 10GbE */ |
196 | #define REG_RX_IN_BYTES(pn) CRA(0x4,pn,0x00) /* # Rx in octets */ | ||
197 | #define REG_RX_SYMBOL_CARRIER(pn) CRA(0x4,pn,0x01) /* Frames w/ symbol errors */ | ||
198 | #define REG_RX_PAUSE(pn) CRA(0x4,pn,0x02) /* # pause frames received */ | ||
199 | #define REG_RX_UNSUP_OPCODE(pn) CRA(0x4,pn,0x03) /* # control frames with unsupported opcode */ | ||
200 | #define REG_RX_OK_BYTES(pn) CRA(0x4,pn,0x04) /* # octets in good frames */ | ||
201 | #define REG_RX_BAD_BYTES(pn) CRA(0x4,pn,0x05) /* # octets in bad frames */ | ||
202 | #define REG_RX_UNICAST(pn) CRA(0x4,pn,0x06) /* # good unicast frames */ | ||
203 | #define REG_RX_MULTICAST(pn) CRA(0x4,pn,0x07) /* # good multicast frames */ | ||
204 | #define REG_RX_BROADCAST(pn) CRA(0x4,pn,0x08) /* # good broadcast frames */ | ||
205 | #define REG_CRC(pn) CRA(0x4,pn,0x09) /* # frames w/ bad CRC only */ | ||
206 | #define REG_RX_ALIGNMENT(pn) CRA(0x4,pn,0x0a) /* # frames w/ alignment err */ | ||
207 | #define REG_RX_UNDERSIZE(pn) CRA(0x4,pn,0x0b) /* # frames undersize */ | ||
208 | #define REG_RX_FRAGMENTS(pn) CRA(0x4,pn,0x0c) /* # frames undersize w/ crc err */ | ||
209 | #define REG_RX_IN_RANGE_LENGTH_ERROR(pn) CRA(0x4,pn,0x0d) /* # frames with length error */ | ||
210 | #define REG_RX_OUT_OF_RANGE_ERROR(pn) CRA(0x4,pn,0x0e) /* # frames with illegal length field */ | ||
211 | #define REG_RX_OVERSIZE(pn) CRA(0x4,pn,0x0f) /* # frames oversize */ | ||
212 | #define REG_RX_JABBERS(pn) CRA(0x4,pn,0x10) /* # frames oversize w/ crc err */ | ||
213 | #define REG_RX_SIZE_64(pn) CRA(0x4,pn,0x11) /* # frames 64 octets long */ | ||
214 | #define REG_RX_SIZE_65_TO_127(pn) CRA(0x4,pn,0x12) /* # frames 65-127 octets */ | ||
215 | #define REG_RX_SIZE_128_TO_255(pn) CRA(0x4,pn,0x13) /* # frames 128-255 */ | ||
216 | #define REG_RX_SIZE_256_TO_511(pn) CRA(0x4,pn,0x14) /* # frames 256-511 */ | ||
217 | #define REG_RX_SIZE_512_TO_1023(pn) CRA(0x4,pn,0x15) /* # frames 512-1023 */ | ||
218 | #define REG_RX_SIZE_1024_TO_1518(pn) CRA(0x4,pn,0x16) /* # frames 1024-1518 */ | ||
219 | #define REG_RX_SIZE_1519_TO_MAX(pn) CRA(0x4,pn,0x17) /* # frames 1519-max */ | ||
220 | 198 | ||
221 | #define REG_TX_OUT_BYTES(pn) CRA(0x4,pn,0x18) /* # octets tx */ | 199 | enum { |
222 | #define REG_TX_PAUSE(pn) CRA(0x4,pn,0x19) /* # pause frames sent */ | 200 | RxInBytes = 0x00, // # Rx in octets |
223 | #define REG_TX_OK_BYTES(pn) CRA(0x4,pn,0x1a) /* # octets tx OK */ | 201 | RxSymbolCarrier = 0x01, // Frames w/ symbol errors |
224 | #define REG_TX_UNICAST(pn) CRA(0x4,pn,0x1b) /* # frames unicast */ | 202 | RxPause = 0x02, // # pause frames received |
225 | #define REG_TX_MULTICAST(pn) CRA(0x4,pn,0x1c) /* # frames multicast */ | 203 | RxUnsupOpcode = 0x03, // # control frames with unsupported opcode |
226 | #define REG_TX_BROADCAST(pn) CRA(0x4,pn,0x1d) /* # frames broadcast */ | 204 | RxOkBytes = 0x04, // # octets in good frames |
227 | #define REG_TX_MULTIPLE_COLL(pn) CRA(0x4,pn,0x1e) /* # frames tx after multiple collisions */ | 205 | RxBadBytes = 0x05, // # octets in bad frames |
228 | #define REG_TX_LATE_COLL(pn) CRA(0x4,pn,0x1f) /* # late collisions detected */ | 206 | RxUnicast = 0x06, // # good unicast frames |
229 | #define REG_TX_XCOLL(pn) CRA(0x4,pn,0x20) /* # frames lost, excessive collisions */ | 207 | RxMulticast = 0x07, // # good multicast frames |
230 | #define REG_TX_DEFER(pn) CRA(0x4,pn,0x21) /* # frames deferred on first tx attempt */ | 208 | RxBroadcast = 0x08, // # good broadcast frames |
231 | #define REG_TX_XDEFER(pn) CRA(0x4,pn,0x22) /* # frames excessively deferred */ | 209 | Crc = 0x09, // # frames w/ bad CRC only |
232 | #define REG_TX_CSENSE(pn) CRA(0x4,pn,0x23) /* carrier sense errors at frame end */ | 210 | RxAlignment = 0x0a, // # frames w/ alignment err |
233 | #define REG_TX_SIZE_64(pn) CRA(0x4,pn,0x24) /* # frames 64 octets long */ | 211 | RxUndersize = 0x0b, // # frames undersize |
234 | #define REG_TX_SIZE_65_TO_127(pn) CRA(0x4,pn,0x25) /* # frames 65-127 octets */ | 212 | RxFragments = 0x0c, // # frames undersize w/ crc err |
235 | #define REG_TX_SIZE_128_TO_255(pn) CRA(0x4,pn,0x26) /* # frames 128-255 */ | 213 | RxInRangeLengthError = 0x0d, // # frames with length error |
236 | #define REG_TX_SIZE_256_TO_511(pn) CRA(0x4,pn,0x27) /* # frames 256-511 */ | 214 | RxOutOfRangeError = 0x0e, // # frames with illegal length field |
237 | #define REG_TX_SIZE_512_TO_1023(pn) CRA(0x4,pn,0x28) /* # frames 512-1023 */ | 215 | RxOversize = 0x0f, // # frames oversize |
238 | #define REG_TX_SIZE_1024_TO_1518(pn) CRA(0x4,pn,0x29) /* # frames 1024-1518 */ | 216 | RxJabbers = 0x10, // # frames oversize w/ crc err |
239 | #define REG_TX_SIZE_1519_TO_MAX(pn) CRA(0x4,pn,0x2a) /* # frames 1519-max */ | 217 | RxSize64 = 0x11, // # frames 64 octets long |
240 | #define REG_TX_SINGLE_COLL(pn) CRA(0x4,pn,0x2b) /* # frames tx after single collision */ | 218 | RxSize65To127 = 0x12, // # frames 65-127 octets |
241 | #define REG_TX_BACKOFF2(pn) CRA(0x4,pn,0x2c) /* # frames tx ok after 2 backoffs/collisions */ | 219 | RxSize128To255 = 0x13, // # frames 128-255 |
242 | #define REG_TX_BACKOFF3(pn) CRA(0x4,pn,0x2d) /* after 3 backoffs/collisions */ | 220 | RxSize256To511 = 0x14, // # frames 256-511 |
243 | #define REG_TX_BACKOFF4(pn) CRA(0x4,pn,0x2e) /* after 4 */ | 221 | RxSize512To1023 = 0x15, // # frames 512-1023 |
244 | #define REG_TX_BACKOFF5(pn) CRA(0x4,pn,0x2f) /* after 5 */ | 222 | RxSize1024To1518 = 0x16, // # frames 1024-1518 |
245 | #define REG_TX_BACKOFF6(pn) CRA(0x4,pn,0x30) /* after 6 */ | 223 | RxSize1519ToMax = 0x17, // # frames 1519-max |
246 | #define REG_TX_BACKOFF7(pn) CRA(0x4,pn,0x31) /* after 7 */ | ||
247 | #define REG_TX_BACKOFF8(pn) CRA(0x4,pn,0x32) /* after 8 */ | ||
248 | #define REG_TX_BACKOFF9(pn) CRA(0x4,pn,0x33) /* after 9 */ | ||
249 | #define REG_TX_BACKOFF10(pn) CRA(0x4,pn,0x34) /* after 10 */ | ||
250 | #define REG_TX_BACKOFF11(pn) CRA(0x4,pn,0x35) /* after 11 */ | ||
251 | #define REG_TX_BACKOFF12(pn) CRA(0x4,pn,0x36) /* after 12 */ | ||
252 | #define REG_TX_BACKOFF13(pn) CRA(0x4,pn,0x37) /* after 13 */ | ||
253 | #define REG_TX_BACKOFF14(pn) CRA(0x4,pn,0x38) /* after 14 */ | ||
254 | #define REG_TX_BACKOFF15(pn) CRA(0x4,pn,0x39) /* after 15 */ | ||
255 | #define REG_TX_UNDERRUN(pn) CRA(0x4,pn,0x3a) /* # frames dropped from underrun */ | ||
256 | #define REG_RX_XGMII_PROT_ERR CRA(0x4,0xa,0x3b) /* # protocol errors detected on XGMII interface */ | ||
257 | #define REG_RX_IPG_SHRINK(pn) CRA(0x4,pn,0x3c) /* # of IPG shrinks detected */ | ||
258 | 224 | ||
259 | #define REG_STAT_STICKY1G(pn) CRA(0x4,pn,0x3e) /* tri-speed sticky bits */ | 225 | TxOutBytes = 0x18, // # octets tx |
260 | #define REG_STAT_STICKY10G CRA(0x4,0xa,0x3e) /* 10GbE sticky bits */ | 226 | TxPause = 0x19, // # pause frames sent |
261 | #define REG_STAT_INIT(pn) CRA(0x4,pn,0x3f) /* Clear all statistics */ | 227 | TxOkBytes = 0x1a, // # octets tx OK |
228 | TxUnicast = 0x1b, // # frames unicast | ||
229 | TxMulticast = 0x1c, // # frames multicast | ||
230 | TxBroadcast = 0x1d, // # frames broadcast | ||
231 | TxMultipleColl = 0x1e, // # frames tx after multiple collisions | ||
232 | TxLateColl = 0x1f, // # late collisions detected | ||
233 | TxXcoll = 0x20, // # frames lost, excessive collisions | ||
234 | TxDefer = 0x21, // # frames deferred on first tx attempt | ||
235 | TxXdefer = 0x22, // # frames excessively deferred | ||
236 | TxCsense = 0x23, // carrier sense errors at frame end | ||
237 | TxSize64 = 0x24, // # frames 64 octets long | ||
238 | TxSize65To127 = 0x25, // # frames 65-127 octets | ||
239 | TxSize128To255 = 0x26, // # frames 128-255 | ||
240 | TxSize256To511 = 0x27, // # frames 256-511 | ||
241 | TxSize512To1023 = 0x28, // # frames 512-1023 | ||
242 | TxSize1024To1518 = 0x29, // # frames 1024-1518 | ||
243 | TxSize1519ToMax = 0x2a, // # frames 1519-max | ||
244 | TxSingleColl = 0x2b, // # frames tx after single collision | ||
245 | TxBackoff2 = 0x2c, // # frames tx ok after 2 backoffs/collisions | ||
246 | TxBackoff3 = 0x2d, // after 3 backoffs/collisions | ||
247 | TxBackoff4 = 0x2e, // after 4 | ||
248 | TxBackoff5 = 0x2f, // after 5 | ||
249 | TxBackoff6 = 0x30, // after 6 | ||
250 | TxBackoff7 = 0x31, // after 7 | ||
251 | TxBackoff8 = 0x32, // after 8 | ||
252 | TxBackoff9 = 0x33, // after 9 | ||
253 | TxBackoff10 = 0x34, // after 10 | ||
254 | TxBackoff11 = 0x35, // after 11 | ||
255 | TxBackoff12 = 0x36, // after 12 | ||
256 | TxBackoff13 = 0x37, // after 13 | ||
257 | TxBackoff14 = 0x38, // after 14 | ||
258 | TxBackoff15 = 0x39, // after 15 | ||
259 | TxUnderrun = 0x3a, // # frames dropped from underrun | ||
260 | // Hole. See REG_RX_XGMII_PROT_ERR below. | ||
261 | RxIpgShrink = 0x3c, // # of IPG shrinks detected | ||
262 | // Duplicate. See REG_STAT_STICKY10G below. | ||
263 | StatSticky1G = 0x3e, // tri-speed sticky bits | ||
264 | StatInit = 0x3f // Clear all statistics | ||
265 | }; | ||
266 | |||
267 | #define REG_RX_XGMII_PROT_ERR CRA(0x4,0xa,0x3b) /* # protocol errors detected on XGMII interface */ | ||
268 | #define REG_STAT_STICKY10G CRA(0x4,0xa,StatSticky1G) /* 10GbE sticky bits */ | ||
269 | |||
270 | #define REG_RX_OK_BYTES(pn) CRA(0x4,pn,RxOkBytes) | ||
271 | #define REG_RX_BAD_BYTES(pn) CRA(0x4,pn,RxBadBytes) | ||
272 | #define REG_TX_OK_BYTES(pn) CRA(0x4,pn,TxOkBytes) | ||
262 | 273 | ||
263 | /* MII-Management Block registers */ | 274 | /* MII-Management Block registers */ |
264 | /* These are for MII-M interface 0, which is the bidirectional LVTTL one. If | 275 | /* These are for MII-M interface 0, which is the bidirectional LVTTL one. If |