Loading drivers/usb/gadget/function/u_ether.c +31 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,9 @@ MODULE_PARM_DESC(min_cpu_freq, */ #define DL_MAX_PKTS_PER_XFER 20 /* Extra buffer size to allocate for tx */ #define EXTRA_ALLOCATION_SIZE_U_ETH 128 enum ifc_state { ETH_UNDEFINED, ETH_STOP, Loading Loading @@ -135,6 +138,7 @@ struct eth_dev { unsigned int tx_pkts_rcvd; unsigned int tx_bytes_rcvd; unsigned int loop_brk_cnt; unsigned long skb_expand_cnt; struct dentry *uether_dent; enum ifc_state state; Loading Loading @@ -1031,8 +1035,11 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, { struct eth_dev *dev = netdev_priv(net); int length = 0; int tail_room = 0; int extra_alloc = 0; int retval; struct usb_request *req = NULL; struct sk_buff *new_skb; unsigned long flags; struct usb_ep *in = NULL; u16 cdc_filter = 0; Loading Loading @@ -1179,7 +1186,28 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, dev->tx_skb_hold_count = 0; spin_unlock_irqrestore(&dev->req_lock, flags); } else { /* * Some UDC requires allocation of some extra bytes for * TX buffer due to hardware requirement. Check if extra * bytes are already there, otherwise allocate new buffer * with extra bytes and do memcpy. */ length = skb->len; if (dev->gadget->extra_buf_alloc) extra_alloc = EXTRA_ALLOCATION_SIZE_U_ETH; tail_room = skb_tailroom(skb); if (tail_room < extra_alloc) { pr_debug("%s: tail_room %d less than %d\n", __func__, tail_room, extra_alloc); new_skb = skb_copy_expand(skb, 0, extra_alloc - tail_room, GFP_ATOMIC); if (!new_skb) return -ENOMEM; dev_kfree_skb_any(skb); skb = new_skb; dev->skb_expand_cnt++; } req->buf = skb->data; req->context = skb; } Loading Loading @@ -2188,6 +2216,8 @@ static int uether_stat_show(struct seq_file *s, void *unused) seq_printf(s, "\nloop_brk_cnt = %u\n tx_pkts_rcvd=%u\n", dev->loop_brk_cnt, dev->tx_pkts_rcvd); seq_printf(s, "skb_expand_cnt = %lu\n", dev->skb_expand_cnt); } return ret; Loading @@ -2209,6 +2239,7 @@ static ssize_t uether_stat_reset(struct file *file, /* Reset tx_throttle */ dev->tx_throttle = 0; dev->rx_throttle = 0; dev->skb_expand_cnt = 0; spin_unlock_irqrestore(&dev->lock, flags); return count; } Loading Loading
drivers/usb/gadget/function/u_ether.c +31 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,9 @@ MODULE_PARM_DESC(min_cpu_freq, */ #define DL_MAX_PKTS_PER_XFER 20 /* Extra buffer size to allocate for tx */ #define EXTRA_ALLOCATION_SIZE_U_ETH 128 enum ifc_state { ETH_UNDEFINED, ETH_STOP, Loading Loading @@ -135,6 +138,7 @@ struct eth_dev { unsigned int tx_pkts_rcvd; unsigned int tx_bytes_rcvd; unsigned int loop_brk_cnt; unsigned long skb_expand_cnt; struct dentry *uether_dent; enum ifc_state state; Loading Loading @@ -1031,8 +1035,11 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, { struct eth_dev *dev = netdev_priv(net); int length = 0; int tail_room = 0; int extra_alloc = 0; int retval; struct usb_request *req = NULL; struct sk_buff *new_skb; unsigned long flags; struct usb_ep *in = NULL; u16 cdc_filter = 0; Loading Loading @@ -1179,7 +1186,28 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, dev->tx_skb_hold_count = 0; spin_unlock_irqrestore(&dev->req_lock, flags); } else { /* * Some UDC requires allocation of some extra bytes for * TX buffer due to hardware requirement. Check if extra * bytes are already there, otherwise allocate new buffer * with extra bytes and do memcpy. */ length = skb->len; if (dev->gadget->extra_buf_alloc) extra_alloc = EXTRA_ALLOCATION_SIZE_U_ETH; tail_room = skb_tailroom(skb); if (tail_room < extra_alloc) { pr_debug("%s: tail_room %d less than %d\n", __func__, tail_room, extra_alloc); new_skb = skb_copy_expand(skb, 0, extra_alloc - tail_room, GFP_ATOMIC); if (!new_skb) return -ENOMEM; dev_kfree_skb_any(skb); skb = new_skb; dev->skb_expand_cnt++; } req->buf = skb->data; req->context = skb; } Loading Loading @@ -2188,6 +2216,8 @@ static int uether_stat_show(struct seq_file *s, void *unused) seq_printf(s, "\nloop_brk_cnt = %u\n tx_pkts_rcvd=%u\n", dev->loop_brk_cnt, dev->tx_pkts_rcvd); seq_printf(s, "skb_expand_cnt = %lu\n", dev->skb_expand_cnt); } return ret; Loading @@ -2209,6 +2239,7 @@ static ssize_t uether_stat_reset(struct file *file, /* Reset tx_throttle */ dev->tx_throttle = 0; dev->rx_throttle = 0; dev->skb_expand_cnt = 0; spin_unlock_irqrestore(&dev->lock, flags); return count; } Loading