linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Ian Munsie <imunsie@au1.ibm.com>
To: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Cc: Michael Neuling <michael.neuling@au1.ibm.com>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH v3 10/18] cxl: New hcalls to support CAPI adapters
Date: Wed, 10 Feb 2016 19:31:10 +1100	[thread overview]
Message-ID: <1455089064-sup-7113@delenn.ozlabs.ibm.com> (raw)
In-Reply-To: <1454765345-7417-11-git-send-email-fbarrat@linux.vnet.ibm.com>

> +#define H_CONTROL_CA_FUNCTION_RESET                   1 /* perform a reset */
> +#define H_CONTROL_CA_FUNCTION_SUSPEND_PROCESS         2 /* suspend a process from being executed */
> +#define H_CONTROL_CA_FUNCTION_RESUME_PROCESS          3 /* resume a process to be executed */
> +#define H_CONTROL_CA_FUNCTION_READ_ERR_STATE          4 /* read the error state */
> +#define H_CONTROL_CA_FUNCTION_GET_AFU_ERR             5 /* collect the AFU error buffer */
> +#define H_CONTROL_CA_FUNCTION_GET_CONFIG              6 /* collect configuration record */
> +#define H_CONTROL_CA_FUNCTION_GET_DOWNLOAD_STATE      7 /* query to return download status */
> +#define H_CONTROL_CA_FUNCTION_TERMINATE_PROCESS       8 /* terminate the process before completion */
> +#define H_CONTROL_CA_FUNCTION_COLLECT_VPD             9 /* collect VPD */
> +#define H_CONTROL_CA_FUNCTION_GET_FUNCTION_ERR_INT   11 /* read the function-wide error data based on an interrupt */
> +#define H_CONTROL_CA_FUNCTION_ACK_FUNCTION_ERR_INT   12 /* acknowledge function-wide error data based on an interrupt */
> +#define H_CONTROL_CA_FUNCTION_GET_ERROR_LOG          13 /* retrieve the Platform Log ID (PLID) of an error log */
> +
> +#define H_CONTROL_CA_FAULTS_RESPOND_PSL    1
> +#define H_CONTROL_CA_FAULTS_RESPOND_AFU    2
> +
> +#define OP_STR_AFU(x)                            \
> +    (x == H_CONTROL_CA_FUNCTION_RESET ? "RESET" :            \
> +        x == H_CONTROL_CA_FUNCTION_RESUME_PROCESS ? "PROCESS" :    \
> +        x == H_CONTROL_CA_FUNCTION_RESUME_PROCESS ? "RESUME" :    \

H_CONTROL_CA_FUNCTION_RESUME_PROCESS is listed twice here, and the names
don't match.

> +        x == H_CONTROL_CA_FUNCTION_READ_ERR_STATE ? "READ_ERR_STATE" : \
> +        x == H_CONTROL_CA_FUNCTION_GET_AFU_ERR ? "GET_AFU_ERR" : \
> +        x == H_CONTROL_CA_FUNCTION_GET_CONFIG ? "GET_CONFIG" :    \
> +        x == H_CONTROL_CA_FUNCTION_GET_DOWNLOAD_STATE ? "DOWNLOAD_STATE" : \
> +        x == H_CONTROL_CA_FUNCTION_TERMINATE_PROCESS ? "TERMINATE_PROC" : \
> +        x == H_CONTROL_CA_FUNCTION_COLLECT_VPD ? "COLLECT_VPD" :    \
> +        x == H_CONTROL_CA_FUNCTION_GET_FUNCTION_ERR_INT ? "GET_ERR_INTERRUPT" :    \
> +        x == H_CONTROL_CA_FUNCTION_ACK_FUNCTION_ERR_INT ? "ACK_ERR_INTERRUPT" :    \
> +        x == H_CONTROL_CA_FUNCTION_GET_ERROR_LOG ? "GET_ERROR_LOG" : \
> +        "UNKNOWN OP")
> +
> +#define H_CONTROL_CA_FACILITY_RESET                   1 /* perform a reset */
> +#define H_CONTROL_CA_FACILITY_COLLECT_VPD             2 /* collect VPD */
> +
> +#define OP_STR_CONTROL_ADAPTER(x)                    \
> +    (x == H_CONTROL_CA_FACILITY_RESET ? "RESET" :            \
> +        x == H_CONTROL_CA_FACILITY_COLLECT_VPD ? "COLLECT_VPD" : \
> +        "UNKNOWN OP")
> +
> +#define H_CONTROL_CA_FACILITY_DOWNLOAD                1 /* download adapter image */
> +#define H_CONTROL_CA_FACILITY_VALIDATE                2 /* validate adapter image */
> +
> +#define OP_STR_DOWNLOAD_ADAPTER(x)                    \
> +    (x == H_CONTROL_CA_FACILITY_DOWNLOAD ? "DOWNLOAD" :        \
> +        x == H_CONTROL_CA_FACILITY_VALIDATE ? "VALIDATE" :    \
> +        "UNKNOWN OP")
> +

