From patchwork Mon Jul 5 12:13:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kulikov Vasiliy X-Patchwork-Id: 57892 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2BC99B6F19 for ; Mon, 5 Jul 2010 22:16:31 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758510Ab0GEMOH (ORCPT ); Mon, 5 Jul 2010 08:14:07 -0400 Received: from mail-ew0-f46.google.com ([209.85.215.46]:47228 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758538Ab0GEMOE (ORCPT ); Mon, 5 Jul 2010 08:14:04 -0400 Received: by mail-ew0-f46.google.com with SMTP id 23so1604333ewy.19 for ; Mon, 05 Jul 2010 05:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=c8KYK2O1dCzUyu2m3ZV0K4nGD57oD5/QwVFnjm01cv8=; b=ZKrRDwH+AHY0+GBl0c4AcpyUg3aWD5BrESinv0evF/DFwxAnWu1qHkastBeoT2D5W0 bOGTIl/kNsm2Qd4c0ZnLMTkbbtiqCXBir7E7ZtR50uqH8FUGfgE9m/MWf4YHhCw9VGXv IEJXEliIML77PQctCxLd1ig4+hpAoxGyQTpXY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=BHTfr+geO1Xm0fAaYCkepcKDZVgY7kRNgHA9Z7phVy8uMvUYNEQL1Nj3WE7hiqChlh guYxW6i6pOPAK8VKlyqDY6ntw0x0BMeiNrG2QFH4lF9wj7G5n/1finq3TK+0912MsAJO gf2o2KFa6YsPemjSOEMvqfqkvz6M7pHAdKt2E= Received: by 10.213.34.3 with SMTP id j3mr2291692ebd.65.1278332042674; Mon, 05 Jul 2010 05:14:02 -0700 (PDT) Received: from localhost (ppp85-140-163-91.pppoe.mtu-net.ru [85.140.163.91]) by mx.google.com with ESMTPS id a48sm34805290eei.6.2010.07.05.05.14.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 05 Jul 2010 05:14:02 -0700 (PDT) From: Kulikov Vasiliy To: Kernel Janitors Cc: "David S. Miller" , Eric Dumazet , Jiri Pirko , Denis Kirjanov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ksz884x: Use the instance of net_device_stats from net_device. Date: Mon, 5 Jul 2010 16:13:58 +0400 Message-Id: <1278332040-17160-1-git-send-email-segooon@gmail.com> X-Mailer: git-send-email 1.7.0.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since net_device has an instance of net_device_stats, we can remove the instance of this from the adapter structure. Signed-off-by: Kulikov Vasiliy --- drivers/net/ksz884x.c | 46 ++++++++++++++++++++++------------------------ 1 files changed, 22 insertions(+), 24 deletions(-) diff --git a/drivers/net/ksz884x.c b/drivers/net/ksz884x.c index f715348..1d998e1 100644 --- a/drivers/net/ksz884x.c +++ b/drivers/net/ksz884x.c @@ -1457,7 +1457,6 @@ struct dev_info { * @adapter: Adapter device information. * @port: Port information. * @monitor_time_info: Timer to monitor ports. - * @stats: Network statistics. * @proc_sem: Semaphore for proc accessing. * @id: Device ID. * @mii_if: MII interface information. @@ -1471,7 +1470,6 @@ struct dev_priv { struct dev_info *adapter; struct ksz_port port; struct ksz_timer_info monitor_timer_info; - struct net_device_stats stats; struct semaphore proc_sem; int id; @@ -4751,8 +4749,8 @@ static void send_packet(struct sk_buff *skb, struct net_device *dev) hw_send_pkt(hw); /* Update transmit statistics. */ - priv->stats.tx_packets++; - priv->stats.tx_bytes += len; + dev->stats.tx_packets++; + dev->stats.tx_bytes += len; } /** @@ -5030,7 +5028,7 @@ static inline int rx_proc(struct net_device *dev, struct ksz_hw* hw, /* skb->data != skb->head */ skb = dev_alloc_skb(packet_len + 2); if (!skb) { - priv->stats.rx_dropped++; + dev->stats.rx_dropped++; return -ENOMEM; } @@ -5050,8 +5048,8 @@ static inline int rx_proc(struct net_device *dev, struct ksz_hw* hw, csum_verified(skb); /* Update receive statistics. */ - priv->stats.rx_packets++; - priv->stats.rx_bytes += packet_len; + dev->stats.rx_packets++; + dev->stats.rx_bytes += packet_len; /* Notify upper layer for received packet. */ rx_status = netif_rx(skb); @@ -5291,7 +5289,7 @@ static irqreturn_t netdev_intr(int irq, void *dev_id) } if (unlikely(int_enable & KS884X_INT_RX_OVERRUN)) { - priv->stats.rx_fifo_errors++; + dev->stats.rx_fifo_errors++; hw_resume_rx(hw); } @@ -5522,7 +5520,7 @@ static int netdev_open(struct net_device *dev) priv->promiscuous = 0; /* Reset device statistics. */ - memset(&priv->stats, 0, sizeof(struct net_device_stats)); + memset(&dev->stats, 0, sizeof(struct net_device_stats)); memset((void *) port->counter, 0, (sizeof(u64) * OID_COUNTER_LAST)); @@ -5622,42 +5620,42 @@ static struct net_device_stats *netdev_query_statistics(struct net_device *dev) int i; int p; - priv->stats.rx_errors = port->counter[OID_COUNTER_RCV_ERROR]; - priv->stats.tx_errors = port->counter[OID_COUNTER_XMIT_ERROR]; + dev->stats.rx_errors = port->counter[OID_COUNTER_RCV_ERROR]; + dev->stats.tx_errors = port->counter[OID_COUNTER_XMIT_ERROR]; /* Reset to zero to add count later. */ - priv->stats.multicast = 0; - priv->stats.collisions = 0; - priv->stats.rx_length_errors = 0; - priv->stats.rx_crc_errors = 0; - priv->stats.rx_frame_errors = 0; - priv->stats.tx_window_errors = 0; + dev->stats.multicast = 0; + dev->stats.collisions = 0; + dev->stats.rx_length_errors = 0; + dev->stats.rx_crc_errors = 0; + dev->stats.rx_frame_errors = 0; + dev->stats.tx_window_errors = 0; for (i = 0, p = port->first_port; i < port->mib_port_cnt; i++, p++) { mib = &hw->port_mib[p]; - priv->stats.multicast += (unsigned long) + dev->stats.multicast += (unsigned long) mib->counter[MIB_COUNTER_RX_MULTICAST]; - priv->stats.collisions += (unsigned long) + dev->stats.collisions += (unsigned long) mib->counter[MIB_COUNTER_TX_TOTAL_COLLISION]; - priv->stats.rx_length_errors += (unsigned long)( + dev->stats.rx_length_errors += (unsigned long)( mib->counter[MIB_COUNTER_RX_UNDERSIZE] + mib->counter[MIB_COUNTER_RX_FRAGMENT] + mib->counter[MIB_COUNTER_RX_OVERSIZE] + mib->counter[MIB_COUNTER_RX_JABBER]); - priv->stats.rx_crc_errors += (unsigned long) + dev->stats.rx_crc_errors += (unsigned long) mib->counter[MIB_COUNTER_RX_CRC_ERR]; - priv->stats.rx_frame_errors += (unsigned long)( + dev->stats.rx_frame_errors += (unsigned long)( mib->counter[MIB_COUNTER_RX_ALIGNMENT_ERR] + mib->counter[MIB_COUNTER_RX_SYMBOL_ERR]); - priv->stats.tx_window_errors += (unsigned long) + dev->stats.tx_window_errors += (unsigned long) mib->counter[MIB_COUNTER_TX_LATE_COLLISION]; } - return &priv->stats; + return &dev->stats; } /**