Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * PAPR nvDimm Specific Methods (PDSM) and structs for libndctl
4 *
5 * (C) Copyright IBM 2020
6 *
7 * Author: Vaibhav Jain <vaibhav at linux.ibm.com>
8 */
9
10#ifndef _UAPI_ASM_POWERPC_PAPR_PDSM_H_
11#define _UAPI_ASM_POWERPC_PAPR_PDSM_H_
12
13#include <linux/types.h>
14#include <linux/ndctl.h>
15
16/*
17 * PDSM Envelope:
18 *
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 * +---------------+-----------------+---------------------------+
34 *
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
44 *
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:
48 *
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
52 *
53 * PDSM Payload:
54 *
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.
60 */
61
62/* Max payload size that we can handle */
63#define ND_PDSM_PAYLOAD_MAX_SIZE 184
64
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)
68
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
74
75/*
76 * Struct exchanged between kernel & ndctl in for PAPR_PDSM_HEALTH
77 * Various flags indicate the health status of the dimm.
78 *
79 * extension_flags : Any extension fields present in the struct.
80 * dimm_unarmed : Dimm not armed. So contents wont persist.
81 * dimm_bad_shutdown : Previous shutdown did not persist contents.
82 * dimm_bad_restore : Contents from previous shutdown werent restored.
83 * dimm_scrubbed : Contents of the dimm have been scrubbed.
84 * dimm_locked : Contents of the dimm cant be modified until CEC reboot
85 * dimm_encrypted : Contents of dimm are encrypted.
86 * dimm_health : Dimm health indicator. One of PAPR_PDSM_DIMM_XXXX
87 */
88struct nd_papr_pdsm_health {
89 union {
90 struct {
91 __u32 extension_flags;
92 __u8 dimm_unarmed;
93 __u8 dimm_bad_shutdown;
94 __u8 dimm_bad_restore;
95 __u8 dimm_scrubbed;
96 __u8 dimm_locked;
97 __u8 dimm_encrypted;
98 __u16 dimm_health;
99 };
100 __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
101 };
102};
103
104/*
105 * Methods to be embedded in ND_CMD_CALL request. These are sent to the kernel
106 * via 'nd_cmd_pkg.nd_command' member of the ioctl struct
107 */
108enum papr_pdsm {
109 PAPR_PDSM_MIN = 0x0,
110 PAPR_PDSM_HEALTH,
111 PAPR_PDSM_MAX,
112};
113
114/* Maximal union that can hold all possible payload types */
115union nd_pdsm_payload {
116 struct nd_papr_pdsm_health health;
117 __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
118} __packed;
119
120/*
121 * PDSM-header + payload expected with ND_CMD_CALL ioctl from libnvdimm
122 * Valid member of union 'payload' is identified via 'nd_cmd_pkg.nd_command'
123 * that should always precede this struct when sent to papr_scm via CMD_CALL
124 * interface.
125 */
126struct nd_pkg_pdsm {
127 __s32 cmd_status; /* Out: Sub-cmd status returned back */
128 __u16 reserved[2]; /* Ignored and to be set as '0' */
129 union nd_pdsm_payload payload;
130} __packed;
131
132#endif /* _UAPI_ASM_POWERPC_PAPR_PDSM_H_ */