summaryrefslogtreecommitdiffstats
path: root/drivers/staging/sep/sep_driver_api.h
blob: 7ef16da7c4ef8c7e79d8652de6f5a140412b7f60 (plain)
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
/*
 *
 *  sep_driver_api.h - Security Processor Driver api definitions
 *
 *  Copyright(c) 2009 Intel Corporation. All rights reserved.
 *  Copyright(c) 2009 Discretix. All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the Free
 *  Software Foundation; either version 2 of the License, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful, but WITHOUT
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 *  more details.
 *
 *  You should have received a copy of the GNU General Public License along with
 *  this program; if not, write to the Free Software Foundation, Inc., 59
 *  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 *  CONTACTS:
 *
 *  Mark Allyn		mark.a.allyn@intel.com
 *
 *  CHANGES:
 *
 *  2009.06.26	Initial publish
 *
 */

#ifndef __SEP_DRIVER_API_H__
#define __SEP_DRIVER_API_H__



/*----------------------------------------------------------------
  IOCTL command defines
  -----------------------------------------------------------------*/

/* magic number 1 of the sep IOCTL command */
#define SEP_IOC_MAGIC_NUMBER                           's'

/* sends interrupt to sep that message is ready */
#define SEP_IOCSENDSEPCOMMAND                 _IO(SEP_IOC_MAGIC_NUMBER , 0)

/* sends interrupt to sep that message is ready */
#define SEP_IOCSENDSEPRPLYCOMMAND             _IO(SEP_IOC_MAGIC_NUMBER , 1)

/* allocate memory in data pool */
#define SEP_IOCALLOCDATAPOLL                  _IO(SEP_IOC_MAGIC_NUMBER , 2)

/* write to pre-allocated  memory in data pool */
#define SEP_IOCWRITEDATAPOLL                  _IO(SEP_IOC_MAGIC_NUMBER , 3)

/* read from  pre-allocated  memory in data pool */
#define SEP_IOCREADDATAPOLL                   _IO(SEP_IOC_MAGIC_NUMBER , 4)

/* create sym dma lli tables */
#define SEP_IOCCREATESYMDMATABLE              _IO(SEP_IOC_MAGIC_NUMBER , 5)

/* create flow dma lli tables */
#define SEP_IOCCREATEFLOWDMATABLE             _IO(SEP_IOC_MAGIC_NUMBER , 6)

/* free dynamic data aalocated during table creation */
#define SEP_IOCFREEDMATABLEDATA                _IO(SEP_IOC_MAGIC_NUMBER , 7)

/* get the static pool area addresses (physical and virtual) */
#define SEP_IOCGETSTATICPOOLADDR               _IO(SEP_IOC_MAGIC_NUMBER , 8)

/* set flow id command */
#define SEP_IOCSETFLOWID                       _IO(SEP_IOC_MAGIC_NUMBER , 9)

/* add tables to the dynamic flow */
#define SEP_IOCADDFLOWTABLE                    _IO(SEP_IOC_MAGIC_NUMBER , 10)

/* add flow add tables message */
#define SEP_IOCADDFLOWMESSAGE                  _IO(SEP_IOC_MAGIC_NUMBER , 11)

/* start sep command */
#define SEP_IOCSEPSTART                        _IO(SEP_IOC_MAGIC_NUMBER , 12)

/* init sep command */
#define SEP_IOCSEPINIT                         _IO(SEP_IOC_MAGIC_NUMBER , 13)

/* end transaction command */
#define SEP_IOCENDTRANSACTION                  _IO(SEP_IOC_MAGIC_NUMBER , 15)

/* reallocate cache and resident */
#define SEP_IOCREALLOCCACHERES                 _IO(SEP_IOC_MAGIC_NUMBER , 16)

/* get the offset of the address starting from the beginnnig of the map area */
#define SEP_IOCGETMAPPEDADDROFFSET             _IO(SEP_IOC_MAGIC_NUMBER , 17)

/* get time address and value */
#define SEP_IOCGETIME                          _IO(SEP_IOC_MAGIC_NUMBER , 19)

/*-------------------------------------------
    TYPEDEFS
----------------------------------------------*/

/*
  init command struct
*/
struct sep_driver_init_t {
	/* start of the 1G of the host memory address that SEP can access */
	unsigned long message_addr;

	/* start address of resident */
	unsigned long message_size_in_words;

};


/*
  realloc cache resident command
*/
struct sep_driver_realloc_cache_resident_t {
	/* new cache address */
	u64 new_cache_addr;
	/* new resident address */
	u64 new_resident_addr;
	/* new resident address */
	u64  new_shared_area_addr;
	/* new base address */
	u64 new_base_addr;
};

struct sep_driver_alloc_t {
	/* virtual address of allocated space */
	unsigned long offset;

	/* physical address of allocated space */
	unsigned long phys_address;

	/* number of bytes to allocate */
	unsigned long num_bytes;
};

/*
 */
struct sep_driver_write_t {
	/* application space address */
	unsigned long app_address;

	/* address of the data pool */
	unsigned long datapool_address;

	/* number of bytes to write */
	unsigned long num_bytes;
};

/*
 */
struct sep_driver_read_t {
	/* application space address */
	unsigned long app_address;

	/* address of the data pool */
	unsigned long datapool_address;

	/* number of bytes to read */
	unsigned long num_bytes;
};

/*
*/
struct sep_driver_build_sync_table_t {
	/* address value of the data in */
	unsigned long app_in_address;

	/* size of data in */
	unsigned long data_in_size;

	/* address of the data out */
	unsigned long app_out_address;

	/* the size of the block of the operation - if needed,
	   every table will be modulo this parameter */
	unsigned long block_size;

