rpmsg_rpc.h
7.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
* Remote Processor Procedure Call Driver
*
* Copyright (C) 2012-2016 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name Texas Instruments nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _UAPI_LINUX_RPMSG_RPC_H_
#define _UAPI_LINUX_RPMSG_RPC_H_
#include <linux/ioctl.h>
/**
* struct rppc_buf_fds - rppc buffer registration/deregistration
* @num: number of file descriptors
* @fds: pointer to the array holding the file descriptors
*/
struct rppc_buf_fds {
uint32_t num;
int32_t *fds;
};
/*
* ioctl definitions
*/
#define RPPC_IOC_MAGIC 'r'
#define RPPC_IOC_CREATE _IOW(RPPC_IOC_MAGIC, 1, char *)
#define RPPC_IOC_BUFREGISTER _IOW(RPPC_IOC_MAGIC, 2, struct rppc_buf_fds)
#define RPPC_IOC_BUFUNREGISTER _IOW(RPPC_IOC_MAGIC, 3, struct rppc_buf_fds)
#define RPPC_IOC_MAXNR (4)
#define RPPC_MAX_PARAMETERS (10)
#define RPPC_MAX_TRANSLATIONS (1024)
#define RPPC_MAX_INST_NAMELEN (48)
/**
* enum rppc_param_type - RPC function parameter type
* @RPPC_PARAM_TYPE_UNKNOWN: unrecognized parameter
* @RPPC_PARAM_TYPE_ATOMIC: an atomic data type, 1 byte to architecture limit
* sized bytes
* @RPPC_PARAM_TYPE_PTR: a pointer to shared memory. The fd field in the
* structures rppc_param and rppc_param_translation must
* contain the file descriptor of the associated dma_buf
* @RPPC_PARAM_TYPE_STRUCT: (unsupported) a structure type. Will be architecture
* width aligned in memory
*
* These enum values are used to identify the parameter type for every
* parameter argument of the remote function.
*/
enum rppc_param_type {
RPPC_PARAM_TYPE_UNKNOWN = 0,
RPPC_PARAM_TYPE_ATOMIC,
RPPC_PARAM_TYPE_PTR,
RPPC_PARAM_TYPE_STRUCT,
};
/**
* struct rppc_param_translation - pointer translation helper structure
* @index: index of the parameter where the translation needs to be done in.
* used for computing the primary offset and mapping into kernel
* the page from the buffer referred to in the corresponding parameter
* @offset: offset from the primary base pointer to the pointer to translate.
* This is the secondary offset, and used either for mentioning the
* offset from an structure array element base, or within a single
* structure which itself is at an offset in an allocated buffer
* @base: the base user virtual address of the pointer to translate (used to
* calculate translated pointer offset)
* @fd: dma_buf file descriptor of the allocated buffer pointer within which
* the translated pointer is present
*/
struct rppc_param_translation {
uint32_t index;
ptrdiff_t offset;
size_t base;
int32_t fd;
};
/**
* struct rppc_param - descriptor structure for each parameter
* @type: type of the parameter, as dictated by enum rppc_param_type
* @size: size of the data (for atomic types) or size of the containing
* structure in which translations are performed
* @data: either the parameter value itself (for atomic type) or
* the actual user space pointer address to the data (for pointer type)
* @base: the base user space pointer address of the original allocated buffer,
* providing a reference if data has the pointer that is at an offset
* from the original pointer
* @fd: file descriptor of the exported allocation (will be used to
* import the associated dma_buf within the driver).
*/
struct rppc_param {
uint32_t type;
size_t size;
size_t data;
size_t base;
int32_t fd;
};
/**
* struct rppc_function - descriptor structure for the remote function
* @fxn_id: index of the function to invoke on the opened rppc device
* @num_params: number of parameters filled in the params field
* @params: array of parameter descriptor structures
* @num_translations: number of in-place translations to be performed within
* the arguments.
* @translations: an open array of the translation descriptor structures, whose
* length is given in @num_translations. Used for translating
* the pointers within the function data.
*
* This is the primary descriptor structure passed down from the userspace,
* describing the function, its parameter arguments and the needed translations.
*/
struct rppc_function {
uint32_t fxn_id;
uint32_t num_params;
struct rppc_param params[RPPC_MAX_PARAMETERS];
uint32_t num_translations;
struct rppc_param_translation translations[0];
};
/**
* struct rppc_function_return - function return status descriptor structure
* @fxn_id: index of the function invoked on the opened rppc device
* @status: return value of the executed function
*/
struct rppc_function_return {
uint32_t fxn_id;
uint32_t status;
};
/**
* struct rppc_create_instance - rppc channel connector helper
* @name: Name of the rppc server device to establish a connection with
*/
struct rppc_create_instance {
char name[RPPC_MAX_INST_NAMELEN];
};
/*
* helper macros for manipulating the function index in the marshalled packet
*/
#define RPPC_DESC_EXEC_SYNC (0x0100)
#define RPPC_DESC_TYPE_MASK (0x0F00)
/*
* helper macros for manipulating the function index in the marshalled packet.
* The remote functions are offset by one relative to the client
* XXX: Remove the relative offset
*/
#define RPPC_SET_FXN_IDX(idx) (((idx) + 1) | 0x80000000)
#define RPPC_FXN_MASK(idx) (((idx) - 1) & 0x7FFFFFFF)
/**
* struct rppc_packet - the actual marshalled packet
* @desc: type of function execution, currently only synchronous function
* invocations are supported
* @msg_id: an incremental message index identifier
* @flags: a combination of job id and pool id of the worker threads
* of the server
* @fxn_id: id of the function to execute
* @result: result of the remotely executed function
* @data_size: size of the payload packet
* @data: variable payload, containing the marshalled function data.
*
* This is actually a condensed structure of the Remote Command Messaging
* (RCM) structure. The initial fields of the structure are used by the
* remote-side server to schedule the execution of the function. The actual
* variable payload data starts from the .data field. This marshalled packet
* is the payload for a rpmsg message.
*
* XXX: remove or mask unneeded fields, some fields can be stripped down
*/
struct rppc_packet {
uint16_t desc;
uint16_t msg_id;
uint32_t flags;
uint32_t fxn_id;
int32_t result;
uint32_t data_size;
uint8_t data[0];
} __packed;
#endif /* _UAPI_LINUX_RPMSG_RPC_H_ */