From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id CEDE7A0471 for ; Wed, 19 Jun 2019 20:58:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 392701D107; Wed, 19 Jun 2019 20:58:07 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id 4AC771D0DB for ; Wed, 19 Jun 2019 20:57:59 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id q10so129231pff.9 for ; Wed, 19 Jun 2019 11:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5KQLa8JXU7iYjmTO14hFZMlxbnfGbb4eamPcVTXkkaE=; b=nKzDgGixkSqTch8bSDg5/OKwMe8lBRYiJjQp1BkEYJCl0Zg1rb4/0KvrH4eH6Ccd5g byhF0SQkEA7fuEk9C42KG/SxOUTcW7NTuuUWhHv++/dg9HXUlZHFq01lods+Kx/lbqY2 kvm0y/cEIKlCU89c0RiZP3hW9oJfO7jF58mmXZ7Cqxwj4pL5kfwPRKbQC3cX973GyesV FqqWhjDSFi7ehgJJT2Rshhuxb9fa+fjYJOUnXKVjGt+3IvrEhcTASRAI7M60+DR0z06X ygE5Yyok01uvdLp6wg9vlqZhD4uJro0GsbF1MAFLtEK4Z31xEHa6nQKtFamfb4qVQq/P OI7Q== 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=5KQLa8JXU7iYjmTO14hFZMlxbnfGbb4eamPcVTXkkaE=; b=W69W2i4UfUzaON7tycqxoZbcqbYB0jwQsg1yf4xvtAwIs3XqcYleAVBpjp92mAPEqJ 6bDi/BrUkxExAhfTNcEPxn3CthWHTABkMO401c/Z74i/KFQ2zXQWKzq9fnAIkpwjQ/MD 18V6VcTwjZgjUsbGMu3kFyRf0FmKGywnwWyEN0UM7XYUuiCMYaNgDD1KIhY52QT5HXlq fWDJMBJJAQgvvtoMIF+1m5VK8q7FI7m2NGprVn3UFB8n/k7jfz7tPJk0c1PxUeSBV71b 5leO9ungZIg8uHioz2+qsoc2l6wDsZXLKwXeyVKkvcoKfKi/5uOHh0+riOWuL/+Fyyht WTAQ== X-Gm-Message-State: APjAAAUmuBoRrlb7PT04E2G348kOL4UXiyowovUcXI/P9ezb2li66s5g ojxAjEMDVxzihNKI7TIqgbqHSqmICiU= X-Google-Smtp-Source: APXvYqwE/RwftLmSgemp0LqaoN+N7i9kfj30TmjsFUo0cahJPCbYM5KG0iK0rCqPOpAr8yjUxu6A/A== X-Received: by 2002:a17:90a:9291:: with SMTP id n17mr12382766pjo.66.1560970678258; Wed, 19 Jun 2019 11:57:58 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id b8sm24774858pff.20.2019.06.19.11.57.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 11:57:57 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 19 Jun 2019 11:57:41 -0700 Message-Id: <20190619185746.26866-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619185746.26866-1-stephen@networkplumber.org> References: <20190610175155.21374-1-stephen@networkplumber.org> <20190619185746.26866-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 3/8] kni: don't keep stats in kni_net X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger Since kernel 2.6.28 the network subsystem has provided dev->stats for devices to use statistics handling and is the default if no ndo_get_stats is provided. This allow allows for 64 bit (rather than just 32 bit) statistics with KNI. Signed-off-by: Stephen Hemminger --- kernel/linux/kni/kni_dev.h | 1 - kernel/linux/kni/kni_net.c | 43 +++++++++++++------------------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h index d57bce647e4a..21e4b0d92368 100644 --- a/kernel/linux/kni/kni_dev.h +++ b/kernel/linux/kni/kni_dev.h @@ -39,7 +39,6 @@ struct kni_dev { /* kni list */ struct list_head list; - struct net_device_stats stats; int status; uint16_t group_id; /* Group ID of a group of KNI devices */ uint32_t core_id; /* Core ID to bind */ diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c index cce5e7eb991f..06310fec57bb 100644 --- a/kernel/linux/kni/kni_net.c +++ b/kernel/linux/kni/kni_net.c @@ -291,15 +291,15 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev) /* Free skb and update statistics */ dev_kfree_skb(skb); - kni->stats.tx_bytes += len; - kni->stats.tx_packets++; + dev->stats.tx_bytes += len; + dev->stats.tx_packets++; return NETDEV_TX_OK; drop: /* Free skb and update statistics */ dev_kfree_skb(skb); - kni->stats.tx_dropped++; + dev->stats.tx_dropped++; return NETDEV_TX_OK; } @@ -343,7 +343,7 @@ kni_net_rx_normal(struct kni_dev *kni) skb = netdev_alloc_skb(dev, len); if (!skb) { /* Update statistics */ - kni->stats.rx_dropped++; + dev->stats.rx_dropped++; continue; } @@ -372,8 +372,8 @@ kni_net_rx_normal(struct kni_dev *kni) netif_rx_ni(skb); /* Update statistics */ - kni->stats.rx_bytes += len; - kni->stats.rx_packets++; + dev->stats.rx_bytes += len; + dev->stats.rx_packets++; } /* Burst enqueue mbufs into free_q */ @@ -396,6 +396,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni) void *data_kva; struct rte_kni_mbuf *alloc_kva; void *alloc_data_kva; + struct net_device *dev = kni->net_dev; /* Get the number of entries in rx_q */ num_rq = kni_fifo_count(kni->rx_q); @@ -443,8 +444,8 @@ kni_net_rx_lo_fifo(struct kni_dev *kni) alloc_kva->pkt_len = len; alloc_kva->data_len = len; - kni->stats.tx_bytes += len; - kni->stats.rx_bytes += len; + dev->stats.tx_bytes += len; + dev->stats.rx_bytes += len; } /* Burst enqueue mbufs into tx_q */ @@ -464,8 +465,8 @@ kni_net_rx_lo_fifo(struct kni_dev *kni) * Update statistic, and enqueue/dequeue failure is impossible, * as all queues are checked at first. */ - kni->stats.tx_packets += num; - kni->stats.rx_packets += num; + dev->stats.tx_packets += num; + dev->stats.rx_packets += num; } /* @@ -518,7 +519,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) /* Simulate real usage, allocate/copy skb twice */ skb = netdev_alloc_skb(dev, len); if (skb == NULL) { - kni->stats.rx_dropped++; + dev->stats.rx_dropped++; continue; } @@ -542,8 +543,8 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) skb->ip_summed = CHECKSUM_UNNECESSARY; - kni->stats.rx_bytes += len; - kni->stats.rx_packets++; + dev->stats.rx_bytes += len; + dev->stats.rx_packets++; /* call tx interface */ kni_net_tx(skb, dev); @@ -573,12 +574,10 @@ kni_net_rx(struct kni_dev *kni) static void kni_net_tx_timeout(struct net_device *dev) { - struct kni_dev *kni = netdev_priv(dev); - pr_debug("Transmit timeout at %ld, latency %ld\n", jiffies, jiffies - dev_trans_start(dev)); - kni->stats.tx_errors++; + dev->stats.tx_errors++; netif_wake_queue(dev); } @@ -627,17 +626,6 @@ kni_net_poll_resp(struct kni_dev *kni) wake_up_interruptible(&kni->wq); } -/* - * Return statistics to the caller - */ -static struct net_device_stats * -kni_net_stats(struct net_device *dev) -{ - struct kni_dev *kni = netdev_priv(dev); - - return &kni->stats; -} - /* * Fill the eth header */ @@ -730,7 +718,6 @@ static const struct net_device_ops kni_net_netdev_ops = { .ndo_change_rx_flags = kni_net_set_promiscusity, .ndo_start_xmit = kni_net_tx, .ndo_change_mtu = kni_net_change_mtu, - .ndo_get_stats = kni_net_stats, .ndo_tx_timeout = kni_net_tx_timeout, .ndo_set_mac_address = kni_net_set_mac, #ifdef HAVE_CHANGE_CARRIER_CB -- 2.20.1