From: Ruslan Ruslichenko <ruslichenko.r@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, artem_mygaiev@epam.com,
volodymyr_babchuk@epam.com, peter.maydell@linaro.org,
francisco.iglesias@amd.com, edgar.iglesias@gmail.com,
berrange@redhat.com, eugene@nuvacore.ai,
Ruslan_Ruslichenko@epam.com, takahiro.nakata.wr@renesas.com,
"Edgar E . Iglesias" <edgar.iglesias@amd.com>
Subject: [PATCH v2 13/20] hw/core: Add Remote Port ATS device skeleton
Date: Tue, 15 Sep 2026 18:00:37 +0200 [thread overview]
Message-ID: <20260915160044.345788-14-ruslichenko.r@gmail.com> (raw)
In-Reply-To: <20260915160044.345788-1-ruslichenko.r@gmail.com>
From: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>
Inroduce the remote-port-ats device and remote-port-ats-cache
interface.
This patch provides the QOM definition and basic initialization
logic required for Address Translation Services in Remote Port
system.
Preserved existing MIT license for remote-port-ats(.c,.h).
Signed-off-by: Francisco Iglesias <francisco.iglesias@amd.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Signed-off-by: Takahiro Nakata <takahiro.nakata.wr@renesas.com>
Signed-off-by: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>
---
hw/core/remote-port-ats.c | 209 ++++++++++++++++++++++++++++++
include/hw/core/remote-port-ats.h | 76 +++++++++++
2 files changed, 285 insertions(+)
create mode 100644 hw/core/remote-port-ats.c
create mode 100644 include/hw/core/remote-port-ats.h
diff --git a/hw/core/remote-port-ats.c b/hw/core/remote-port-ats.c
new file mode 100644
index 0000000000..793f9fc52d
--- /dev/null
+++ b/hw/core/remote-port-ats.c
@@ -0,0 +1,209 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * QEMU remote port ATS
+ *
+ * Copyright (c) 2021 Xilinx Inc
+ * Written by Francisco Iglesias <francisco.iglesias@xilinx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "qemu/osdep.h"
+#include "system/system.h"
+#include "system/dma.h"
+#include "qemu/log.h"
+#include "qapi/qmp/qerror.h"
+#include "qapi/error.h"
+#include "hw/core/sysbus.h"
+#include "migration/vmstate.h"
+#include "hw/core/qdev-properties.h"
+#include "trace.h"
+
+#include "hw/core/remote-port-proto.h"
+#include "hw/core/remote-port-ats.h"
+
+typedef struct ATSIOMMUNotifier {
+ IOMMUNotifier n;
+ MemoryRegion *mr;
+ RemotePortATS *rp_ats;
+ int iommu_idx;
+} ATSIOMMUNotifier;
+
+IOMMUTLBEntry *rp_ats_cache_lookup_translation(RemotePortATSCache *cache,
+ hwaddr translated_addr,
+ hwaddr len)
+{
+ RemotePortATSCacheClass *c = REMOTE_PORT_ATS_CACHE_GET_CLASS(cache);
+
+ return c->lookup_translation(cache, translated_addr, len);
+}
+
+static IOMMUTLBEntry *rp_ats_lookup_translation(RemotePortATSCache *cache,
+ hwaddr translated_addr,
+ hwaddr len)
+{
+ /* TBD */
+ return NULL;
+}
+
+static bool ats_translate_address(RemotePortATS *s, struct rp_pkt *pkt,
+ hwaddr *phys_addr, hwaddr *phys_len)
+{
+ /* TBD */
+ return true;
+}
+
+static void rp_ats_req(RemotePortDevice *dev, struct rp_pkt *pkt)
+{
+ RemotePortATS *s = REMOTE_PORT_ATS(dev);
+ size_t pktlen = sizeof(struct rp_pkt_ats);
+ hwaddr phys_addr = 0;
+ hwaddr phys_len = (hwaddr)(-1);
+ uint64_t result;
+ size_t enclen;
+ int64_t delay;
+ int64_t clk;
+
+ assert(!(pkt->hdr.flags & RP_PKT_FLAGS_response));
+
+ rp_dpkt_alloc(&s->rsp, pktlen);
+
+ result = ats_translate_address(s, pkt, &phys_addr, &phys_len) ?
+ RP_ATS_RESULT_ok : RP_ATS_RESULT_error;
+
+ /*
+ * delay here could be set to the annotated cost of doing issuing
+ * these accesses. QEMU doesn't support this kind of annotations
+ * at the moment. So we just clear the delay.
+ */
+ delay = 0;
+ clk = pkt->ats.timestamp + delay;
+
+ enclen = rp_encode_ats_req(pkt->hdr.id, pkt->hdr.dev,
+ &s->rsp.pkt->ats,
+ clk,
+ pkt->ats.attributes,
+ phys_addr,
+ phys_len,
+ result,
+ pkt->hdr.flags | RP_PKT_FLAGS_response);
+ assert(enclen == pktlen);
+
+ rp_write(s->rp, (void *)s->rsp.pkt, enclen);
+}
+
+static void rp_ats_realize(DeviceState *dev, Error **errp)
+{
+ RemotePortATS *s = REMOTE_PORT_ATS(dev);
+ RemotePortDevice *rpd = REMOTE_PORT_DEVICE(dev);
+
+ rp_register_dev(s->rp, rpd, s->rp_dev);
+
+ s->peer = rp_get_peer(s->rp);
+ address_space_init(&s->as, s->mr ? s->mr : get_system_memory(), "ats-as");
+
+ s->iommu_notifiers = g_array_new(false, true, sizeof(ATSIOMMUNotifier *));
+ s->cache = g_array_new(false, true, sizeof(IOMMUTLBEntry *));
+}
+
+static void rp_prop_allow_set_link(const Object *obj, const char *name,
+ Object *val, Error **errp)
+{
+}
+
+static void rp_ats_init(Object *obj)
+{
+ RemotePortATS *s = REMOTE_PORT_ATS(obj);
+
+ object_property_add_link(obj, "rp-adaptor0", "remote-port",
+ (Object **)&s->rp,
+ rp_prop_allow_set_link,
+ OBJ_PROP_LINK_STRONG);
+ object_property_add_link(obj, "mr", TYPE_MEMORY_REGION,
+ (Object **)&s->mr,
+ qdev_prop_allow_set_link_before_realize,
+ OBJ_PROP_LINK_STRONG);
+}
+
+static void rp_ats_unrealize(DeviceState *dev)
+{
+ RemotePortATS *s = REMOTE_PORT_ATS(dev);
+ ATSIOMMUNotifier *notifier;
+ int i;
+
+ for (i = 0; i < s->iommu_notifiers->len; i++) {
+ notifier = g_array_index(s->iommu_notifiers, ATSIOMMUNotifier *, i);
+ memory_region_unregister_iommu_notifier(notifier->mr, ¬ifier->n);
+ g_free(notifier);
+ }
+ g_array_free(s->iommu_notifiers, true);
+
+ address_space_destroy(&s->as);
+
+ for (i = 0; i < s->cache->len; i++) {
+ IOMMUTLBEntry *tmp = g_array_index(s->cache, IOMMUTLBEntry *, i);
+ g_free(tmp);
+ }
+ g_array_free(s->cache, true);
+}
+
+static Property rp_properties[] = {
+ DEFINE_PROP_UINT32("rp-chan0", RemotePortATS, rp_dev, 0),
+};
+
+static void rp_ats_class_init(ObjectClass *oc, const void *data)
+{
+ RemotePortDeviceClass *rpdc = REMOTE_PORT_DEVICE_CLASS(oc);
+ RemotePortATSCacheClass *atscc = REMOTE_PORT_ATS_CACHE_CLASS(oc);
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ device_class_set_props_n(dc, rp_properties, ARRAY_SIZE(rp_properties));
+
+ rpdc->ops[RP_CMD_ats_req] = rp_ats_req;
+ dc->realize = rp_ats_realize;
+ dc->unrealize = rp_ats_unrealize;
+ atscc->lookup_translation = rp_ats_lookup_translation;
+}
+
+static const TypeInfo rp_ats_info = {
+ .name = TYPE_REMOTE_PORT_ATS,
+ .parent = TYPE_DEVICE,
+ .instance_size = sizeof(RemotePortATS),
+ .instance_init = rp_ats_init,
+ .class_init = rp_ats_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_REMOTE_PORT_DEVICE },
+ { TYPE_REMOTE_PORT_ATS_CACHE },
+ { },
+ },
+};
+
+static const TypeInfo rp_ats_cache_info = {
+ .name = TYPE_REMOTE_PORT_ATS_CACHE,
+ .parent = TYPE_INTERFACE,
+ .class_size = sizeof(RemotePortATSCacheClass),
+};
+
+static void rp_register_types(void)
+{
+ type_register_static(&rp_ats_cache_info);
+ type_register_static(&rp_ats_info);
+}
+
+type_init(rp_register_types)
diff --git a/include/hw/core/remote-port-ats.h b/include/hw/core/remote-port-ats.h
new file mode 100644
index 0000000000..ffe60539ac
--- /dev/null
+++ b/include/hw/core/remote-port-ats.h
@@ -0,0 +1,76 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * QEMU remote port ATS
+ *
+ * Copyright (c) 2021 Xilinx Inc
+ * Written by Francisco Iglesias <francisco.iglesias@xilinx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#ifndef REMOTE_PORT_ATS_H
+#define REMOTE_PORT_ATS_H
+
+#include "hw/core/remote-port.h"
+
+#define TYPE_REMOTE_PORT_ATS "remote-port-ats"
+#define REMOTE_PORT_ATS(obj) \
+ OBJECT_CHECK(RemotePortATS, (obj), TYPE_REMOTE_PORT_ATS)
+
+typedef struct {
+ /* private */
+ SysBusDevice parent;
+
+ /* public */
+ struct RemotePort *rp;
+ struct rp_peer_state *peer;
+ MemoryRegion *mr;
+ AddressSpace as;
+ RemotePortDynPkt rsp;
+ GArray *iommu_notifiers;
+ uint32_t rp_dev;
+ GArray *cache; /* Translation cache */
+} RemotePortATS;
+
+#define TYPE_REMOTE_PORT_ATS_CACHE "remote-port-ats-cache"
+
+#define REMOTE_PORT_ATS_CACHE_CLASS(klass) \
+ OBJECT_CLASS_CHECK(RemotePortATSCacheClass, (klass), \
+ TYPE_REMOTE_PORT_ATS_CACHE)
+#define REMOTE_PORT_ATS_CACHE_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(RemotePortATSCacheClass, (obj), TYPE_REMOTE_PORT_ATS_CACHE)
+#define REMOTE_PORT_ATS_CACHE(obj) \
+ INTERFACE_CHECK(RemotePortATSCache, (obj), TYPE_REMOTE_PORT_ATS_CACHE)
+
+typedef struct RemotePortATSCache {
+ Object Parent;
+} RemotePortATSCache;
+
+typedef struct RemotePortATSCacheClass {
+ InterfaceClass parent;
+
+ IOMMUTLBEntry *(*lookup_translation)(RemotePortATSCache *cache,
+ hwaddr translated_addr,
+ hwaddr len);
+} RemotePortATSCacheClass;
+
+IOMMUTLBEntry *rp_ats_cache_lookup_translation(RemotePortATSCache *cache,
+ hwaddr translated_addr,
+ hwaddr len);
+#endif
--
2.43.0
next prev parent reply other threads:[~2026-09-15 16:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 16:00 [PATCH v2 00/20] hw/core: Introduce Remote Port Co-simulation Protocol Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 01/20] hw/core: Add Remote Port protocol packet definition Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 02/20] hw/core: Add Remote Port header helpers Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 03/20] hw/core: Add Remote Port session state and hello protocol Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 04/20] hw/core: Implement Remote Port bus access helpers Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 05/20] hw/core: Implement Remote Port irq, sync and ATS helpers Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 06/20] hw/core: Add Remote Port object skeleton Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 07/20] hw/core: Add Remote Port protocol thread and handshake Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 08/20] hw/core: Implement Remote Port response handling Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 09/20] hw/core: Implement Remote Port time synchronization Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 10/20] hw/core: Add Remote Port Memory Master object skeleton Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 11/20] hw/core: Implement Remote Port Memory Master bus transactions Ruslan Ruslichenko
2026-10-13 16:09 ` Philippe Mathieu-Daudé
2026-10-13 16:10 ` Philippe Mathieu-Daudé
2026-10-14 8:24 ` Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 12/20] system/physmem: Add ats_do_translate helper Ruslan Ruslichenko
2026-10-13 14:27 ` Clément MATHIEU--DRIF
2026-10-14 8:21 ` Ruslan Ruslichenko
2026-09-15 16:00 ` Ruslan Ruslichenko [this message]
2026-09-15 16:00 ` [PATCH v2 14/20] hw/core: Implement Remote Port ATS logic and cache management Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 15/20] hw/core: Add Remote Port memory slave device Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 16/20] hw/core: Add Remote Port GPIO/Interrupt bridge Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 17/20] hw/core: Add Remote Port Stream device Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 18/20] hw/core: Add Remote Port files to build Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 19/20] hw/core: Add FDT support to Remote Port GPIO Ruslan Ruslichenko
2026-09-15 16:00 ` [PATCH v2 20/20] hw/core: Add FDT support to Remote Port memory master Ruslan Ruslichenko
2026-09-28 7:30 ` [PATCH v2 00/20] hw/core: Introduce Remote Port Co-simulation Protocol Ruslan Ruslichenko
2026-10-13 16:17 ` Philippe Mathieu-Daudé
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=20260915160044.345788-14-ruslichenko.r@gmail.com \
--to=ruslichenko.r@gmail.com \
--cc=Ruslan_Ruslichenko@epam.com \
--cc=artem_mygaiev@epam.com \
--cc=berrange@redhat.com \
--cc=edgar.iglesias@amd.com \
--cc=edgar.iglesias@gmail.com \
--cc=eugene@nuvacore.ai \
--cc=francisco.iglesias@amd.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=takahiro.nakata.wr@renesas.com \
--cc=volodymyr_babchuk@epam.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.