Lines Matching refs:dev_data

17 #define to_tio_status(dev_data)	\  argument
18 (container_of((dev_data), struct tio_dsm, data)->sev->tio_status)
535 struct tsm_dsm_tio *dev_data) in sev_tio_do_cmd() argument
548 rc1 = sla_expand(&dev_data->output, &dev_data->output_len); in sev_tio_do_cmd()
552 rc2 = sla_expand(&dev_data->scratch, &dev_data->scratch_len); in sev_tio_do_cmd()
567 struct sev_tio_status *tio_status = to_tio_status(dev_data); in sev_tio_do_cmd()
571 if (!dev_data->cmd) { in sev_tio_do_cmd()
574 if (WARN_ON(data_len > sizeof(dev_data->cmd_data))) in sev_tio_do_cmd()
576 memcpy(dev_data->cmd_data, data, data_len); in sev_tio_do_cmd()
577 memset(&dev_data->cmd_data[data_len], 0xFF, in sev_tio_do_cmd()
578 sizeof(dev_data->cmd_data) - data_len); in sev_tio_do_cmd()
579 dev_data->cmd = cmd; in sev_tio_do_cmd()
582 req_hdr = sla_to_dobj_req_hdr(dev_data->reqbuf); in sev_tio_do_cmd()
583 resp_hdr = sla_to_dobj_resp_hdr(dev_data->respbuf); in sev_tio_do_cmd()
595 dev_data->spdm.req_len = req_hdr->hdr.length - in sev_tio_do_cmd()
597 dev_data->spdm.rsp_len = resp_len; in sev_tio_do_cmd()
598 } else if (dev_data && dev_data->cmd) { in sev_tio_do_cmd()
600 memset(dev_data->cmd_data, 0, sizeof(dev_data->cmd_data)); in sev_tio_do_cmd()
601 dev_data->cmd = 0; in sev_tio_do_cmd()
607 int sev_tio_continue(struct tsm_dsm_tio *dev_data) in sev_tio_continue() argument
612 if (!dev_data || !dev_data->cmd) in sev_tio_continue()
615 resp_hdr = sla_to_dobj_resp_hdr(dev_data->respbuf); in sev_tio_continue()
617 dev_data->spdm.rsp_len, 32); in sev_tio_continue()
618 dev_data->respbuf->payload_sz = resp_hdr->hdr.length; in sev_tio_continue()
620 ret = sev_tio_do_cmd(dev_data->cmd, dev_data->cmd_data, 0, in sev_tio_continue()
621 &dev_data->psp_ret, dev_data); in sev_tio_continue()
625 if (dev_data->psp_ret != SEV_RET_SUCCESS) in sev_tio_continue()
631 static void spdm_ctrl_init(struct spdm_ctrl *ctrl, struct tsm_dsm_tio *dev_data) in spdm_ctrl_init() argument
633 ctrl->req = dev_data->req; in spdm_ctrl_init()
634 ctrl->resp = dev_data->resp; in spdm_ctrl_init()
635 ctrl->scratch = dev_data->scratch; in spdm_ctrl_init()
636 ctrl->output = dev_data->output; in spdm_ctrl_init()
639 static void spdm_ctrl_free(struct tsm_dsm_tio *dev_data) in spdm_ctrl_free() argument
641 struct sev_tio_status *tio_status = to_tio_status(dev_data); in spdm_ctrl_free()
645 struct tsm_spdm *spdm = &dev_data->spdm; in spdm_ctrl_free()
647 sla_buffer_unmap(dev_data->resp, dev_data->respbuf); in spdm_ctrl_free()
648 sla_buffer_unmap(dev_data->req, dev_data->reqbuf); in spdm_ctrl_free()
651 sla_free(dev_data->req, len, true); in spdm_ctrl_free()
652 sla_free(dev_data->resp, len, false); in spdm_ctrl_free()
653 sla_free(dev_data->scratch, tio_status->spdm_scratch_size_max, true); in spdm_ctrl_free()
655 dev_data->req.sla = 0; in spdm_ctrl_free()
656 dev_data->resp.sla = 0; in spdm_ctrl_free()
657 dev_data->scratch.sla = 0; in spdm_ctrl_free()
658 dev_data->respbuf = NULL; in spdm_ctrl_free()
659 dev_data->reqbuf = NULL; in spdm_ctrl_free()
660 sla_free(dev_data->output, tio_status->spdm_out_size_max, true); in spdm_ctrl_free()
663 static int spdm_ctrl_alloc(struct tsm_dsm_tio *dev_data) in spdm_ctrl_alloc() argument
665 struct sev_tio_status *tio_status = to_tio_status(dev_data); in spdm_ctrl_alloc()
666 struct tsm_spdm *spdm = &dev_data->spdm; in spdm_ctrl_alloc()
669 dev_data->req = sla_alloc(tio_status->spdm_req_size_max, true); in spdm_ctrl_alloc()
670 dev_data->resp = sla_alloc(tio_status->spdm_req_size_max, false); in spdm_ctrl_alloc()
671 dev_data->scratch_len = tio_status->spdm_scratch_size_max; in spdm_ctrl_alloc()
672 dev_data->scratch = sla_alloc(dev_data->scratch_len, true); in spdm_ctrl_alloc()
673 dev_data->output_len = tio_status->spdm_out_size_max; in spdm_ctrl_alloc()
674 dev_data->output = sla_alloc(dev_data->output_len, true); in spdm_ctrl_alloc()
676 if (IS_SLA_NULL(dev_data->req) || IS_SLA_NULL(dev_data->resp) || in spdm_ctrl_alloc()
677 IS_SLA_NULL(dev_data->scratch) || IS_SLA_NULL(dev_data->dev_ctx)) { in spdm_ctrl_alloc()
682 dev_data->reqbuf = sla_buffer_map(dev_data->req); in spdm_ctrl_alloc()
683 dev_data->respbuf = sla_buffer_map(dev_data->resp); in spdm_ctrl_alloc()
684 if (!dev_data->reqbuf || !dev_data->respbuf) { in spdm_ctrl_alloc()
689 spdm->req = sla_to_data(dev_data->reqbuf, SPDM_DOBJ_ID_REQ); in spdm_ctrl_alloc()
690 spdm->rsp = sla_to_data(dev_data->respbuf, SPDM_DOBJ_ID_RESP); in spdm_ctrl_alloc()
696 dobj_response_init(dev_data->respbuf); in spdm_ctrl_alloc()
701 spdm_ctrl_free(dev_data); in spdm_ctrl_alloc()
741 int sev_tio_dev_create(struct tsm_dsm_tio *dev_data, u16 device_id, in sev_tio_dev_create() argument
744 struct sev_tio_status *tio_status = to_tio_status(dev_data); in sev_tio_dev_create()
754 dev_data->dev_ctx = sla_alloc(tio_status->devctx_size, true); in sev_tio_dev_create()
755 if (IS_SLA_NULL(dev_data->dev_ctx)) in sev_tio_dev_create()
764 create.dev_ctx_sla = dev_data->dev_ctx; in sev_tio_dev_create()
765 ret = sev_do_cmd(SEV_CMD_TIO_DEV_CREATE, &create, &dev_data->psp_ret); in sev_tio_dev_create()
769 dev_data->data_pg = data_pg; in sev_tio_dev_create()
780 int sev_tio_dev_reclaim(struct tsm_dsm_tio *dev_data) in sev_tio_dev_reclaim() argument
782 struct sev_tio_status *tio_status = to_tio_status(dev_data); in sev_tio_dev_reclaim()
785 .dev_ctx_sla = dev_data->dev_ctx, in sev_tio_dev_reclaim()
789 if (dev_data->data_pg) { in sev_tio_dev_reclaim()
790 snp_free_firmware_page(dev_data->data_pg); in sev_tio_dev_reclaim()
791 dev_data->data_pg = NULL; in sev_tio_dev_reclaim()
794 if (IS_SLA_NULL(dev_data->dev_ctx)) in sev_tio_dev_reclaim()
797 ret = sev_do_cmd(SEV_CMD_TIO_DEV_RECLAIM, &r, &dev_data->psp_ret); in sev_tio_dev_reclaim()
799 sla_free(dev_data->dev_ctx, tio_status->devctx_size, true); in sev_tio_dev_reclaim()
800 dev_data->dev_ctx = SLA_NULL; in sev_tio_dev_reclaim()
802 spdm_ctrl_free(dev_data); in sev_tio_dev_reclaim()
807 int sev_tio_dev_connect(struct tsm_dsm_tio *dev_data, u8 tc_mask, u8 ids[8], u8 cert_slot) in sev_tio_dev_connect() argument
813 .dev_ctx_sla = dev_data->dev_ctx, in sev_tio_dev_connect()
821 if (WARN_ON(IS_SLA_NULL(dev_data->dev_ctx))) in sev_tio_dev_connect()
826 ret = spdm_ctrl_alloc(dev_data); in sev_tio_dev_connect()
830 spdm_ctrl_init(&connect.spdm_ctrl, dev_data); in sev_tio_dev_connect()
833 &dev_data->psp_ret, dev_data); in sev_tio_dev_connect()
836 int sev_tio_dev_disconnect(struct tsm_dsm_tio *dev_data, bool force) in sev_tio_dev_disconnect() argument
840 .dev_ctx_sla = dev_data->dev_ctx, in sev_tio_dev_disconnect()
844 if (WARN_ON_ONCE(IS_SLA_NULL(dev_data->dev_ctx))) in sev_tio_dev_disconnect()
847 spdm_ctrl_init(&dc.spdm_ctrl, dev_data); in sev_tio_dev_disconnect()
850 &dev_data->psp_ret, dev_data); in sev_tio_dev_disconnect()