Commit Graph

53 Commits

Author SHA1 Message Date
p-szafonimateusz
8723aa7125 drivers: fix gcc14 errors for virtio
fix gcc14 errors for virtio

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2024-09-16 11:25:40 -03:00
wangyongrong
639843ade3 virtio-pci: fix set virtio device features error
Should assgin back the feature to the vdev->features

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-09-15 02:22:16 +08:00
wangyongrong
b0d70b76cb virtio-pci.c: polling mode support
1. Some platforms do not support interrupt mode (PCI_MSI/MSIX),
so add polling mode support, so these platforms can also use virtio-pci;
2. In some cases, we do not want to use the interrupt for virtio driver
to avoid time jitter, so add the polling mode support;
3. If CONFIG_DRIVERS_VIRTIO_PCI_POLLING_PERIOD <= 0, interrupt mode.
   if CONFIG_DRIVERS_VIRTIO_PCI_POLLING_PERIOD > 0, polling mode.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-09-15 02:22:16 +08:00
wangyongrong
ee6bc2e7df virtio-pci: extract common part of virtio pci modern and leagcy
Extrace common part of virtio pci modern and legacy to virtio-pci to
reduce the duplicated code.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-09-15 02:22:16 +08:00
wangyongrong
d54d07b62c virtio-pci: add virtio pci legacy support
Follow the virtio spec, support the virtio pci Legacy

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
Signed-off-by: andi <andi6@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-15 02:22:16 +08:00
wangyongrong
decfc9ad65 virtio-pci-modern: replace pci_read/write_mmio_xxx with pci_read/write_io_xxx
Use IO api to access the io region

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-09-15 02:22:16 +08:00
wangyongrong
877e462990 vitrio-pci.c: add virtio-pci transport support for Nuttx
1. only support pci modern device;
2. need the pci controller support MSI/MSI-X;
It has been verified based on virtio-rng and virtio-net.

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-15 02:22:16 +08:00
Bowen Wang
0fbfcf4caf virtio-blk: support called read/write in interrupt
Coredump need call the block read/write ops in interrupt
Not consider the ops called in thread and intterupt simultaneously.
Only used for coredump now.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-10 11:35:35 +08:00
Petro Karashchenko
d252b6229f nuttx: use sizeof instead of define or number in snprintf
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-25 19:22:15 +08:00
liqinhui
e04aa9ac51 wifisim: Support the setting of the number of simulated WiFi interfaces.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 13:25:53 +08:00
Zhe Weng
648c52fc4b drivers/virtio-net: Use reclaim in ops to finish TODO
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-08-21 01:39:34 +08:00
liuhongchao
fb37391ea6 drivers/input: enable touch/kbd/mouse for virtio input
Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
2024-08-19 20:08:50 +08:00
liuhongchao
7495014b17 drivers/input: Add goldfish events driver
Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
2024-08-18 10:54:22 -03:00
Zhe Weng
504af7a1fa drivers/virtio-net: Support VIRTIO_F_ANY_LAYOUT
According to Virtual I/O Spec:
When using legacy interfaces, transitional drivers which have not negotiated VIRTIO_F_ANY_LAYOUT MUST use a single descriptor for the struct virtio_net_hdr on both transmit and receive, with the network data in the following descriptors.

https://docs.oasis-open.org/virtio/virtio/v1.2/cs01/virtio-v1.2-cs01.html#x1-2280006 (Section 5.1.6.6)

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-08-16 21:15:31 +08:00
Yanfeng Liu
3fecf46097 virtio/serial: initial CONSOLE support
This adds DRIVERS_VIRTIO_SERIAL_CONSOLE config and related logic to
virtio serial so that it can be used as console device. Note that
due to its dependency on OS services, this console is available late
so it is not proper for debugging too early booting issues.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-07-26 12:01:29 +08:00
Yanfeng Liu
1eb96c3446 virtio/gpu: minor revision on virtio_gpu_send_cmd()
This revises comments and completes reclaiming buf param.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-04-01 00:27:16 +08:00
Yanfeng Liu
715f8de1bb virtio/cmake: sync with makefile system
This adds drivers like virtio-gpu etc to cmake system to be in line
with the makefile system.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-03-31 08:04:47 -03:00
chao an
6d50274ebe nuttx/list: rename container_of to list_container_of from public header
Use private naming to avoid conflicts with user applications

In file included from libuv/src/unix/internal.h:25,
                 from libuv/src/unix/udp.c:23:
libuv/src/uv-common.h:57: warning: "container_of" redefined
   57 | #define container_of(ptr, type, member) \
      |
In file included from nuttx/include/nuttx/list.h:47,
                 from nuttx/include/nuttx/tls.h:40,
                 from nuttx/include/nuttx/sched.h:48,
                 from nuttx/include/nuttx/arch.h:87,
                 from nuttx/include/nuttx/userspace.h:35,
                 from nuttx/include/nuttx/mm/mm.h:30,
                 from nuttx/include/nuttx/kmalloc.h:34,
                 from nuttx/include/nuttx/lib/lib.h:31,
                 from nuttx/include/stdio.h:35,
                 from apps/system/libuv/libuv/include/uv.h:59,
                 from libuv/src/unix/udp.c:22:
nuttx/include/nuttx/nuttx.h:48: note: this is the location of the previous definition
   48 | #define container_of(ptr, type, member) \
      |

Signed-off-by: chao an <anchao@lixiang.com>
2024-02-29 19:44:54 +08:00
Bowen Wang
ca22e95577 virtio: move metal_init to the virtio_register_drivers()
Only call metal_init() once for virtio framework

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-02-18 04:09:44 -08:00
Bowen Wang
e9a146bbfc virtio-mmio: use byte to byte in read/write config when length != 1,2,4,8
The length of some config elements are not equal to 1,2,4,8, so we can't
assert in virtio_mmio_config_read/write() direclty when length != 1,2,4,8

For example, in virtio_net_config from virtio spec v1.2
struct virtio_net_config {
	u8 mac[6];
	le16 status;
	le16 max_virtqueue_pairs;
	le16 mtu;
	le32 speed;
	u8 duplex;
	u8 rss_max_key_size;
	le16 rss_max_indirection_table_length;
	le32 supported_hash_types;
};

The mac length is 6 and not equal to 1,2,4,8

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-01-06 04:23:05 -08:00
Bowen Wang
a8d21c3876 virtio-mmio: avoid output error log when not found mmio device
Not found the mmio device is a normal case, so should not print the
error log.
This commit change the log level to info when not found the mmio
device.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-01-04 20:28:21 -08:00
Bowen Wang
409431b2ad virtio-mmio: ack the interrupt as soon as possible
Follow the linux does, avoid miss mmio interrupt

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-01-04 20:05:29 -08:00
Xiang Xiao
b9bd88d9d3 rptun: Select OPENMAP under RPTUN
to simplify the IPC related configuration

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-12-28 11:08:57 +08:00
liqinhui
41a3c8a5e3 virtio-net:Fix the compile error.
CC:  virtio/virtio-net.c virtio/virtio-net.c: In function 'virtio_net_set_macaddr':
virtio/virtio-net.c:595:17: error: invalid operands to binary % (have 'struct net_driver_s *' and 'int')
  595 |             dev % 256
      |                 ^
make[1]: *** [Makefile:107: virtio-net.o] Error 1
make: *** [tools/LibTargets.mk:101: drivers/libdrivers.a] Error 2
make: *** Waiting for unfinished jobs....

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-21 01:21:01 -08:00
liqinhui
98e3615b60 net/netdev: Modify the logic for setting the IFF_RUNNING status of interfaces.
Refer to the logic of the `netif_carrier_on` on linux.
https://github.com/torvalds/linux/blob/master/net/sched/sch_generic.c#L575

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-15 18:24:23 -08:00
liqinhui
6a8c638d57 qemu/wifi: Add the virtual wifi function on the emulator.
-The qemu wifi fucntion only supports the STA mode and the following
 operations:
 wapi mode wlan0 2
 wapi scan wlan0
 wapi psk wlan0 password 3
 wapi essid wlan0 wifi_name 1
 wapi show wlan0
 wapi disconnect wlan0
