From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B04C7C282D7 for ; Mon, 11 Feb 2019 15:36:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80D1C222A5 for ; Mon, 11 Feb 2019 15:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549899384; bh=lOJZ29Cn6s7ySZRYto7E17J7Uz338jh0HsmvNncVLBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ogXM/I5nQXjfRPeuqo1b/WZIZIOwqLEUObMw3ka6sGHwGe0v9FxTwbc31QBmOBOpl fqy38cWh+jHeNYP4vYzuAxW5w/5QVDpcLGY+jR1PkAXjc/M3WyJnXIUku8FhCLVFIN ezc3TZ+G4h25EwVBkc0pRbp77oPcTbSxDBlFwneY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387886AbfBKOvv (ORCPT ); Mon, 11 Feb 2019 09:51:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:37996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387918AbfBKOvu (ORCPT ); Mon, 11 Feb 2019 09:51:50 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 987F12081B; Mon, 11 Feb 2019 14:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896710; bh=lOJZ29Cn6s7ySZRYto7E17J7Uz338jh0HsmvNncVLBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CtzwtjAisIedqHOlSaIchJNxNISICDkLIPLSnYuVhL8iFf64n9syEMk60jj0KwUmw V67fes3FuFlhQiGWHiOMUm6m0vLY7hmw5RXMnAOfGzekcqSIiWS+WPOY0fZd1c8RTy jvU9fVbPAn9C9q9j5E3eJT5CStj034ZnvJePnxlY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Ahern , Toshiaki Makita , "Michael S. Tsirkin" , "David S. Miller" Subject: [PATCH 4.19 275/313] virtio_net: Account for tx bytes and packets on sending xdp_frames Date: Mon, 11 Feb 2019 15:19:15 +0100 Message-Id: <20190211141911.671054443@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141852.749630980@linuxfoundation.org> References: <20190211141852.749630980@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Toshiaki Makita [ Upstream commit 546f28974d771b124fb0bf7b551b343888cf0419 ] Previously virtnet_xdp_xmit() did not account for device tx counters, which caused confusions. To be consistent with SKBs, account them on freeing xdp_frames. Reported-by: David Ahern Signed-off-by: Toshiaki Makita Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/virtio_net.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -502,6 +502,8 @@ static int virtnet_xdp_xmit(struct net_d struct bpf_prog *xdp_prog; struct send_queue *sq; unsigned int len; + int packets = 0; + int bytes = 0; int drops = 0; int kicks = 0; int ret, err; @@ -525,10 +527,18 @@ static int virtnet_xdp_xmit(struct net_d /* Free up any pending old buffers before queueing new ones. */ while ((ptr = virtqueue_get_buf(sq->vq, &len)) != NULL) { - if (likely(is_xdp_frame(ptr))) - xdp_return_frame(ptr_to_xdp(ptr)); - else - napi_consume_skb(ptr, false); + if (likely(is_xdp_frame(ptr))) { + struct xdp_frame *frame = ptr_to_xdp(ptr); + + bytes += frame->len; + xdp_return_frame(frame); + } else { + struct sk_buff *skb = ptr; + + bytes += skb->len; + napi_consume_skb(skb, false); + } + packets++; } for (i = 0; i < n; i++) { @@ -548,6 +558,8 @@ static int virtnet_xdp_xmit(struct net_d } out: u64_stats_update_begin(&sq->stats.syncp); + sq->stats.bytes += bytes; + sq->stats.packets += packets; sq->stats.xdp_tx += n; sq->stats.xdp_tx_drops += drops; sq->stats.kicks += kicks;