All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petko Manolov <petkan@mip-labs.com>
To: Tobias Klauser <tklauser@distanz.ch>
Cc: netdev@vger.kernel.org, Petko Manolov <petkan@nucleusys.com>,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next 14/14] usbnet: pegasus: Use net_device_stats from struct net_device
Date: Tue, 11 Apr 2017 11:30:32 +0300	[thread overview]
Message-ID: <20170411083032.7pzkh242avstuays@p310> (raw)
In-Reply-To: <20170407081739.5243-15-tklauser@distanz.ch>

On 17-04-07 10:17:39, Tobias Klauser wrote:
> Instead of using a private copy of struct net_device_stats in struct pegasus, 
> use stats from struct net_device. Also remove the now unnecessary 
> .ndo_get_stats function.

Looks OK to me.


		Petko


> Cc: Petko Manolov <petkan@nucleusys.com>
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> ---
>  drivers/net/usb/pegasus.c | 36 +++++++++++++++---------------------
>  drivers/net/usb/pegasus.h |  1 -
>  2 files changed, 15 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
> index 321e059e13ae..6514c86f043e 100644
> --- a/drivers/net/usb/pegasus.c
> +++ b/drivers/net/usb/pegasus.c
> @@ -501,13 +501,13 @@ static void read_bulk_callback(struct urb *urb)
>  	if (rx_status & 0x1e) {
>  		netif_dbg(pegasus, rx_err, net,
>  			  "RX packet error %x\n", rx_status);
> -		pegasus->stats.rx_errors++;
> +		net->stats.rx_errors++;
>  		if (rx_status & 0x06)	/* long or runt	*/
> -			pegasus->stats.rx_length_errors++;
> +			net->stats.rx_length_errors++;
>  		if (rx_status & 0x08)
> -			pegasus->stats.rx_crc_errors++;
> +			net->stats.rx_crc_errors++;
>  		if (rx_status & 0x10)	/* extra bits	*/
> -			pegasus->stats.rx_frame_errors++;
> +			net->stats.rx_frame_errors++;
>  		goto goon;
>  	}
>  	if (pegasus->chip == 0x8513) {
> @@ -535,8 +535,8 @@ static void read_bulk_callback(struct urb *urb)
>  	skb_put(pegasus->rx_skb, pkt_len);
>  	pegasus->rx_skb->protocol = eth_type_trans(pegasus->rx_skb, net);
>  	netif_rx(pegasus->rx_skb);
> -	pegasus->stats.rx_packets++;
> -	pegasus->stats.rx_bytes += pkt_len;
> +	net->stats.rx_packets++;
> +	net->stats.rx_bytes += pkt_len;
>  
>  	if (pegasus->flags & PEGASUS_UNPLUG)
>  		return;
> @@ -670,13 +670,13 @@ static void intr_callback(struct urb *urb)
>  		/* byte 0 == tx_status1, reg 2B */
>  		if (d[0] & (TX_UNDERRUN|EXCESSIVE_COL
>  					|LATE_COL|JABBER_TIMEOUT)) {
> -			pegasus->stats.tx_errors++;
> +			net->stats.tx_errors++;
>  			if (d[0] & TX_UNDERRUN)
> -				pegasus->stats.tx_fifo_errors++;
> +				net->stats.tx_fifo_errors++;
>  			if (d[0] & (EXCESSIVE_COL | JABBER_TIMEOUT))
> -				pegasus->stats.tx_aborted_errors++;
> +				net->stats.tx_aborted_errors++;
>  			if (d[0] & LATE_COL)
> -				pegasus->stats.tx_window_errors++;
> +				net->stats.tx_window_errors++;
>  		}
>  
>  		/* d[5].LINK_STATUS lies on some adapters.
> @@ -685,7 +685,7 @@ static void intr_callback(struct urb *urb)
>  		 */
>  
>  		/* bytes 3-4 == rx_lostpkt, reg 2E/2F */
> -		pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
> +		net->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
>  	}
>  
>  	res = usb_submit_urb(urb, GFP_ATOMIC);
> @@ -701,7 +701,7 @@ static void pegasus_tx_timeout(struct net_device *net)
>  	pegasus_t *pegasus = netdev_priv(net);
>  	netif_warn(pegasus, timer, net, "tx timeout\n");
>  	usb_unlink_urb(pegasus->tx_urb);
> -	pegasus->stats.tx_errors++;
> +	net->stats.tx_errors++;
>  }
>  
>  static netdev_tx_t pegasus_start_xmit(struct sk_buff *skb,
> @@ -731,23 +731,18 @@ static netdev_tx_t pegasus_start_xmit(struct sk_buff *skb,
>  			netif_device_detach(pegasus->net);
>  			break;
>  		default:
> -			pegasus->stats.tx_errors++;
> +			net->stats.tx_errors++;
>  			netif_start_queue(net);
>  		}
>  	} else {
> -		pegasus->stats.tx_packets++;
> -		pegasus->stats.tx_bytes += skb->len;
> +		net->stats.tx_packets++;
> +		net->stats.tx_bytes += skb->len;
>  	}
>  	dev_kfree_skb(skb);
>  
>  	return NETDEV_TX_OK;
>  }
>  
> -static struct net_device_stats *pegasus_netdev_stats(struct net_device *dev)
> -{
> -	return &((pegasus_t *) netdev_priv(dev))->stats;
> -}
> -
>  static inline void disable_net_traffic(pegasus_t *pegasus)
>  {
>  	__le16 tmp = cpu_to_le16(0);
> @@ -1294,7 +1289,6 @@ static const struct net_device_ops pegasus_netdev_ops = {
>  	.ndo_do_ioctl =			pegasus_ioctl,
>  	.ndo_start_xmit =		pegasus_start_xmit,
>  	.ndo_set_rx_mode =		pegasus_set_multicast,
> -	.ndo_get_stats =		pegasus_netdev_stats,
>  	.ndo_tx_timeout =		pegasus_tx_timeout,
>  	.ndo_set_mac_address =		eth_mac_addr,
>  	.ndo_validate_addr =		eth_validate_addr,
> diff --git a/drivers/net/usb/pegasus.h b/drivers/net/usb/pegasus.h
> index d15646244fdf..9b7ea9c9167d 100644
> --- a/drivers/net/usb/pegasus.h
> +++ b/drivers/net/usb/pegasus.h
> @@ -83,7 +83,6 @@ typedef struct pegasus {
>  	struct usb_device	*usb;
>  	struct usb_interface	*intf;
>  	struct net_device	*net;
> -	struct net_device_stats	stats;
>  	struct mii_if_info	mii;
>  	unsigned		flags;
>  	unsigned		features;
> -- 
> 2.12.2
> 
> 
> 

  reply	other threads:[~2017-04-11  8:46 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07  8:17 [PATCH net-next 00/14] Use net_device_stats from struct net_device Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 01/14] net: cxgb: " Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 02/14] net: cxgb3: " Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 03/14] net: dl2k: " Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 04/14] net: emac: " Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 05/14] net: macb: " Tobias Klauser
2017-04-07  8:29   ` Nicolas Ferre
2017-04-07  8:57     ` Tobias Klauser
2017-04-07 14:08       ` David Miller
2017-04-07  8:17 ` [PATCH net-next 06/14] net: moxa: " Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 07/14] net: nmlan_cs: " Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 08/14] net: nuvoton: " Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 09/14] net: sunbmac: " Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 10/14] net: sunhme: " Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 11/14] net: tulip: de2104x: " Tobias Klauser
2017-04-07  8:17 ` [PATCH net-next 12/14] net: typhoon: " Tobias Klauser
     [not found] ` <20170407081739.5243-1-tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org>
2017-04-07  8:17   ` [PATCH net-next 13/14] usbnet: kaweth: " Tobias Klauser
     [not found]     ` <20170407081739.5243-14-tklauser-93Khv+1bN0NyDzI6CaY1VQ@public.gmane.org>
2017-04-11  9:15       ` Oliver Neukum
2017-04-07  8:17 ` [PATCH net-next 14/14] usbnet: pegasus: " Tobias Klauser
2017-04-11  8:30   ` Petko Manolov [this message]
2017-04-07 14:06 ` [PATCH net-next 00/14] " David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170411083032.7pzkh242avstuays@p310 \
    --to=petkan@mip-labs.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=petkan@nucleusys.com \
    --cc=tklauser@distanz.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.