Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2660630imj; Mon, 11 Feb 2019 06:37:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ9x/p2hG+ZPIiiGlWszpUmbR9NZ4yBZr6v3LMVA/s6Yrerb+TdT0/lyhThC0+WtKMHCqSm X-Received: by 2002:a63:ef04:: with SMTP id u4mr34019764pgh.197.1549895861868; Mon, 11 Feb 2019 06:37:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895861; cv=none; d=google.com; s=arc-20160816; b=0RQso7VB2ey1ZoQ1iVSF6/jcOn+KLDZiOGuJ54BQtdygcijcavzaBfGFkIaIz9sV3M BOWTLTh6s5D+pomIFHElVs7oDmly3m3XP3iRk/SlIUvE51LUzm45mXjB+EuUprIUb/lo Slz8uBU/GaWlIvJdUl9j0X9wJREfSS3PC4ZyZLmxTDsvBks4hozE/KmMuR+j+OL+kVDS 7LEX72aSADrYA3AD4spYqnCpInihWPPDeqTSApZBBMjhn1Q8+P/XCZktssLYTPusYwjI 3/0pKnL863olC5jiSQUBLqB18sKripgPCsrEpXempiBAoWCu+FoqZl7Cm6W+0tJtN3/G rJnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jctyx5u4UH85zB3LkbE+ruqglMLAb+fmyhhnh9UV/rM=; b=Y52SD+Nuct8lMWMaLCLK4wT+c+dboQ9lov+FuPMehXsfA3mNJwKsYoteyawWpKcoSA MZN3Rw6W8QhXqF/yD2LpIbRLwwxl1UkxTAx+rRADp0H64xjtABxkjfmpGI1obTcxxNLV Uq9nYmHZYsEe287dYXdkFWSCc6ItyK5wD2JLKDpZe5TuzmxpOyqG/UalQxNA6uuacPSy 9ZpVSIcTqjX730DYTIJV+NKoVhrP+fcvyoOqem9x6QSafpcWQvKS+oZQ/ORMz5B126Cg pIQ3kn+K02ufB6KwwdxaUF+bgQXfoc+fkCC+rWg8QGdS+3fNbPWre0gLKLMb14Up3u/R Ociw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yW9YS1Es; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si435716pff.171.2019.02.11.06.37.25; Mon, 11 Feb 2019 06:37:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yW9YS1Es; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731285AbfBKOgi (ORCPT + 99 others); Mon, 11 Feb 2019 09:36:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:45710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731271AbfBKOge (ORCPT ); Mon, 11 Feb 2019 09:36:34 -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 3CCAF20818; Mon, 11 Feb 2019 14:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895793; bh=mzYsWjHoFpcG7eevJA3ldtl8mFO4u5KDbGzajJOEFFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yW9YS1EsboDKF5gBZW3ofTNUcGNAIR3S+WfUSU/pyrLCLX2XrZ8KpYCZvFcpSQajS Kfk7tIV4d6zInKkBQDMZXemNfaH9UerTdpHurPubXL2pjWaIXfbs+ovFsdFlEI3Qnb JgNuoyNwj+a7tyHbIWrGwoPaAaVqOpajJXIHWiYQ= 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.20 307/352] virtio_net: Account for tx bytes and packets on sending xdp_frames Date: Mon, 11 Feb 2019 15:18:54 +0100 Message-Id: <20190211141906.393061756@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-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;