All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anup Patel <apatel@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v2 09/13] lib: utils: Implement get_attribute() for the RPMI shared memory mailbox
Date: Wed, 22 Jan 2025 12:14:36 +0530	[thread overview]
Message-ID: <20250122064441.272115-10-apatel@ventanamicro.com> (raw)
In-Reply-To: <20250122064441.272115-1-apatel@ventanamicro.com>

To allow clients query service group version of a RPMI mailbox channel,
implement get_attribute() callback for the RPMI shared memory mailbox
controller.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 include/sbi_utils/mailbox/rpmi_msgprot.h   | 13 +++++++-
 lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c | 35 ++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/include/sbi_utils/mailbox/rpmi_msgprot.h b/include/sbi_utils/mailbox/rpmi_msgprot.h
index 9575dc72..17d678a3 100644
--- a/include/sbi_utils/mailbox/rpmi_msgprot.h
+++ b/include/sbi_utils/mailbox/rpmi_msgprot.h
@@ -175,7 +175,7 @@ enum rpmi_error {
 	RPMI_ERR_VENDOR_START	= -128,
 };
 
-/** RPMI Message Arguments */
+/** RPMI Mailbox Message Arguments */
 struct rpmi_message_args {
 	u32 flags;
 #define RPMI_MSG_FLAGS_NO_TX		(1U << 0)
@@ -189,6 +189,17 @@ struct rpmi_message_args {
 	u32 rx_data_len;
 };
 
+/** RPMI Mailbox Channel Attribute IDs */
+enum rpmi_channel_attribute_id {
+	RPMI_CHANNEL_ATTR_PROTOCOL_VERSION = 0,
+	RPMI_CHANNEL_ATTR_MAX_DATA_LEN,
+	RPMI_CHANNEL_ATTR_TX_TIMEOUT,
+	RPMI_CHANNEL_ATTR_RX_TIMEOUT,
+	RPMI_CHANNEL_ATTR_SERVICEGROUP_ID,
+	RPMI_CHANNEL_ATTR_SERVICEGROUP_VERSION,
+	RPMI_CHANNEL_ATTR_MAX,
+};
+
 /*
  * RPMI SERVICEGROUPS AND SERVICES
  */
diff --git a/lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c b/lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c
index b8bd3cd6..e9f52c7a 100644
--- a/lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c
+++ b/lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c
@@ -490,6 +490,40 @@ static int rpmi_shmem_mbox_xfer(struct mbox_chan *chan, struct mbox_xfer *xfer)
 	return 0;
 }
 
+static int rpmi_shmem_mbox_get_attribute(struct mbox_chan *chan,
+					 int attr_id, void *out_value)
+{
+	struct rpmi_shmem_mbox_controller *mctl =
+			container_of(chan->mbox,
+				     struct rpmi_shmem_mbox_controller,
+				     controller);
+	struct rpmi_srvgrp_chan *srvgrp_chan = to_srvgrp_chan(chan);
+
+	switch (attr_id) {
+	case RPMI_CHANNEL_ATTR_PROTOCOL_VERSION:
+		*((u32 *)out_value) = mctl->spec_version;
+		break;
+	case RPMI_CHANNEL_ATTR_MAX_DATA_LEN:
+		*((u32 *)out_value) = RPMI_MSG_DATA_SIZE(mctl->slot_size);
+		break;
+	case RPMI_CHANNEL_ATTR_TX_TIMEOUT:
+		*((u32 *)out_value) = RPMI_DEF_TX_TIMEOUT;
+		break;
+	case RPMI_CHANNEL_ATTR_RX_TIMEOUT:
+		*((u32 *)out_value) = RPMI_DEF_RX_TIMEOUT;
+		break;
+	case RPMI_CHANNEL_ATTR_SERVICEGROUP_ID:
+		*((u32 *)out_value) = srvgrp_chan->servicegroup_id;
+		break;
+	case RPMI_CHANNEL_ATTR_SERVICEGROUP_VERSION:
+		*((u32 *)out_value) = srvgrp_chan->servicegroup_version;
+		break;
+	default:
+		return SBI_ENOTSUPP;
+	}
+
+	return 0;
+}
 
 static struct mbox_chan *rpmi_shmem_mbox_request_chan(
 						struct mbox_controller *mbox,
@@ -665,6 +699,7 @@ static int rpmi_shmem_mbox_init(const void *fdt, int nodeoff,
 	mctl->controller.request_chan = rpmi_shmem_mbox_request_chan;
 	mctl->controller.free_chan = rpmi_shmem_mbox_free_chan;
 	mctl->controller.xfer = rpmi_shmem_mbox_xfer;
+	mctl->controller.get_attribute = rpmi_shmem_mbox_get_attribute;
 	ret = mbox_controller_add(&mctl->controller);
 	if (ret)
 		goto fail_free_controller;
-- 
2.43.0



  parent reply	other threads:[~2025-01-22  6:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-22  6:44 [PATCH v2 00/13] More RPMI and MPXY updates Anup Patel
2025-01-22  6:44 ` [PATCH v2 01/13] lib: utils: Split the FDT MPXY RPMI mailbox client into two parts Anup Patel
2025-01-22  6:44 ` [PATCH v2 02/13] lib: utils: Constantify mpxy_rpmi_mbox_data in mpxy_rpmi_mbox Anup Patel
2025-01-22  6:44 ` [PATCH v2 03/13] lib: utils: Introduce optional MPXY RPMI service group operations Anup Patel
2025-01-22  6:44 ` [PATCH v2 04/13] lib: sbi: Fix capability bit assignment in MPXY framework Anup Patel
2025-01-22  6:44 ` [PATCH v2 05/13] lib: sbi: Improve local variable declarations " Anup Patel
2025-01-22  6:44 ` [PATCH v2 06/13] lib: utils: Drop notifications from MPXY RPMI mailbox client Anup Patel
2025-01-22  6:44 ` [PATCH v2 07/13] lib: utils: Improve variable declarations in " Anup Patel
2025-01-22  6:44 ` [PATCH v2 08/13] include: sbi_utils: Include mailbox.h in rpmi_mailbox.h header Anup Patel
2025-01-22  6:44 ` Anup Patel [this message]
2025-01-22  6:44 ` [PATCH v2 10/13] lib: utils: Populate MPXY channel attributes from RPMI channel attributes Anup Patel
2025-01-22  6:44 ` [PATCH v2 11/13] include: sbi_utils: Update RPMI service group IDs and BASE service group Anup Patel
2025-01-22  6:44 ` [PATCH v2 12/13] lib: utils: Add MPXY RPMI mailbox driver for System MSI " Anup Patel
2025-01-22  6:44 ` [PATCH v2 13/13] lib: sbi: Update MPXY framework and SBI extension as per latest spec Anup Patel
2025-02-13  5:48 ` [PATCH v2 00/13] More RPMI and MPXY updates Anup Patel

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=20250122064441.272115-10-apatel@ventanamicro.com \
    --to=apatel@ventanamicro.com \
    --cc=opensbi@lists.infradead.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 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.