aboutsummaryrefslogtreecommitdiff
path: root/hw/net/spapr_llan.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2016-04-04 12:13:10 +0200
committerDavid Gibson <david@gibson.dropbear.id.au>2016-05-27 09:40:23 +1000
commit5c29dd8c28c3c7718cc37b38c5171b3caf629928 (patch)
tree953ecb3e14535f981afd606f662a146b6f785577 /hw/net/spapr_llan.c
parent8836630f5d2df198dca2da9a1f1fb2d2a0c310a0 (diff)
hw/net/spapr_llan: Provide counter with dropped rx frames to the guest
The last 8 bytes of the receive buffer list page (that has been supplied by the guest with the H_REGISTER_LOGICAL_LAN call) contain a counter for frames that have been dropped because there was no suitable receive buffer available. This patch introduces code to use this field to provide the information about dropped rx packets to the guest. There it can be queried with "ethtool -S eth0 | grep rx_no_buffer". Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw/net/spapr_llan.c')
-rw-r--r--hw/net/spapr_llan.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index 36a9214128..8b2eebd4e3 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -123,6 +123,21 @@ static int spapr_vlan_can_receive(NetClientState *nc)
}
/**
+ * The last 8 bytes of the receive buffer list page (that has been
+ * supplied by the guest with the H_REGISTER_LOGICAL_LAN call) contain
+ * a counter for frames that have been dropped because there was no
+ * suitable receive buffer available. This function is used to increase
+ * this counter by one.
+ */
+static void spapr_vlan_record_dropped_rx_frame(VIOsPAPRVLANDevice *dev)
+{
+ uint64_t cnt;
+
+ cnt = vio_ldq(&dev->sdev, dev->buf_list + 4096 - 8);
+ vio_stq(&dev->sdev, dev->buf_list + 4096 - 8, cnt + 1);
+}
+
+/**
* Get buffer descriptor from one of our receive buffer pools
*/
static vlan_bd_t spapr_vlan_get_rx_bd_from_pool(VIOsPAPRVLANDevice *dev,
@@ -207,6 +222,7 @@ static ssize_t spapr_vlan_receive(NetClientState *nc, const uint8_t *buf,
}
if (!dev->rx_bufs) {
+ spapr_vlan_record_dropped_rx_frame(dev);
return 0;
}
@@ -216,6 +232,7 @@ static ssize_t spapr_vlan_receive(NetClientState *nc, const uint8_t *buf,
bd = spapr_vlan_get_rx_bd_from_page(dev, size);
}
if (!bd) {
+ spapr_vlan_record_dropped_rx_frame(dev);
return 0;
}