Commit Graph

97 Commits

Author SHA1 Message Date
Petro Karashchenko 68902d8732 pid_t: unify usage of special task IDs
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-22 21:22:32 +08:00
Xiang Xiao 9c1fc8da4e net: Remove net_lockinitialize
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-12 19:24:17 +02:00
chao.an a92d5f622e net/ioballoc: add support of alloc with timeout net_iobtimedalloc()
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-17 21:27:39 +01:00
Petro Karashchenko 08043fb5bc net: unify FAR keyword usage for all net buffer memory mapped buffers
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-20 01:42:56 +08:00
Petro Karashchenko 9551de7115 net: use HTONS, NTOHS, HTONL, NTOHL macro in kernel code
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-18 10:59:47 +01:00
chao.an 3b69d09c80 net/udp/icmp: correct the unreadchable handling
Reference RFC1122:
https://datatracker.ietf.org/doc/html/rfc1122
----------------------------------------------

4.1.3  SPECIFIC ISSUES

  4.1.3.1  Ports

    If a datagram arrives addressed to a UDP port for which
    there is no pending LISTEN call, UDP SHOULD send an ICMP
    Port Unreachable message.

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-11-26 08:47:54 -06:00
Masayuki Ishikawa 3330543fe6 net: utils: Remove critical section for SMP in net_lock.c
Summary:
- The critical section was added in Mar 2018 to improve
  stability in SMP mode
- However, I noticed that this critical section is no longer
  needed

Impact:
- None

Testing:
- Tested with spresense:wifi_smp and spresense:rndis_smp

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-09-06 14:57:08 +08:00
YAMAMOTO Takashi 0272a16010 net_ioballoc: remove redundant critical section 2021-08-05 23:50:46 -07:00
Alin Jerpelea 08e5378b11 NuttX: Gregory Nutt: update licenses to Apache
Several licenses were missed in the initial work

David Sidrane has submitted the ICLA and we can migrate the licenses
 to Apache.

Gregory Nutt has submitted the SGA and we can migrate the licenses
 to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-04-03 04:20:31 -07:00
Alin Jerpelea 37d5c1b0d9 net: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can migrate the licenses
 to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-20 00:38:18 -08:00
