Linux CXL
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Klaus Jensen <k.jensen@samsung.com>, <cminyard@mvista.com>,
	Fan Ni <fan.ni@samsung.com>, Anisa Su <anisa.su@samsung.com>,
	<qemu-devel@nongnu.org>, <linux-cxl@vger.kernel.org>,
	<mst@redhat.com>
Cc: linuxarm@huawei.com, "Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [RFC PATCH qemu 0/5] hw/cxl/mctp/i2c/usb: MCTP for OoB control of CXL devices.
Date: Mon, 9 Jun 2025 17:33:28 +0100	[thread overview]
Message-ID: <20250609163334.922346-1-Jonathan.Cameron@huawei.com> (raw)

This posting is primarily about sharing the USB device emulation to get some
early feedback.

RFC reasons:
- Known 'inaccuracies' in emulation (not obeying MTU in the to host direction for
  example)./
- Not sure what to do wrt to Klaus' I2C MCTP support given that has been stalled
  for some time. For now only the headers are really shared between the
  two implementations.
- This is more of an FYI / request for testing than a formal suggestion that this
  might be ready for upstream.

Why add a CXL FM-API over MCTP over USB device?
- Can be emulated on pretty much any host system as USB is discoverable and
  expandable. If you want a giggle, see the hacks on i386/pc and arm/virt on
  we've been using until now given only I2C controller that works is the aspeed
  one. e.g. https://gitlab.com/jic23/qemu/-/commit/134c2e3952b
- Being able to talk to both the fabric management out of band interfaces
  and the in band devices on the same host makes testing much simpler.

Background:

Back in 2022 I posted some support for controlling the CXL fabric via the
spec defined out of band interfaces (CXL Fabric Management API - FM-API)
over MCTP on I2C

https://lore.kernel.org/qemu-devel/20220520170128.4436-1-Jonathan.Cameron@huawei.com/
I reworked that on top of the NVME-MI work from Klauss.

To that end I hacked the aspeed-i2c controller onto both i386/pc and arm/virt
and posted kernel patches to enabled ACPI support for that device (more or less).
It worked and has been useful in the meantime, but adding that i2c controller
to those boards was obviously not going to be upstreamable - and to build
reliable tests against it I don't want to carry this out of tree for ever.
I messed around with a PCI hosted aspeed controller and might come back to
that at some point.

In the meantime, DMTF published a transport binding for MCTP over USB
https://www.dmtf.org/sites/default/files/standards/documents/DSP0283_1.0.1.pdf

Kernel support duly followed early this year: drivers/net/mctp/mctp-usb.c
https://codeconstruct.com.au/docs/mctp-over-usb/

Given the ease of adding a suitable USB controller on a PCI bus, emulating a
suitable endpoint provides what I think is an upstreamable solution.

To use this:
 -device usb-ehci,id=ehci
 -device usb-cxl-mctp,bus=ehci.0,id=fred,target=us0

where target is either a CXL switch upstream port, or a type 3 device.

Then install the mctp userspace tools in your guest and configure it with

  mctp addr add 8 dev mctpusb0
  mctp link set mctpusb0 net 11
  mctp link set mctpusb0 up

  systemctl start mctpd.service
  busctl call au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/interfaces/mctpusb0 au.com.codeconstruct.MCTP.BusOwner1 SetupEndpoint ay 0

I've been testing the CXL commands with

https://gitlab.com/jic23/cxl-fmapi-tests
(mostly because I still had them in my image from the i2c work)
but libcxlmi is probably a better bet

https://github.com/computexpresslink/libcxlmi

I'll post a tree with this on at gitlab.com/jic23/qemu shortly
(cxl-<latest date>).

Jonathan Cameron (3):
  hw/cxl/i2c_mctp_cxl: Initial device emulation
  docs: cxl: Add example commandline for MCTP CXL CCIs
  usb/mctp/cxl: CXL FMAPI interface via MCTP over usb.

Klaus Jensen (2):
  hw/i2c: add smbus pec utility function
  hw/i2c: add mctp core

 MAINTAINERS                               |   7 +
 docs/system/devices/cxl.rst               |  27 +
 include/hw/cxl/cxl_device.h               |   8 +
 include/hw/i2c/mctp.h                     | 125 +++++
 include/hw/i2c/smbus_master.h             |   2 +
 include/hw/pci-bridge/cxl_upstream_port.h |   1 +
 include/hw/usb.h                          |   1 +
 include/net/mctp.h                        | 100 ++++
 hw/cxl/cxl-mailbox-utils.c                |  49 ++
 hw/cxl/i2c_mctp_cxl.c                     | 289 ++++++++++
 hw/i2c/mctp.c                             | 414 ++++++++++++++
 hw/i2c/smbus_master.c                     |  26 +
 hw/usb/dev-mctp.c                         | 639 ++++++++++++++++++++++
 hw/arm/Kconfig                            |   1 +
 hw/cxl/Kconfig                            |   4 +
 hw/cxl/meson.build                        |   4 +
 hw/i2c/Kconfig                            |   4 +
 hw/i2c/meson.build                        |   1 +
 hw/i2c/trace-events                       |  14 +
 hw/usb/Kconfig                            |   5 +
 hw/usb/meson.build                        |   1 +
 21 files changed, 1722 insertions(+)
 create mode 100644 include/hw/i2c/mctp.h
 create mode 100644 include/net/mctp.h
 create mode 100644 hw/cxl/i2c_mctp_cxl.c
 create mode 100644 hw/i2c/mctp.c
 create mode 100644 hw/usb/dev-mctp.c

-- 
2.48.1


             reply	other threads:[~2025-06-09 16:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-09 16:33 Jonathan Cameron [this message]
2025-06-09 16:33 ` [RFC PATCH qemu 1/5] hw/i2c: add smbus pec utility function Jonathan Cameron
2025-06-09 16:33 ` [RFC PATCH qemu 2/5] hw/i2c: add mctp core Jonathan Cameron
2025-06-09 16:33 ` [RFC PATCH qemu 3/5] hw/cxl/i2c_mctp_cxl: Initial device emulation Jonathan Cameron
2025-06-10 16:39   ` Jonathan Cameron
2025-06-09 16:33 ` [RFC PATCH qemu 4/5] docs: cxl: Add example commandline for MCTP CXL CCIs Jonathan Cameron
2025-06-09 16:33 ` [RFC PATCH qemu 5/5] usb/mctp/cxl: CXL FMAPI interface via MCTP over usb Jonathan Cameron
2025-06-24 19:47 ` [RFC PATCH qemu 0/5] hw/cxl/mctp/i2c/usb: MCTP for OoB control of CXL devices Anisa Su

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=20250609163334.922346-1-Jonathan.Cameron@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=anisa.su@samsung.com \
    --cc=cminyard@mvista.com \
    --cc=fan.ni@samsung.com \
    --cc=k.jensen@samsung.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mst@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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