1316485Sdavidcs/* 2316485Sdavidcs * Copyright (c) 2017-2018 Cavium, Inc. 3316485Sdavidcs * All rights reserved. 4316485Sdavidcs * 5316485Sdavidcs * Redistribution and use in source and binary forms, with or without 6316485Sdavidcs * modification, are permitted provided that the following conditions 7316485Sdavidcs * are met: 8316485Sdavidcs * 9316485Sdavidcs * 1. Redistributions of source code must retain the above copyright 10316485Sdavidcs * notice, this list of conditions and the following disclaimer. 11316485Sdavidcs * 2. Redistributions in binary form must reproduce the above copyright 12316485Sdavidcs * notice, this list of conditions and the following disclaimer in the 13316485Sdavidcs * documentation and/or other materials provided with the distribution. 14316485Sdavidcs * 15316485Sdavidcs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16316485Sdavidcs * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17316485Sdavidcs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18316485Sdavidcs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19316485Sdavidcs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20316485Sdavidcs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21316485Sdavidcs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22316485Sdavidcs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23316485Sdavidcs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24316485Sdavidcs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25316485Sdavidcs * POSSIBILITY OF SUCH DAMAGE. 26316485Sdavidcs * 27316485Sdavidcs * $FreeBSD: stable/11/sys/dev/qlnx/qlnxe/ecore_ooo.h 337517 2018-08-09 01:17:35Z davidcs $ 28316485Sdavidcs * 29316485Sdavidcs */ 30316485Sdavidcs 31316485Sdavidcs#ifndef __ECORE_OOO_H__ 32316485Sdavidcs#define __ECORE_OOO_H__ 33316485Sdavidcs 34316485Sdavidcs#include "ecore.h" 35316485Sdavidcs 36316485Sdavidcs#define ECORE_MAX_NUM_ISLES 256 37316485Sdavidcs#define ECORE_MAX_NUM_OOO_HISTORY_ENTRIES 512 38316485Sdavidcs 39316485Sdavidcs#define ECORE_OOO_LEFT_BUF 0 40316485Sdavidcs#define ECORE_OOO_RIGHT_BUF 1 41316485Sdavidcs 42316485Sdavidcsstruct ecore_ooo_buffer { 43316485Sdavidcs osal_list_entry_t list_entry; 44316485Sdavidcs void *rx_buffer_virt_addr; 45316485Sdavidcs dma_addr_t rx_buffer_phys_addr; 46316485Sdavidcs u32 rx_buffer_size; 47316485Sdavidcs u16 packet_length; 48316485Sdavidcs u16 parse_flags; 49316485Sdavidcs u16 vlan; 50316485Sdavidcs u8 placement_offset; 51316485Sdavidcs}; 52316485Sdavidcs 53316485Sdavidcsstruct ecore_ooo_isle { 54316485Sdavidcs osal_list_entry_t list_entry; 55316485Sdavidcs osal_list_t buffers_list; 56316485Sdavidcs}; 57316485Sdavidcs 58316485Sdavidcsstruct ecore_ooo_archipelago { 59316485Sdavidcs osal_list_t isles_list; 60316485Sdavidcs}; 61316485Sdavidcs 62316485Sdavidcsstruct ecore_ooo_history { 63316485Sdavidcs struct ooo_opaque *p_cqes; 64316485Sdavidcs u32 head_idx; 65316485Sdavidcs u32 num_of_cqes; 66316485Sdavidcs}; 67316485Sdavidcs 68316485Sdavidcsstruct ecore_ooo_info { 69316485Sdavidcs osal_list_t free_buffers_list; 70316485Sdavidcs osal_list_t ready_buffers_list; 71316485Sdavidcs osal_list_t free_isles_list; 72316485Sdavidcs struct ecore_ooo_archipelago *p_archipelagos_mem; 73316485Sdavidcs struct ecore_ooo_isle *p_isles_mem; 74316485Sdavidcs struct ecore_ooo_history ooo_history; 75316485Sdavidcs u32 cur_isles_number; 76316485Sdavidcs u32 max_isles_number; 77316485Sdavidcs u32 gen_isles_number; 78316485Sdavidcs u16 max_num_archipelagos; 79316485Sdavidcs u16 cid_base; 80316485Sdavidcs}; 81316485Sdavidcs 82337517Sdavidcs#if defined(CONFIG_ECORE_ISCSI) || defined(CONFIG_ECORE_IWARP) 83316485Sdavidcsenum _ecore_status_t ecore_ooo_alloc(struct ecore_hwfn *p_hwfn); 84316485Sdavidcs 85316485Sdavidcsvoid ecore_ooo_setup(struct ecore_hwfn *p_hwfn); 86316485Sdavidcs 87316485Sdavidcsvoid ecore_ooo_free(struct ecore_hwfn *p_hwfn); 88337517Sdavidcs#else 89337517Sdavidcsstatic inline enum _ecore_status_t 90337517Sdavidcsecore_ooo_alloc(struct ecore_hwfn OSAL_UNUSED *p_hwfn) 91337517Sdavidcs{ 92337517Sdavidcs return ECORE_INVAL; 93337517Sdavidcs} 94316485Sdavidcs 95337517Sdavidcsstatic inline void 96337517Sdavidcsecore_ooo_setup(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {} 97337517Sdavidcs 98337517Sdavidcsstatic inline void 99337517Sdavidcsecore_ooo_free(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {} 100337517Sdavidcs#endif 101337517Sdavidcs 102337517Sdavidcs 103320164Sdavidcsvoid ecore_ooo_save_history_entry(struct ecore_ooo_info *p_ooo_info, 104320164Sdavidcs struct ooo_opaque *p_cqe); 105316485Sdavidcs 106320164Sdavidcsvoid ecore_ooo_release_connection_isles(struct ecore_ooo_info *p_ooo_info, 107320164Sdavidcs u32 cid); 108316485Sdavidcs 109320164Sdavidcsvoid ecore_ooo_release_all_isles(struct ecore_ooo_info *p_ooo_info); 110316485Sdavidcs 111320164Sdavidcsvoid ecore_ooo_put_free_buffer(struct ecore_ooo_info *p_ooo_info, 112320164Sdavidcs struct ecore_ooo_buffer *p_buffer); 113316485Sdavidcs 114316485Sdavidcsstruct ecore_ooo_buffer * 115320164Sdavidcsecore_ooo_get_free_buffer(struct ecore_ooo_info *p_ooo_info); 116316485Sdavidcs 117320164Sdavidcsvoid ecore_ooo_put_ready_buffer(struct ecore_ooo_info *p_ooo_info, 118320164Sdavidcs struct ecore_ooo_buffer *p_buffer, u8 on_tail); 119316485Sdavidcs 120316485Sdavidcsstruct ecore_ooo_buffer * 121320164Sdavidcsecore_ooo_get_ready_buffer(struct ecore_ooo_info *p_ooo_info); 122316485Sdavidcs 123316485Sdavidcsvoid ecore_ooo_delete_isles(struct ecore_hwfn *p_hwfn, 124316485Sdavidcs struct ecore_ooo_info *p_ooo_info, 125316485Sdavidcs u32 cid, 126316485Sdavidcs u8 drop_isle, 127316485Sdavidcs u8 drop_size); 128316485Sdavidcs 129316485Sdavidcsvoid ecore_ooo_add_new_isle(struct ecore_hwfn *p_hwfn, 130316485Sdavidcs struct ecore_ooo_info *p_ooo_info, 131316485Sdavidcs u32 cid, 132316485Sdavidcs u8 ooo_isle, 133316485Sdavidcs struct ecore_ooo_buffer *p_buffer); 134316485Sdavidcs 135316485Sdavidcsvoid ecore_ooo_add_new_buffer(struct ecore_hwfn *p_hwfn, 136316485Sdavidcs struct ecore_ooo_info *p_ooo_info, 137316485Sdavidcs u32 cid, 138316485Sdavidcs u8 ooo_isle, 139316485Sdavidcs struct ecore_ooo_buffer *p_buffer, 140316485Sdavidcs u8 buffer_side); 141316485Sdavidcs 142316485Sdavidcsvoid ecore_ooo_join_isles(struct ecore_hwfn *p_hwfn, 143316485Sdavidcs struct ecore_ooo_info *p_ooo_info, 144316485Sdavidcs u32 cid, 145316485Sdavidcs u8 left_isle); 146316485Sdavidcs 147316485Sdavidcsvoid ecore_ooo_dump_rx_event(struct ecore_hwfn *p_hwfn, 148316485Sdavidcs struct ooo_opaque *iscsi_ooo, 149316485Sdavidcs struct ecore_ooo_buffer *p_buffer); 150316485Sdavidcs 151316485Sdavidcs#endif /*__ECORE_OOO_H__*/ 152316485Sdavidcs 153