Commit Graph

81 Commits

Author SHA1 Message Date
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
zhanghongyu
451c53daa4 usrsock: Move event field to usrsock_message_common_s
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-04-03 11:38:50 +09:00
Xiang Xiao
7598070508 net: Remove the unnecessary initialization code
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-12 19:24:17 +02:00
chao.an
3fce144aeb net/inet: move recv/send timeout into socket_conn_s
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
99cde13a11 net/inet: move socket flags into socket_conn_s
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
f7bf28deac net/usrsock: replace the common connect prologue
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
086fb829fd net/usrsock: fix build warning
usrsock/usrsock_sockif.c:72:3: warning:
initialization of ‘int (*)(struct socket **)’ from incompatible pointer type
‘int (*)(struct socket *, int,  void *, size_t)’ {aka ‘int (*)(struct socket *, int,  void *, long unsigned int)’} [-Wincompatible-pointer-types]
   72 |   usrsock_ioctl               /* si_ioctl */
      |   ^~~~~~~~~~~~~

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-19 12:09:53 +01:00
chao.an
4603d108be net/usrsock: add support for CONFIG_NET_ALLOC_CONNS
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-05 12:39:00 +08:00
chao.an
cbe9352f41 net/usrsock: remove the connections limit
replace xid type to uint64_t to avoid connections limit

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-05 12:38:42 +08:00
Xiang Xiao
43c28c4456 net/usrsock: Fix the compile warning
In file included from usrsock/usrsock_bind.c:32:
usrsock/usrsock_bind.c: In function ‘usrsock_bind’:
usrsock/usrsock_bind.c:183:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  183 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                            |
      |                                                            ssize_t {aka long int}
usrsock/usrsock_bind.c:183:54: note: format string is defined here
  183 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                     ~^
      |                                                      |
      |                                                      int
      |                                                     %ld
CC:  usrsock/usrsock_connect.c
CC:  usrsock/usrsock_dev.c
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c: In function ‘usrsockdev_handle_event’:
usrsock/usrsock_dev.c:488:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  488 |             nwarn("message too short, %d < %d.\n", len, sizeof(*hdr));
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                    |
      |                                                    size_t {aka long unsigned int}
usrsock/usrsock_dev.c:488:40: note: format string is defined here
  488 |             nwarn("message too short, %d < %d.\n", len, sizeof(*hdr));
      |                                       ~^
      |                                        |
      |                                        int
      |                                       %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c:488:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
  488 |             nwarn("message too short, %d < %d.\n", len, sizeof(*hdr));
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ~~~~~~~~~~~~
      |                                                         |
      |                                                         long unsigned int
usrsock/usrsock_dev.c:488:45: note: format string is defined here
  488 |             nwarn("message too short, %d < %d.\n", len, sizeof(*hdr));
      |                                            ~^
      |                                             |
      |                                             int
      |                                            %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c: In function ‘usrsockdev_handle_datareq_response’:
usrsock/usrsock_dev.c:657:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  657 |       nwarn("%dth buffer not large enough (need: %d, have: %d).\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
  660 |             conn->resp.datain.iov[iovpos].iov_len);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                          |
      |                                          size_t {aka long unsigned int}
