111e25f0dSDavid C Somayajulu /*
211e25f0dSDavid C Somayajulu * Copyright (c) 2017-2018 Cavium, Inc.
311e25f0dSDavid C Somayajulu * All rights reserved.
411e25f0dSDavid C Somayajulu *
511e25f0dSDavid C Somayajulu * Redistribution and use in source and binary forms, with or without
611e25f0dSDavid C Somayajulu * modification, are permitted provided that the following conditions
711e25f0dSDavid C Somayajulu * are met:
811e25f0dSDavid C Somayajulu *
911e25f0dSDavid C Somayajulu * 1. Redistributions of source code must retain the above copyright
1011e25f0dSDavid C Somayajulu * notice, this list of conditions and the following disclaimer.
1111e25f0dSDavid C Somayajulu * 2. Redistributions in binary form must reproduce the above copyright
1211e25f0dSDavid C Somayajulu * notice, this list of conditions and the following disclaimer in the
1311e25f0dSDavid C Somayajulu * documentation and/or other materials provided with the distribution.
1411e25f0dSDavid C Somayajulu *
1511e25f0dSDavid C Somayajulu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1611e25f0dSDavid C Somayajulu * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1711e25f0dSDavid C Somayajulu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1811e25f0dSDavid C Somayajulu * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1911e25f0dSDavid C Somayajulu * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2011e25f0dSDavid C Somayajulu * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2111e25f0dSDavid C Somayajulu * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2211e25f0dSDavid C Somayajulu * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2311e25f0dSDavid C Somayajulu * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2411e25f0dSDavid C Somayajulu * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2511e25f0dSDavid C Somayajulu * POSSIBILITY OF SUCH DAMAGE.
2611e25f0dSDavid C Somayajulu *
2711e25f0dSDavid C Somayajulu */
2811e25f0dSDavid C Somayajulu
2911e25f0dSDavid C Somayajulu #ifndef __ECORE_OOO_H__
3011e25f0dSDavid C Somayajulu #define __ECORE_OOO_H__
3111e25f0dSDavid C Somayajulu
3211e25f0dSDavid C Somayajulu #include "ecore.h"
3311e25f0dSDavid C Somayajulu
3411e25f0dSDavid C Somayajulu #define ECORE_MAX_NUM_ISLES 256
3511e25f0dSDavid C Somayajulu #define ECORE_MAX_NUM_OOO_HISTORY_ENTRIES 512
3611e25f0dSDavid C Somayajulu
3711e25f0dSDavid C Somayajulu #define ECORE_OOO_LEFT_BUF 0
3811e25f0dSDavid C Somayajulu #define ECORE_OOO_RIGHT_BUF 1
3911e25f0dSDavid C Somayajulu
4011e25f0dSDavid C Somayajulu struct ecore_ooo_buffer {
4111e25f0dSDavid C Somayajulu osal_list_entry_t list_entry;
4211e25f0dSDavid C Somayajulu void *rx_buffer_virt_addr;
4311e25f0dSDavid C Somayajulu dma_addr_t rx_buffer_phys_addr;
4411e25f0dSDavid C Somayajulu u32 rx_buffer_size;
4511e25f0dSDavid C Somayajulu u16 packet_length;
4611e25f0dSDavid C Somayajulu u16 parse_flags;
4711e25f0dSDavid C Somayajulu u16 vlan;
4811e25f0dSDavid C Somayajulu u8 placement_offset;
4911e25f0dSDavid C Somayajulu };
5011e25f0dSDavid C Somayajulu
5111e25f0dSDavid C Somayajulu struct ecore_ooo_isle {
5211e25f0dSDavid C Somayajulu osal_list_entry_t list_entry;
5311e25f0dSDavid C Somayajulu osal_list_t buffers_list;
5411e25f0dSDavid C Somayajulu };
5511e25f0dSDavid C Somayajulu
5611e25f0dSDavid C Somayajulu struct ecore_ooo_archipelago {
5711e25f0dSDavid C Somayajulu osal_list_t isles_list;
5811e25f0dSDavid C Somayajulu };
5911e25f0dSDavid C Somayajulu
6011e25f0dSDavid C Somayajulu struct ecore_ooo_history {
6111e25f0dSDavid C Somayajulu struct ooo_opaque *p_cqes;
6211e25f0dSDavid C Somayajulu u32 head_idx;
6311e25f0dSDavid C Somayajulu u32 num_of_cqes;
6411e25f0dSDavid C Somayajulu };
6511e25f0dSDavid C Somayajulu
6611e25f0dSDavid C Somayajulu struct ecore_ooo_info {
6711e25f0dSDavid C Somayajulu osal_list_t free_buffers_list;
6811e25f0dSDavid C Somayajulu osal_list_t ready_buffers_list;
6911e25f0dSDavid C Somayajulu osal_list_t free_isles_list;
7011e25f0dSDavid C Somayajulu struct ecore_ooo_archipelago *p_archipelagos_mem;
7111e25f0dSDavid C Somayajulu struct ecore_ooo_isle *p_isles_mem;
7211e25f0dSDavid C Somayajulu struct ecore_ooo_history ooo_history;
7311e25f0dSDavid C Somayajulu u32 cur_isles_number;
7411e25f0dSDavid C Somayajulu u32 max_isles_number;
7511e25f0dSDavid C Somayajulu u32 gen_isles_number;
7611e25f0dSDavid C Somayajulu u16 max_num_archipelagos;
7711e25f0dSDavid C Somayajulu u16 cid_base;
7811e25f0dSDavid C Somayajulu };
7911e25f0dSDavid C Somayajulu
80*217ec208SDavid C Somayajulu #if defined(CONFIG_ECORE_ISCSI) || defined(CONFIG_ECORE_IWARP)
8111e25f0dSDavid C Somayajulu enum _ecore_status_t ecore_ooo_alloc(struct ecore_hwfn *p_hwfn);
8211e25f0dSDavid C Somayajulu
8311e25f0dSDavid C Somayajulu void ecore_ooo_setup(struct ecore_hwfn *p_hwfn);
8411e25f0dSDavid C Somayajulu
8511e25f0dSDavid C Somayajulu void ecore_ooo_free(struct ecore_hwfn *p_hwfn);
86*217ec208SDavid C Somayajulu #else
87*217ec208SDavid C Somayajulu static inline enum _ecore_status_t
ecore_ooo_alloc(struct ecore_hwfn OSAL_UNUSED * p_hwfn)88*217ec208SDavid C Somayajulu ecore_ooo_alloc(struct ecore_hwfn OSAL_UNUSED *p_hwfn)
89*217ec208SDavid C Somayajulu {
90*217ec208SDavid C Somayajulu return ECORE_INVAL;
91*217ec208SDavid C Somayajulu }
92*217ec208SDavid C Somayajulu
93*217ec208SDavid C Somayajulu static inline void
ecore_ooo_setup(struct ecore_hwfn OSAL_UNUSED * p_hwfn)94*217ec208SDavid C Somayajulu ecore_ooo_setup(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {}
95*217ec208SDavid C Somayajulu
96*217ec208SDavid C Somayajulu static inline void
ecore_ooo_free(struct ecore_hwfn OSAL_UNUSED * p_hwfn)97*217ec208SDavid C Somayajulu ecore_ooo_free(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {}
98*217ec208SDavid C Somayajulu #endif
99*217ec208SDavid C Somayajulu
1009efd0ba7SDavid C Somayajulu void ecore_ooo_save_history_entry(struct ecore_ooo_info *p_ooo_info,
10111e25f0dSDavid C Somayajulu struct ooo_opaque *p_cqe);
10211e25f0dSDavid C Somayajulu
1039efd0ba7SDavid C Somayajulu void ecore_ooo_release_connection_isles(struct ecore_ooo_info *p_ooo_info,
10411e25f0dSDavid C Somayajulu u32 cid);
10511e25f0dSDavid C Somayajulu
1069efd0ba7SDavid C Somayajulu void ecore_ooo_release_all_isles(struct ecore_ooo_info *p_ooo_info);
10711e25f0dSDavid C Somayajulu
1089efd0ba7SDavid C Somayajulu void ecore_ooo_put_free_buffer(struct ecore_ooo_info *p_ooo_info,
10911e25f0dSDavid C Somayajulu struct ecore_ooo_buffer *p_buffer);
11011e25f0dSDavid C Somayajulu
11111e25f0dSDavid C Somayajulu struct ecore_ooo_buffer *
1129efd0ba7SDavid C Somayajulu ecore_ooo_get_free_buffer(struct ecore_ooo_info *p_ooo_info);
11311e25f0dSDavid C Somayajulu
1149efd0ba7SDavid C Somayajulu void ecore_ooo_put_ready_buffer(struct ecore_ooo_info *p_ooo_info,
1159efd0ba7SDavid C Somayajulu struct ecore_ooo_buffer *p_buffer, u8 on_tail);
11611e25f0dSDavid C Somayajulu
11711e25f0dSDavid C Somayajulu struct ecore_ooo_buffer *
1189efd0ba7SDavid C Somayajulu ecore_ooo_get_ready_buffer(struct ecore_ooo_info *p_ooo_info);
11911e25f0dSDavid C Somayajulu
12011e25f0dSDavid C Somayajulu void ecore_ooo_delete_isles(struct ecore_hwfn *p_hwfn,
12111e25f0dSDavid C Somayajulu struct ecore_ooo_info *p_ooo_info,
12211e25f0dSDavid C Somayajulu u32 cid,
12311e25f0dSDavid C Somayajulu u8 drop_isle,
12411e25f0dSDavid C Somayajulu u8 drop_size);
12511e25f0dSDavid C Somayajulu
12611e25f0dSDavid C Somayajulu void ecore_ooo_add_new_isle(struct ecore_hwfn *p_hwfn,
12711e25f0dSDavid C Somayajulu struct ecore_ooo_info *p_ooo_info,
12811e25f0dSDavid C Somayajulu u32 cid,
12911e25f0dSDavid C Somayajulu u8 ooo_isle,
13011e25f0dSDavid C Somayajulu struct ecore_ooo_buffer *p_buffer);
13111e25f0dSDavid C Somayajulu
13211e25f0dSDavid C Somayajulu void ecore_ooo_add_new_buffer(struct ecore_hwfn *p_hwfn,
13311e25f0dSDavid C Somayajulu struct ecore_ooo_info *p_ooo_info,
13411e25f0dSDavid C Somayajulu u32 cid,
13511e25f0dSDavid C Somayajulu u8 ooo_isle,
13611e25f0dSDavid C Somayajulu struct ecore_ooo_buffer *p_buffer,
13711e25f0dSDavid C Somayajulu u8 buffer_side);
13811e25f0dSDavid C Somayajulu
13911e25f0dSDavid C Somayajulu void ecore_ooo_join_isles(struct ecore_hwfn *p_hwfn,
14011e25f0dSDavid C Somayajulu struct ecore_ooo_info *p_ooo_info,
14111e25f0dSDavid C Somayajulu u32 cid,
14211e25f0dSDavid C Somayajulu u8 left_isle);
14311e25f0dSDavid C Somayajulu
14411e25f0dSDavid C Somayajulu void ecore_ooo_dump_rx_event(struct ecore_hwfn *p_hwfn,
14511e25f0dSDavid C Somayajulu struct ooo_opaque *iscsi_ooo,
14611e25f0dSDavid C Somayajulu struct ecore_ooo_buffer *p_buffer);
14711e25f0dSDavid C Somayajulu
14811e25f0dSDavid C Somayajulu #endif /*__ECORE_OOO_H__*/
149