2013-03-17 09:59:10

by Jussi Kivilinna

[permalink] [raw]
Subject: [PATCH 0/4] rtlwifi: usb: improve RX performance and lower CPU usage

Patchset improves RX path handling in rtlwifi/usb.c by:
- change to use preallocated DMA coherent URB buffers.
- kill unnessasary skbuff copies.
- defer RX processing to tasklet.
- add proper alignment of skbuff early on.

With this patchset IRQ CPU usage drops from 37% to 25% on ARM system with
1Ghz Cortex-A8, when doing large transfer with rtl8192cu. Tranfer speed
appears to be slightly improved too, from 29Mbit to 31Mbit.

---

Jussi Kivilinna (4):
rtlwifi: usb: use usb_alloc_coherent for RX buffers
rtlwifi: usb: remove extra skb copy on RX path
rtlwifi: usb: defer rx processing to tasklet
rtlwifi: usb: add NET_IP_ALIGN padding to RX skb when needed


drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2
drivers/net/wireless/rtlwifi/usb.c | 220 ++++++++++++++++++--------
drivers/net/wireless/rtlwifi/usb.h | 5 -
3 files changed, 156 insertions(+), 71 deletions(-)


2013-03-17 09:59:31

by Jussi Kivilinna

[permalink] [raw]
Subject: [PATCH 4/4] rtlwifi: usb: add NET_IP_ALIGN padding to RX skb when needed

Add proper alignment at first packet copy, to avoid extra copies made later
in networking stack.

Signed-off-by: Jussi Kivilinna <[email protected]>
---
drivers/net/wireless/rtlwifi/usb.c | 41 +++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 6cb2940..83915dc 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -569,6 +569,37 @@ static void _rtl_rx_work(unsigned long param)
}
}

+static unsigned int _rtl_rx_get_padding(struct ieee80211_hdr *hdr,
+ unsigned int len)
+{
+ unsigned int padding = 0;
+
+ /* make function no-op when possible */
+ if (NET_IP_ALIGN == 0 || len < sizeof(*hdr))
+ return 0;
+
+ /* alignment calculation as in lbtf_rx() / carl9170_rx_copy_data() */
+ /* TODO: deduplicate common code, define helper function instead? */
+
+ if (ieee80211_is_data_qos(hdr->frame_control)) {
+ u8 *qc = ieee80211_get_qos_ctl(hdr);
+
+ padding ^= NET_IP_ALIGN;
+
+ /* Input might be invalid, avoid accessing memory outside
+ * the buffer.
+ */
+ if ((unsigned long)qc - (unsigned long)hdr < len &&
+ *qc & IEEE80211_QOS_CTL_A_MSDU_PRESENT)
+ padding ^= NET_IP_ALIGN;
+ }
+
+ if (ieee80211_has_a4(hdr->frame_control))
+ padding ^= NET_IP_ALIGN;
+
+ return padding;
+}
+
#define __RADIO_TAP_SIZE_RSV 32

static void _rtl_rx_completed(struct urb *_urb)
@@ -582,9 +613,11 @@ static void _rtl_rx_completed(struct urb *_urb)
goto free;

