Bug 218527 - [rtwn] Constantly packet dropping and connection loss
Summary: [rtwn] Constantly packet dropping and connection loss
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: wireless (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-wireless (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-10 09:52 UTC by George
Modified: 2021-01-23 10:59 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description George 2017-04-10 09:52:05 UTC
I have a laptop with OS: FreeBSD G-BSD 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r316281: Fri Mar 31 00:44:45 +05 2017 amd64 
Since integrated WiFi based on Realtek 8723AE not supported, I have USB dongle ASUS USB-N13 based on Realtek RTL8192CU chipset.
I have periodically disconnections from router (/var/log/messages have not any records in that moments), packets not transmitted (I try to ping router) and after some timeout (about 60 seconds) network start works but latency >1000ms and packet dropping 10-20%. If I replug dongle, some time all works good until next turn.
My PC places not far from WiFi router, and all other users have not problems with WiFi.
I have that problem with various APs and that dongle in Win-PC works without problem.

===== loader.conf ======================== 
if_rtwn_load="YES"
if_rtwn_usb_load="YES"
if_rtwn_pci_load="YES"
legal.realtek.license_ack=1

===== /etc/rc.conf =======================
wlans_rtwn0="wlan0"
ifconfig_wlan0="WPA inet 192.168.0.100/24"

===== ifconfig wlan0 list ap =============
UK              4e:5d:4e:4b:c8:f8    1   54M  -75:-95   100 EP   HTCAP RSN WME BSSLOAD

===== /var/log/messages periodical messages related to rtwn
Apr 10 13:20:24 G-BSD kernel: rtwn0: rtwn_rxeof: totlen (1606) > len (1280)!
Apr 10 13:20:24 G-BSD kernel: rtwn0: rtwn_rxeof: totlen (13315) > len (384)!

===== /var/log/messages after plug in dongle ==============
Apr 10 14:29:52 G-BSD kernel: ugen0.2: <vendor 0x0b05 product 0x17ab> at usbus0
Apr 10 14:29:52 G-BSD kernel: rtwn0 on uhub0
Apr 10 14:29:52 G-BSD kernel: rtwn0: <vendor 0x0b05 product 0x17ab, class 0/0, rev 2.00/2.00, addr 3> on usbus0
Apr 10 14:29:52 G-BSD kernel: rtwn0: MAC/BB RTL8192CU, RF 6052 2T2R
Apr 10 14:29:52 G-BSD kernel: wlan0: Ethernet address: 50:46:5d:af:f5:5e
Apr 10 14:29:52 G-BSD wpa_supplicant[27836]: Successfully initialized wpa_supplicant
Apr 10 14:29:55 G-BSD wpa_supplicant[27837]: wlan0: Trying to associate with 4e:5d:4e:4b:c8:f8 (SSID='UK' freq=2412 MHz)
Apr 10 14:29:55 G-BSD wpa_supplicant[27837]: wlan0: Associated with 4e:5d:4e:4b:c8:f8
Apr 10 14:29:55 G-BSD kernel: wlan0: link state changed to UP
Apr 10 14:29:56 G-BSD wpa_supplicant[27837]: wlan0: WPA: Key negotiation completed with 4e:5d:4e:4b:c8:f8 [PTK=CCMP GTK=CCMP]
Apr 10 14:29:56 G-BSD wpa_supplicant[27837]: wlan0: CTRL-EVENT-CONNECTED - Connection to 4e:5d:4e:4b:c8:f8 completed [id=0 id_str=]

===== ifconfig wlan0 =====================================
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 50:46:5d:af:f5:5e
        inet 192.168.6.95 netmask 0xffffff00 broadcast 192.168.6.255 
        media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
        status: associated
        ssid UK channel 1 (2412 MHz 11g ht/20) bssid 4e:5d:4e:4b:c8:f8
        regdomain FCC country US authmode WPA2/802.11i privacy ON
        deftxkey UNDEF AES-CCM 2:128-bit txpower 30 bmiss 7 scanvalid 60
        protmode CTS ht20 ampdulimit 64k ampdudensity 4 shortgi -stbc -ldpc
        wme roaming MANUAL
        groups: wlan 

===== lsusb -v info about dongle ==============================
Bus /dev/usb Device /dev/ugen0.2: ID 0b05:17ab ASUSTek Computer, Inc. USB-N13 802.11n Network Adapter (rev. B1) [Realtek RTL8192CU]
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0b05 ASUSTek Computer, Inc.
  idProduct          0x17ab USB-N13 802.11n Network Adapter (rev. B1) [Realtek RTL8192CU]
  bcdDevice            2.00
  iManufacturer           1 Realtek
  iProduct                2 802.11n WLAN Adapter
  iSerial                 3 00e04c000001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           46
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           4
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Input/output error
Device Status:     0x0000
  (Bus Powered)
Comment 1 commit-hook freebsd_committer freebsd_triage 2017-07-30 23:35:30 UTC
A commit references this bug:

Author: avos
Date: Sun Jul 30 23:35:21 UTC 2017
New revision: 321735
URL: https://svnweb.freebsd.org/changeset/base/321735

Log:
  rtwn_usb: add support for fragmented Rx.

  Since device can pass multiple frames in a single payload temporary
  Rx buffer was big enough to hold all of them; now the driver can
  concatenate a single frame from multiple payloads.

  The Rx buffer size may be configured via tunable (dev.rtwn.%d.rx_buf_size).

  Tested with:
   - rtl8188cus, rtl8188eu and rtl8821au (STA mode).
   - (by kevlo) rtl8192cu and rtl8188eu.

  PR:		218527
  Reviewed by:	kevlo
  Differential Revision:	https://reviews.freebsd.org/D11705

Changes:
  head/sys/dev/rtwn/if_rtwnreg.h
  head/sys/dev/rtwn/usb/rtwn_usb_attach.c
  head/sys/dev/rtwn/usb/rtwn_usb_ep.c
  head/sys/dev/rtwn/usb/rtwn_usb_rx.c
  head/sys/dev/rtwn/usb/rtwn_usb_var.h
Comment 2 Andriy Voskoboinyk freebsd_committer freebsd_triage 2017-07-31 00:04:57 UTC
Should be fixed now.
Comment 3 mr_beaner_2003 2018-11-23 22:06:59 UTC
This doesn't appear to be fixed. I am using an EDIMAX N150 USB dongle, and I see packet loss.

# freebsd-version
12.0-RC1

# dmesg | grep rtwn
rtwn0 on uhub0
rtwn0: <Realtek 802.11n WLAN Adapter, class 0/0, rev 2.00/2.00, addr 2> on usbus1
rtwn0: MAC/BB RTL8188CUS, RF 6052 1T1R

# ping -c 100 172.16.100.2
PING 172.16.100.2 (172.16.100.2): 56 data bytes
64 bytes from 172.16.100.2: icmp_seq=0 ttl=255 time=12.919 ms
64 bytes from 172.16.100.2: icmp_seq=1 ttl=255 time=16.632 ms
64 bytes from 172.16.100.2: icmp_seq=2 ttl=255 time=13.729 ms
64 bytes from 172.16.100.2: icmp_seq=4 ttl=255 time=19.672 ms
64 bytes from 172.16.100.2: icmp_seq=5 ttl=255 time=29.435 ms
64 bytes from 172.16.100.2: icmp_seq=7 ttl=255 time=28.343 ms
64 bytes from 172.16.100.2: icmp_seq=8 ttl=255 time=20.443 ms
64 bytes from 172.16.100.2: icmp_seq=9 ttl=255 time=16.860 ms
...
64 bytes from 172.16.100.2: icmp_seq=98 ttl=255 time=20.125 ms
64 bytes from 172.16.100.2: icmp_seq=99 ttl=255 time=29.647 ms

--- 172.16.100.2 ping statistics ---
100 packets transmitted, 90 packets received, 10.0% packet loss
round-trip min/avg/max/stddev = 8.417/21.663/52.897/8.762 ms

# cat /boot/loader.conf 
if_rtwn_usb_load="YES"
legal.realtek.license_ack=1
pf_load="YES"

# grep wlan /etc/rc.conf
wlans_rtwn0="wlan0"
ifconfig_wlan0="WPA DHCP"
create_args_wlan0="country US regdomain FCC"

# ifconfig wlan0 list ap
SSID/MESH ID                      BSSID              CHAN RATE    S:N     INT CAPS
WAP                       82:2a:a8:d7:ec:a5    1   54M  -85:-95   100 EPS  BSSLOAD HTCAP WME ATH RSN

# usbconfig list
ugen1.1: <Intel EHCI root HUB> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.1: <Apple OHCI root HUB> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen1.2: <Realtek 802.11n WLAN Adapter> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)
# usbconfig ugen1.2 dump_all_config_desc
ugen1.2: <Realtek 802.11n WLAN Adapter> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)


 Configuration index 0

    bLength = 0x0009 
    bDescriptorType = 0x0002 
    wTotalLength = 0x002e 
    bNumInterfaces = 0x0001 
    bConfigurationValue = 0x0001 
    iConfiguration = 0x0000  <no string>
    bmAttributes = 0x00a0 
    bMaxPower = 0x00fa 

    Interface 0
      bLength = 0x0009 
      bDescriptorType = 0x0004 
      bInterfaceNumber = 0x0000 
      bAlternateSetting = 0x0000 
      bNumEndpoints = 0x0004 
      bInterfaceClass = 0x00ff  <Vendor specific>
      bInterfaceSubClass = 0x00ff 
      bInterfaceProtocol = 0x00ff 
      iInterface = 0x0000  <no string>

     Endpoint 0
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0081  <IN>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

     Endpoint 1
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0002  <OUT>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

     Endpoint 2
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0003  <OUT>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

     Endpoint 3
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0084  <IN>
        bmAttributes = 0x0003  <INTERRUPT>
        wMaxPacketSize = 0x0040 
        bInterval = 0x0001 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

