Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3430956ybp; Sun, 6 Oct 2019 11:46:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9L4Sb/RrT5BmFfBfeiHy3+Fs0lme8LFRzp4ssx1W228/53d5Jy+RRMYf9G+msP2eBFGEu X-Received: by 2002:a50:8a9a:: with SMTP id j26mr25846112edj.251.1570387577200; Sun, 06 Oct 2019 11:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570387577; cv=none; d=google.com; s=arc-20160816; b=O4f9eGXGfhsYlcWKIBXAUfpKIbqEIdkKvi9HGtcEwRGYTx7xJxzsLtwKY8rIjOD5ig 4YvSb9tNZa8n9mbtuKQIjcJTEGIa4RNur3MRbr//XfB06NZsuxiNtXc0v83yVLeuUBD6 heYtw1sIoQZpKhZR04PmFImpRvvdvvzqNZIzCYP9zRSekD1Du105nNqhi+lUbhi3h5Ss XTTavXwrmmJUfNmk9VRyLsgad6OlWMlq4+lewWj0Xns/yzQBCvPDHw0WlmXrziKTHIEe 4Ha4ci9fu+H/wRj54zbVd+G223TBuRPTRTh1rGaKYXa+JHGmBDPENHMSWhBICoot6PES pHMw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4+0D96UNcW16NmIZzh7KLXswmY9Zu6wl9T6ptTV3qho=; b=ZULVoY6nHq76jZi9eS4jo3/GCRrdq5pbjGWs5cdeoa1s1UQycbiIEmSROoNAJHQD+M HNcxwXt+E8CKE0IokRmd4n+zFmr2JQQofAO+BchW2RGRn1grpyoKoBKSe9LbFlSGe6CE ZyVyBc1YnfBjcO6U+Muijai7poH7W+djmnI7zcgSvqq14CfN9R9//jdfL9FK901sOLIE DU1HgxeLOxfz1mL7qDchqUcp7Jmx6Y9Uc93WatJ82H+UhT2zvjJKzcnZK57fkxopDE0c k2qnn7n/zmi/S2+9O2gb6T2DcAMtJRAslBafTYtp1fCP2k58i7sG++O8Be2R7qYIR0L8 eNmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LIipmTrS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g50si7317197edb.47.2019.10.06.11.45.53; Sun, 06 Oct 2019 11:46:17 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=LIipmTrS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbfJFSp3 (ORCPT + 99 others); Sun, 6 Oct 2019 14:45:29 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:36366 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725905AbfJFSp1 (ORCPT ); Sun, 6 Oct 2019 14:45:27 -0400 Received: by mail-qt1-f193.google.com with SMTP id o12so16171767qtf.3; Sun, 06 Oct 2019 11:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4+0D96UNcW16NmIZzh7KLXswmY9Zu6wl9T6ptTV3qho=; b=LIipmTrSU2Fe7zrquUlZt36LofVfmw3+efcqrExFJHFJhnuGug1fg54yhAKr7GI67j oHtpp0/ZG1zdhEP4F/1qVBRiCqmBHkuM6EALQP0f8gkp8nzvn+uwVoYV7ofke98Bskod qTiaaaKA+fynSBP/Hq+zdbb3hKP3koKjW2nv+bqjCYeBhox4ahHMelYD87/YJnoUoTMP 0ySAtNVExLQ8bEP+EKJGNm1TPOE6DmuYCO5z530P4LbtzdY1flCarykY7hvancmGb0I1 JHsaMpbHBWVJjLmot+yNSGZp5Qb6INnVlzBvlAvTqxpdMMl8fOWLnz9pCa6UP47EeTlX BC1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4+0D96UNcW16NmIZzh7KLXswmY9Zu6wl9T6ptTV3qho=; b=PzWWpNbYIx1ALAWebDpcqrf6rAHUPLj4kkFO359TDHN39DjpBZnT3eaZYXTtp2AZ6m xvXc4R8O6fizVdfJa4gIQCrlqEdoCrKTe25C9oFQQVbXElEnJjIY2gotfuElEASVflpk V6gtWbLy9wybikNj1P1773DMrq+NdTiIrObJNrmWS7tiCUynAvM1vHEb844W5+xayKLA Epk3IE7LVOTCbUot2qpmnRvlMn/f4x7U7WXFrJ9k7H+7/CAnC8bN2aaWAzllLvX26y6/ YNE0yy3dgoS1ULSo0TW/Mig+MeWd4fqy7GXxAHMt8JfTKdoEQzeNcy0WmCS0Bt4RlH3q 0WqA== X-Gm-Message-State: APjAAAX5Ci77A5c/ipmbZeBFpAfPhOr2RMFM53cUhLAxrYgU7MJqTZfX au6AB4k6FlzYpX4X3VbEMIABpSeE X-Received: by 2002:a0c:add6:: with SMTP id x22mr24177091qvc.203.1570387525924; Sun, 06 Oct 2019 11:45:25 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7cb:21c2:d505:73c7:4df5:8eac]) by smtp.gmail.com with ESMTPSA id l23sm11275578qta.53.2019.10.06.11.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2019 11:45:25 -0700 (PDT) From: jcfaracco@gmail.com To: netdev@vger.kernel.org Cc: mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, dnmendes76@gmail.com Subject: [PATCH RFC net-next 2/2] drivers: net: virtio_net: Add tx_timeout function Date: Sun, 6 Oct 2019 15:45:15 -0300 Message-Id: <20191006184515.23048-3-jcfaracco@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191006184515.23048-1-jcfaracco@gmail.com> References: <20191006184515.23048-1-jcfaracco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julio Faracco To enable dev_watchdog, virtio_net should have a tx_timeout defined (.ndo_tx_timeout). This is only a skeleton to throw a warn message. It notifies the event in some specific queue of device. This function still counts tx_timeout statistic and consider this event as an error (one error per queue), reporting it. Signed-off-by: Julio Faracco Signed-off-by: Daiane Mendes Cc: Jason Wang --- drivers/net/virtio_net.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 27f9b212c9f5..4b703b4b9441 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2585,6 +2585,29 @@ static int virtnet_set_features(struct net_device *dev, return 0; } +static void virtnet_tx_timeout(struct net_device *dev) +{ + struct virtnet_info *vi = netdev_priv(dev); + u32 i; + + /* find the stopped queue the same way dev_watchdog() does */ + for (i = 0; i < vi->curr_queue_pairs; i++) { + struct send_queue *sq = &vi->sq[i]; + + if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i))) + continue; + + u64_stats_update_begin(&sq->stats.syncp); + sq->stats.tx_timeouts++; + u64_stats_update_end(&sq->stats.syncp); + + netdev_warn(dev, "TX timeout on send queue: %d, sq: %s, vq: %d, name: %s\n", + i, sq->name, sq->vq->index, sq->vq->name); + + dev->stats.tx_errors++; + } +} + static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close, @@ -2600,6 +2623,7 @@ static const struct net_device_ops virtnet_netdev = { .ndo_features_check = passthru_features_check, .ndo_get_phys_port_name = virtnet_get_phys_port_name, .ndo_set_features = virtnet_set_features, + .ndo_tx_timeout = virtnet_tx_timeout, }; static void virtnet_config_changed_work(struct work_struct *work) @@ -3018,6 +3042,9 @@ static int virtnet_probe(struct virtio_device *vdev) dev->netdev_ops = &virtnet_netdev; dev->features = NETIF_F_HIGHDMA; + /* Set up dev_watchdog cycle. */ + dev->watchdog_timeo = 5 * HZ; + dev->ethtool_ops = &virtnet_ethtool_ops; SET_NETDEV_DEV(dev, &vdev->dev); -- 2.21.0