Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1486231 > unrolled thread

[PATCH v2 0/3] Usb gadget ncm code cleanup

Started byHarish Jenny K N <harish_kandiga@mentor.com>
First post2016-09-19 10:10 +0200
Last post2016-09-19 10:10 +0200
Articles 3 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 0/3] Usb gadget ncm code cleanup Harish Jenny K N <harish_kandiga@mentor.com> - 2016-09-19 10:10 +0200
    [PATCH v2 3/3] usb: gadget: NCM: differentiate consumed packets from dropped packets Harish Jenny K N <harish_kandiga@mentor.com> - 2016-09-19 10:10 +0200
    [PATCH v2 2/3] usb: gadget: u_ether: link socket buffers to the device for received packets Harish Jenny K N <harish_kandiga@mentor.com> - 2016-09-19 10:10 +0200

#1486231 — [PATCH v2 0/3] Usb gadget ncm code cleanup

FromHarish Jenny K N <harish_kandiga@mentor.com>
Date2016-09-19 10:10 +0200
Subject[PATCH v2 0/3] Usb gadget ncm code cleanup
Message-ID<sj1Oi-2Ug-9@gated-at.bofh.it>
This patchset consists of some code cleanup in usb gadget ncm code.

Note: Testing has only been done on an ARM i.MX6 based platform.

---
Change from v1 to v2
Subject line changed on Patch 2.

Torsten Polle (3):
  usb: gadget: NCM: link socket buffers to the device for tx packets
  usb: gadget: u_ether: link socket buffers to the device for received
    packets
  usb: gadget: NCM: differentiate consumed packets from dropped packets

 drivers/usb/gadget/function/f_ncm.c   |   11 +++++++----
 drivers/usb/gadget/function/u_ether.c |    5 +++--
 2 files changed, 10 insertions(+), 6 deletions(-)

-- 
1.7.9.5

[toc] | [next] | [standalone]


#1486232 — [PATCH v2 3/3] usb: gadget: NCM: differentiate consumed packets from dropped packets

FromHarish Jenny K N <harish_kandiga@mentor.com>
Date2016-09-19 10:10 +0200
Subject[PATCH v2 3/3] usb: gadget: NCM: differentiate consumed packets from dropped packets
Message-ID<sj1Oi-2Ug-21@gated-at.bofh.it>
In reply to#1486231
From: Torsten Polle <tpolle@de.adit-jv.com>

dev_kfree_skb_any() is used to free packets that are dropped by the
network stack. Therefore the function should not be used for packets
that have been successfully processed by the network stack. Instead
dev_consume_skb_any() has to be used for such consumed packets.

This separation helps to identify dropped packets.

Signed-off-by: Torsten Polle <tpolle@de.adit-jv.com>
Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com>
---
 drivers/usb/gadget/function/f_ncm.c   |    8 ++++----
 drivers/usb/gadget/function/u_ether.c |    3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index b6771ad..e8008fa 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -998,7 +998,7 @@ static struct sk_buff *package_for_tx(struct f_ncm *ncm)
 	/* Merge the skbs */
 	swap(skb2, ncm->skb_tx_data);
 	if (ncm->skb_tx_data) {
-		dev_kfree_skb_any(ncm->skb_tx_data);
+		dev_consume_skb_any(ncm->skb_tx_data);
 		ncm->skb_tx_data = NULL;
 	}
 
@@ -1009,7 +1009,7 @@ static struct sk_buff *package_for_tx(struct f_ncm *ncm)
 	/* Copy NTB across. */
 	ntb_iter = (void *) skb_put(skb2, ncm->skb_tx_ndp->len);
 	memcpy(ntb_iter, ncm->skb_tx_ndp->data, ncm->skb_tx_ndp->len);
-	dev_kfree_skb_any(ncm->skb_tx_ndp);
+	dev_consume_skb_any(ncm->skb_tx_ndp);
 	ncm->skb_tx_ndp = NULL;
 
 	/* Insert zero'd datagram. */
@@ -1136,7 +1136,7 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
 		memset(ntb_data, 0, dgram_pad);
 		ntb_data = (void *) skb_put(ncm->skb_tx_data, skb->len);
 		memcpy(ntb_data, skb->data, skb->len);
-		dev_kfree_skb_any(skb);
+		dev_consume_skb_any(skb);
 		skb = NULL;
 
 	} else if (ncm->skb_tx_data && ncm->timer_force_tx) {
@@ -1332,7 +1332,7 @@ static int ncm_unwrap_ntb(struct gether *port,
 		} while (ndp_len > 2 * (opts->dgram_item_len * 2));
 	} while (ndp_index);
 
-	dev_kfree_skb_any(skb);
+	dev_consume_skb_any(skb);
 
 	VDBG(port->func.config->cdev,
 	     "Parsed NTB with %d frames\n", dgram_counter);
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index d8593c7..8a6be06 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -455,16 +455,17 @@ static void tx_complete(struct usb_ep *ep, struct usb_request *req)
 		/* FALLTHROUGH */
 	case -ECONNRESET:		/* unlink */
 	case -ESHUTDOWN:		/* disconnect etc */
+		dev_kfree_skb_any(skb);
 		break;
 	case 0:
 		dev->net->stats.tx_bytes += skb->len;
+		dev_consume_skb_any(skb);
 	}
 	dev->net->stats.tx_packets++;
 
 	spin_lock(&dev->req_lock);
 	list_add(&req->list, &dev->tx_reqs);
 	spin_unlock(&dev->req_lock);
-	dev_kfree_skb_any(skb);
 
 	atomic_dec(&dev->tx_qlen);
 	if (netif_carrier_ok(dev->net))
-- 
1.7.9.5

[toc] | [prev] | [next] | [standalone]


#1486235 — [PATCH v2 2/3] usb: gadget: u_ether: link socket buffers to the device for received packets

FromHarish Jenny K N <harish_kandiga@mentor.com>
Date2016-09-19 10:10 +0200
Subject[PATCH v2 2/3] usb: gadget: u_ether: link socket buffers to the device for received packets
Message-ID<sj1Oi-2Ug-23@gated-at.bofh.it>
In reply to#1486231
From: Torsten Polle <tpolle@de.adit-jv.com>

Socket buffers should be linked to the (network) device that allocated
the buffers. __netdev_alloc_skb performs this task.

Signed-off-by: Torsten Polle <tpolle@de.adit-jv.com>
Signed-off-by: Jim Baxter <jim_baxter@mentor.com>
Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com>
---
Change from v1 to v2
Subject line changed

 drivers/usb/gadget/function/u_ether.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 8cb0803..d8593c7 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -224,7 +224,7 @@ static void defer_kevent(struct eth_dev *dev, int flag)
 	if (dev->port_usb->is_fixed)
 		size = max_t(size_t, size, dev->port_usb->fixed_out_len);
 
-	skb = alloc_skb(size + NET_IP_ALIGN, gfp_flags);
+	skb = __netdev_alloc_skb(dev->net, size + NET_IP_ALIGN, gfp_flags);
 	if (skb == NULL) {
 		DBG(dev, "no rx skb\n");
 		goto enomem;
-- 
1.7.9.5

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web