From patchwork Mon Apr 4 10:13:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 8739731 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 40A129F38C for ; Mon, 4 Apr 2016 10:13:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A17CA201FA for ; Mon, 4 Apr 2016 10:13:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DFC1220138 for ; Mon, 4 Apr 2016 10:13:26 +0000 (UTC) Received: from localhost ([::1]:57689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an1Ve-0006dI-8V for patchwork-qemu-devel@patchwork.kernel.org; Mon, 04 Apr 2016 06:13:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an1VV-0006cJ-Ni for qemu-devel@nongnu.org; Mon, 04 Apr 2016 06:13:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1an1VR-0008A6-RO for qemu-devel@nongnu.org; Mon, 04 Apr 2016 06:13:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an1VR-0008A0-Lk; Mon, 04 Apr 2016 06:13:13 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A3A480E42; Mon, 4 Apr 2016 10:13:13 +0000 (UTC) Received: from thh440s.fritz.box (vpn1-6-48.ams2.redhat.com [10.36.6.48]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u34ADAow015969; Mon, 4 Apr 2016 06:13:11 -0400 From: Thomas Huth To: qemu-ppc@nongnu.org, David Gibson , Alexander Graf Date: Mon, 4 Apr 2016 12:13:10 +0200 Message-Id: <1459764790-17173-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jason Wang , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH for-2.7] hw/net/spapr_llan: Provide counter with dropped rx frames to the guest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; }