Netdev List
 help / color / mirror / Atom feed
From: Hayes Wang <hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
To: <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: <nic_swsd-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>,
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	<linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Hayes Wang <hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH net v3 2/4] r8152: modify the tx flow
Date: Fri, 15 Nov 2013 15:57:57 +0800	[thread overview]
Message-ID: <1384502279-9959-3-git-send-email-hayeswang@realtek.com> (raw)
In-Reply-To: <1384502279-9959-1-git-send-email-hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>

Remove the code for sending the packet in the rtl8152_start_xmit().
Let rtl8152_start_xmit() to queue the packet only, and schedule a
tasklet to send the queued packets. This simplify the code and make
sure all the packet would be sent by the original order.

Signed-off-by: Hayes Wang <hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
---
 drivers/net/usb/r8152.c | 46 +++-------------------------------------------
 1 file changed, 3 insertions(+), 43 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 5dbfe50..763234d 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1388,53 +1388,13 @@ static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb,
 					    struct net_device *netdev)
 {
 	struct r8152 *tp = netdev_priv(netdev);
-	struct net_device_stats *stats = rtl8152_get_stats(netdev);
-	unsigned long flags;
-	struct tx_agg *agg = NULL;
-	struct tx_desc *tx_desc;
-	unsigned int len;
-	u8 *tx_data;
-	int res;
 
 	skb_tx_timestamp(skb);
 
-	/* If tx_queue is not empty, it means at least one previous packt */
-	/* is waiting for sending. Don't send current one before it.      */
-	if (skb_queue_empty(&tp->tx_queue))
-		agg = r8152_get_tx_agg(tp);
-
-	if (!agg) {
-		skb_queue_tail(&tp->tx_queue, skb);
-		return NETDEV_TX_OK;
-	}
-
-	tx_desc = (struct tx_desc *)agg->head;
-	tx_data = agg->head + sizeof(*tx_desc);
-	agg->skb_num = agg->skb_len = 0;
+	skb_queue_tail(&tp->tx_queue, skb);
 
-	len = skb->len;
-	r8152_tx_csum(tp, tx_desc, skb);
-	memcpy(tx_data, skb->data, len);
-	dev_kfree_skb_any(skb);
-	agg->skb_num++;
-	agg->skb_len += len;
-	usb_fill_bulk_urb(agg->urb, tp->udev, usb_sndbulkpipe(tp->udev, 2),
-			  agg->head, len + sizeof(*tx_desc),
-			  (usb_complete_t)write_bulk_callback, agg);
-	res = usb_submit_urb(agg->urb, GFP_ATOMIC);
-	if (res) {
-		/* Can we get/handle EPIPE here? */
-		if (res == -ENODEV) {
-			netif_device_detach(tp->netdev);
-		} else {
-			netif_warn(tp, tx_err, netdev,
-				   "failed tx_urb %d\n", res);
-			stats->tx_dropped++;
-			spin_lock_irqsave(&tp->tx_lock, flags);
-			list_add_tail(&agg->list, &tp->tx_free);
-			spin_unlock_irqrestore(&tp->tx_lock, flags);
-		}
-	}
+	if (!list_empty(&tp->tx_free))
+		tasklet_schedule(&tp->tl);
 
 	return NETDEV_TX_OK;
 }
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-11-15  7:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-15  7:57 [PATCH net v3 0/4] r8152 bug fixes Hayes Wang
2013-11-15  7:57 ` [PATCH net v3 1/4] r8152: fix tx/rx memory overflow Hayes Wang
2013-11-15 22:39   ` David Miller
     [not found]     ` <20131115.173948.1712849813995511721.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2013-11-19  2:32       ` hayeswang
     [not found] ` <1384502279-9959-1-git-send-email-hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
2013-11-15  7:57   ` Hayes Wang [this message]
2013-11-15  7:57   ` [PATCH net v3 3/4] r8152: support stopping/waking tx queue Hayes Wang
2013-11-15  7:57 ` [PATCH net v3 4/4] r8152: fix incorrect type in assignment Hayes Wang
2013-11-19  3:25 ` [PATCH net v4 0/4] r8152 bug fixes Hayes Wang
     [not found]   ` <1384831511-1625-1-git-send-email-hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
2013-11-19  3:25     ` [PATCH net v4 1/4] r8152: fix tx/rx memory overflow Hayes Wang
2013-11-19  3:25   ` [PATCH net v4 2/4] r8152: modify the tx flow Hayes Wang
2013-11-19  3:25   ` [PATCH net v4 3/4] r8152: support stopping/waking tx queue Hayes Wang
     [not found]     ` <1384831511-1625-4-git-send-email-hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
2013-11-19 20:25       ` David Miller
     [not found]         ` <20131119.152536.146706009595105149.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2013-11-20  3:28           ` hayeswang
     [not found]             ` <9C2E97E7BED9426ABE0FF4F63E12E33D-Rasf1IRRPZGoECsaD+WFmw@public.gmane.org>
2013-11-20  5:22               ` David Miller
2013-11-20  6:30                 ` hayeswang
2013-11-19  3:25   ` [PATCH net v4 4/4] r8152: fix incorrect type in assignment Hayes Wang
2013-11-20  9:30 ` [PATCH net v5 0/4] r8152 bug fixes Hayes Wang
2013-11-20  9:30   ` [PATCH net v5 1/4] r8152: fix tx/rx memory overflow Hayes Wang
2013-11-20  9:30   ` [PATCH net v5 2/4] r8152: modify the tx flow Hayes Wang
2013-11-20  9:30   ` [PATCH net v5 3/4] r8152: support stopping/waking tx queue Hayes Wang
2013-11-20  9:30   ` [PATCH net v5 4/4] r8152: fix incorrect type in assignment Hayes Wang
2013-12-23  2:20   ` [PATCH net v5 0/4] r8152 bug fixes hayeswang

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=1384502279-9959-3-git-send-email-hayeswang@realtek.com \
    --to=hayeswang-rasf1irrpzfbdgjk7y7tuq@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nic_swsd-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox