diff mbox series

[08/18] libsbefifo: Add implementation of suspend_io chipop

Message ID 20200924044236.130586-9-amitay@ozlabs.org
State Superseded
Headers show
Series Add p10 support to libpdbg | expand

Commit Message

Amitay Isaacs Sept. 24, 2020, 4:42 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libsbefifo/cmd_control.c     | 51 ++++++++++++++++++++++++++++++++++++
 libsbefifo/libsbefifo.h      |  1 +
 libsbefifo/sbefifo_private.h |  1 +
 3 files changed, 53 insertions(+)

Comments

Joel Stanley Sept. 28, 2020, 5:53 a.m. UTC | #1
On Thu, 24 Sep 2020 at 04:43, Amitay Isaacs <amitay@ozlabs.org> wrote:
>
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>

Is there a document or source file you can refer to for the definition of these?


> ---
>  libsbefifo/cmd_control.c     | 51 ++++++++++++++++++++++++++++++++++++
>  libsbefifo/libsbefifo.h      |  1 +
>  libsbefifo/sbefifo_private.h |  1 +
>  3 files changed, 53 insertions(+)
>
> diff --git a/libsbefifo/cmd_control.c b/libsbefifo/cmd_control.c
> index 9293ef9..4826b5d 100644
> --- a/libsbefifo/cmd_control.c
> +++ b/libsbefifo/cmd_control.c
> @@ -76,3 +76,54 @@ int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t m
>
>         return rc;
>  }
> +
> +static int sbefifo_suspend_io_push(uint8_t **buf, uint32_t *buflen)
> +{
> +       uint32_t *msg;
> +       uint32_t nwords, cmd;
> +
> +       nwords = 2;
> +       *buflen = nwords * sizeof(uint32_t);
> +       msg = malloc(*buflen);
> +       if (!msg)
> +               return ENOMEM;
> +
> +       cmd = SBEFIFO_CMD_CLASS_CONTROL | SBEFIFO_CMD_SUSPEND_IO;
> +
> +       msg[0] = htobe32(nwords);
> +       msg[1] = htobe32(cmd);
> +
> +       *buf = (uint8_t *)msg;
> +       return 0;
> +}
> +
> +static int sbefifo_suspend_io_pull(uint8_t *buf, uint32_t buflen)
> +{
> +       if (buflen != 0)
> +               return EPROTO;
> +
> +       return 0;
> +}
> +
> +int sbefifo_suspend_io(struct sbefifo_context *sctx)
> +{
> +       uint8_t *msg, *out;
> +       uint32_t msg_len, out_len;
> +       int rc;
> +
> +       rc = sbefifo_suspend_io_push(&msg, &msg_len);
> +       if (rc)
> +               return rc;
> +
> +       out_len = 0;
> +       rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
> +       free(msg);
> +       if (rc)
> +               return rc;
> +
> +       rc = sbefifo_suspend_io_pull(out, out_len);
> +       if (out)
> +               free(out);
> +
> +       return rc;
> +}
> diff --git a/libsbefifo/libsbefifo.h b/libsbefifo/libsbefifo.h
> index 3af54b4..1c26ea3 100644
> --- a/libsbefifo/libsbefifo.h
> +++ b/libsbefifo/libsbefifo.h
> @@ -73,6 +73,7 @@ uint32_t sbefifo_ffdc_get(struct sbefifo_context *sctx, const uint8_t **ffdc, ui
>  void sbefifo_ffdc_dump(struct sbefifo_context *sctx);
>
>  int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t minor);
> +int sbefifo_suspend_io(struct sbefifo_context *sctx);
>
>  #define SBEFIFO_SCOM_OPERAND_NONE        0
>  #define SBEFIFO_SCOM_OPERAND_OR          1
> diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h
> index 6262c3e..5c9b10a 100644
> --- a/libsbefifo/sbefifo_private.h
> +++ b/libsbefifo/sbefifo_private.h
> @@ -22,6 +22,7 @@
>
>  #define SBEFIFO_CMD_CLASS_CONTROL        0xA100
>  #define   SBEFIFO_CMD_EXECUTE_ISTEP        0x01
> +#define   SBEFIFO_CMD_SUSPEND_IO           0x02
>
>  #define SBEFIFO_CMD_CLASS_SCOM           0xA200
>  #define   SBEFIFO_CMD_GET_SCOM             0x01
> --
> 2.26.2
>
> --
> Pdbg mailing list
> Pdbg@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg
Amitay Isaacs Sept. 28, 2020, 6:05 a.m. UTC | #2
On Mon, 2020-09-28 at 05:53 +0000, Joel Stanley wrote:
> On Thu, 24 Sep 2020 at 04:43, Amitay Isaacs <amitay@ozlabs.org>
> wrote:
> > Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> 
> Is there a document or source file you can refer to for the
> definition of these?

There is SBE interface specification document for P10 which has not yet
released.  You can get access to current draft.

> 
> 
> > ---
> >  libsbefifo/cmd_control.c     | 51
> > ++++++++++++++++++++++++++++++++++++
> >  libsbefifo/libsbefifo.h      |  1 +
> >  libsbefifo/sbefifo_private.h |  1 +
> >  3 files changed, 53 insertions(+)
> > 
> > diff --git a/libsbefifo/cmd_control.c b/libsbefifo/cmd_control.c
> > index 9293ef9..4826b5d 100644
> > --- a/libsbefifo/cmd_control.c
> > +++ b/libsbefifo/cmd_control.c
> > @@ -76,3 +76,54 @@ int sbefifo_istep_execute(struct sbefifo_context
> > *sctx, uint8_t major, uint8_t m
> > 
> >         return rc;
> >  }
> > +
> > +static int sbefifo_suspend_io_push(uint8_t **buf, uint32_t
> > *buflen)
> > +{
> > +       uint32_t *msg;
> > +       uint32_t nwords, cmd;
> > +
> > +       nwords = 2;
> > +       *buflen = nwords * sizeof(uint32_t);
> > +       msg = malloc(*buflen);
> > +       if (!msg)
> > +               return ENOMEM;
> > +
> > +       cmd = SBEFIFO_CMD_CLASS_CONTROL | SBEFIFO_CMD_SUSPEND_IO;
> > +
> > +       msg[0] = htobe32(nwords);
> > +       msg[1] = htobe32(cmd);
> > +
> > +       *buf = (uint8_t *)msg;
> > +       return 0;
> > +}
> > +
> > +static int sbefifo_suspend_io_pull(uint8_t *buf, uint32_t buflen)
> > +{
> > +       if (buflen != 0)
> > +               return EPROTO;
> > +
> > +       return 0;
> > +}
> > +
> > +int sbefifo_suspend_io(struct sbefifo_context *sctx)
> > +{
> > +       uint8_t *msg, *out;
> > +       uint32_t msg_len, out_len;
> > +       int rc;
> > +
> > +       rc = sbefifo_suspend_io_push(&msg, &msg_len);
> > +       if (rc)
> > +               return rc;
> > +
> > +       out_len = 0;
> > +       rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
> > +       free(msg);
> > +       if (rc)
> > +               return rc;
> > +
> > +       rc = sbefifo_suspend_io_pull(out, out_len);
> > +       if (out)
> > +               free(out);
> > +
> > +       return rc;
> > +}
> > diff --git a/libsbefifo/libsbefifo.h b/libsbefifo/libsbefifo.h
> > index 3af54b4..1c26ea3 100644
> > --- a/libsbefifo/libsbefifo.h
> > +++ b/libsbefifo/libsbefifo.h
> > @@ -73,6 +73,7 @@ uint32_t sbefifo_ffdc_get(struct sbefifo_context
> > *sctx, const uint8_t **ffdc, ui
> >  void sbefifo_ffdc_dump(struct sbefifo_context *sctx);
> > 
> >  int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t
> > major, uint8_t minor);
> > +int sbefifo_suspend_io(struct sbefifo_context *sctx);
> > 
> >  #define SBEFIFO_SCOM_OPERAND_NONE        0
> >  #define SBEFIFO_SCOM_OPERAND_OR          1
> > diff --git a/libsbefifo/sbefifo_private.h
> > b/libsbefifo/sbefifo_private.h
> > index 6262c3e..5c9b10a 100644
> > --- a/libsbefifo/sbefifo_private.h
> > +++ b/libsbefifo/sbefifo_private.h
> > @@ -22,6 +22,7 @@
> > 
> >  #define SBEFIFO_CMD_CLASS_CONTROL        0xA100
> >  #define   SBEFIFO_CMD_EXECUTE_ISTEP        0x01
> > +#define   SBEFIFO_CMD_SUSPEND_IO           0x02
> > 
> >  #define SBEFIFO_CMD_CLASS_SCOM           0xA200
> >  #define   SBEFIFO_CMD_GET_SCOM             0x01
> > --
> > 2.26.2
> > 
> > --
> > Pdbg mailing list
> > Pdbg@lists.ozlabs.org
> > https://lists.ozlabs.org/listinfo/pdbg

