Xiang Xiao
0ef073573a
net: Remove protocol argument from si_setup callback
...
since the implementor could get the same value from socket::s_proto
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-13 22:41:19 +08:00
chao an
e942a7c55e
build/Kconfig: fix warnings detected by kconfiglib
...
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:07:46 +08:00
chao an
3a0fdb019d
nuttx: replace all ARRAY_SIZE()/ARRAYSIZE() to nitems()
...
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:05:44 +08:00
zhanghongyu
e7d1ba157c
usrsock: Don't clear recvfrom available flag
...
Don't clear available flag if the response indicate there is more data
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-02-04 20:52:56 +09:00
zhanghongyu
01fe37206a
usrsock: optimize send case
...
Don't clear available flag if the response indicate there is more space
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-02-04 20:52:56 +09:00
Zhe Weng
d3dd349649
net: Implement shutdown() for usrsock
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 11:15:01 +08:00
Zhe Weng
8819eeaf15
net: Implement shutdown() interface and tcp shutdown
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 11:15:01 +08:00
lilei19
1d8af7e105
add holder for mutex
...
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-01-31 12:08:05 +09:00
liangchaozhong
7e80879f88
usrsock: Output the log if usrsock_request return error
...
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2023-01-28 16:27:21 +09:00
liangchaozhong
cc940e8f69
net_lock:fix deadlock issue when running iperf tx test on usrsock
...
Issue Description:
deadlock happens when runnging iperf TCP tx on usrsock with the
following commands:
device command: iperf2 -c <PC IP address> -u -i 1 -p 1122 -t 10
PC command: iperf -s -u -i 1 -p 1122
iperf's thread holds net_lock before call usrsock_setup_request_callback
and waits for conn->resp.sem by calling
nxsem_wait_uninterruptible(&conn->resp.sem), while conn->resp.sem
can only be signaled in usrsock_response, who is waiting for net_lock in
tptun's thread.
Solution:
call net_lockedwait_uninterruptible to make sure net_lock can be
released when conn->resp.sem is not available.
Here's the backtrace:
up_block_task
nuttx/arch/arm/src/common/arm_blocktask.c:151
nxsem_wait
nuttx/sched/semaphore/sem_wait.c:185 (discriminator 2)
nxsem_wait_uninterruptible
nuttx/sched/semaphore/sem_wait.c:223 (discriminator 1)
usrsock_setup_request_callback
nuttx/net/usrsock/usrsock_conn.c:228
usrsock_setup_data_request_callback
nuttx/net/usrsock/usrsock_conn.c:257
usrsock_getsockopt
nuttx/net/usrsock/usrsock_getsockopt.c:202
psock_getsockopt
nuttx/net/socket/getsockopt.c:448
getsockopt
nuttx/net/socket/getsockopt.c:515
getsock_tcp_windowsize
external/iperf2/iperf2/src/tcp_window_size.c:165
reporter_reportsettings
external/iperf2/iperf2/src/ReportDefault.c:384
reporter_print
external/iperf2/iperf2/src/Reporter.c:1402
reporter_process_report
external/iperf2/iperf2/src/Reporter.c:860
reporter_process_report
external/iperf2/iperf2/src/Reporter.c:828
reporter_spawn
external/iperf2/iperf2/src/Reporter.c:720
thread_run_wrapper
external/iperf2/iperf2/compat/Thread.c:270
pthread_startup
nuttx/libs/libc/pthread/pthread_create.c:59 (discriminator 2)
pthread_start
nuttx/sched/pthread/pthread_create.c:182 (discriminator 4)
up_block_task
nuttx/arch/arm/src/common/arm_blocktask.c:151
nxsem_wait
nuttx/sched/semaphore/sem_wait.c:185 (discriminator 2)
sem_wait
nuttx/sched/semaphore/sem_wait.c:271
nxmutex_lock
nuttx/include/nuttx/mutex.h:165
nxrmutex_lock
nuttx/include/nuttx/mutex.h:369
usrsock_handle_req_response
nuttx/net/usrsock/usrsock_devif.c:466
usrsockdev_write
nuttx/drivers/usrsock/usrsock_dev.c:304
file_write
nuttx/fs/vfs/fs_write.c:90
usrsock_rpmsg_default_handler
apps/netutils/usrsock_rpmsg/usrsock_rpmsg_client.c:137
rpmsg_virtio_rx_callback
nuttx/openamp/open-amp/lib/rpmsg/rpmsg_virtio.c:371
virtqueue_notification
nuttx/openamp/open-amp/lib/virtio/virtqueue.c:706
rproc_virtio_notified
nuttx/openamp/open-amp/lib/remoteproc/remoteproc_virtio.c:337 (discriminator 2)
remoteproc_get_notification
nuttx/openamp/open-amp/lib/remoteproc/remoteproc.c:999
rptun_worker
nuttx/drivers/rptun/rptun.c:333
rptun_thread
nuttx/drivers/rptun/rptun.c:364 (discriminator 1)
nxtask_start
nuttx/sched/task/task_start.c:144
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2023-01-28 16:27:21 +09:00
Masayuki Ishikawa
dc454765fb
Revert "add holder for mutex"
...
This reverts commit fc176addeb
.
2023-01-19 06:04:48 +09:00
lilei19
fc176addeb
add holder for mutex
...
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-01-18 17:40:58 +08:00
Xiang Xiao
a851ad84c3
net: consistent the net sem wait naming conversion
...
to prepare the new mutex wait function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-15 12:31:30 -03:00
梁超众
aca1a065a8
move usrsock to kernel space
...
Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
2023-01-11 15:14:03 +08:00
Xiang Xiao
c38d6f1ae4
net: Remove usrsock specific process from common code as much as possible
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-28 16:32:41 +09:00
dongjiuzhu1
d5b08a7ef1
net/usrsock: fix get/setsockopt issue about usrsock protocol
...
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 21:27:15 +09:00
dongjiuzhu1
e6f8ccda4a
net/get/setsockopt: add si_get/setsockopt interface to simply get/setsockopt
...
move private option to protocol sockif
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 15:01:54 +08:00
Xiang Xiao
b170e4cc9f
net/usrsock: Split NET_USRSOCK_OTHER to NET_USRSOCK_ICMP[v6]
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-22 20:45:26 +09:00
Xiang Xiao
8bbb477316
net/usrsock: Should select NET_[UDP|TCP]_NO_STACK instead NET_[UDP|TCP]
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-22 20:45:26 +09:00
Xiang Xiao
c2f566afcb
net/usrsock: Remove NET_USRSOCK_NO_INET[6]
...
let the remote peer do all final decision
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-22 20:45:26 +09:00
zhanghongyu
ae46cd4fa1
usrsock: add REMOTE_CLOSED event handler to connect
...
when usrsock client try to connect usrsock server local_loop
socket with an invalid port, server cannot find a listener conn
to handle this connet request, then it will response a TCP_RESET
packet via nuttx existing processing, when before conn recv this
RESET packet, it will trigger usrsock_rpmsg_server poll return
and send REMOTE_CLOSE event to usrsock client.
so usrsock connect_event fucntion need handle this event.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-11-22 15:18:15 +09:00
anjiahao
e1ca516488
use SEM_INITIALIZER inside of NXSEM_INITIALIZER
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
anjiahao
5724c6b2e4
sem:remove sem default protocl
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
anjiahao
d1d46335df
Replace nxsem API when used as a lock with nxmutex API
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
zhanghongyu
403c657f42
usrsock: combine response and events when socket setup case
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-14 12:29:21 +09:00
liangchaozhong
c75253623d
usrsock:fix blocking socket connect operation hang issue
...
Issue description:
usrsock will wait for state.recvsem forever because no event triggers
state.recvsem post operation when connect operation in server side is
non-blocking.
Solution:
trigger state.recvsem post operation after receive USRSOCK_EVENT_SENDTO_READY.
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2022-10-14 12:29:21 +09:00
zhanghongyu
be06d00f85
usrsock: update state to connected when recv sento ready under connecting
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-14 12:29:21 +09:00
liangchaozhong
cc426f8539
usrsock:add done flag in usrsock_iovec_do
...
set done to true if all data in iovec array is copied
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2022-10-11 00:57:49 +08:00
Xiang Xiao
40ef5bc6db
libc: Move queue.h from include to include/nuttx
...
to avoid the conflict with libuv's queue.h
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-26 08:04:58 +02:00
wangbowen6
344c8be049
poll: add poll_notify() api and call it in all drivers
...
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-09-26 12:06:32 +08:00
Xiang Xiao
b400b99001
net/usrsock: Simplify the return value process of net_timedwait
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-11 10:08:04 +09:00
Xiang Xiao
77823415ed
net/usrsock: Remove the unnecessary blank line
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-11 10:08:04 +09:00
Xiang Xiao
3269c1a102
net/usrsock: Remove the unnecessary label
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-11 10:08:04 +09:00
Xiang Xiao
3d0985df39
net/usrsock: Remove the unnecessary extra space
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-11 10:08:04 +09:00
liangchaozhong
5ec4296553
move usrsock_dev.c to driver folder
...
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2022-09-10 13:08:22 +08:00
liangchaozhong
644c4afeed
usrsock:refine usrsock's architecture
...
Seperate usrsock device driver with usrsock core function layer
to make it more flexiable to adopt other kind of usrsock interface driver
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2022-09-09 20:56:12 +09:00
Xiang Xiao
e0bb281e7a
net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-06 22:46:37 +08:00
chao an
63cd44e5e1
net/usrsock: forward FIONBIO to socket level
...
fix usrsock nonblock connect test break:
apps/examples/usrsocktest/usrsocktest_noblock_connect.c:
...
157 TEST(no_block_connect, delayed_connect)
158 {
...
190 ret = fcntl(sd, F_SETFL, flags | O_NONBLOCK);
...
204 ret = connect(sd, (FAR const struct sockaddr *)&addr, sizeof(addr));
205 TEST_ASSERT_EQUAL(-1, ret);
206 TEST_ASSERT_EQUAL(EINPROGRESS, errno);
should goahead to socket level:
nuttx/net/netdev/netdev_ioctl.c:
...
1755 int psock_vioctl(FAR struct socket *psock, int cmd, va_list ap)
1756 {
...
1771 ret = netdev_ioctl(psock, cmd, arg);
...
1775 if (ret == -ENOTTY)
1776 {
1777 ret = netdev_file_ioctl(psock, cmd, arg);
1778 }
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-01 14:44:50 +08:00
Masayuki Ishikawa
aaae317d0c
Revert "net/usrsock: read from the closed remote should return EOF"
...
This reverts commit 3a653c1d5e
.
2022-09-01 13:16:46 +09:00
chao an
5d4c774352
net/usrsock: allow usrsock *DATA_ACK with no-preload data
...
allow usrsock USRSOCK_MESSAGE_RESPONSE_DATA_ACK with no-preload data
so addrlen could be updated to valuelen_nontrunc of usrsock_message_datareq_ack_s
nsh> usrsocktest
...
Testing group "basic_getsockname" =>
[TEST ASSERT FAILED!]
In function "basic_getsockname_open":
line 170: Assertion `(ssize_t)((ret)) == (ssize_t)((0))' failed.
got value: -1
should be: 0
Group "basic_getsockname": [FAILED]
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-01 09:09:25 +09:00
chao an
3a653c1d5e
net/usrsock: read from the closed remote should return EOF
...
fix usrsock remote_disconnect fail:
nsh> usrsocktest
...
Testing group "remote_disconnect" =>
[TEST ASSERT FAILED!]
In function "receive":
line 497: Assertion `(ssize_t)((ret)) == (ssize_t)((0))' failed.
got value: -1
should be: 0
Group "remote_disconnect": [FAILED]
...
Reference:
RECV(2)
NAME
recv, recvfrom, recvmsg - receive a message from a socket
...
RETURN VALUE
...
When a stream socket peer has performed an orderly shutdown,
the return value will be 0 (the traditional "end-of-file" return).
Datagram sockets in various domains (e.g., the UNIX and Internet domains)
permit zero-length datagrams. When such a datagram is received, the return value is 0.
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-01 08:48:26 +09:00
chao an
6f27c29ce5
net/usrsock: Change xid from uint64_t to uint32_t
...
follow the below change:
-----------------------------------------------
commit 0334819742
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date: Mon Aug 22 05:10:47 2022 +0800
net/usrsock: Change xid from uint64_t to uint32_t
by generating the new xid for each transaction
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: chao an <anchao@xiaomi.com>
2022-08-31 19:01:29 +02:00
chao.an
162fcd10ca
net: cleanup pvconn reference to avoid confuse
...
More reference:
https://github.com/apache/incubator-nuttx/pull/5252
https://github.com/apache/incubator-nuttx/pull/5434
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 20:58:11 +08:00
chao.an
ea621599fd
net: remove pvconn reference from all devif callback
...
Do not use 'pvconn' argument to get the connection pointer since
pvconn is normally NULL for some events like NETDEV_DOWN.
Instead, the connection pointer can be reliably obtained from the
corresponding private pointer.
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 20:58:11 +08:00
Xiang Xiao
0334819742
net/usrsock: Change xid from uint64_t to uint32_t
...
by generating the new xid for each transaction
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-23 12:16:33 -03:00
Xiang Xiao
697e2a333b
net/usrsock: Remove dev field from usrsockdev_s
...
since this field isn't really used at all
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-22 17:49:51 +03:00
Gustavo Henrique Nihei
3948736c41
net: Convert DEBUGASSERT(false) into more intuitive DEBUGPANIC()
...
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-07-14 12:08:45 +08:00
zhanghongyu
4c693239c0
fix: usrsock iovec_do skip empty iov
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-04-14 02:47:31 +08:00
zhanghongyu
f60480a5db
rpmsg_usrsock: Support the wireless ioctl which contain pointer 1/2
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-04-14 02:47:31 +08:00
Jiuzhu Dong
d87cf8d4ca
fs/poll: change format for type pollevent_t
...
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-07 12:14:06 +08:00