Since these are almost sequential how about using static arrays and a
lookup helper, like:

static char *afu_op_names[] = {
	"UNKNOWN_OP",           /* 0 undefined */
	"RESET",                /* 1 */
	"SUSPEND_PROCESS",      /* 2 */
	"RESUME_PROCESS",       /* 3 */
	"READ_ERR_STATE",       /* 4 */
	"GET_AFU_ERR",          /* 5 */
	"GET_CONFIG",           /* 6 */
	"GET_DOWNLOAD_STATE",   /* 7 */
	"TERMINATE_PROCESS",    /* 8 */
	"COLLECT_VPD",          /* 9 */
	"UNKNOWN_OP",           /* 10 undefined */
	"GET_FUNCTION_ERR_INT", /* 11 */
	"ACK_FUNCTION_ERR_INT", /* 12 */
	"GET_ERROR_LOG",        /* 13 */
};

static char *control_adapter_op_names[] = {
	"UNKNOWN_OP",           /* 0 undefined */
	"RESET",                /* 1 */
	"COLLECT_VPD",          /* 2 */
};

static char *download_op_names[] = {
	"UNKNOWN_OP",           /* 0 undefined */
	"DOWNLOAD",             /* 1 */
	"VALIDATE",             /* 2 */
};

static char* op_str(unsigned int op, char *name_array[], int array_len)
{
	if (op >= array_len)
		return "UNKNOWN_OP";
	return name_array[op];
}

#define OP_STR(op, name_array)      op_str(op, name_array, ARRAY_SIZE(name_array))

#define OP_STR_AFU(op)              OP_STR(op, afu_op_names)
#define OP_STR_CONTROL_ADAPTER(op)  OP_STR(op, control_adapter_op_names)
#define OP_STR_DOWNLOAD_ADAPTER(op) OP_STR(op, download_op_names)

> +    buf = (u32 *) element;
> +    for (i = 0; i*4 < sizeof(struct cxl_process_element_hcall); i += 4) {
> +        if ((i+3)*4 < sizeof(struct cxl_process_element_hcall))
> +            pr_devel("%.8x %.8x %.8x %.8x\n", buf[i], buf[i + 1], buf[i + 2], buf[i + 3]);
> +        else if ((i+2)*4 < sizeof(struct cxl_process_element_hcall))
> +            pr_devel("%.8x %.8x %.8x\n", buf[i], buf[i + 1], buf[i + 2]);
> +        else if ((i+1)*4 < sizeof(struct cxl_process_element_hcall))
> +            pr_devel("%.8x %.8x\n", buf[i], buf[i + 1]);
> +        else
> +            pr_devel("%.8x\n", buf[i]);

For something that is only used with pr_devel for debugging I'd like
something that is a little easier on the eyes, like:

or (i = 0; i < sizeof(struct cxl_process_element_hcall); i++) {
	if (i && i % 4 == 0)
		pr_devel("\n");
	pr_devel("%08x ", buf[i]);
}
pr_devel("\n");



> +/*
> + * This is straight out of PAPR, but replacing some of the compound fields with
> + * a single field, where they were identical to the register layout.
> + *
> + * The 'flags' parameter regroups the various bit-fields
> + */

Thanks for getting rid of the bit fields :)