if (likely(0 == _urb->status)) {
+ unsigned int padding;
struct sk_buff *skb;
unsigned int qlen;
unsigned int size = _urb->actual_length;
+ struct ieee80211_hdr *hdr;

if (size < RTL_RX_DESC_SIZE + sizeof(struct ieee80211_hdr)) {
RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
@@ -601,7 +634,10 @@ static void _rtl_rx_completed(struct urb *_urb)
goto resubmit;
}

- skb = dev_alloc_skb(size + __RADIO_TAP_SIZE_RSV);
+ hdr = (void *)(_urb->transfer_buffer + RTL_RX_DESC_SIZE);
+ padding = _rtl_rx_get_padding(hdr, size - RTL_RX_DESC_SIZE);
+
+ skb = dev_alloc_skb(size + __RADIO_TAP_SIZE_RSV + padding);
if (!skb) {
RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
"Can't allocate skb for bulk IN!\n");
@@ -610,6 +646,9 @@ static void _rtl_rx_completed(struct urb *_urb)

_rtl_install_trx_info(rtlusb, skb, rtlusb->in_ep);

+ /* Make sure the payload data is 4 byte aligned. */
+ skb_reserve(skb, padding);
+
/* reserve some space for mac80211's radiotap */
skb_reserve(skb, __RADIO_TAP_SIZE_RSV);



2013-03-17 09:59:20

by Jussi Kivilinna

[permalink] [raw]
Subject: [PATCH 2/4] rtlwifi: usb: remove extra skb copy on RX path

RX path has extra copying of packets, that can be avoided.

Signed-off-by: Jussi Kivilinna <[email protected]>
---
drivers/net/wireless/rtlwifi/usb.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 146d2b4..8563818 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -513,22 +513,11 @@ static void _rtl_usb_rx_process_noagg(struct ieee80211_hw *hw,
if (unicast)
rtlpriv->link_info.num_rx_inperiod++;
}
- if (likely(rtl_action_proc(hw, skb, false))) {
- struct sk_buff *uskb = NULL;
- u8 *pdata;
-
- uskb = dev_alloc_skb(skb->len + 128);
- if (uskb) { /* drop packet on allocation failure */
- memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status,
- sizeof(rx_status));
- pdata = (u8 *)skb_put(uskb, skb->len);
- memcpy(pdata, skb->data, skb->len);
- ieee80211_rx_irqsafe(hw, uskb);
- }
- dev_kfree_skb_any(skb);
- } else {
+
+ if (likely(rtl_action_proc(hw, skb, false)))
+ ieee80211_rx_irqsafe(hw, skb);
+ else
dev_kfree_skb_any(skb);
- }
}
}



2013-03-17 09:59:16

by Jussi Kivilinna

[permalink] [raw]
Subject: [PATCH 1/4] rtlwifi: usb: use usb_alloc_coherent for RX buffers

Use dedicated DMA coherent buffers for RX urbs, to avoid allocation of large
skbuffs in hard-irq context and improve performance.

Signed-off-by: Jussi Kivilinna <[email protected]>
---
drivers/net/wireless/rtlwifi/usb.c | 114 +++++++++++++++++++++---------------
drivers/net/wireless/rtlwifi/usb.h | 1
2 files changed, 68 insertions(+), 47 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 41dce83..146d2b4 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -324,6 +324,7 @@ static int _rtl_usb_init_rx(struct ieee80211_hw *hw)
pr_info("rx_max_size %d, rx_urb_num %d, in_ep %d\n",
rtlusb->rx_max_size, rtlusb->rx_urb_num, rtlusb->in_ep);
init_usb_anchor(&rtlusb->rx_submitted);
+ init_usb_anchor(&rtlusb->rx_cleanup_urbs);
return 0;
}

@@ -405,40 +406,30 @@ static void rtl_usb_init_sw(struct ieee80211_hw *hw)
rtlusb->disableHWSM = true;
}

-#define __RADIO_TAP_SIZE_RSV 32
-
static void _rtl_rx_completed(struct urb *urb);

-static struct sk_buff *_rtl_prep_rx_urb(struct ieee80211_hw *hw,
- struct rtl_usb *rtlusb,
- struct urb *urb,
- gfp_t gfp_mask)
+static int _rtl_prep_rx_urb(struct ieee80211_hw *hw, struct rtl_usb *rtlusb,
+ struct urb *urb, gfp_t gfp_mask)
{
- struct sk_buff *skb;
struct rtl_priv *rtlpriv = rtl_priv(hw);
+ void *buf;

- skb = __dev_alloc_skb((rtlusb->rx_max_size + __RADIO_TAP_SIZE_RSV),
- gfp_mask);
- if (!skb) {
+ buf = usb_alloc_coherent(rtlusb->udev, rtlusb->rx_max_size, gfp_mask,
+ &urb->transfer_dma);
+ if (!buf) {
RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
- "Failed to __dev_alloc_skb!!\n");
- return ERR_PTR(-ENOMEM);
+ "Failed to usb_alloc_coherent!!\n");
+ return -ENOMEM;
}

- /* reserve some space for mac80211's radiotap */
- skb_reserve(skb, __RADIO_TAP_SIZE_RSV);
usb_fill_bulk_urb(urb, rtlusb->udev,
usb_rcvbulkpipe(rtlusb->udev, rtlusb->in_ep),
- skb->data, min(skb_tailroom(skb),
- (int)rtlusb->rx_max_size),
- _rtl_rx_completed, skb);
+ buf, rtlusb->rx_max_size, _rtl_rx_completed, rtlusb);
+ urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;

