CV-Bowen opened a new pull request, #21818:
URL: https://github.com/apache/nuttx/pull/21818
## Summary
The rptun ivshmem resource table only carries two rng devices and one
rpmsg device, fixed at compile time, so a vhost vsock or vhost-net
backend on one side has no vdev to bind to, and a board cannot supply
its own table.
- drivers/rptun/rptun_ivshmem: add a vsock device to the resource table
- drivers/rptun/rptun_ivshmem: offer VIRTIO_VSOCK_F_HOST_CID
- drivers/rptun/rptun_ivshmem: enlarge the vsock carveout
- drivers/rptun/rptun_ivshmem: derive the vsock cids from the cpu names
- guest_cid / host_cid are the first four bytes of the peer and local
cpu names, so several instances get distinct cids.
- drivers/rptun/rptun_ivshmem: add the rng entries only with vhost-rng
- drivers/rptun/rptun_ivshmem: order the table writes before hdr.ver
- drivers/rptun/rptun_ivshmem: support a vendor resource table
- `pci_register_rptun_ivshmem_slave_driver(cpuname, drvid, rsc_table,
rsc_size)` lets a slave register its own table; the built-in one
becomes a const `g_rsc_table` copied into shared memory.
- drivers/rptun/rptun_ivshmem: fill the rpmsg cpu names at run time
- drivers/rptun/rptun_ivshmem: set the vsock cids in the built-in table
- drivers/rptun/rptun_ivshmem: gate the table entries by vhost config
- Each vdev entry (rng, rpmsg, vsock) is built only with its vhost
Kconfig, and the vdev count follows.
- drivers/rptun/rptun_ivshmem: add a virtio-net device to the table
These are kept as separate commits in the order they were made; the
later ones rework the table the earlier ones extend.
## Impact
- The slave side (the one that writes the table) now offers a vdev only
for each vhost backend it enables: `CONFIG_DRIVERS_VHOST_RNG`,
`CONFIG_DRIVERS_VHOST_RPMSG`, `CONFIG_NET_VSOCK_VHOST`,
`CONFIG_DRIVERS_VHOST_NET`. qemu-armv8a:rpproxy enables rng and rpmsg,
so its table keeps one rng device (was two) and the rpmsg device.
- New `pci_register_rptun_ivshmem_slave_driver()` in
`include/nuttx/rptun/rptun_ivshmem.h`.
- No Kconfig added or removed.
## Testing
Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
Each commit builds with 0 warnings on qemu-armv8a:rpserver,
qemu-armv8a:rpproxy, both with the vsock overlay below, and
qemu-armv8a:rpproxy with `CONFIG_NET` + `CONFIG_DRIVERS_VHOST_NET`.
vsock between the two instances over ivshmem. Overlay on
qemu-armv8a:rpserver and rpproxy: `CONFIG_NET`, `CONFIG_NET_SOCKOPTS`,
`CONFIG_NET_VSOCK`; rpproxy (writes the table) adds
`CONFIG_DRIVERS_VHOST` + `CONFIG_NET_VSOCK_VHOST`, rpserver adds
`CONFIG_DRIVERS_VIRTIO` + `CONFIG_NET_VSOCK_VIRTIO`. The vsock test
client is apps/examples/vsock from our tree (not in nuttx-apps yet).
Echo server on the proxy, client on the server connecting to the
proxy's cid "prox" (0x786f7270):
```
proxy> vsock -t data -p 28065 -i 1024 -n 64 &
server> vsock -c 2020569712 -t data -p 28065 -i 1024 -n 64
```
| | master | this PR |
|---|---|---|
| vsock vdev on the server | none | bound, cids from the cpu names |
| 64 x 1 KiB echo | connect fails, -ENOTSUP (no transport) | 65536 bytes,
10/10 runs |
<details><summary>this PR</summary>
```
[ 3.407939] [ 9] [ EMERG] [server] [Vsock Transport] id=19
vdev=0x404bcbc0 driver=0x404a0290 priv=0x404bcf98
[ 3.408572] [ 9] [ EMERG] [server] guest_cid=1987208563,
host_cid=2020569712, pkt_bufsize=2092 B (hdr=44 + data=2048)
[ 3.409788] [ 9] [ EMERG] [server] Vsock Connections:
proxy> Vsock server test, port=28065, size=1024, cid=4294967295
Vsock client test, port=28065, size=1024, count=64, cid=2020569712
Connect, s=3
Send finish, sendlen=65536
Close
server> Accept peer_fd=4
Close
```
</details>
<details><summary>master</summary>
```
proxy> Vsock server test, port=28065, size=1024, cid=4294967295
Vsock client test, port=28065, size=1024, count=64, cid=2020569712
Connect, s=3
Connect failed, ret=18446744073709551478 (-ENOTSUP)
Close
```
</details>
One of 12 runs crashed at proxy boot in `rptun_ivshmem_wdog()` ->
`rptun_callback()` -> `remoteproc_get_notification()` ->
`virtqueue.c:429`, before any vsock traffic: the polling wdog fires
while the vring is still being created. The same race shows on master
with the default rpproxy config (seen in #21757 and #21813 testing);
this PR does not touch that path.
No regression in rpmsg: sim:rpserver/rpproxy and
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping,
rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC
disabled, which current master needs for nxinit to start nsh there; unrelated
to this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]