1823939204523d42f5bd6200e453ee51ee0e8441
[dpdk.git] / drivers / common / cpt / cpt_common.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Cavium, Inc
3  */
4
5 #ifndef _CPT_COMMON_H_
6 #define _CPT_COMMON_H_
7
8 /*
9  * This file defines common macros and structs
10  */
11
12 /*
13  * Macros to determine CPT model. Driver makefile will define CPT_MODEL
14  * accordingly
15  */
16 #define CRYPTO_OCTEONTX         0x1
17
18 /* Default command timeout in seconds */
19 #define DEFAULT_COMMAND_TIMEOUT 4
20
21 #define CPT_COUNT_THOLD         32
22 #define CPT_TIMER_THOLD         0x3F
23
24 #define AE_TYPE 1
25 #define SE_TYPE 2
26
27 #ifndef ROUNDUP4
28 #define ROUNDUP4(val)   (((val) + 3) & 0xfffffffc)
29 #endif
30
31 #ifndef ROUNDUP8
32 #define ROUNDUP8(val)   (((val) + 7) & 0xfffffff8)
33 #endif
34
35 #ifndef ROUNDUP16
36 #define ROUNDUP16(val)  (((val) + 15) & 0xfffffff0)
37 #endif
38
39 #ifndef __hot
40 #define __hot __attribute__((hot))
41 #endif
42
43 #define MOD_INC(i, l)   ((i) == (l - 1) ? (i) = 0 : (i)++)
44
45 struct cptvf_meta_info {
46         void *cptvf_meta_pool;
47         int cptvf_op_mlen;
48         int cptvf_op_sb_mlen;
49 };
50
51 struct rid {
52         /** Request id of a crypto operation */
53         uintptr_t rid;
54 };
55
56 /*
57  * Pending queue structure
58  *
59  */
60 struct pending_queue {
61         /** Tail of queue to be used for enqueue */
62         uint16_t enq_tail;
63         /** Head of queue to be used for dequeue */
64         uint16_t deq_head;
65         /** Array of pending requests */
66         struct rid *rid_queue;
67         /** Pending requests count */
68         uint64_t pending_count;
69 };
70
71 struct cpt_request_info {
72         /** Data path fields */
73         uint64_t comp_baddr;
74         volatile uint64_t *completion_addr;
75         volatile uint64_t *alternate_caddr;
76         void *op;
77         struct {
78                 uint64_t ei0;
79                 uint64_t ei1;
80                 uint64_t ei2;
81                 uint64_t ei3;
82         } ist;
83
84         /** Control path fields */
85         uint64_t time_out;
86         uint8_t extra_time;
87 };
88
89 #endif /* _CPT_COMMON_H_ */