- _rtl_install_trx_info(rtlusb, skb, rtlusb->in_ep);
- return skb;
+ return 0;
}

-#undef __RADIO_TAP_SIZE_RSV
-
static void _rtl_usb_rx_process_agg(struct ieee80211_hw *hw,
struct sk_buff *skb)
{
@@ -558,11 +549,11 @@ static void _rtl_rx_pre_process(struct ieee80211_hw *hw, struct sk_buff *skb)
}
}

+#define __RADIO_TAP_SIZE_RSV 32
+
static void _rtl_rx_completed(struct urb *_urb)
{
- struct sk_buff *skb = (struct sk_buff *)_urb->context;
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- struct rtl_usb *rtlusb = (struct rtl_usb *)info->rate_driver_data[0];
+ struct rtl_usb *rtlusb = (struct rtl_usb *)_urb->context;
struct ieee80211_hw *hw = usb_get_intfdata(rtlusb->intf);
struct rtl_priv *rtlpriv = rtl_priv(hw);
int err = 0;
@@ -571,28 +562,42 @@ static void _rtl_rx_completed(struct urb *_urb)
goto free;

if (likely(0 == _urb->status)) {
- /* If this code were moved to work queue, would CPU
- * utilization be improved? NOTE: We shall allocate another skb
- * and reuse the original one.
+ struct sk_buff *skb;
+ unsigned int size = _urb->actual_length;
+
+ if (size < RTL_RX_DESC_SIZE + sizeof(struct ieee80211_hdr)) {
+ RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
+ "Too short packet from bulk IN! (len: %d)\n",
+ size);
+ goto resubmit;
+ }
+
+ skb = dev_alloc_skb(size + __RADIO_TAP_SIZE_RSV);
+ if (!skb) {
+ RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
+ "Can't allocate skb for bulk IN!\n");
+ goto resubmit;
+ }
+
+ _rtl_install_trx_info(rtlusb, skb, rtlusb->in_ep);
+
+ /* reserve some space for mac80211's radiotap */
+ skb_reserve(skb, __RADIO_TAP_SIZE_RSV);
+
+ memcpy(skb_put(skb, size), _urb->transfer_buffer, size);
+
+ /* TODO: Do further processing in tasklet (queue skbs,
+ * schedule tasklet)
*/
- skb_put(skb, _urb->actual_length);

if (likely(!rtlusb->usb_rx_segregate_hdl)) {
- struct sk_buff *_skb;
_rtl_usb_rx_process_noagg(hw, skb);
- _skb = _rtl_prep_rx_urb(hw, rtlusb, _urb, GFP_ATOMIC);
- if (IS_ERR(_skb)) {
- err = PTR_ERR(_skb);
- RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
- "Can't allocate skb for bulk IN!\n");
- return;
- }
- skb = _skb;
- } else{
+ } else {
/* TO DO */
_rtl_rx_pre_process(hw, skb);
pr_err("rx agg not supported\n");
}
+
goto resubmit;
}

@@ -608,9 +613,6 @@ static void _rtl_rx_completed(struct urb *_urb)
}

resubmit:
- skb_reset_tail_pointer(skb);
- skb_trim(skb, 0);
-
usb_anchor_urb(_urb, &rtlusb->rx_submitted);
err = usb_submit_urb(_urb, GFP_ATOMIC);
if (unlikely(err)) {
@@ -620,13 +622,31 @@ resubmit:
return;

free:
- dev_kfree_skb_irq(skb);
+ /* On some architectures, usb_free_coherent must not be called from
+ * hardirq context. Queue urb to cleanup list.
+ */
+ usb_anchor_urb(_urb, &rtlusb->rx_cleanup_urbs);
+}
+
+#undef __RADIO_TAP_SIZE_RSV
+
+static void _rtl_usb_cleanup_rx(struct ieee80211_hw *hw)
+{
+ struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
+ struct urb *urb;
+
+ usb_kill_anchored_urbs(&rtlusb->rx_submitted);
+
+ while ((urb = usb_get_from_anchor(&rtlusb->rx_cleanup_urbs))) {
+ usb_free_coherent(urb->dev, urb->transfer_buffer_length,
+ urb->transfer_buffer, urb->transfer_dma);
+ usb_free_urb(urb);
+ }
}

