Commit Graph

5897 Commits

Author SHA1 Message Date
Xiang Xiao
43bda3282f net/arp: Move arp_ipin and arp_out to private header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-04 20:39:21 +08:00
Xiang Xiao
c6e9edcbb6 net: Rename arp_arpin to arp_input
align with other similar function(e.g. ipv4_input and ipv6_input)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-04 20:39:21 +08:00
chao an
62004a28a6 net/d_buf: remove d_buf reference from l3/l4
l3/l4 stack will decouple the reference of d_buf gradually, Only legacy
devices still retain d_buf support, new net devices will use d_iob

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-04 20:37:14 +08:00
chao an
34d2cde8a8 net/l2/l3/l4: add support of iob offload
1. Add new config CONFIG_NET_LL_GUARDSIZE to isolation of l2 stack,
   which will benefit l3(IP) layer for multi-MAC(l2) implementation,
   especially in some NICs such as celluler net driver.

new configuration options: CONFIG_NET_LL_GUARDSIZE

CONFIG_NET_LL_GUARDSIZE will reserved l2 buffer header size of
network buffer to isolate the L2/L3 (MAC/IP) data on network layer,
which will be beneficial to L3 network layer protocol transparent
transmission and forwarding

------------------------------------------------------------
Layout of frist iob entry:

        iob_data (aligned by CONFIG_IOB_ALIGNMENT)
            |
            |                  io_offset(CONFIG_NET_LL_GUARDSIZE)
            |                                |
            -------------------------------------------------
      iob   |            Reserved            |    io_len    |
            -------------------------------------------------

-------------------------------------------------------------
Layout of different NICs implementation:

        iob_data (aligned by CONFIG_IOB_ALIGNMENT)
            |
            |                 io_offset(CONFIG_NET_LL_GUARDSIZE)
            |                                |
            -------------------------------------------------
 Ethernet   |       Reserved    | ETH_HDRLEN |    io_len    |
            ---------------------------------|---------------
 8021Q      |   Reserved  | ETH_8021Q_HDRLEN |    io_len    |
            ---------------------------------|---------------
 ipforward  |            Reserved            |    io_len    |
            -------------------------------------------------

--------------------------------------------------------------------

2. Support iob offload to l2 driver to avoid unnecessary memory copy

Support send/receive iob vectors directly between the NICs and l3/l4
stack to avoid unnecessary memory copies, especially on hardware that
supports Scatter/gather, which can greatly improve performance.

new interface to support iob offload:

  ------------------------------------------
  |    IOB version     |     original      |
  |----------------------------------------|
  |  devif_iob_poll()  |   devif_poll()    |
  |       ...          |       ...         |
  ------------------------------------------

--------------------------------------------------------------------

1> NIC hardware support Scatter/gather transfer

TX:

                tcp_poll()/udp_poll()/pkt_poll()/...(l3|l4)
                           /              \
                          /                \
devif_poll_[l3|l4]_connections()     devif_iob_send() (nocopy:udp/icmp/...)
           /                                   \      (copy:tcp)
          /                                     \
  devif_iob_poll("NIC"_txpoll)                callback() // "NIC"_txpoll
                                                  |
                            dev->d_iob:           |
                                                ---------------         ---------------
                             io_data       iob1 |  |          |    iob3 |  |          |
                                    \           ---------------         ---------------
                                  ---------------  |       --------------- |
                             iob0 |  |          |  |  iob2 |  |          | |
                                  ---------------  |       --------------- |
                                     \             |          /           /
                                        \          |       /           /
                                   ----------------------------------------------
                    NICs io vector |    |    |    |    |    |    |    |    |    |
                                   ----------------------------------------------

RX:

  [tcp|udp|icmp|...]ipv[4|6]_data_handler()(iob_concat/append to readahead)
                    |
                    |
      [tcp|udp|icmp|...]_ipv[4|6]_in()/...
                    |
                    |
          pkt/ipv[4/6]_input()/...
                    |
                    |
     NICs io vector receive(iov_base to each iobs)

--------------------------------------------------------------------

2> CONFIG_IOB_BUFSIZE is greater than MTU:

