xref: /dpdk/drivers/common/cpt/cpt_common.h (revision 200bc52e5aa0d72e70464c9cd22b55cf536ed13c)
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 #include <rte_mempool.h>
9 
10 /*
11  * This file defines common macros and structs
12  */
13 
14 #define TIME_IN_RESET_COUNT	5
15 
16 /* Default command timeout in seconds */
17 #define DEFAULT_COMMAND_TIMEOUT	4
18 
19 #define CPT_COUNT_THOLD		32
20 #define CPT_TIMER_THOLD		0x3F
21 
22 #define AE_TYPE 1
23 #define SE_TYPE 2
24 
25 #ifndef ROUNDUP4
26 #define ROUNDUP4(val)	(((val) + 3) & 0xfffffffc)
27 #endif
28 
29 #ifndef ROUNDUP8
30 #define ROUNDUP8(val)	(((val) + 7) & 0xfffffff8)
31 #endif
32 
33 #ifndef ROUNDUP16
34 #define ROUNDUP16(val)	(((val) + 15) & 0xfffffff0)
35 #endif
36 
37 #ifndef __hot
38 #define __hot __attribute__((hot))
39 #endif
40 
41 #define MOD_INC(i, l)   ((i) == (l - 1) ? (i) = 0 : (i)++)
42 
43 struct cpt_qp_meta_info {
44 	struct rte_mempool *pool;
45 	int sg_mlen;
46 	int lb_mlen;
47 };
48 
49 struct rid {
50 	/** Request id of a crypto operation */
51 	uintptr_t rid;
52 };
53 
54 /*
55  * Pending queue structure
56  *
57  */
58 struct pending_queue {
59 	/** Pending requests count */
60 	uint64_t pending_count;
61 	/** Array of pending requests */
62 	struct rid *rid_queue;
63 	/** Tail of queue to be used for enqueue */
64 	uint16_t enq_tail;
65 	/** Head of queue to be used for dequeue */
66 	uint16_t deq_head;
67 };
68 
69 struct cpt_request_info {
70 	/** Data path fields */
71 	uint64_t comp_baddr;
72 	volatile uint64_t *completion_addr;
73 	volatile uint64_t *alternate_caddr;
74 	void *op;
75 	struct {
76 		uint64_t ei0;
77 		uint64_t ei1;
78 		uint64_t ei2;
79 		uint64_t ei3;
80 	} ist;
81 
82 	/** Control path fields */
83 	uint64_t time_out;
84 	uint8_t extra_time;
85 } __rte_cache_aligned;
86 
87 #endif /* _CPT_COMMON_H_ */
88