static int _rtl_usb_receive(struct ieee80211_hw *hw)
{
struct urb *urb;
- struct sk_buff *skb;
int err;
int i;
struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -645,11 +665,10 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw)
goto err_out;
}

- skb = _rtl_prep_rx_urb(hw, rtlusb, urb, GFP_KERNEL);
- if (IS_ERR(skb)) {
+ err = _rtl_prep_rx_urb(hw, rtlusb, urb, GFP_KERNEL);
+ if (err < 0) {
RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
"Failed to prep_rx_urb!!\n");
- err = PTR_ERR(skb);
usb_free_urb(urb);
goto err_out;
}
@@ -664,6 +683,7 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw)

err_out:
usb_kill_anchored_urbs(&rtlusb->rx_submitted);
+ _rtl_usb_cleanup_rx(hw);
return err;
}

@@ -705,7 +725,7 @@ static void rtl_usb_cleanup(struct ieee80211_hw *hw)
SET_USB_STOP(rtlusb);

/* clean up rx stuff. */
- usb_kill_anchored_urbs(&rtlusb->rx_submitted);
+ _rtl_usb_cleanup_rx(hw);

/* clean up tx stuff */
for (i = 0; i < RTL_USB_MAX_EP_NUM; i++) {
diff --git a/drivers/net/wireless/rtlwifi/usb.h b/drivers/net/wireless/rtlwifi/usb.h
index fb986f9..22d7c68 100644
--- a/drivers/net/wireless/rtlwifi/usb.h
+++ b/drivers/net/wireless/rtlwifi/usb.h
@@ -141,6 +141,7 @@ struct rtl_usb {
u32 rx_max_size; /* Bulk IN max buffer size */
u32 rx_urb_num; /* How many Bulk INs are submitted to host. */
struct usb_anchor rx_submitted;
+ struct usb_anchor rx_cleanup_urbs;
void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
struct sk_buff_head *);
void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);


2013-03-17 09:59:26

by Jussi Kivilinna

[permalink] [raw]
Subject: [PATCH 3/4] rtlwifi: usb: defer rx processing to tasklet

Move processing of received packets to tasklet from hard-irq context.

Signed-off-by: Jussi Kivilinna <[email protected]>
---
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2 -
drivers/net/wireless/rtlwifi/usb.c | 60 ++++++++++++++++++++------
drivers/net/wireless/rtlwifi/usb.h | 4 +-
3 files changed, 51 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
index b6222ee..710f790 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
@@ -434,7 +434,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
(u32)hdr->addr1[2], (u32)hdr->addr1[3],
(u32)hdr->addr1[4], (u32)hdr->addr1[5]);
memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status));
- ieee80211_rx_irqsafe(hw, skb);
+ ieee80211_rx(hw, skb);
}

void rtl8192cu_rx_hdl(struct ieee80211_hw *hw, struct sk_buff * skb)
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 8563818..6cb2940 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -308,6 +308,8 @@ static int _rtl_usb_init_tx(struct ieee80211_hw *hw)
return 0;
}

+static void _rtl_rx_work(unsigned long param);
+
static int _rtl_usb_init_rx(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -325,6 +327,11 @@ static int _rtl_usb_init_rx(struct ieee80211_hw *hw)
rtlusb->rx_max_size, rtlusb->rx_urb_num, rtlusb->in_ep);
init_usb_anchor(&rtlusb->rx_submitted);
init_usb_anchor(&rtlusb->rx_cleanup_urbs);
+
+ skb_queue_head_init(&rtlusb->rx_queue);
+ rtlusb->rx_work_tasklet.func = _rtl_rx_work;
+ rtlusb->rx_work_tasklet.data = (unsigned long)rtlusb;
+
return 0;
}

@@ -515,7 +522,7 @@ static void _rtl_usb_rx_process_noagg(struct ieee80211_hw *hw,
}