TX:

"(CONFIG_IOB_BUFSIZE) > (MAX_NETDEV_PKTSIZE + CONFIG_NET_GUARDSIZE + CONFIG_NET_LL_GUARDSIZE)"

                tcp_poll()/udp_poll()/pkt_poll()/...(l3|l4)
                           /              \
                          /                \
devif_poll_[l3|l4]_connections()     devif_iob_send() (nocopy:udp/icmp/...)
           /                                   \      (copy:tcp)
          /                                     \
  devif_iob_poll("NIC"_txpoll)                callback() // "NIC"_txpoll
                                                  |
                                             "NIC"_send()
                          (dev->d_iob->io_data[CONFIG_NET_LL_GUARDSIZE - NET_LL_HDRLEN(dev)])

RX:

  [tcp|udp|icmp|...]ipv[4|6]_data_handler()(iob_concat/append to readahead)
                    |
                    |
      [tcp|udp|icmp|...]_ipv[4|6]_in()/...
                    |
                    |
          pkt/ipv[4/6]_input()/...
                    |
                    |
     NICs io vector receive(iov_base to io_data)

--------------------------------------------------------------------

3> Compatible with all old flat buffer NICs

TX:
                tcp_poll()/udp_poll()/pkt_poll()/...(l3|l4)
                           /              \
                          /                \
devif_poll_[l3|l4]_connections()     devif_iob_send() (nocopy:udp/icmp/...)
           /                                   \      (copy:tcp)
          /                                     \
  devif_iob_poll(devif_poll_callback())  devif_poll_callback() /* new interface, gather iobs to flat buffer */
       /                                           \
      /                                             \
 devif_poll("NIC"_txpoll)                     "NIC"_send()(dev->d_buf)

RX:

  [tcp|udp|icmp|...]ipv[4|6]_data_handler()(iob_concat/append to readahead)
                    |
                    |
      [tcp|udp|icmp|...]_ipv[4|6]_in()/...
                    |
                    |
               netdev_input()  /* new interface, Scatter/gather flat/iob buffer */
                    |
                    |
          pkt/ipv[4|6]_input()/...
                    |
                    |
    NICs io vector receive(Orignal flat buffer)

3. Iperf passthrough on NuttX simulator:

  -------------------------------------------------
  |  Protocol      | Server | Client |            |
  |-----------------------------------------------|
  |  TCP           |  813   |   834  |  Mbits/sec |
  |  TCP(Offload)  | 1720   |  1100  |  Mbits/sec |
  |  UDP           |   22   |   757  |  Mbits/sec |
  |  UDP(Offload)  |   25   |  1250  |  Mbits/sec |
  -------------------------------------------------

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-03 11:47:04 +08:00
Peter Bee
c26fd6565d drivers/video: enhance v4l2 compatibility
Add common BSD v4l2 header file
Complete ioctls according to standard v4l2 drivers

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2022-12-03 02:48:01 +08:00
田昕
cb0418676f include/nuttx:add linux-like notifier
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-12-02 22:56:22 +08:00
Peter Bee
87e16c3694 drivers/video: add support for yuv420p
Add calc functions for buffer size (yuv420p is 6Byte/4px)

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2022-12-02 13:18:20 +08:00
Peter Bee
365b1f4bb8 drivers/video: add support for YUYV format
Add YUYV format which is used by most USB Cameras

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2022-12-02 13:18:20 +08:00
FASTSHIFT
0ae242aa8d drivers/video/fb: add poll support
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
2022-12-01 15:08:03 +08:00
chao an
4281acdb83 net/chksum: move all chksum api declarations to common header
The following APIs need to be overriden by the arch after enabling
CONFIG_NET_ARCH_CHKSUM, move these functions to the common header
file to avoid prototype conflicts

uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len);
uint16_t net_chksum(FAR uint16_t *data, uint16_t len);
uint16_t ipv4_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto);
uint16_t ipv6_upperlayer_chksum(FAR struct net_driver_s *dev,
                                uint8_t proto, unsigned int iplen);
