All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] spapr-vlan: Don't touch last entry in buffer list
@ 2014-08-22  1:50 Anton Blanchard
  2014-08-26  3:02 ` David Gibson
  2014-08-27 11:07 ` Alexander Graf
  0 siblings, 2 replies; 3+ messages in thread
From: Anton Blanchard @ 2014-08-22  1:50 UTC (permalink / raw)
  To: agraf, david, aik, paulus; +Cc: qemu-ppc, qemu-devel

The last 8 bytes of the buffer list is defined to contain the number
of dropped frames. At the moment we use it to store rx entries,
which trips up ethtool -S:

rx_no_buffer: 9223380832981355136

Fix this by skipping the last buffer list entry.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index 2d47df6..23c47d3 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -72,7 +72,14 @@ typedef uint64_t vlan_bd_t;
 #define VLAN_RXQ_BD_OFF      0
 #define VLAN_FILTER_BD_OFF   8
 #define VLAN_RX_BDS_OFF      16
-#define VLAN_MAX_BUFS        ((SPAPR_TCE_PAGE_SIZE - VLAN_RX_BDS_OFF) / 8)
+/*
+ * The final 8 bytes of the buffer list is a counter of frames dropped
+ * because there was not a buffer in the buffer list capable of holding
+ * the frame. We must avoid it, or the operating system will report garbage
+ * for this statistic.
+ */
+#define VLAN_RX_BDS_LEN      (SPAPR_TCE_PAGE_SIZE - VLAN_RX_BDS_OFF - 8)
+#define VLAN_MAX_BUFS        (VLAN_RX_BDS_LEN / 8)
 
 #define TYPE_VIO_SPAPR_VLAN_DEVICE "spapr-vlan"
 #define VIO_SPAPR_VLAN_DEVICE(obj) \
@@ -119,7 +126,7 @@ static ssize_t spapr_vlan_receive(NetClientState *nc, const uint8_t *buf,
 
     do {
         buf_ptr += 8;
-        if (buf_ptr >= SPAPR_TCE_PAGE_SIZE) {
+        if (buf_ptr >= (VLAN_RX_BDS_LEN + VLAN_RX_BDS_OFF)) {
             buf_ptr = VLAN_RX_BDS_OFF;
         }
 
@@ -397,7 +404,7 @@ static target_ulong h_add_logical_lan_buffer(PowerPCCPU *cpu,
 
     do {
         dev->add_buf_ptr += 8;
-        if (dev->add_buf_ptr >= SPAPR_TCE_PAGE_SIZE) {
+        if (dev->add_buf_ptr >= (VLAN_RX_BDS_LEN + VLAN_RX_BDS_OFF)) {
             dev->add_buf_ptr = VLAN_RX_BDS_OFF;
         }
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] spapr-vlan: Don't touch last entry in buffer list
  2014-08-22  1:50 [Qemu-devel] [PATCH] spapr-vlan: Don't touch last entry in buffer list Anton Blanchard
@ 2014-08-26  3:02 ` David Gibson
  2014-08-27 11:07 ` Alexander Graf
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2014-08-26  3:02 UTC (permalink / raw)
  To: Anton Blanchard; +Cc: aik, qemu-ppc, paulus, agraf, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 706 bytes --]

On Fri, Aug 22, 2014 at 11:50:57AM +1000, Anton Blanchard wrote:
> The last 8 bytes of the buffer list is defined to contain the number
> of dropped frames. At the moment we use it to store rx entries,
> which trips up ethtool -S:
> 
> rx_no_buffer: 9223380832981355136
> 
> Fix this by skipping the last buffer list entry.
> 
> Signed-off-by: Anton Blanchard <anton@samba.org>

Huh.  I obviously missed that bit of the llan spec in PAPR.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

-- 
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: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] spapr-vlan: Don't touch last entry in buffer list
  2014-08-22  1:50 [Qemu-devel] [PATCH] spapr-vlan: Don't touch last entry in buffer list Anton Blanchard
  2014-08-26  3:02 ` David Gibson
@ 2014-08-27 11:07 ` Alexander Graf
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2014-08-27 11:07 UTC (permalink / raw)
  To: Anton Blanchard, david, aik, paulus; +Cc: qemu-ppc, qemu-devel



On 22.08.14 03:50, Anton Blanchard wrote:
> The last 8 bytes of the buffer list is defined to contain the number
> of dropped frames. At the moment we use it to store rx entries,
> which trips up ethtool -S:
> 
> rx_no_buffer: 9223380832981355136
> 
> Fix this by skipping the last buffer list entry.
> 
> Signed-off-by: Anton Blanchard <anton@samba.org>

Thanks, applied to ppc-next.


Alex

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-27 11:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-22  1:50 [Qemu-devel] [PATCH] spapr-vlan: Don't touch last entry in buffer list Anton Blanchard
2014-08-26  3:02 ` David Gibson
2014-08-27 11:07 ` Alexander Graf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.