Amitay.
Joel Stanley Sept. 28, 2020, 6:11 a.m. UTC | #3
On Mon, 28 Sep 2020 at 06:05, Amitay Isaacs <amitay@ozlabs.org> wrote:
>
> On Mon, 2020-09-28 at 05:53 +0000, Joel Stanley wrote:
> > On Thu, 24 Sep 2020 at 04:43, Amitay Isaacs <amitay@ozlabs.org>
> > wrote:
> > > Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> >
> > Is there a document or source file you can refer to for the
> > definition of these?
>
> There is SBE interface specification document for P10 which has not yet
> released.  You can get access to current draft.

That's what I was after. Can you put the name in the commit or the
source, so we know where to go looking?
Amitay Isaacs Sept. 28, 2020, 6:59 a.m. UTC | #4
On Mon, 2020-09-28 at 06:11 +0000, Joel Stanley wrote:
> On Mon, 28 Sep 2020 at 06:05, Amitay Isaacs <amitay@ozlabs.org>
> wrote:
> > On Mon, 2020-09-28 at 05:53 +0000, Joel Stanley wrote:
> > > On Thu, 24 Sep 2020 at 04:43, Amitay Isaacs <amitay@ozlabs.org>
> > > wrote:
> > > > Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> > > 
> > > Is there a document or source file you can refer to for the
> > > definition of these?
> > 
> > There is SBE interface specification document for P10 which has not
> > yet
> > released.  You can get access to current draft.
> 
> That's what I was after. Can you put the name in the commit or the
> source, so we know where to go looking?

Sure, will add the information to sbefifo.h.

Amitay.
diff mbox series

Patch

diff --git a/libsbefifo/cmd_control.c b/libsbefifo/cmd_control.c
index 9293ef9..4826b5d 100644
--- a/libsbefifo/cmd_control.c
+++ b/libsbefifo/cmd_control.c
@@ -76,3 +76,54 @@  int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t m
 
 	return rc;
 }
+
+static int sbefifo_suspend_io_push(uint8_t **buf, uint32_t *buflen)
+{
+	uint32_t *msg;
+	uint32_t nwords, cmd;
+
+	nwords = 2;
+	*buflen = nwords * sizeof(uint32_t);
+	msg = malloc(*buflen);
+	if (!msg)
+		return ENOMEM;
+
+	cmd = SBEFIFO_CMD_CLASS_CONTROL | SBEFIFO_CMD_SUSPEND_IO;
+
+	msg[0] = htobe32(nwords);
+	msg[1] = htobe32(cmd);
+
+	*buf = (uint8_t *)msg;
+	return 0;
+}
+
+static int sbefifo_suspend_io_pull(uint8_t *buf, uint32_t buflen)
+{
+	if (buflen != 0)
+		return EPROTO;
+
+	return 0;
+}
+
+int sbefifo_suspend_io(struct sbefifo_context *sctx)
+{
+	uint8_t *msg, *out;
+	uint32_t msg_len, out_len;
+	int rc;
+
+	rc = sbefifo_suspend_io_push(&msg, &msg_len);
+	if (rc)
+		return rc;
+
+	out_len = 0;
+	rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+	free(msg);
+	if (rc)
+		return rc;
+
+	rc = sbefifo_suspend_io_pull(out, out_len);
+	if (out)
+		free(out);
+
+	return rc;
+}
diff --git a/libsbefifo/libsbefifo.h b/libsbefifo/libsbefifo.h
index 3af54b4..1c26ea3 100644
--- a/libsbefifo/libsbefifo.h
+++ b/libsbefifo/libsbefifo.h
@@ -73,6 +73,7 @@  uint32_t sbefifo_ffdc_get(struct sbefifo_context *sctx, const uint8_t **ffdc, ui
 void sbefifo_ffdc_dump(struct sbefifo_context *sctx);
 
 int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t minor);
+int sbefifo_suspend_io(struct sbefifo_context *sctx);
 
 #define SBEFIFO_SCOM_OPERAND_NONE        0
 #define SBEFIFO_SCOM_OPERAND_OR          1
diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h
index 6262c3e..5c9b10a 100644
--- a/libsbefifo/sbefifo_private.h
+++ b/libsbefifo/sbefifo_private.h
@@ -22,6 +22,7 @@ 
 
 #define SBEFIFO_CMD_CLASS_CONTROL        0xA100
 #define   SBEFIFO_CMD_EXECUTE_ISTEP        0x01
+#define   SBEFIFO_CMD_SUSPEND_IO           0x02
 
 #define SBEFIFO_CMD_CLASS_SCOM           0xA200
 #define   SBEFIFO_CMD_GET_SCOM             0x01