88f490268fab350cdf73ad63f27d57702349f615
[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 #define AE_TYPE 1
19 #define SE_TYPE 2
20
21 #ifndef ROUNDUP4
22 #define ROUNDUP4(val)   (((val) + 3) & 0xfffffffc)
23 #endif
24
25 #ifndef ROUNDUP8
26 #define ROUNDUP8(val)   (((val) + 7) & 0xfffffff8)
27 #endif
28
29 #ifndef ROUNDUP16
30 #define ROUNDUP16(val)  (((val) + 15) & 0xfffffff0)
31 #endif
32
33 #ifndef __hot
34 #define __hot __attribute__((hot))
35 #endif
36
37 #define MOD_INC(i, l)   ((i) == (l - 1) ? (i) = 0 : (i)++)
38
39 struct cptvf_meta_info {
40         void *cptvf_meta_pool;
41         int cptvf_op_mlen;
42         int cptvf_op_sb_mlen;
43 };
44
45 struct rid {
46         /** Request id of a crypto operation */
47         uintptr_t rid;
48 };
49
50 /*
51  * Pending queue structure
52  *
53  */
54 struct pending_queue {
55         /** Tail of queue to be used for enqueue */
56         uint16_t enq_tail;
57         /** Head of queue to be used for dequeue */
58         uint16_t deq_head;
59         /** Array of pending requests */
60         struct rid *rid_queue;
61         /** Pending requests count */
62         uint64_t pending_count;
63 };
64
65 struct cpt_request_info {
66         /** Data path fields */
67         uint64_t comp_baddr;
68         volatile uint64_t *completion_addr;
69         volatile uint64_t *alternate_caddr;
70         void *op;
71         struct {
72                 uint64_t ei0;
73                 uint64_t ei1;
74                 uint64_t ei2;
75                 uint64_t ei3;
76         } ist;
77
78         /** Control path fields */
79         uint64_t time_out;
80         uint8_t extra_time;
81 };
82
83 #endif /* _CPT_COMMON_H_ */