Re: [PATCH RFC v2 17/18] tools/testing/cxl: Add DC Regions to mock mem data

From: Jonathan Cameron
Date: Wed Aug 30 2023 - 15:30:05 EST


On Mon, 28 Aug 2023 22:21:08 -0700
Ira Weiny <ira.weiny@xxxxxxxxx> wrote:

> To test DC regions the mock memory devices will need to store
> information about the regions and manage fake extent data.
>
> Define mock_dc_region information within the mock memory data. Add
> sysfs entries on the mock device to inject and delete extents.
>
> The inject format is <start>:<length>:<tag>
> The delete format is <start>
>
> Add DC mailbox commands to the CEL and implement those commands.
>
> Signed-off-by: Ira Weiny <ira.weiny@xxxxxxxxx>

Looks fine to me. Totally trivial comment inline.

FWIW
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>


> +
> static int mock_gsl(struct cxl_mbox_cmd *cmd)
> {
> if (cmd->size_out < sizeof(mock_gsl_payload))
> @@ -1315,6 +1429,148 @@ static int mock_activate_fw(struct cxl_mockmem_data *mdata,
> return -EINVAL;
> }
>

Bit inconsistent on whether there are one or two blank lines between functions.

> +static int mock_get_dc_config(struct device *dev,
> + struct cxl_mbox_cmd *cmd)
> +{
> + struct cxl_mbox_get_dc_config *dc_config = cmd->payload_in;
> + struct cxl_mockmem_data *mdata = dev_get_drvdata(dev);
> + u8 region_requested, region_start_idx, region_ret_cnt;
> + struct cxl_mbox_dynamic_capacity *resp;
> +
> + region_requested = dc_config->region_count;
> + if (NUM_MOCK_DC_REGIONS < region_requested)
> + region_requested = NUM_MOCK_DC_REGIONS;
> +
> + if (cmd->size_out < struct_size(resp, region, region_requested))
> + return -EINVAL;
> +
> + memset(cmd->payload_out, 0, cmd->size_out);
> + resp = cmd->payload_out;
> +
> + region_start_idx = dc_config->start_region_index;
> + region_ret_cnt = 0;
> + for (int i = 0; i < NUM_MOCK_DC_REGIONS; i++) {
> + if (i >= region_start_idx) {
> + memcpy(&resp->region[region_ret_cnt],
> + &mdata->dc_regions[i],
> + sizeof(resp->region[region_ret_cnt]));
> + region_ret_cnt++;
> + }
> + }
> + resp->avail_region_count = region_ret_cnt;
> +
> + dev_dbg(dev, "Returning %d dc regions\n", region_ret_cnt);
> + return 0;
> +}