Abdelatif Guettouche 6385408483 net/: Correct some comments.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-01-15 16:23:12 -05:00
Xiang Xiao 2956b8516b Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-10-20 01:45:06 -07:00
Xiang Xiao eb4121ce38 Change all 'Nuttx' to 'NuttX'
Unify the naming convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-10-20 01:45:06 -07:00
Peter van der Perk 55d9e5f7af net: Add SocketCAN support 2020-06-15 08:07:19 -06: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 c1b0aa118c Remove psock_send and sockfd_socket from net/socket/socket.h
Since both is already declared in include/nuttx/net/net.h and fix other minor issue in network socket layer.
2020-01-31 13:45:15 -06:00
Xiang Xiao 68951e8d72 Remove exra whitespace from files (#189)
* Remove multiple newlines at the end of files
* Remove the whitespace from the end of lines
2020-01-31 09:24:49 -06:00
Xiang Xiao b80fb6befc net/utils: Fix the wrong mask calculation in net_ipv6_pref2mask 2020-01-30 07:47:07 -06:00
Xiang Xiao 174df6b793 net/utils/net_dsec2tick.c: Rturn type should unsigned int 2020-01-30 07:45:14 -06:00
Xiang Xiao affc32c9d1 net/: Fix net checksum related issue
1. Remove the unused and unimplemented ipv6_chksum declaration
2. Update NET_ARCH_CHKSUM description to align with the implementation
3. Declare all checksum function prototype regardless CONFIG_NET_ARCH_CHKSUM
4. Remove the CONFIG_NET_ARCH_CHKSUM guard for tcp_ipv[4|6]_chksum
2020-01-30 07:44:36 -06: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
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
Gregory Nutt a52ceac13e net/: Now handles reception of IPv4 packets with larger IPv4 headers containing options. 2019-08-31 12:25:30 -06:00
Anthony Merlino 70404ed0dc Merged in antmerlino/nuttx/iobinstrumentation (pull request #1001)
Iobinstrumentation

* mm/iob: Introduces producer/consumer id to every iob call. This is so that the calls can be instrumented to monitor the IOB resources.

* iob instrumentation - Merges producer/consumer enumeration for simpler IOB user.

* fs/procfs: Starts adding support for /proc/iobinfo

* fs/procfs: Finishes first pass of simple IOB user stastics and /proc/iobinfo entry

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2019-08-16 22:42:25 +00:00
Gregory Nutt 1346f29151 net/: Fix alignment and spacing problems found by tools/nxstyle. 2019-07-02 18:02:23 -06:00
Gregory Nutt c999d12bba net/utils: net_lock() and net_restorelock() not return a value. That values is the standard zero on success; negated errno value on failure. This return value is only needed for -ECANCELED. That cancellation indication needs to ripple all the way back to the highest levels where the cancellation can be acted on. This commit only adds the return value; it does not add checking for the return values of net_lock() and net_restorelock() at higher levels. That is required too. 2019-04-14 09:37:25 -06:00
Gregory Nutt f6b00e1966 tools/nxstyle.c: Fix logic error that prevent detecion of '/' and '/=' as operators. net/: Minor updates resulting from testing tools/nxstyle. 2019-03-11 12:48:39 -06:00
Gregory Nutt 22de66d553 arch/arm/src/max326xx/max32660/max32660_wdt.c: Fix alarm delay calculation. 2018-11-21 17:54:36 -06:00
Gregory Nutt 33ed27ae65 Squashed commit of the following:
net/mld: Checksum calculation needs to know the full size of the IPv6 header, including the size of the extension headers.  The payload size in the IPv64 header must include the extension headers (not considered part of the header in this case).  Fixes a few additional errors in size, endian-ness and checksum calculations.  Wireshark now reports the the outgoing Report has a good checksum.

    net/mld/mld_query.c:  Add a cast to assure that the left shift does not overflow.
2018-11-05 08:56:07 -06:00
Gregory Nutt 88130a996a net/: Fixes for more coding standard issues detected by nxstyle. 2018-10-29 18:00:30 -06:00
Gregory Nutt 6571d4fa37 Update some comments. 2018-07-07 15:23:46 -06:00
Gregory Nutt 427b3b8fcb Squashed commit of the following:
net/utils:  return from net_breaklock() was being clobbered.
    net/:  Replace all calls to iob_alloc() with calls to net_ioballoc() which will release the network lock, if necessary.
    net/utils, tcp, include/net:  Separate out the special IOB allocation logic and place it in its own function.  Prototype is available in a public header file where it can also be used by network drivers.
    net/utils: net_timedwait() now uses new net_breaklock() and net_restorelock().
2018-07-07 08:26:13 -06:00
Gregory Nutt 75cc19ebb4 net/tcp: Fix a deadlock condition that can occur when (1) all network logic runs on a single work queue, (1) TCP write buffering is enabled, and (2) we run out of IOBs. In this case, the TCP write buffering logic was blocking on iob_alloc() with the network locked. Since the network was locked, the device driver polls that would provide take the write buffer data and release the IOBs could not execute. This fixes the problem by unlocking the network lock while waiting for the IOBs. 2018-07-06 19:49:05 -06:00
Gregory Nutt 22cd0d47fa This commit attempts remove some long standard confusion in naming and some actual problems that result from the naming confusion. The basic problem is the standard MTU does not include the size of the Ethernet header. For clarity, I changed the naming of most things called MTU to PKTSIZE. For example, CONFIG_NET_ETH_MTU is now CONFIG_NET_ETH_PKTSIZE.
This makes the user interface a little hostile.  People thing of an MTU of 1500 bytes, but the corresponding packet is really 1514 bytes (including the 14 byte Ethernet header).  A more friendly solution would configure the MTU (as before), but then derive the packet buffer size by adding the MAC header length.  Instead, we define the packet buffer size then derive the MTU.

The MTU is not common currency in networking.  On the wire, the only real issue is the MSS which is derived from MTU by subtracting the IP header and TCP header sizes (for the case of TCP).  Now it is derived for the PKTSIZE by subtracting the IP header, the TCP header, and the MAC header sizes.  So we should be all good and without the recurring 14 byte error in MTU's and MSS's.

Squashed commit of the following:

    Trivial update to fix some spacing issues.
    net/: Rename several macros containing _MTU to _PKTSIZE.
    net/: Rename CONFIG_NET_SLIP_MTU to CONFIG_NET_SLIP_PKTSIZE and similarly for CONFIG_NET_TUN_MTU.  These are not the MTU which does not include the size of the link layer header.  These are the full size of the packet buffer memory (minus any GUARD bytes).
    net/: Rename CONFIG_NET_6LOWPAN_MTU to CONFIG_NET_6LOWPAN_PKTSIZE and similarly for CONFIG_NET_TUN_MTU.  These are not the MTU which does not include the size of the link layer header.  These are the full size of the packet buffer memory (minus any GUARD bytes).
    net/: Rename CONFIG_NET_ETH_MTU to CONFIG_NET_ETH_PKTSIZE.  This is not the MTU which does not include the size of the link layer header.  This is the full size of the packet buffer memory (minus any GUARD bytes).
    net/: Rename the file d_mtu in the network driver structure to d_pktsize.  That value saved there is not the MTU.  The packetsize is the memory large enough to hold the maximum packet PLUS the size of the link layer header.  The MTU does not include the link layer header.
2018-07-04 14:10:40 -06:00
Masayuki Ishikawa 1d958980bd Merged in masayuki2009/nuttx.nuttx/fix_smp_bugs (pull request #615)
Fix SMP related bugs

* sched/sched: Fix a deadlock in SMP mode

    Two months ago, I introduced sched_tasklist_lock() and
    sched_tasklist_unlock() to protect tasklists in SMP mode.
    Actually, this change works pretty well for HTTP audio
    streaming aging test with lc823450-xgevk.

    However, I found a deadlock in the scheduler when I tried
    similar aging tests with DVFS autonomous mode where CPU
    clock speed changed based on cpu load. In this case, call
    sequences were as follows;

    cpu1: sched_unlock()->sched_mergepending()->sched_addreadytorun()->up_cpu_pause()
    cpu0: sched_lock()->sched_mergepending()

    To avoid this deadlock, I added sched_tasklist_unlock() when calling
    up_cpu_pause() and sched_addreadytorun(). Also, added
    sched_tasklist_lock() after the call.

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

* libc: Add critical section in lib_filesem.c for SMP

    To set my_pid into fs_folder atomically in SMP mode,
    critical section API must be used.

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

* mm: Add critical section in mm_sem.c for SMP

    To set my_pid into mm_folder atomically in SMP mode,
    critical section API must be used.

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

* net: Add critical section in net_lock.c for SMP

    To set my pid (me) into fs_folder atomically in SMP mode,
    critical section API must be used.

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

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2018-03-20 12:34:38 +00:00
Gregory Nutt b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Gregory Nutt 7cf88d7dbd Make sure that labeling is used consistently in all function headers. 2018-02-01 10:00:02 -06:00
Gregory Nutt cccc86da09 This change adds support for semi-standard IPPROTO_ICMP AF_INET datagram sockets. This replaces the old ad hoc, nonstandard way of implementing ping with a more standard, socket interface.
Squashed commit of the following:

    net/icmp:  Finishes off icmp_recvfrom().
    net/icmp:  Add readahead support for IPPROTO_ICMP sockets.
    net/icmp:  Add poll() support for IPPROTO_ICMP sockets.
    net/icmp:  Add a connection structure for IPPROTO_ICMP sockets.
    net/icmp:  Implements sendto for the IPPROTO_ICMP socket.
    net/icmp:  Move icmp_sendto() and icmp_recvfrom() to separate files.  They are likely to be complex (when they are implemented).
    net/icmp:  Hook IPPROTO_ICMP sockets into network.  Fix some naming collisions.  Still missing basic ICMP send/receive logic.
    configs: apps/system/ping current need poll() enabled.
    configs: All defconfig files that use to enable low-level support must now enabled CONFIG_SYSTEM_PING.
    net/icmp:  Adds basic build framework to support IPPROTO_ICMP sockets.
2017-10-23 08:45:12 -06:00
Gregory Nutt 29b5b3667f sched/semaphore: sem_timedwait() is a cancellation point and, hence, cannot be called from within the OS. Created nxsem_timedwait() that is equivalent but does not modify the errno and does not cause cancellation. All calls to sem_timedwait() change to calls to nxsem_timedwait() in the OS. 2017-10-05 07:24:54 -06:00
Gregory Nutt 9568600ab1 Squashed commit of the following:
This commit backs out most of commit b4747286b1.  That change was added because sem_wait() would sometimes cause cancellation points inappropriated.  But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.

    In the OS, all calls to sem_wait() changed to nxsem_wait().  nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.

    In all OS functions (not libraries), change sem_wait() to nxsem_wait().  This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.

    sched/semaphore:  Add the function nxsem_wait().  This is a new internal OS interface.  It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
2017-10-04 15:22:27 -06:00
Gregory Nutt 42a0796615 Squashed commit of the following:
sched/semaphore:  Add nxsem_post() which is identical to sem_post() except that it never modifies the errno variable.  Changed all references to sem_post in the OS to nxsem_post().

    sched/semaphore:  Add nxsem_destroy() which is identical to sem_destroy() except that it never modifies the errno variable.  Changed all references to sem_destroy() in the OS to nxsem_destroy().

    libc/semaphore and sched/semaphore:  Add nxsem_getprotocol() and nxsem_setprotocola which are identical to sem_getprotocol() and set_setprotocol() except that they never modifies the errno variable.  Changed all references to sem_setprotocol in the OS to nxsem_setprotocol().  sem_getprotocol() was not used in the OS
2017-10-03 15:35:24 -06:00
Gregory Nutt 83cdb0c552 Squashed commit of the following:
libc/semaphore:  Add nxsem_getvalue() which is identical to sem_getvalue() except that it never modifies the errno variable.  Changed all references to sem_getvalue in the OS to nxsem_getvalue().

    sched/semaphore:  Rename all internal private functions from sem_xyz to nxsem_xyz.  The sem_ prefix is (will be) reserved only for the application semaphore interfaces.

    libc/semaphore:  Add nxsem_init() which is identical to sem_init() except that it never modifies the errno variable.  Changed all references to sem_init in the OS to nxsem_init().

    sched/semaphore:  Rename sem_tickwait() to nxsem_tickwait() so that it is clear this is an internal OS function.

    sched/semaphoate:  Rename sem_reset() to nxsem_reset() so that it is clear this is an internal OS function.
2017-10-03 12:52:31 -06:00
Jussi Kivilinna 5beaad491a Fix net_lock returning ERROR when instead of real error code on failure. 2017-09-01 07:18:16 -06:00
Gregory Nutt afe137ffbf net_timedwait() and net_lockedwait() no longer return errors via errno but returned negated errno values like other internal OS functions. 2017-09-01 07:13:03 -06:00
Gregory Nutt 32a96bda6d IPv6 forwarding logic must decrement the TTL and drop the packet if the hop limit is exceeded. 2017-07-04 07:05:42 -06:00
Gregory Nutt f87d5a3f81 net/: Remove dangling space at the end of lines. 2017-06-28 13:32:19 -06:00
Masayuki Ishikawa 980b17d951 IPv6: Fix net_ipv6_pref2mask()
Signed-off-by: Masayuki Ishikawa <masayuki.ishikawa@gmail.com>
2017-05-18 20:26:24 +09:00
Gregory Nutt d5207efb5a Be consistent... Use Name: consistent in function headers vs Function: 2017-04-21 16:33:14 -06:00
Gregory Nutt 3367312401 6loWPAN: Forgot to add files with last commit. 2017-04-02 14:45:14 -06:00
Gregory Nutt 392c90b020 6loWPAN: Fix last checksum issues. Contiki 6loWPAN port is now complete (but completely untested) 2017-04-02 14:30:01 -06:00