blob: 383543d97f9c45fa05ffa39fe4148ab7249d361a [file] [log] [blame]
Mark Allyncd1bb432009-08-06 20:43:59 +01001/*
2 *
3 * sep_driver_api.h - Security Processor Driver api definitions
4 *
5 * Copyright(c) 2009 Intel Corporation. All rights reserved.
6 * Copyright(c) 2009 Discretix. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 59
20 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 * CONTACTS:
23 *
24 * Mark Allyn mark.a.allyn@intel.com
25 *
26 * CHANGES:
27 *
28 * 2009.06.26 Initial publish
29 *
30 */
31
32#ifndef __SEP_DRIVER_API_H__
33#define __SEP_DRIVER_API_H__
34
35
36
37/*----------------------------------------------------------------
38 IOCTL command defines
39 -----------------------------------------------------------------*/
40
41/* magic number 1 of the sep IOCTL command */
42#define SEP_IOC_MAGIC_NUMBER 's'
43
44/* sends interrupt to sep that message is ready */
45#define SEP_IOCSENDSEPCOMMAND _IO(SEP_IOC_MAGIC_NUMBER , 0)
46
47/* sends interrupt to sep that message is ready */
48#define SEP_IOCSENDSEPRPLYCOMMAND _IO(SEP_IOC_MAGIC_NUMBER , 1)
49
50/* allocate memory in data pool */
51#define SEP_IOCALLOCDATAPOLL _IO(SEP_IOC_MAGIC_NUMBER , 2)
52
53/* write to pre-allocated memory in data pool */
54#define SEP_IOCWRITEDATAPOLL _IO(SEP_IOC_MAGIC_NUMBER , 3)
55
56/* read from pre-allocated memory in data pool */
57#define SEP_IOCREADDATAPOLL _IO(SEP_IOC_MAGIC_NUMBER , 4)
58
59/* create sym dma lli tables */
60#define SEP_IOCCREATESYMDMATABLE _IO(SEP_IOC_MAGIC_NUMBER , 5)
61
62/* create flow dma lli tables */
63#define SEP_IOCCREATEFLOWDMATABLE _IO(SEP_IOC_MAGIC_NUMBER , 6)
64
65/* free dynamic data aalocated during table creation */
66#define SEP_IOCFREEDMATABLEDATA _IO(SEP_IOC_MAGIC_NUMBER , 7)
67
68/* get the static pool area addersses (physical and virtual) */
69#define SEP_IOCGETSTATICPOOLADDR _IO(SEP_IOC_MAGIC_NUMBER , 8)
70
71/* set flow id command */
72#define SEP_IOCSETFLOWID _IO(SEP_IOC_MAGIC_NUMBER , 9)
73
74/* add tables to the dynamic flow */
75#define SEP_IOCADDFLOWTABLE _IO(SEP_IOC_MAGIC_NUMBER , 10)
76
77/* add flow add tables message */
78#define SEP_IOCADDFLOWMESSAGE _IO(SEP_IOC_MAGIC_NUMBER , 11)
79
80/* start sep command */
81#define SEP_IOCSEPSTART _IO(SEP_IOC_MAGIC_NUMBER , 12)
82
83/* init sep command */
84#define SEP_IOCSEPINIT _IO(SEP_IOC_MAGIC_NUMBER , 13)
85
Mark Allyncd1bb432009-08-06 20:43:59 +010086/* end transaction command */
87#define SEP_IOCENDTRANSACTION _IO(SEP_IOC_MAGIC_NUMBER , 15)
88
89/* reallocate cache and resident */
90#define SEP_IOCREALLOCCACHERES _IO(SEP_IOC_MAGIC_NUMBER , 16)
91
92/* get the offset of the address starting from the beginnnig of the map area */
93#define SEP_IOCGETMAPPEDADDROFFSET _IO(SEP_IOC_MAGIC_NUMBER , 17)
94
95/* get time address and value */
96#define SEP_IOCGETIME _IO(SEP_IOC_MAGIC_NUMBER , 19)
97
98/*-------------------------------------------
99 TYPEDEFS
100----------------------------------------------*/
101
102/*
103 init command struct
104*/
105struct sep_driver_init_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100106 /* start of the 1G of the host memory address that SEP can access */
107 unsigned long message_addr;
Mark Allyncd1bb432009-08-06 20:43:59 +0100108
Alan Coxd19cf322009-08-06 20:45:57 +0100109 /* start address of resident */
110 unsigned long message_size_in_words;
Mark Allyncd1bb432009-08-06 20:43:59 +0100111
112};
113
114
115/*
116 realloc cache resident command
117*/
118struct sep_driver_realloc_cache_resident_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100119 /* new cache address */
Alan Cox6f13ea32009-08-14 15:41:50 +0100120 u64 new_cache_addr;
Alan Coxd19cf322009-08-06 20:45:57 +0100121 /* new resident address */
Alan Cox6f13ea32009-08-14 15:41:50 +0100122 u64 new_resident_addr;
Alan Coxd19cf322009-08-06 20:45:57 +0100123 /* new resident address */
Alan Cox6f13ea32009-08-14 15:41:50 +0100124 u64 new_shared_area_addr;
Alan Coxd19cf322009-08-06 20:45:57 +0100125 /* new base address */
Alan Cox6f13ea32009-08-14 15:41:50 +0100126 u64 new_base_addr;
Mark Allyncd1bb432009-08-06 20:43:59 +0100127};
128
Mark Allyncd1bb432009-08-06 20:43:59 +0100129struct sep_driver_alloc_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100130 /* virtual address of allocated space */
131 unsigned long offset;
Mark Allyncd1bb432009-08-06 20:43:59 +0100132
Alan Coxd19cf322009-08-06 20:45:57 +0100133 /* physical address of allocated space */
134 unsigned long phys_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100135
Alan Coxd19cf322009-08-06 20:45:57 +0100136 /* number of bytes to allocate */
137 unsigned long num_bytes;
Mark Allyncd1bb432009-08-06 20:43:59 +0100138};
139
140/*
141 */
142struct sep_driver_write_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100143 /* application space address */
144 unsigned long app_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100145
Alan Coxd19cf322009-08-06 20:45:57 +0100146 /* address of the data pool */
147 unsigned long datapool_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100148
Alan Coxd19cf322009-08-06 20:45:57 +0100149 /* number of bytes to write */
150 unsigned long num_bytes;
Mark Allyncd1bb432009-08-06 20:43:59 +0100151};
152
153/*
154 */
155struct sep_driver_read_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100156 /* application space address */
157 unsigned long app_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100158
Alan Coxd19cf322009-08-06 20:45:57 +0100159 /* address of the data pool */
160 unsigned long datapool_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100161
Alan Coxd19cf322009-08-06 20:45:57 +0100162 /* number of bytes to read */
163 unsigned long num_bytes;
Mark Allyncd1bb432009-08-06 20:43:59 +0100164};
165
166/*
167*/
168struct sep_driver_build_sync_table_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100169 /* address value of the data in */
170 unsigned long app_in_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100171
Alan Coxd19cf322009-08-06 20:45:57 +0100172 /* size of data in */
173 unsigned long data_in_size;
Mark Allyncd1bb432009-08-06 20:43:59 +0100174
Alan Coxd19cf322009-08-06 20:45:57 +0100175 /* address of the data out */
176 unsigned long app_out_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100177
Alan Coxd19cf322009-08-06 20:45:57 +0100178 /* the size of the block of the operation - if needed,
179 every table will be modulo this parameter */
180 unsigned long block_size;
Mark Allyncd1bb432009-08-06 20:43:59 +0100181
Alan Coxd19cf322009-08-06 20:45:57 +0100182 /* the physical address of the first input DMA table */
183 unsigned long in_table_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100184
Alan Coxd19cf322009-08-06 20:45:57 +0100185 /* number of entries in the first input DMA table */
186 unsigned long in_table_num_entries;
Mark Allyncd1bb432009-08-06 20:43:59 +0100187
Alan Coxd19cf322009-08-06 20:45:57 +0100188 /* the physical address of the first output DMA table */
189 unsigned long out_table_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100190
Alan Coxd19cf322009-08-06 20:45:57 +0100191 /* number of entries in the first output DMA table */
192 unsigned long out_table_num_entries;
Mark Allyncd1bb432009-08-06 20:43:59 +0100193
Alan Coxd19cf322009-08-06 20:45:57 +0100194 /* data in the first input table */
195 unsigned long table_data_size;
Mark Allyncd1bb432009-08-06 20:43:59 +0100196
Alan Coxd19cf322009-08-06 20:45:57 +0100197 /* distinct user/kernel layout */
198 bool isKernelVirtualAddress;
Mark Allyncd1bb432009-08-06 20:43:59 +0100199
200};
201
202/*
203*/
204struct sep_driver_build_flow_table_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100205 /* flow type */
206 unsigned long flow_type;
Mark Allyncd1bb432009-08-06 20:43:59 +0100207
Alan Coxd19cf322009-08-06 20:45:57 +0100208 /* flag for input output */
209 unsigned long input_output_flag;
Mark Allyncd1bb432009-08-06 20:43:59 +0100210
Alan Coxd19cf322009-08-06 20:45:57 +0100211 /* address value of the data in */
212 unsigned long virt_buff_data_addr;
Mark Allyncd1bb432009-08-06 20:43:59 +0100213
Alan Coxd19cf322009-08-06 20:45:57 +0100214 /* size of data in */
215 unsigned long num_virtual_buffers;
Mark Allyncd1bb432009-08-06 20:43:59 +0100216
Alan Coxd19cf322009-08-06 20:45:57 +0100217 /* the physical address of the first input DMA table */
218 unsigned long first_table_addr;
Mark Allyncd1bb432009-08-06 20:43:59 +0100219
Alan Coxd19cf322009-08-06 20:45:57 +0100220 /* number of entries in the first input DMA table */
221 unsigned long first_table_num_entries;
Mark Allyncd1bb432009-08-06 20:43:59 +0100222
Alan Coxd19cf322009-08-06 20:45:57 +0100223 /* data in the first input table */
224 unsigned long first_table_data_size;
Mark Allyncd1bb432009-08-06 20:43:59 +0100225
Alan Coxd19cf322009-08-06 20:45:57 +0100226 /* distinct user/kernel layout */
227 bool isKernelVirtualAddress;
Mark Allyncd1bb432009-08-06 20:43:59 +0100228};
229
230
231struct sep_driver_add_flow_table_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100232 /* flow id */
233 unsigned long flow_id;
Mark Allyncd1bb432009-08-06 20:43:59 +0100234
Alan Coxd19cf322009-08-06 20:45:57 +0100235 /* flag for input output */
236 unsigned long inputOutputFlag;
Mark Allyncd1bb432009-08-06 20:43:59 +0100237
Alan Coxd19cf322009-08-06 20:45:57 +0100238 /* address value of the data in */
239 unsigned long virt_buff_data_addr;
Mark Allyncd1bb432009-08-06 20:43:59 +0100240
Alan Coxd19cf322009-08-06 20:45:57 +0100241 /* size of data in */
242 unsigned long num_virtual_buffers;
Mark Allyncd1bb432009-08-06 20:43:59 +0100243
Alan Coxd19cf322009-08-06 20:45:57 +0100244 /* address of the first table */
245 unsigned long first_table_addr;
Mark Allyncd1bb432009-08-06 20:43:59 +0100246
Alan Coxd19cf322009-08-06 20:45:57 +0100247 /* number of entries in the first table */
248 unsigned long first_table_num_entries;
Mark Allyncd1bb432009-08-06 20:43:59 +0100249
Alan Coxd19cf322009-08-06 20:45:57 +0100250 /* data size of the first table */
251 unsigned long first_table_data_size;
Mark Allyncd1bb432009-08-06 20:43:59 +0100252
Alan Coxd19cf322009-08-06 20:45:57 +0100253 /* distinct user/kernel layout */
254 bool isKernelVirtualAddress;
Mark Allyncd1bb432009-08-06 20:43:59 +0100255
256};
257
258/*
259 command struct for set flow id
260*/
261struct sep_driver_set_flow_id_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100262 /* flow id to set */
263 unsigned long flow_id;
Mark Allyncd1bb432009-08-06 20:43:59 +0100264};
265
266
267/* command struct for add tables message */
268struct sep_driver_add_message_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100269 /* flow id to set */
270 unsigned long flow_id;
Mark Allyncd1bb432009-08-06 20:43:59 +0100271
Alan Coxd19cf322009-08-06 20:45:57 +0100272 /* message size in bytes */
273 unsigned long message_size_in_bytes;
Mark Allyncd1bb432009-08-06 20:43:59 +0100274
Alan Coxd19cf322009-08-06 20:45:57 +0100275 /* address of the message */
276 unsigned long message_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100277};
278
279/* command struct for static pool addresses */
280struct sep_driver_static_pool_addr_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100281 /* physical address of the static pool */
282 unsigned long physical_static_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100283
Alan Coxd19cf322009-08-06 20:45:57 +0100284 /* virtual address of the static pool */
285 unsigned long virtual_static_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100286};
287
288/* command struct for getiing offset of the physical address from
289 the start of the mapped area */
290struct sep_driver_get_mapped_offset_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100291 /* physical address of the static pool */
292 unsigned long physical_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100293
Alan Coxd19cf322009-08-06 20:45:57 +0100294 /* virtual address of the static pool */
295 unsigned long offset;
Mark Allyncd1bb432009-08-06 20:43:59 +0100296};
297
298/* command struct for getting time value and address */
299struct sep_driver_get_time_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100300 /* physical address of stored time */
301 unsigned long time_physical_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100302
Alan Coxd19cf322009-08-06 20:45:57 +0100303 /* value of the stored time */
304 unsigned long time_value;
Mark Allyncd1bb432009-08-06 20:43:59 +0100305};
306
307
308/*
309 structure that represent one entry in the DMA LLI table
310*/
311struct sep_lli_entry_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100312 /* physical address */
313 unsigned long physical_address;
Mark Allyncd1bb432009-08-06 20:43:59 +0100314
Alan Coxd19cf322009-08-06 20:45:57 +0100315 /* block size */
316 unsigned long block_size;
Mark Allyncd1bb432009-08-06 20:43:59 +0100317};
318
319/*
320 structure that reperesents data needed for lli table construction
321*/
322struct sep_lli_prepare_table_data_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100323 /* pointer to the memory where the first lli entry to be built */
324 struct sep_lli_entry_t *lli_entry_ptr;
Mark Allyncd1bb432009-08-06 20:43:59 +0100325
Alan Coxd19cf322009-08-06 20:45:57 +0100326 /* pointer to the array of lli entries from which the table is to be built */
327 struct sep_lli_entry_t *lli_array_ptr;
Mark Allyncd1bb432009-08-06 20:43:59 +0100328
Alan Coxd19cf322009-08-06 20:45:57 +0100329 /* number of elements in lli array */
330 int lli_array_size;
Mark Allyncd1bb432009-08-06 20:43:59 +0100331
Alan Coxd19cf322009-08-06 20:45:57 +0100332 /* number of entries in the created table */
333 int num_table_entries;
Mark Allyncd1bb432009-08-06 20:43:59 +0100334
Alan Coxd19cf322009-08-06 20:45:57 +0100335 /* number of array entries processed during table creation */
336 int num_array_entries_processed;
Mark Allyncd1bb432009-08-06 20:43:59 +0100337
Alan Coxd19cf322009-08-06 20:45:57 +0100338 /* the totatl data size in the created table */
339 int lli_table_total_data_size;
Mark Allyncd1bb432009-08-06 20:43:59 +0100340};
341
342/*
343 structure that represent tone table - it is not used in code, jkust
344 to show what table looks like
345*/
346struct sep_lli_table_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100347 /* number of pages mapped in this tables. If 0 - means that the table
348 is not defined (used as a valid flag) */
349 unsigned long num_pages;
350 /*
351 pointer to array of page pointers that represent the mapping of the
352 virtual buffer defined by the table to the physical memory. If this
353 pointer is NULL, it means that the table is not defined
354 (used as a valid flag)
355 */
356 struct page **table_page_array_ptr;
Mark Allyncd1bb432009-08-06 20:43:59 +0100357
Alan Coxd19cf322009-08-06 20:45:57 +0100358 /* maximum flow entries in table */
359 struct sep_lli_entry_t lli_entries[SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE];
Mark Allyncd1bb432009-08-06 20:43:59 +0100360};
361
362
363/*
364 structure for keeping the mapping of the virtual buffer into physical pages
365*/
366struct sep_flow_buffer_data {
Alan Coxd19cf322009-08-06 20:45:57 +0100367 /* pointer to the array of page structs pointers to the pages of the
368 virtual buffer */
369 struct page **page_array_ptr;
Mark Allyncd1bb432009-08-06 20:43:59 +0100370
Alan Coxd19cf322009-08-06 20:45:57 +0100371 /* number of pages taken by the virtual buffer */
372 unsigned long num_pages;
Mark Allyncd1bb432009-08-06 20:43:59 +0100373
Alan Coxd19cf322009-08-06 20:45:57 +0100374 /* this flag signals if this page_array is the last one among many that were
375 sent in one setting to SEP */
376 unsigned long last_page_array_flag;
Mark Allyncd1bb432009-08-06 20:43:59 +0100377};
378
379/*
380 struct that keeps all the data for one flow
381*/
382struct sep_flow_context_t {
Alan Coxd19cf322009-08-06 20:45:57 +0100383 /*
384 work struct for handling the flow done interrupt in the workqueue
385 this structure must be in the first place, since it will be used
386 forcasting to the containing flow context
387 */
388 struct work_struct flow_wq;
Mark Allyncd1bb432009-08-06 20:43:59 +0100389
Alan Coxd19cf322009-08-06 20:45:57 +0100390 /* flow id */
391 unsigned long flow_id;
Mark Allyncd1bb432009-08-06 20:43:59 +0100392
Alan Coxd19cf322009-08-06 20:45:57 +0100393 /* additional input tables exists */
394 unsigned long input_tables_flag;
Mark Allyncd1bb432009-08-06 20:43:59 +0100395
Alan Coxd19cf322009-08-06 20:45:57 +0100396 /* additional output tables exists */
397 unsigned long output_tables_flag;
Mark Allyncd1bb432009-08-06 20:43:59 +0100398
Alan Coxd19cf322009-08-06 20:45:57 +0100399 /* data of the first input file */
400 struct sep_lli_entry_t first_input_table;
Mark Allyncd1bb432009-08-06 20:43:59 +0100401
Alan Coxd19cf322009-08-06 20:45:57 +0100402 /* data of the first output table */
403 struct sep_lli_entry_t first_output_table;
Mark Allyncd1bb432009-08-06 20:43:59 +0100404
Alan Coxd19cf322009-08-06 20:45:57 +0100405 /* last input table data */
406 struct sep_lli_entry_t last_input_table;
Mark Allyncd1bb432009-08-06 20:43:59 +0100407
Alan Coxd19cf322009-08-06 20:45:57 +0100408 /* last output table data */
409 struct sep_lli_entry_t last_output_table;
Mark Allyncd1bb432009-08-06 20:43:59 +0100410
Alan Coxd19cf322009-08-06 20:45:57 +0100411 /* first list of table */
412 struct sep_lli_entry_t input_tables_in_process;
Mark Allyncd1bb432009-08-06 20:43:59 +0100413
Alan Coxd19cf322009-08-06 20:45:57 +0100414 /* output table in process (in sep) */
415 struct sep_lli_entry_t output_tables_in_process;
Mark Allyncd1bb432009-08-06 20:43:59 +0100416
Alan Coxd19cf322009-08-06 20:45:57 +0100417 /* size of messages in bytes */
418 unsigned long message_size_in_bytes;
Mark Allyncd1bb432009-08-06 20:43:59 +0100419
Alan Coxd19cf322009-08-06 20:45:57 +0100420 /* message */
421 unsigned char message[SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES];
Mark Allyncd1bb432009-08-06 20:43:59 +0100422};
423
424
Mark Allyncd1bb432009-08-06 20:43:59 +0100425#endif