@@ -87,6 +87,17 @@ static void pldm_add_type(struct pldm_type *new_type)
new_type->name, new_type->pldm_type_id);
}
+static void pldm_add_cmd(struct pldm_type *type, struct pldm_cmd *new_cmd)
+{
+ assert(new_cmd->pldm_cmd_id < 256); /* limited by GetPLDMCommands */
+ assert(new_cmd->handler);
+ assert(!find_cmd(type, new_cmd->pldm_cmd_id));
+
+ list_add_tail(&type->commands, &new_cmd->link);
+ prlog(PR_DEBUG, "Registered command %s (%d) under %s\n",
+ new_cmd->name, new_cmd->pldm_cmd_id, type->name);
+}
+
/*
* PLDM Base commands support
*/
@@ -96,6 +107,44 @@ static struct pldm_type pldm_base_type = {
.version = { 0xF1, 0xF0, 0xF0, 0x00 },
};
+/*
+ * GetTID command (0x02)
+ * The GetTID command is used to retrieve the present Terminus ID (TID)
+ * setting for a PLDM Terminus.
+ */
+static int base_get_tid_handler(const struct pldm_rx_data *req)
+{
+ char response_msg[PKT_SIZE(struct pldm_get_tid_resp)];
+ int rc;
+
+ memset(response_msg, 0, sizeof(response_msg));
+
+ rc = encode_get_tid_resp(req->hdrinf.instance,
+ PLDM_SUCCESS,
+ HOST_TID,
+ (struct pldm_msg *)response_msg);
+ if (rc != PLDM_SUCCESS) {
+ prlog(PR_ERR, "Encode GetTID Error, rc: %d\n", rc);
+ pldm_cc_resp(req, req->hdrinf.pldm_type,
+ req->hdrinf.command, PLDM_ERROR);
+ return OPAL_PARAMETER;
+ }
+
+ rc = pldm_send(req->source_eid, response_msg, sizeof(response_msg));
+ if (rc) {
+ prlog(PR_ERR, "Failed to send GetTID response, rc = %d\n", rc);
+ return OPAL_HARDWARE;
+ }
+
+ return OPAL_SUCCESS;
+}
+
+static struct pldm_cmd pldm_base_get_tid = {
+ .name = "PLDM_GET_TID",
+ .pldm_cmd_id = PLDM_GET_TID,
+ .handler = base_get_tid_handler,
+};
+
int pldm_rx_handle_request(struct pldm_rx_data *rx)
{
const struct pldm_type *t;
@@ -131,6 +180,7 @@ int pldm_mctp_responder_init(void)
{
/* Register mandatory commands we'll respond to - DSP0240 */
pldm_add_type(&pldm_base_type);
+ pldm_add_cmd(&pldm_base_type, &pldm_base_get_tid);
return OPAL_SUCCESS;
}
@@ -20,6 +20,12 @@ void printbuf(const char *name, const char *msg, int len);
#define BMC_EID 8
#define HOST_EID 9
+/*
+ * Skiboot's PLDM Terminus ID.
+ * BMC TID is 1, HB is 2, Skiboot is 3.
+ */
+#define HOST_TID 3
+
#define PKT_SIZE(x) (sizeof(struct pldm_msg_hdr) + sizeof(x))
struct pldm_rx_data {