# grep wpa_supplicant /var/log/messages
Nov 23 15:19:28 localhost wpa_supplicant[848]: Successfully initialized wpa_supplicant
Nov 23 15:19:35 localhost wpa_supplicant[849]: wlan0: Trying to associate with 80:2a:a8:d7:ec:a5 (SSID='WAP0' freq=2412 MHz)
Nov 23 15:19:35 localhost wpa_supplicant[849]: wlan0: Associated with 80:2a:a8:d7:ec:a5
Nov 23 15:19:36 localhost wpa_supplicant[849]: wlan0: WPA: Key negotiation completed with 80:2a:a8:d7:ec:a5 [PTK=CCMP GTK=CCMP]
Nov 23 15:19:36 localhost wpa_supplicant[849]: wlan0: CTRL-EVENT-CONNECTED - Connection to 80:2a:a8:d7:ec:a5 completed [id=0 id_str=]
Nov 23 15:23:24 localhost wpa_supplicant[797]: Successfully initialized wpa_supplicant
Nov 23 15:23:54 localhost wpa_supplicant[798]: wlan0: Trying to associate with 80:2a:a8:d7:ec:a5 (SSID='WAP0' freq=2412 MHz)
Nov 23 15:23:54 localhost wpa_supplicant[798]: wlan0: Associated with 80:2a:a8:d7:ec:a5
Nov 23 15:23:55 localhost wpa_supplicant[798]: wlan0: WPA: Key negotiation completed with 80:2a:a8:d7:ec:a5 [PTK=CCMP GTK=CCMP]
Nov 23 15:23:55 localhost wpa_supplicant[798]: wlan0: CTRL-EVENT-CONNECTED - Connection to 80:2a:a8:d7:ec:a5 completed [id=0 id_str=]
Nov 23 15:25:21 localhost wpa_supplicant[798]: wlan0: CTRL-EVENT-DISCONNECTED bssid=80:2a:a8:d7:ec:a5 reason=3 locally_generated=1
Nov 23 15:25:21 localhost wpa_supplicant[798]: wlan0: CTRL-EVENT-TERMINATING 
Nov 23 15:25:21 localhost wpa_supplicant[1258]: Successfully initialized wpa_supplicant
Nov 23 15:25:36 localhost wpa_supplicant[1263]: wlan0: Trying to associate with 82:2a:a8:d7:ec:a5 (SSID='WAP' freq=2412 MHz)
Nov 23 15:25:36 localhost wpa_supplicant[1263]: wlan0: Associated with 82:2a:a8:d7:ec:a5
Nov 23 15:25:37 localhost wpa_supplicant[1263]: wlan0: WPA: Key negotiation completed with 82:2a:a8:d7:ec:a5 [PTK=CCMP GTK=CCMP]
Nov 23 15:25:37 localhost wpa_supplicant[1263]: wlan0: CTRL-EVENT-CONNECTED - Connection to 82:2a:a8:d7:ec:a5 completed [id=1 id_str=]
Comment 4 mr_beaner_2003 2018-11-23 22:09:09 UTC
# uname -a
FreeBSD bsd12test 12.0-RC1 FreeBSD 12.0-RC1 r340470 GENERIC  amd64
Comment 5 Tony 2021-01-23 10:59:00 UTC
still have data loss on EDIMAX N150 USB (RTL8188CUS)
FreeBSD 12.2-RELEASE r366954 GENERIC AMD