if (likely(rtl_action_proc(hw, skb, false)))
- ieee80211_rx_irqsafe(hw, skb);
+ ieee80211_rx(hw, skb);
else
dev_kfree_skb_any(skb);
}
@@ -534,7 +541,31 @@ static void _rtl_rx_pre_process(struct ieee80211_hw *hw, struct sk_buff *skb)
while (!skb_queue_empty(&rx_queue)) {
_skb = skb_dequeue(&rx_queue);
_rtl_usb_rx_process_agg(hw, _skb);
- ieee80211_rx_irqsafe(hw, _skb);
+ ieee80211_rx(hw, _skb);
+ }
+}
+
+#define __RX_SKB_MAX_QUEUED 32
+
+static void _rtl_rx_work(unsigned long param)
+{
+ struct rtl_usb *rtlusb = (struct rtl_usb *)param;
+ struct ieee80211_hw *hw = usb_get_intfdata(rtlusb->intf);
+ struct sk_buff *skb;
+
+ while ((skb = skb_dequeue(&rtlusb->rx_queue))) {
+ if (unlikely(IS_USB_STOP(rtlusb))) {
+ dev_kfree_skb_any(skb);
+ continue;
+ }
+
+ if (likely(!rtlusb->usb_rx_segregate_hdl)) {
+ _rtl_usb_rx_process_noagg(hw, skb);
+ } else {
+ /* TO DO */
+ _rtl_rx_pre_process(hw, skb);
+ pr_err("rx agg not supported\n");
+ }
}
}

@@ -552,6 +583,7 @@ static void _rtl_rx_completed(struct urb *_urb)

if (likely(0 == _urb->status)) {
struct sk_buff *skb;
+ unsigned int qlen;
unsigned int size = _urb->actual_length;

if (size < RTL_RX_DESC_SIZE + sizeof(struct ieee80211_hdr)) {
@@ -561,6 +593,14 @@ static void _rtl_rx_completed(struct urb *_urb)
goto resubmit;
}

+ qlen = skb_queue_len(&rtlusb->rx_queue);
+ if (qlen >= __RX_SKB_MAX_QUEUED) {
+ RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
+ "Pending RX skbuff queue full! (qlen: %d)\n",
+ qlen);
+ goto resubmit;
+ }
+
skb = dev_alloc_skb(size + __RADIO_TAP_SIZE_RSV);
if (!skb) {
RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
@@ -575,17 +615,8 @@ static void _rtl_rx_completed(struct urb *_urb)

memcpy(skb_put(skb, size), _urb->transfer_buffer, size);

- /* TODO: Do further processing in tasklet (queue skbs,
- * schedule tasklet)
- */
-
- if (likely(!rtlusb->usb_rx_segregate_hdl)) {
- _rtl_usb_rx_process_noagg(hw, skb);
- } else {
- /* TO DO */
- _rtl_rx_pre_process(hw, skb);
- pr_err("rx agg not supported\n");
- }
+ skb_queue_tail(&rtlusb->rx_queue, skb);
+ tasklet_schedule(&rtlusb->rx_work_tasklet);

goto resubmit;
}
@@ -626,6 +657,9 @@ static void _rtl_usb_cleanup_rx(struct ieee80211_hw *hw)

usb_kill_anchored_urbs(&rtlusb->rx_submitted);

+ tasklet_kill(&rtlusb->rx_work_tasklet);
+ skb_queue_purge(&rtlusb->rx_queue);
+
while ((urb = usb_get_from_anchor(&rtlusb->rx_cleanup_urbs))) {
usb_free_coherent(urb->dev, urb->transfer_buffer_length,
urb->transfer_buffer, urb->transfer_dma);
diff --git a/drivers/net/wireless/rtlwifi/usb.h b/drivers/net/wireless/rtlwifi/usb.h
index 22d7c68..685273c 100644
--- a/drivers/net/wireless/rtlwifi/usb.h
+++ b/drivers/net/wireless/rtlwifi/usb.h
@@ -136,12 +136,14 @@ struct rtl_usb {
void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *);

/* Rx */
- u8 in_ep_nums ;
+ u8 in_ep_nums;
u32 in_ep; /* Bulk IN endpoint number */
u32 rx_max_size; /* Bulk IN max buffer size */
u32 rx_urb_num; /* How many Bulk INs are submitted to host. */
struct usb_anchor rx_submitted;
struct usb_anchor rx_cleanup_urbs;
+ struct tasklet_struct rx_work_tasklet;
+ struct sk_buff_head rx_queue;
void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
struct sk_buff_head *);
void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);


