1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2016 Cavium, Inc. 4 */ 5 6 #ifndef __REQUEST_MANAGER_H 7 #define __REQUEST_MANAGER_H 8 9 #include "cpt_common.h" 10 11 #define TIME_IN_RESET_COUNT 5 12 #define COMPLETION_CODE_SIZE 8 13 #define COMPLETION_CODE_INIT 0 14 #define PENDING_THOLD 100 15 #define MAX_SG_IN_CNT 12 16 #define MAX_SG_OUT_CNT 13 17 #define SG_LIST_HDR_SIZE 8 18 #define MAX_BUF_CNT 16 19 20 union ctrl_info { 21 u32 flags; 22 struct { 23 #if defined(__BIG_ENDIAN_BITFIELD) 24 u32 reserved0:26; 25 u32 grp:3; /* Group bits */ 26 u32 dma_mode:2; /* DMA mode */ 27 u32 se_req:1;/* To SE core */ 28 #else 29 u32 se_req:1; /* To SE core */ 30 u32 dma_mode:2; /* DMA mode */ 31 u32 grp:3; /* Group bits */ 32 u32 reserved0:26; 33 #endif 34 } s; 35 }; 36 37 union opcode_info { 38 u16 flags; 39 struct { 40 u8 major; 41 u8 minor; 42 } s; 43 }; 44 45 struct cptvf_request { 46 union opcode_info opcode; 47 u16 param1; 48 u16 param2; 49 u16 dlen; 50 }; 51 52 struct buf_ptr { 53 u8 *vptr; 54 dma_addr_t dma_addr; 55 u16 size; 56 }; 57 58 struct cpt_request_info { 59 u8 incnt; /* Number of input buffers */ 60 u8 outcnt; /* Number of output buffers */ 61 u16 rlen; /* Output length */ 62 union ctrl_info ctrl; /* User control information */ 63 struct cptvf_request req; /* Request Information (Core specific) */ 64 65 struct buf_ptr in[MAX_BUF_CNT]; 66 struct buf_ptr out[MAX_BUF_CNT]; 67 68 void (*callback)(int, void *); /* Kernel ASYNC request callabck */ 69 void *callback_arg; /* Kernel ASYNC request callabck arg */ 70 }; 71 72 struct sglist_component { 73 union { 74 u64 len; 75 struct { 76 u16 len0; 77 u16 len1; 78 u16 len2; 79 u16 len3; 80 } s; 81 } u; 82 u64 ptr0; 83 u64 ptr1; 84 u64 ptr2; 85 u64 ptr3; 86 }; 87 88 struct cpt_info_buffer { 89 struct cpt_vf *cptvf; 90 unsigned long time_in; 91 u8 extra_time; 92 93 struct cpt_request_info *req; 94 dma_addr_t dptr_baddr; 95 u32 dlen; 96 dma_addr_t rptr_baddr; 97 dma_addr_t comp_baddr; 98 u8 *in_buffer; 99 u8 *out_buffer; 100 u8 *gather_components; 101 u8 *scatter_components; 102 103 struct pending_entry *pentry; 104 volatile u64 *completion_addr; 105 volatile u64 *alternate_caddr; 106 }; 107 108 /* 109 * CPT_INST_S software command definitions 110 * Words EI (0-3) 111 */ 112 union vq_cmd_word0 { 113 u64 u64; 114 struct { 115 u16 opcode; 116 u16 param1; 117 u16 param2; 118 u16 dlen; 119 } s; 120 }; 121 122 union vq_cmd_word3 { 123 u64 u64; 124 struct { 125 #if defined(__BIG_ENDIAN_BITFIELD) 126 u64 grp:3; 127 u64 cptr:61; 128 #else 129 u64 cptr:61; 130 u64 grp:3; 131 #endif 132 } s; 133 }; 134 135 struct cpt_vq_command { 136 union vq_cmd_word0 cmd; 137 u64 dptr; 138 u64 rptr; 139 union vq_cmd_word3 cptr; 140 }; 141 142 void vq_post_process(struct cpt_vf *cptvf, u32 qno); 143 int process_request(struct cpt_vf *cptvf, struct cpt_request_info *req); 144 #endif /* __REQUEST_MANAGER_H */ 145