1 /* QLogic qed NIC Driver 2 * Copyright (c) 2015 QLogic Corporation 3 * 4 * This software is available under the terms of the GNU General Public License 5 * (GPL) Version 2, available from the file COPYING in the main directory of 6 * this source tree. 7 */ 8 9 #ifndef _QED_DEV_API_H 10 #define _QED_DEV_API_H 11 12 #include <linux/types.h> 13 #include <linux/kernel.h> 14 #include <linux/slab.h> 15 #include <linux/qed/qed_chain.h> 16 #include <linux/qed/qed_if.h> 17 #include "qed_int.h" 18 19 /** 20 * @brief qed_init_dp - initialize the debug level 21 * 22 * @param cdev 23 * @param dp_module 24 * @param dp_level 25 */ 26 void qed_init_dp(struct qed_dev *cdev, 27 u32 dp_module, 28 u8 dp_level); 29 30 /** 31 * @brief qed_init_struct - initialize the device structure to 32 * its defaults 33 * 34 * @param cdev 35 */ 36 void qed_init_struct(struct qed_dev *cdev); 37 38 /** 39 * @brief qed_resc_free - 40 * 41 * @param cdev 42 */ 43 void qed_resc_free(struct qed_dev *cdev); 44 45 /** 46 * @brief qed_resc_alloc - 47 * 48 * @param cdev 49 * 50 * @return int 51 */ 52 int qed_resc_alloc(struct qed_dev *cdev); 53 54 /** 55 * @brief qed_resc_setup - 56 * 57 * @param cdev 58 */ 59 void qed_resc_setup(struct qed_dev *cdev); 60 61 /** 62 * @brief qed_hw_init - 63 * 64 * @param cdev 65 * @param b_hw_start 66 * @param int_mode - interrupt mode [msix, inta, etc.] to use. 67 * @param allow_npar_tx_switch - npar tx switching to be used 68 * for vports configured for tx-switching. 69 * @param bin_fw_data - binary fw data pointer in binary fw file. 70 * Pass NULL if not using binary fw file. 71 * 72 * @return int 73 */ 74 int qed_hw_init(struct qed_dev *cdev, 75 bool b_hw_start, 76 enum qed_int_mode int_mode, 77 bool allow_npar_tx_switch, 78 const u8 *bin_fw_data); 79 80 /** 81 * @brief qed_hw_timers_stop_all - stop the timers HW block 82 * 83 * @param cdev 84 * 85 * @return void 86 */ 87 void qed_hw_timers_stop_all(struct qed_dev *cdev); 88 89 /** 90 * @brief qed_hw_stop - 91 * 92 * @param cdev 93 * 94 * @return int 95 */ 96 int qed_hw_stop(struct qed_dev *cdev); 97 98 /** 99 * @brief qed_hw_stop_fastpath -should be called incase 100 * slowpath is still required for the device, 101 * but fastpath is not. 102 * 103 * @param cdev 104 * 105 */ 106 void qed_hw_stop_fastpath(struct qed_dev *cdev); 107 108 /** 109 * @brief qed_hw_start_fastpath -restart fastpath traffic, 110 * only if hw_stop_fastpath was called 111 * 112 * @param cdev 113 * 114 */ 115 void qed_hw_start_fastpath(struct qed_hwfn *p_hwfn); 116 117 /** 118 * @brief qed_hw_reset - 119 * 120 * @param cdev 121 * 122 * @return int 123 */ 124 int qed_hw_reset(struct qed_dev *cdev); 125 126 /** 127 * @brief qed_hw_prepare - 128 * 129 * @param cdev 130 * @param personality - personality to initialize 131 * 132 * @return int 133 */ 134 int qed_hw_prepare(struct qed_dev *cdev, 135 int personality); 136 137 /** 138 * @brief qed_hw_remove - 139 * 140 * @param cdev 141 */ 142 void qed_hw_remove(struct qed_dev *cdev); 143 144 /** 145 * @brief qed_ptt_acquire - Allocate a PTT window 146 * 147 * Should be called at the entry point to the driver (at the beginning of an 148 * exported function) 149 * 150 * @param p_hwfn 151 * 152 * @return struct qed_ptt 153 */ 154 struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn); 155 156 /** 157 * @brief qed_ptt_release - Release PTT Window 158 * 159 * Should be called at the end of a flow - at the end of the function that 160 * acquired the PTT. 161 * 162 * 163 * @param p_hwfn 164 * @param p_ptt 165 */ 166 void qed_ptt_release(struct qed_hwfn *p_hwfn, 167 struct qed_ptt *p_ptt); 168 void qed_reset_vport_stats(struct qed_dev *cdev); 169 170 enum qed_dmae_address_type_t { 171 QED_DMAE_ADDRESS_HOST_VIRT, 172 QED_DMAE_ADDRESS_HOST_PHYS, 173 QED_DMAE_ADDRESS_GRC 174 }; 175 176 /* value of flags If QED_DMAE_FLAG_RW_REPL_SRC flag is set and the 177 * source is a block of length DMAE_MAX_RW_SIZE and the 178 * destination is larger, the source block will be duplicated as 179 * many times as required to fill the destination block. This is 180 * used mostly to write a zeroed buffer to destination address 181 * using DMA 182 */ 183 #define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001 184 #define QED_DMAE_FLAG_COMPLETION_DST 0x00000008 185 186 struct qed_dmae_params { 187 u32 flags; /* consists of QED_DMAE_FLAG_* values */ 188 }; 189 190 /** 191 * @brief qed_dmae_host2grc - copy data from source addr to 192 * dmae registers using the given ptt 193 * 194 * @param p_hwfn 195 * @param p_ptt 196 * @param source_addr 197 * @param grc_addr (dmae_data_offset) 198 * @param size_in_dwords 199 * @param flags (one of the flags defined above) 200 */ 201 int 202 qed_dmae_host2grc(struct qed_hwfn *p_hwfn, 203 struct qed_ptt *p_ptt, 204 u64 source_addr, 205 u32 grc_addr, 206 u32 size_in_dwords, 207 u32 flags); 208 209 /** 210 * @brief qed_chain_alloc - Allocate and initialize a chain 211 * 212 * @param p_hwfn 213 * @param intended_use 214 * @param mode 215 * @param num_elems 216 * @param elem_size 217 * @param p_chain 218 * 219 * @return int 220 */ 221 int 222 qed_chain_alloc(struct qed_dev *cdev, 223 enum qed_chain_use_mode intended_use, 224 enum qed_chain_mode mode, 225 u16 num_elems, 226 size_t elem_size, 227 struct qed_chain *p_chain); 228 229 /** 230 * @brief qed_chain_free - Free chain DMA memory 231 * 232 * @param p_hwfn 233 * @param p_chain 234 */ 235 void qed_chain_free(struct qed_dev *cdev, 236 struct qed_chain *p_chain); 237 238 /** 239 * @@brief qed_fw_l2_queue - Get absolute L2 queue ID 240 * 241 * @param p_hwfn 242 * @param src_id - relative to p_hwfn 243 * @param dst_id - absolute per engine 244 * 245 * @return int 246 */ 247 int qed_fw_l2_queue(struct qed_hwfn *p_hwfn, 248 u16 src_id, 249 u16 *dst_id); 250 251 /** 252 * @@brief qed_fw_vport - Get absolute vport ID 253 * 254 * @param p_hwfn 255 * @param src_id - relative to p_hwfn 256 * @param dst_id - absolute per engine 257 * 258 * @return int 259 */ 260 int qed_fw_vport(struct qed_hwfn *p_hwfn, 261 u8 src_id, 262 u8 *dst_id); 263 264 /** 265 * @@brief qed_fw_rss_eng - Get absolute RSS engine ID 266 * 267 * @param p_hwfn 268 * @param src_id - relative to p_hwfn 269 * @param dst_id - absolute per engine 270 * 271 * @return int 272 */ 273 int qed_fw_rss_eng(struct qed_hwfn *p_hwfn, 274 u8 src_id, 275 u8 *dst_id); 276 277 /** 278 * *@brief Cleanup of previous driver remains prior to load 279 * 280 * @param p_hwfn 281 * @param p_ptt 282 * @param id - For PF, engine-relative. For VF, PF-relative. 283 * 284 * @return int 285 */ 286 int qed_final_cleanup(struct qed_hwfn *p_hwfn, 287 struct qed_ptt *p_ptt, 288 u16 id); 289 290 #endif 291