-Eanble the virtual wifi function with the MACRO `CONFIG_DRIVERS_WIFI_SIM`.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-14 20:22:12 -08:00
jianglianfang
5f631e2b2b virtio-gpu: convert virito-gpu fb_register to virtio_gpu_fb_register
Signed-off-by: jianglianfang <jianglianfang@xiaomi.com>
2023-12-13 09:05:17 -08:00
liqinhui
73ceb049af virtio-net: Support for setting MAC addresses of the virtio-net interfaces.
Refers to https://docs.oasis-open.org/virtio/virtio/v1.2/cs01/virtio-v1.2-cs01.html#x1-2230004
A driver SHOULD negotiate VIRTIO_NET_F_MAC if the device offers it.
If the driver negotiates the VIRTIO_NET_F_MAC feature, the driver MUST
set the physical address of the NIC to mac. Otherwise, it SHOULD use a
locally-administered MAC address.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-13 05:00:59 -08:00
Bowen Wang
af39ee49d8 virtio-mmio: use nuttx implemented io operation instead libmetal's
Openamp/libmetal's metal io operation used the atomic operation, but
in QEMU 8.1.2, the risc-v IO region is not allow to use atomic instruction
in SMP case.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2023-11-17 09:42:52 +01:00
chao an
2b06142232 kernel: replace all sem_* to nxsem_*: in kernel space
syscall cannot be called from kernel space

Signed-off-by: chao an <anchao@xiaomi.com>
2023-10-25 15:46:03 +08:00
shipei
f99f67378d audio:add state sync for virtio snd device
qemu host virtio device don't support recvice the same cmd like start/stop twice
Signed-off-by: shipei <shipei@xiaomi.com>
2023-09-25 21:04:59 +08:00
wanggang26
0e7e7c4ee6 rpmb: add virtio rpmb support
The RPMB partition cannot be accessed via standard block layer, but by a set of specific commands: WRITE, READ, GET_WRITE_COUNTER, and PROGRAM_KEY. Such a partition provides authenticated and replay protected access, hence suitable as a secure storage.

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-09-09 00:13:25 +08:00
chao an
b60f01a55b inode/i_private: remove all unnecessary cast for i_private
Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 08:58:07 +02:00
chao an
7aa45305b7 fs/inode: remove all unnecessary check for filep/inode
Since VFS layer already contains sanity checks, so remove unnecessary lower half checks

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 09:47:11 +08:00
Zhe Weng
5597b8a9e2 drivers/virtio-net: Add support to offload small IOBs
TCP receive tested with different IOB_BUFSIZE:
|             | 256B vs 1534B | 512B vs 1534B | 768B vs 1534B |
| :---------: | :-----------: | :-----------: | :-----------: |
|     Non-SMP |     ~85%      |     ~93%      |     ~96%      |
|  armv8a-SMP |     ~66%      |     ~84%      |     ~92%      |
| rv32/64-SMP |     ~52%      |     ~72%      |     ~83%      |

It seems we still get performance penalty on smaller IOBs, and may be
affected more under SMP mode. It may be caused by critical sections in
IOB operations.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-22 16:34:21 +09:00
Zhe Weng
2fa68fbddd drivers/virtio-net: Support different LL_GUARDSIZE
Previously, the CONFIG_NET_LL_GUARDSIZE is fixed to 32 (64-Bit) or
28 (32-Bit), it's a little bit tricky.
Now add support to any value greater than minimal size.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-22 16:34:21 +09:00
Petro Karashchenko
075738cf14 net/ip: print ip addresses using ip4_addrN macro
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-08-19 13:28:21 -03:00
rongyichang
72587c6e79 drivers/virtio: add virtio input driver
Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
2023-08-13 11:47:39 -03:00
shipei
3cabf7ced8 audio:add virtio snd driver
playback test:
nxplayer
device /dev/audio/pcm0p
playraw /data/test.wav 2 16 44100
stop

record test:
nxrecorder
device /dev/audio/pcm0c
recordraw /data/rec.pcm 2 16 16000
stop

