From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: <shiju.jose@huawei.com>
Cc: <qemu-devel@nongnu.org>, <linux-cxl@vger.kernel.org>,
<tanxiaofei@huawei.com>, <prime.zeng@hisilicon.com>,
<linuxarm@huawei.com>
Subject: Re: [PATCH v4 1/3] hw/cxl/cxl-mailbox-utils: Add support for feature commands (8.2.9.6)
Date: Mon, 19 Feb 2024 16:38:34 +0000 [thread overview]
Message-ID: <20240219163834.00005d6e@Huawei.com> (raw)
In-Reply-To: <20240219150025.1531-2-shiju.jose@huawei.com>
On Mon, 19 Feb 2024 23:00:23 +0800
<shiju.jose@huawei.com> wrote:
> From: Shiju Jose <shiju.jose@huawei.com>
>
> CXL spec 3.1 section 8.2.9.6 describes optional device specific features.
> CXL devices supports features with changeable attributes.
> Get Supported Features retrieves the list of supported device specific
> features. The settings of a feature can be retrieved using Get Feature and
> optionally modified using Set Feature.
>
> Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
> Reviewed-by: Fan Ni <fan.ni@samsung.com>
> Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
Hi Shiju,
Sorry I've taken so long to get to this!
Looks good. One small comment inline.
Jonathan
> +
> +/* CXL r3.1 section 8.2.9.6.1: Get Supported Features (Opcode 0500h) */
> +static CXLRetCode cmd_features_get_supported(const struct cxl_cmd *cmd,
> + uint8_t *payload_in,
> + size_t len_in,
> + uint8_t *payload_out,
> + size_t *len_out,
> + CXLCCI *cci)
> +{
> + struct {
> + uint32_t count;
> + uint16_t start_index;
> + uint16_t reserved;
> + } QEMU_PACKED QEMU_ALIGNED(16) * get_feats_in = (void *)payload_in;
> +
> + struct {
> + CXLSupportedFeatureHeader hdr;
> + CXLSupportedFeatureEntry feat_entries[];
> + } QEMU_PACKED QEMU_ALIGNED(16) * get_feats_out = (void *)payload_out;
> + uint16_t index;
> + uint16_t entry, req_entries;
> + uint16_t feat_entries = 0;
> +
> + if (get_feats_in->count < sizeof(CXLSupportedFeatureHeader) ||
> + get_feats_in->start_index > CXL_FEATURE_MAX) {
> + return CXL_MBOX_INVALID_INPUT;
> + }
> + req_entries = (get_feats_in->count -
> + sizeof(CXLSupportedFeatureHeader)) /
> + sizeof(CXLSupportedFeatureEntry);
I'm struggling a bit with the Specification text.
I says that count is
"Count in bytes of the supported Feature data to return in the
output payload."
I suppose that includes the header but it's not entirely clear
to me. Let's go with what we have here unless we get a spec
clarification.
> + req_entries = MIN(req_entries, CXL_FEATURE_MAX);
> + index = get_feats_in->start_index;
> +
> + entry = 0;
> + while (entry < req_entries) {
Given it's a known set of bounds a for loops should be
easier to read.
for (index = get_feats_in->start_index;
index < req_entries;
index++) {
switch (index) {
default:
__builtin_unreachable();
}
}
> + switch (index) {
> + default:
> + break;
> + }
> + index++;
> + entry++;
> + }
> +
> + get_feats_out->hdr.nsuppfeats_dev = CXL_FEATURE_MAX;
> + get_feats_out->hdr.entries = feat_entries;
> + *len_out = sizeof(CXLSupportedFeatureHeader) +
> + feat_entries * sizeof(CXLSupportedFeatureEntry);
> +
> + return CXL_MBOX_SUCCESS;
> +}
next prev parent reply other threads:[~2024-02-19 16:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-19 15:00 [PATCH v4 0/3] hw/cxl/cxl-mailbox-utils: Add feature commands, device patrol scrub control and DDR5 ECS control features shiju.jose--- via
2024-02-19 15:00 ` [PATCH v4 1/3] hw/cxl/cxl-mailbox-utils: Add support for feature commands (8.2.9.6) shiju.jose--- via
2024-02-19 16:38 ` Jonathan Cameron via [this message]
2024-02-19 15:00 ` [PATCH v4 2/3] hw/cxl/cxl-mailbox-utils: Add device patrol scrub control feature shiju.jose--- via
2024-02-19 16:49 ` Jonathan Cameron via
2024-02-19 15:00 ` [PATCH v4 3/3] hw/cxl/cxl-mailbox-utils: Add device DDR5 ECS " shiju.jose--- via
2024-02-19 16:59 ` Jonathan Cameron via
2024-02-19 17:46 ` Shiju Jose via
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=20240219163834.00005d6e@Huawei.com \
--to=qemu-devel@nongnu.org \
--cc=Jonathan.Cameron@Huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=prime.zeng@hisilicon.com \
--cc=shiju.jose@huawei.com \
--cc=tanxiaofei@huawei.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 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).