1 /* 2 * Copyright (c) 2016 QLogic Corporation. 3 * All rights reserved. 4 * www.qlogic.com 5 * 6 * See LICENSE.qede_pmd for copyright and licensing details. 7 */ 8 9 #ifndef __ECORE_DEV_API_H__ 10 #define __ECORE_DEV_API_H__ 11 12 #include "ecore_status.h" 13 #include "ecore_chain.h" 14 #include "ecore_int_api.h" 15 16 struct ecore_tunn_start_params; 17 18 /** 19 * @brief ecore_init_dp - initialize the debug level 20 * 21 * @param p_dev 22 * @param dp_module 23 * @param dp_level 24 * @param dp_ctx 25 */ 26 void ecore_init_dp(struct ecore_dev *p_dev, 27 u32 dp_module, u8 dp_level, void *dp_ctx); 28 29 /** 30 * @brief ecore_init_struct - initialize the device structure to 31 * its defaults 32 * 33 * @param p_dev 34 */ 35 void ecore_init_struct(struct ecore_dev *p_dev); 36 37 /** 38 * @brief ecore_resc_free - 39 * 40 * @param p_dev 41 */ 42 void ecore_resc_free(struct ecore_dev *p_dev); 43 44 /** 45 * @brief ecore_resc_alloc - 46 * 47 * @param p_dev 48 * 49 * @return enum _ecore_status_t 50 */ 51 enum _ecore_status_t ecore_resc_alloc(struct ecore_dev *p_dev); 52 53 /** 54 * @brief ecore_resc_setup - 55 * 56 * @param p_dev 57 */ 58 void ecore_resc_setup(struct ecore_dev *p_dev); 59 60 /** 61 * @brief ecore_hw_init - 62 * 63 * @param p_dev 64 * @param p_tunn - tunneling parameters 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 enum _ecore_status_t 73 */ 74 enum _ecore_status_t ecore_hw_init(struct ecore_dev *p_dev, 75 struct ecore_tunn_start_params *p_tunn, 76 bool b_hw_start, 77 enum ecore_int_mode int_mode, 78 bool allow_npar_tx_switch, 79 const u8 *bin_fw_data); 80 81 /** 82 * @brief ecore_hw_timers_stop_all - 83 * 84 * @param p_dev 85 * 86 * @return void 87 */ 88 void ecore_hw_timers_stop_all(struct ecore_dev *p_dev); 89 90 /** 91 * @brief ecore_hw_stop - 92 * 93 * @param p_dev 94 * 95 * @return enum _ecore_status_t 96 */ 97 enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev); 98 99 /** 100 * @brief ecore_hw_stop_fastpath -should be called incase 101 * slowpath is still required for the device, but 102 * fastpath is not. 103 * 104 * @param p_dev 105 * 106 */ 107 void ecore_hw_stop_fastpath(struct ecore_dev *p_dev); 108 109 /** 110 * @brief ecore_prepare_hibernate -should be called when 111 * the system is going into the hibernate state 112 * 113 * @param p_dev 114 * 115 */ 116 void ecore_prepare_hibernate(struct ecore_dev *p_dev); 117 118 /** 119 * @brief ecore_hw_start_fastpath -restart fastpath traffic, 120 * only if hw_stop_fastpath was called 121 122 * @param p_dev 123 * 124 */ 125 void ecore_hw_start_fastpath(struct ecore_hwfn *p_hwfn); 126 127 /** 128 * @brief ecore_hw_reset - 129 * 130 * @param p_dev 131 * 132 * @return enum _ecore_status_t 133 */ 134 enum _ecore_status_t ecore_hw_reset(struct ecore_dev *p_dev); 135 136 /** 137 * @brief ecore_hw_prepare - 138 * 139 * @param p_dev 140 * @param personality - personality to initialize 141 * 142 * @return enum _ecore_status_t 143 */ 144 enum _ecore_status_t ecore_hw_prepare(struct ecore_dev *p_dev, int personality); 145 146 /** 147 * @brief ecore_hw_remove - 148 * 149 * @param p_dev 150 */ 151 void ecore_hw_remove(struct ecore_dev *p_dev); 152 153 /** 154 * @brief ecore_ptt_acquire - Allocate a PTT window 155 * 156 * Should be called at the entry point to the driver (at the beginning of an 157 * exported function) 158 * 159 * @param p_hwfn 160 * 161 * @return struct ecore_ptt 162 */ 163 struct ecore_ptt *ecore_ptt_acquire(struct ecore_hwfn *p_hwfn); 164 165 /** 166 * @brief ecore_ptt_release - Release PTT Window 167 * 168 * Should be called at the end of a flow - at the end of the function that 169 * acquired the PTT. 170 * 171 * 172 * @param p_hwfn 173 * @param p_ptt 174 */ 175 void ecore_ptt_release(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt); 176 177 #ifndef __EXTRACT__LINUX__ 178 struct ecore_eth_stats { 179 u64 no_buff_discards; 180 u64 packet_too_big_discard; 181 u64 ttl0_discard; 182 u64 rx_ucast_bytes; 183 u64 rx_mcast_bytes; 184 u64 rx_bcast_bytes; 185 u64 rx_ucast_pkts; 186 u64 rx_mcast_pkts; 187 u64 rx_bcast_pkts; 188 u64 mftag_filter_discards; 189 u64 mac_filter_discards; 190 u64 tx_ucast_bytes; 191 u64 tx_mcast_bytes; 192 u64 tx_bcast_bytes; 193 u64 tx_ucast_pkts; 194 u64 tx_mcast_pkts; 195 u64 tx_bcast_pkts; 196 u64 tx_err_drop_pkts; 197 u64 tpa_coalesced_pkts; 198 u64 tpa_coalesced_events; 199 u64 tpa_aborts_num; 200 u64 tpa_not_coalesced_pkts; 201 u64 tpa_coalesced_bytes; 202 203 /* port */ 204 u64 rx_64_byte_packets; 205 u64 rx_65_to_127_byte_packets; 206 u64 rx_128_to_255_byte_packets; 207 u64 rx_256_to_511_byte_packets; 208 u64 rx_512_to_1023_byte_packets; 209 u64 rx_1024_to_1518_byte_packets; 210 u64 rx_1519_to_1522_byte_packets; 211 u64 rx_1519_to_2047_byte_packets; 212 u64 rx_2048_to_4095_byte_packets; 213 u64 rx_4096_to_9216_byte_packets; 214 u64 rx_9217_to_16383_byte_packets; 215 u64 rx_crc_errors; 216 u64 rx_mac_crtl_frames; 217 u64 rx_pause_frames; 218 u64 rx_pfc_frames; 219 u64 rx_align_errors; 220 u64 rx_carrier_errors; 221 u64 rx_oversize_packets; 222 u64 rx_jabbers; 223 u64 rx_undersize_packets; 224 u64 rx_fragments; 225 u64 tx_64_byte_packets; 226 u64 tx_65_to_127_byte_packets; 227 u64 tx_128_to_255_byte_packets; 228 u64 tx_256_to_511_byte_packets; 229 u64 tx_512_to_1023_byte_packets; 230 u64 tx_1024_to_1518_byte_packets; 231 u64 tx_1519_to_2047_byte_packets; 232 u64 tx_2048_to_4095_byte_packets; 233 u64 tx_4096_to_9216_byte_packets; 234 u64 tx_9217_to_16383_byte_packets; 235 u64 tx_pause_frames; 236 u64 tx_pfc_frames; 237 u64 tx_lpi_entry_count; 238 u64 tx_total_collisions; 239 u64 brb_truncates; 240 u64 brb_discards; 241 u64 rx_mac_bytes; 242 u64 rx_mac_uc_packets; 243 u64 rx_mac_mc_packets; 244 u64 rx_mac_bc_packets; 245 u64 rx_mac_frames_ok; 246 u64 tx_mac_bytes; 247 u64 tx_mac_uc_packets; 248 u64 tx_mac_mc_packets; 249 u64 tx_mac_bc_packets; 250 u64 tx_mac_ctrl_frames; 251 }; 252 #endif 253 254 enum ecore_dmae_address_type_t { 255 ECORE_DMAE_ADDRESS_HOST_VIRT, 256 ECORE_DMAE_ADDRESS_HOST_PHYS, 257 ECORE_DMAE_ADDRESS_GRC 258 }; 259 260 /* value of flags If ECORE_DMAE_FLAG_RW_REPL_SRC flag is set and the 261 * source is a block of length DMAE_MAX_RW_SIZE and the 262 * destination is larger, the source block will be duplicated as 263 * many times as required to fill the destination block. This is 264 * used mostly to write a zeroed buffer to destination address 265 * using DMA 266 */ 267 #define ECORE_DMAE_FLAG_RW_REPL_SRC 0x00000001 268 #define ECORE_DMAE_FLAG_VF_SRC 0x00000002 269 #define ECORE_DMAE_FLAG_VF_DST 0x00000004 270 #define ECORE_DMAE_FLAG_COMPLETION_DST 0x00000008 271 272 struct ecore_dmae_params { 273 u32 flags; /* consists of ECORE_DMAE_FLAG_* values */ 274 u8 src_vfid; 275 u8 dst_vfid; 276 }; 277 278 /** 279 * @brief ecore_dmae_host2grc - copy data from source addr to 280 * dmae registers using the given ptt 281 * 282 * @param p_hwfn 283 * @param p_ptt 284 * @param source_addr 285 * @param grc_addr (dmae_data_offset) 286 * @param size_in_dwords 287 * @param flags (one of the flags defined above) 288 */ 289 enum _ecore_status_t 290 ecore_dmae_host2grc(struct ecore_hwfn *p_hwfn, 291 struct ecore_ptt *p_ptt, 292 u64 source_addr, 293 u32 grc_addr, u32 size_in_dwords, u32 flags); 294 295 /** 296 * @brief ecore_dmae_grc2host - Read data from dmae data offset 297 * to source address using the given ptt 298 * 299 * @param p_ptt 300 * @param grc_addr (dmae_data_offset) 301 * @param dest_addr 302 * @param size_in_dwords 303 * @param flags - one of the flags defined above 304 */ 305 enum _ecore_status_t 306 ecore_dmae_grc2host(struct ecore_hwfn *p_hwfn, 307 struct ecore_ptt *p_ptt, 308 u32 grc_addr, 309 dma_addr_t dest_addr, u32 size_in_dwords, u32 flags); 310 311 /** 312 * @brief ecore_dmae_host2host - copy data from to source address 313 * to a destination address (for SRIOV) using the given ptt 314 * 315 * @param p_hwfn 316 * @param p_ptt 317 * @param source_addr 318 * @param dest_addr 319 * @param size_in_dwords 320 * @param params 321 */ 322 enum _ecore_status_t 323 ecore_dmae_host2host(struct ecore_hwfn *p_hwfn, 324 struct ecore_ptt *p_ptt, 325 dma_addr_t source_addr, 326 dma_addr_t dest_addr, 327 u32 size_in_dwords, struct ecore_dmae_params *p_params); 328 329 /** 330 * @brief ecore_chain_alloc - Allocate and initialize a chain 331 * 332 * @param p_hwfn 333 * @param intended_use 334 * @param mode 335 * @param num_elems 336 * @param elem_size 337 * @param p_chain 338 * 339 * @return enum _ecore_status_t 340 */ 341 enum _ecore_status_t 342 ecore_chain_alloc(struct ecore_dev *p_dev, 343 enum ecore_chain_use_mode intended_use, 344 enum ecore_chain_mode mode, 345 enum ecore_chain_cnt_type cnt_type, 346 u32 num_elems, 347 osal_size_t elem_size, struct ecore_chain *p_chain); 348 349 /** 350 * @brief ecore_chain_free - Free chain DMA memory 351 * 352 * @param p_hwfn 353 * @param p_chain 354 */ 355 void ecore_chain_free(struct ecore_dev *p_dev, struct ecore_chain *p_chain); 356 357 /** 358 * @@brief ecore_fw_l2_queue - Get absolute L2 queue ID 359 * 360 * @param p_hwfn 361 * @param src_id - relative to p_hwfn 362 * @param dst_id - absolute per engine 363 * 364 * @return enum _ecore_status_t 365 */ 366 enum _ecore_status_t ecore_fw_l2_queue(struct ecore_hwfn *p_hwfn, 367 u16 src_id, u16 *dst_id); 368 369 /** 370 * @@brief ecore_fw_vport - Get absolute vport ID 371 * 372 * @param p_hwfn 373 * @param src_id - relative to p_hwfn 374 * @param dst_id - absolute per engine 375 * 376 * @return enum _ecore_status_t 377 */ 378 enum _ecore_status_t ecore_fw_vport(struct ecore_hwfn *p_hwfn, 379 u8 src_id, u8 *dst_id); 380 381 /** 382 * @@brief ecore_fw_rss_eng - Get absolute RSS engine ID 383 * 384 * @param p_hwfn 385 * @param src_id - relative to p_hwfn 386 * @param dst_id - absolute per engine 387 * 388 * @return enum _ecore_status_t 389 */ 390 enum _ecore_status_t ecore_fw_rss_eng(struct ecore_hwfn *p_hwfn, 391 u8 src_id, u8 *dst_id); 392 393 /** 394 * @brief ecore_llh_add_mac_filter - configures a MAC filter in llh 395 * 396 * @param p_hwfn 397 * @param p_ptt 398 * @param p_filter - MAC to add 399 */ 400 enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_hwfn *p_hwfn, 401 struct ecore_ptt *p_ptt, 402 u8 *p_filter); 403 404 /** 405 * @brief ecore_llh_remove_mac_filter - removes a MAC filtre from llh 406 * 407 * @param p_hwfn 408 * @param p_ptt 409 * @param p_filter - MAC to remove 410 */ 411 void ecore_llh_remove_mac_filter(struct ecore_hwfn *p_hwfn, 412 struct ecore_ptt *p_ptt, u8 *p_filter); 413 414 /** 415 * @brief ecore_llh_add_ethertype_filter - configures a ethertype filter in llh 416 * 417 * @param p_hwfn 418 * @param p_ptt 419 * @param filter - ethertype to add 420 */ 421 enum _ecore_status_t ecore_llh_add_ethertype_filter(struct ecore_hwfn *p_hwfn, 422 struct ecore_ptt *p_ptt, 423 u16 filter); 424 425 /** 426 * @brief ecore_llh_remove_ethertype_filter - removes a ethertype llh filter 427 * 428 * @param p_hwfn 429 * @param p_ptt 430 * @param filter - ethertype to remove 431 */ 432 void ecore_llh_remove_ethertype_filter(struct ecore_hwfn *p_hwfn, 433 struct ecore_ptt *p_ptt, u16 filter); 434 435 /** 436 * @brief ecore_llh_clear_all_filters - removes all MAC filters from llh 437 * 438 * @param p_hwfn 439 * @param p_ptt 440 */ 441 void ecore_llh_clear_all_filters(struct ecore_hwfn *p_hwfn, 442 struct ecore_ptt *p_ptt); 443 444 /** 445 *@brief Cleanup of previous driver remains prior to load 446 * 447 * @param p_hwfn 448 * @param p_ptt 449 * @param id - For PF, engine-relative. For VF, PF-relative. 450 * @param is_vf - true iff cleanup is made for a VF. 451 * 452 * @return enum _ecore_status_t 453 */ 454 enum _ecore_status_t ecore_final_cleanup(struct ecore_hwfn *p_hwfn, 455 struct ecore_ptt *p_ptt, 456 u16 id, bool is_vf); 457 458 /** 459 * @brief ecore_test_registers - Perform register tests 460 * 461 * @param p_hwfn 462 * @param p_ptt 463 * 464 * @return enum _ecore_status_t 465 */ 466 enum _ecore_status_t ecore_test_registers(struct ecore_hwfn *p_hwfn, 467 struct ecore_ptt *p_ptt); 468 469 /** 470 * @brief ecore_set_rxq_coalesce - Configure coalesce parameters for an Rx queue 471 * 472 * @param p_hwfn 473 * @param p_ptt 474 * @param coalesce - Coalesce value in micro seconds. 475 * @param qid - Queue index. 476 * 477 * @return enum _ecore_status_t 478 */ 479 enum _ecore_status_t ecore_set_rxq_coalesce(struct ecore_hwfn *p_hwfn, 480 struct ecore_ptt *p_ptt, 481 u8 coalesce, u8 qid); 482 483 /** 484 * @brief ecore_set_txq_coalesce - Configure coalesce parameters for a Tx queue 485 * 486 * @param p_hwfn 487 * @param p_ptt 488 * @param coalesce - Coalesce value in micro seconds. 489 * @param qid - Queue index. 490 * 491 * @return enum _ecore_status_t 492 */ 493 enum _ecore_status_t ecore_set_txq_coalesce(struct ecore_hwfn *p_hwfn, 494 struct ecore_ptt *p_ptt, 495 u8 coalesce, u8 qid); 496 497 #endif 498