aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb/cdc_mbim.c
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2014-05-16 15:48:25 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-16 22:39:01 -0400
commitbeeecd42c3b41d17d0bf1d839db99274c287f514 (patch)
tree65bbae15a9ec1d3368a059f3bd4fad7d7c0a018b /drivers/net/usb/cdc_mbim.c
parent43e4c6dfc0fd781e68f20caf563a06f5c6ece995 (diff)
net: cdc_ncm/cdc_mbim: adding NCM protocol statistics
To have an idea of the effects of the protocol coalescing it's useful to have some counters showing the different aspects. Due to the asymmetrical usbnet interface the netdev rx_bytes counter has been counting real received payload, while the tx_bytes counter has included the NCM/MBIM framing overhead. This overhead can be many times the payload because of the aggressive padding strategy of this driver, and will vary a lot depending on device and traffic. With very few exceptions, users are only interested in the payload size. Having an somewhat accurate payload byte counter is particularly important for mobile broadband devices, which many NCM devices and of course all MBIM devices are. Users and userspace applications will use this counter to monitor account quotas. Having protocol specific counters for the overhead, we are now able to correct the tx_bytes netdev counter so that it shows the real payload Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb/cdc_mbim.c')
-rw-r--r--drivers/net/usb/cdc_mbim.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index bc23273d0455..5ee7a1dbc023 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -420,6 +420,7 @@ static int cdc_mbim_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
420 struct usb_cdc_ncm_dpe16 *dpe16; 420 struct usb_cdc_ncm_dpe16 *dpe16;
421 int ndpoffset; 421 int ndpoffset;
422 int loopcount = 50; /* arbitrary max preventing infinite loop */ 422 int loopcount = 50; /* arbitrary max preventing infinite loop */
423 u32 payload = 0;
423 u8 *c; 424 u8 *c;
424 u16 tci; 425 u16 tci;
425 426
@@ -482,6 +483,7 @@ next_ndp:
482 if (!skb) 483 if (!skb)
483 goto error; 484 goto error;
484 usbnet_skb_return(dev, skb); 485 usbnet_skb_return(dev, skb);
486 payload += len; /* count payload bytes in this NTB */
485 } 487 }
486 } 488 }
487err_ndp: 489err_ndp:
@@ -490,6 +492,10 @@ err_ndp:
490 if (ndpoffset && loopcount--) 492 if (ndpoffset && loopcount--)
491 goto next_ndp; 493 goto next_ndp;
492 494
495 /* update stats */
496 ctx->rx_overhead += skb_in->len - payload;
497 ctx->rx_ntbs++;
498
493 return 1; 499 return 1;
494error: 500error:
495 return 0; 501 return 0;