Signed-off-by: shipei <shipei@xiaomi.com>
2023-08-11 20:40:40 +08:00
Peter Bee
78b993c4e8 drivers/virtio: add virtio gpu driver
This patch provides basic framebuffer display support for virtio.
Multiple displays are supported.

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2023-08-11 20:20:11 +08:00
wangbowen6
9aa57b6c53 virtio: add virtio framework in NuttX
1. virtio devics/drivers match and probe/remote mechanism;
2. virtio mmio transport layer based on OpenAmp (Compatible with both
   virtio mmio version 1 and 2);
3. virtio-serial driver based on new virtio framework;
4. virtio-rng driver based on new virtio framework;
5. virtio-net driver based on new virtio framework
   (IOB Offload implementation);
6. virtio-blk driver based on new virtio framework;
7. Remove the old virtio mmio framework, the old framework only
   support mmio transport layer, and the new framwork support
   more transport layer and this commit has implemented all the
   old virtio drivers;
8. Refresh the the qemu-arm64 and qemu-riscv virtio related
   configs, and update its README.txt;

New virtio-net driver has better performance
Compared with previous virtio-mmio-net:
|                        | master/-c | master/-s | this/-c | this/-s |
| :--------------------: | :-------: | :-------: | :-----: | :-----: |
| qemu-armv8a:netnsh     |  539Mbps  |  524Mbps  | 906Mbps | 715Mbps |
| qemu-armv8a:netnsh_smp |  401Mbps  |  437Mbps  | 583Mbps | 505Mbps |
| rv-virt:netnsh         |  487Mbps  |  512Mbps  | 760Mbps | 634Mbps |
| rv-virt:netnsh_smp     |  387Mbps  |  455Mbps  | 447Mbps | 502Mbps |
| rv-virt:netnsh64       |  602Mbps  |  595Mbps  | 881Mbps | 769Mbps |
| rv-virt:netnsh64_smp   |  414Mbps  |  515Mbps  | 491Mbps | 525Mbps |
| rv-virt:knetnsh64      |  515Mbps  |  457Mbps  | 606Mbps | 540Mbps |
| rv-virt:knetnsh64_smp  |  308Mbps  |  389Mbps  | 415Mbps | 474Mbps |
Note: Both CONFIG_IOB_NBUFFERS=64, using iperf command, all in Mbits/sec
      Tested in QEMU 7.2.2

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-10 03:39:39 +08:00
Masayuki Ishikawa
5e7ce13b3e drivers: virtio: Use one dscriptor for RX in virtio-mmio-net.c
Summary:
- In this implementation, only one descriptor is used for RX.
- NOTE: we still use two descriptors for TX

Impact:
- None

Testing:
- Tested with qemu-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-06-21 16:38:04 +08:00
Masayuki Ishikawa
ee364e115a drivers: virtio: Remove unused code and fix comments in virtio-mmio-net.c
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-06-04 01:14:08 +08:00
Masayuki Ishikawa
e149a1278b dirivers: virtio: Fix virtnet_virtnet_txpoll() in virtio-mmio-net.c
Summary:
- I noticed that nfsmount always timed out.
- This commit fixes this issue.

Impact:
- None

Testing:
- Tested wih qemu-7.1
- NOTE: defconfigs will be updated later.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-06-02 16:28:34 +08:00
Masayuki Ishikawa
6b35a49f6e dirivers: virtio: Fix virtnet_transmit() in virtio-mmio-net.c
Summary:
- I noticed that the driver sends incorrect packets sometimes.
- This commit fixes this issue.

Impact:
- None

Testing:
- Tested with qemu-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-06-01 13:44:30 +08:00
Xiang Xiao
7990f90915 Indent the define statement by two spaces
follow the code style convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-21 09:52:08 -03:00
Masayuki Ishikawa
498a75a58b drivers: virtio: Add virtio-mmio-blk
Summary:
- This commit adds virtio-mmio-blk driver

Impact:
- None

Testing:
- Tested with rv-virt:netnsh which will be updated later

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-05-13 13:58:09 +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
Zhe Weng
5e42bd97cd virtio/net: Try fix virtnet logic
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-09 10:10:49 +09:00
Xiang Xiao
d5689e070b net/arp: Remove nuttx/net/arp.h
1.move ARPHRD_ETHER to netinet/arp.h
1.move arp_entry_s to net/arp/arp.h
2.move arp_input to nuttx/net/netdev.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-16 22:10:59 +02:00