This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

USB wifi adapter integration

Hi,

We are trying to use a USB wifi adapter based on the realtek chipset instead of the Wilink adapter to do tethering. We were able to compile the driver from the realtek website for our kernel and it seems to work fine. With no other modification to the TI Android tree we can create an hotspot and try to connect on it but the connection always fails. Right now we don't have any obvious error message.

I've included to kernel and logcat output when trying to connect to the hotspot: Is it possible to get more debug output from hostapd, wpa_cupplicant or any other actors in this tether connection? Is there something we should modify or look at in the Android tree since we changed the wifi driver to realtek?

Thanks

[ 2487.481750] +OnAuth
[ 2487.483978] auth alg=0, seq=1
[ 2487.487060] going to alloc stainfo for sa=60FACD6C69C6
[ 2487.498138] OnAssocReq
[ 2487.500610] unknown vendor specific information element ignored (vendor OUI 00:10:18 len=9)
[ 2487.509368] allocate new AID = (1)
[ 2487.512939] HT: STA 60:fa:cd:6c:69:c6 HT Capabilities Info: 0x0100
[ 2487.519409] bss_cap_update STA 60:fa:cd:6c:69:c6 - no greenfield, num of non-gf stations 1
[ 2487.528045] bss_cap_update STA 60:fa:cd:6c:69:c6 - 20 MHz HT, num of 20MHz HT STAs 1
[ 2487.536163] indicate_sta_join_event to upper layer - hostapd
[ 2487.542083] report_add_sta_event: add STA
[ 2487.546295] issue_asocrsp
[ 2487.549102] rtw_cfg80211_indicate_sta_assoc
[ 2487.553588] update raid entry, bitmap=0xfff50, arg=0x82
[ 2487.559082] rtl8192c_Add_RateATid() pHalData->fw_ractrl == _TRUE
D/hostapd ( 1291[ 2487.567474] rtl8192c_Add_RateATid() rtl8192c_set_raid_cmd, bitmap=0xfff50, arg =0x82
): nl80211: Event message available
D/hostapd ( 1291): nl80211: MLME event 38
D/hostapd ( 1291): nl80211: MLME event frame - hexdump(len=149): 00 00 3c 00 e0 91 53 69 c5 18 60 fa cd 6c 69 c6 e0 91 53 69 c5 18 30 00 31 04 0f 00 00 09 4.
D/hostapd ( 1291): wlan0: Event ASSOC_REJECT (13) received
D/hostapd ( 1291): Unknown event 13
D/hostapd ( 1291): wlan0: Event ASSOC_REJECT (13) received
D/hostapd ( 1291): Unknown event 13
[ 2490.579071] OnDisassoc Reason code(8)
[ 2490.582946] OnDisassoc, STA:60:fa:cd:6c:69:c6
[ 2490.587524] issue_deauth to 60:fa:cd:6c:69:c6
[ 2490.592163] report_del_sta_event: delete STA
[ 2490.596710] rtw_cfg80211_indicate_sta_disassoc
D/hostapd ( 1291): nl80211: Event message available
D/hostapd ( 1291): nl80211: MLME event 40
D/hostapd ( 1291): nl80211: MLME event frame - hexdump(len=26): c0 00 00 00 e0 91 53 69 c5 18 60 fa cd 6c 69 c6 e0 91 53 69 c5 18 60 be 03 00
D/hostapd ( 1291): wlan0: Event DISASSOC (1) received
D/hostapd ( 1291): Disassociation notification for unknown STA e0:91:53:69:c5:18

  • Hi,

    We weren't able to make it work even trying with multiple different Realtek based USB keys with the official Realtek driver so we changed to Atheros based keys with the kernel included ath9k_htc driver (branch origin/rowboat-am335x-kernel-3.2).

    Using this setup we got it working but the driver was crashing when running with heavy network traffic on the wireless hotspot. We did a lot of tests using the ubuntu kernel also based on 3.2.0 which is not crashing and came up with with a working version by merging a small section of the ubuntu driver/usb/musb/musb_host.c into the TI version. 

    As of now we have no idea how this patch influences the USB behaviour other than fixing our specific hotspot crash problem.

    Can somebody tell us if it's safe to let this patch in our production kernel or if there is a better way to fix the problem doing something else?

    I've included the patch below and also as an attachment along with the kernel crash dump.

    Thanks

    4478.ath_crash_dump.txt

    8688.musb_host.patch.txt

    diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
    index f4919ca..bc7be6f 100644
    --- a/drivers/usb/musb/musb_host.c
    +++ b/drivers/usb/musb/musb_host.c
    @@ -332,6 +332,8 @@ start:
     
     /* Context: caller owns controller lock, IRQs are blocked */
     static void musb_giveback(struct musb *musb, struct urb *urb, int status)
    +__releases(musb->lock)
    +__acquires(musb->lock)
     {
     	dev_dbg(musb->controller,
     			"complete %p %pF (%d), dev%d ep%d%s, %d/%d\n",
    @@ -342,7 +344,10 @@ static void musb_giveback(struct musb *musb, struct urb *urb, int status)
     			urb->actual_length, urb->transfer_buffer_length
     			);
     
    +	usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb);
    +	spin_unlock(&musb->lock);
     	usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status);
    +	spin_lock(&musb->lock);
     }
     
     /* For bulk/interrupt endpoints only */
    @@ -411,6 +416,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,
     {
     	struct musb_qh		*qh = musb_ep_get_qh(hw_ep, is_in);
     	struct musb_hw_ep	*ep = qh->hw_ep;
    +	int			ready = qh->is_ready;
     	int			status;
     
     	status = (urb->status == -EINPROGRESS) ? 0 : urb->status;
    @@ -427,7 +433,9 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,
     		break;
     	}
     
    -	usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb);
    +	qh->is_ready = 0;
    +	musb_giveback(musb, urb, status);
    +	qh->is_ready = ready;
     
     	/* reclaim resources (and bandwidth) ASAP; deschedule it, and
     	 * invalidate qh as soon as list_empty(&hep->urb_list)
    @@ -493,17 +501,6 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,
     		    hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh));
     		musb_start_urb(musb, is_in, qh);
     	}
    -
    -	/* if we had set the status as -ECANCELED for dequeued URBs
    -	 * now the status has to be changed to -EINPROGRESS
    -	 * stack/application will not like -ECANCELED status
    -	 */
    -	if (urb->status == -ECANCELED)
    -		urb->status = -EINPROGRESS;
    -
    -	/* if URB is successfully completed then giveback in workqueue */
    -	push_queue(musb, urb);
    -	queue_work(musb->gb_queue, &musb->gb_work);
     }
    



  • Can you tell which is the source of this ubuntu 3.2.0 kernel? Meanwhile we shall go through this patch and see if it has any side effects.

    Regards,

    Arun

  • It's name is "3.2.0-52-generic". This corresponds to tag "Ubuntu-3.2.0-52.78" on git://kernel.ubuntu.com/ubuntu/ubuntu-precise.git

  • Hi Francois,

    Sorry, I completely missed to reply this thread.

    Can you give the exact crash messages you got when you tried the atheros wifi dongle?

    The section

    -
    -   /* if we had set the status as -ECANCELED for dequeued URBs
    -    * now the status has to be changed to -EINPROGRESS
    -    * stack/application will not like -ECANCELED status
    -    */
    -   if (urb->status == -ECANCELED)
    -       urb->status = -EINPROGRESS;
    -
    -   /* if URB is successfully completed then giveback in workqueue */
    -   push_queue(musb, urb);
    -   queue_work(musb->gb_queue, &musb->gb_work);
    got added recently and was supposed to fix out of order giveback of URBs. All android USB use cases work even before this patch was applied.
    Can you isolate the fix either to the locking/unlocking or the above patch section?
     
    We have not tested Atheros WIFI dongle in android but it was tested in beaglebone community with the angstrom 3.2 kernel. Please find the instructions from this post https://groups.google.com/forum/#!topic/beagleboard/9KCIs7yqsa8
    Regards,
    Arun
  • Hi Arun,

    The crash log is included in my earlier post. The file is named 4478.ath_crash_dump.txt.

    Other than that, I'll try to isolate the code section as requested soon and I'll take a look at the link provided.

    Thanks

  • Hi Arun,

    I follow up on your fix isolation question.

    I did some tests and the patch provided in my earlier post won't work if partially applied. The end results of a partially applied fix will range from kernel lockup on usb init to full kernel crash when using the atheros driver.

    How's the investigation going on your side?

  • HI Francois,

    The crash actually looks more from a atheros driver, than an issue with the MUSB driver. Can you analyse the USB packets and check if the atheros driver does not receive any of the expected packet in correct order?

    It will be difficult for us to analyse the crash since we do not have the required hardware.

    I think you should be safe to go ahead with the UBUNTU patch since all USB use cases will work without patch for the out of order giveback of URBs.

    Regards,

    Arun