From: Pavel Pisa <pisa@cmp.felk.cvut.cz>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Oliver Hartkopp A <socketcan@hartkopp.net>,
jinyang.sia@gmail.com
Cc: "Stefan Weil" <sw@weilnetz.de>,
rtems-devel@rtems.org, "Andreas Färber" <afaerber@suse.de>,
linux-can@vger.kernel.org
Subject: [Qemu-devel] [PATCH 0/2] CAN SJA100 controller emulation and SocketCAN based host CAN bus access
Date: Fri, 9 May 2014 20:10:19 +0200 [thread overview]
Message-ID: <201405092010.19482.pisa@cmp.felk.cvut.cz> (raw)
Hello everybody,
I have invested some time to wrap-up and get back
on the track 2013 GSoC Jin Yang work on QEMU CAN
bus emulation done in frame of RTEMS project preparation
for future RTEMS CAN bus infrastructure preparation.
I think that code is important for much wider community.
RTEMS page for original QEMU 1.4 work
http://www.rtems.org/wiki/index.php/Qemu_simulations
Be warned, page is not yet updated for redesigned CAN
infrastructure conecept
The patch series consists of
- CAN bus simple SJA1000 PCI card emulation for QEMU
Files:
- include/net/can_emu.h
- basic CAN bus related types. Those which could possibly clash
with Linux kernel prepended by "qemu_".
- prototypes for CAN buses naming and clients registration
- original Jin Yang approach uses chardev, but that does not
map well to little different semantics of CAN messages
distribution. I have considered common vlan code but
I have not found how to use it with CAN well too.
- hw/net/can_core.c
- implementation of CAN messages delivery
- support to connect into real host CAN bus network for case
of Linux SocketCAN
- hw/net/can_sja1000.h
- declarations of SJA1000 CAN controller registers
and connection type independent part of API
- hw/net/can_sja1000.c
- SJA1000 CAN controller registers and registers model
implementation - hard part implemented by Jin Yang
- hw/net/can_pci.c
- connection of above infrastructure to the minimal PCI
card with only one mmio BAR and no bridge interrupts setup
and control. Unfortuantelly, I am not aware of any such
straightforward card but it is great for testing and
drivers porting. Used vendor and product ID are random ones
chosen by Jin Yang, if there is some consensus that work worth
for integration then I suggest to ask RedHat for unique PCI ID
donation
- CAN bus Kvaser PCI CAN-S (single SJA1000 channel)
Files:
- hw/net/can_kvaser_pci.c
Implementation of
Testing:
I have implemented first simple single SJA1000 memory mapped PCI
board support for LinCAN
Setup real or virtual can in host system
modprobe can-raw
modprobe vcan
ip link add dev can0 type vcan
ip link set can0 up
QEMU run with some subset of next parameters
$QEMU -enable-kvm -kernel /boot/vmlinuz-3.2.0-4-amd64 \
-initrd ramdisk.cpio \
-virtfs local,path=shareddir,security_model=none,mount_tag=shareddir \
-vga cirrus \
-device can_pci,model=SJA1000,canbus=canbus0,host=can0 \
-nographic -append "console=ttyS0"
Run in the guest system
modprobe lincan hw=pcisja1000mm io=0
mdev -s
sendburst
readburst
Test with Kvaser
$QEMU -enable-kvm -kernel /boot/vmlinuz-3.2.0-4-amd64 \
-initrd ramdisk.cpio \
-virtfs local,path=shareddir,security_model=none,mount_tag=shareddir \
-vga cirrus \
-device kvaser_pci,canbus=canbus0,host=can0 \
-nographic -append "console=ttyS0"
Run in the guest system
modprobe lincan hw=pcican-s io=0
mdev -s
SocketCAN in the guest system
No load lincan or rmmod lincan
Then SocketCAN in inner system setup
modprobe can-raw
modprobe kvaser-pci
ip link set can0 type can bitrate 1000000
ip link set can0 up
cangen can0 -e -I 123 -g 1000 -D 11223344DEADBEEF -L 8
candump can0
Visualization in host / outer system possible by QCANalyzer
for example
http://ortcan.sourceforge.net/qcanalyzer/
Code is really hot and more or less proof of concept
but worked for me stable for some while.
There is no buffering in CAN bus model for now
so messages can be easily lost or overwritten.
No CAN filters are in real use for now.
Some filters union and application to the SocketCAN
can be usesfull for future. But separation of CAN
bus model out of chardev and or vlan allows to
implement CAN specific things more easily.
Best wishes,
Pavel
--
Pavel Pisa
e-mail: pisa@cmp.felk.cvut.cz
www: http://cmp.felk.cvut.cz/~pisa
university: http://dce.fel.cvut.cz/
company: http://www.pikron.com/
next reply other threads:[~2014-05-09 18:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-09 18:10 Pavel Pisa [this message]
2014-05-09 18:14 ` [Qemu-devel] [PATCH 1/2] CAN bus simple SJA1000 PCI card emulation for QEMU Pavel Pisa
2014-05-12 9:01 ` Peter Crosthwaite
2014-05-12 9:18 ` Andreas Färber
2014-05-09 18:15 ` [Qemu-devel] [PATCH 2/2] CAN bus Kvaser PCI CAN-S (single SJA1000 channel) emulation added Pavel Pisa
2014-05-13 12:29 ` [Qemu-devel] [PATCH 0/2] CAN SJA100 controller emulation and SocketCAN based host CAN bus access Stefan Hajnoczi
2014-05-15 13:53 ` Pavel Pisa
2014-05-23 1:52 ` [Qemu-devel] " jinyang.sia
2014-05-23 9:42 ` [Qemu-devel] [PATCH 0/2] " Stefan Hajnoczi
2014-05-23 14:25 ` Pavel Pisa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201405092010.19482.pisa@cmp.felk.cvut.cz \
--to=pisa@cmp.felk.cvut.cz \
--cc=afaerber@suse.de \
--cc=jinyang.sia@gmail.com \
--cc=linux-can@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=rtems-devel@rtems.org \
--cc=socketcan@hartkopp.net \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).