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