From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: <qemu-devel@nongnu.org>, Michael Tsirkin <mst@redhat.com>,
Fan Ni <fan.ni@samsung.com>, <linux-cxl@vger.kernel.org>
Cc: "Dave Jiang" <dave.jiang@intel.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
linuxarm@huawei.com
Subject: [PATCH 1/2] hw/cxl: Add utility functions decoder interleave ways and target count.
Date: Mon, 4 Sep 2023 17:47:03 +0100 [thread overview]
Message-ID: <20230904164704.18739-2-Jonathan.Cameron@huawei.com> (raw)
In-Reply-To: <20230904164704.18739-1-Jonathan.Cameron@huawei.com>
As an encoded version of these key configuration parameters is
a register, provide functions to extract it again so as to avoid
the need for duplicating the storage.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
include/hw/cxl/cxl_component.h | 14 ++++++++++++++
hw/cxl/cxl-component-utils.c | 17 +++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h
index 42c7e581a7..f0ad9cf7de 100644
--- a/include/hw/cxl/cxl_component.h
+++ b/include/hw/cxl/cxl_component.h
@@ -238,7 +238,21 @@ static inline int cxl_decoder_count_enc(int count)
return 0;
}
+static inline int cxl_decoder_count_dec(int enc_cnt)
+{
+ switch (enc_cnt) {
+ case 0: return 1;
+ case 1: return 2;
+ case 2: return 4;
+ case 3: return 6;
+ case 4: return 8;
+ case 5: return 10;
+ }
+ return 0;
+}
+
uint8_t cxl_interleave_ways_enc(int iw, Error **errp);
+int cxl_interleave_ways_dec(uint8_t iw_enc, Error **errp);
uint8_t cxl_interleave_granularity_enc(uint64_t gran, Error **errp);
static inline hwaddr cxl_decode_ig(int ig)
diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c
index 378f1082ce..e96398e8af 100644
--- a/hw/cxl/cxl-component-utils.c
+++ b/hw/cxl/cxl-component-utils.c
@@ -392,6 +392,23 @@ uint8_t cxl_interleave_ways_enc(int iw, Error **errp)
}
}
+int cxl_interleave_ways_dec(uint8_t iw_enc, Error **errp)
+{
+ switch (iw_enc) {
+ case 0x0: return 1;
+ case 0x1: return 2;
+ case 0x2: return 4;
+ case 0x3: return 8;
+ case 0x4: return 16;
+ case 0x8: return 3;
+ case 0x9: return 6;
+ case 0xa: return 12;
+ default:
+ error_setg(errp, "Encoded interleave ways: %d not supported", iw_enc);
+ return 0;
+ }
+}
+
uint8_t cxl_interleave_granularity_enc(uint64_t gran, Error **errp)
{
switch (gran) {
--
2.39.2
next prev parent reply other threads:[~2023-09-04 16:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 16:47 [PATCH 0/2] hw/cxl: Support emulating 4 HDM decoders throughout topology Jonathan Cameron
2023-09-04 16:47 ` Jonathan Cameron [this message]
2023-09-04 18:26 ` [PATCH 1/2] hw/cxl: Add utility functions decoder interleave ways and target count Philippe Mathieu-Daudé
2023-09-05 14:56 ` Jonathan Cameron
2023-09-05 15:06 ` Jonathan Cameron
2023-09-05 16:55 ` Philippe Mathieu-Daudé
2023-09-07 11:27 ` Jonathan Cameron
2023-09-04 16:47 ` [PATCH 2/2] hw/cxl: Support 4 HDM decoders at all levels of topology Jonathan Cameron
2023-09-04 18:36 ` Philippe Mathieu-Daudé
2023-09-05 15:44 ` Jonathan Cameron
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=20230904164704.18739-2-Jonathan.Cameron@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=dave.jiang@intel.com \
--cc=fan.ni@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