Cheers,
-Ian

  reply	other threads:[~2016-02-10  8:32 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-06 13:28 [PATCH v3 00/18] cxl: Add support for powerVM guest​ Frederic Barrat
2016-02-06 13:28 ` [PATCH v3 01/18] cxl: Move common code away from bare-metal-specific files Frederic Barrat
2016-02-10  6:26   ` Ian Munsie
2016-02-06 13:28 ` [PATCH v3 02/18] cxl: Move bare-metal specific code to specialized files Frederic Barrat
2016-02-10  6:28   ` Ian Munsie
2016-02-06 13:28 ` [PATCH v3 03/18] cxl: Define process problem state area at attach time only Frederic Barrat
2016-02-10  6:32   ` Ian Munsie
2016-02-11 14:40     ` Frederic Barrat
2016-02-06 13:28 ` [PATCH v3 04/18] cxl: Introduce implementation-specific API Frederic Barrat
2016-02-10  7:07   ` Ian Munsie
2016-02-06 13:28 ` [PATCH v3 05/18] cxl: Rename some bare-metal specific functions Frederic Barrat
2016-02-10  7:10   ` Ian Munsie
2016-02-06 13:28 ` [PATCH v3 06/18] cxl: Isolate a few bare-metal-specific calls Frederic Barrat
2016-02-10  7:12   ` Ian Munsie
2016-02-06 13:28 ` [PATCH v3 07/18] cxl: Update cxl_irq() prototype Frederic Barrat
2016-02-10  7:13   ` Ian Munsie
2016-02-06 13:28 ` [PATCH v3 08/18] cxl: IRQ allocation for guests Frederic Barrat
2016-02-10  7:23   ` Ian Munsie
2016-02-06 13:28 ` [PATCH v3 09/18] cxl: New possible return value from hcall Frederic Barrat
2016-02-10  7:24   ` Ian Munsie
2016-02-06 13:28 ` [PATCH v3 10/18] cxl: New hcalls to support CAPI adapters Frederic Barrat
2016-02-10  8:31   ` Ian Munsie [this message]
2016-02-06 13:28 ` [PATCH v3 11/18] cxl: Separate bare-metal fields in adapter and AFU data structures Frederic Barrat
2016-02-10  9:04   ` Ian Munsie
2016-02-06 13:28 ` [PATCH v3 12/18] cxl: Add guest-specific code Frederic Barrat
2016-02-10  9:35   ` Ian Munsie
2016-02-06 13:29 ` [PATCH v3 13/18] cxl: sysfs support for guests Frederic Barrat
2016-02-08  3:02   ` Stewart Smith
2016-02-09 15:21     ` Frederic Barrat
2016-02-10  6:22       ` Ian Munsie
2016-02-10  9:38   ` Ian Munsie
2016-02-06 13:29 ` [PATCH v3 14/18] cxl: Support to flash a new image on the adapter from a guest Frederic Barrat
2016-02-10 11:20   ` Ian Munsie
2016-02-15 20:53     ` christophe lombard
2016-02-15 23:19       ` Ian Munsie
2016-02-16 10:47         ` christophe lombard
2016-02-06 13:29 ` [PATCH v3 15/18] cxl: Parse device tree and create CAPI device(s) at boot Frederic Barrat
2016-02-10 11:21   ` Ian Munsie
2016-02-06 13:29 ` [PATCH v3 16/18] cxl: Support the cxl kernel API from a guest Frederic Barrat
2016-02-10 11:26   ` Ian Munsie
2016-02-06 13:29 ` [PATCH v3 17/18] cxl: Adapter failure handling Frederic Barrat
2016-02-10 11:28   ` Ian Munsie
2016-02-06 13:29 ` [PATCH v3 18/18] cxl: Add tracepoints around the CAPI hcall Frederic Barrat
2016-02-10 11:29   ` Ian Munsie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455089064-sup-7113@delenn.ozlabs.ibm.com \
    --to=imunsie@au1.ibm.com \
    --cc=fbarrat@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=michael.neuling@au1.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).