ecore_ooo.h revision 320164
133965Sjdp/*
2218822Sdim * Copyright (c) 2017-2018 Cavium, Inc.
3130561Sobrien * All rights reserved.
433965Sjdp *
533965Sjdp *  Redistribution and use in source and binary forms, with or without
633965Sjdp *  modification, are permitted provided that the following conditions
733965Sjdp *  are met:
833965Sjdp *
933965Sjdp *  1. Redistributions of source code must retain the above copyright
1033965Sjdp *     notice, this list of conditions and the following disclaimer.
1133965Sjdp *  2. Redistributions in binary form must reproduce the above copyright
1233965Sjdp *     notice, this list of conditions and the following disclaimer in the
1333965Sjdp *     documentation and/or other materials provided with the distribution.
1433965Sjdp *
1533965Sjdp *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1633965Sjdp *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1733965Sjdp *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1833965Sjdp *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1933965Sjdp *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20218822Sdim *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21218822Sdim *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2233965Sjdp *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2333965Sjdp *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2433965Sjdp *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2533965Sjdp *  POSSIBILITY OF SUCH DAMAGE.
2633965Sjdp *
27218822Sdim * $FreeBSD: stable/11/sys/dev/qlnx/qlnxe/ecore_ooo.h 320164 2017-06-20 19:16:06Z davidcs $
2833965Sjdp *
29218822Sdim */
3033965Sjdp
3133965Sjdp#ifndef __ECORE_OOO_H__
3233965Sjdp#define __ECORE_OOO_H__
3333965Sjdp
34130561Sobrien#include "ecore.h"
35130561Sobrien
36130561Sobrien#define ECORE_MAX_NUM_ISLES	256
37130561Sobrien#define ECORE_MAX_NUM_OOO_HISTORY_ENTRIES	512
38130561Sobrien
39130561Sobrien#define ECORE_OOO_LEFT_BUF	0
40130561Sobrien#define ECORE_OOO_RIGHT_BUF	1
41130561Sobrien
4233965Sjdpstruct ecore_ooo_buffer {
4333965Sjdp	osal_list_entry_t	list_entry;
4433965Sjdp	void			*rx_buffer_virt_addr;
4533965Sjdp	dma_addr_t		rx_buffer_phys_addr;
46130561Sobrien	u32			rx_buffer_size;
47130561Sobrien	u16			packet_length;
4833965Sjdp	u16			parse_flags;
49130561Sobrien	u16			vlan;
50130561Sobrien	u8			placement_offset;
5133965Sjdp};
5233965Sjdp
5333965Sjdpstruct ecore_ooo_isle {
5433965Sjdp	osal_list_entry_t	list_entry;
5533965Sjdp	osal_list_t		buffers_list;
5633965Sjdp};
5733965Sjdp
5833965Sjdpstruct ecore_ooo_archipelago {
5933965Sjdp	osal_list_t		isles_list;
6033965Sjdp};
6133965Sjdp
6233965Sjdpstruct ecore_ooo_history {
6333965Sjdp	struct ooo_opaque	*p_cqes;
6433965Sjdp	u32			head_idx;
6533965Sjdp	u32			num_of_cqes;
6633965Sjdp};
6733965Sjdp
6833965Sjdpstruct ecore_ooo_info {
6933965Sjdp	osal_list_t	 free_buffers_list;
7033965Sjdp	osal_list_t	 ready_buffers_list;
7133965Sjdp	osal_list_t	 free_isles_list;
7233965Sjdp	struct ecore_ooo_archipelago	*p_archipelagos_mem;
7333965Sjdp	struct ecore_ooo_isle	*p_isles_mem;
7433965Sjdp	struct ecore_ooo_history	ooo_history;
7533965Sjdp	u32		cur_isles_number;
7633965Sjdp	u32		max_isles_number;
7733965Sjdp	u32		gen_isles_number;
7833965Sjdp	u16		max_num_archipelagos;
7933965Sjdp	u16		cid_base;
8033965Sjdp};
81130561Sobrien
8233965Sjdpenum _ecore_status_t ecore_ooo_alloc(struct ecore_hwfn *p_hwfn);
8333965Sjdp
8433965Sjdpvoid ecore_ooo_setup(struct ecore_hwfn *p_hwfn);
8533965Sjdp
8660484Sobrienvoid ecore_ooo_free(struct ecore_hwfn *p_hwfn);
8760484Sobrien
8833965Sjdpvoid ecore_ooo_save_history_entry(struct ecore_ooo_info *p_ooo_info,
8933965Sjdp				  struct ooo_opaque *p_cqe);
9033965Sjdp
9133965Sjdpvoid ecore_ooo_release_connection_isles(struct ecore_ooo_info *p_ooo_info,
9233965Sjdp					u32 cid);
9333965Sjdp
9433965Sjdpvoid ecore_ooo_release_all_isles(struct ecore_ooo_info *p_ooo_info);
9533965Sjdp
96130561Sobrienvoid ecore_ooo_put_free_buffer(struct ecore_ooo_info *p_ooo_info,
97130561Sobrien			       struct ecore_ooo_buffer *p_buffer);
98130561Sobrien
9933965Sjdpstruct ecore_ooo_buffer *
10033965Sjdpecore_ooo_get_free_buffer(struct ecore_ooo_info *p_ooo_info);
10133965Sjdp
10233965Sjdpvoid ecore_ooo_put_ready_buffer(struct ecore_ooo_info *p_ooo_info,
10333965Sjdp				struct ecore_ooo_buffer *p_buffer, u8 on_tail);
104218822Sdim
105218822Sdimstruct ecore_ooo_buffer *
106218822Sdimecore_ooo_get_ready_buffer(struct ecore_ooo_info *p_ooo_info);
107218822Sdim
108218822Sdimvoid ecore_ooo_delete_isles(struct ecore_hwfn	*p_hwfn,
109218822Sdim			   struct ecore_ooo_info *p_ooo_info,
110218822Sdim			   u32 cid,
11133965Sjdp			   u8 drop_isle,
112130561Sobrien			   u8 drop_size);
11333965Sjdp
114130561Sobrienvoid ecore_ooo_add_new_isle(struct ecore_hwfn	*p_hwfn,
11533965Sjdp			   struct ecore_ooo_info *p_ooo_info,
11633965Sjdp			   u32 cid,
11733965Sjdp			   u8 ooo_isle,
11833965Sjdp			   struct ecore_ooo_buffer *p_buffer);
11933965Sjdp
12033965Sjdpvoid ecore_ooo_add_new_buffer(struct ecore_hwfn	*p_hwfn,
12133965Sjdp			     struct ecore_ooo_info *p_ooo_info,
12233965Sjdp			     u32 cid,
12333965Sjdp			     u8 ooo_isle,
12433965Sjdp			     struct ecore_ooo_buffer *p_buffer,
12533965Sjdp		             u8 buffer_side);
12633965Sjdp
12733965Sjdpvoid ecore_ooo_join_isles(struct ecore_hwfn	*p_hwfn,
12833965Sjdp			 struct ecore_ooo_info *p_ooo_info,
12933965Sjdp			 u32 cid,
13033965Sjdp			 u8 left_isle);
13133965Sjdp
13233965Sjdpvoid ecore_ooo_dump_rx_event(struct ecore_hwfn	*p_hwfn,
13333965Sjdp			     struct ooo_opaque *iscsi_ooo,
13433965Sjdp			     struct ecore_ooo_buffer *p_buffer);
13533965Sjdp
13633965Sjdp#endif  /*__ECORE_OOO_H__*/
137130561Sobrien
13833965Sjdp