uint16_t ipv4_chksum(FAR struct ipv4_hdr_s *ipv4);

Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-30 15:08:14 +08:00
liyi
391b501639 net: extract l3 header build code into new functions
Signed-off-by: liyi <liyi25@xiaomi.com>
2022-11-29 18:36:15 +08:00
Masayuki Ishikawa
8b4ffb8d3e virtio: Add virtio drivers
Summary:
- This commit adds virtio-mmio and virtio-net drivers

Impact:
- None (new drivers)

Testing:
- Tested with rv-virt (will be updated later) with QEMU-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-11-29 13:16:44 +08:00
chao an
cdaa2ba8d4 mm/iob: new function iob_update_pktlen() to update packet length of the iob
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-29 13:16:23 +08:00
chao an
b452e2fddf mm/iob: new function iob_reserve() to adjust headroom offset
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-29 13:16:23 +08:00
田昕
1d8d6e5ed2 drivers/syslog:support stream as syslog backend.
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-11-28 20:19:00 +08:00
Xiang Xiao
af2b491420 driver/segger: Move SYSLOG_RTT config from drivers/syslog to drivers/segger
and remove include/nuttx/syslog/syslog_rtt.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 23:10:39 +01:00
Xiang Xiao
fd268d7123 drivers/segger: Add STREAM_RTT option
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 23:10:39 +01:00
Xiang Xiao
df6666ab5e libc/stream: Rename lib_stream_[put|get]c to lib_stream_[put|get]
keep the macro consistent with the callback name

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-27 22:59:21 +01:00
yinshengkai
126b33c488 drivers/segger: add Segger RTT stream support
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-11-27 23:39:20 +08:00
chao an
8850dee746 net/devif: move preprocess of txpoll into common code
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-27 12:11:12 +08:00
yinshengkai
511070c300 include: unified stream read and write interface
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-11-25 21:41:51 +08:00
Xiang Xiao
5fd1379d3f syslog: Move syslog stream to libc like other stream implementation
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-25 01:46:31 +08:00
Xiang Xiao
90c641d4c1 libc/streams: Add lib_[si]gets_t callback
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-25 01:07:12 +08:00
Xiang Xiao
5ee1da4211 libc/streams: Ensure the different stream type has the common layout
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-25 01:07:12 +08:00
田昕
28739b8b8a libc/stream:Add mtd backend stream.
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-11-24 12:07:10 +08:00
dongjiuzhu1
ccf0c3566e net/local: support cmd SO_PEERCRED
the credentials of the peer process connected to this socket.
refs:https://man7.org/linux/man-pages/man7/unix.7.html

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 15:01:54 +08: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
zhangyuan21
d8051ba979 nuttx/sched: merge up_block_task and up_unblock_task 2022-11-22 22:59:08 +08:00
wangbowen6
25bfd437fe fs_epoll: support extend the epoll dynamicly.
1. epoll_ctl(EPOLL_CTL_ADD) support extend the epoll
   events dynamicly;
2. enhance the epoll performance by moving some poll setup
   and teardown process to the EPOLL_CTL_ADD/DEL/MOD;

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-11-22 21:08:56 +08:00
Ville Juven
f8a6ec2cdf mm/shm: Fix ARCH_SHM_VEND
The last address is base+size-1
2022-11-22 08:54:34 +01:00
Ville Juven
48b9a8d6f4 mm/shm: Move the vma allocators to separate functions
This will allow changing the underlying backend, i.e. granule allocator,
to something more efficient, if this is needed later.

Also, it gives easier access to the common SHM book keeping.
2022-11-22 08:54:34 +01:00
Ville Juven
458ff380e5 mm/gran: Allow run-time execution of gran_reserve
User can ask for specific granules to be allocated.

