From nobody Wed Nov 5 20:03:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537881834178397.846032677552; Tue, 25 Sep 2018 06:23:54 -0700 (PDT) Received: from localhost ([::1]:53112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4nJY-0004TP-SR for importer@patchew.org; Tue, 25 Sep 2018 09:23:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4jOy-0002KS-Tu for qemu-devel@nongnu.org; Tue, 25 Sep 2018 05:13:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4j8u-0000mB-Po for qemu-devel@nongnu.org; Tue, 25 Sep 2018 04:56:32 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:41590) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g4j8u-0000kJ-Cp for qemu-devel@nongnu.org; Tue, 25 Sep 2018 04:56:28 -0400 Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Tue, 25 Sep 2018 02:56:17 -0600 From: Martin Wilck To: Jason Wang , qemu-devel@nongnu.org Date: Tue, 25 Sep 2018 10:56:00 +0200 Message-Id: <20180925085600.14750-1-mwilck@suse.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 137.65.250.81 X-Mailman-Approved-At: Tue, 25 Sep 2018 09:22:53 -0400 Subject: [Qemu-devel] [PATCH] e1000: indicate dropped packets in HW counters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Kubecek , Martin Wilck , Hannes Reinecke Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The e1000 emulation silently discards RX packets if there's insufficient space in the ring buffer. This leads to errors on higher-level protocols in the guest, with no indication about the error cause. This patch increments the "Missed Packets Count" (MPC) and "Receive No Buffers Count" (RNBC) HW counters in this case. As the emulation has no FIFO for buffering packets that can't immediately be pushed to the guest, these two registers are practically equivalent (see 10.2.7.4, 10.2.7.33 in https://www.intel.com/content/www/us/en/embedded/products/networking/82574l= -gbe-controller-datasheet.html). On a Linux guest, the register content will be reflected in the "rx_missed_errors" and "rx_no_buffer_count" stats from "ethtool -S", and in the "missed" stat from "ip -s -s link show", giving at least some hint about the error cause inside the guest. If the cause is known, problems like this can often be avoided easily, by increasing the number of RX descriptors in the guest e1000 driver (e.g under Linux, "e1000.RxDescriptors=3D1024"). The patch also adds a qemu trace message for this condition. Signed-off-by: Martin Wilck --- hw/net/e1000.c | 20 ++++++++++++++------ hw/net/trace-events | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 13a9494..312d6b1 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -36,6 +36,7 @@ #include "qemu/range.h" =20 #include "e1000x_common.h" +#include "trace.h" =20 static const uint8_t bcast[] =3D {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; =20 @@ -847,6 +848,16 @@ static uint64_t rx_desc_base(E1000State *s) return (bah << 32) + bal; } =20 +static int +e1000_receiver_overrun(E1000State *s, size_t size) +{ + trace_e1000_receiver_overrun(size, s->mac_reg[RDH], s->mac_reg[RDT]); + e1000x_inc_reg_if_not_full(s->mac_reg, RNBC); + e1000x_inc_reg_if_not_full(s->mac_reg, MPC); + set_ics(s, 0, E1000_ICS_RXO); + return -1; +} + static ssize_t e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) { @@ -915,10 +926,8 @@ e1000_receive_iov(NetClientState *nc, const struct iov= ec *iov, int iovcnt) rdh_start =3D s->mac_reg[RDH]; desc_offset =3D 0; total_size =3D size + e1000x_fcs_len(s->mac_reg); - if (!e1000_has_rxbufs(s, total_size)) { - set_ics(s, 0, E1000_ICS_RXO); - return -1; - } + if (!e1000_has_rxbufs(s, total_size)) + return e1000_receiver_overrun(s, total_size); do { desc_size =3D total_size - desc_offset; if (desc_size > s->rxbuf_size) { @@ -969,8 +978,7 @@ e1000_receive_iov(NetClientState *nc, const struct iove= c *iov, int iovcnt) rdh_start >=3D s->mac_reg[RDLEN] / sizeof(desc)) { DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\n", rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]); - set_ics(s, 0, E1000_ICS_RXO); - return -1; + return e1000_receiver_overrun(s, total_size); } } while (desc_offset < total_size); =20 diff --git a/hw/net/trace-events b/hw/net/trace-events index 663bea1..7e3da9d 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -104,6 +104,9 @@ net_rx_pkt_rss_ip6_ex(void) "Calculating IPv6/EX RSS h= ash" net_rx_pkt_rss_hash(size_t rss_length, uint32_t rss_hash) "RSS hash for %z= u bytes: 0x%X" net_rx_pkt_rss_add_chunk(void* ptr, size_t size, size_t input_offset) "Add= RSS chunk %p, %zu bytes, RSS input offset %zu bytes" =20 +# hw/net/e1000.c +e1000_receiver_overrun(size_t s, uint32_t rdh, uint32_t rdt) "Receiver ove= rrun: dropped packet of %lu bytes, RDH=3D%u, RDT=3D%u" + # hw/net/e1000x_common.c e1000x_rx_can_recv_disabled(bool link_up, bool rx_enabled, bool pci_master= ) "link_up: %d, rx_enabled %d, pci_master %d" e1000x_vlan_is_vlan_pkt(bool is_vlan_pkt, uint16_t eth_proto, uint16_t vet= ) "Is VLAN packet: %d, ETH proto: 0x%X, VET: 0x%X" --=20 2.19.0