WIP FPC-III support
[linux/fpc-iii.git] / arch / powerpc / include / uapi / asm / papr_pdsm.h
blob50ef95e2f5b185dde90bd27991a2a4b5beda6347
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3 * PAPR nvDimm Specific Methods (PDSM) and structs for libndctl
5 * (C) Copyright IBM 2020
7 * Author: Vaibhav Jain <vaibhav at linux.ibm.com>
8 */
10 #ifndef _UAPI_ASM_POWERPC_PAPR_PDSM_H_
11 #define _UAPI_ASM_POWERPC_PAPR_PDSM_H_
13 #include <linux/types.h>
14 #include <linux/ndctl.h>
17 * PDSM Envelope:
19 * The ioctl ND_CMD_CALL exchange data between user-space and kernel via
20 * envelope which consists of 2 headers sections and payload sections as
21 * illustrated below:
22 * +-----------------+---------------+---------------------------+
23 * | 64-Bytes | 8-Bytes | Max 184-Bytes |
24 * +-----------------+---------------+---------------------------+
25 * | ND-HEADER | PDSM-HEADER | PDSM-PAYLOAD |
26 * +-----------------+---------------+---------------------------+
27 * | nd_family | | |
28 * | nd_size_out | cmd_status | |
29 * | nd_size_in | reserved | nd_pdsm_payload |
30 * | nd_command | payload --> | |
31 * | nd_fw_size | | |
32 * | nd_payload ---> | | |
33 * +---------------+-----------------+---------------------------+
35 * ND Header:
36 * This is the generic libnvdimm header described as 'struct nd_cmd_pkg'
37 * which is interpreted by libnvdimm before passed on to papr_scm. Important
38 * member fields used are:
39 * 'nd_family' : (In) NVDIMM_FAMILY_PAPR_SCM
40 * 'nd_size_in' : (In) PDSM-HEADER + PDSM-IN-PAYLOAD (usually 0)
41 * 'nd_size_out' : (In) PDSM-HEADER + PDSM-RETURN-PAYLOAD
42 * 'nd_command' : (In) One of PAPR_PDSM_XXX
43 * 'nd_fw_size' : (Out) PDSM-HEADER + size of actual payload returned
45 * PDSM Header:
46 * This is papr-scm specific header that precedes the payload. This is defined
47 * as nd_cmd_pdsm_pkg. Following fields aare available in this header:
49 * 'cmd_status' : (Out) Errors if any encountered while servicing PDSM.
50 * 'reserved' : Not used, reserved for future and should be set to 0.
51 * 'payload' : A union of all the possible payload structs
53 * PDSM Payload:
55 * The layout of the PDSM Payload is defined by various structs shared between
56 * papr_scm and libndctl so that contents of payload can be interpreted. As such
57 * its defined as a union of all possible payload structs as
58 * 'union nd_pdsm_payload'. Based on the value of 'nd_cmd_pkg.nd_command'
59 * appropriate member of the union is accessed.
62 /* Max payload size that we can handle */
63 #define ND_PDSM_PAYLOAD_MAX_SIZE 184
65 /* Max payload size that we can handle */
66 #define ND_PDSM_HDR_SIZE \
67 (sizeof(struct nd_pkg_pdsm) - ND_PDSM_PAYLOAD_MAX_SIZE)
69 /* Various nvdimm health indicators */
70 #define PAPR_PDSM_DIMM_HEALTHY 0
71 #define PAPR_PDSM_DIMM_UNHEALTHY 1
72 #define PAPR_PDSM_DIMM_CRITICAL 2
73 #define PAPR_PDSM_DIMM_FATAL 3
75 /* struct nd_papr_pdsm_health.extension_flags field flags */
77 /* Indicate that the 'dimm_fuel_gauge' field is valid */
78 #define PDSM_DIMM_HEALTH_RUN_GAUGE_VALID 1
81 * Struct exchanged between kernel & ndctl in for PAPR_PDSM_HEALTH
82 * Various flags indicate the health status of the dimm.
84 * extension_flags : Any extension fields present in the struct.
85 * dimm_unarmed : Dimm not armed. So contents wont persist.
86 * dimm_bad_shutdown : Previous shutdown did not persist contents.
87 * dimm_bad_restore : Contents from previous shutdown werent restored.
88 * dimm_scrubbed : Contents of the dimm have been scrubbed.
89 * dimm_locked : Contents of the dimm cant be modified until CEC reboot
90 * dimm_encrypted : Contents of dimm are encrypted.
91 * dimm_health : Dimm health indicator. One of PAPR_PDSM_DIMM_XXXX
92 * dimm_fuel_gauge : Life remaining of DIMM as a percentage from 0-100
94 struct nd_papr_pdsm_health {
95 union {
96 struct {
97 __u32 extension_flags;
98 __u8 dimm_unarmed;
99 __u8 dimm_bad_shutdown;
100 __u8 dimm_bad_restore;
101 __u8 dimm_scrubbed;
102 __u8 dimm_locked;
103 __u8 dimm_encrypted;
104 __u16 dimm_health;
106 /* Extension flag PDSM_DIMM_HEALTH_RUN_GAUGE_VALID */
107 __u16 dimm_fuel_gauge;
109 __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
114 * Methods to be embedded in ND_CMD_CALL request. These are sent to the kernel
115 * via 'nd_cmd_pkg.nd_command' member of the ioctl struct
117 enum papr_pdsm {
118 PAPR_PDSM_MIN = 0x0,
119 PAPR_PDSM_HEALTH,
120 PAPR_PDSM_MAX,
123 /* Maximal union that can hold all possible payload types */
124 union nd_pdsm_payload {
125 struct nd_papr_pdsm_health health;
126 __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
127 } __packed;
130 * PDSM-header + payload expected with ND_CMD_CALL ioctl from libnvdimm
131 * Valid member of union 'payload' is identified via 'nd_cmd_pkg.nd_command'
132 * that should always precede this struct when sent to papr_scm via CMD_CALL
133 * interface.
135 struct nd_pkg_pdsm {
136 __s32 cmd_status; /* Out: Sub-cmd status returned back */
137 __u16 reserved[2]; /* Ignored and to be set as '0' */
138 union nd_pdsm_payload payload;
139 } __packed;
141 #endif /* _UAPI_ASM_POWERPC_PAPR_PDSM_H_ */