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 TIME_IN_RESET_COUNT 5 19 20 /* Default command timeout in seconds */ 21 #define DEFAULT_COMMAND_TIMEOUT 4 22 23 #define CPT_COUNT_THOLD 32 24 #define CPT_TIMER_THOLD 0x3F 25 26 #define AE_TYPE 1 27 #define SE_TYPE 2 28 29 #ifndef ROUNDUP4 30 #define ROUNDUP4(val) (((val) + 3) & 0xfffffffc) 31 #endif 32 33 #ifndef ROUNDUP8 34 #define ROUNDUP8(val) (((val) + 7) & 0xfffffff8) 35 #endif 36 37 #ifndef ROUNDUP16 38 #define ROUNDUP16(val) (((val) + 15) & 0xfffffff0) 39 #endif 40 41 #ifndef __hot 42 #define __hot __attribute__((hot)) 43 #endif 44 45 #define MOD_INC(i, l) ((i) == (l - 1) ? (i) = 0 : (i)++) 46 47 struct cptvf_meta_info { 48 void *cptvf_meta_pool; 49 int cptvf_op_mlen; 50 int cptvf_op_sb_mlen; 51 }; 52 53 struct rid { 54 /** Request id of a crypto operation */ 55 uintptr_t rid; 56 }; 57 58 /* 59 * Pending queue structure 60 * 61 */ 62 struct pending_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 /** Array of pending requests */ 68 struct rid *rid_queue; 69 /** Pending requests count */ 70 uint64_t pending_count; 71 }; 72 73 struct cpt_request_info { 74 /** Data path fields */ 75 uint64_t comp_baddr; 76 volatile uint64_t *completion_addr; 77 volatile uint64_t *alternate_caddr; 78 void *op; 79 struct { 80 uint64_t ei0; 81 uint64_t ei1; 82 uint64_t ei2; 83 uint64_t ei3; 84 } ist; 85 86 /** Control path fields */ 87 uint64_t time_out; 88 uint8_t extra_time; 89 }; 90 91 #endif /* _CPT_COMMON_H_ */ 92