* [Qemu-devel] [PATCH for-2.7] hw/net/spapr_llan: Provide counter with dropped rx frames to the guest
@ 2016-04-04 10:13 Thomas Huth
2016-04-05 2:18 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2016-04-04 10:13 UTC (permalink / raw)
To: qemu-ppc, David Gibson, Alexander Graf; +Cc: Jason Wang, qemu-devel
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>
---
Note: The patch has to be applied on top of the "Delay flushing of the
RX queue while adding new RX buffers" patch that I sent last week
(otherwise there will be context conflicts with the "return" statements).
hw/net/spapr_llan.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index d604d55..719ad29 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -122,6 +122,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,
@@ -206,6 +221,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;
}
@@ -215,6 +231,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;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.7] hw/net/spapr_llan: Provide counter with dropped rx frames to the guest
2016-04-04 10:13 [Qemu-devel] [PATCH for-2.7] hw/net/spapr_llan: Provide counter with dropped rx frames to the guest Thomas Huth
@ 2016-04-05 2:18 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2016-04-05 2:18 UTC (permalink / raw)
To: Thomas Huth; +Cc: Jason Wang, qemu-ppc, Alexander Graf, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2589 bytes --]
On Mon, Apr 04, 2016 at 12:13:10PM +0200, Thomas Huth wrote:
> 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>
> ---
> Note: The patch has to be applied on top of the "Delay flushing of the
> RX queue while adding new RX buffers" patch that I sent last week
> (otherwise there will be context conflicts with the "return"
> statements).
Applied to ppc-for-2.7, thanks.
>
> hw/net/spapr_llan.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
> index d604d55..719ad29 100644
> --- a/hw/net/spapr_llan.c
> +++ b/hw/net/spapr_llan.c
> @@ -122,6 +122,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,
> @@ -206,6 +221,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;
> }
>
> @@ -215,6 +231,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;
> }
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-05 3:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-04 10:13 [Qemu-devel] [PATCH for-2.7] hw/net/spapr_llan: Provide counter with dropped rx frames to the guest Thomas Huth
2016-04-05 2:18 ` David Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).