usrsock/usrsock_dev.c:657:61: note: format string is defined here
  657 |       nwarn("%dth buffer not large enough (need: %d, have: %d).\n",
      |                                                            ~^
      |                                                             |
      |                                                             int
      |                                                            %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c:678:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  678 |           nwarn("%dth buffer not large enough "
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
  682 |                 conn->resp.datain.iov[iovpos].iov_len);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                              |
      |                                              size_t {aka long unsigned int}
usrsock/usrsock_dev.c:679:45: note: format string is defined here
  679 |                 "(need: %" PRId32 ", have: %d).\n",
      |                                            ~^
      |                                             |
      |                                             int
      |                                            %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c: In function ‘usrsockdev_handle_req_response’:
usrsock/usrsock_dev.c:745:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  745 |       nwarn("message too short, %d < %d.\n", len, hdrlen);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                              |
      |                                              size_t {aka long unsigned int}
usrsock/usrsock_dev.c:745:34: note: format string is defined here
  745 |       nwarn("message too short, %d < %d.\n", len, hdrlen);
      |                                 ~^
      |                                  |
      |                                  int
      |                                 %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c: In function ‘usrsockdev_write’:
usrsock/usrsock_dev.c:858:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  858 |           nwarn("message too short, %d < %d.\n", len,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                  |
      |                                                  size_t {aka long unsigned int}
usrsock/usrsock_dev.c:858:38: note: format string is defined here
  858 |           nwarn("message too short, %d < %d.\n", len,
      |                                     ~^
      |                                      |
      |                                      int
      |                                     %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c:858:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
  858 |           nwarn("message too short, %d < %d.\n", len,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  859 |                 sizeof(struct usrsock_message_common_s));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                 |
      |                 long unsigned int
usrsock/usrsock_dev.c:858:43: note: format string is defined here
  858 |           nwarn("message too short, %d < %d.\n", len,
      |                                          ~^
      |                                           |
      |                                           int
      |                                          %ld
CC:  usrsock/usrsock_getpeername.c
In file included from usrsock/usrsock_getpeername.c:32:
usrsock/usrsock_getpeername.c: In function ‘usrsock_getpeername’:
usrsock/usrsock_getpeername.c:190:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  190 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                            |
      |                                                            ssize_t {aka long int}
usrsock/usrsock_getpeername.c:190:54: note: format string is defined here
  190 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                     ~^
      |                                                      |
      |                                                      int
      |                                                     %ld
CC:  usrsock/usrsock_event.c
CC:  usrsock/usrsock_getsockname.c
In file included from usrsock/usrsock_getsockname.c:32:
usrsock/usrsock_getsockname.c: In function ‘usrsock_getsockname’:
usrsock/usrsock_getsockname.c:190:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  190 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                            |
      |                                                            ssize_t {aka long int}
usrsock/usrsock_getsockname.c:190:54: note: format string is defined here
  190 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                     ~^
      |                                                      |
      |                                                      int
      |                                                     %ld
CC:  usrsock/usrsock_getsockopt.c
CC:  usrsock/usrsock_poll.c
CC:  usrsock/usrsock_recvmsg.c
In file included from usrsock/usrsock_recvmsg.c:32:
usrsock/usrsock_recvmsg.c: In function ‘usrsock_recvmsg’:
usrsock/usrsock_recvmsg.c:321:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  321 |               nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                                    |
      |                                                                    ssize_t {aka long int}
usrsock/usrsock_recvmsg.c:321:62: note: format string is defined here
  321 |               nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                             ~^
      |                                                              |
      |                                                              int
      |                                                             %ld
In file included from usrsock/usrsock_recvmsg.c:32:
usrsock/usrsock_recvmsg.c:343:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  343 |                   nerr("net_timedwait errno: %d\n", ret);
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                     |
      |                                                     ssize_t {aka long int}
usrsock/usrsock_recvmsg.c:343:47: note: format string is defined here
  343 |                   nerr("net_timedwait errno: %d\n", ret);
      |                                              ~^
      |                                               |
      |                                               int
      |                                              %ld
In file included from usrsock/usrsock_recvmsg.c:32:
usrsock/usrsock_recvmsg.c:384:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  384 |           nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                                |
      |                                                                ssize_t {aka long int}
usrsock/usrsock_recvmsg.c:384:58: note: format string is defined here
  384 |           nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %ld
CC:  usrsock/usrsock_sendmsg.c
In file included from usrsock/usrsock_sendmsg.c:32:
usrsock/usrsock_sendmsg.c: In function ‘usrsock_sendmsg’:
usrsock/usrsock_sendmsg.c:302:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  302 |               nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                                    |
      |                                                                    ssize_t {aka long int}
usrsock/usrsock_sendmsg.c:302:62: note: format string is defined here
  302 |               nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                             ~^
      |                                                              |
      |                                                              int
      |                                                             %ld
In file included from usrsock/usrsock_sendmsg.c:32:
usrsock/usrsock_sendmsg.c:324:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  324 |                   nerr("net_timedwait errno: %d\n", ret);
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                     |
      |                                                     ssize_t {aka long int}
usrsock/usrsock_sendmsg.c:324:47: note: format string is defined here
  324 |                   nerr("net_timedwait errno: %d\n", ret);
      |                                              ~^
      |                                               |
      |                                               int
      |                                              %ld
In file included from usrsock/usrsock_sendmsg.c:32:
usrsock/usrsock_sendmsg.c:364:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  364 |           nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                                |
      |                                                                ssize_t {aka long int}
usrsock/usrsock_sendmsg.c:364:58: note: format string is defined here
  364 |           nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %ld

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-03 11:19:32 +08:00
chao.an
1e83c83bf3 net/usrsock: increase the send/recv() length limit to UINT32_MAX
change request type to uint32_t to the impove the throughput

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-21 03:14:25 -06:00
Alin Jerpelea
4ca25d8a4d net: usrsock: Haltian Ltd: update licenses to Apache
Gregory Nutt has submitted the SGA
Haltian Ltd has submitted the SGA

as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-11-15 06:49:32 -06:00
Alexander Lunev
36fbedcbfc net/devif/devif_callback.c: corrected the connection event list to work as FIFO instead of LIFO.
In case of enabled packet forwarding mode, packets were forwarded in a reverse order
because of LIFO behavior of the connection event list.
The issue exposed only during high network traffic. Thus the event list started to grow
that resulted in changing the order of packets inside of groups of several packets
like the following: 3, 2, 1, 6, 5, 4, 8, 7 etc.

Remarks concerning the connection event list implementation:
* Now the queue (list) is FIFO as it should be.
* The list is singly linked.
* The list has a head pointer (inside of outer net_driver_s structure),
  and a tail pointer is added into outer net_driver_s structure.
* The list item is devif_callback_s structure.
  It still has two pointers to two different list chains (*nxtconn and *nxtdev).
* As before the first argument (*dev) of the list functions can be NULL,
  while the other argument (*list) is effective (not NULL).
* An extra (*tail) argument is added to devif_callback_alloc()
  and devif_conn_callback_free() functions.
* devif_callback_alloc() time complexity is O(1) (i.e. O(n) to fill the whole list).
* devif_callback_free() time complexity is O(n) (i.e. O(n^2) to empty the whole list).
* devif_conn_event() time complexity is O(n).
2021-09-18 21:01:39 -05:00
jordi
b87333bae8 Kconfig: remove empty help sections
To avoid the setconfig warning: "has 'help' but empty help text"
2021-07-23 02:32:19 -07:00
chao.an
e506b2a52c usrsock/recv: guarantee all data is received before close
adjust the close sequence to avoid data discard

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-07 08:40:55 +09:00
Alin Jerpelea
8975a65197 net: fix nxstyle errors
fix errors reported by nxstyle

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-04-02 11:12:25 -05:00
chao.an
03f899f302 net/usrsock: add send multi-elements support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-23 00:44:37 -07:00
Gustavo Henrique Nihei
330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +08:00
Peter Bee
e223f60c09 net/socket: move si_send/recv into sendmsg/recvmsg
Implement si_send/sendto/recvfrom with si_sendmsg/recvmsg, instead of
the other way round.

Change-Id: I7b858556996e0862df22807a6edf6d7cfe6518fc
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2021-03-05 04:46:13 -08:00
Juha Niskanen
de1ad1fdb3 net: fix typos, incorrect comments, nxstyle
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-12-13 09:06:28 -06:00
YAMAMOTO Takashi
dbe389a6bd net/usrsock/usrsock_dev.c: Fix syslog formats 2020-11-27 05:18:57 -06:00
Juha Niskanen
366e8afdb1 net/usrsock: fix outputted function name in debug prints
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-09-21 10:36:31 -03:00
Xiang Xiao
b5f429c88b Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-22 17:37:21 -06:00
Xiang Xiao
ae356001cf Change all files come from Xiaomi/Pinecone to Apache License 2.0
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-22 17:37:21 -06:00
SPRESENSE
8f39b20488 net/usrsock: Fix recv() couldn't peek data
Fix a bug that recv() couldn't peek receive data.
recv() would be failed by previous recv() call with MSG_PEEK.
2020-07-30 20:58:15 -05:00
SPRESENSE
d2f75467b5 net/usrsock: Add flags to sendto/recvfrom in usrsock
Add flags argument into sendto() and recvfrom() APIs for MSG_* flags can
handling in the daemon.

However, MSG_DONTWAIT should process in usrsock, so it unnecessary to pass to
the daemon like O_NONBLOCK.
2020-07-29 09:40:51 +02:00
Kazuya Hioki
822061a3d0 net: Fix dupulicated NET_USRSOCK in Kconfig
Reviewed-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
Signed-off-by: Kazuya Hioki <Kazuya.Hioki@sony.com>
2020-07-19 20:05:50 -07:00
Gregory Nutt
57bc329aac Run nxstyle all .c and .h files modified by PR. 2020-05-17 14:01:00 -03:00
Gregory Nutt
a569006fd8 sched/: Make more naming consistent
Rename various functions per the quidelines of https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+OS+Internal+Functions

    nxsem_setprotocol -> nxsem_set_protocol
    nxsem_getprotocol -> nxsem_get_protocol
    nxsem_getvalue -> nxsem_get_value
2020-05-17 14:01:00 -03:00
Xiang Xiao
5b839061f9 net/usrsock: fix error: variable 'pos' is used uninitialized
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-29 07:10:44 -06:00
Gregory Nutt
97339e47f1 Check return from nxsem_wait_initialize()
Resolution of Issue 619 will require multiple steps, this part of the first step in that resolution:  Every call to nxsem_wait_uninterruptible() must handle the return value from nxsem_wait_uninterruptible properly.  This commit is only for those files under graphics/, mm/, net/, sched/, wireless/bluetooth.

Still to do:  Files under fs/, drivers/, and arch.  The last is 116 files and will take some effort.
2020-03-29 20:11:10 +01:00
Xiang Xiao
cde88cabcc Run codespell -w with the latest dictonary again
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-02-23 22:27:46 +01:00
Xiang Xiao
f7ef08cdc1 net/usrsock: Don't return -ESHUTDOWN even usrsockdev_is_opened return false
since usrsock_conn_s::resp::result contain more detailed info and fix the below error in usrsocktest:
Testing group "WakeWithSignal" =>
	[TEST ASSERT FAILED!]
		In function "do_usrsock_blocking_connect_thread":
		line 200: Assertion `(ssize_t)((*get_errno_ptr())) == (ssize_t)((test_abort ? 113 : 4))' failed.
			got value: 110
			should be: 113
	[TEST ASSERT FAILED!]
		In function "do_usrsock_blocking_connect_thread":
		line 200: Assertion `(ssize_t)((*get_errno_ptr())) == (ssize_t)((test_abort ? 113 : 4))' failed.
			got value: 110
			should be: 113
	[TEST ASSERT FAILED!]
		In function "do_usrsock_blocking_connect_thread":
		line 200: Assertion `(ssize_t)((*get_errno_ptr())) == (ssize_t)((test_abort ? 113 : 4))' failed.
			got value: 110
			should be: 113
	[TEST ASSERT FAILED!]
		In function "do_wake_test":
		line 567: Assertion `(bool)((usrsocktest_test_failed)) == (bool)(false)' failed.
			got value: 1
			should be: 0
	Group "WakeWithSignal": [FAILED]
2020-02-22 07:33:01 -06:00
chao.an
c65d8e6a23 net/socket: add MSG_DONTWAIT support
MSG_DONTWAIT (since Linux 2.2)
  Enables nonblocking operation; if the operation would block, the
  call fails with the error EAGAIN or EWOULDBLOCK. This provides
  similar behavior to setting the O_NONBLOCK flag (via the fcntl(2)
  F_SETFL operation), but differs in that MSG_DONTWAIT is a per-call
  option, whereas O_NONBLOCK is a setting on the open file description
  (see open(2)), which will affect all threads in the calling process
  and as well as other processes that hold file descriptors referring
  to the same open file description.
2020-02-19 12:21:28 -06:00
Xiang Xiao
5c80b94820 Replace #include <semaphore.h> to #include <nuttx/semaphore.h>
Since the kernel side should call nxsem_xxx instead and remove the unused inclusion
2020-02-01 08:27:30 -06:00
patacongo
3a3539f2be net/: Fix some new problems found by the current nxstyle with .c files in the net/ directory. (#92) 2020-01-13 21:26:04 +01:00
Gregory Nutt
98f431d8d8 net/: Run all .c files under net/ through tools/nxstyle and fix all resulting complaints. 2020-01-11 13:41:33 -03:00
Xiang Xiao
5c5c08efcd network: simplify the timeout process logic
1.Consolidate absolute to relative timeout conversion into one place(_net_timedwait)
2.Drive the wait timeout logic by net_timedwait instead of devif_timer
This patch help us remove devif_timer(period tick) to save the power in the future.

Change-Id: I534748a5d767ca6da8a7843c3c2f993ed9ea77d4
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-01-11 08:24:49 -06:00
Juha Niskanen
260af07717 net/usrsock/usrsock_dev.c: Fix uninitialized return value introduced in 6a3c2ade. 2020-01-09 07:31:40 -06:00
Xiang Xiao
6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Xiang Xiao
90c52e6f8f Squashed commit of the following:
Author: Gregory Nutt <gnutt@nuttx.org>

    Run all .h and .c files modified in last PR through nxstyle.

Author: Xiang Xiao <xiaoxiang@xiaomi.com>

    Net cleanup (#17)

    * Fix the semaphore usage issue found in tcp/udp

    1. The count semaphore need disable priority inheritance
    2. Loop again if net_lockedwait return -EINTR
    3. Call nxsem_trywait to avoid the race condition
    4. Call nxsem_post instead of sem_post

    * Put the work notifier into free list to avoid the heap fragment in the long run.  Since the allocation strategy is encapsulated internally, we can even refine the implementation later.

    * Network stack shouldn't allocate memory in the poll implementation to avoid the heap fragment in the long run, other modification include:

    1. Select MM_IOB automatically since ICMP[v6] socket can't work without the read ahead buffer
    2. Remove the net lock since xxx_callback_free already do the same thing
    3. TCP/UDP poll should work even the read ahead buffer isn't enabled at all

    * Add NET_ prefix for UDP_NOTIFIER and TCP_NOTIFIER option to align with other UDP/TCP option convention

    * Remove the unused _SF_[IDLE|ACCEPT|SEND|RECV|MASK] flags since there are code to set/clear these flags, but nobody check them.
2019-12-31 09:26:14 -06:00
Xiang Xiao
8214973f80 net/usrsock/usrsock_poll.c: usrsock_pollsetup() doesn't need logic and with fds->events since line 279 will do the same thing:
fds->revents &= (~(POLLOUT | POLLIN) | info->fds->events);
2019-11-25 11:44:58 -06:00
Gregory Nutt
3b275fcf4e net/: Run nxstyle against all C files. 2019-10-25 11:31:42 -06:00
Gregory Nutt
6266e067e9 net/: Re-order the content of all address-family socket 'connection' structures so that they begin with a comomon prologue. This permits better use of logic for different address family types. 2019-09-01 08:47:01 -06:00
Gregory Nutt
1346f29151 net/: Fix alignment and spacing problems found by tools/nxstyle. 2019-07-02 18:02:23 -06:00
Masayuki Ishikawa
fd387b6b8c Merged in masayuki2009/nuttx.nuttx/fix_usrsock (pull request #879)
net/usrsock: Fix debug logs and remove DEBUGASSERT from usrsockdev_do_request()

In a client mode, socket() will be the first request for usrsockdev_do_request().
However, in a server mode, the first request to accepted sockets will be recv()
or others which depend on applications. So I think we should remove this
DEBUGASSERT from usrsockdev_do_request().

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2019-06-03 11:43:43 +00:00