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