@@ -196,11 +196,15 @@ enum ravb_reg {
MAHR = 0x05c0,
MALR = 0x05c8,
TROCR = 0x0700, /* R-Car Gen3 and RZ/G2L only */
+ CXR41 = 0x0708, /* RZ/G2L only */
+ CXR42 = 0x0710, /* RZ/G2L only */
CEFCR = 0x0740,
FRECR = 0x0748,
TSFRCR = 0x0750,
TLFRCR = 0x0758,
RFCR = 0x0760,
+ CXR55 = 0x0768, /* RZ/G2L only */
+ CXR56 = 0x0770, /* RZ/G2L only */
MAFCR = 0x0778,
};
@@ -1023,6 +1027,7 @@ struct ravb_hw_info {
unsigned nc_queue:1; /* AVB-DMAC has NC queue */
unsigned magic_pkt:1; /* E-MAC supports magic packet detection */
unsigned half_duplex:1; /* E-MAC supports half duplex mode */
+ unsigned carrier_counters:1; /* E-MAC has carrier counters */
};
struct ravb_private {
@@ -2069,6 +2069,18 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev)
ravb_write(ndev, 0, TROCR); /* (write clear) */
}
+ if (info->carrier_counters) {
+ nstats->collisions += ravb_read(ndev, CXR41);
+ ravb_write(ndev, 0, CXR41); /* (write clear) */
+ nstats->tx_carrier_errors += ravb_read(ndev, CXR42);
+ ravb_write(ndev, 0, CXR42); /* (write clear) */
+
+ nstats->tx_carrier_errors += ravb_read(ndev, CXR55);
+ ravb_write(ndev, 0, CXR55); /* (write clear) */
+ nstats->tx_carrier_errors += ravb_read(ndev, CXR56);
+ ravb_write(ndev, 0, CXR56); /* (write clear) */
+ }
+
nstats->rx_packets = stats0->rx_packets;
nstats->tx_packets = stats0->tx_packets;
nstats->rx_bytes = stats0->rx_bytes;
@@ -2449,6 +2461,7 @@ static const struct ravb_hw_info gbeth_hw_info = {
.aligned_tx = 1,
.tx_counters = 1,
.half_duplex = 1,
+ .carrier_counters = 1,
};
static const struct of_device_id ravb_match_table[] = {