2013-04-03 19:19:09

by Jussi Kivilinna

[permalink] [raw]
Subject: Re: [PATCH 0/4] rtlwifi: usb: improve RX performance and lower CPU usage

On 03.04.2013 20:32, John W. Linville wrote:
> They are in wireless-next...

Ah, thanks!

-Jussi

>
> commit 657e27656dfb3a99e81c99df6e78e770d7fe0d48
> Author: Jussi Kivilinna <[email protected]>
> Date: Sun Mar 17 11:59:29 2013 +0200
>
> rtlwifi: usb: add NET_IP_ALIGN padding to RX skb when needed
>
> Add proper alignment at first packet copy, to avoid extra copies made later
> in networking stack.
>
> Signed-off-by: Jussi Kivilinna <[email protected]>
> Signed-off-by: John W. Linville <[email protected]>
>
> commit 29bb7013a53d8fc43f79f39d22a15ba8d3e77d9b
> Author: Jussi Kivilinna <[email protected]>
> Date: Sun Mar 17 11:59:24 2013 +0200
>
> rtlwifi: usb: defer rx processing to tasklet
>
> Move processing of received packets to tasklet from hard-irq context.
>
> Signed-off-by: Jussi Kivilinna <[email protected]>
> Signed-off-by: John W. Linville <[email protected]>
>
> commit d7d0f081c48951018133cac38c8c0796f37db727
> Author: Jussi Kivilinna <[email protected]>
> Date: Sun Mar 17 11:59:18 2013 +0200
>
> rtlwifi: usb: remove extra skb copy on RX path
>
> RX path has extra copying of packets, that can be avoided.
>
> Signed-off-by: Jussi Kivilinna <[email protected]>
> Signed-off-by: John W. Linville <[email protected]>
>
> commit 872de8ff04922e4ad95c5af39131ae9fbefe6ac5
> Author: Jussi Kivilinna <[email protected]>
> Date: Sun Mar 17 11:59:13 2013 +0200
>
> rtlwifi: usb: use usb_alloc_coherent for RX buffers
>
> Use dedicated DMA coherent buffers for RX urbs, to avoid allocation of large
> skbuffs in hard-irq context and improve performance.
>
> Signed-off-by: Jussi Kivilinna <[email protected]>
> Signed-off-by: John W. Linville <[email protected]>
>
> On Wed, Apr 03, 2013 at 08:16:20PM +0300, Jussi Kivilinna wrote:
>> Any comments on this patchset?
>>
>> On 17.03.2013 11:59, Jussi Kivilinna wrote:
>>> Patchset improves RX path handling in rtlwifi/usb.c by:
>>> - change to use preallocated DMA coherent URB buffers.
>>> - kill unnessasary skbuff copies.
>>> - defer RX processing to tasklet.
>>> - add proper alignment of skbuff early on.
>>>
>>> With this patchset IRQ CPU usage drops from 37% to 25% on ARM system with
>>> 1Ghz Cortex-A8, when doing large transfer with rtl8192cu. Tranfer speed
>>> appears to be slightly improved too, from 29Mbit to 31Mbit.
>>>
>>> ---
>>>
>>> Jussi Kivilinna (4):
>>> rtlwifi: usb: use usb_alloc_coherent for RX buffers
>>> rtlwifi: usb: remove extra skb copy on RX path
>>> rtlwifi: usb: defer rx processing to tasklet
>>> rtlwifi: usb: add NET_IP_ALIGN padding to RX skb when needed
>>>
>>>
>>> drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2
>>> drivers/net/wireless/rtlwifi/usb.c | 220 ++++++++++++++++++--------
>>> drivers/net/wireless/rtlwifi/usb.h | 5 -
>>> 3 files changed, 156 insertions(+), 71 deletions(-)
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>>> the body of a message to [email protected]
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>


2013-04-03 17:33:10

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH 0/4] rtlwifi: usb: improve RX performance and lower CPU usage

They are in wireless-next...

commit 657e27656dfb3a99e81c99df6e78e770d7fe0d48
Author: Jussi Kivilinna <[email protected]>
Date: Sun Mar 17 11:59:29 2013 +0200

rtlwifi: usb: add NET_IP_ALIGN padding to RX skb when needed

Add proper alignment at first packet copy, to avoid extra copies made later
in networking stack.

