[Skiboot] [PATCH RFC v2 11/12] prd: Implement firmware side of opaque PRD channel

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Fri May 26 21:42:18 AEST 2017


On 05/26/2017 08:24 AM, Jeremy Kerr wrote:
> This change introduces the firmware side of the opaque HBRT <--> OPAL
> message channel. We define a base message format to be shared with HBRT
> (in include/prd-fw-msg.h), and allow firmware requests and responses to
> be sent over this channel.
>
> We don't currently have any notifications defined, so have nothing to do
> for firmware_notify() at this stage.
>
> Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
> CC: Daniel M Crowell <dcrowell at us.ibm.com>
> ---

.../...

> +static int prd_msg_handle_firmware_req(struct opal_prd_msg *msg)
> +{
> +	unsigned long fw_req_len, fw_resp_len;
> +	struct prd_fw_msg *fw_req, *fw_resp;
> +	int rc;
> +
> +	fw_req_len = be64_to_cpu(msg->fw_req.req_len);
> +	fw_resp_len = be64_to_cpu(msg->fw_req.resp_len);
> +	fw_req = (struct prd_fw_msg *)msg->fw_req.data;
> +
> +	/* do we have a full firmware message? */
> +	if (fw_req_len < sizeof(struct prd_fw_msg))
> +		return -EINVAL;
> +
> +	/* does the total (outer) PRD message len provide enough data for the
> +	 * claimed (inner) FW message?
> +	 */
> +	if (msg->hdr.size < fw_req_len +
> +			offsetof(struct opal_prd_msg, fw_req.data))

This works fine.. But may be better be16_to_cpu(msg->hdr.size).

> +		return -EINVAL;
> +
> +	/* is there enough response buffer for a base response? Type-specific
> +	 * responses may be larger, but anything less than BASE_SIZE is
> +	 * invalid. */
> +	if (fw_resp_len < PRD_FW_MSG_BASE_SIZE)
> +		return -EINVAL;
> +
> +	/* prepare a response message. */
> +	lock(&events_lock);
> +	prd_msg_inuse = true;
> +	prd_msg->token = 0;
> +	prd_msg->hdr.type = OPAL_PRD_MSG_TYPE_FIRMWARE_RESPONSE;
> +	fw_resp = (void *)prd_msg->fw_resp.data;
> +
> +	switch (be64_to_cpu(fw_req->type)) {
> +	case PRD_FW_MSG_TYPE_REQ_NOP:
> +		fw_resp->type = cpu_to_be64(PRD_FW_MSG_TYPE_RESP_NOP);
> +		prd_msg->fw_resp.len = cpu_to_be64(PRD_FW_MSG_BASE_SIZE);
> +		prd_msg->hdr.size = cpu_to_be16(sizeof(*prd_msg));
> +		rc = 0;
> +		break;
> +	default:
> +		rc = -ENOSYS;

better  rc =  OPAL_UNSUPPORTED?

-Vasant


> +	}
> +
> +	if (!rc)
> +		rc = _opal_queue_msg(OPAL_MSG_PRD, prd_msg, prd_msg_consumed, 4,
> +				(uint64_t *) prd_msg);
> +	else
> +		prd_msg_inuse = false;
> +
> +	unlock(&events_lock);
> +
> +	return rc;
> +}
> +



More information about the Skiboot mailing list