mbox series

[RFC,0/2] Modify CCI cmd sets to be mutable

Message ID 20230720195819.17905-1-gregory.price@memverge.com
Headers show
Series Modify CCI cmd sets to be mutable | expand

Message

Gregory Price July 20, 2023, 7:58 p.m. UTC
This is on top of the proposed CCI changes by Jonathan.

Base repo: https://gitlab.com/jic23/qemu
Base branch: cxl-2023-07-17


A proposal to make the CCI cmd sets full members of their device,
and copy the const struct entries instead of referencing them.
This would allow child devices to inherit the parent device default
behavior, but with the flexibility to override without changing the
core device.

This also enables the base device to receive the commands via the
same /dev/cxl/XXXX device, simplifying testing.


An example of how one might override/add commands (paraphrased):


instantiating:

-device cxl-type3,bus=rp0,volatile-memdev=mem0,id=cxl-mem0
-device cxl-my-cmds,target=cxl-mem0


simple code:

static const struct cxl_cmd cxl_cmd_set_my_cmds[256][256] = {
    [MY_CMDS][GET_INFO] = { "SPECIAL_GET_INFO",
      cmd_my_cmds_get_info, 0, 0 },}

static void cxl_my_cmds_realize(DeviceState *d, Error **errp)
{
    CXL_MyCmds_State *s = CXL_MyCmds(d);

    if (object_dynamic_cast(OBJECT(s->target), TYPE_CXL_TYPE3)) {
        CXLType3Dev *ct3d = CXL_TYPE3(s->target);

        s->type = cxl_type3;
        s->cci = &ct3d->cci;

        cxl_add_cci_commands(&ct3d->cci, cxl_cmd_set_my_cmds, 512);
        return;
    }
    error_setg(errp, "Unhandled target type for CXL MHDSLD");
}

#define TYPE_CXL_Niagara "cxl-my-cmds"
static const TypeInfo cxl_my_cmds_info = {
    .name = TYPE_CXL_MyCmds,
    .parent = TYPE_CXL_TYPE3,
    .class_size = sizeof(struct CXL_MyCmdsClass),
    .class_init = cxl_my_cmds_class_init,
    .instance_size = sizeof(CXL_MyCmds_State),
    .interfaces = (InterfaceInfo[]) {
        { INTERFACE_CXL_DEVICE },
        { INTERFACE_PCIE_DEVICE },
        {}
    },
};

Signed-off-by: Gregory Price <gregory.price@memverge.com>

---
Gregory Price (2):
  cxl/mailbox: change CCI cmd set structure to be a member, not a
    refernce
  cxl/mailbox: interface to add CCI commands to an existing CCI

 hw/cxl/cxl-mailbox-utils.c  | 37 +++++++++++++++++++++++++++++++++----
 include/hw/cxl/cxl_device.h |  4 +++-
 2 files changed, 36 insertions(+), 5 deletions(-)