UDP throughput error message in LOG UART

All information, news and questions about the Pine64 IoT-stamp can be found and discussed here
cheydrick
Posts: 8
Joined: Tue Apr 04, 2017 9:47 pm

UDP throughput error message in LOG UART

Postby cheydrick » Fri May 05, 2017 10:29 pm

I've been trying to do some wifi transmission speed tests on the PADI IoT device. I can get UDP to/from the device, but when you send UDP data too fast, the wifi driver complains in the UART LOG. What's not obvious to me is what the message means, and how I can programmatically know when I'm sending too much data.

The error messages coming across the UART LOG look like this:

RTL8195A[Driver]: skb_unavailable=630 in last 2 seconds

I'm assuming "skb_unavailable" means the SocKet Buffer is unavailable because I'm trying to send data faster than the buffer can clear. I've emailed Realtek, since the error looks to be coming from their driver, but no response.

Here's my code: https://gist.github.com/anonymous/e988a5236cda3974a0de5523e930416b

I'd love to see some thoughts on this, or answer any questions. I've tried different data sizes, but that didn't help. I have to add in a vTaskDelay() call of at least 10 milliseconds before the errors go away. The data rate I've achieved with no errors is something like 64k bytes per second, which seems really low.

kissste
Posts: 53
Joined: Fri Aug 12, 2016 3:43 am
Location: ON, Canada

Re: UDP throughput error message in LOG UART

Postby kissste » Mon May 08, 2017 2:32 am

1/ Answer is here:

https://www.amebaiot.com/en/questions/f ... nsmission/


2/ Take a look at SDK, you might be able to figure out how you can check buffer's availability prior to sending a message.

Please let us know how fast/slow you can push messages out if you pre-check before sending, instead of a blind wait period.

Thanks

lib_wlan.a.o/rtw_mlme.o:
Checking hardcoded every 2 seconds

void __fastcall dynamic_check_timer_handlder(void *FunctionContext)
{
_adapter *v1; // r4@1
_adapter *v2; // r0@3

v1 = (_adapter *)FunctionContext;
if ( skb_fail_get_and_rst() )
{
rtl_printf("\n\r");
rtl_printf("RTL8195A[Driver]: skb_unavailable=%d in last 2 seconds\n");
}
v2 = v1->pbuddy_adapter;
if ( v2 )
rtw_dynamic_check_timer_handlder(v2);
rtw_dynamic_check_timer_handlder(v1);
rtw_set_timer(&v1->mlmepriv.dynamic_chk_timer, 2000);
}

common/drivers/wlan/realtek/include/wlan_lib.h:extern int skb_fail_count;


int __fastcall skb_fail_get_and_rst(int a1)
{
int v1; // r0@1
int v2; // r4@1

v1 = save_and_cli(a1);
v2 = skb_fail_count;
skb_fail_count = 0;
restore_flags(v1);
return v2;
}

void __fastcall skb_fail_inc(int a1)
{
int v1; // r0@1

v1 = save_and_cli(a1);
++skb_fail_count;
restore_flags(v1);
}


raised the number, when this allocation fails...

sk_buff *__fastcall rltk_wlan_alloc_skb(unsigned int total_len)
{
sk_buff *result; // r0@3

if ( max_local_skb_num - 2 <= skbbuf_used_num || max_skb_buf_num - 2 <= skbdata_used_num )
{
skb_fail_inc(total_len);
result = 0;
}
else
{
result = (sk_buff *)dev_alloc_skb(total_len, 74);
}
return result;
}


you can pre-check
common/drivers/wlan/realtek/include/wlan_lib.h:extern int skbbuf_used_num;
common/drivers/wlan/realtek/include/wlan_lib.h:extern int max_skbbuf_used_num;

