Repository navigation
Conversation
Add the ioctl commands and struct rpmsg_endpoint_info of the Linux <linux/rpmsg.h> interface, for the rpmsg char driver that follows: RPMSG_CREATE_EPT_IOCTL, RPMSG_CREATE_DEV_IOCTL and RPMSG_RELEASE_DEV_IOCTL on the rpmsg device, RPMSG_DESTROY_EPT_IOCTL and the flow control ioctls on an endpoint device. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Let an application talk to a remote service without a dedicated driver, with the Linux rpmsg_char interface: RPMSG_CREATE_EPT_IOCTL on /dev/rpmsg/<cpu> creates an endpoint and registers /dev/rpmsg-<name>, which then supports read(), write() and poll(). Received messages are queued per endpoint device until read. Enabled by CONFIG_RPMSG_CHAR. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
The Linux rpmsg_char driver binds to the "rpmsg-raw" service. Create the endpoint as "rpmsg-raw-<name>" so that a NuttX rpmsg char endpoint and a Linux one find each other through the name service. Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com> Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
When a reader is waiting in read(), the endpoint callback now copies the message into the reader's buffer instead of allocating an rx buffer and copying it a second time in read(). Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com> Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NuttX has no generic way for an application to talk to a remote rpmsg
service: each service needs its own driver. Linux has
rpmsg_charforthis; this PR adds the same interface:
include/nuttx/rpmsg/rpmsg.h: the ioctls andstruct rpmsg_endpoint_infoof Linux<linux/rpmsg.h>(
RPMSG_CREATE_EPT_IOCTL,RPMSG_CREATE_DEV_IOCTL,RPMSG_RELEASE_DEV_IOCTL,RPMSG_DESTROY_EPT_IOCTL, and the flowcontrol ones).
drivers/rpmsg: add the rpmsg char driver(CONFIG_RPMSG_CHAR):RPMSG_CREATE_EPT_IOCTL/RPMSG_CREATE_DEV_IOCTLon/dev/rpmsg/<cpu>creates an endpoint and registers/dev/rpmsg-<name>, which supportsread(),write()andpoll();received messages are queued until read, and the peer's name service
destroy makes
read()return-ECONNRESETandpoll()reportPOLLHUP.rpmsg_char: prefix the endpoint name with "rpmsg-raw-", the servicename the Linux driver binds to, so a NuttX and a Linux rpmsg char
endpoint find each other.
rpmsg_char: copy into the reader's buffer directlywhen a reader isalready waiting.
Impact
RPMSG_CHAR(default n) andRPMSG_CHAR_NPOLLWAITERS.include/nuttx/rpmsg/rpmsg.handstruct rpmsg_endpoint_info; the existing ioctl numbers do not change.RPMSG_CHARis enabled.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
qemu-armv8a:rpserver + qemu-armv8a:rpproxy (rptun ivshmem), both with
CONFIG_RPMSG_CHAR. The server runs therpmsgchartest program(nuttx-apps
examples/rpmsgchar, apache/nuttx-apps#4081); the proxyruns a small test-only echo server (below, not in this PR) that creates
the same endpoints with
RPMSG_CREATE_DEV_IOCTL, writes back everymessage, and releases an endpoint once the peer destroys it.
rpmsgchar -t echo -c /dev/rpmsg/proxy -n t0: 1000 write/read round trips of 12 bytes over/dev/rpmsg-t0Finish the echo test, the echo server counts 1000 messagesrpmsgchar -t destroy -c /dev/rpmsg/proxy -n d: create 100 endpoints, one round trip each, then release them allEnd the destroy test; no/dev/rpmsg-d*left on the server, heap back to the same number of chunksOn master
RPMSG_CHARdoes not exist.log
test-only echo server
Every commit builds with no warning on sim:rpserver with and without
CONFIG_RPMSG_CHAR.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.