[v3,5/6] tools/testing/cxl: Mock the max err records field of Identify cmd

Message ID 14b883bd220ff388cc3a287cf104d83d53a2f520.1668115235.git.alison.schofield@intel.com
State New
Headers
Series CXL Poison List Retrieval & Tracing |

Commit Message

Alison Schofield Nov. 11, 2022, 3:12 a.m. UTC
  From: Alison Schofield <alison.schofield@intel.com>

The CXL mbox command Identify reports the maximum media error
records that a device will report. Mock it here for testing
the GET POISON LIST mbox command.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
 tools/testing/cxl/test/mem.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Jonathan Cameron Nov. 16, 2022, 12:51 p.m. UTC | #1
On Thu, 10 Nov 2022 19:12:43 -0800
alison.schofield@intel.com wrote:

> From: Alison Schofield <alison.schofield@intel.com>
> 
> The CXL mbox command Identify reports the maximum media error
> records that a device will report. Mock it here for testing
> the GET POISON LIST mbox command.
> 
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> ---
>  tools/testing/cxl/test/mem.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
> index aa2df3a15051..f0704d090073 100644
> --- a/tools/testing/cxl/test/mem.c
> +++ b/tools/testing/cxl/test/mem.c
> @@ -111,6 +111,10 @@ static int mock_id(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
>  			cpu_to_le64(DEV_SIZE / CXL_CAPACITY_MULTIPLIER),
>  	};
>  
> +	__le32 val = cpu_to_le32(SZ_64);
> +
> +	memcpy(id.poison_list_max_mer, &val, 3);
As in other direction, can we do this with a buffer of the right size if
we can't do a put_unaligned_le24() directly.

> +
>  	if (cmd->size_out < sizeof(id))
>  		return -EINVAL;
>
  
Alison Schofield Nov. 18, 2022, 12:25 a.m. UTC | #2
On Wed, Nov 16, 2022 at 12:51:45PM +0000, Jonathan Cameron wrote:
> On Thu, 10 Nov 2022 19:12:43 -0800
> alison.schofield@intel.com wrote:
> 
> > From: Alison Schofield <alison.schofield@intel.com>
> > 
> > The CXL mbox command Identify reports the maximum media error
> > records that a device will report. Mock it here for testing
> > the GET POISON LIST mbox command.
> > 
> > Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> > ---
> >  tools/testing/cxl/test/mem.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
> > index aa2df3a15051..f0704d090073 100644
> > --- a/tools/testing/cxl/test/mem.c
> > +++ b/tools/testing/cxl/test/mem.c
> > @@ -111,6 +111,10 @@ static int mock_id(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
> >  			cpu_to_le64(DEV_SIZE / CXL_CAPACITY_MULTIPLIER),
> >  	};
> >  
> > +	__le32 val = cpu_to_le32(SZ_64);
> > +
> > +	memcpy(id.poison_list_max_mer, &val, 3);
> As in other direction, can we do this with a buffer of the right size if
> we can't do a put_unaligned_le24() directly.
> 
Yes. Got it, thanks!

> > +
> >  	if (cmd->size_out < sizeof(id))
> >  		return -EINVAL;
> >  
>
  

Patch

diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
index aa2df3a15051..f0704d090073 100644
--- a/tools/testing/cxl/test/mem.c
+++ b/tools/testing/cxl/test/mem.c
@@ -111,6 +111,10 @@  static int mock_id(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
 			cpu_to_le64(DEV_SIZE / CXL_CAPACITY_MULTIPLIER),
 	};
 
+	__le32 val = cpu_to_le32(SZ_64);
+
+	memcpy(id.poison_list_max_mer, &val, 3);
+
 	if (cmd->size_out < sizeof(id))
 		return -EINVAL;