ecore_ooo.h revision 316485
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: head/sys/dev/qlnx/qlnxe/ecore_ooo.h 316485 2017-04-04 06:16:59Z 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
82316485Sdavidcsenum _ecore_status_t ecore_ooo_alloc(struct ecore_hwfn *p_hwfn);
83316485Sdavidcs
84316485Sdavidcsvoid ecore_ooo_setup(struct ecore_hwfn *p_hwfn);
85316485Sdavidcs
86316485Sdavidcsvoid ecore_ooo_free(struct ecore_hwfn *p_hwfn);
87316485Sdavidcs
88316485Sdavidcsvoid ecore_ooo_save_history_entry(struct ecore_hwfn       *p_hwfn,
89316485Sdavidcs				       struct ecore_ooo_info *p_ooo_info,
90316485Sdavidcs				       struct ooo_opaque *p_cqe);
91316485Sdavidcs
92316485Sdavidcsvoid ecore_ooo_release_connection_isles(struct ecore_hwfn       *p_hwfn,
93316485Sdavidcs				       struct ecore_ooo_info *p_ooo_info,
94316485Sdavidcs				       u32 cid);
95316485Sdavidcs
96316485Sdavidcsvoid ecore_ooo_release_all_isles(struct ecore_hwfn       *p_hwfn,
97316485Sdavidcs				struct ecore_ooo_info *p_ooo_info);
98316485Sdavidcs
99316485Sdavidcsvoid ecore_ooo_put_free_buffer(struct ecore_hwfn	*p_hwfn,
100316485Sdavidcs			      struct ecore_ooo_info	*p_ooo_info,
101316485Sdavidcs			      struct ecore_ooo_buffer	*p_buffer);
102316485Sdavidcs
103316485Sdavidcsstruct ecore_ooo_buffer *
104316485Sdavidcs	ecore_ooo_get_free_buffer(struct ecore_hwfn	*p_hwfn,
105316485Sdavidcs				 struct ecore_ooo_info *p_ooo_info);
106316485Sdavidcs
107316485Sdavidcsvoid ecore_ooo_put_ready_buffer(struct ecore_hwfn	*p_hwfn,
108316485Sdavidcs			      struct ecore_ooo_info	*p_ooo_info,
109316485Sdavidcs			      struct ecore_ooo_buffer	*p_buffer,
110316485Sdavidcs			      u8 on_tail);
111316485Sdavidcs
112316485Sdavidcsstruct ecore_ooo_buffer *
113316485Sdavidcs	ecore_ooo_get_ready_buffer(struct ecore_hwfn	*p_hwfn,
114316485Sdavidcs				  struct ecore_ooo_info *p_ooo_info);
115316485Sdavidcs
116316485Sdavidcsvoid ecore_ooo_delete_isles(struct ecore_hwfn	*p_hwfn,
117316485Sdavidcs			   struct ecore_ooo_info *p_ooo_info,
118316485Sdavidcs			   u32 cid,
119316485Sdavidcs			   u8 drop_isle,
120316485Sdavidcs			   u8 drop_size);
121316485Sdavidcs
122316485Sdavidcsvoid ecore_ooo_add_new_isle(struct ecore_hwfn	*p_hwfn,
123316485Sdavidcs			   struct ecore_ooo_info *p_ooo_info,
124316485Sdavidcs			   u32 cid,
125316485Sdavidcs			   u8 ooo_isle,
126316485Sdavidcs			   struct ecore_ooo_buffer *p_buffer);
127316485Sdavidcs
128316485Sdavidcsvoid ecore_ooo_add_new_buffer(struct ecore_hwfn	*p_hwfn,
129316485Sdavidcs			     struct ecore_ooo_info *p_ooo_info,
130316485Sdavidcs			     u32 cid,
131316485Sdavidcs			     u8 ooo_isle,
132316485Sdavidcs			     struct ecore_ooo_buffer *p_buffer,
133316485Sdavidcs		             u8 buffer_side);
134316485Sdavidcs
135316485Sdavidcsvoid ecore_ooo_join_isles(struct ecore_hwfn	*p_hwfn,
136316485Sdavidcs			 struct ecore_ooo_info *p_ooo_info,
137316485Sdavidcs			 u32 cid,
138316485Sdavidcs			 u8 left_isle);
139316485Sdavidcs
140316485Sdavidcsvoid ecore_ooo_dump_rx_event(struct ecore_hwfn	*p_hwfn,
141316485Sdavidcs			     struct ooo_opaque *iscsi_ooo,
142316485Sdavidcs			     struct ecore_ooo_buffer *p_buffer);
143316485Sdavidcs
144316485Sdavidcs#endif  /*__ECORE_OOO_H__*/
145316485Sdavidcs
146