This is useful for one thing only: when mmap() is called for a specific
vaddr. The parameter itself is non-sensical, this is just to satisfy
the POSIX standard.
2022-11-22 08:54:34 +01:00
zhangyuan21
5c1b518314 nuttx/sched: move reprioritize process to public function 2022-11-22 15:29:00 +09:00
zhangyuan21
08f7152d9f nuttx/sched: remove nxsched_remove_readytorun from up_block_task
It takes about 10 cycles to obtain the task list according to the task
status. In most cases, we know the task status, so we can directly
add the task from the specified task list to reduce time consuming.
2022-11-22 15:29:00 +09:00
zhangyuan21
e54b602208 nuttx/sched: remove nxsched_remove_blocked from up_unblock_task
It takes about 10 cycles to obtain the task list according to the task
status. In most cases, we know the task status, so we can directly
delete the task from the specified task list to reduce time consuming.
2022-11-22 15:29:00 +09:00
Xiang Xiao
af2aa13873 phtread: Change stacksize type from long to size_t
follow the standard prototype:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstack.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-22 08:23:37 +09:00
Robert-Ionut Alexa
039262484a drivers/sensors: add LTR308 ambient light sensor
Add support for the LTR308 ambient light sensor through I2C. Currently,
the interrupt-driven mode of operation is not supported.

Signed-off-by: Robert-Ionut Alexa <robertalexa2000@gmail.com>
2022-11-21 23:48:52 +08:00
Xiang Xiao
1a942c3c31 Fix lcd/ili9225.c:388:46: error: shift count >= width of type
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-20 14:34:44 +01:00
qinwei1
ce95db46b9 include/nuttx/tls.h: add CXX extern define for tls
Summary:
   In order to use C functions in C++ code, "extern C"
needs to be defined in the C header file.
   Add "extern C" define for tls.h

Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2022-11-18 12:42:26 +08:00
qinwei1
8021dfece6 sched/task/task_getpid: getpid should return process id not thread id
Summary:
   implement the right semantics:
1. getpid should return the main thread id
2. gettid should return the current thread id

Refer to:
 https://github.com/apache/incubator-nuttx/issues/2499
 https://github.com/apache/incubator-nuttx/pull/2518

Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2022-11-17 17:58:08 +08:00
zhangyuan21
f27065cb9e sched/mqueue: make mqueue and mqueue sysv can disable separately 2022-11-16 20:03:40 +08:00
Simon Filgis
6376d90c3d In case of SAMV7 it is possible to overwrite the pwm output with 0 or 1 immediately. Changing the dutycycle to 0 or 100 will take effect only on end of cycle, which could be to late for some applications.
This solution adds a overwrite flag and value when updating the duty cycle.
2022-11-16 12:07:09 +08:00
David Sidrane
d05a5d16ee imxrt:Support TJ1103 PHY 2022-11-15 02:27:35 +08:00
anjiahao
a4563b8744 Fix the coding style and typo issue
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-14 09:34:04 +09:00
Andrés Sánchez Pascual
9f029194e1 sys: boardctl: Add more reset causes to enum
Signed-off-by: Andrés Sánchez Pascual <tito97_sp@hotmail.com>
2022-11-13 21:26:31 -03:00
Xiang Xiao
f52ad42425 Fix error: unknown attribute 'long_call' ignored [-Werror,-Wunknown-attributes]
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-13 22:35:19 +08:00
Xiang Xiao
6f33dd6ea0 mm/heap: Change TCB_FLAG_HEAPCHECK to TCB_FLAG_HEAP_CHECK
align with other flags naming convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-12 09:39:01 +01:00
Zhe Weng
8239ddeef4 net/nat: Add TCP entry expiration logic
Add TCP entry expiration logic for NAT, with entries changed from sq to dq for fast removal.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
b595430578 net: add basic NAT workflow
Add basic functions for NAT (NAPT), remaining some logic unimplemented (UDP, ICMP, port assignment, etc). NAT for TCP can work now (unless port conflicts).
Outbound: LAN ->  Forward  ->  NAT(only if targeting at WAN)  -> WAN
Inbound:  WAN ->  NAT(only from WAN, change dest) -> Forward  -> LAN

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
ligd
4501490302 hwspinlock: add hwspinlock driver for multi CPU
The design follow Linux kernel:
https://www.kernel.org/doc/html/latest/locking/hwspinlock.html

Signed-off-by: ligd <liguiding@pinecone.net>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-09 09:12:01 +01:00