	/* the physical address of the first input DMA table */
	unsigned long in_table_address;

	/* number of entries in the first input DMA table */
	unsigned long in_table_num_entries;

	/* the physical address of the first output DMA table */
	unsigned long out_table_address;

	/* number of entries in the first output DMA table */
	unsigned long out_table_num_entries;

	/* data in the first input table */
	unsigned long table_data_size;

	/* distinct user/kernel layout */
	bool isKernelVirtualAddress;

};

/*
*/
struct sep_driver_build_flow_table_t {
	/* flow type */
	unsigned long flow_type;

	/* flag for input output */
	unsigned long input_output_flag;

	/* address value of the data in */
	unsigned long virt_buff_data_addr;

	/* size of data in */
	unsigned long num_virtual_buffers;

	/* the physical address of the first input DMA table */
	unsigned long first_table_addr;

	/* number of entries in the first input DMA table */
	unsigned long first_table_num_entries;

	/* data in the first input table */
	unsigned long first_table_data_size;

	/* distinct user/kernel layout */
	bool isKernelVirtualAddress;
};


struct sep_driver_add_flow_table_t {
	/* flow id  */
	unsigned long flow_id;

	/* flag for input output */
	unsigned long inputOutputFlag;

	/* address value of the data in */
	unsigned long virt_buff_data_addr;

	/* size of data in */
	unsigned long num_virtual_buffers;

	/* address of the first table */
	unsigned long first_table_addr;

	/* number of entries in the first table */
	unsigned long first_table_num_entries;

	/* data size of the first table */
	unsigned long first_table_data_size;

	/* distinct user/kernel layout */
	bool isKernelVirtualAddress;

};

/*
  command struct for set flow id
*/
struct sep_driver_set_flow_id_t {
	/* flow id to set */
	unsigned long flow_id;
};


/* command struct for add tables message */
struct sep_driver_add_message_t {
	/* flow id to set */
	unsigned long flow_id;

	/* message size in bytes */
	unsigned long message_size_in_bytes;

	/* address of the message */
	unsigned long message_address;
};

/* command struct for static pool addresses  */
struct sep_driver_static_pool_addr_t {
	/* physical address of the static pool */
	unsigned long physical_static_address;

	/* virtual address of the static pool */
	unsigned long virtual_static_address;
};

/* command struct for getiing offset of the physical address from
	the start of the mapped area  */
struct sep_driver_get_mapped_offset_t {
	/* physical address of the static pool */
	unsigned long physical_address;

	/* virtual address of the static pool */
	unsigned long offset;
};

/* command struct for getting time value and address */
struct sep_driver_get_time_t {
	/* physical address of stored time */
	unsigned long time_physical_address;

	/* value of the stored time */
	unsigned long time_value;
};


/*
  structure that represent one entry in the DMA LLI table
*/
struct sep_lli_entry_t {
	/* physical address */
	unsigned long physical_address;

	/* block size */
	unsigned long block_size;
};

/*
  structure that reperesents data needed for lli table construction
*/
struct sep_lli_prepare_table_data_t {
	/* pointer to the memory where the first lli entry to be built */
	struct sep_lli_entry_t *lli_entry_ptr;

	/* pointer to the array of lli entries from which the table is to be built */
	struct sep_lli_entry_t *lli_array_ptr;

	/* number of elements in lli array */
	int lli_array_size;

	/* number of entries in the created table */
	int num_table_entries;

	/* number of array entries processed during table creation */
	int num_array_entries_processed;

	/* the totatl data size in the created table */
	int lli_table_total_data_size;
};

/*
  structure that represent tone table - it is not used in code, jkust
  to show what table looks like
*/
struct sep_lli_table_t {
	/* number of pages mapped in this tables. If 0 - means that the table
	   is not defined (used as a valid flag) */
	unsigned long num_pages;
	/*
	   pointer to array of page pointers that represent the mapping of the
	   virtual buffer defined by the table to the physical memory. If this
	   pointer is NULL, it means that the table is not defined
	   (used as a valid flag)
	 */
	struct page **table_page_array_ptr;

	/* maximum flow entries in table */
	struct sep_lli_entry_t lli_entries[SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE];
};


/*
  structure for keeping the mapping of the virtual buffer into physical pages
*/
struct sep_flow_buffer_data {
	/* pointer to the array of page structs pointers to the pages of the
	   virtual buffer */
	struct page **page_array_ptr;

	/* number of pages taken by the virtual buffer */
	unsigned long num_pages;

	/* this flag signals if this page_array is the last one among many that were
	   sent in one setting to SEP */
	unsigned long last_page_array_flag;
};

/*
  struct that keeps all the data for one flow
*/
struct sep_flow_context_t {
	/*
	   work struct for handling the flow done interrupt in the workqueue
	   this structure must be in the first place, since it will be used
	   forcasting to the containing flow context
	 */
	struct work_struct flow_wq;

	/* flow id */
	unsigned long flow_id;

	/* additional input tables exists */
	unsigned long input_tables_flag;

	/* additional output tables exists */
	unsigned long output_tables_flag;

	/*  data of the first input file */
	struct sep_lli_entry_t first_input_table;

	/* data of the first output table */
	struct sep_lli_entry_t first_output_table;

	/* last input table data */
	struct sep_lli_entry_t last_input_table;

	/* last output table data */
	struct sep_lli_entry_t last_output_table;

	/* first list of table */
	struct sep_lli_entry_t input_tables_in_process;

	/* output table in process (in sep) */
	struct sep_lli_entry_t output_tables_in_process;

	/* size of messages in bytes */
	unsigned long message_size_in_bytes;

	/* message */
	unsigned char message[SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES];
};


#endif
OpenPOWER on IntegriCloud