common/drivers/wlan/realtek/include/wlan_lib.h:extern int max_local_skb_num; // = 10;
common/drivers/wlan/realtek/src/core/option/rtw_opt_skbuf.c:#define MAX_LOCAL_SKB_NUM (MAX_SKB_BUF_NUM + 2)
common/drivers/wlan/realtek/src/core/option/rtw_opt_skbuf.c:int max_local_skb_num = MAX_LOCAL_SKB_NUM;
common/drivers/wlan/realtek/src/core/option/rtw_opt_skbuf.c:struct skb_buf skb_pool[MAX_LOCAL_SKB_NUM];
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_LOCAL_SKB_NUM (10 + 18) //tx+rx
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_LOCAL_SKB_NUM (MAX_SKB_BUF_NUM + 2) //tx+rx, +2: AP mode broadcast
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_LOCAL_SKB_NUM (10 + 18) //tx+rx
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_LOCAL_SKB_NUM (MAX_SKB_BUF_NUM + 2) //tx+rx, +2: AP mode broadcast
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h:#define MAX_LOCAL_SKB_NUM 10
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h:#define MAX_LOCAL_SKB_NUM 100
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h:#define MAX_LOCAL_SKB_NUM 10
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h:extern int max_local_skb_num;
common/drivers/wlan/realtek/include/wlan_lib.h:extern int max_skb_buf_num; // = 8;
common/drivers/wlan/realtek/src/core/option/rtw_opt_skbuf.c:#define MAX_SKB_BUF_NUM 8
common/drivers/wlan/realtek/src/core/option/rtw_opt_skbuf.c:#define MAX_LOCAL_SKB_NUM (MAX_SKB_BUF_NUM + 2)
common/drivers/wlan/realtek/src/core/option/rtw_opt_skbuf.c:unsigned int nr_xmitframe = MAX_SKB_BUF_NUM;
common/drivers/wlan/realtek/src/core/option/rtw_opt_skbuf.c:unsigned int nr_xmitbuff = MAX_SKB_BUF_NUM;
common/drivers/wlan/realtek/src/core/option/rtw_opt_skbuf.c:int max_skb_buf_num = MAX_SKB_BUF_NUM;
common/drivers/wlan/realtek/src/core/option/rtw_opt_skbuf.c:struct skb_data skb_data_pool[MAX_SKB_BUF_NUM];
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_SKB_BUF_NUM (8 + 4) //tx+rx (8 + RX_Q_DESC_NUM) Reduce rx skb number due to memory limitation
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_SKB_BUF_NUM 10 //tx+rx, ping 10k test
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_SKB_BUF_NUM 59
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_SKB_BUF_NUM 8 //tx+rx
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_LOCAL_SKB_NUM (MAX_SKB_BUF_NUM + 2) //tx+rx, +2: AP mode broadcast
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_SKB_BUF_NUM (8 + 4) //tx+rx (8 + RX_Q_DESC_NUM) Reduce rx skb number due to memory limitation
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_SKB_BUF_NUM 10 //tx+rx, ping 10k test
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_SKB_BUF_NUM 59
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_SKB_BUF_NUM 8 //tx+rx
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h: #define MAX_LOCAL_SKB_NUM (MAX_SKB_BUF_NUM + 2) //tx+rx, +2: AP mode broadcast
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h:#define MAX_SKB_BUF_NUM 7
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h:#define MAX_SKB_BUF_NUM 100
common/drivers/wlan/realtek/src/osdep/freertos/freertos_skbuff.h:extern int max_skb_buf_num;
common/drivers/wlan/realtek/src/wifi_skbuf.c:#undef MAX_SKB_BUF_NUM
common/drivers/wlan/realtek/src/wifi_skbuf.c:#define MAX_SKB_BUF_NUM 16
common/drivers/wlan/realtek/src/wifi_skbuf.c:struct skb_data skb_data_pool[MAX_SKB_BUF_NUM];

cheydrick
Posts: 8
Joined: Tue Apr 04, 2017 9:47 pm

Re: UDP throughput error message in LOG UART

Postby cheydrick » Mon May 08, 2017 6:55 pm

I really appreciate the response. I modified my program to monitor the skbbuf_used_num to delay while it's greater than 4.

Code: Select all

while (1)
   {
      n_sendto_data = lwip_sendto(sock, &d, size_d, 0, (struct sockaddr *)&sRemote, sizeof(sRemote));
      d.index++;
      while (skbbuf_used_num > 4)
      {
         vTaskDelay(1);
      }
   }


This seems to be enough to prevent the driver from complaining now, and I'm experimenting with different skbbuf_used_num values. I'm getting about 800,000 bytes per second being transferred from the IoT device to a wired PC.

Can you tell me what SDK you're using that has the source you referenced? I don't have wlan_lib.h in my source tree at all.

kissste
Posts: 53
Joined: Fri Aug 12, 2016 3:43 am
Location: ON, Canada

Re: UDP throughput error message in LOG UART

Postby kissste » Tue May 09, 2017 12:39 am

1/
if ( max_local_skb_num - 2 <= skbbuf_used_num || max_skb_buf_num - 2 <= skbdata_used_num ) { wait }

This should be the max, unless there is some other traffic/activity that interrupts your program and use the buffer.

2/
I use pvvx's SDK 3.5.2 GCC.

https://github.com/pvvx/RTL00MP3.git

3/ I would like to get access to SDK 4.0, but it has not been released (without NDA).

cheydrick
Posts: 8
Joined: Tue Apr 04, 2017 9:47 pm

Re: UDP throughput error message in LOG UART

Postby cheydrick » Wed May 10, 2017 4:41 pm

I appreciate the information, thanks.

I changed the wifi security method to "open" and now I'm getting about 1,400 kBps, up from 800 kBps before. That's a big jump. I knew encryption had overhead but I didn't realize how much!


Return to “Pine64 - PADI IoT Stamp”

Who is online

Users browsing this forum: No registered users and 1 guest