Signed-off-by: Jussi Kivilinna <[email protected]>
Signed-off-by: John W. Linville <[email protected]>

commit 29bb7013a53d8fc43f79f39d22a15ba8d3e77d9b
Author: Jussi Kivilinna <[email protected]>
Date: Sun Mar 17 11:59:24 2013 +0200

rtlwifi: usb: defer rx processing to tasklet

Move processing of received packets to tasklet from hard-irq context.

Signed-off-by: Jussi Kivilinna <[email protected]>
Signed-off-by: John W. Linville <[email protected]>

commit d7d0f081c48951018133cac38c8c0796f37db727
Author: Jussi Kivilinna <[email protected]>
Date: Sun Mar 17 11:59:18 2013 +0200

rtlwifi: usb: remove extra skb copy on RX path

RX path has extra copying of packets, that can be avoided.

Signed-off-by: Jussi Kivilinna <[email protected]>
Signed-off-by: John W. Linville <[email protected]>

commit 872de8ff04922e4ad95c5af39131ae9fbefe6ac5
Author: Jussi Kivilinna <[email protected]>
Date: Sun Mar 17 11:59:13 2013 +0200

rtlwifi: usb: use usb_alloc_coherent for RX buffers

Use dedicated DMA coherent buffers for RX urbs, to avoid allocation of large
skbuffs in hard-irq context and improve performance.

Signed-off-by: Jussi Kivilinna <[email protected]>
Signed-off-by: John W. Linville <[email protected]>

On Wed, Apr 03, 2013 at 08:16:20PM +0300, Jussi Kivilinna wrote:
> Any comments on this patchset?
>
> On 17.03.2013 11:59, Jussi Kivilinna wrote:
> > Patchset improves RX path handling in rtlwifi/usb.c by:
> > - change to use preallocated DMA coherent URB buffers.
> > - kill unnessasary skbuff copies.
> > - defer RX processing to tasklet.
> > - add proper alignment of skbuff early on.
> >
> > With this patchset IRQ CPU usage drops from 37% to 25% on ARM system with
> > 1Ghz Cortex-A8, when doing large transfer with rtl8192cu. Tranfer speed
> > appears to be slightly improved too, from 29Mbit to 31Mbit.
> >
> > ---
> >
> > Jussi Kivilinna (4):
> > rtlwifi: usb: use usb_alloc_coherent for RX buffers
> > rtlwifi: usb: remove extra skb copy on RX path
> > rtlwifi: usb: defer rx processing to tasklet
> > rtlwifi: usb: add NET_IP_ALIGN padding to RX skb when needed
> >
> >
> > drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2
> > drivers/net/wireless/rtlwifi/usb.c | 220 ++++++++++++++++++--------
> > drivers/net/wireless/rtlwifi/usb.h | 5 -
> > 3 files changed, 156 insertions(+), 71 deletions(-)
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> > the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2013-04-03 17:18:29

by Jussi Kivilinna

[permalink] [raw]
Subject: Re: [PATCH 0/4] rtlwifi: usb: improve RX performance and lower CPU usage

Any comments on this patchset?

On 17.03.2013 11:59, Jussi Kivilinna wrote:
> Patchset improves RX path handling in rtlwifi/usb.c by:
> - change to use preallocated DMA coherent URB buffers.
> - kill unnessasary skbuff copies.
> - defer RX processing to tasklet.
> - add proper alignment of skbuff early on.
>
> With this patchset IRQ CPU usage drops from 37% to 25% on ARM system with
> 1Ghz Cortex-A8, when doing large transfer with rtl8192cu. Tranfer speed
> appears to be slightly improved too, from 29Mbit to 31Mbit.
>
> ---
>
> Jussi Kivilinna (4):
> rtlwifi: usb: use usb_alloc_coherent for RX buffers
> rtlwifi: usb: remove extra skb copy on RX path
> rtlwifi: usb: defer rx processing to tasklet
> rtlwifi: usb: add NET_IP_ALIGN padding to RX skb when needed
>
>
> drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2
> drivers/net/wireless/rtlwifi/usb.c | 220 ++++++++++++++++++--------
> drivers/net/wireless/rtlwifi/usb.h | 5 -
> 3 files changed, 156 insertions(+), 71 deletions(-)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>