Revisión | c85d70ef64ebe5c92811113108517eaacff47f7e (tree) |
---|---|
Tiempo | 2011-02-20 04:32:37 |
Autor | Vitaly Kuzmichev <vkuzmichev@mvis...> |
Commiter | Remy Bohmer |
USB-CDC: Port struct net_device_stats
Port struct net_device_stats and statistics collecting needed for
RNDIS protocol.
Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
@@ -22,6 +22,7 @@ | ||
22 | 22 | |
23 | 23 | #include <common.h> |
24 | 24 | #include <asm/errno.h> |
25 | +#include <linux/netdevice.h> | |
25 | 26 | #include <linux/usb/ch9.h> |
26 | 27 | #include <linux/usb/cdc.h> |
27 | 28 | #include <linux/usb/gadget.h> |
@@ -175,6 +176,7 @@ struct eth_dev { | ||
175 | 176 | struct usb_request *tx_req, *rx_req; |
176 | 177 | |
177 | 178 | struct eth_device *net; |
179 | + struct net_device_stats stats; | |
178 | 180 | unsigned int tx_qlen; |
179 | 181 | |
180 | 182 | unsigned zlp:1; |
@@ -1274,6 +1276,28 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req) | ||
1274 | 1276 | struct eth_dev *dev = ep->driver_data; |
1275 | 1277 | |
1276 | 1278 | debug("%s: status %d\n", __func__, req->status); |
1279 | + switch (req->status) { | |
1280 | + /* normal completion */ | |
1281 | + case 0: | |
1282 | + dev->stats.rx_packets++; | |
1283 | + dev->stats.rx_bytes += req->length; | |
1284 | + break; | |
1285 | + | |
1286 | + /* software-driven interface shutdown */ | |
1287 | + case -ECONNRESET: /* unlink */ | |
1288 | + case -ESHUTDOWN: /* disconnect etc */ | |
1289 | + /* for hardware automagic (such as pxa) */ | |
1290 | + case -ECONNABORTED: /* endpoint reset */ | |
1291 | + break; | |
1292 | + | |
1293 | + /* data overrun */ | |
1294 | + case -EOVERFLOW: | |
1295 | + dev->stats.rx_over_errors++; | |
1296 | + /* FALLTHROUGH */ | |
1297 | + default: | |
1298 | + dev->stats.rx_errors++; | |
1299 | + break; | |
1300 | + } | |
1277 | 1301 | |
1278 | 1302 | packet_received = 1; |
1279 | 1303 | } |
@@ -1302,7 +1326,22 @@ fail1: | ||
1302 | 1326 | |
1303 | 1327 | static void tx_complete(struct usb_ep *ep, struct usb_request *req) |
1304 | 1328 | { |
1329 | + struct eth_dev *dev = ep->driver_data; | |
1330 | + | |
1305 | 1331 | debug("%s: status %s\n", __func__, (req->status) ? "failed" : "ok"); |
1332 | + switch (req->status) { | |
1333 | + default: | |
1334 | + dev->stats.tx_errors++; | |
1335 | + debug("tx err %d\n", req->status); | |
1336 | + /* FALLTHROUGH */ | |
1337 | + case -ECONNRESET: /* unlink */ | |
1338 | + case -ESHUTDOWN: /* disconnect etc */ | |
1339 | + break; | |
1340 | + case 0: | |
1341 | + dev->stats.tx_bytes += req->length; | |
1342 | + } | |
1343 | + dev->stats.tx_packets++; | |
1344 | + | |
1306 | 1345 | packet_sent = 1; |
1307 | 1346 | } |
1308 | 1347 |
@@ -0,0 +1,65 @@ | ||
1 | +/* | |
2 | + * INET An implementation of the TCP/IP protocol suite for the LINUX | |
3 | + * operating system. INET is implemented using the BSD Socket | |
4 | + * interface as the means of communication with the user level. | |
5 | + * | |
6 | + * Definitions for the Interfaces handler. | |
7 | + * | |
8 | + * Version: @(#)dev.h 1.0.10 08/12/93 | |
9 | + * | |
10 | + * Authors: Ross Biro | |
11 | + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> | |
12 | + * Corey Minyard <wf-rch!minyard@relay.EU.net> | |
13 | + * Donald J. Becker, <becker@cesdis.gsfc.nasa.gov> | |
14 | + * Alan Cox, <Alan.Cox@linux.org> | |
15 | + * Bjorn Ekwall. <bj0rn@blox.se> | |
16 | + * Pekka Riikonen <priikone@poseidon.pspt.fi> | |
17 | + * | |
18 | + * This program is free software; you can redistribute it and/or | |
19 | + * modify it under the terms of the GNU General Public License | |
20 | + * as published by the Free Software Foundation; either version | |
21 | + * 2 of the License, or (at your option) any later version. | |
22 | + * | |
23 | + * Moved to /usr/include/linux for NET3 | |
24 | + */ | |
25 | +#ifndef _LINUX_NETDEVICE_H | |
26 | +#define _LINUX_NETDEVICE_H | |
27 | + | |
28 | +/* | |
29 | + * Network device statistics. Akin to the 2.0 ether stats but | |
30 | + * with byte counters. | |
31 | + */ | |
32 | + | |
33 | +struct net_device_stats { | |
34 | + unsigned long rx_packets; /* total packets received */ | |
35 | + unsigned long tx_packets; /* total packets transmitted */ | |
36 | + unsigned long rx_bytes; /* total bytes received */ | |
37 | + unsigned long tx_bytes; /* total bytes transmitted */ | |
38 | + unsigned long rx_errors; /* bad packets received */ | |
39 | + unsigned long tx_errors; /* packet transmit problems */ | |
40 | + unsigned long rx_dropped; /* no space in linux buffers */ | |
41 | + unsigned long tx_dropped; /* no space available in linux */ | |
42 | + unsigned long multicast; /* multicast packets received */ | |
43 | + unsigned long collisions; | |
44 | + | |
45 | + /* detailed rx_errors: */ | |
46 | + unsigned long rx_length_errors; | |
47 | + unsigned long rx_over_errors; /* receiver ring buff overflow */ | |
48 | + unsigned long rx_crc_errors; /* recved pkt with crc error */ | |
49 | + unsigned long rx_frame_errors; /* recv'd frame alignment error */ | |
50 | + unsigned long rx_fifo_errors; /* recv'r fifo overrun */ | |
51 | + unsigned long rx_missed_errors; /* receiver missed packet */ | |
52 | + | |
53 | + /* detailed tx_errors */ | |
54 | + unsigned long tx_aborted_errors; | |
55 | + unsigned long tx_carrier_errors; | |
56 | + unsigned long tx_fifo_errors; | |
57 | + unsigned long tx_heartbeat_errors; | |
58 | + unsigned long tx_window_errors; | |
59 | + | |
60 | + /* for cslip etc */ | |
61 | + unsigned long rx_compressed; | |
62 | + unsigned long tx_compressed; | |
63 | +}; | |
64 | + | |
65 | +#endif /* _LINUX_NETDEVICE_H */ |